OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
main_l0regen.c
Go to the documentation of this file.
1 /*
2 This program reads a SeaWiFS level-1A HDF file and writes out the
3 data in SeaWiFS level-0 format.
4 The program also writes out a text file containing the station
5 identification information that is needed by SWl01. The name
6 of this text file is "<output levl-0 name>.station_info" .
7 
8 Norman Kuring 11-Dec-1997
9  */
10 
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <time.h>
15 #include <math.h>
16 #include "mfhdf.h"
17 #include "genutils.h"
18 
19 #define VERSION "1.0"
20 #define USAGE "Usage: %s SeaWiFS_level_1a_filename output_filename\n"
21 
22 #define READ_GLBL_ATTR(nam,ptr) { \
23  if(SDreadattr(sd_id,SDfindattr(sd_id,(nam)),(VOIDP)(ptr))){ \
24  fprintf(stderr, \
25  "-E- %s line %d: Could not get global attribute, %s, from file, %s.\n", \
26  __FILE__,__LINE__,(nam),argv[1]); \
27  exit(EXIT_FAILURE); \
28  } \
29 }
30 
31 #define READ_SDS(nam,ptr,s0,s1,s2,e0,e1,e2) { \
32  int32 start[3]; \
33  int32 edge[3]; \
34  edge[0]=(e0); edge[1]=(e1); edge[2]=(e2); \
35  start[0]=(s0); start[1]=(s1); start[2]=(s2); \
36  if(SDreaddata(SDselect(sd_id, SDnametoindex(sd_id, (nam))), \
37  start, NULL, edge, (VOIDP)(ptr)) == FAIL){ \
38  fprintf(stderr,"-E- %s line %d: Could not read SDS, %s.\n", \
39  __FILE__,__LINE__,(nam)); \
40  exit(EXIT_FAILURE); \
41  } \
42 }
43 
44 #define MALLOC(ptr,typ,num) { \
45  (ptr) = (typ *)malloc((num) * sizeof(typ)); \
46  if((ptr) == NULL){ \
47  fprintf(stderr,"-E- %s line %d: Memory allocation failure.\n", \
48  __FILE__,__LINE__); \
49  exit(EXIT_FAILURE); \
50  } \
51 }
52 
53 #define MINOR_FRAME_SIZE 21504
54 
55 double doubleutime(int16, int16, int32);
56 void get_frame_data(int32, int32, int32, int16 *, int16 *, uint8 *,
57  int16 *, int16 *, int16 *, int16 *, int16 *, int16 *);
58 
59 int main(int argc, char *argv[]) {
60 
61  FILE *fh;
62  int32 sd_id;
64  int32 smsec, emsec, npix, nscan, s;
65  uint8 *s_flags;
66  int is_gac;
67  time_t aos, los;
68  uint16 bit_error_rate_denominator;
69  uint8 bit_error_rate_numerator;
70  uint32 ber_numerator = 0, ber_denominator = 0;
71  static uint8 frame[MINOR_FRAME_SIZE];
72  uint8 *fp;
73  int16 sc_id[2], sc_ttag[4], inst_tlm[44];
74  int16 start_syn[8], stop_syn[8], dark_rest[8], gain_tdi[8];
75  int16 *l1a_data;
76  uint8 sc_soh[775];
77  static uint8 header[512];
78  uint8 dtype[32], center[1024], station[1024];
79  uint8 is_hrpt;
80  int base;
81  char *stationfile;
82  static char code[4];
83  float32 lat, lon;
84 
85  if (argc != 3) {
86  fprintf(stderr, "%s %s (%s %s)\n", argv[0], VERSION, __DATE__, __TIME__);
87  fprintf(stderr, USAGE, argv[0]);
88  exit(EXIT_FAILURE);
89  }
90 
91  /* Make sure the input file exists. */
92  if ((fh = fopen(argv[1], "rb")) == NULL) {
93  fprintf(stderr, "-E- %s line %d: Could not open file, %s . ",
94  __FILE__, __LINE__, argv[1]);
95  perror(NULL);
96  exit(EXIT_FAILURE);
97  } else {
98  fclose(fh);
99  }
100 
101  /* Make sure the output file does not already exist. */
102  if ((fh = fopen(argv[2], "rb")) != NULL) {
103  fprintf(stderr, "-E- %s line %d: File, %s , already exists.\n",
104  __FILE__, __LINE__, argv[2]);
105  exit(EXIT_FAILURE);
106  }
107 
108  /* Compose a station info filename and make sure it doesn't exist. */
109  MALLOC(stationfile, char, strlen(argv[2]) + 14);
110  strcpy(stationfile, argv[2]);
111  strcat(stationfile, ".station_info");
112  if ((fh = fopen(stationfile, "rb")) != NULL) {
113  fprintf(stderr, "-E- %s line %d: File, %s , already exists.\n",
114  __FILE__, __LINE__, stationfile);
115  exit(EXIT_FAILURE);
116  }
117 
118  /* Open the HDF input file */
119  sd_id = SDstart(argv[1], DFACC_RDONLY);
120  if (sd_id == FAIL) {
121  fprintf(stderr, "-E- %s line %d: SDstart(%s, %d) failed.\n",
122  __FILE__, __LINE__, argv[1], DFACC_RDONLY);
123  exit(EXIT_FAILURE);
124  }
125 
126  /* Read some of the level-1A global attributes. */
127  READ_GLBL_ATTR("Data Type", dtype);
128  READ_GLBL_ATTR("Start Year", &syear);
129  READ_GLBL_ATTR("Start Day", &sday);
130  READ_GLBL_ATTR("Start Millisec", &smsec);
131  READ_GLBL_ATTR("End Year", &eyear);
132  READ_GLBL_ATTR("End Day", &eday);
133  READ_GLBL_ATTR("End Millisec", &emsec);
134  READ_GLBL_ATTR("Pixels per Scan Line", &npix);
135  READ_GLBL_ATTR("Number of Scan Lines", &nscan);
136  READ_GLBL_ATTR("Data Center", center);
137  READ_GLBL_ATTR("Station Name", station);
138  READ_GLBL_ATTR("Station Latitude", &lat);
139  READ_GLBL_ATTR("Station Longitude", &lon);
140 
141  /* Reformat the start and end times. */
142  aos = (time_t) floor(doubleutime(syear, sday, smsec));
143  los = (time_t) ceil(doubleutime(eyear, eday, emsec));
144 
145  /* Is it HRPT data? */
146  is_hrpt = strcmp((char*) dtype, "HRPT") ? 0 : 1;
147 
148  /* Is it GAC data? */
149  switch (npix) {
150  case 248: is_gac = 1;
151  break;
152  case 1285: is_gac = 0;
153  break;
154  default:
155  fprintf(stderr, "-E- %s line %d: ", __FILE__, __LINE__);
156  fprintf(stderr, "\"Pixels per Scan Line\" global attribute of file, ");
157  fprintf(stderr, "%s , has the unexpected value, %d.\n", argv[1], npix);
158  exit(EXIT_FAILURE);
159  }
160 
161  /* Consistency check. */
162  if (is_hrpt && is_gac) {
163  fprintf(stderr, "-E- %s line %d: ", __FILE__, __LINE__);
164  fprintf(stderr, "\"Pixels per Scan Line\" (= %d) ", npix);
165  fprintf(stderr, "is inconsistent with \"Data Type\" (= \"%s\") ", dtype);
166  fprintf(stderr, "in file, %s .\n", argv[1]);
167  exit(EXIT_FAILURE);
168  }
169 
170  /* Get a 3-letter code from the input filename if this is HRPT data. */
171  if (is_hrpt) {
172  char *p;
173  p = argv[1] + strlen(argv[1]) - 3;
174  strcpy(code, p);
175  }
176 
177  /* Write out the station information. */
178  if ((fh = fopen(stationfile, "wb")) == NULL) {
179  fprintf(stderr, "-E- %s line %d: Could not create file, %s . ",
180  __FILE__, __LINE__, stationfile);
181  perror(NULL);
182  exit(EXIT_FAILURE);
183  }
184  if (is_hrpt)
185  fprintf(fh, "Code: %s\n", code);
186  fprintf(fh, "Data Center: %s\n", center);
187  fprintf(fh, "Station Name: %s\n", station);
188  fprintf(fh, "Station Latitude: %f\n", lat);
189  fprintf(fh, "Station Longitude: %f\n", lon);
190  fclose(fh); /* Close the station info file. */
191 
192  /*
193  Read the s_flags SDS. I need this for bit error rates and
194  GAC scan line positions within a minor frame.
195  */
196  MALLOC(s_flags, uint8, nscan * 4);
197  READ_SDS("s_flags", s_flags, 0, 0, 0, nscan, 4, 1);
198 
199  /*
200  Due to some confusion about whether the GAC-line-number byte is
201  zero-based or one-based, different level-1A files may store that
202  byte in different ways. So, I make a guess at the scheme used
203  to write the current input file by checking the very first GAC
204  line number stored.
205  */
206  if (s_flags[2] == 0 || s_flags[2] == 5 || s_flags[2] == 10)
207  base = 0;
208  else
209  base = 1;
210 
211  /* Sum up the bit error rate values. */
212  if (is_gac) {
213  int mfnumber;
214  int prevmfnumber;
215  int gacposition;
216  int prevposition;
217 
218  for (s = 0; s < nscan; s++) {
219  mfnumber = (s_flags[4 * s + 2] - base) / 5;
220  gacposition = (s_flags[4 * s + 2] - base) % 5;
221  if (s == 0 || gacposition <= prevposition || mfnumber != prevmfnumber) {
222  ber_numerator += s_flags[4 * s];
223  ber_denominator += 5 * s_flags[4 * s + 3];
224  }
225  prevmfnumber = mfnumber;
226  prevposition = gacposition;
227  }
228  } else {
229  for (s = 0; s < nscan; s++) {
230  ber_numerator += s_flags[4 * s];
231  ber_denominator += 5 * s_flags[4 * s + 3];
232  }
233  }
234 
235  /* Fill in the header. */
236  strcpy((char*) header, "CWIF");
237 
238  if (endianess() == 1) {
239  swapc_bytes((char *) &ber_denominator, 4, 1);
240  swapc_bytes((char *) &ber_numerator, 4, 1);
241  swapc_bytes((char *) &aos, 4, 1);
242  swapc_bytes((char *) &los, 4, 1);
243  }
244 
245  header[5] = is_hrpt;
246  memcpy(&header[316], &ber_denominator, 4);
247  memcpy(&header[320], &ber_numerator, 4);
248  memcpy(&header[332], &aos, 4);
249  memcpy(&header[336], &los, 4);
250  header[511] = 1; /* Signal that this L0 file was generated from L1A. */
251 
252  /* Allocate some memory for the level-1a image data. */
253  MALLOC(l1a_data, int16, npix * 8);
254 
255  /* Create the output file and write out the header. */
256  if ((fh = fopen(argv[2], "wb")) == NULL) {
257  fprintf(stderr, "-E- %s line %d: Could not create file, %s . ",
258  __FILE__, __LINE__, argv[2]);
259  perror(NULL);
260  exit(EXIT_FAILURE);
261  }
262  fwrite(header, 1, 512, fh);
263 
264  if (is_gac) {
265  int mfnumber;
266  int prevmfnumber;
267  int gacposition;
268  int prevposition = 5;
269  int mf_is_empty = 1;
270 
271  for (s = 0; s < nscan; s++) {
272  mfnumber = (s_flags[4 * s + 2] - base) / 5;
273  gacposition = (s_flags[4 * s + 2] - base) % 5;
274  if ((gacposition <= prevposition || mfnumber != prevmfnumber) && s != 0) {
275  /* Write out the previous minor frame. */
276  fwrite(frame, 1, MINOR_FRAME_SIZE, fh);
277  /* Zero out minor frame buffer. */
278  memset(frame, 0, MINOR_FRAME_SIZE);
279  /* Signal that the minor fame is not yet initialized. */
280  mf_is_empty = 1;
281  }
282  prevmfnumber = mfnumber;
283  prevposition = gacposition;
284 
285  get_frame_data(sd_id, npix, s, sc_id, sc_ttag, sc_soh, inst_tlm,
286  l1a_data, start_syn, stop_syn, dark_rest, gain_tdi);
287 
288  /*
289  Copy the various pieces to the appropriate places in the minor frame.
290  Only one of the five scans in a GAC minor frame is used to fill in
291  the bit error rate, the spacecraft ID, the spacecraft time tag, and
292  the state-of-health telemetry. The rest of the pieces are copied
293  from each scan line.
294  */
295  if (mf_is_empty) {
296  bit_error_rate_denominator = 5 * s_flags[4 * s + 3];
297  bit_error_rate_numerator = s_flags[4 * s ];
298  fp = frame;
299  if (endianess() == 1) {
300  swapc_bytes((char *) &bit_error_rate_denominator, 2, 1);
301  swapc_bytes((char *) sc_id, 2, 2);
302  swapc_bytes((char *) sc_ttag, 2, 4);
303  }
304  memcpy(fp, &bit_error_rate_denominator, 2);
305  fp += 2;
306  memcpy(fp, &bit_error_rate_numerator, 1);
307  fp++;
308  memcpy(fp, sc_id, 4);
309  fp += 4;
310  memcpy(fp, sc_ttag, 8);
311  fp += 8;
312  memcpy(fp, sc_soh, 775);
313  mf_is_empty = 0;
314  }
315  fp = frame + 790 + gacposition * ((8 + 8 + 8 + 248 * 8 + 8)*2);
316  if (endianess() == 1) {
317  swapc_bytes((char *) gain_tdi, 2, 8);
318  swapc_bytes((char *) start_syn, 2, 8);
319  swapc_bytes((char *) dark_rest, 2, 8);
320  swapc_bytes((char *) l1a_data, 2, 1984);
321  swapc_bytes((char *) stop_syn, 2, 8);
322  swapc_bytes((char *) inst_tlm, 2, 44);
323  }
324  memcpy(fp, gain_tdi, 16);
325  fp += 16;
326  memcpy(fp, start_syn, 16);
327  fp += 16;
328  memcpy(fp, dark_rest, 16);
329  fp += 16;
330  memcpy(fp, l1a_data, 3968);
331  fp += 3968;
332  memcpy(fp, stop_syn, 16);
333  fp = frame + 790 + 5 * (8 + 8 + 8 + 248 * 8 + 8)*2 + gacposition * (44 * 2);
334  memcpy(fp, inst_tlm, 88);
335  }
336 
337  /* Write out the final minor frame of GAC data. */
338  fwrite(frame, 1, MINOR_FRAME_SIZE, fh);
339 
340  } else { /* non-GAC data */
341  for (s = 0; s < nscan; s++) {
342  get_frame_data(sd_id, npix, s, sc_id, sc_ttag, sc_soh, inst_tlm,
343  l1a_data, start_syn, stop_syn, dark_rest, gain_tdi);
344  bit_error_rate_denominator = 5 * s_flags[4 * s + 3];
345  bit_error_rate_numerator = s_flags[4 * s ];
346  fp = frame;
347  if (endianess() == 1) {
348  swapc_bytes((char *) &bit_error_rate_denominator, 2, 1);
349  swapc_bytes((char *) sc_id, 2, 2);
350  swapc_bytes((char *) sc_ttag, 2, 4);
351  swapc_bytes((char *) inst_tlm, 2, 44);
352  swapc_bytes((char *) gain_tdi, 2, 8);
353  swapc_bytes((char *) start_syn, 2, 8);
354  swapc_bytes((char *) dark_rest, 2, 8);
355  swapc_bytes((char *) l1a_data, 2, 10280);
356  swapc_bytes((char *) stop_syn, 2, 8);
357  }
358  memcpy(fp, &bit_error_rate_denominator, 2);
359  fp += 2;
360  memcpy(fp, &bit_error_rate_numerator, 1);
361  fp++;
362  memcpy(fp, sc_id, 4);
363  fp += 4;
364  memcpy(fp, sc_ttag, 8);
365  fp += 8;
366  memcpy(fp, sc_soh, 775);
367  fp += 775;
368  memcpy(fp, inst_tlm, 88);
369  fp += 88;
370  memcpy(fp, gain_tdi, 16);
371  fp += 16;
372  memcpy(fp, start_syn, 16);
373  fp += 16;
374  memcpy(fp, dark_rest, 16);
375  fp += 16;
376  memcpy(fp, l1a_data, 20560);
377  fp += 20560;
378  memcpy(fp, stop_syn, 16);
379  /* Write out the minor frame. */
380  fwrite(frame, 1, MINOR_FRAME_SIZE, fh);
381  /* Zero out minor frame buffer. */
382  memset(frame, 0, MINOR_FRAME_SIZE);
383  }
384  }
385  fclose(fh); /* Close the level-0 file. */
386  exit(0);
387 }
388 
389 
390 
391 
392 
393 /* Leap year definition from Kernighan and Ritchie page 37 */
394 #define IS_LEAP_YEAR(y) ( (!((y)%4) && (y)%100) || !((y)%400) )
395 #define EPOCH_YEAR 1970
396 #define SECONDS_PER_YEAR 31536000
397 #define SECONDS_PER_LEAP_YEAR 31622400
398 
399 double doubleutime(int16 year, int16 day, int32 msec) {
400 
401  double utime = 0;
402  int y;
403 
404  for (y = EPOCH_YEAR; y < year; y++)
406  utime += (day - 1) * 86400;
407  utime += msec / 1000.0;
408  return (utime);
409 }
410 
411 void
413  int32 sd_id, /* This variable is part of the READ_SDS macro. */
414  int32 npix,
415  int32 scan,
416  int16 *sc_id,
417  int16 *sc_ttag,
418  uint8 *sc_soh,
419  int16 *inst_tlm,
420  int16 *l1a_data,
421  int16 *start_syn,
422  int16 *stop_syn,
423  int16 *dark_rest,
424  int16 *gain_tdi
425  ) {
426  int16 gain[8], tdi[8];
427  int b;
428 
429  READ_SDS("sc_id", sc_id, scan, 0, 0, 1, 2, 1);
430  READ_SDS("sc_ttag", sc_ttag, scan, 0, 0, 1, 4, 1);
431  READ_SDS("sc_soh", sc_soh, scan, 0, 0, 1, 775, 1);
432  READ_SDS("inst_tlm", inst_tlm, scan, 0, 0, 1, 44, 1);
433  READ_SDS("l1a_data", l1a_data, scan, 0, 0, 1, npix, 8);
434  READ_SDS("start_syn", start_syn, scan, 0, 0, 1, 8, 1);
435  READ_SDS("stop_syn", stop_syn, scan, 0, 0, 1, 8, 1);
436  READ_SDS("dark_rest", dark_rest, scan, 0, 0, 1, 8, 1);
437  READ_SDS("gain", gain, scan, 0, 0, 1, 8, 1);
438  READ_SDS("tdi", tdi, scan, 0, 0, 1, 8, 1);
439 
440  for (b = 0; b < 8; b++) {
441  gain_tdi[b] = ((gain[b] << 8) & 0x0300) | (tdi[b] & 0x00FF);
442  }
443 }
integer, parameter int16
Definition: cubeio.f90:3
#define READ_SDS(nam, ptr, s0, s1, s2, e0, e1, e2)
Definition: main_l0regen.c:31
int16 eday
Definition: l1_czcs_hdf.c:17
int32_t day
===========================================================================V4.1.3 12/18/2002============================================================================Changes which do not affect scientific output:1. The R *LUT was eliminated and the equivalent formulation for R *, i.e. 1/(m1 *e_sun_over_pi), was substituted for it in the only instance of its use, which is in the calculation of the RSB uncertainty index. This reduces the size of the Reflective LUT HDF file by approximately 1/4 to 1/3. The equivalent formulation of R *differed from the new by at most 0.056% in test granules and uncertainty differences of at most 1 count(out of a range of 0-15) were found in no more than 1 in 100, 000 pixels. 2. In Preprocess.c, a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed. This counter is internal only and is not yet used for any purpose. 3. NEW MYD02OBC Metadata Configuration Files. MCST wishes to have the OBC files archived even when the Orbit Number is recorded as "-1". Accordingly, ECS has delivered new MCF files for OBC output having all elements in the OrbitCalculatedSpatialDomain container set to "MANDATORY=FALSE". 4. pgs_in.version is now reset to "1" in Metadata.c before the call to look up the geolocation gringpoint information.============================================================================V4.1.1 CODE SPECIFIC TO MODIS/AQUA(FM1) 10/03/2002============================================================================Two changes were made to the code which do not affect scientific output:1. A bug which caused PGE02 to fail when scans were dropped between granules was fixed.(The length of the error message generated was shortened.) 2. Messages regarding an invalid MCST LUT Version or an invalid Write High Resolution Night Mode Output value in the PCF file were added.==============================================================================V4.1.0 CODE SPECIFIC TO MODIS/AQUA(FM1)(NEVER USED IN PRODUCTION) 07/30/2002==============================================================================Changes which impact scientific output of code:1. The LUT type of the RVS corrections was changed to piecewise linear. In addition the RVS LUTs were changed from listing the RVS corrections to listing the quadratic coefficients necessary to make the RVS corrections. The coefficients are now calculated by interpolating on the granule collection time and the RVS corrections are then generated using the interpolated coefficients. Previously used Emissive and Reflective RVS LUT tables were eliminated and new ones introduced. Several changes were made to the code which should not affect scientific output. They are:1. The ADC correction algorithm and related LUTs were stripped from the code.(The ADC correction has always been set to "0" so this has no scientific impact.) 2. Some small changes to the code, chiefly to casting of variables, were added to make it LINUX-compatible. Output of code run on LINUX machines displays differences of at most 1 scaled integer(SI) from output of code run on IRIX machines. The data type of the LUT "dn_sat_ev" was changed to float64 to avoid discrepancies seen between MOD_PR02 run on LINUX systems and IRIX systems where values were flagged under one operating system but not the other. 3. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 4. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 5.(MODIS/AQUA ONLY) The name of the seed(error message) file was changed from "MODIS_36100.h" to "MODIS_36110.h". 6. Metadata.c was changed so that the source of the geolocation metadata is the input geolocation file rather than the L1A granule. 7. To reduce to overall size of the reflective LUT HDF files, fill values were eliminated from all LUTs previously dimensioned "BDSM"([NUM_REFLECTIVE_BANDS] *[MAX_DETECTORS_PER_BAND] *[MAX_SAMPLES_PER_BAND] *[NUM_MIRROR_SIDES]) in the LUT HDF files. Each table piece is stored in the HDF file with dimensions NUM_REFLECTIVE_INDICES, where NUM_REFLECTIVE_INDICES=[NUM_250M_BANDS *DETECTORS_PER_250M_BAND *SAMPLES_PER_250M_BAND *NUM_MIRROR_SIDES]+[NUM_500M_BANDS *DETECTORS_PER_500M_BAND *SAMPLES_PER_500M_BAND *NUM_MIRROR_SIDES]+[NUM_1000M_BANDS *DETECTORS_PER_1KM_BAND *SAMPLES_PER_1KM_BAND *NUM_MIRROR_SIDES] with SAMPLES_PER_250M_BAND=4, SAMPLES_PER_500M_BAND=2, and SAMPLES_PER_1KM_BAND=1. Values within each table piece appear in the order listed above. The overall dimensions of time dependent BDSM LUTs are now[NUM_TIMES] *[NUM_REFLECTIVE_INDICES], where NUM_TIMES is the number of time dependent table pieces. 8. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 9. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 10. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop.============================================================================V3.1.0(Original Aqua-specific code version) 02/06/2002============================================================================AQUA-Specific changes made:1. A correction to a problem with blackbody warmup on bands 33, 35, and 36 was inserted. PC Bands 33, 35, and 36 on MODIS Aqua saturate on BB warmup before 310K, which means current code will not provide correct b1 calibration coefficients when the BB temperatures are above the saturation threshold. A LUT with default b1s and band-dependent temperature thresholds will be inserted in code. If the BB temperature is over the saturation threshold for the band, the default b1 from the table is used. 2. The number of possible wavelengths in the Emissive LUT RSR file was changed to 67 in order to accommodate the Aqua RSR tables. 3. Several changes to the upper and lower bound limits on LUT values were inserted. Changes to both Aqua and Terra Code:1. A check was put into Emissive_Cal.c to see whether the value of b1 being used to calibrate a pixel is negative. If so, the pixel is flagged with the newly created flag TEB_B1_NOT_CALCULATED, value 65526, and the number of pixels for which this occurs is counted in the QA_common table. 2. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop. 3. Minor code changes were made to eliminate compiler warnings when the code is compiled in 64-bit mode. 4. Temperature equations were upgraded to be MODIS/Aqua or MODIS/Terra specific and temperature conversion coefficients for Aqua were inserted.========================================================================================================================================================ALL CHANGES BELOW ARE TO COMMON TERRA/AQUA CODE USED BEFORE 02/06/2002========================================================================================================================================================v3.0.1 11/26/2001============================================================================Several small changes to the code were made, none of which changes the scientific output:1. The code was changed so that production of 250m and 500m resolution data when all scans of a granule are in night mode may be turned off/on through the PCF file. 2. A check on the times of the leading and trailing granules was inserted. If a leading or trailing granule does not immediately precede or follow(respectively) the middle granule, it is treated as a missing granule and a warning message is printed. 3. The code now reads the "MCST Version Number"(e.g. "3.0.1.0_Terra") from the PCF file and checks it against the MCST Version number contained in the LUT HDF files. This was done to allow the user to make sure the code is being run using the correct LUT files.(The designators "0_Terra", "1_Terra", etc.) refer to the LUT versions.) 4. A small bug in Preprocess.c was corrected code
Definition: HISTORY.txt:661
int16 * gain
Definition: l1_czcs_hdf.c:33
#define FAIL
Definition: ObpgReadGrid.h:18
#define NULL
Definition: decode_rs.h:63
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 SECONDS_PER_LEAP_YEAR
Definition: main_l0regen.c:397
int16_t * l1a_data
Definition: l1a_seawifs.c:84
float32 base
Definition: maplists.h:106
int16_t * dark_rest
Definition: l1a_seawifs.c:89
float * lat
int32 * msec
Definition: l1_czcs_hdf.c:31
int16 eyear
Definition: l1_czcs_hdf.c:17
int syear
Definition: l1_czcs_hdf.c:15
int32 nscan
Definition: l1_czcs_hdf.c:19
int32 smsec
Definition: l1_czcs_hdf.c:16
#define VERSION
Definition: main_l0regen.c:19
int endianess(void)
determine endianess
Definition: endianess.c:10
int swapc_bytes(char *in, int nbyte, int ntime)
Definition: swapc_bytes.c:4
int sday
Definition: l1_czcs_hdf.c:15
int main(int argc, char *argv[])
Definition: main_l0regen.c:59
#define MINOR_FRAME_SIZE
Definition: main_l0regen.c:53
#define IS_LEAP_YEAR(y)
Definition: main_l0regen.c:394
void get_frame_data(int32, int32, int32, int16 *, int16 *, uint8 *, int16 *, int16 *, int16 *, int16 *, int16 *, int16 *)
Definition: main_l0regen.c:412
int16_t tdi[BANDS_DIMS_1A]
Definition: l1a_seawifs.c:37
#define READ_GLBL_ATTR(nam, ptr)
Definition: main_l0regen.c:22
#define SECONDS_PER_YEAR
Definition: main_l0regen.c:396
data_t b[NROOTS+1]
Definition: decode_rs.h:77
int32 emsec
Definition: l1_czcs_hdf.c:18
#define EPOCH_YEAR
Definition: main_l0regen.c:395
def center
Definition: sort_gring.py:68
dtype
Definition: DDataset.hpp:31
float * lon
data_t s[NROOTS]
Definition: decode_rs.h:75
double doubleutime(int16, int16, int32)
Definition: main_l0regen.c:399
#define MALLOC(ptr, typ, num)
Definition: main_l0regen.c:44
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
int npix
Definition: get_cmp.c:27
#define USAGE
Definition: main_l0regen.c:20
float p[MODELMAX]
Definition: atrem_corl1.h:131