OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
vir_xf_scan.c
Go to the documentation of this file.
1 #include "viirs_sim_sdr.h"
2 
3 int vir_xf_scan(float scn_in, int scn_in_typ, int scn_out_typ, float *scn_out)
4 /*-----------------------------------------------------------------------------
5  Routine: vir_xf_scan
6 
7  Description: utility to transform VIIRS scan values between
8  pixel, scan angle, and AOI on HAM
9 
10  Returns type: int - 0 if good, else I/O error
11 
12  Arguments:
13  Type Name I/O Description
14  ---- ---- --- -----------
15  float scn_in I incoming scan quantity
16  int scn_in_typ I designation of the type of input scan
17  quantity:
18  int scn_out_typ I designation of the type of output scan
19  quantity
20  float * scn_out O output scan quantity
21 
22  The types of scan quantity can be
23  VIR_SCAN_UASMP unaggregated samples
24  VIR_SCAN_AGSMP aggregated samples
25  VIR_SCAN_AOI AOI on HAM mirror, degrees
26  VIR_SCAN_ANG scan angle, degrees
27 
28  Implemented transforms:
29  VIR_SCAN_UASMP -> VIR_SCAN_AOI
30 
31  Modification history:
32 
33  W. Robinson, SAIC 16 Sep 2010 Original development
34 
35 ----------------------------------------------------------------------------*/ {
36  float sind = 0.0003104; /* # radians / sample */
37  float rad2deg = 180. / M_PI;
38  float theta_oop = 28.6 / rad2deg;
39  int iret, idir, in_chain;
40  float ua_smp, scan, theta_ham, aoi;
41  /*
42  * The types of scan quantity can be
43  * mnemonic value description
44  * VIR_SCAN_AGSMP 0 aggregated sample #
45  * VIR_SCAN_UASMP 1 unaggregated sample #
46  * VIR_SCAN_ANG 2 scan angle, degrees
47  * VIR_SCAN_AOI 3 AOI on HAM mirror, degrees
48  *
49  * The transforms will fall in 1 of 2 main directions:
50  * 1: VIR_SCAN_AGSMP -> VIR_SCAN_UASMP -> VIR_SCAN_ANG -> VIR_SCAN_AOI
51  * 2: VIR_SCAN_AOI -> VIR_SCAN_ANG -> VIR_SCAN_UASMP -> VIR_SCAN_AGSMP
52  * as the values of the mnemonic in (1) rise from 0 -> 3 the direction
53  * to choose is determined simply by seeing if scn_out_typ - scn_in_typ
54  * is > 0 (direction (1) ) or < 0 (direction (2) )
55  */
56  iret = 0;
57  if (scn_out_typ == scn_in_typ) {
58  *scn_out = scn_in;
59  } else {
60  idir = (scn_out_typ > scn_in_typ) ? 1 : 2;
61  if (idir == 1) {
62  /*
63  * set internal variable for the type and progress through transform
64  * chain, doing what is needed
65  */
66  switch (scn_in_typ) {
67  case VIR_SCAN_AGSMP:
68  //ag_samp = scn_in;
69  break;
70  case VIR_SCAN_UASMP:
71  ua_smp = scn_in;
72  break;
73  case VIR_SCAN_ANG:
74  scan = scn_in;
75  break;
76  }
77 
78  in_chain = 0;
79  if (scn_in_typ == VIR_SCAN_AGSMP) {
80  /*
81  * aggregated to unaggregated transform
82  */
83  printf("%s, %d: Error, aggregated to unaggregated scan transform not supported yet\n", __FILE__, __LINE__);
84  iret = 1;
85  return iret;
86  }
87  if (scn_out_typ == VIR_SCAN_UASMP) {
88  in_chain = 0;
89  *scn_out = ua_smp;
90  }
91  if ((scn_in_typ == VIR_SCAN_UASMP) || (in_chain == 1)) {
92  /*
93  * unaggregated sample to scan angle
94  */
95  scan = (ua_smp - 3151.5) * sind * rad2deg;
96  in_chain = 1;
97  }
98  if (scn_out_typ == VIR_SCAN_ANG) {
99  in_chain = 0;
100  *scn_out = scan;
101  }
102  if (in_chain == 1) {
103  /*
104  * scan angle to AOI angle
105  */
106  theta_ham = (scan - 46.) / 2.;
107  aoi = acos(cos(theta_ham / rad2deg) * cos(theta_oop));
108  *scn_out = aoi * rad2deg;
109  }
110  } else {
111  /*
112  * nothing implemented yet
113  */
114  printf("%s, %d: Error, this scan transform is not supported yet\n",
115  __FILE__, __LINE__);
116  printf("\t Path AOI on HAM -> scan angle -> unagg sample -> agg\n");
117  }
118  }
119  return iret;
120 }
#define VIR_SCAN_AGSMP
Definition: viirs_sim_sdr.h:51
#define VIR_SCAN_ANG
Definition: viirs_sim_sdr.h:53
MOD_PR01 Production producing one five minute granule of output data in each run It can be configured to produce as many as three five minute granules per run Each execution with one construction record and one date file for each dataset In normal these are created by which splits them out of the hour datasets For LANCE they are created by which merges all session MODIS L0 datasets overlapping the requested time and extracts from the merged data those packets which fall within that time period Each scan of data is stored in the L1A granule that covers the start time of that scan
Definition: MOD_PR01_pr.txt:19
#define M_PI
Definition: pml_iop.h:15
int vir_xf_scan(float scn_in, int scn_in_typ, int scn_out_typ, float *scn_out)
Definition: vir_xf_scan.c:3
#define VIR_SCAN_UASMP
Definition: viirs_sim_sdr.h:52
const double rad2deg