OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
EnvsatSPH.cpp
Go to the documentation of this file.
1 /*
2  * File: EnvsatSPH.cpp
3  * Author: dshea
4  *
5  * Created on November 28, 2012, 1:11 PM
6  */
7 
8 #include "EnvsatSPH.h"
9 
10 #include "EnvsatUtil.h"
11 #include "EnvsatDSD.h"
12 
13 #include <unistd.h>
14 #include <string.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string>
18 
19 using namespace std;
20 
21 //EnvsatSPH::EnvsatSPH() {
22 // size=0;
23 // buffer = NULL;
24 // envsatFile = NULL;
25 //}
26 
28  init(orig.envsatFile, orig.size, orig.numDSDs, orig.DSDSize);
29  memcpy(this->buffer, orig.buffer, size);
30  createDSDs();
31 }
32 
33 EnvsatSPH::EnvsatSPH(EnvsatFile* file, int size, int numDSDs, int DSDSize) {
34  init(file, size, numDSDs, DSDSize);
35 }
36 
38  delete buffer;
39  deleteDSDs();
40 }
41 
43  if (size != src.size) {
44  printf("Error %s:%s:%d size mismatch, this=%d, src=%d\n", __FILE__,
45  __func__, __LINE__, size, src.size);
46  exit(1);
47  }
48  memcpy(buffer, src.buffer, size);
49  numDSDs = src.numDSDs;
50  DSDSize = src.DSDSize;
51  deleteDSDs();
52  createDSDs();
53  return *this;
54 }
55 
56 void EnvsatSPH::init(EnvsatFile* file, int size, int numDSDs, int DSDSize) {
57  this->size = size;
58  buffer = new char[size];
59  envsatFile = file;
60  this->numDSDs = numDSDs;
61  this->DSDSize = DSDSize;
62  envsatDSDs = new EnvsatDSD*[numDSDs];
63  for (int i = 0; i < numDSDs; i++)
64  envsatDSDs[i] = NULL;
65 }
66 
67 int EnvsatSPH::readHeader(int fin) {
68  int result;
69  int num = 0;
70 
71  while (num < size) {
72  result = read(fin, buffer + num, size - num);
73  if (result == -1)
74  return -1;
75  else
76  num += result;
77  }
78 
79  deleteDSDs();
80  createDSDs();
81  return 0;
82 }
83 
84 int EnvsatSPH::writeHeader(int fout) {
85  int result;
86  int num = 0;
87 
88  while (num < size) {
89  result = write(fout, buffer + num, size - num);
90  if (result == -1)
91  return -1;
92  else
93  num += result;
94  }
95  return 0;
96 }
97 
99  return numDSDs;
100 }
101 
103  if (numDSDs == 0)
104  return NULL;
105  if (index >= numDSDs)
106  return NULL;
107  return envsatDSDs[index];
108 }
109 
111  for (int i = 0; i < getNumDSDs(); i++) {
112  EnvsatDSD* dsd = getDSD(i);
113  if (dsd != NULL)
114  if (dsd->getType() == DSDType)
115  return dsd;
116  }
117  return NULL;
118 }
119 
121  for (int i = 0; i < getNumDSDs(); i++) {
122  EnvsatDSD* dsd = getDSD(i);
123  if (dsd != NULL) {
124  if (dsd->getName() == name)
125  return dsd;
126  }
127  }
128  return NULL;
129 }
130 
132  if (envsatDSDs == NULL) {
133  printf("Error %s:%s:%d envsatDSDs is NULL\n", __FILE__, __func__,
134  __LINE__);
135  exit(1);
136  }
137 
138  int dsdOffset = size - numDSDs * DSDSize;
139  for (int i = 0; i < numDSDs; i++) {
140  envsatDSDs[i] = new EnvsatDSD(this, buffer + dsdOffset, i);
141  dsdOffset += DSDSize;
142  }
143 }
144 
146  if (envsatDSDs == NULL) {
147  printf("Error %s:%s:%d DSD buffer alignment \n", __FILE__, __func__,
148  __LINE__);
149  exit(1);
150  }
151 
152  for (int i = 0; i < numDSDs; i++) {
153  if (envsatDSDs[i] != NULL)
154  delete envsatDSDs[i];
155  }
156 }
157 
159  printf("EnvsatSPH-----\n");
160  printf("size = %d\n", getSize());
161  printf("numDSDs = %d\n", getNumDSDs());
162  printf("DSDSize = %d\n", getDSDSize());
163 }
164 
166  print();
167  for (int i = 0; i < numDSDs; i++) {
168  if (envsatDSDs[i] != NULL) {
169  printf("\n");
170  envsatDSDs[i]->printRecursive();
171  }
172  }
173 }
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 EnvsatDSD * findDSD(const std::string &name)
Definition: EnvsatSPH.cpp:120
virtual int readHeader(int fin)
Definition: EnvsatSPH.cpp:67
#define NULL
Definition: decode_rs.h:63
virtual int writeHeader(int fout)
Definition: EnvsatSPH.cpp:84
virtual int getNumDSDs()
Definition: EnvsatSPH.cpp:98
EnvsatSPH(const EnvsatSPH &orig)
Definition: EnvsatSPH.cpp:27
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
virtual EnvsatDSD * findFirstDSD(char DSDType)
Definition: EnvsatSPH.cpp:110
int init(int32_t ipr, int32_t jpr, char *efile, char *pfile)
Definition: proj_report.c:51
virtual std::string & getName()
Definition: EnvsatDSD.cpp:44
virtual void deleteDSDs()
Definition: EnvsatSPH.cpp:145
virtual char getType()
Definition: EnvsatDSD.cpp:50
virtual EnvsatSPH & operator=(const EnvsatSPH &src)
Definition: EnvsatSPH.cpp:42
virtual void printRecursive()
Definition: EnvsatSPH.cpp:165
virtual void print()
Definition: EnvsatSPH.cpp:158
virtual ~EnvsatSPH()
Definition: EnvsatSPH.cpp:37
virtual void createDSDs()
Definition: EnvsatSPH.cpp:131
char * buffer
Definition: EnvsatSPH.h:94
int i
Definition: decode_rs.h:71
virtual EnvsatDSD * getDSD(int index)
Definition: EnvsatSPH.cpp:102