OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
j2000_to_ecr.py
Go to the documentation of this file.
1 def j2000_to_ecr(iy,idy,sec,strUTCpole):
2  # Get J2000 to ECEF transformation matrix
3  # Arguments:
4  # Name Type I/O Description
5  # --------------------------------------------------------
6  # iy I I Year, four digits
7  # idy I I Day of year
8  # sec R*8 I Seconds of day
9  # ecmat(3,3) R O J2000 to ECEF matrix
10  # strUTCpole string, I Earth motion file, 'utcpole.dat'
11  # Ported from j2000_to_ecr.pro by Fred Patt
12  # Liang Hong, 2/14/2020
13  # Liang Hong, 3/24/2020, array calculation
14 
15  from hawknav.j2000_to_mod import j2000_to_mod
16  from hawknav.get_nut import get_nut
17  from hawknav.get_ut1 import get_ut1
18  from hawknav.gha2000 import gha2000
19  import numpy as np
20 
21  daysec = 86400.0 # Second per day
22 
23  # Get transformation from J2000 to mean-of-date inertial
24 
25  j2mod = np.squeeze(j2000_to_mod(iy,idy,sec))
26 
27  # Get nutation and UT1-UTC (once per run)
28  xnut = np.squeeze(get_nut(iy,idy))
29  ut1utc = get_ut1(iy,idy,strUTCpole)
30 
31  # Compute Greenwich hour angle for time of day
32 
33  day = idy + (sec+ut1utc)/daysec
34  gha = gha2000(iy,day)
35  gham = np.zeros((np.size(iy),3,3))
36  gha = np.deg2rad(gha)
37  gham[:,0,0] = np.cos(gha)
38  gham[:,1,1] = np.cos(gha)
39  gham[:,2,2] = 1.0
40  gham[:,1,0] = np.sin(gha)
41  gham[:,0,1] = -np.sin(gha)
42 
43  # Combine all transformations
44 
45  if np.size(iy)==1:
46  xnut = np.squeeze(xnut)
47  gham = np.squeeze(gham)
48  #ecmat = np.dot(j2mod,np.dot(np.transpose(xnut),gham))
49  ecmat = np.linalg.multi_dot([j2mod,np.transpose(xnut),gham])
50  else:
51  ecmat = np.matmul(j2mod,np.matmul(xnut.swapaxes(1,2),gham))
52 
53  return ecmat
def j2000_to_ecr(iy, idy, sec, strUTCpole)
Definition: j2000_to_ecr.py:1