Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Error regarding USNO Sunmoon data

Discussion of Ken True's web site templates

Moderator: saratogaWX

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: Error regarding USNO Sunmoon data

Post by sfws »

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: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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: 12694
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Error regarding USNO Sunmoon data

Post by mcrossley »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

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 - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

consistant as ever - I'm getting USNO errors again:)
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

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 - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

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 - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

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 - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

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

Re: Error regarding USNO Sunmoon data

Post by saratogaWX »

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
ConligWX
Posts: 1571
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: Error regarding USNO Sunmoon data

Post by ConligWX »

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 - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
Post Reply