Well, fooey...
Just like that I figured it out.  =D
Apparently we're not allowed to issue calibration statements for the same 
metric more than once.

The following works, because I am making up two "fake" place-holder variables 
first, windDirMod and windGustDirMod.
Since those aren't known to weewx already, they're fine.
Then after those I am modifying the actual windDir and windGustDir metrics only 
once.

Was this an RTFM?  If so, sorry I missed it.  :S

Meanwhile, how is my approach?
Is there a simpler, more efficient way?

windCalibDegrees=-90.0

windDirMod = ((windDir + windCalibDegrees) % 360) if windDir is not None else 
None
windDir = (windDirMod + 360 if windDirMod < 0 else windDirMod) if windDir is 
not None else None
windGustDirMod = ((windGustDir + windCalibDegrees) % 360) if windGustDir is not 
None else None
windGustDir = (windGustDirMod + 360 if windGustDirMod < 0 else windGustDirMod) 
if windGustDir is not None else None

Regards,
Leon
--
Leon Shaner :: Dearborn, Michigan (iPad Pro)

> On Apr 15, 2019, at 3:36 PM, Leon Shaner <l...@isylum.org> wrote:
> 
> Hey, WeeWX'ers!  =D
> 
> I am baffled by a weewx.conf parsing error while trying to do a windDir and 
> windGustDir calibration adjustment.  :-(
> 
> I tested my python code already with an external script and that's working 
> fine, but weewx doesn't like the relevant lines in the weewx.conf...
> 
> Apr 15 15:15:37 nixie weewx[12130]: engine: Error while parsing configuration 
> file /etc/weewx/weewx.conf
> Apr 15 15:15:37 nixie weewx[12130]: ****    Reason: 'Parsing failed with 
> several errors.
>                                    First error at line 447.'
> 
> Below is what I have in the weewx.conf.
> 
> Line 447 corresponds to the second occurrence of windDir, where I am checking 
> if it is < 0.
> 
> #   This section can adjust data using calibration expressions.
> 
> [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
> 
>        windCalibDegrees=-90.0
> 
>        windDir = ((windDir + windCalibDegrees) % 360) if windDir is not None 
> else None
>        windDir = (windDir + 360 if windDir < 0 else windDir) if windDir is 
> not None else None
>        windGustDir = ((windGustDir + windCalibDegrees) % 360) if windGustDir 
> is not None else None
>        windGustDir = (windGustDir + 360 if windGustDir < 0 else windGustDir) 
> if windGustDir is not None else None
> 
> 
> And here's how I am testing it outside of weewx:
> 
> sqlite3 /var/lib/weewx/weewx.sdb "select windDir, windGustDir from archive 
> where dateTime>1555351400;" | awk -F\| '{print $1 " " $2}' | while read 
> windDir windGustDir ; do ./windcalib.py $windDir $windGustDir; done
> 
> Where windcalib.py contains
> 
> #!/usr/bin/python3
> 
> import sys
> 
> 
> if len(sys.argv) != 3:
>    sys.exit("Please pass windDir and windGustDir as args")
> 
> 
> windDir = float(sys.argv[1])
> windGustDir = float(sys.argv[2])
> print ("INPUT : windDir =", windDir, "windGustDir =", windGustDir)
> 
> windCalibDegrees=-90.0
> 
> windDir = ((windDir + windCalibDegrees) % 360) if windDir is not None else 
> None
> windDir = (windDir + 360 if windDir < 0 else windDir) if windDir is not None 
> else None
> windGustDir = ((windGustDir + windCalibDegrees) % 360) if windGustDir is not 
> None else None
> windGustDir = (windGustDir + 360 if windGustDir < 0 else windGustDir) if 
> windGustDir is not None else None
> 
> print ("OUTPUT: windDir =", windDir, "windGustDir =", windGustDir)
> 
> 
> Regards,
> \Leon
> --
> Leon Shaner :: Dearborn, Michigan (iPad Pro)
> 
> -- 
> 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.

-- 
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.

Reply via email to