If you use Cumulus, please donate Image

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Error regarding USNO Sunmoon data

Discussion of Ken True's web site templates

Moderator: saratogaWX

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Wed Aug 02, 2017 10:19 pm

The WU api 'astronomy' JSON includes:

precentIlluminated
ageOfMoon
current_time.hour
current_time.minute
sunrise.hour
sunrise.minute
sunset.hour
sunset.minute

Not quite enough and no moonrise/moonset date/times.

sfws
Posts: 340
Joined: Fri Jul 27, 2012 11:29 am
Weather Station: Mixed manufacturers
Operating System: off-line W10 pc
Location: UK

Re: Error regarding USNO Sunmoon data

Postby sfws » Thu Aug 03, 2017 1:18 am

You've said Cumulus does provide times but does not provide dates for moon rise/set.

Being perdantic, Cumulus only provides a time when the moon rises or sets on the current day (so in those cases it does indicate the date), the time is reported as '--:--' when it rose the previous day or will set the next day (so in those cases it indicates the date but not the time).

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Thu Aug 03, 2017 2:11 am

Yes, I've observed that behavior with Cumulus before. The USNO returns the nearest moonrise/moonset to the current date:time and returns both date and time so it's easy to see when only one event occurred 'today'. Of the weather software programs I have running, only Weather-Display provides both date and time for moonrise and moonset .. the others only provide times. The various scripts I've been trying also output a date and time for both events.

User avatar
mcrossley
Posts: 4968
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Jessie Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Error regarding USNO Sunmoon data

Postby mcrossley » Thu Aug 03, 2017 8:28 am

The other thing to check is the effect of latitude. Some of the calculations start to lose accuracy once you get to 60+ degrees or so. It would be interesting to see the same table for say Tromsø at 70N! Especially when there is no sun rise or set in mid-winter/summer.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Fri Aug 04, 2017 12:18 am

looks like they are up again...

though looking at the API web page: http://aa.usno.navy.mil/data/docs/api.php

the title is: Astronomical Applications API v2.0.1


HTTP/1.1 200 OK
Date: Thu, 03 Aug 2017 23:29:50 GMT
Server: Apache
Access-Control-Allow-Origin: *
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json

2c6
{
"error":false,
"apiversion":"2.0.0",
"year":2017,
"month":8,
"day":4,
"dayofweek":"Friday",
"datechanged":false,


api version seems to be different. 2.0.1 <-> 2.0.0
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Fri Aug 04, 2017 12:27 am

I always trust the source code, not necessarily the documentation :)

They may have regressed the code base due to the problems of the last week.. would make some sense if they cut over 2.0.1 and began experiencing issues with the server.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Thu Aug 17, 2017 3:34 pm

consistant as ever - I'm getting USNO errors again:)
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Thu Aug 17, 2017 3:51 pm

After several months of trying/tweaking, I think I found a good set of calculations to allow replacement of the USNO for moon times/sun times.
This uses 3 classes with some mods from their originals. One does phase/illumination, one does rise/set times and one (from Jachym) is used for moon transit times.

Try: https://saratoga-weather.org/wxtemplate ... p?sce=view

Put in Settings.php

Code: Select all

$SITE['useUSNO'] = false;  // =false; use internal calcs, =true; use USNO Moon/Sun data
to activate the calculations instead of the fetch from USNO.

Let me know how it works for you (and if you see any PHP errata from using it).

The calculated times are +/- 1 minute v.s. the built-in calcs (and the USNO) for sun/moon rise/set times -- see attached calcs comparison.
You do not have the required permissions to view the files attached to this post.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Thu Aug 17, 2017 9:24 pm

Will do...

I take it the value in settings.php:

Code: Select all

$SITE['useUSNO'] = false;  // =false; use internal calcs, =true; use USNO Moon/Sun data


overides the

Code: Select all

$useUSNO = true;                   // =true; use USNO data, =false; use computed values only (not as accurate)


in get-USNO-sunmoon.php ?

noticed an issue already in https://www.conligwx.org/wxastronomy.php

