OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
swfnav.f
Go to the documentation of this file.
1  subroutine swfnav(navqc,navctl,input,nframes,orbit,nlines,
2  * navblk,tilts,xnodel,nodet)
3 c
4 c swfnav(navqc,navctl,input,nframes,orbit,nlines,navblk)
5 c
6 c purpose: main routine of seawifs navigation processing subsystem
7 c
8 c calling arguments:
9 c
10 c name Type i/o description
11 c -------- ---- --- -----------
12 c navqc struct i navigation quality control parameters
13 c navctl struct i controls for processing and sensor,
14 c offset data
15 c input struct i input data structure containing
16 c spacecraft id and time, tilt,
17 c sun, magnetometer and earth sensor data
18 c as well as the s/c computed attitude
19 c nframes i*4 i number of data frames in input
20 c orbit struct i structure containing processed orbit data
21 c nlines i*4 o number of lines in the navblk structure
22 c navblk struct o processed navigation block data
23 c for every scan line of data
24 c tilts struct o tilt states for this scene and tilt angle
25 c for every scan line
26 c xnodel r*4 o longitude of descending node(degrees)
27 c nodet i*4 o time of node crossing in milliseconds of day
28 c
29 c by: w. robinson, gsc, 19 mar 93
30 c
31 c notes:
32 c
33 c modification history:
34 c
35 c august, 13 1993: reworked to accept input data structure passed from
36 c frank chen's Level 1A processing soiftware and orbit data structure
37 c generated by navigation initialization routine. Added calls to
38 c nav_tlm subroutine to fill tlm structure, and orb_interp subroutine
39 c to interpolate input orbit data to scan line times.
40 c Frederick S. Patt, GSC
41 c
42 c June 24, 1994: Added tilt structure to pass to calling routine.
43 c Frederick S. Patt, GSC
44 c
45 c July 13, 1994: Added call to get_node and orbit node parameters to
46 c pass to calling routine
47 c Frederick S. Patt, GSC
48 c
49 c October 1, 2001: Initialize navblock.nflag from input.nflag, so information
50 c about timing shift corrections can be recorded.
51 c B. Franz, SAIC.
52 c
53 c October 30, 2007: Add warning message if nav flags are set in input.
54 c F. Patt, SAIC.
55 
56  implicit none
57 c
58 #include "tlm_str.fin"
59 #include "navctl_s.fin"
60 #include "navqc_s.fin"
61 #include "navblk_s.fin"
62 #include "input_s.fin"
63 #include "orbit_s.fin"
64 #include "tilt_s.fin"
65 c
66  type(navctl_struct) :: navctl
67  type(navqc_struct) :: navqc
68  type(navblk_struct) :: navblk(maxlin)
69  type(tlm_struct) :: tlm
70  type(input_struct) :: input(maxlin)
71  type(orbit_struct) :: orbit
72  type(tilt_states) :: tilts
73 c
74  real*4 pos(3,maxlin), vel(3,maxlin), attxfm(3,3,maxlin),
75  1 att_ang(3,maxlin), tiltpr(maxlin), xnodel
76  real*8 time(maxlin), timref(3), tnode
77  integer*4 gaclac, ntim, iret, nlines, lun, ilin, i, j, nframes,
78  1 attangfl(maxlin), tiltfl(maxlin), orbfl(maxlin), nodet,
79  1 iframe, nper
80  logical*1 failflag
81 c
82 c
83 c start, open a temporary data file
84 c
85  lun = 8
86 .gt. if (navctl%lvdbug0)
87  * open( unit = lun, file = 'swfnav.out', status = 'unknown' )
88 c
89 c extract navigation telemetry from input structure
90 c
91  call navtlm(input,nframes,navctl,gaclac,tlm,tilts)
92 
93 c initialize nav block flags from input flags
94 c
95  nper = 1
96 .eq. if (gaclac 1) nper = 5
97  do ilin = 1, nper*nframes
98  iframe = (ilin-1)/nper + 1
99  do i = 1, 8
100  navblk(ilin)%nflag(i) = input(iframe)%nflag(i)
101  end do
102 .eq. if (navblk(ilin)%nflag(1)1) failflag = .true.
103  end do
104 
105  if (failflag) print *,' navfail flag set in input data'
106 c
107 c pre-process time tags to line-by-line time and reference
108 c
109  ntim = tlm%ntlm
110 c
111  call proctim2(input,nframes,navqc,time,timref,nlines,iret)
112 .eq. if( iret 0 ) then
113 c
114 c write out the processed time data
115 c
116  write(6,100)gaclac, ntim, nlines, timref
117  100 format(' swfnav: gaclac, ntim, nlines =',/,
118  1 3i7,//,' reference time(year, day, sec)=',
119  1 /,3f12.4,/)
120 .gt. if (navctl%lvdbug0) then
121  write(lun,100)gaclac, ntim, nlines, timref
122  do ilin = 1, nlines
123  write(lun,200)ilin,time(ilin)
124 c write(6,200)ilin,time(ilin)
125  200 format(2x,i7,f14.4)
126  end do
127  end if
128 
129 c interpolate orbit data to scan line times
130 c
131  call orb_interp(orbit,nlines,timref,time,pos,vel,orbfl)
132 c
133 c check for orbit interpolation error
134 c
135 .ne..or..ne. if ((orbfl(1)0) (orbfl(nlines)0)) then
136  do ilin = 1,nlines
137  navblk(ilin)%nflag(1) = 1
138  navblk(ilin)%nflag(2) = 1
139  end do
140  go to 998
141  end if
142 
143 c find node crossing for scene
144 c
145  call get_node(nlines,timref,time,pos,vel,xnodel,tnode)
146  nodet = tnode*1000.
147 c
148 c compute attitude transform matrix array for the segment
149 c
150  call cmpaxm( nlines, pos, vel, attxfm )
151 c
152 .gt.c if (navctl%lvdbug0) then
153 c do ilin = 1,nlines
154 c write(6,300)ilin,((attxfm(i,j,ilin),i=1,3),j=1,3)
155 c write(lun,300)ilin,((attxfm(i,j,ilin),i=1,3),j=1,3)
156 c 300 format(' attitude xform matrix for line',i7,/,
157 c 1 3(3f12.6,/))
158 c end do
159 c end if
160 c
161 c this branch will use the on-board attitude
162 c
163 .eq. if( navctl%procatt 0 )then
164 c
165 c process S/C based pitch, roll, yaw to line-by-line data
166 c
167  print *,' swfnav: using s/c provided attitude'
168  call sc_att(gaclac, tlm, navqc, att_ang, attangfl, iret )
169 c
170 c print out the fitted pitch, roll, yaw
171 c
172 .gt. if (navctl%lvdbug0) then
173 c write(6,500)
174  write(lun,500)
175  500 format(//,' fitted yaw, roll, pitch follows')
176  do ilin = 1,nlines
177 c write(6,400)attangfl(ilin),(att_ang(i,ilin),i=1,3)
178  write(lun,400)attangfl(ilin),(att_ang(i,ilin),i=1,3)
179  400 format(i7,3f12.7)
180  end do
181  end if
182 c
183 c prepare the tilt values reported
184 c
185  call tiltcomp( nlines, tlm, timref, time, gaclac, navqc,
186  1 tiltpr, tiltfl )
187 c
188 c compute remaining nav block parameters
189 c
190  call scpar(nlines, attxfm, att_ang, attangfl,
191  1 timref, time, pos, tiltpr, tiltfl, navctl, navblk)
192 c
193 c this branch will use sun and earth sensor data to compute attitude
194 c
195  else
196  print *,' swfnav: determining attitude from sensor data'
197  call attcmp( nlines, gaclac, tlm, pos, vel, timref,
198  1 time, navctl, navqc, attxfm, navblk, tiltpr, tiltfl)
199  end if
200 c
201 c place any remaining data into the navigation block
202 c
203  do ilin = 1,nlines
204  tilts%tilt(ilin) = tiltpr(ilin)
205  do j = 1,3
206  navblk(ilin)%orb_vec(j) = pos(j,ilin)
207  end do
208  end do
209 c
210  else
211 c
212 c for bad time processing, fill correct flags in nav block
213 c
214  do ilin = 1, nlines
215  navblk(ilin)%nflag(1) = 1
216  navblk(ilin)%nflag(6) = 1
217  end do
218  end if
219 c
220 .gt. 998 if (navctl%lvdbug0) close( unit = lun )
221 c
222 c for debug - write out some of the navblk info
223 c
224 .gt. if (navctl%lvdbug0) then
225  open(unit=lun, file = 'navblk.out', status = 'unknown' )
226  do ilin = 1, nlines
227  write(lun,600)(navblk(ilin)%orb_vec(j),j=1,3),
228  1 (navblk(ilin)%att_ang(j),j=1,3)
229  600 format(2x,3f13.4,3f13.7)
230  end do
231  close(unit=lun)
232 
233  open(unit=lun, file = 'tilt.out', status = 'unknown' )
234  do ilin = 1, nlines
235  write (lun,*) ilin,tilts%tilt(ilin)
236  end do
237  close(unit=lun)
238  end if
239 c
240 c and return
241 c
242  return
243  end
int navigation(int32_t fileID)
Definition: l1_octs_hdf.c:696
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
===========================================================================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
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_MPI") target_link_libraries(afrt_nc4 $
Definition: CMakeLists.txt:16
int main(int argc, char *argv[])
Definition: afrt_nc4.cpp:30
#define degrees(radians)
Definition: niwa_iop.c:30