< Summary

Information
Class: Morpho25.Settings.RadScheme
Assembly: Morpho25
File(s): D:\a\Morpho\Morpho\project\Morpho\Morpho25\Settings\RadScheme.cs
Line coverage
91%
Covered lines: 102
Uncovered lines: 10
Coverable lines: 112
Total lines: 242
Line coverage: 91%
Branch coverage
78%
Covered branches: 11
Total branches: 14
Branch coverage: 78.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

D:\a\Morpho\Morpho\project\Morpho\Morpho25\Settings\RadScheme.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3
 4namespace 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    {
 125        public static readonly int[] AngleCategory = new[] { 2, 5, 10, 15, 30, 45, -1 };
 26
 127        private static readonly double[][] Steps = new double[][]{
 128            new double[] { 0.25000, 0.50000 },
 129            new double[] { 0.50000, 0.75000 }
 130        };
 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
 1943            {
 1944                return _ivsHeightAngleHighRes;
 1945            }
 46            set
 447            {
 448                if (!AngleCategory.Contains(value))
 049                    throw new Exception("Value must be 2, 5, 10, 15, 30, 45");
 450                _ivsHeightAngleHighRes = value;
 451                UpdateCalculatedFields();
 452            }
 53        }
 54
 55        /// <summary>
 56        /// Raytracing precision
 57        /// </summary>
 58        public Active LowResolution
 59        {
 60            get
 061            {
 062                return _lowResolution;
 063            }
 64            set
 265            {
 266                _lowResolution = value;
 267                if (_lowResolution == Active.NO)
 268                {
 269                    HighStep = Steps[0][0];
 270                    LowStep = Steps[0][1];
 271                }
 72                else
 073                {
 074                    HighStep = Steps[1][0];
 075                    LowStep = Steps[1][1];
 076                }
 277            }
 78        }
 79
 80        /// <summary>
 81        /// Advance canopy radiation transfer module
 82        /// </summary>
 583        public Active AdvCanopyRadTransfer { get; set; }
 84
 85        /// <summary>
 86        /// Update interval for View Factor calculation
 87        /// </summary>
 388        public uint ViewFactorInterval { get; set; }
 89
 90        /// <summary>
 91        /// Raytrace step eidth high resolution
 92        /// </summary>
 393        public double HighStep { get; private set; }
 94
 95        /// <summary>
 96        /// Raytrace step eidth low resolution
 97        /// </summary>
 398        public double LowStep { get; private set; }
 99
 100        /// <summary>
 101        /// MRT Calculation method
 102        /// </summary>
 6103        public MRTCalculationMethod MRTCalculationMethod { get; set; }
 104
 105        /// <summary>
 106        /// Human projector factor
 107        /// </summary>
 6108        public MRTProjectionMethod MRTProjectionMethod { get; set; }
 109
 110        /// <summary>
 111        /// Azimut angle for IVS calculation
 112        /// </summary>
 113        public int IVSAzimutAngleHighRes
 114        {
 115            get
 19116            {
 19117                return _ivsAzimutAngleHighRes;
 19118            }
 119            set
 4120            {
 4121                if (!AngleCategory.Contains(value))
 0122                    throw new Exception("Value must be 2, 5, 10, 15, 30, 45");
 4123                _ivsAzimutAngleHighRes = value;
 4124                UpdateCalculatedFields();
 4125            }
 126        }
 127
 128        /// <summary>
 129        /// Height angle for IVS calculation (low resolution)
 130        /// </summary>
 14131        public int IVSHeightAngleLowRes { get; private set; }
 132
 133        /// <summary>
 134        /// Azimut angle for IVS calculation (low resolution)
 135        /// </summary>
 14136        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
 25144            {
 25145                return _heightCap;
 25146            }
 147            set
 4148            {
 4149                _heightCap = value;
 4150                UpdateCalculatedFields();
 4151            }
 152        }
 153
 154        private void UpdateCalculatedFields()
 12155        {
 12156            if (RadiationHeightBoundary < 0)
 6157            {
 6158                IVSHeightAngleLowRes = IVSHeightAngleHighRes;
 6159            }
 160            else
 6161            {
 6162                var hIndex = AngleCategory.ToList().IndexOf(IVSHeightAngleHighRes);
 10163                if (IVSHeightAngleHighRes == -1) hIndex -= 1;
 164
 6165                IVSHeightAngleLowRes = AngleCategory.ElementAt(hIndex + 1);
 6166            }
 167
 12168            if (RadiationHeightBoundary < 0)
 6169            {
 6170                IVSAzimutAngleLowRes = IVSAzimutAngleHighRes;
 6171            }
 172            else
 6173            {
 6174                var aIndex = AngleCategory.ToList().IndexOf(IVSAzimutAngleHighRes);
 8175                if (IVSAzimutAngleHighRes == -1) aIndex -= 1;
 176
 6177                IVSAzimutAngleLowRes = AngleCategory.ElementAt(aIndex + 1);
 6178            }
 12179        }
 180
 181        /// <summary>
 182        /// Create new radiation settings
 183        /// </summary>
 2184        public RadScheme()
 2185        {
 2186            IVSHeightAngleHighRes = -1;
 2187            IVSAzimutAngleHighRes = -1;
 2188            RadiationHeightBoundary = -1;
 2189            LowResolution = Active.NO;
 2190            AdvCanopyRadTransfer = Active.YES;
 2191            ViewFactorInterval = 10;
 2192            MRTCalculationMethod = MRTCalculationMethod.TwoDirectional;
 2193            MRTProjectionMethod = MRTProjectionMethod.Envimet;
 2194        }
 195
 196        /// <summary>
 197        /// Title of the XML section
 198        /// </summary>
 1199        public string Title => "RadScheme";
 200
 201        /// <summary>
 202        /// Values of the XML section
 203        /// </summary>
 1204        public string[] Values => new [] {
 1205            IVSHeightAngleHighRes.ToString(),
 1206            IVSAzimutAngleHighRes.ToString(),
 1207            IVSHeightAngleLowRes.ToString(),
 1208            IVSAzimutAngleLowRes.ToString(),
 1209            ((int)AdvCanopyRadTransfer).ToString(),
 1210            ViewFactorInterval.ToString(),
 1211            HighStep.ToString("n6"),
 1212            LowStep.ToString("n6"),
 1213            RadiationHeightBoundary.ToString("n6"),
 1214            ((int)MRTCalculationMethod).ToString(),
 1215            ((int)MRTProjectionMethod).ToString(),
 1216        };
 217
 218        /// <summary>
 219        /// Tags of the XML section
 220        /// </summary>
 1221        public string[] Tags => new [] {
 1222            "IVSHeightAngle_HiRes",
 1223            "IVSAziAngle_HiRes",
 1224            "IVSHeightAngle_LoRes",
 1225            "IVSAziAngle_LoRes",
 1226            "AdvCanopyRadTransfer",
 1227            "ViewFacUpdateInterval",
 1228            "RayTraceStepWidthHighRes",
 1229            "RayTraceStepWidthLowRes",
 1230            "RadiationHeightBoundary",
 1231            "MRTCalcMethod",
 1232            "MRTProjFac",
 1233        };
 234
 235        /// <summary>
 236        /// String representation of IVS.
 237        /// </summary>
 238        /// <returns>String representation.</returns>
 0239        public override string ToString() => "Config::RadScheme";
 240    }
 241
 242}