public SimulationEngine(SimDateTime sdtStart, int totalDays, int nofSnapshots) { SimDateTime sdtSimEnd = sdtStart.AddHours((int)(AbsoluteConstants.HoursPerDay * totalDays)); Console.WriteLine(string.Format("Simulation params: starting at: {0}, ending at: {1}, total days: {2} ...", sdtStart, sdtSimEnd, totalDays)); // The length of the baseline is equal to the total number of days. _simLength = totalDays; _snapshotLength = (int)(AbsoluteConstants.HoursPerDay / nofSnapshots); Console.WriteLine(string.Format(" -> snapshot: {0} hrs, total sim length: {1} days...", _snapshotLength, _simLength)); Console.WriteLine("********"); Console.WriteLine("Using parameters:"); Console.Write(SimulationParameters.Instance.ToString()); Console.WriteLine("********"); _simStart = sdtStart; SimDateTime sdtBaselineEnd = _simStart.AddHours((int)(AbsoluteConstants.HoursPerDay * _simLength)); _sim = new Simulation(sdtStart, sdtBaselineEnd, _snapshotLength, false); _sim.ID = 0; }
public static float GetRefTempYearlyDelta_MidLevel(EarthModel earth, int r, int c) { string key = string.Format("{0}_{1}", r, c); lock (_refTempYearlyDelta) { if (_refTempYearlyDelta.ContainsKey(key) == false) { float tRefMin = 100; float tRefMax = -100; SimDateTime sdtStart = earth.UTC; for (int i = 0; i < 365; i += 5) { SimDateTime sdt = sdtStart.AddHours((int)AbsoluteConstants.HoursPerDay * i); float tRef = GetRefTemp(earth, sdt, r, c); tRefMin = Math.Min(tRefMin, tRef); tRefMax = Math.Max(tRefMax, tRef); } float delta = (tRefMax - tRefMin); _refTempYearlyDelta.Add(key, delta); } } return(_refTempYearlyDelta[key]); }
private bool CanSelectSnapshot(int offset) { if (offset == short.MinValue || offset == short.MaxValue) { return(true); } if (_crtSnapshot != null && _min != null && _max != null) { try { SimDateTime sdt = _crtSnapshot.AddHours(offset); return(_min.GetHoursOffset(sdt) <= 0 && sdt.GetHoursOffset(_max) <= 0); } catch { } } return(false); }
public static float GetSunLatitude_Radians(SimDateTime sdt) { float delay = SimulationParameters.Instance.Delay * AbsoluteConstants.HoursPerDay; SimDateTime actualSdt = sdt.AddHours((int)delay); int yday = actualSdt.DayOfYear; lock (_sunLatitude) { if (_sunLatitude.ContainsKey(yday) == false) { float p = (float)Math.Asin(0.39795f * (float)Math.Cos(0.2163108f + 2 * (float)Math.Atan(0.9671396f * (float)Math.Tan(0.00860f * (yday - 182.625f))))); _sunLatitude.Add(yday, p); } } return(_sunLatitude[yday]); }
private void ProcessSimRange(DateTime dtInit, SimDateTime firstSnapshotStart, int rangeSize, int idx) { //-------------------------------- TimeSpan tsDiff = DateTime.Now - dtInit; SimDateTime dtStart = firstSnapshotStart.AddHours((int)(AbsoluteConstants.HoursPerDay * rangeSize * (idx))); Console.WriteLine(string.Format("STAT: Initializing range {0} + {2}days [elapsed {1} msec]", dtStart, (int)tsDiff.TotalMilliseconds, rangeSize)); SimDateTimeRange sdtr = SimDateTimeRange.BuildRange(dtStart, rangeSize); if (sdtr == null) { return; } tsDiff = DateTime.Now - dtInit; Console.WriteLine(string.Format("STAT: Starting processing on range {0} [elapsed {1} msec]", sdtr, (int)tsDiff.TotalMilliseconds)); var c1 = sdtr.AtmList.Count; var c2 = sdtr.SfcList.Count; if (c1 <= 0 || c2 <= 0 || c1 != c2) { return; } SimDateTimeRangeStats stats = sdtr.BuildStatistics(); stats.Save(sdtr.Start.Title); tsDiff = DateTime.Now - dtInit; Console.WriteLine(string.Format("STAT: Done range {0} [elapsed {1} msec]", sdtr, (int)tsDiff.TotalMilliseconds)); _doneEvents[idx].Set(); //-------------------------------- }