[weewx-user] Re: Unit conversion options

2018-04-13 Thread gjr80


> i suppose the solution is to add 9/5 +32 to my parsing extension to log 
> the reading as F'
>

Provided your 1 wire sensor always reports in C and your vantage driver 
always emits F then yes, a more robust approach might be (pseudo code):

if packet['usUnits'] == US:
packet['1wire_temp'] = CtoF(temperature)
else:
packet['1wire_temp'] = temperature


one thing that iam not sure is why i cannot alter the readings under
>
> [StdCalibrate]
>
> [[Corrections]]
> # For each type, an arbitrary calibration expression can be given.
> # It should be in the units defined in the StdConvert section.
> # Example:
> foo = foo + 0.2
>
>
> cctemp = cctemp *1.8
>
> extraTemp7 = extraTemp7 + 10
>
> the cctemp is logged with my extension ok i will modify it
> but the extraTemp7 is logged with the 1wire extension that 's freely 
> available from weewx
>
>
> trying to add 10 to extraTemp7  has no effect on what is displayed on the 
> html pages
>
> strange?
>
>
You should be able to correct like that in StdCalibrate, though its rather 
clunky/inflexible and not without risk. One thing to keep in mind is that 
the weeWX services are run sequentially as per the [Engine] [[Services]] 
stanza in weewx.conf. So if your 1 wire service is adding data to the 
packet/record after StdCalibrate has run then anything that StdCalibrate 
does (or attempts to do) to your 1 wire data will fail as the 1 wire data 
is not yet in the packet/record. The risk in this approach is that for the 
period between when your 1 wire service places your 1 wire data in the 
packet/record and StdCalibrate 'fixes' the 1 wire data there is an anomaly 
in the packet/record and any services that act on this anomalous data (ie 
before StdCalibrate 'fixes' it) will possibly be at risk. 

Gary

-- 
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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: Unit conversion options

2018-04-13 Thread vigilancewx
Thank you for the informative reply

i suppose the solution is to add 9/5 +32 to my parsing extension to log the 
reading as F'

one thing that iam not sure is why i cannot alter the readings under

[StdCalibrate]

[[Corrections]]
# For each type, an arbitrary calibration expression can be given.
# It should be in the units defined in the StdConvert section.
# Example:
foo = foo + 0.2


cctemp = cctemp *1.8

extraTemp7 = extraTemp7 + 10

the cctemp is logged with my extension ok i will modify it
but the extraTemp7 is logged with the 1wire extension that 's freely 
available from weewx


trying to add 10 to extraTemp7  has no effect on what is displayed on the 
html pages

strange?




On Thursday, April 12, 2018 at 9:34:22 PM UTC+1, vigilancewx wrote:
>
> hi
>
> I normally run weewx with a vantage and a few 1 wire sensors
>
> standardreport units are set to metric
>
> but the target units in weewx.conf set to US
># DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
> target_unit = US# Options are 'US', 'METRICWX', or 'METRIC'
>
>
>
> all temperatures and other readings displayed on the html pages as they 
> should be
>
> I have tried to create my own extension to read my electricity meter and 
> it should work (this version is in simulator mode just now) 
>
> the current sensor collects the power and temp readings to a txt file and 
> my extension imports it in to weewx.sdb
> the imported power readings are in watts however the temperature is in C'
>
> Checking the weewxsdb all the temp readings are stored in F and then 
> displayed on the html pages in C'
>
> this particular reading cctemp is being parsed and stored in weewx.sdb as 
> deg C so when its shown on the html pages its incorrect  
>
> i have tried to convert it back to 'C under stdcalibrate/corrections but 
> it has no effect?
>
>
> is it possible to display this temperature back to 'C
>
> Unit conversion options 
>
> The tag optional_unit_conversion can be used with either current 
> observations or aggregations. If supplied, the results will be converted to 
> the specified units. For example, if you have set group_pressure to 
> inches of mercury (inHg), then the tag 
>
> Today's average pressure=$day.barometer.avg 
>
> would normally give a result such as
>
> Today's average pressure=30.05 inHg 
>
> However, if you add mbar to the end, 
>
> $day.barometer.avg.mbar 
>
> then the results will be in millibars:
>
>
> i have tried to convert with the above but unsure how to implement it
>
>
> thanks for any advice
>

