Post Reply 
High Accuracy Sun Position Calculation
09-22-2015, 06:12 PM
Post: #1
High Accuracy Sun Position Calculation
Hi all,

I have finished porting my SPA program, thats calculate the Sun Position with high accuracy.

The main body SunPos(JulianDate,{parameters}) is working well.

Have no experience for making a nice GUI of that, but that will be the next step.

If there are ideas how to do that, please let me know.

Attach an article that I found, and is the base of this SPA routine.

Also the next step is calculation Sun-Rise, Sun-Set and Sun-Transit time.

Have fun with this program.

Cheers,

Jan


Attached File(s)
.pdf  34302.pdf (Size: 1.21 MB / Downloads: 79)
.hpprgm  SunPosition.hpprgm (Size: 16.89 KB / Downloads: 57)
Find all posts by this user
Quote this message in a reply
09-22-2015, 08:00 PM
Post: #2
RE: High Accuracy Sun Position Calculation
Hi Jan
Your SPA program is base on the same technique (VSOP87) that ASTRO LAB 4 use for calculating all this positions... In your PDF document, you have the référence about J. Meeus Astronomical Algorithms. I use this book for the creation of Astro Lab 4. Nice to meet you...
Marcel
Find all posts by this user
Quote this message in a reply
09-23-2015, 03:00 PM
Post: #3
RE: High Accuracy Sun Position Calculation
Hi Marcel,

When I change the SunPos(JD) in EXPORT SunPos(JD) and start it from the program Catalog, I can give in the Juliandate but when running I get
"SunPos Error: Undefined results.

When running from the command line "SunPos(xxxxxxx)" I get the right results.

Please can you help me with this.

Cheers,

Jan
Find all posts by this user
Quote this message in a reply
09-23-2015, 04:18 PM
Post: #4
RE: High Accuracy Sun Position Calculation
(09-22-2015 08:00 PM)Marcel Wrote:  Hi Jan
Your SPA program is base on the same technique (VSOP87) that ASTRO LAB 4 use for calculating all this positions... In your PDF document, you have the référence about J. Meeus Astronomical Algorithms. I use this book for the creation of Astro Lab 4. Nice to meet you...
Marcel

I agree also.
I'll try the program soon...
The book of Meeus was very important also for me to make my program.

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
Visit this user's website Find all posts by this user
Quote this message in a reply
09-23-2015, 07:03 PM
Post: #5
RE: High Accuracy Sun Position Calculation
Hi Salvo,

I have the last two versions of the book.
I like it for the formulae. I'm not so familiar with astronomy, but in my working life
(I am a retired Mechanical Engineer, and live in the Netherlands)
my job was make different optimization models (Math) for PowerMarket/Powerplant Portfolio optimization.
So I like to program these algorithm.

Now i'm working on a planetarium for my Prime, and for the Arduino Due in combination with a 7" TFT screen.
So I not need to do the precise calculations.

Therefore I have also Used the formulae of :

Computing planetary positions - a tutorial with worked examples

By Paul Schlyter, Stockholm, Sweden
email: pausch@stjarnhimlen.se or WWW: http://stjarnhimlen.se/

Cheers,

Jan
Find all posts by this user
Quote this message in a reply
09-23-2015, 07:04 PM
Post: #6
RE: High Accuracy Sun Position Calculation
I the last post I mean you Marcel, slip of the pen!

Cheers,

Jan
Find all posts by this user
Quote this message in a reply
09-23-2015, 07:36 PM
Post: #7
RE: High Accuracy Sun Position Calculation
Hi Jan and Salvomic!
Thank you for the book and good luck in your planetarium programming with hp prime..
This is a great calculator and a very fast one.
Marcel
Find all posts by this user
Quote this message in a reply
09-23-2015, 08:19 PM (This post was last modified: 09-23-2015 09:33 PM by Kiwi Geoff.)
Post: #8
RE: High Accuracy Sun Position Calculation
(09-22-2015 06:12 PM)Powersoft Wrote:  Also the next step is calculation Sun-Rise, Sun-Set and Sun-Transit time.

