Open mikesongming opened 2 years ago
Hello,
Thank you to give a try to sg2.
To use build-wheel.sh
from git repository you need to generate sg2-2.3.0.tar.gz with make dist
I will update the documentation but, as developer you should setup your sources directory using autoreconf, libtoollize and other autotools. Once this is done you must use configure to generate makefiles for you own computer/setup, then you will be able to generate sg2-2.3.0.tar.gz by running make dist
. Once the sg2-2.3.0.tar.gz is generated the build-wheel.sh
script should run smootly.
The sg2-2.3.0.tar.gz is package crafted for source distribution to end users, it is not for developers. it include the generated configure
script, that way users do not have to deal with autotools but can follow the common configure & make & make install flow.
As user of python you can install pre-build wheel using:
pip install sg2 -f https://pip.oie-lab.net/python/
Currently there is no public test to check if sg2 is working, we expect to provide some sanity test in future, but currently our test need human expertise and aren't fully automated. In the meanwhile you can compare your result with the result you can get from pre-build binaries.
I will leave the issue open to track the implementation of test.
Best regards
@gschwind
I've tested the https://pip.oie-lab.net/python/sg2
wheel using SPA's test case: sun_position and sun_rise at gp=[[-105.178, 39.743, 1829]]
and jd=2452930.3125
, the result is:
>>> jd_to_ymdh(jd)
(2003, 10, 17, 19.5)
>>> sun_position(gp, [jd], ['topoc.gamma_S0', 'topoc.alpha_S']).topoc
namespace(gamma_S0=array([[-0.59883594]]), alpha_S=array([[1.25052971]]))
>>> sun_rise(gp, [jd])
array([[['2003-10-17T22:31:12.828', '2003-10-18T03:59:30.114',
'2003-10-18T09:27:12.863']]], dtype='datetime64[ms]')
However, the result of SPA calculated by nrel is:
Date (M/D/YYYY),Time (H:MM:SS),Topocentric zenith angle,Top. azimuth angle (eastward from N),Local sunrise time,Local sun transit time,Local sunset time,Julian day
10/17/2003,12:30:00,50.088088,194.183166,6.212034,11.768003,17.338617,2452930.312500
Output of two algorithms differs a lot.
Hello,
I do not get the same result as you even if gamma_S0 seems little bit different, maybe due to refraction correction.
~ $ python3 -m venv env-test-sg2
~ $ source env-test-sg2/
bash: source: env-test-sg2/: is a directory
~ $ source env-test-sg2/bin/activate
(env-test-sg2) ~ $ pip install -f https://pip.oie-lab.net/python/ sg2
Looking in links: https://pip.oie-lab.net/python/
Collecting sg2
Downloading https://pip.oie-lab.net/python/sg2-2.3.0-cp39-cp39-linux_x86_64.whl (2.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.4/2.4 MB 15.5 MB/s eta 0:00:00
Collecting numpy>=1.22.4
Using cached numpy-1.23.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
Installing collected packages: numpy, sg2
Successfully installed numpy-1.23.1 sg2-2.3.0
WARNING: You are using pip version 22.0.4; however, version 22.2 is available.
You should consider upgrading via the '/home/benoit.gschwind/env-test-sg2/bin/python3 -m pip install --upgrade pip' command.
(env-test-sg2) ~ $ python3
Python 3.9.13 (main, Jun 27 2022, 10:58:48)
[GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sg2
>>> gp=[[-105.178, 39.743, 1829]]
>>> jd=2452930.3125
>>> x = sg2.sun_position(gp, [jd], ['topoc.gamma_S0', 'topoc.alpha_S'])
>>> x
namespace(geoc=namespace(), gp=namespace(), topoc=namespace(gamma_S0=array([[0.69630034]]), alpha_S=array([[3.3891339]])))
>>> import numpy as np
>>> np.degrees(x.topoc.gamma_S0)
array([[39.89507058]])
>>> np.degrees(90-x.topoc.gamma_S0)
array([[5116.72508559]])
>>> 90-np.degrees(x.topoc.gamma_S0)
array([[50.10492942]])
>>> np.degrees(x.topoc.alpha_S)
array([[194.18306882]])
>>> sg2.sun_rise(gp, [jd])
array([[['2003-10-17T13:17:09.210', '2003-10-17T18:46:04.821',
'2003-10-18T00:14:25.956']]], dtype='datetime64[ms]')
>>>
Note that the sun rise equation get some fixes, the output of sg2 is in universal time.
Managed to find some ground truth data at https://aa.usno.navy.mil/data/AltAz ,
returned sun position for upon test case is:
12:30 39.9 194.2
Both SPA and SG2 is not correct for sun elevation angle. The ERFA enabled astropy
package achieved better result of 39.89613166, 194.18049288
Hello,
I did compared the result you provided from https://aa.usno.navy.mil/data/AltAz with the attached python script and I get quite close match as show in the attached plot.
note that aa.usno.navy.mil seems to be computed data.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sg2
import numpy as np
from datetime import datetime
import re
from io import StringIO
import matplotlib.pyplot as plt
d = """
Astronomical Applications Dept.
U.S. Naval Observatory
Washington, DC 20392-5420
DENVER, CO
o , o ,
W105 11, N39 45
Altitude and Azimuth of the Sun
Oct 17, 2003
Zone: 7h West of Greenwich
Altitude Azimuth
(E of N)
h m o o
05:20 -10.9 93.0
05:30 -9.0 94.6
05:40 -7.0 96.1
05:50 -5.1 97.7
06:00 -3.2 99.3
06:10 -1.4 100.9
06:20 0.9 102.5
06:30 2.7 104.1
06:40 4.4 105.7
06:50 6.2 107.4
07:00 8.0 109.0
07:10 9.8 110.8
07:20 11.6 112.5
07:30 13.3 114.3
07:40 15.1 116.1
07:50 16.8 117.9
08:00 18.5 119.8
08:10 20.1 121.7
08:20 21.7 123.7
08:30 23.3 125.8
08:40 24.8 127.9
08:50 26.3 130.1
09:00 27.8 132.3
09:10 29.1 134.7
09:20 30.5 137.0
09:30 31.8 139.5
09:40 33.0 142.1
09:50 34.1 144.7
10:00 35.2 147.4
10:10 36.2 150.2
10:20 37.1 153.0
10:30 37.9 155.9
10:40 38.6 158.9
10:50 39.3 162.0
11:00 39.8 165.1
11:10 40.3 168.3
11:20 40.6 171.5
11:30 40.8 174.8
11:40 40.9 178.0
11:50 41.0 181.3
12:00 40.9 184.5
12:10 40.6 187.8
12:20 40.3 191.0
12:30 39.9 194.2
12:40 39.4 197.3
12:50 38.8 200.4
13:00 38.0 203.4
13:10 37.2 206.3
13:20 36.3 209.2
13:30 35.4 212.0
13:40 34.3 214.7
13:50 33.2 217.3
14:00 32.0 219.9
14:10 30.7 222.4
14:20 29.4 224.8
14:30 28.0 227.1
14:40 26.6 229.4
14:50 25.1 231.6
15:00 23.5 233.7
15:10 22.0 235.7
15:20 20.4 237.7
15:30 18.7 239.7
15:40 17.1 241.6
15:50 15.4 243.5
16:00 13.6 245.3
16:10 11.9 247.0
16:20 10.1 248.8
16:30 8.3 250.5
16:40 6.5 252.2
16:50 4.7 253.8
17:00 2.9 255.4
17:10 1.2 257.0
17:20 -1.1 258.6
17:30 -2.9 260.2
17:40 -4.8 261.8
17:50 -6.8 263.4
18:00 -8.7 264.9
18:10 -10.6 266.5
"""
xt = []
xg = []
xa = []
for l in StringIO(d):
m = re.match("^(\\d+):(\\d+)\\s+([0-9+\\-.]+)\\s+([0-9+\\-.]+)$", l)
if not m:
continue
print(m.groups())
xt.append(np.datetime64(f'2003-10-17 {m.group(1)}:{m.group(2)}')+np.timedelta64(7, 'h'))
xg.append(float(m.group(3)))
xa.append(float(m.group(4)))
print(xt, xg, xa)
gp = [[-105.178, 39.743, 1829]]
s = sg2.sun_position(gp, np.array(xt), ['topoc.gamma_S0', 'topoc.alpha_S'])
s.topoc.gamma_S0 = np.degrees(s.topoc.gamma_S0)
s.topoc.alpha_S = np.degrees(s.topoc.alpha_S)
print(s)
plt.figure()
plt.subplot(2,1,1)
plt.plot(xt, xg, label="navy")
plt.plot(xt, s.topoc.gamma_S0.flat, 'x', label="sg2")
plt.legend()
plt.subplot(2,1,2)
plt.plot(xt, xa, label="navy")
plt.plot(xt, s.topoc.alpha_S.flat, 'x', label="sg2")
plt.legend()
plt.show()
After clone the source code, I managed to rebuild the "configure" file used in
build-wheel.sh
in given docker container by:autoreconf -fiv
However, the build-wheel.sh failed at:
./configure --with-pic CXXFLAGS="-O3" CFLAGS="-O3"
Why the
build-wheel.sh
must run directory extracted from "sg2-2.3.0.tar.gz" ?Can you append test cases on sun_position and sun_rise so that users of SG2 can verify the building process is correct?