Moonrise: 01:09 (01/Jan/1970)
Moonset: 17:35 (01/Jan/1970)
Waning Crescent
19% Illuminated
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Thu Aug 17, 2017 9:40 pm

Yes, the Settings.php entry overrides the default set in get-USNO-sunmoon.php script itself.

Here's a better comparison with the USNO v.s. other software for times -- the USNO timeout had to be set to 30 seconds to have the API respond :(
You do not have the required permissions to view the files attached to this post.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Thu Aug 17, 2017 9:48 pm

I noticed an issue already in https://www.conligwx.org/wxastronomy.php

Moonrise: 01:09 (01/Jan/1970)
Moonset: 17:35 (01/Jan/1970)
Waning Crescent
19% Illuminated

I renamed the USNO-moondata.txt to USNO-moondata.txt.old, but cant see a new file being created.
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Thu Aug 17, 2017 10:04 pm

Oops, forgot to honor the $SITE['WDdateMDY'] setting for the output dates.

Change

Code: Select all

   $timeFormat = "H:i m/d/Y";
to

Code: Select all

   $timeFormat = $useMDY?"H:i m/d/Y":"H:i d/m/Y";
and that should fix it up.

I've updated the beta script with that change.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Thu Aug 17, 2017 10:31 pm

saratogaWX wrote:Oops, forgot to honor the $SITE['WDdateMDY'] setting for the output dates.

Change

Code: Select all

   $timeFormat = "H:i m/d/Y";
to

Code: Select all

   $timeFormat = $useMDY?"H:i m/d/Y":"H:i d/m/Y";
and that should fix it up.

I've updated the beta script with that change.


Yep page now has good values.

there are some differences in timings from this page - using Brian Underdown's Homeweather Template

https://www.conligwx.org/pws/moon.php

and

https://www.conligwx.org/wxastronomy.php

moonset seems to be a whole hour out...
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image

User avatar
saratogaWX
Posts: 830
Joined: Wed May 06, 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows XP SP3
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Postby saratogaWX » Thu Aug 17, 2017 11:33 pm

Brian is using the same class Moon() for rise/set calculations as I am using (renamed to class calcMoon in my code).

That program was showing an hour off the USNO times due to a coding foible the original author had used.. setting the timezone offset by 15degree chunks based on the longitude. The original code was

Code: Select all

      $timezone = (int)($lon / 15);
      $date = self::modifiedJulianDate($month, $day, $year);
      $date -= $timezone / 24;
which I changed to use the actual timezone offset (based on $outTZ) to be

Code: Select all

//      $timezone = (int)($lon / 15);
      $date = self::modifiedJulianDate($month, $day, $year);
//      $date -= $timezone / 24;
    $timezone = date('Z')/3600; // KT
      $date -= $timezone / 24;
so the values matched the Standard or Daylight times as needed. That resulted in the same (+/- 1 minute) times as the USNO specified.

Brian seems to have minified the PHP code for that in his livedata.php. I also used the MoonPhase class, with some mods to more accurately match the USNO's declaration of the phases of the moon based on % illumination. The original code kept the 'New', 'First Quarter', 'Full', 'Last Quarter' displays active longer than the USNO had done.

That's been why it took me so long (and several lunar cycles) to tease the algorithms to produce results comparable to the USNO output.

User avatar
Toxic17
Posts: 528
Joined: Mon May 19, 2014 10:45 pm
Weather Station: Davis Vantage Pro2 Plus
Operating System: Debian 9.1 Stretch
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Postby Toxic17 » Fri Aug 18, 2017 1:07 am

nice.

I was going to see if i could fix that but I just had a hard disk failure! good job i have a cloned imaged:)
Regards Simon
https://www.conligwx.org
https://www.conligwx.org/pws/
Davis Vantage Pro2+ - CumulusMX v3.0.0 (build 3043) + Saratoga/PWS
Image


Return to “Saratoga Templates”

Who is online

Users browsing this forum: No registered users and 2 guests