Ok, I will try setup a minimal repro skin. is mysql for the data table ok? On Thursday, April 15, 2021 at 1:02:48 AM UTC+2 [email protected] wrote:
> I can only fix what I can reproduce and, so far, I have not been able to. > My apologies. If you can send me a simple template and database that > reproduces the problem, I'll go at it. > > > > On Tue, Apr 13, 2021 at 11:35 PM [email protected] <[email protected]> > wrote: > >> Below, is the full template file as google does not seem to allow me to >> attach a file to a post. >> >> ## template for json data to feed the steel series gauges >> ## $Id: gauge-data.txt.tmpl 1279 2015-03-01 15:49:03Z mwall $ >> ## by Matthew Wall on flight 868 ;) >> ## 31dec2014 >> ## Updated 25jan2015 by M Crossley, changed cloudbase: to cloudbasevalue: >> ## Updated 12jan2016 by M Crossley, fixes applied from here: >> https://groups.google.com/forum/#!topic/weewx-user/rDdSbzQWbFw >> ## Updated 12mar2016 by M Crossley, force pressure UoM mbar to mb. >> ## added UoM consitency from unit_type >> rather than labels which can be localised >> ## force rain in cm to mm as gauges do >> not currently handle cm's. >> ## Updated 04oct2016 by M Crossley, added changes from PR4 >> ## Updated 3Jun2020 by G Roderick, rain calculations now tolerate a >> station that does not provide rain data >> ## (as distinct from rain data that is 0) >> ## definitions for the tags can be found here: >> ## http://wiki.sandaysoft.com/a/Webtags >> ## >> ## the following fields are not directly available from weewx: >> ## >> ## ver:10? >> ## apptemp - calculated in this template >> ## apptempTL >> ## apptempTH >> ## TapptempTL >> ## TapptempTH >> ## humidex - calculated in this template >> ## forecast - calculated by forecasting module >> ## LastRainTipISO >> ## Tbeaufort - calculated by this template >> ## BearingRangeFrom10 - lowest clockwise bearing in last 10 minutes >> ## BearingRangeTo10 - highest clockwise bearing in last 10 minutes >> ## CurrentSolarMax - calculated in this template >> ## WindRoseData >> ## windrun - calculated in this template >> ## >> ## ver:12 >> ## cloudbasevalue - calculated in this template in feet >> ## cloudbaseunit - defined in this template as ft >> ## >> ## ver:13 >> ## changed UoMs >> ## >> #import math >> #import time >> ## >> ## get the time in formats that we need later >> #set $ts=float($current.dateTime.raw) >> #set $timeutc=time.strftime("%Y,%m,%d,%H,%M,%S", time.gmtime($ts)) >> ## >> ## get some formats for calculated obs >> #set $temp_format = $unit.format.outTemp >> #set $press_format = $unit.format.pressure >> #set $rain_format = $unit.format.rain >> #set $rainrate_format = $unit.format.rainRate >> #set $cloudbase_format = $unit.format.cloudbase >> #set $windrun_format = $unit.format.windrun >> #set $radiation_format = $unit.format.radiation >> ## >> ## see if the station has contact with the sensor >> #set $sensorContactLost = 0 >> #set $rxchk = $getVar('current.rxCheckPercent.raw', 100) >> #if $rxchk is not None and $rxchk == 0 >> #set $sensorContactLost = 1 >> #end if >> ## >> ## calculate humidex >> ## http://www.physlink.com/reference/weather.cfm >> #if $varExists('current.outTemp') and $current.outTemp.raw is not None >> and $varExists('current.dewpoint') and $current.dewpoint.raw is not None >> #set $oT_C = $current.outTemp.degree_C.raw >> #set $dp_K = $current.dewpoint.degree_C.raw + 273.16 >> #set $e = 6.11 * math.exp(5417.7530 * ((1/273.16) - 1/$dp_K)) >> #set $h = 0.5555 * ($e - 10.0) >> #if $h > 0 >> #set $humidex = $oT_C + $h >> #else >> #set $humidex = $oT_C >> #end if >> #if $unit.unit_type.outTemp == 'degree_F' >> #set $humidex = 32.0 + 1.8 * $humidex >> #end if >> #set $humidex = $temp_format % $humidex >> #else >> #set $humidex = 'N/A' >> #end if >> ## >> ## calculate apparent temperature >> ## >> ## http://www.bom.gov.au/info/thermal_stress/#atapproximation >> ## AT = Ta + 0.33*e - 0.70*ws - 4.00 >> ## where AT and Ta (air temperature) are deg-C, >> ## e is water vapor pressure >> ## ws is wind speed (m/s) at elevation of 10 meters >> ## e = rh / 100 * 6.105 * exp(17.27 * Ta / (237.7 + Ta)) >> ## rh is relative humidity >> ## >> ## http://www.ncdc.noaa.gov/societal-impacts/apparent-temp/ >> ## AT = -2.7 + 1.04*T + 2.0*e -0.65*v >> ## where AT and T (air temperature) are deg-C, >> ## e is vapor pressure in kPa, >> ## and v is 10m wind speed in m/sec >> ## >> #if $varExists('current.outTemp') and $current.outTemp.raw is not None >> and $varExists('current.outHumidity') and $current.outHumidity.raw is not >> None and $varExists('current.windSpeed') and $current.windSpeed.raw is not >> None >> #set $oT_C = $current.outTemp.degree_C.raw >> #set $rh = $current.outHumidity.raw >> #set $ws = $current.windSpeed.meter_per_second.raw >> #set $e = ($rh / 100) * 6.105 * math.exp(17.27 * $oT_C / (237.7 + $oT_C)) >> #set $apptemp = $oT_C + 0.33 * $e - 0.7 * $ws - 4.0 >> #if $unit.unit_type.outTemp == 'degree_F' >> #set $apptemp = 32.0 + 1.8 * $apptemp >> #end if >> #set $apptemp = $temp_format % $apptemp >> #else >> #set $apptemp = 'N/A' >> #end if >> ## >> ## calculate the cloud base in feet >> #if $varExists('current.outTemp') and $current.outTemp.raw is not None >> and $varExists('current.dewpoint') and $current.dewpoint.raw is not None >> #set $oT_F = $current.outTemp.degree_F.raw >> #set $dp_F = $current.dewpoint.degree_F.raw >> #set $a_f = $station.altitude.foot.raw >> #set $cloudbase = (($oT_F - $dp_F) / 4.4 * 1000) + $a_f >> #set $cloudbase = $cloudbase_format % $cloudbase >> #else >> #set $cloudbase = 'N/A' >> #end if >> ## >> ## calculate the wind run for the day >> ## FIXME: this is an approximation since averages are per-hour >> #set $t = time.localtime($ts) >> #set $windrun = 0 >> #for $n in range($t[3]) >> #set $ago = $hours_ago(hours_ago=$n).windSpeed.avg.raw >> #if $ago is not None >> #set $windrun = $windrun + $ago >> #end if >> #end for >> #if $unit.unit_type.windSpeed == 'meter_per_second' >> #set $windrun = $windrun / 3.6 >> #end if >> #set $windrun = $windrun_format % $windrun >> ## >> ## calulate solar max >> ## Ryan-Stolzenbach, MIT 1972 formula >> ## http://www.ecy.wa.gov/programs/eap/models.html >> ## >> ## el - solar elevation in decimal degrees >> ## R - distance from earth to sun in AU >> ## atc - atmospheric transmission coefficient (0.70-0.91) >> ## z - elevation in meters >> ## >> #if $almanac.hasExtras >> #set $rs_el = $almanac.sun.alt >> #set $rs_R = $almanac.sun.earth_distance >> #set $rs_atc = 0.8 >> #set $rs_z = $station.altitude.meter.raw >> #set $rs_nrel = 1367.0 >> #set $rs_sinel = math.sin($rs_el * math.pi / 180.0) >> #if $rs_z is not None and $rs_R is not None >> #if $rs_sinel < 0 >> #set $solarMax = 0 >> #else >> #set $rs_rm = >> math.pow((288.0-0.0065*$rs_z)/288.0,5.256)/($rs_sinel+0.15*math.pow($rs_el+3.885,-1.253)) >> #set $rs_toa = $rs_nrel * $rs_sinel / ($rs_R * $rs_R) >> #set $solarMax = $rs_toa * math.pow($rs_atc, $rs_rm) >> #end if >> #set $solarMax = $radiation_format % $solarMax >> #else >> #set $solarMax = 'N/A' >> #end if >> #else >> #set $solarMax = 'N/A' >> #end if >> ## >> ## calculate today's highest beaufort based on wind speed in knots >> #if $varExists('day.windSpeed') and $day.windSpeed.max.raw is not None >> #if $unit.unit_type.windSpeed == 'mile_per_hour' >> #set $kts = $day.windSpeed.max.raw * 0.8689762 >> #elif $unit.unit_type.windSpeed == 'km_per_hour' >> #set $kts = $day.windSpeed.max.raw * 0.539956 >> #elif $unit.unit_type.windSpeed == 'meter_per_second' >> #set $kts = $day.windSpeed.max.raw * 1.943844 >> #elif $unit.unit_type.windSpeed == 'knot' >> #set $kts = $day.windSpeed.max.raw >> #else >> #set $kts = 0 >> #end if >> #if $kts < 1 >> #set $beaufort = 0 >> #elif $kts < 4 >> #set $beaufort = 1 >> #elif $kts < 7 >> #set $beaufort = 2 >> #elif $kts < 11 >> #set $beaufort = 3 >> #elif $kts < 17 >> #set $beaufort = 4 >> #elif $kts < 22 >> #set $beaufort = 5 >> #elif $kts < 28 >> #set $beaufort = 6 >> #elif $kts < 34 >> #set $beaufort = 7 >> #elif $kts < 41 >> #set $beaufort = 8 >> #elif $kts < 48 >> #set $beaufort = 9 >> #elif $kts < 56 >> #set $beaufort = 10 >> #elif $kts < 64 >> #set $beaufort = 11 >> #else >> #set $beaufort = 12 >> #end if >> #else >> #set $beaufort = 'N/A' >> #end if >> ## >> ## if forecasting is installed, report the Zambretti forecast >> #if $varExists('forecast.zambretti') >> #set $fc = $forecast.label('Zambretti', $forecast.zambretti.code) >> #else >> #set $fc = 'forecast is not available' >> #end if >> ## >> #set $periods = $forecast.weather_periods('WU') >> #set $WU_ICON_LABELS = ["Tornado","Tropical Storm","Hurricane","Strong >> Storms","Thunderstorms","Rain / Snow","Rain / Sleet","Wintry Mix","Freezing >> Drizzle","Drizzle","Freezing Rain","Showers","Rain","Flurries","Snow >> Showers","Blowing / Drifting Snow","Snow","Hail","Sleet","Blowing Dust / >> Sandstorm","Foggy","Haze","Smoke","Breezy","Windy","Frigid / Ice >> Crystals","Cloudy","Mostly Cloudy","Mostly Cloudy","Partly Cloudy","Partly >> Cloudy","Clear","Sunny","Fair / Mostly Clear","Fair / Mostly Sunny","Mixed >> Rain and Hail","Hot","Isolated Thunderstorms","Scattered >> Thunderstorms","Scattered Showers","Heavy Rain","Scattered Snow >> Showers","Heavy Snow","Blizzard","Not Available (N/A)","Scattered >> Showers","Scattered Snow Showers","Scattered Thunderstorms"] >> >> #if len($periods) > 0 >> #set $wts = '' >> #set $wloc = '' >> #set $fc = '' >> #set $Loops = 0 >> #for $period in $periods >> #set $wts = $period.issued_ts >> #set $wloc = $period.location >> #if $period.event_ts is not None >> #set $fc +=$period.event_ts.string('') + ' ' >> #end if >> #if $period.temp is not None >> #set $fc += $period.temp.string('') + ' ' >> #end if >> #if $period.clouds is None >> #set $fc += 'N/A' >> #else >> #set $fc += $WU_ICON_LABELS[int($period.clouds)] >> ##set $fc += $period.clouds >> #end if >> #set $fc += ' ' >> #if $Loops > 10 >> #break >> #else >> #set $Loops += 1 >> #end if >> #end for >> #else >> #set $fc='No forecast available' >> #end if >> ## >> #set $_trend = $trend(time_delta=3600).outTemp.raw >> #if $_trend is None >> #set $_trend = 0 >> #end if >> #set $t_trend = $temp_format % $_trend >> ## >> #set $_trend = $trend(time_delta=10800).barometer.raw >> #if $_trend is None >> #set $_trend = 0 >> #end if >> #set $p_trend = $press_format % $_trend >> ## >> ## Set consistent units of measure >> ## Pressure UoM >> #set $UOM_bar = $unit.unit_type.barometer >> #if $UOM_bar == 'mbar' >> #set $UOM_bar = 'mb' >> #end if >> ## >> ## Temperature UoM >> #if $unit.unit_type.outTemp == 'degree_F' >> #set $UOM_temp = 'F' >> #else >> #set $UOM_temp = 'C' >> #end if >> ## >> ## Windspeed UoM >> #if $unit.unit_type.windSpeed == 'mile_per_hour' >> #set $UOM_wind = 'mph' >> #elif $unit.unit_type.windSpeed == 'km_per_hour' >> #set $UOM_wind = 'km/h' >> #elif $unit.unit_type.windSpeed == 'knot' >> #set $UOM_wind = 'kts' >> #elif $unit.unit_type.windSpeed == 'meter_per_second' >> #set $UOM_wind = 'm/s' >> #end if >> ## >> ## Rain UoM >> #set $rain_mult = 1 >> #set $UOM_rain = $unit.unit_type.rain >> #if $unit.unit_type.rain == 'inch' >> #set $UOM_rain = 'in' >> #elif $unit.unit_type.rain == 'cm' >> ## Gauges do not handle cm, convert to mm >> #set $UOM_rain = 'mm' >> #set $rain_mult = 10 >> #end if >> #if $day.rain.sum.has_data >> #set $day_rain = $rain_format % ($day.rain.sum.raw * $rain_mult) >> #else >> #set $day_rain = 0.0 >> #end if >> #if $current.rainRate.raw is not None >> #set $current_rainrate = $rainrate_format % ($current.rainRate.raw * >> $rain_mult) >> #else >> #set $current_rainrate = 0.0 >> #end if >> #if $day.rainRate.max.has_data >> #set $day_rainrate_max = $rainrate_format % ($day.rainRate.max.raw * >> $rain_mult) >> #else >> #set $day_rainrate_max = 0.0 >> #end if >> ## >> ## Today's High Hourly Rain >> #set $hourlyrainTH = 0 >> #set $ThourlyrainTH = '' >> #for $hour in $day.hours >> #if $hour.rain.sum.has_data and $hour.rain.sum.raw > $hourlyrainTH >> #set $hourlyrainTH = $hour.rain.sum.raw >> #set $ThourlyrainTH = $hour.dateTime.format("%H:%M") >> #end if >> #end for >> #set $hourlyrainTH = $hourlyrainTH * $rain_mult >> #set $hourlyrainTH = $rain_format % $hourlyrainTH >> ## >> #set $Avg1hPM25 = $hour.pm2_5.max >> #set $Avg1hPM10 = $hour.pm10_0.max >> { >> "timeUTC":"$timeutc", >> "date":"$current.dateTime.format('%Y.%m.%d %H:%M')", >> "dateFormat":"y.m.d h:m", >> "SensorContactLost":"$sensorContactLost", >> "tempunit":"$UOM_temp", >> "windunit":"$UOM_wind", >> "pressunit":"$UOM_bar", >> "rainunit":"$UOM_rain", >> "cloudbaseunit":"ft", >> "temp":"$current.outTemp.formatted", >> "tempTL":"$day.outTemp.min.formatted", >> "tempTH":"$day.outTemp.max.formatted", >> "TtempTL":"$day.outTemp.mintime", >> "TtempTH":"$day.outTemp.maxtime", >> "temptrend":"$t_trend", >> "intemp":"$current.inTemp.formatted", >> "intempTL":"$day.inTemp.min.formatted", >> "intempTH":"$day.inTemp.max.formatted", >> "TintempTL":"$day.inTemp.mintime", >> "TintempTH":"$day.inTemp.maxtime", >> "hum":"$current.outHumidity.formatted", >> "humTL":"$day.outHumidity.min.formatted", >> "humTH":"$day.outHumidity.max.formatted", >> "ThumTL":"$day.outHumidity.mintime", >> "ThumTH":"$day.outHumidity.maxtime", >> "inhum":"$current.inHumidity.formatted", >> "dew":"$current.dewpoint.formatted", >> "dewpointTL":"$day.dewpoint.min.formatted", >> "dewpointTH":"$day.dewpoint.max.formatted", >> "TdewpointTL":"$day.dewpoint.mintime", >> "TdewpointTH":"$day.dewpoint.maxtime", >> "wchill":"$current.windchill.formatted", >> "wchillTL":"$day.windchill.min.formatted", >> "TwchillTL":"$day.windchill.mintime", >> "heatindex":"$current.heatindex.formatted", >> "heatindexTH":"$day.heatindex.max.formatted", >> "TheatindexTH":"$day.heatindex.maxtime", >> "apptemp":"$apptemp", >> "apptempTL":"0", >> "apptempTH":"0", >> "TapptempTL":"", >> "TapptempTH":"", >> "humidex":"$humidex", >> "press":"$current.barometer.formatted", >> "pressL":"$year.barometer.min.formatted", >> "pressH":"$year.barometer.max.formatted", >> "pressTL":"$day.barometer.min.formatted", >> "pressTH":"$day.barometer.max.formatted", >> "TpressTL":"$day.barometer.mintime", >> "TpressTH":"$day.barometer.maxtime", >> "presstrendval":"$p_trend", >> "rfall":"$day_rain", >> "rrate":"$current_rainrate", >> "rrateTM":"$day_rainrate_max", >> "TrrateTM":"$day.rainRate.maxtime", >> "hourlyrainTH":"$hourlyrainTH", >> "ThourlyrainTH":"$ThourlyrainTH", >> "LastRainTipISO":"2000-01-01 00:00", >> "wlatest":"$current.windGust.formatted", >> "wspeed":"$current.windSpeed.formatted", >> "windTM":"$day.windSpeed.max.formatted", >> "wgust":"$current.windGust.formatted", >> "wgustTM":"$day.windGust.max.formatted", >> "TwgustTM":"$day.windGust.maxtime", >> "bearing":"$current.windDir.formatted", >> "avgbearing":"$day.wind.vecdir.formatted", >> "bearingTM":"$day.wind.gustdir.formatted", >> "BearingRangeFrom10":"000", >> "BearingRangeTo10":"000", >> "domwinddir":"$day.wind.vecdir.ordinal_compass", >> "WindRoseData":[], >> "windrun":"$windrun", >> "Tbeaufort":"F$beaufort", >> "UV":"$current.UV", >> "UVTH":"$day.UV.max.formatted", >> "SolarRad":"$current.radiation.formatted", >> "SolarTM":"$day.radiation.max.formatted", >> "CurrentSolarMax":"$solarMax", >> "cloudbasevalue":"$cloudbase", >> "forecast":"$fc", >> "version":"$station.version", >> "build":"", >> "pm2_5":"$current.pm2_5.formatted", >> "pm10":"$current.pm10_0.formatted", >> "Avg1hPM25":"$Avg1hPM25", >> "Avg1hPM10":"$Avg1hPM10", >> "ver":"15" >> } >> >> On Wednesday, April 14, 2021 at 8:34:59 AM UTC+2 [email protected] wrote: >> >>> Hello, >>> >>> I admit I fell from my chair when trying your above sample, and seeing >>> the results. :). >>> The sample interestingly shows has_data = false, but pm2_5.avg gets >>> calculated. (you can check output, plus the ones I actually need there : >>> http://meteobron.ddns.net). >>> >>> However, when I add : >>> <snip> >>> ## >>> #set $Avg1hPM25 = $hour.pm2_5.max >>> #set $Avg1hPM10 = $hour.pm10_0.max >>> { >>> </snip> >>> to the gauge-data.txt.tmpl of my steal series template, the resulting >>> data is : >>> { "timeUTC":"2021,04,14,05,24,00", "date":"2021.04.14 07:24", >>> "dateFormat":"y.m.d h:m", "SensorContactLost":"0", "tempunit":"C", >>> "windunit":"km/h", "pressunit":"mb", "rainunit":"mm", "cloudbaseunit":"ft", >>> "temp":"2.0", "tempTL":"1.9", "tempTH":"6.2", "TtempTL":"07:11:34 AM", >>> "TtempTH":"12:00:44 AM", "temptrend":"-0.5", "intemp":"20.2", >>> "intempTL":"18.4", "intempTH":"20.7", "TintempTL":"06:37:35 AM", >>> "TintempTH":"12:03:07 AM", "hum":"58", "humTL":"43", "humTH":"59", >>> "ThumTL":"12:00:44 AM", "ThumTH":"07:23:22 AM", "inhum":"40", "dew":"-5.3", >>> "dewpointTL":"-5.9", "dewpointTH":"-5.1", "TdewpointTL":"04:54:51 AM", >>> "TdewpointTH":"01:38:07 AM", "wchill":"2.0", "wchillTL":"1.9", >>> "TwchillTL":"07:12:00 AM", "heatindex":"2.0", "heatindexTH":"4.4", >>> "TheatindexTH":"02:27:18 AM", "apptemp":"-0.6", "apptempTL":"0", >>> "apptempTH":"0", "TapptempTL":"", "TapptempTH":"", "humidex":"2.0", >>> "press":"1026.3", "pressL":"863.5", "pressH":"1181.0", "pressTL":"1025.8", >>> "pressTH":"1026.7", "TpressTL":"03:45:59 AM", "TpressTH":"12:55:49 AM", >>> "presstrendval":"0.4", "rfall":"0.0", "rrate":"0.0", "rrateTM":"0.0", >>> "TrrateTM":"12:00:12 AM", "hourlyrainTH":"0.0", "ThourlyrainTH":"", >>> "LastRainTipISO":"2000-01-01 00:00", "wlatest":"0", "wspeed":"0", >>> "windTM":"4", "wgust":"0", "wgustTM":"9", "TwgustTM":"03:34:00 AM", >>> "bearing":" N/A", "avgbearing":"345", "bearingTM":" N/A", >>> "BearingRangeFrom10":"000", "BearingRangeTo10":"000", "domwinddir":"NNW", >>> "WindRoseData":[], "windrun":"1.4", "Tbeaufort":"F1", "UV":"0.0", >>> "UVTH":"0.0", "SolarRad":"9", "SolarTM":"10", "CurrentSolarMax":"7", >>> "cloudbasevalue":"3603", "forecast":"14-Apr-2021 19:00 0.6°C Fair / >>> Mostly Clear 15-Apr-2021 07:00 13.3°C Fair / Mostly Sunny 15-Apr-2021 >>> 19:00 1.1°C Partly Cloudy 16-Apr-2021 07:00 13.9°C Partly Cloudy >>> 16-Apr-2021 19:00 1.7°C Partly Cloudy 17-Apr-2021 07:00 14.4°C >>> Partly Cloudy 17-Apr-2021 19:00 3.9°C Partly Cloudy 18-Apr-2021 07:00 >>> 15.6°C Partly Cloudy 18-Apr-2021 19:00 3.9°C Partly Cloudy >>> 19-Apr-2021 07:00 17.8°C Partly Cloudy 19-Apr-2021 19:00 5.0°C >>> Partly Cloudy ", "version":"4.3.0", "build":"", "pm2_5":"1.233", >>> "pm10":"2.200", "Avg1hPM25":" N/A", "Avg1hPM10":" N/A", "ver":"15" } >>> >>> with my 2 PM measures showing as N/A. >>> >>> >>> >>> Many thanks again. >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "weewx-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/weewx-user/0da2917e-573d-4937-9848-5e52fb262306n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/weewx-user/0da2917e-573d-4937-9848-5e52fb262306n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/b00504bd-de40-4f1b-af34-cdfe27b64065n%40googlegroups.com.
