OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
rd_geo_scan.c
Go to the documentation of this file.
1 #include "viirs_sim_sdr.h"
2 
3 int rd_geo_scan(int iscn, sdr_info_struc *sdr_info, in_rec_struc *in_rec)
4 /*-----------------------------------------------------------------------------
5  Program: rd_geo_scan.c
6 
7  Description: get all scan oriented data from simulated geolocation dataset
8 
9  Arguments:
10  Type Name I/O Description
11  ---- ---- --- -----------
12  int iscn I scan to read
13  sdr_info_struc * sdr_info I general sdr information
14  in_rec_struc * in_rec I/O input record controls
15 
16  Modification history:
17 
18  W. Robinson, SAIC 21 Oct 2008 Original development
19  W. Robinson, SAIC 17 Mar 2010 adapt for scan oriented use
20 
21 ----------------------------------------------------------------------------*/ {
22  int start[2], count[2], ipix, idet, st_line, nlin, loc;
23  float lon;
24  /*
25  * Start with the latitude scan
26  */
27  st_line = iscn * in_rec->ndet_scan;
28  nlin = in_rec->ndet_scan;
29  start[0] = st_line;
30  start[1] = 0;
31  count[0] = nlin;
32  count[1] = in_rec->npix;
33  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[0]), start, count,
34  (void *) (in_rec->lat)) != 0) {
35  printf("%s, %d: lat input failed on scan: %d\n", __FILE__, __LINE__,
36  iscn);
37  return 1;
38  }
39  /* longitude */
40  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[1]), start, count,
41  (void *) (in_rec->lon)) != 0) {
42  printf("%s, %d: lon input failed on scan: %d\n", __FILE__, __LINE__,
43  iscn);
44  return 1;
45  }
46  /*
47  * update the latitude and longitude limits
48  */
49  for (idet = 0; idet < nlin; idet++) {
50  for (ipix = 0; ipix < in_rec->npix; ipix++) {
51  loc = idet * in_rec->npix + ipix;
52  if (*(in_rec->lat + loc) < in_rec->ll_lims[0])
53  in_rec->ll_lims[0] = *(in_rec->lat + loc);
54  if (*(in_rec->lat + loc) > in_rec->ll_lims[1])
55  in_rec->ll_lims[1] = *(in_rec->lat + loc);
56  if ((lon = *(in_rec->lon + loc)) >= 0) {
57  if (lon < in_rec->ll_lims[2]) in_rec->ll_lims[2] = lon;
58  if (lon > in_rec->ll_lims[3]) in_rec->ll_lims[3] = lon;
59  } else {
60  if (lon < in_rec->ll_lims[4]) in_rec->ll_lims[4] = lon;
61  if (lon > in_rec->ll_lims[5]) in_rec->ll_lims[5] = lon;
62  }
63  }
64  }
65  /* sensor azimuth */
66  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[2]), start, count,
67  (void *) (in_rec->sena)) != 0) {
68  printf("%s, %d: sena input failed on scan: %d\n", __FILE__, __LINE__
69  , iscn);
70  return 1;
71  }
72  /* sensor zenith */
73  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[3]), start, count,
74  (void *) (in_rec->senz)) != 0) {
75  printf("%s, %d: senz input failed on scan: %d\n", __FILE__, __LINE__
76  , iscn);
77  return 1;
78  }
79  /* solar azimuth */
80  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[4]), start, count,
81  (void *) (in_rec->sola)) != 0) {
82  printf("%s, %d: sola input failed on scan: %d\n", __FILE__, __LINE__,
83  iscn);
84  return 1;
85  }
86  /* solar zenith */
87  if (h5io_rd_ds_slice(&(in_rec->geo_dat_id[5]), start, count,
88  (void *) (in_rec->solz)) != 0) {
89  printf("%s, %d: solz input failed on scan: %d\n", __FILE__, __LINE__,
90  iscn);
91  return 1;
92  }
93  return 0;
94 }
int rd_geo_scan(int iscn, sdr_info_struc *sdr_info, in_rec_struc *in_rec)
Definition: rd_geo_scan.c:3
int nlin
Definition: get_cmp.c:28
int h5io_rd_ds_slice(h5io_str *ds_id, int *start, int *count, void *data)
Definition: h5io.c:602
data_t loc[NROOTS]
Definition: decode_rs.h:78
float * lon
int count
Definition: decode_rs.h:79