OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
ocorient.f
Go to the documentation of this file.
1  subroutine ocorient(pos,vel,att,rm,coef)
2 
3 c this subroutine performs a simple calculation of the sensor
4 c orientation from the orbit position vector and input values of the
5 c attitude offset angles. the calculations assume that the angles
6 c represent the roll, pitch and yaw offsets between the local vertical
7 c reference frame(at the spacecraft position) and the sensor frame.
8 c sensor tilt angles are assumed to be included in the pitch angle.
9 c the outputs are the matrix which represents the transformation from
10 c the geocentric rotating to sensor frame, and the coefficients which
11 c represent the earth scan track in the sensor frame.
12 
13 c the reference ellipsoid uses an equatorial radius of 6378.137 km and
14 c a flattening factor of 1/298.257 (wgs 1984).
15 
16 
17 c calling arguments
18 
19 c name Type i/o description
20 c
21 c pos(3) r*4 i orbit position vector ecef(km)
22 c vel(3) r*4 i orbit velocity vector ecef(km/sec)
23 c att(3) r*4 i attitude offsets(euler angles in
24 c degrees); referenced to local vertical
25 c coordinates; order is roll, pitch, yaw
26 c(x, y, z)
27 c rm(3,3) r*4 o sensor orientation matrix
28 c coef(10) r*4 o scan path coefficients
29 c
30 c subprograms called(attached):
31 
32 c crossp compute cross product of two vectors
33 c euler compute matrix from euler angles
34 c matmpy multiply two 3x3 matrices
35 c
36 c Program written by: frederick s. patt
37 c general sciences corporation
38 c july 22, 1992
39 c
40 c modification history:
41 c
42 c added improved calculation of local vertical reference frame and
43 c modified calling argument names.
44 c f. s. patt, september 30, 1992
45 c
46 c expanded vector normalization in-line to eliminate subroutine
47 c call. f. s. patt, october 19, 1992
48 c
49 c eliminated redundant calculations, changed to correspond to
50 c paper, "Exact closed-form geolocation algorithm for earth
51 c survey sensors", international journal of remote sensing, patt
52 c and gregg, 1993. w. gregg, 4/5/93.
53 c
54 c modified to support three-dimensional view vectors by computing
55 c coefficients array with all 10 ellipsoid terms.
56 c f. s. patt, november 25, 1996
57 c
58  real*8 pi,radeg,re,rem,f,omf2,omegae
59  real vc(3),xpri(3),ypri(3),zpri(3),yrp(3,3),rn(3,3),rm(3,3)
60  real pos(3),vel(3),att(3),coef(10)
61  common /gconst/pi,radeg,re,rem,f,omf2,omegae
62 c
63 c compute correction to orbit velocity vector in earth-centered
64 c earth-fixed(ecef) frame; this involves subtracting effect of earth
65 c rotation rate on velocity to get correct scan plane orientation in
66 c ecef frame.
67  vc(1) = vel(1) - omegae*pos(2)
68  vc(2) = vel(2) + omegae*pos(1)
69  vc(3) = vel(3)
70 
71 c determine nadir frame reference axes
72 c uses method of local ellipsoid approximation good to 0.3 arcsecond
73 c compute z axis as local nadir vector
74  pm = dsqrt(dble(pos(1)*pos(1)+pos(2)*pos(2)+pos(3)*pos(3)))
75  omf2p = (omf2*rem + pm - rem)/pm
76  pxy = pos(1)*pos(1)+pos(2)*pos(2)
77  temp = dsqrt(dble(pos(3)*pos(3) + omf2p*omf2p*pxy))
78  zpri(1) = -omf2p*pos(1)/temp
79  zpri(2) = -omf2p*pos(2)/temp
80  zpri(3) = -pos(3)/temp
81 c compute y axis along negative orbit normal
82  call crossp(vc,zpri,ypri)
83  yprim = dsqrt(dble(ypri(1)*ypri(1) + ypri(2)*ypri(2) +
84  + ypri(3)*ypri(3)))
85  ypri(1) = -ypri(1)/yprim
86  ypri(2) = -ypri(2)/yprim
87  ypri(3) = -ypri(3)/yprim
88 c compute x axis to complete orthonormal triad
89  call crossp(ypri,zpri,xpri)
90 c store in matrix
91  do i=1,3
92  rn(1,i)=xpri(i)
93  rn(2,i)=ypri(i)
94  rn(3,i)=zpri(i)
95  end do
96 c
97 c convert attitude(euler) angles to yrp matrix
98  call oceuler(att,yrp)
99 
100 c compute sensor orientation matrix
101  call matmpy(yrp,rn,rm)
102 
103 c compute coefficients of intersection ellipse in scan plane
104  rd=1.d0/omf2
105  coef(1) = 1.d0+(rd-1.d0)*rm(1,3)*rm(1,3)
106  coef(2) = 1.d0+(rd-1.d0)*rm(2,3)*rm(2,3)
107  coef(3) = 1.d0+(rd-1.d0)*rm(3,3)*rm(3,3)
108  coef(4) = (rd-1.d0)*rm(1,3)*rm(2,3)*2.d0
109  coef(5) = (rd-1.d0)*rm(1,3)*rm(3,3)*2.d0
110  coef(6) = (rd-1.d0)*rm(2,3)*rm(3,3)*2.d0
111  coef(7) = (rm(1,1)*pos(1)+rm(1,2)*pos(2)+rm(1,3)*
112  * pos(3)*rd)*2.d0
113  coef(8) = (rm(2,1)*pos(1)+rm(2,2)*pos(2)+rm(2,3)*
114  * pos(3)*rd)*2.d0
115  coef(9) = (rm(3,1)*pos(1)+rm(3,2)*pos(2)+rm(3,3)*
116  * pos(3)*rd)*2.d0
117  coef(10) = pos(1)*pos(1)+pos(2)*pos(2)+pos(3)*pos(3)*rd-re*re
118 c
119  return
120  end
121 
122 c subroutine crossp(v1,v2,v3)
123 c originally here but removed as it is a independent routine in library
124 
125  subroutine oceuler(a,xm)
126 c computes coordinate transformation matrix corresponding to euler
127 c sequence. the order of angles in the input array is yaw, roll,
128 c pitch; according to osc, the order of the rotations is the reverse
129 c of this; the roll and pitch angles are about the negative y and z
130 c axes, respectively, while the yaw angle is about the positive x axis.
131 
132 c reference: wertz, appendix e; osc, personal communication
133 
134 c calling arguments
135 
136 c name Type i/o description
137 c
138 c a(3) r*4 i input array of euler angles(degrees)
139 c xm(3,3) r*4 o output transformation matrix
140 c
141 c frederick s. patt, gsc, sometime in 1992.
142 c
143 c modification history:
144 c
145 c
146 c modified to change order of rotations to pitch, roll, yaw(-z, -y, -x)
147 c f. s. patt, gsc, september 29, 1996.
148 c
149 c removed negative signs on y and z rotations for octs; order of rotations
150 c is yaw, pitch, roll(z, y, x)
151 
152  real xm1(3,3),xm2(3,3),xm3(3,3),xm(3,3),xmm(3,3),a(3)
153  real*8 radeg
154  radeg = 180.d0/3.14159265359d0
155 
156 c initialize all matrix elements to zero.
157  do i=1,3
158  do j=1,3
159  xm1(i,j) = 0.d0
160  xm2(i,j) = 0.d0
161  xm3(i,j) = 0.d0
162  end do
163  end do
164 
165 c compute sines and cosines
166  c1=dcos(a(1)/radeg)
167  s1=dsin(a(1)/radeg)
168  c2=dcos(a(2)/radeg)
169  s2=dsin(a(2)/radeg)
170  c3=dcos(a(3)/radeg)
171  s3=dsin(a(3)/radeg)
172 
173 c convert individual rotations to matrices
174  xm1(1,1)=1.d0
175  xm1(2,2)=c1
176  xm1(3,3)=c1
177  xm1(2,3)=s1
178  xm1(3,2)=-s1
179  xm2(2,2)=1.d0
180  xm2(1,1)=c2
181  xm2(3,3)=c2
182  xm2(3,1)=s2
183  xm2(1,3)=-s2
184  xm3(3,3)=1.d0
185  xm3(2,2)=c3
186  xm3(1,1)=c3
187  xm3(1,2)=s3
188  xm3(2,1)=-s3
189 
190 c compute total rotation as xm1*xm2*xm3
191  call matmpy(xm2,xm3,xmm)
192  call matmpy(xm1,xmm,xm)
193  return
194  end
195 
196  subroutine matmpy(xm1,xm2,xm3)
197 c computes matrix product of 3x3 matrices xm1 and xm2
198 
199 c calling arguments
200 
201 c name Type i/o description
202 c
203 c xm1(3,3) r*4 i input matrix
204 c xm2(3,3) r*4 i input matrix
205 c xm3(3,3) r*4 o output matrix
206 
207  real xm1(3,3),xm2(3,3),xm3(3,3)
208  do i=1,3
209  do j=1,3
210  xm3(i,j) = 0.d0
211  do k=1,3
212  xm3(i,j) = xm3(i,j) + xm1(i,k)*xm2(k,j)
213  end do
214  end do
215  end do
216  return
217  end
float * vector(long nl, long nh)
Definition: nrutil.c:15
subroutine oceuler(a, xm)
Definition: ocorient.f:126
#define flattening
Definition: vincenty.c:24
void initialize(int pixref_flag, int blkref_flag)
Definition: Usds.c:1371
subroutine earth(pos, vel, widphse1, widphfl1, widphse2,
Definition: earth.f:2
float ** matrix(long nrl, long nrh, long ncl, long nch)
Definition: nrutil.c:60
#define real
Definition: DbAlgOcean.cpp:26
Definition: triad.py:1
subroutine ecef(gha, posi, veli, pose, vele)
Definition: ecef.f:2
float rd(float x, float y, float z)
#define re
Definition: l1_czcs_hdf.c:701
===========================================================================V5.0.48(Terra) 03/20/2015 Changes shown below are differences from MOD_PR02 V5.0.46(Terra)============================================================================Changes noted for V6.1.20(Terra) below were also instituted for this version.============================================================================V6.1.20(Terra) 03/12/2015 Changes shown below are differences from MOD_PR02 V6.1.18(Terra)============================================================================Changes from v6.1.18 which may affect scientific output:A situation can occur in which a scan which contains sector rotated data has a telemetry value indicating the completeness of the sector rotation. This issue is caused by the timing of the instrument command to perform the sector rotation and the recording of the telemetry point that reports the status of sector rotation. In this case a scan is considered valid by L1B and pass through the calibration - reporting extremely high radiances. Operationally the TEB calibration uses a 40 scan average coefficient, so the 20 scans(one mirror side) after the sector rotation are contaminated with anomalously high radiance values. A similar timing issue appeared before the sector rotation was fixed in V6.1.2. Our analysis indicates the ‘SET_FR_ENC_DELTA’ telemetry correlates well with the sector rotation encoder position. The use of this telemetry point to determine scans that are sector rotated should fix the anomaly occured before and after the sector rotation(usually due to the lunar roll maneuver). The fix related to the sector rotation in V6.1.2 is removed in this version.============================================================================V6.1.18(Terra) 10/01/2014 Changes shown below are differences from MOD_PR02 V6.1.16(Terra)============================================================================Added doi attributes to NRT(Near-Real-Time) product.============================================================================V6.1.16(Terra) 01/27/2014 Changes shown below are differences from MOD_PR02 V6.1.14(Terra)============================================================================Migrate to SDP Toolkit 5.2.17============================================================================V6.1.14(Terra) 06/26/2012 Changes shown below are differences from MOD_PR02 V6.1.12(Terra)============================================================================Added the doi metadata to L1B product============================================================================V6.1.12(Terra) 04/25/2011 Changes shown below are differences from MOD_PR02 V6.1.8(Terra)============================================================================1. The algorithm to calculate uncertainties for reflective solar bands(RSB) is updated. The current uncertainty in L1B code includes 9 terms from prelaunch analysis. The new algorithm regroups them with the new added contributions into 5 terms:u1:the common term(AOI and time independent) and
Definition: HISTORY.txt:126
subroutine crossp(v1, v2, v3)
Definition: crossp.f:2
subroutine ocorient(pos, vel, att, rm, coef)
Definition: ocorient.f:2
void reverse(int iorder[], int ncity, int n[])
#define pi
Definition: vincenty.c:23
subroutine euler(a, xm)
Definition: euler.f:2
#define omf2
Definition: l1_czcs_hdf.c:703
Definition: names.f90:1
#define f
Definition: l1_czcs_hdf.c:702
for(i=0;i< NROOTS;i++) s[i]
Definition: decode_rs.h:85
void radius(double A)
Definition: proj_report.c:132
subroutine matmpy(xm1, xm2, xm3)
Definition: ocorient.f:197
#define degrees(radians)
Definition: niwa_iop.c:30
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned on(as it will be in Near-Real-Time processing).