Nothing wrong with that approach, but if you're writing a weewx service,
the latitude, longitude, and altitude are available in the object stn_info,
which is an instance of class weewx.station.StationInfo. So, your call
would become

# Convert altitude to meters
altitude_vt = weewx.units.convert(self.stn_info.altitude_vt, "meter")
almanac = Almanac(time.time(), self.stn_info.latitude_f,
self.stn_info.longitude_f, altitude_vt[0])

Not much simpler, but it has two advantages: if the hardware supports it,
StationInfo reads the altitude directly off your console, and it avoids
reparsing the configuration file.

-tk

On Thu, Dec 1, 2016 at 11:50 PM, Graham Gear <[email protected]> wrote:

> Thanks Thomas, that worked great, I appreciate the point - what great
> service from the weewx community, mark me very impressed!
>
> For others reference, I pulled the lat/log/alt from the weewx config as
> below:
>
> import weewx
>
> import weecfg
>
> from weewx.almanac import Almanac
>
> almanac = Almanac(time.time(), 
> float(weecfg.get_station_info(self.config_dict)['latitude']),
>
>                   
> float(weecfg.get_station_info(self.config_dict)['longitude']),
>
>                   
> float(weecfg.get_station_info(self.config_dict)['altitude'][0]))
>
>

Reply via email to