OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
id_drv.f
Go to the documentation of this file.
1  subroutine id_drv(gaclac,west,numi,xlon,xlat,wlon,wlat,nilp,nump)
2 
3 c This subroutine is a driver for the FDF pattern matching routine IDENTY.
4 c It converts the input island latitudes and longitudes to unit vectors and
5 c sets up some additional variables and parameters for the identification
6 c algorithm.
7 
8 c Calling Arguments
9 
10 c Name Type I/O Description
11 c
12 c gaclac I*4 I GAC/LAC flag (1 = GAC)
13 c west L*4 I Flag to indicate scene starts in Western
14 c hemisphere (sets longitude range at 0 to 360
15 c instead of -180 to 180 degrees)
16 c numi I*4 I Number of islands found
17 c xlon(1000) R*4 I Longitude centroid of each island
18 c xlat(1000) R*4 I Latitude centroid of each island
19 c wlon(1000) R*4 I Longitude extent of each island
20 c wlat(1000) R*4 I Latitude extent of each island
21 c nilp(1000) I*4 I Pixel number in scan line for each island
22 c nump(1000) I*4 I Number of pixels for each island
23 
24 c Subprograms Called: identy
25 
26 c Program written by: Frederick S. Patt
27 c General Sciences Corporation
28 c June 13, 1994
29 c
30 c Modification History:
31 
32 
33  real*4 xlon(1000),xlat(1000),wlon(1000),wlat(1000)
34  integer*4 nilp(1000), nump(1000), gaclac
35  real*8 eptime,dangtl,dmagtl,pangtl,tangtl,tminco
36  real*8 timclm(1000),dmagtg,pangtg,tangtg,tmincg
37  real*4 gcrclm(3,1000),briclm(1000),vrmclm(1000),vrpclm(1000)
38  real*4 datcat(7,16000),skyclm(10,3,1000)
39  real*4 dv(3),dlon(1000),dlat(1000),dlom,dloq,dlam,dlaq
40  integer*4 nobclm(1000),mrkclm(1000),klmstr(1000)
41  integer*4 mrkstr(1000),lblclm(1000),idfclm(1000),nrfclm(1000)
42  integer*4 idncat(16000),mapclm(10,1000),idfhst(1000),iqlimt(6)
43  logical west
44 
45  real*8 pi,radeg,re,rem,f,omf2,omegae
46  common /gconst/pi,radeg,re,rem,f,omf2,omegae
47  common /idparm/dangtl,dmagtl,pangtl,tangtl,tminco,
48  * dmagtg,pangtg,tangtg,tmincg,imatch
49 
50  data eptime/0.d0/,timclm/1000*0.d0/,ifxclm/10/
51  data vrmclm/1000*0.d0/,vrpclm/1000*0.d0/,iqlimt/6*0/
52  data nobclm/1000*1/,mrkclm/1000*0/,mrkstr/1000*0/
53  data sinc/0.00159/
54  data dmismn/0.02/,dnotmx/0.015/,dmismg/0.07/,dnotmg/0.05/
55 
56 
57  open (54,file='nav_assess.out')
58 c open (55,file='nav_stats.out')
59 
60 c Define position matching parameters
61 
62  sind = sinc
63  inpix = 643
64 c If GAC then
65  if (gaclac.eq.1) then
66  dmagtl = dmagtg
67  pangtl = pangtg
68  tangtl = tangtg
69  tminco = tmincg
70  sind = sinc*4.0
71  inpix = 125
72  dmismn = dmismg
73  dnotmx = dnotmg
74  end if
75 
76  rporm = 7083./rem
77  rpor2 = rporm*rporm
78 
79 c Convert input positions to unit vectors and
80 c load island parameters into arrays
81  do i=1,numi
82  gcrclm(1,i) = cos(xlon(i)/radeg)*cos(xlat(i)/radeg)
83  gcrclm(2,i) = sin(xlon(i)/radeg)*cos(xlat(i)/radeg)
84  gcrclm(3,i) = sin(xlat(i)/radeg)
85 
86 c Store island "magnitude" as largest dimension
87  zlon = wlon(i)*cos(xlat(i)/radeg)
88  briclm(i) = amax1(zlon,wlat(i)) + 0.01
89 
90 c Estimate position uncertainty from pixel number and number of pixels
91  th = sind*(nilp(i)-inpix)
92  vrpclm(i) = rporm*cos(th)/sqrt(1.0-rpor2*(sin(th))**2) - 1
93  vrpclm(i) = vrpclm(i)/sqrt(float(nump(i)))
94  klmstr(i) = i
95  lblclm(i) = i
96  end do
97  numstr = numi
98  numclm = numi
99 
100 c Store gaclac and west flags in catalog quality array
101  iqlimt(1) = gaclac
102  if (west) iqlimt(2) = 1
103 
104 
105 c Call identification routine
106  call identy (eptime, imatch, dangtl, dmagtl, pangtl, tangtl,
107  * tminco, smaglm, iqlimt, maxcat, idncat, datcat,
108  * ifxclm, numclm, timclm, gcrclm, briclm, vrmclm,
109  * vrpclm, nobclm, mrkclm, numstr, klmstr, mrkstr,
110  * lblclm, idfclm, nrfclm, mapclm, skyclm, idfhst,
111  * ircode)
112 
113 c Print results
114  write(*,*)'IDENTY return code',ircode
115  nid = 0
116  mis = 0
117  nnt = 0
118  do i=1,numi
119  dp = 0.0
120 
121 c If at least one candidate, compute position difference
122  if (nrfclm(i).ge.1) then
123  do j=1,3
124  dv(j) = gcrclm(j,i) - skyclm(1,j,i)
125  dp = dp + dv(j)*dv(j)
126  end do
127  dp = radeg*sqrt(dp)
128 
129 c If this is a positive ID
130  if (mrkclm(i).eq.0) then
131  nid = nid + 1
132 
133 c Compute difference in longitude and latitude and write stats to file
134  clat2 = gcrclm(1,i)**2 + gcrclm(2,i)**2
135  clat = sqrt(clat2)
136  dlat(nid) = radeg*dv(3)/clat
137  dlon(nid) = radeg*(dv(2)*gcrclm(1,i)-dv(1)*gcrclm(2,i))/clat2
138  l = lblclm(i)
139  write (55,1200) lblclm(i),xlon(l),xlat(l),nump(l),nilp(l),
140  * mapclm(1,i),dlon(nid),dlat(nid)
141  1200 format (i6,2f12.5,3i8,2f10.5)
142 
143 c If position difference exceeds tolerance, this may be a mis-ID
144  if (dp.gt.dmismn) mis = mis + 1
145 
146 c Else if not ID but position difference is small
147  else if (dp.lt.dnotmx) then
148  nnt = nnt + 1
149  end if
150  write(*,*)i,lblclm(i),mrkclm(i),nrfclm(i),mapclm(1,i),dp
151  end if
152  write (54,*) i,lblclm(i),mrkclm(i),nrfclm(i),mapclm(1,i),dp
153  end do
154  write(*,*)'IDs',nid,' Mis',mis,' Not',nnt
155 
156 c If at least 5 IDs, compute summary statistics
157  if (nid.ge.5) then
158  call mediqr(dlon,nid,dlom,dloq)
159  write(*,*)'Longitude median, IQR =',dlom,dloq
160  call mediqr(dlat,nid,dlam,dlaq)
161  write(*,*)' Latitude median, IQR =',dlam,dlaq
162  end if
163 
164  return
165  end
166 
subroutine id_drv(gaclac, west, numi, xlon, xlat, wlon, wlat, nilp, nump)
Definition: id_drv.f:2
#define real
Definition: DbAlgOcean.cpp:26
#define re
Definition: l1_czcs_hdf.c:701
subroutine mediqr(dat, ndat, xmed, xiqr)
Definition: mediqr.f:2
#define pi
Definition: vincenty.c:23
#define omf2
Definition: l1_czcs_hdf.c:703
subroutine identy(EPTIME, IMATCH, DANGTL, DMAGTL, PANGTL, TANGTL, TMINCO, SMAGLM, IQLIMT, MAXCAT, IDNCAT, DATCAT, IFXCLM, NUMCLM, TIMCLM, GCICLM, BRICLM, VRMCLM, VRPCLM, NOBCLM, MRKCLM, NUMSTR, KLMSTR, MRKSTR, LBLCLM, IDFCLM, NRFCLM, MAPCLM, SKYCLM, IDFHST, IRCODE)
Definition: identy.f:8
#define f
Definition: l1_czcs_hdf.c:702