| | 1 | | using System; |
| | 2 | | using System.Linq; |
| | 3 | |
|
| | 4 | | namespace Morpho25.Settings |
| | 5 | | { |
| | 6 | | public enum MRTCalculationMethod |
| | 7 | | { |
| | 8 | | TwoDirectional = 0, |
| | 9 | | SixDirectional = 1, |
| | 10 | | } |
| | 11 | |
|
| | 12 | | public enum MRTProjectionMethod |
| | 13 | | { |
| | 14 | | Envimet = 0, |
| | 15 | | Solweig = 1, |
| | 16 | | Rayman = 2, |
| | 17 | | CityComfort = 3, |
| | 18 | | } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// IVS class. |
| | 22 | | /// </summary> |
| | 23 | | public class RadScheme |
| | 24 | | { |
| 1 | 25 | | public static readonly int[] AngleCategory = new[] { 2, 5, 10, 15, 30, 45, -1 }; |
| | 26 | |
|
| 1 | 27 | | private static readonly double[][] Steps = new double[][]{ |
| 1 | 28 | | new double[] { 0.25000, 0.50000 }, |
| 1 | 29 | | new double[] { 0.50000, 0.75000 } |
| 1 | 30 | | }; |
| | 31 | |
|
| | 32 | | private int _ivsHeightAngleHighRes; |
| | 33 | | private int _ivsAzimutAngleHighRes; |
| | 34 | | private double _heightCap; |
| | 35 | | private Active _lowResolution; |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Height angle for IVS calculation |
| | 39 | | /// </summary> |
| | 40 | | public int IVSHeightAngleHighRes |
| | 41 | | { |
| | 42 | | get |
| 19 | 43 | | { |
| 19 | 44 | | return _ivsHeightAngleHighRes; |
| 19 | 45 | | } |
| | 46 | | set |
| 4 | 47 | | { |
| 4 | 48 | | if (!AngleCategory.Contains(value)) |
| 0 | 49 | | throw new Exception("Value must be 2, 5, 10, 15, 30, 45"); |
| 4 | 50 | | _ivsHeightAngleHighRes = value; |
| 4 | 51 | | UpdateCalculatedFields(); |
| 4 | 52 | | } |
| | 53 | | } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Raytracing precision |
| | 57 | | /// </summary> |
| | 58 | | public Active LowResolution |
| | 59 | | { |
| | 60 | | get |
| 0 | 61 | | { |
| 0 | 62 | | return _lowResolution; |
| 0 | 63 | | } |
| | 64 | | set |
| 2 | 65 | | { |
| 2 | 66 | | _lowResolution = value; |
| 2 | 67 | | if (_lowResolution == Active.NO) |
| 2 | 68 | | { |
| 2 | 69 | | HighStep = Steps[0][0]; |
| 2 | 70 | | LowStep = Steps[0][1]; |
| 2 | 71 | | } |
| | 72 | | else |
| 0 | 73 | | { |
| 0 | 74 | | HighStep = Steps[1][0]; |
| 0 | 75 | | LowStep = Steps[1][1]; |
| 0 | 76 | | } |
| 2 | 77 | | } |
| | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> |
| | 81 | | /// Advance canopy radiation transfer module |
| | 82 | | /// </summary> |
| 5 | 83 | | public Active AdvCanopyRadTransfer { get; set; } |
| | 84 | |
|
| | 85 | | /// <summary> |
| | 86 | | /// Update interval for View Factor calculation |
| | 87 | | /// </summary> |
| 3 | 88 | | public uint ViewFactorInterval { get; set; } |
| | 89 | |
|
| | 90 | | /// <summary> |
| | 91 | | /// Raytrace step eidth high resolution |
| | 92 | | /// </summary> |
| 3 | 93 | | public double HighStep { get; private set; } |
| | 94 | |
|
| | 95 | | /// <summary> |
| | 96 | | /// Raytrace step eidth low resolution |
| | 97 | | /// </summary> |
| 3 | 98 | | public double LowStep { get; private set; } |
| | 99 | |
|
| | 100 | | /// <summary> |
| | 101 | | /// MRT Calculation method |
| | 102 | | /// </summary> |
| 6 | 103 | | public MRTCalculationMethod MRTCalculationMethod { get; set; } |
| | 104 | |
|
| | 105 | | /// <summary> |
| | 106 | | /// Human projector factor |
| | 107 | | /// </summary> |
| 6 | 108 | | public MRTProjectionMethod MRTProjectionMethod { get; set; } |
| | 109 | |
|
| | 110 | | /// <summary> |
| | 111 | | /// Azimut angle for IVS calculation |
| | 112 | | /// </summary> |
| | 113 | | public int IVSAzimutAngleHighRes |
| | 114 | | { |
| | 115 | | get |
| 19 | 116 | | { |
| 19 | 117 | | return _ivsAzimutAngleHighRes; |
| 19 | 118 | | } |
| | 119 | | set |
| 4 | 120 | | { |
| 4 | 121 | | if (!AngleCategory.Contains(value)) |
| 0 | 122 | | throw new Exception("Value must be 2, 5, 10, 15, 30, 45"); |
| 4 | 123 | | _ivsAzimutAngleHighRes = value; |
| 4 | 124 | | UpdateCalculatedFields(); |
| 4 | 125 | | } |
| | 126 | | } |
| | 127 | |
|
| | 128 | | /// <summary> |
| | 129 | | /// Height angle for IVS calculation (low resolution) |
| | 130 | | /// </summary> |
| 14 | 131 | | public int IVSHeightAngleLowRes { get; private set; } |
| | 132 | |
|
| | 133 | | /// <summary> |
| | 134 | | /// Azimut angle for IVS calculation (low resolution) |
| | 135 | | /// </summary> |
| 14 | 136 | | public int IVSAzimutAngleLowRes { get; private set; } |
| | 137 | |
|
| | 138 | | /// <summary> |
| | 139 | | /// Height cap in meters above ground below which higher precision is used |
| | 140 | | /// </summary> |
| | 141 | | public double RadiationHeightBoundary |
| | 142 | | { |
| | 143 | | get |
| 25 | 144 | | { |
| 25 | 145 | | return _heightCap; |
| 25 | 146 | | } |
| | 147 | | set |
| 4 | 148 | | { |
| 4 | 149 | | _heightCap = value; |
| 4 | 150 | | UpdateCalculatedFields(); |
| 4 | 151 | | } |
| | 152 | | } |
| | 153 | |
|
| | 154 | | private void UpdateCalculatedFields() |
| 12 | 155 | | { |
| 12 | 156 | | if (RadiationHeightBoundary < 0) |
| 6 | 157 | | { |
| 6 | 158 | | IVSHeightAngleLowRes = IVSHeightAngleHighRes; |
| 6 | 159 | | } |
| | 160 | | else |
| 6 | 161 | | { |
| 6 | 162 | | var hIndex = AngleCategory.ToList().IndexOf(IVSHeightAngleHighRes); |
| 10 | 163 | | if (IVSHeightAngleHighRes == -1) hIndex -= 1; |
| | 164 | |
|
| 6 | 165 | | IVSHeightAngleLowRes = AngleCategory.ElementAt(hIndex + 1); |
| 6 | 166 | | } |
| | 167 | |
|
| 12 | 168 | | if (RadiationHeightBoundary < 0) |
| 6 | 169 | | { |
| 6 | 170 | | IVSAzimutAngleLowRes = IVSAzimutAngleHighRes; |
| 6 | 171 | | } |
| | 172 | | else |
| 6 | 173 | | { |
| 6 | 174 | | var aIndex = AngleCategory.ToList().IndexOf(IVSAzimutAngleHighRes); |
| 8 | 175 | | if (IVSAzimutAngleHighRes == -1) aIndex -= 1; |
| | 176 | |
|
| 6 | 177 | | IVSAzimutAngleLowRes = AngleCategory.ElementAt(aIndex + 1); |
| 6 | 178 | | } |
| 12 | 179 | | } |
| | 180 | |
|
| | 181 | | /// <summary> |
| | 182 | | /// Create new radiation settings |
| | 183 | | /// </summary> |
| 2 | 184 | | public RadScheme() |
| 2 | 185 | | { |
| 2 | 186 | | IVSHeightAngleHighRes = -1; |
| 2 | 187 | | IVSAzimutAngleHighRes = -1; |
| 2 | 188 | | RadiationHeightBoundary = -1; |
| 2 | 189 | | LowResolution = Active.NO; |
| 2 | 190 | | AdvCanopyRadTransfer = Active.YES; |
| 2 | 191 | | ViewFactorInterval = 10; |
| 2 | 192 | | MRTCalculationMethod = MRTCalculationMethod.TwoDirectional; |
| 2 | 193 | | MRTProjectionMethod = MRTProjectionMethod.Envimet; |
| 2 | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> |
| | 197 | | /// Title of the XML section |
| | 198 | | /// </summary> |
| 1 | 199 | | public string Title => "RadScheme"; |
| | 200 | |
|
| | 201 | | /// <summary> |
| | 202 | | /// Values of the XML section |
| | 203 | | /// </summary> |
| 1 | 204 | | public string[] Values => new [] { |
| 1 | 205 | | IVSHeightAngleHighRes.ToString(), |
| 1 | 206 | | IVSAzimutAngleHighRes.ToString(), |
| 1 | 207 | | IVSHeightAngleLowRes.ToString(), |
| 1 | 208 | | IVSAzimutAngleLowRes.ToString(), |
| 1 | 209 | | ((int)AdvCanopyRadTransfer).ToString(), |
| 1 | 210 | | ViewFactorInterval.ToString(), |
| 1 | 211 | | HighStep.ToString("n6"), |
| 1 | 212 | | LowStep.ToString("n6"), |
| 1 | 213 | | RadiationHeightBoundary.ToString("n6"), |
| 1 | 214 | | ((int)MRTCalculationMethod).ToString(), |
| 1 | 215 | | ((int)MRTProjectionMethod).ToString(), |
| 1 | 216 | | }; |
| | 217 | |
|
| | 218 | | /// <summary> |
| | 219 | | /// Tags of the XML section |
| | 220 | | /// </summary> |
| 1 | 221 | | public string[] Tags => new [] { |
| 1 | 222 | | "IVSHeightAngle_HiRes", |
| 1 | 223 | | "IVSAziAngle_HiRes", |
| 1 | 224 | | "IVSHeightAngle_LoRes", |
| 1 | 225 | | "IVSAziAngle_LoRes", |
| 1 | 226 | | "AdvCanopyRadTransfer", |
| 1 | 227 | | "ViewFacUpdateInterval", |
| 1 | 228 | | "RayTraceStepWidthHighRes", |
| 1 | 229 | | "RayTraceStepWidthLowRes", |
| 1 | 230 | | "RadiationHeightBoundary", |
| 1 | 231 | | "MRTCalcMethod", |
| 1 | 232 | | "MRTProjFac", |
| 1 | 233 | | }; |
| | 234 | |
|
| | 235 | | /// <summary> |
| | 236 | | /// String representation of IVS. |
| | 237 | | /// </summary> |
| | 238 | | /// <returns>String representation.</returns> |
| 0 | 239 | | public override string ToString() => "Config::RadScheme"; |
| | 240 | | } |
| | 241 | |
|
| | 242 | | } |