OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
get_viirs_packet_time.c
Go to the documentation of this file.
1 // Ported from IDL procedure to unpack and convert the CCSDS segmented time code
2 // from the first packet of a VIIRS packet group
3 
4 
5 // Arguments
6 //
7 // Name Type I/O Description
8 // ---- ---- --- -----------
9 // p1 byte(*) I Input array containing first packet
10 // pyear I*4 O Year of packet time
11 // pday I*4 O Day of packet time
12 // eyear I*4 O Year of packet end time
13 // eday I*4 O Day of packet end time
14 // syear I*4 O Year of scan start time
15 // sday I*4 O Day of scan start time
16 // stime R*8 O Packet scan start time
17 // ptime R*8 O Packet time
18 // etime R*8 O Packet scan end time
19 
20 // Liang Hong, July 22, 2015
21 // Liang Hong, added year, day for packet, start and end time
22 
23 #include <stdint.h>
24 #include <timeutils.h>
25 
26 int get_viirs_packet_time(uint8_t p1[], int32_t *pyear, int32_t *eyear, int32_t *syear, int32_t *pday, int32_t *eday, int32_t *sday, double *stime, double *ptime, double *etime) {
27  uint8_t cctime[8];
28  int toff;
29  // Get day count since Jan. 1, 1958 (Julian day 2436205)
30 
31  // Packet time
32  toff = 18; // changed from 20, Liang H. 8/5/2015
33  memcpy(cctime, &p1[toff], 8);
34  ccsds_to_yds(cctime, pyear, pday, ptime);
35 
36  // Scan end time
37  toff = 40; // changed from 38, Liang H. 8/5/2015
38  memcpy(cctime, &p1[toff], 8);
39  ccsds_to_yds(cctime, eyear, eday, etime);
40 
41  // Scan start time
42  toff = 6;
43  memcpy(cctime, &p1[toff], 8);
44  ccsds_to_yds(cctime, syear, sday, stime);
45 
46  return 0;
47 }
48 
int16 eday
Definition: l1_czcs_hdf.c:17
int get_viirs_packet_time(uint8_t p1[], int32_t *pyear, int32_t *eyear, int32_t *syear, int32_t *pday, int32_t *eday, int32_t *sday, double *stime, double *ptime, double *etime)
int16 eyear
Definition: l1_czcs_hdf.c:17
int syear
Definition: l1_czcs_hdf.c:15
int ccsds_to_yds(uint8_t *cctime, int32_t *iyear, int32_t *iday, double *sec)
Definition: ccsds_to_yds.c:5
int sday
Definition: l1_czcs_hdf.c:15