".$row["year"]."
"; $year = $row["year"]; 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 = ($row["day"]-1)*1440+$row["hour"]*60+$row["minute"]; $time = sprintf("%02s",$row["day"]).sprintf("%02s",$row["hour"]).sprintf("%02s",$row["minute"]); $T = sprintf("%01.2f",($row["temperature"]-32)*5/9); if ($row["indoor_temperature"] == 0) $Ti = 0; else $Ti = sprintf("%01.2f",($row["indoor_temperature"]-32)*5/9); $D = sprintf("%01.2f",($row["dew_point_temperature"]-32)*5/9); if ($row["barometer"] == 0) $Pr = 0; else $Pr = sprintf("%01.4f",($row["barometer"]*33.8637526)); if ($row["average_windspeed"] == 0) $W = 0; else $W = sprintf("%01.2f",($row["average_windspeed"]*1.60934)); $Wd = $row["wind_direction"]; if ($row["current_windchill"] == 0) $Wc = 0; else $Wc = sprintf("%01.2f",($row["current_windchill"]-32)*5/9); if ($row["gust_windspeed"] == 0) $Wg = 0; else $Wg = sprintf("%01.2f",($row["gust_windspeed"]*1.60934)); if ($row["rain_rate"] == 0) $Ph = 0; else $Ph = sprintf("%01.2f",($row["rain_rate"]*25.4)); if ($row["daily_rainfall"] == 0) $P = 0; else $P = sprintf("%01.2f",($row["daily_rainfall"]*25.4)); $H = $row["outdoor_humidity"]; $Hi = $row["indoor_humidity"]; if ($row["monthly_rainfall"] == 0) $Pm = 0; else $Pm = sprintf("%01.2f",($row["monthly_rainfall"]*25.4)); if ($row["yearly_rainfall"] == 0) $Py = 0; else $Py = sprintf("%01.2f",($row["yearly_rainfall"]*25.4)); $C = $row["current_weather_desc"]; $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); ?>