OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
EnvsatDSD.cpp
Go to the documentation of this file.
1 /*
2  * File: EnvsatDSD.cpp
3  * Author: dshea
4  *
5  * Created on November 28, 2012, 1:11 PM
6  */
7 
8 #include "EnvsatDSD.h"
9 
10 #include "EnvsatUtil.h"
11 #include <stdio.h>
12 #include <sys/types.h>
13 #include <unistd.h>
14 #include <stdlib.h>
15 
16 using namespace std;
17 
18 const string EnvsatDSD::DSD_NAME_KEY_VALUE = "DS_NAME";
19 
21  init(orig.sph, orig.buffer, orig.index);
22 }
23 
24 EnvsatDSD::EnvsatDSD(EnvsatSPH* sph, char* buffer, int index) {
25  init(sph, buffer, index);
26 }
27 
29 
30 }
31 
32 void EnvsatDSD::init(EnvsatSPH* sph, char* buffer, int index) {
33  this->sph = sph;
34  this->buffer = buffer;
35  this->index = index;
36 }
37 
39  string name;
40  getString(buffer, name, DSD_NAME_KEY_OFFSET, DSD_NAME_KEY_LENGTH);
41  return name.compare(DSD_NAME_KEY_VALUE) == 0;
42 }
43 
44 string& EnvsatDSD::getName() {
45  static string name;
46  getString(buffer, name, DS_NAME_OFFSET, DS_NAME_LENGTH);
47  return name;
48 }
49 
51  return buffer[DS_TYPE_OFFSET];
52 }
53 
55  return getInt64(buffer, DS_OFFSET_OFFSET, DS_OFFSET_LENGTH);
56 }
57 
59  setInt64(offset, buffer, DS_OFFSET_OFFSET, DS_OFFSET_LENGTH);
60 }
61 
63  return getInt64(buffer, DS_SIZE_OFFSET, DS_SIZE_LENGTH);
64 }
65 
66 void EnvsatDSD::setDSSize(int64_t size) {
67  setInt64(size, buffer, DS_SIZE_OFFSET, DS_SIZE_LENGTH);
68 }
69 
71  return getInt(buffer, NUM_DSR_OFFSET, NUM_DSR_LENGTH);
72 }
73 
75  setInt(size, buffer, NUM_DSR_OFFSET, NUM_DSR_LENGTH);
76 }
77 
79  return getInt64(buffer, DSR_SIZE_OFFSET, DSR_SIZE_LENGTH);
80 }
81 
82 void EnvsatDSD::setDSRSize(int64_t size) {
83  setInt64(size, buffer, DSR_SIZE_OFFSET, DSR_SIZE_LENGTH);
84 }
85 
87  off_t result;
88  result = lseek(fd, (off_t) getDSOffset(), SEEK_SET);
89  if (result == -1) {
90  printf("Error %s:%s:%d seek to data start failed\n", __FILE__,
91  __func__, __LINE__);
92  exit(1);
93  }
94 }
95 
97  printf("EnvsatDSD-----\n");
98  if (isValid()) {
99  printf("name = %s\n", getName().c_str());
100  printf("index = %d\n", getIndex());
101  printf("Type = %c\n", getType());
102  printf("DSOffset = %ld\n", (long) getDSOffset());
103  printf("DSSize = %ld\n", (long) getDSSize());
104  printf("numDSRs = %d\n", getNumDSRs());
105  printf("DSRSize = %ld\n", (long) getDSRSize());
106  } else {
107  printf("DSD %d is invalid\n", index);
108  }
109 }
110 
112  print();
113 }
virtual void setDSRSize(int64_t size)
Definition: EnvsatDSD.cpp:82
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
virtual void setDSSize(int64_t size)
Definition: EnvsatDSD.cpp:66
virtual int64_t getDSSize()
Definition: EnvsatDSD.cpp:62
int64_t getInt64(const char *buffer, unsigned int offset, int size)
Definition: EnvsatUtil.cpp:66
int getInt(const char *buffer, unsigned int offset, int size)
Definition: EnvsatUtil.cpp:50
virtual ~EnvsatDSD()
Definition: EnvsatDSD.cpp:28
virtual int getNumDSRs()
Definition: EnvsatDSD.cpp:70
virtual int64_t getDSRSize()
Definition: EnvsatDSD.cpp:78
int init(int32_t ipr, int32_t jpr, char *efile, char *pfile)
Definition: proj_report.c:51
virtual void seekDataStart(int fd)
Definition: EnvsatDSD.cpp:86
virtual void setDSOffset(int64_t offset)
Definition: EnvsatDSD.cpp:58
void setInt64(int64_t val, char *buffer, unsigned int offset, int size)
Definition: EnvsatUtil.cpp:75
virtual std::string & getName()
Definition: EnvsatDSD.cpp:44
virtual void setNumDSRs(int size)
Definition: EnvsatDSD.cpp:74
virtual void printRecursive()
Definition: EnvsatDSD.cpp:111
virtual int64_t getDSOffset()
Definition: EnvsatDSD.cpp:54
virtual char getType()
Definition: EnvsatDSD.cpp:50
void getString(const char *buffer, string &str, unsigned int offset, int size)
Definition: EnvsatUtil.cpp:45
EnvsatDSD(const EnvsatDSD &orig)
Definition: EnvsatDSD.cpp:20
virtual bool isValid()
Definition: EnvsatDSD.cpp:38
l2prod offset
void setInt(int val, char *buffer, unsigned int offset, int size)
Definition: EnvsatUtil.cpp:59
virtual void print()
Definition: EnvsatDSD.cpp:96