OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
hdr_2_gattr.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "l1czcs.h"
3 
4 void hdr_2_gattr(HEADER2_TYPE header2, gattr_struc *gattr)
5 /*******************************************************************
6 
7  hdr_2_gattr
8 
9  purpose: extract and convert the CRTT header data into values needed
10  for the output file global attributes
11 
12  Returns type: void
13 
14  Parameters: (in calling order)
15  Type Name I/O Description
16  ---- ---- --- -----------
17  HEADER2TYPE header2 I structure with CRTT header
18  gattr_struc * gattr I/O structure with final
19  attributes
20 
21  Modification history:
22  Programmer Date Description of change
23  ---------- ---- ---------------------
24  W. Robinson 9-Mar-2004 Original development
25 
26  *******************************************************************/ {
27  int i;
28  unsigned short us;
29  /*
30  * Just fill the needed values, converting when necessary
31  */
32  gattr->start_year = header2.starting_yr;
33  gattr->start_day = header2.starting_day;
34  gattr->start_msec = header2.start_msec;
35 
36  time_str(header2.starting_yr, header2.starting_day, header2.start_msec,
37  gattr->start_time);
38  /*
39  * get the scene center time
40  */
41  time_str(header2.scene_cntr_yr, header2.scene_cntr_doy,
42  header2.scene_cntr_msec, gattr->center_time);
43 
44  gattr->orbit = (unsigned short) header2.orbit;
45  gattr->gain = header2.gain;
46  gattr->thresh = header2.threshold;
47  gattr->tilt = header2.tilt / 1000.;
48 
49  gattr->center_lat = header2.lat_cntr / 100. - 90.;
50  us = (unsigned short) header2.long_cntr;
51  gattr->center_lon = (us > 18000) ? us / 100. - 360. : us / 100.;
52 
53  gattr->pix_per_scan = 1968;
54  gattr->scan_lines = header2.no_of_scans;
55 
56  /* North limit, choose among top corners
57  printf( "long corners: fitr %d, litr %d, fitl %d, litl %d\n", header2.long_crnr_fitr, header2.long_crnr_litr, header2.long_crnr_fitl, header2.long_crnr_litl );
58  printf( "lat corners: fitr %d, litr %d, fitl %d, litl %d\n", header2.lat_crnr_fitr, header2.lat_crnr_litr, header2.lat_crnr_fitl, header2.lat_crnr_litl );
59  */
60 
61  gattr->limits[0] = (header2.lat_crnr_litl > header2.lat_crnr_litr) ?
62  header2.lat_crnr_litl / 100. : header2.lat_crnr_litr / 100.;
63  /* South */
64  gattr->limits[1] = (header2.lat_crnr_fitl < header2.lat_crnr_fitr) ?
65  header2.lat_crnr_fitl / 100. : header2.lat_crnr_fitr / 100.;
66  /* West */
67  gattr->limits[2] = (header2.long_crnr_fitl < header2.long_crnr_litl) ?
68  header2.long_crnr_fitl / 100. : header2.long_crnr_litl / 100.;
69  /* East */
70  gattr->limits[3] = (header2.long_crnr_fitr > header2.long_crnr_litr) ?
71  header2.long_crnr_fitr / 100. : header2.long_crnr_litr / 100.;
72 
73  /*
74  * slope and intercept
75  */
76  for (i = 0; i < 6; i++) {
77  gattr->slope[i] = fixed_pt_2_floating_pt(header2.chan_line[i].slope, 24);
78  gattr->intercept[i] =
79  fixed_pt_2_floating_pt(header2.chan_line[i].intercept, 24);
80  }
81  /*
82  * pitch, roll and yaw
83  */
84  gattr->roll = header2.cntr_roll / 1000.;
85  gattr->pitch = header2.cntr_pitch / 1000.;
86  gattr->yaw = header2.cntr_yaw / 1000.;
87  /*
88  * file metric info (is any of this really used, we'll find out)
89  */
90  gattr->ilt_flags = header2.ilt_flags;
91  gattr->parm_presence = header2.parameter_presence;
92  gattr->n_miss_scans = header2.no_of_missing_scans_all;
93  for (i = 0; i < 6; i++)
94  gattr->n_scan_mis_chan[i] = header2.no_of_missing_scans[i];
95  gattr->n_hdt_sync_loss = header2.no_of_hdt_sync_losses;
96  gattr->n_hdt_parity_err = header2.no_of_hdt_parity_errs;
97  gattr->n_wbvt_sync_loss = header2.no_of_wbvt_sync_losses;
98  gattr->n_wbvt_slips = header2.no_of_wbvt_bit_slips;
99  return;
100 }
float fixed_pt_2_floating_pt(int, int)
Definition: read_crtt.c:211
void hdr_2_gattr(HEADER2_TYPE header2, gattr_struc *gattr)
Definition: hdr_2_gattr.c:4
int time_str(short, short, int, char *)
Definition: time_str.c:3
int i
Definition: decode_rs.h:71