Skip to content

Commit a855750

Browse files
authored
Merge pull request #10 from mcrossley/master
v1.3.0 - CMX v3.20.0 support
2 parents 3968ef5 + 2af1a95 commit a855750

6 files changed

Lines changed: 265 additions & 80 deletions

File tree

CreateMissing.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
6-
<AssemblyVersion>1.2.1.0</AssemblyVersion>
7-
<FileVersion>1.2.1.0</FileVersion>
8-
<Version>1.2.1</Version>
6+
<AssemblyVersion>1.3.0.1</AssemblyVersion>
7+
<FileVersion>1.3.0.1</FileVersion>
8+
<Version></Version>
99
<StartupObject>CreateMissing.Program</StartupObject>
1010
<TargetFramework>net48</TargetFramework>
1111
<Authors>Mark Crossley</Authors>

Cumulus.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class Cumulus
2828
public int ChillHourSeasonStart;
2929
public double ChillHourThreshold;
3030

31+
public double CalibRainMult;
32+
3133
private readonly StationOptions StationOptions = new StationOptions();
3234
internal StationUnits Units = new StationUnits();
3335
private readonly int[] WindDPlaceDefaults = { 1, 0, 0, 0 }; // m/s, mph, km/h, knots
@@ -55,7 +57,7 @@ public Cumulus()
5557

5658
private void ReadIniFile()
5759
{
58-
if (!System.IO.File.Exists("Cumulus.ini"))
60+
if (!System.IO.File.Exists(Program.location + "Cumulus.ini"))
5961
{
6062
Program.LogMessage("Failed to find Cumulus.ini file!");
6163
Console.WriteLine("Failed to find Cumulus.ini file!");
@@ -129,6 +131,8 @@ private void ReadIniFile()
129131
NOAAcoolingthreshold = Units.Temp == 0 ? 18.3 : 65;
130132
}
131133

134+
CalibRainMult = ini.GetValue("Offsets", "RainMult", 1.0);
135+
132136
ChillHourSeasonStart = ini.GetValue("Station", "ChillHourSeasonStart", 10);
133137
if (ChillHourSeasonStart < 1 || ChillHourSeasonStart > 12)
134138
ChillHourSeasonStart = 1;
@@ -162,6 +166,7 @@ public class StationOptions
162166
public bool UseZeroBearing { get; set; }
163167
public bool UseWind10MinAve { get; set; }
164168
public bool UseSpeedForAvgCalc { get; set; }
169+
public bool UseSpeedForLatest { get; set; }
165170
public bool Humidity98Fix { get; set; }
166171
public bool CalculatedDP { get; set; }
167172
public bool CalculatedWC { get; set; }

DayFile.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.IO;
5-
using System.Linq;
65
using System.Text;
76
using System.Text.RegularExpressions;
87

@@ -18,7 +17,7 @@ class DayFile
1817
public string FieldSep = string.Empty;
1918
public string DateSep = string.Empty;
2019

21-
private readonly string dayFileName = "data" + Path.DirectorySeparatorChar + "dayfile.txt";
20+
private readonly string dayFileName = Program.location + "data" + Path.DirectorySeparatorChar + "dayfile.txt";
2221

2322
public DayFile()
2423
{
@@ -228,8 +227,10 @@ private string RecToCsv(Dayfilerec rec)
228227
// 50 High Humidex
229228
// 51 Time of high Humidex
230229

231-
// 52 Low Humidex
232-
// 53 Time of low Humidex
230+
// 52 Chill hours
231+
// 53 High 24 hr rain
232+
// 54 Time of high 24 hr rain
233+
233234

234235

235236
// Write the date back using the same separator as the source file
@@ -435,7 +436,13 @@ private string RecToCsv(Dayfilerec rec)
435436
}
436437

437438
if (rec.ChillHours != -9999)
438-
strb.Append(rec.ChillHours.ToString("F1"));
439+
strb.Append(rec.ChillHours.ToString("F1") + FieldSep);
440+
441+
if (rec.HighRain24h != -9999)
442+
{
443+
strb.Append(rec.HighRain24h.ToString(Program.cumulus.TempFormat) + FieldSep);
444+
strb.Append(rec.HighRain24hTime.ToString("HH:mm"));
445+
}
439446

440447
Program.LogMessage("Dayfile.txt Added: " + datestring);
441448

@@ -579,6 +586,13 @@ private Dayfilerec ParseDayFileRec(string data)
579586

580587
if (st.Count > idx++ && double.TryParse(st[52], out varDbl))
581588
rec.ChillHours = varDbl;
589+
590+
if (st.Count > idx++ && double.TryParse(st[53], out varDbl))
591+
rec.HighRain24h = varDbl;
592+
593+
if (st.Count > idx++ && st[54].Length == 5)
594+
rec.HighRain24hTime = Utils.GetDateTime(rec.Date, st[54]);
595+
582596
}
583597
catch (Exception ex)
584598
{
@@ -645,6 +659,8 @@ public class Dayfilerec
645659
public double HighHumidex;
646660
public DateTime HighHumidexTime;
647661
public double ChillHours;
662+
public double HighRain24h;
663+
public DateTime HighRain24hTime;
648664

649665
public Dayfilerec()
650666
{
@@ -679,6 +695,7 @@ public Dayfilerec()
679695
LowFeelsLike = 9999;
680696
HighHumidex = -9999;
681697
ChillHours = -9999;
698+
HighRain24h = -9999;
682699
}
683700

684701
public bool HasMissingData()
@@ -687,8 +704,7 @@ public bool HasMissingData()
687704
DominantWindBearing == 9999 || LowDewPoint == 9999 || HighDewPoint == -9999 || LowWindChill == 9999 || HighHourlyRain == -9999 ||
688705
LowAppTemp == 9999 || HighAppTemp == -9999 || HighHeatIndex == -9999 || HighHumidity == -9999 || LowHumidity == 9999 ||
689706
HighAvgWind == -9999 || AvgTemp == -9999 || HighRainRate == -9999 || LowPress == 9999 || HighPress == -9999 ||
690-
HighTemp == -9999 || LowTemp == 9999 || HighGust == -9999 || ChillHours == -9999
691-
)
707+
HighTemp == -9999 || LowTemp == 9999 || HighGust == -9999 || ChillHours == -9999 || HighRain24h == -9999)
692708
{
693709
return true;
694710
}

LogicFlow.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
3+
StartDate
4+
5+
CurrentDate = StartDate
6+
7+
// process each dayfile record we have at the start
8+
ForEach dayfile record
9+
{
10+
if record > CurrentDate
11+
{
12+
while record > CurrentDate
13+
{
14+
Get new rec from logfile
15+
if we get a record from log file
16+
Update rec with Solar from log
17+
18+
increment CurrentDate
19+
}
20+
21+
decrement CurrentDate
22+
}
23+
else
24+
{
25+
if record has missing data
26+
Get missing data from log file
27+
}
28+
29+
increment CurrentDate
30+
}
31+
32+
// now add any missing records at the end
33+
While CurrentDate < EndDate
34+
{
35+
Get record from logfile
36+
if we get a record from log file
37+
Update rec with Solar from log
38+
39+
increment CurrentDate
40+
}
41+
42+
43+
Save the dayfile

0 commit comments

Comments
 (0)