Hello Jan,

Back in March of this year (2015), I tinkered with the SPA code, and found an anomaly with the "Sunrise/Sunset" algorithm.

The SPA header file says the "sunrise and sunset" times are +/- 30 second accuracy, but the following example (on the 20th September 2015) shows a delta of something like 100 seconds (in time).

I just tried using this SPA Calculator.

with this data:

********************************
Start Date 2015 September 20
End Date 2015 September 20

Interval = 10 minutes
latitude = 39.742476;
longitude = -105.1786;
timezone = -7.0;
elevation = 0.0;
pressure = 820;
temperature = 11;
delta_ut1 = 0.0;
delta_t = 67;

azm_rotation = 180;
slope = 0;
atmos_refract = 0.5667;
********************************

The SPA calculator gave the following result:

Date,Time,Local sunrise time,Local sun transit time,Local sunset time
9/20/2015,0:00:00,5.770938,11.902407,18.050313

SPA Calculator (in format HH:MM:SS.ss)
2015-9-20 R 05:46:15.38
2015-9-20 T 11:54:08.67
2015-9-20 S 18:03:01.13

JPL DE430 ephemeris gives the following:
2015-9-20 R 05:46:15.930 Az = 87.884
2015-9-20 T 11:54:08.515 El = 51.252
2015-9-20 S 18:01:21.472 Az = 271.858

There is reasonable agreement between "Rise" and "Transit" times, but the "Sunset" has a delta of something like 100 seconds.

Following is a graph showing SPA.C compared to the JPL DE430 ephemeris for all "sunsets" for 2015 using above configuration.

[Image: attachment.php?aid=2568]

To help isolate the problem with SPA.C , I tried SPA.C using coordinates near my house here in the Southern Hemisphere. The "sunset" data is now very good but the "sunrise" calculation in SPA has the 100 second error. So this "sunrise/sunset" error is related to which "longitude" hemisphere one is in (East or West).

The following graph , shows the accuracy of SPA over a period of 85 years , showing the Sunset and transit delta for each of the 31,047 days for a location here in Christchurch New Zealand (approx 172.7 East , -43.5 South).

[Image: attachment.php?aid=2569]

I tried to write to Afshin Andreas (author of SPA.C) at NREL, to advise that I think there is an issue with the SPA.C code regarding Sunrise and Sunset. However I did not hear back from Afshin - maybe my email was rejected from being "overseas" (New Zealand).

So according to my comparison to the JPL DE430 ephemeris Jan, there is an issue with the Sunrise/Sunset algorithm in SPA.

Perhaps a person who has the book by J. Meeus called "Astronomical Algorithms" could check to see where the SPA code has made a possible mistake implementing the method for "Sunrise/Sunset".

Regards, Geoff Hitchcox, Christchurch, New Zealand.


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
09-23-2015, 10:58 PM
Post: #9
RE: High Accuracy Sun Position Calculation
Hi Geoff,
With Astro Lab 4 (from Meeus book..), I found
R: 05:46:14
T: 11:54:08
S: 18:03:01
in local time.
Marcel.
Find all posts by this user
Quote this message in a reply
09-24-2015, 04:48 AM
Post: #10
RE: High Accuracy Sun Position Calculation
(09-23-2015 10:58 PM)Marcel Wrote:  Hi Geoff,
With Astro Lab 4 (from Meeus book..), I found
R: 05:46:14
T: 11:54:08
S: 18:03:01
in local time.
Marcel.

Thank you Marcel, this is getting very interesting.

I thought the "Sunrise/Sunset" issue I found only applied to SPA, however if Astro Lab 4 is derived from the J. Meeus book (and not SPA) then it implies that the algorithm issue goes back to the J Meeus book.

From your Astro Lab4 output, we can see that it is "sunset" time that does not agree with my JPL DE430 derived time.

