RaspAstro Web – Working with pyEphem Sun and Moon Info

I have been doing a bit of tinkering with my RaspAstro Web application. I added two new pages one dedicated to the Sun and one dedicated to the Moon. The RaspAstro Web is a web application written in Python which uses pyEphem to predict and display different interesting and useful astronomical information. I have an instance of RaspAstro Web running on my All Sky Camera Raspberry Pi. This instance of RaspAstroWeb can be accessed at http://vhersey.hopto.org:5000/.

On the Solar System sheet I added the distance from the Observer to the Sun and from the Observer to the Moon. I also added links to the new Sun and the Moon pages.
RaspAstroWeb Solar System Information Sheet
!!!UPDATE!!!
RaspAstroWeb has been moved to a dedicated github repository. The new repository can be found here: https://github.com/herseyc/RaspAstroWeb

This was easy to add as the earth_distance is already predicted by sun_info() and moon_info(), I just needed to convert it to kilometers and add it to the template. The observer information used for this page is based on the GPS location and the current date/time. The distance was converted from AU to meters using ephem.meters_per_au and then divided by 1000 to display in kilometers (km) rounded to 2 decimal places.

Both the Sun and the Moon flask apps have a variable numdays which can be set to the number of days to display (the default is 10 for the Sun and 30 for the Moon).

To get the Sun information I start by determining the local time offset (local time – UTC time), set the local time to midnight by replacing the hour with 0 and minute with 0, and then convert local midnight to UTC (Today at Midnight – Time Offset). I initialize the AstroData class with the observer data (gps coordinates, the local midnight time in UTC). The sun_info() function is called to get Sun rise (next_rising) and Sun set (next_setting). I subtract the next_setting from the next_rising times to get the day length. To get Astronomical Day and Dark I set the observer horizon to -18 and call sun_info(usecenter=True), the next_rising and next_setting with the center of the Sun -18 degrees below the horizon are the astronomical day and astronomical dark times. I am using a while loop to loop while day less than numdays which adds the current day value to the current time to get day 0, 1, 2, 3, 4… etc (day 0 is the current day).

The Sun page displays the current image of the Sun from NASA’s SDO Data. The table displays the Sun information for the next 10 days including Astronomical Day, Sun Rise, Sun Transit (Solar Noon), Sun Set, Astronomical Dark, and the length of the day (hours:minutes between Sun rise and Sun set).
RaspAstroWeb Sun Stats - Rise/Set/Transit/Day Length
The data is displayed using the template sun_stats.html. You can view this information here: http://vhersey.hopto.org:5000/sun

As with the Sun, I determine the local time offset, set the local time to midnight, and then convert local midnight to UTC (Today at Midnight – Time Offset). I initialize the AstroData class using the gps data and the UTC time calculated. I call the moon_info() function to get the next_rising. Since the Moon could rise one day and set the next, once I get the next_rising time I change the observer date/time to that and get the next_settings. The Moon phase information is for the time of rising. Loop through the numdays to get data for day 0, 1, 2, 3, 4… etc (day 0 is the current day). Probably a more efficient, maybe easier, way to do all this, but this is how I am doing and it seems to work.

The Moon page shows 30 days on Moon information since that covers a full Moon cycle (29.5 days). Moon rise, Moon set (which could be the next day), and information about the Moon phase at the rise time for that day is displayed.
RaspAstroWeb Moon Stats - Rise/Set/Phase Information
The data is displayed using the template moon_stats.html. You can view this information here http://vhersey.hopto.org:5000/moon

You can download RaspAstro Web from the github page here: https://github.com/herseyc/RaspAstroWeb
If you have any issues or questions please feel free to leave them in the comments below or submit a raspastro issue on GitHub.
In the near future I am planning to move RaspAstro Web to it’s on github repository… just need to figure out how to do it.
!!!UPDATE!!!
RaspAstroWeb has been moved to a dedicated github repository. The new repository can be found here: https://github.com/herseyc/RaspAstroWeb

Leave a Reply

Your email address will not be published. Required fields are marked *

19 + 14 =