-- 
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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[weewx-user] Re: Unit conversion options

2018-04-12 Thread gjr80
Hi,

The first thing you need to do is forget about target_units = XXX, it has 
nothing to do with how or what your sensors (via respective 
driver/services) feed weeWX nor does it have any real effect of the unit 
formatting in reports. target_units merely sets the unit system that weeWX 
uses to store obs in the database - you could equally use apples for 
temperature and oranges for humidity, as long as weeWX knows how to convert 
apples to C/F and oranges to % :)

The secret to getting weeWX unit conversion working error free is to follow 
a few simple rules:

1. weeWX recognises 3 different unit systems; US customary, Metric and 
MetricWx. The units used for individual obs in these unit systems are 
covered in the Units appendix  
to the Customization guide.
2. Each loop packet or archive record either generated by a driver or in 
use within weeWX must have a field usUnits that is set to either weewx.US 
(value 0x01), weewx.METRIC (value 0x10) or weewx.METRICWX (value 0x11).
3. The obs fields in loop packets/archive records must be in the applicable 
units specified by the usUnits field in the loop packet/archive record 
concerned.
4. Any services that add fields to loop packets/archive records must ensure 
any added fields are in the respective units defined by the usUnits field 
in the packet/record concerned.

A driver can emit packets/records using whatever unit system you want; US 
customary, Metric or MetricWX. When it comes time so save that data to the 
database the weeWX internals will do the necessary conversion (if required) 
to save to the target_units. If you have a service that pulls data from an 
external sensor and adds it to a loop or archive record then your service 
must check the usUnits field of the packet/record to which the data is to 
be added and the service needs to do the conversion, if required, before 
adding the data to the packet/record. This is easily done with the through 
a weeWX API call, you don't have to reinvent unit conversions. If you don't 
make sure that the obs you add are in the correct units then chances are 
somewhere along the line (storing to db, converting for display/reports) 
your data will be assumed to be in particular units when it is not and 
incorrectly converted.

If you follow this approach report unit conversion/formatting should work 
without issue. If you get your units mixed up internally no amount of unit 
conversion in reports will resolve the issue.

The above being said, if you are using the OWFS Service you should be able 
to set I up appropriately, of course if you are using something else or 
have modified its operation you will need to make sure that it is 
respecting  the usUnits value in of any packets/records it modifies.

Gary

On Friday, 13 April 2018 06:34:22 UTC+10, vigilancewx wrote:
>
> hi
>
> I normally run weewx with a vantage and a few 1 wire sensors
>
> standardreport units are set to metric
>
> but the target units in weewx.conf set to US
># DO NOT MODIFY THIS VALUE UNLESS YOU KNOW WHAT YOU ARE DOING!
> target_unit = US# Options are 'US', 'METRICWX', or 'METRIC'
>
>
>
> all temperatures and other readings displayed on the html pages as they 
> should be
>
> I have tried to create my own extension to read my electricity meter and 
> it should work (this version is in simulator mode just now) 
>
> the current sensor collects the power and temp readings to a txt file and 
> my extension imports it in to weewx.sdb
> the imported power readings are in watts however the temperature is in C'
>
> Checking the weewxsdb all the temp readings are stored in F and then 
> displayed on the html pages in C'
>
> this particular reading cctemp is being parsed and stored in weewx.sdb as 
> deg C so when its shown on the html pages its incorrect  
>
> i have tried to convert it back to 'C under stdcalibrate/corrections but 
> it has no effect?
>
>
> is it possible to display this temperature back to 'C
>
> Unit conversion options 
>
> The tag optional_unit_conversion can be used with either current 
> observations or aggregations. If supplied, the results will be converted to 
> the specified units. For example, if you have set group_pressure to 
> inches of mercury (inHg), then the tag 
>
> Today's average pressure=$day.barometer.avg 
>
> would normally give a result such as
>
> Today's average pressure=30.05 inHg 
>
> However, if you add mbar to the end, 
>
> $day.barometer.avg.mbar 
>
> then the results will be in millibars:
>
>
> i have tried to convert with the above but unsure how to implement it
>
>
> thanks for any advice
>

-- 
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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.