This is a good question, and it took me a while to figure out how to work
around the limitations of pyephem. Try this:

1. Put the following in user/extensions.py:

import ephem
eros = ephem.readdb("433
Eros,e,10.8276,304.3222,178.8165,1.457940,0.5598795,0.22258902,71.2803,09/04.0/2017,2000,H11.16,0.46")
ephem.Eros = eros

2. Modify the WeeWX module weewx/almanac.py so that the function
_get_ephem_body() looks like this:

def _get_ephem_body(heavenly_body):
    # The library 'ephem' refers to heavenly bodies using a capitalized
    # name. For example, the module used for 'mars' is 'ephem.Mars'.
    cap_name = heavenly_body.capitalize()

    # If the heavenly body is a star, or if the body does not exist, then an
    # exception will be raised. Be prepared to catch it.
    try:
        ephem_body = getattr(ephem, cap_name)()
    except AttributeError:
        # That didn't work. Try a star. If this doesn't work either,
        # then a KeyError exception will be raised.
        ephem_body = ephem.star(cap_name)
    except TypeError:
        ephem_body = getattr(ephem, cap_name)

    return ephem_body

You are adding the two highlighted lines.

3. Then use this in your template:

$almanac.eros.rise

for when it rises, etc. (treat it just like any other planet).

Double check the answer. I'm not 100% confident this will work. If it does,
I'll add the changes for weewx/almanac.py to the code base.

-tk

On Sat, Jan 19, 2019 at 10:20 AM Paul Bartholdi <[email protected]>
wrote:

> Hi,
>
> I nodified a few years ago the "Standard/index.html.tmpl" to print the
> main solar systems objects (sun, moon, Jupiter...).
> Now I want to pint the same informations but for the minor planet Eros
> that pass very (very relative!) the earth in the few next days.
> This implies adding the python line:
>
>      eros = ephem.readdb("433
> Eros,e,10.8276,304.3222,178.8165,1.457940,0.5598795,0.22258902,71.2803,09/04.0/2017,2000,H11.16,0.46")
>
> and then (in index.html.tmp) :
>
>                <tr>
>                   <td class="label">Rise  :</td>
>                   <td class="data">$almanac.eros.rise</td>
>                 </tr>
>
> Where should I add the " eros = ephem.readdb(...) line ?   (
> index.html.tmpl ?  almanac.py ? elsewhere ?).
>
> Thanks for any help/advice!     Paul
>
>
> --
> 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].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to