".substr($row["RecDate"],0,4)."
";
$year = substr($row["RecDate"],0,4);
if (!file_exists('./'.$year)) {
mkdir('./'.$year, 0775, true);
}
}
if (ltrim(substr($row["RecDate"],4,2),0) != $month) {
echo "
".ltrim(substr($row["RecDate"],4,2),0)."
";
if ($month != 0) fclose($fh);
$month = ltrim(substr($row["RecDate"],4,2),0);
$myFile = "./".$year."/".$month."_WeatherCatData.cat";
$fh = fopen($myFile, 'w') or die("can't open file");
$top = "WeatherCat data file ***If you modify this file, be sure to delete the relevent .hrs file***.\nt and V are not optional, all other fields are. t is the day, hour and minute (2 digits each), T is outside temperature, Ti is internal temperature, T1 to T8 is auxiliary temperatures, D is dew point, Pr is barometric pressure, W is wind speed,\n Wd is wind direction, Wc is wind chill, Wg is wind gust, Ph is hourly precipitation, P is total precipitation,H is outside humidity, Hi is internal humidity, H1 to H8 are auxiliary humidity sensors, S is solar, \nSm1 to Sm4 is soil moisture, Lw1 to Lw4 is leaf wetness, St1 to St4 is soil temperature, \nLt1 to Lt4 is leaf temperature, U is UV, Pm is monthly precipitation, Py is annual precipitation, Ed is daily ET, Em is monthly ET, Ey is yearly ET, C is current conditions (delimited by double quotes), V is validation. \n\nVERS:3\n\n";
fwrite($fh, $top);
}
$rc = ($day-1)*1440+$hour*60+$min;
$time = sprintf("%02s",$day).sprintf("%02s",$hour).sprintf("%02s",$min);
$T = sprintf("%01.2f",($row["OutdoorTemperature"]-32)*5/9);
if ($row["IndoorTemperature"] == 0) $Ti = 0; else $Ti = sprintf("%01.2f",($row["IndoorTemperature"]-32)*5/9);
$D = sprintf("%01.2f",($row["DewPoint"]-32)*5/9);
if ($row["BarometricPressure"] == 0) $Pr = 0; else $Pr = sprintf("%01.4f",($row["BarometricPressure"]*33.8637526));
if ($row["WindSpeed"] == 0) $W = 0; else $W = sprintf("%01.2f",($row["WindSpeed"]*1.60934));
$Wd = $row["WindDir"];
if ($row["WindChill"] == 0) $Wc = 0; else $Wc = sprintf("%01.2f",($row["WindChill"]-32)*5/9);
if ($row["WindGust"] == 0) $Wg = 0; else $Wg = sprintf("%01.2f",($row["WindGust"]*1.60934));
if ($row["TotalRainRate"] == 0) $Ph = 0; else $Ph = sprintf("%01.2f",($row["TotalRainRate"]*25.4));
if ($row["RainDaily"] == 0) $P = 0; else $P = sprintf("%01.2f",($row["RainDaily"]*25.4));
$H = $row["OutdoorHumidity"];
$Hi = $row["IndoorTemperature"];
if ($row["MonthlyRain"] == 0) $Pm = 0; else $Pm = sprintf("%01.2f",($row["MonthlyRain"]*25.4));
if ($row["TotalRain"] == 0) $Py = 0; else $Py = sprintf("%01.2f",($row["TotalRain"]*25.4));
$C = "---";
$rec = $rc." t:".$time." T:".$T." Ti:".$Ti." D:".$D." Pr:".$Pr." W:".$W." Wd:".$Wd." Wc:".$Wc." Wg:".$Wg." Ph:".$Ph." P:".$P." H:".$H." Hi:".$Hi." S:0 U:0.0 Lw4:0.0 Pm:".$Pm." Py:".$Py." Ed:0.00 Em:0.00 Ey:0.00 C:\"".$C."\" V:4\n";
fwrite($fh, $rec);
echo $rec."
";
}
fclose($fh);
?>