/// <summary>Write soil to XML</summary> /// <param name="soil">The soil.</param> /// <returns></returns> public static string ToXML(Soil soil) { XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer x = new XmlSerializer(typeof(Soil)); StringWriter Out = new StringWriter(); x.Serialize(Out, soil, ns); string st = Out.ToString(); if (st.Length > 5 && st.Substring(0, 5) == "<?xml") { // remove the first line: <?xml version="1.0"?>/n int posEol = st.IndexOf("\n"); if (posEol != -1) { return(st.Substring(posEol + 1)); } } return(st); }
/// <summary>Return the index of the layer that contains the specified depth.</summary> /// <param name="soil">The soil</param> /// <param name="depth">The depth to search for.</param> /// <returns></returns> static public int FindLayerIndex(Soil soil, double depth) { return(Array.FindIndex(ToCumThickness(soil.Water.Thickness), d => d >= depth)); }
/// <summary>Return the plant available water CAPACITY of the soil. Units: mm</summary> /// <param name="soil">The soil to calculate PAWC for.</param> public static double[] OfSoilmm(Soil soil) { double[] pawc = OfSoil(soil); return(MathUtilities.Multiply(pawc, soil.Water.Thickness)); }
/// <summary>Return the plant available water CAPACITY for the specified crop. Units: mm</summary> /// <param name="soil">The soil to calculate PAWC for.</param> /// <param name="crop">The crop.</param> /// <returns></returns> public static double[] OfCropmm(Soil soil, SoilCrop crop) { double[] pawc = PAWC.OfCrop(soil, crop); return(MathUtilities.Multiply(pawc, soil.Water.Thickness)); }
/// <summary>Return the plant available water CAPACITY of the soil. Units: mm/mm</summary> /// <param name="soil">The soil to calculate PAWC for.</param> public static double[] OfSoil(Soil soil) { return(PAWCInternal(soil.Water.Thickness, soil.Water.LL15, soil.Water.DUL, null)); }