Page 1 of 1

numerical expression NOAA Reports

Posted: Sat Mar 09, 2024 8:12 pm
by hymrog
Hi

I am working on adding some additional detail to the daily NOAA reports, specifically trying to add heating and cooling days. So far I have been able to get the heating and cooling days on a per day basis using the following:

Code: Select all

 #if#{*[th0temp-avg=F]<65*}#then#{*round( 65-[th0temp-avg=F])*00}#else#0#fi# 

Code: Select all

#if#{*[th0temp-avg=F]>65*}#then#{*round([th0temp-avg=F]-65 )*00}#else#0#fi# 
However when attempting to get the monthly totals using the below the expression does not fully evaluate:

Code: Select all

#if#{*[th0temp-mavg=F.000001]>65.0*}#then#{*round([th0temp-mavg=F.000001]-65.0)*[DD]*00}#else#0#fi# 
Here is what is returned:

Code: Select all

#if#{*50.2>65*}#then#{*round(50.2-65 )*01*00}#else#0#fi#
The mavg value is populated but the expression never evaluates and the [DD] shows a "1" when it should show a "9" since today is March 9, 2024

When running this in my browser:

Code: Select all

http://ip-of-meteobrige/cgi-bin/template.cgi?template={*round(65-[th0temp-mavg=F])*[DD]*00}
I get the expected result.

Just curious if I am simply missing something or a possible bug might exist.

g

Re: numerical expression NOAA Reports

Posted: Tue Mar 12, 2024 3:09 pm
by admin
can you please post the complete report definition?
BTW: if-then-else and expression evaluation is not working in the to be repeated line definitions.

Re: numerical expression NOAA Reports

Posted: Tue Mar 12, 2024 3:38 pm
by hymrog
Hi -

Here is what I am using:

Code: Select all

# Standard monthly NOAA template with data in imperial units
# 
$                  MONTHLY CLIMATOLOGICAL SUMMARY FOR [YYYY]-[MM]
$
$Elevation: [mbsystem-altitude=feet.0:]ft
$Latitude:  [mbsystem-latitude.3:]
$Longitude: [mbsystem-longitude.3:]
$
$Temperature in F, Rain in INCH, Wind Speed in MPH, Pressure in INHG
$
$
$                                              HEAT   COOL
$      AVG                                     DEG    DEG     AVG                 DOM              RAIN
$DAY   TEMP   HIGH   TIME   LOW   TIME   RAIN  DAYS   DAYS    WIND   HIGH   TIME  DIR  BAROM  HUM  DAYS
$------------------------------------------------------------------------------------------------------
 [DD]  [th0temp-avg=F.000001:     ]  [th0temp-max=F.000001:     ]  [th0temp-maxts.ij:  ]:[th0temp-maxts.kl:  ] [th0temp-min=F.000001:     ]  [th0temp-mints.ij:  ]:[th0temp-mints.kl:  ]  [rain0total-sum=in.000002:    ]   #if#{*[th0temp-avg=F]<65*}#then#{*( 65-[th0temp-avg=F])*00}#else#00#fi#     #if#{*[th0temp-avg=F]>65*}#then#{*round([th0temp-avg=F.1]-65 )*00}#else#00#fi#    [wind0wind-avg=mph.00001:    ]  [wind0wind-max=mph.000001:     ]   [wind0wind-maxts.ij:  ]:[wind0wind-maxts.kl:  ]  [wind0dir-avg.000:   ]  [thb0seapress-avg=inhg.000002:     ]   [th0hum-avg.00:  ]   [rain0total-count.00:  ]
$------------------------------------------------------------------------------------------------------
$MONTH[th0temp-mavg=F.000001:     ]  [th0temp-mmax=F.000001:     ]  [th0temp-mmaxtime.gh:  ]    [th0temp-mmin=F.000001:     ]  [th0temp-mmintime.gh:  ]     [rain0total-monthsum=in.000002:     ]   #if#{*[th0temp-mavg=F]<65*}#then#{*round([th0temp-mavg=F]-65 )*[DD]*00}#else#0#fi#     #if#{*[th0temp-mavg=F]>65*}#then#{*round([th0temp-mavg=F]-65 )*[DD]*00}#else#0#fi#      [wind0wind-mavg=mph.00001:    ]  [wind0wind-mmax=mph.000001:     ]  [wind0wind-mmaxtime.gh:  ]     [wind0dir-mavg=endir.3:   ]  [thb0seapress-mavg=inhg.000002:     ]    [th0hum-mavg.00:  ]   [rain0total-mcount.00:  ]
$
Thanks for looking at this

g

Re: numerical expression NOAA Reports

Posted: Tue Mar 12, 2024 7:25 pm
by admin
Lines that do not start with a "#" or "$" are iterated with the data from the database according to the start/end date and the specified time resolution.
In these lines only template variable expansion is supported, no numerical or conditional expressions.