So who is correct here ?

Perhaps the most accurate resource is:

JPL Solar System Dynamics.

which gives the "sunset" (using parameters given previously in the thread) as

Date Time (-7) Az(r-appr) Elev
2015-Sep-20 18:01:21 Cs 271.8562 -0.2141

I also found that we can use the:
SPA online calculator
to generate the Solar position every 1 second, and then "manually" extract the R.T.S.

SPA generated SOLAR position:
R 9/20/2015 05:46:16 87.884450 (degrees Azimuth)
T 9/20/2015 11:54:09 180.002206 (degrees Azimuth)
S 9/20/2015 18:01:22 271.858286 (degrees Azimuth)

This now agrees within ONE HALF SECOND (of time) with the JPL DE430 ephemeris.

JPL DE430 ephemeris gives the following:
R 2015-9-20 05:46:15.930 Az = 87.884
T 2015-9-20 11:54:08.515 El = 51.252
S 2015-9-20 18:01:21.472 Az = 271.858

Thus we can see that the SPA "sun position code", does not agree with the SPA (and Lab4) "Sunrise/Sunset" times.

I feel this "proves" my above assertion - that something is indeed wrong with the Sunrise/Sunset algorithm given by J Meeus. I wonder if there was an erratum at some stage - or am I the first to find this issue with the "Sunrise/Sunset" algorithm?

Regards, Geoff Hitchcox, Christchurch, New Zealand.
Find all posts by this user
Quote this message in a reply
09-25-2015, 01:53 PM
Post: #11
RE: High Accuracy Sun Position Calculation
Marcel,

Is it posible to store all variable that I use in my SunPos in a file?
so I can use AVars?

If yes how can I construct this kind of a file?

I hope you can help me with this.

Cheers,

Jan
Find all posts by this user
Quote this message in a reply
09-25-2015, 02:41 PM (This post was last modified: 09-25-2015 02:44 PM by StephenG1CMZ.)
Post: #12
RE: High Accuracy Sun Position Calculation
have you checked the known errata to see if there is anything relevant already known?

If not, Google "Jean Meeus errata" and a willbell.com page will list the known errata for editions 1 and 2 of his book.

Last time I tried to get his book, my local Waterstones said it was out of print, and Amazon sent the wrong book.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
09-25-2015, 03:21 PM
Post: #13
HP Prime Virtual Calculator Latest version
Hello,

What is the latest version of the HP Prime Virtual Calculator?

Where to download?

Cheers,


Jan
Find all posts by this user
Quote this message in a reply
09-25-2015, 04:25 PM
Post: #14
RE: High Accuracy Sun Position Calculation
Hi Jan
Yes, you can use AVars. This is exactly what I do in Astro Lab 4.. If you edit the program you will see what to do. If you open the variables tab you will have all the variables that I store with AVars.. Go and see!
Marcel
Find all posts by this user
Quote this message in a reply
09-26-2015, 09:16 AM
Post: #15
RE: High Accuracy Sun Position Calculation
Dear Marcel,

I think have ask the wrong question.
In your App Astro Lab4 I see "Astro Lab 4.hpappvars"
I found in the code how to read it, but not how to create.

Question is how do you create this from all the constants from J.Meeuse?

When I'm right this can only used inside of an App?

Thanks,

Jan
Find all posts by this user
Quote this message in a reply
09-26-2015, 01:01 PM (This post was last modified: 09-26-2015 01:02 PM by Marcel.)
Post: #16
RE: High Accuracy Sun Position Calculation
Hi Jan
If you enter AVars and press HELP key, you will have a small help screen. This is where I get my help with this command.
In the ConnKit, double click on your Prime, and double click on Application Library and double click on Astro Lab 4 and now, double click on Variables. All the DATA will be visibles.
You can reuse this DATA in your program.. This is not my DATA. All of us can reuse and do a better Astronomy Program. This is a long work to enter but you can also reenter it.
Marcel
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: