OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
l_sun.py
Go to the documentation of this file.
1 def l_sun(iyr,iday,sec):
2  # Computes unit Sun vector in geocentric rotating coodinates, using
3  # subprograms to compute inertial Sun vector and Greenwich hour angle
4  # converted from l_sum.pro
5  # Liang Hong, 2017/6/26
6 
7  import math
8  import numpy as np
9  from hawknav.gha2000 import gha2000
10 
11  # Get unit Sun vector in geocentric inertial coordinates
12  [su,rs] = sun2000(iyr,iday,sec)
13 
14  # Get Greenwich mean sideral angle
15  day = iday + sec/86400.0
16  gha = gha2000(iyr,day)
17  ghar = np.deg2rad(gha)
18 
19  # Transform Sun vector into geocentric rotating frame
20  n = np.size(day)
21  sunr = np.zeros((3,n))
22  sunr[0][:] = su[0][:]*np.cos(ghar) + su[1][:]*np.sin(ghar)
23  sunr[1][:] = su[1][:]*np.cos(ghar) - su[0][:]*np.sin(ghar)
24  sunr[2][:] = su[2][:]
25 
26  return [sunr,rs]
27 
28 def sun2000(iyr,iday,sec):
29  # This subroutine computes the Sun vector in geocentric inertial
30  # (equatorial) coodinates. It uses the model referenced in The
31  # Astronomical Almanac for 1984, Section S (Supplement) and documented
32  # for the SeaWiFS Project in "Constants and Parameters for SeaWiFS
33  # Mission Operations", in TBD. The accuracy of the Sun vector is
34  # approximately 0.1 arcminute.
35 
36  import math
37  import numpy as np
38  from hawknav.jd import jd
39  from hawknav.gha2000 import gha2000,ephparms,nutate
40 
41  xk = 0.0056932 #Constant of aberration
42  imon = np.ones(np.shape(iyr))
43 
44  # common nutcm,dpsi,eps,nutime
45 
46  # Compute floating point days since Jan 1.5, 2000
47  # Note that the Julian day starts at noon on the specified date
48  jday = jd(iyr,imon,iday)
49  t = jday - 2451545.0 + (sec-43200.0)/86400.0
50  if np.isscalar(t):
51  n = 1
52  else:
53  n = len(t)
54  sun = np.zeros((3,n))
55 
56  # Compute solar ephemeris parameters
57  [xls,gs,xlm,omega] = ephparms(t)
58 
59  # Check if need to compute nutation corrections for this day
60  [dpsi,eps,epsm] = nutate(t,xls,gs,xlm,omega)
61 
62  # Compute planet mean anomalies
63  # Venus Mean Anomaly
64  g2 = 50.40828 + 1.60213022*t
65  g2 = g2 % 360
66 
67  # Mars Mean Anomaly
68  g4 = 19.38816 + 0.52402078*t
69  g4 = g4 % 360
70 
71  # Jupiter Mean Anomaly
72  g5 = 20.35116 + 0.08309121*t
73  g5 = g5 % 360
74 
75  # Compute solar distance (AU)
76  rs = 1.00014-0.01671*np.cos(np.deg2rad(gs))-0.00014*np.cos(2.0*np.deg2rad(gs))
77 
78  # Compute Geometric Solar Longitude
79  dls = (6893.0 - 4.6543463e-4*t)*np.sin(np.deg2rad(gs)) \
80  + 72.0*np.sin(2.0*np.deg2rad(gs)) \
81  - 7.0*np.cos(np.deg2rad(gs - g5)) \
82  + 6.0*np.sin(np.deg2rad(xlm - xls)) \
83  + 5.0*np.sin(np.deg2rad(4.0*gs - 8.0*g4 + 3.0*g5)) \
84  - 5.0*np.cos(np.deg2rad(2.0*gs - 2.0*g2)) \
85  - 4.0*np.sin(np.deg2rad(gs - g2)) \
86  + 4.0*np.cos(np.deg2rad(4.0*gs - 8.0*g4 + 3.0*g5)) \
87  + 3.0*np.sin(np.deg2rad(2.0*gs - 2.0*g2)) \
88  - 3.0*np.sin(np.deg2rad(g5)) \
89  - 3.0*np.sin(np.deg2rad(2.0*gs - 2.0*g5))
90 
91  xlsg = xls + dls/3600.0
92 
93  # Compute Apparent Solar Longitude; includes corrections for nutation
94  # in longitude and velocity aberration
95  xlsa = xlsg + dpsi - xk/rs
96 
97  # Compute unit Sun vector
98  sun[0][:] = np.cos(np.deg2rad(xlsa))
99  sun[1][:] = np.sin(np.deg2rad(xlsa))*np.cos(np.deg2rad(eps))
100  sun[2][:] = np.sin(np.deg2rad(xlsa))*np.sin(np.deg2rad(eps))
101 
102  return [sun,rs]
def l_sun(iyr, iday, sec)
Definition: l_sun.py:1
def sun2000(iyr, iday, sec)
Definition: l_sun.py:28
Definition: jd.py:1
short int nutate(double tjd, short int fn1, double *pos, double *pos2)
int ephparms(double t, double &xls, double &gs, double &xlm, double &omega)