sunrise, transit and sunset calculation

Talks about solar stuff
Post Reply
pohl3758
Posts: 3
Joined: Tue Apr 16, 2019 7:37 pm

sunrise, transit and sunset calculation

Post by pohl3758 » Tue Apr 16, 2019 8:07 pm

Dear JeanMarc,

I am using 123solar with an Aurora PowerOne/ABB inverter on an Odroid C2 with Arch Linux and its working great so far. Outputs are recorded and submitted to PVOutput.

The query I have is that data logging starts and stops two hours too on my system early. I think the issue was reported here http://123solar.org/phpBB/viewtopic.php ... info#p1924, but discussion never got forward.
I understand that the start/stop times of 123solar are based on the sunrise, transit and sunset calculation, which in turn are generated by the timezone setting, the location and the builtin date_sun_info() php function.

On my system I have set the following date and time:

Code: Select all

$ datetimectl
               Local time: Tue 2019-04-16 20:23:09 CEST
           Universal time: Tue 2019-04-16 18:23:09 UTC
                 RTC time: n/a
                Time zone: Europe/Berlin (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
The following php code

Code: Select all

<?php
define('checkaccess', TRUE);
include('config/config_main.php');
date_default_timezone_set($DTZ);

$now       = date('Ymd H:i');
echo "it is $now your timezone is $DTZ ";
$sun_info     = date_sun_info((strtotime(date('Ymd'))), $LATITUDE, $LONGITUDE);

echo "SUNRISE " . date('H:i', $sun_info['sunrise']) . " - TRANSIT " . date("H:i", $sun_info['transit']) . " - SUNSET " . date('H:i', $sun_info['sunset']);
?>
generates the output:

Code: Select all

$ php ./test.php 
it is 20190416 20:15 your timezone is Europe/Berlin SUNRISE 04:32 - TRANSIT 10:41 - SUNSET 16:51
The results are two hours too early for my location. If I switch timezone to UTC+4, for example "Asia/Dubai", then the calculated sunrise and sunset are correct:

Code: Select all

$ php ./test.php 
it is 20190416 22:35 your timezone is Asia/Dubai SUNRISE 06:32 - TRANSIT 12:41 - SUNSET 18:51
It looks like this issue is not related to 123solar, but to the evaluation of the date_sun_info() function of php. The calculation seems to be based on the UTC time rather than the correct CEST+0200 time. But maybe you have an idea what is going wrong here. In the meantime, I will temporarily change my timezone setting from "Europe/Berlin" to "Asia/Dubai".

Thank you very much for your help.

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: sunrise, transit and sunset calculation

Post by jeanmarc » Tue Apr 16, 2019 8:53 pm

Hi Pohl,
The date_sun_info is also calculated on $LATITUDE $LONGITUDE parameters. Are you sure you set them correctly ?

Code: Select all

[root@i3 ~]# timedatectl
               Local time: Tue 2019-04-16 21:49:31 CEST
           Universal time: Tue 2019-04-16 19:49:31 UTC
                 RTC time: Tue 2019-04-16 19:49:31
                Time zone: Europe/Brussels (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@i3 123solar]# php test.php 
it is 20190416 21:54 your timezone is Europe/Brussels SUNRISE 06:45 - TRANSIT 13:41 - SUNSET 20:37

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: sunrise, transit and sunset calculation

Post by jeanmarc » Wed Apr 17, 2019 7:27 am

I will switch the values in the interace, it's confusing with epsg.io ;)

pohl3758
Posts: 3
Joined: Tue Apr 16, 2019 7:37 pm

Re: sunrise, transit and sunset calculation

Post by pohl3758 » Wed Apr 17, 2019 10:18 am

Dear Jean-Marc,

which coordinate system does the latitude and longitude coordinates parameter expect? I used the provided link in the 123solar web interface epsg.io. I zoomed to my location and copied the values written on top of the map. I guess these are EPSG:4326 WGS 84 coordinates.

Changing the time zone to UTC+4 produced the right sunrise and sunset times in the web interface, but reported the wrong system time to PVOutput. So I switched back to the correct time zone "Europe/Berlin".

regards,
Alexander

pohl3758
Posts: 3
Joined: Tue Apr 16, 2019 7:37 pm

Re: sunrise, transit and sunset calculation

Post by pohl3758 » Wed Apr 17, 2019 10:27 am

Dear Jean-Marc,
jeanmarc wrote:
Wed Apr 17, 2019 7:27 am
I will switch the values in the interace, it's confusing with epsg.io ;)
The longitude and latitude parameters in the 123solar admin interface are in the wrong order compared to the epsg.io web interface. When switching them around, the calculation is correct :D .

Regards

jeanmarc
Posts: 1764
Joined: Thu Aug 29, 2013 7:16 am

Re: sunrise, transit and sunset calculation

Post by jeanmarc » Wed Apr 17, 2019 2:19 pm

Neat ;) i have swap both entries

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests