OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
hawkeyeUtil.h
Go to the documentation of this file.
1 #include "netcdf.h"
2 #include "nc4utils.h"
3 #include "timeutils.h"
4 
5 const int PHDRLEN = 6; // length of primary header
6 const int SHDRLEN = 6; // length of secondary header
7 const int PUSLEN = 3; // length of PUS header
8 
9 using namespace std;
10 
11 
12 int createFile( const char* filename, const char* cdlfile,
13  size_t sdim, int *ncid, int *gid);
14 
15 int parseDims( int ncid, int ndims, string dimString, int *numDims,
16  int *dimid, int *varDims);
17 
18 int createNCDF( int ncid, const char *sname, const char *lname,
19  const char *standard_name, const char *units,
20  void *fill_value,
21  const char *flag_values, const char *flag_meanings,
22  double low, double high,
23  float scale_factor, float add_offset,
24  int nt, int rank, int *dimids);
25 
26 int tepoch2yds( double tepoch, int32_t *iyr, int32_t *idy, double *sec);
27 
28 /*
29 int get_packet_from_frame( ifstream *framefile, uint8_t **packet,
30  uint32_t &packet_length, int first);
31 */
32 
33 int readFrame ( ifstream *framefile, uint8_t frame[892], int& prevFrameCnt,
34  int ierror[2]);
35 
36 int getSHpacket( ifstream *framefile, uint8_t frame[892], int& framePtr,
37  uint8_t **packet, int& packetLength, int& prevFrameCnt,
38  int& frameDrop);
39 
40 inline
41 int expandEnvVar( string *sValue) {
42  if ( (*sValue).find_first_of( "$" ) == string::npos) return 0;
43  string::size_type posEndIdx = (*sValue).find_first_of( "/" );
44  if ( posEndIdx == string::npos) return 0;
45  char *envVar_str = getenv((*sValue).substr( 1, posEndIdx-1 ).c_str());
46  if (envVar_str == 0x0) {
47  printf("Environment variable: %s not defined.\n", envVar_str);
48  exit(1);
49  }
50  *sValue = envVar_str + (*sValue).substr( posEndIdx);
51 
52  return 0;
53 }
54 
int readFrame(ifstream *framefile, uint8_t frame[892], int &prevFrameCnt, int ierror[2])
const int PHDRLEN
Definition: hawkeyeUtil.h:5
const int PUSLEN
Definition: hawkeyeUtil.h:7
const int SHDRLEN
Definition: hawkeyeUtil.h:6
int parseDims(int ncid, int ndims, string dimString, int *numDims, int *dimid, int *varDims)
int expandEnvVar(string *sValue)
Definition: hawkeyeUtil.h:41
int getSHpacket(ifstream *framefile, uint8_t frame[892], int &framePtr, uint8_t **packet, int &packetLength, int &prevFrameCnt, int &frameDrop)
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
int createFile(const char *filename, const char *cdlfile, size_t sdim, int *ncid, int *gid)
Definition: hawkeyeUtil.cpp:39
int tepoch2yds(double tepoch, int32_t *iyr, int32_t *idy, double *sec)
int createNCDF(int ncid, const char *sname, const char *lname, const char *standard_name, const char *units, void *fill_value, const char *flag_values, const char *flag_meanings, double low, double high, float scale_factor, float add_offset, int nt, int rank, int *dimids)
Extra metadata that will be written to the HDF4 file l2prod rank
int32_t idy
Definition: atrem_corl1.h:161
These two strings are used for the product XML output If product_id is not set then prefix is used If the last char of the name_prefix is _ then it is removed If algorithm_id is not set then name_suffix is used If the first char is _ then it is removed l2prod standard_name[0]
int32_t iyr
Definition: atrem_corl1.h:161