Go to the documentation of this file.
39 #define EARTH_RADIUS 6371.229
40 #define BIN_NOT_FOUND 110
48 float north, south, east, west;
51 fprintf(outfp,
"%07ld %9.5f %10.5f %9.5f %9.5f %10.5f %10.5f ", (
long)bin,
52 lat,
lon, north, south, west, east);
63 bool binFound =
false;
64 for (row = 0; row < shape->
getNumRows(); row++) {
65 for (col = 0; col < shape->
getNumCols(row); col++) {
66 l3Bin = l3File.
getBin(row, col);
69 printBin(outfp, row, col, l3Bin, shape);
74 fprintf(
stderr,
"No bins found in file.\n");
80 int main(
int argc,
char *argv[]) {
87 char outfile[FILENAME_MAX] =
"\0";
99 for (
i = 0;
i < argc;
i++) {
101 if ((strcmp(argv[
i],
"-h") == 0) || (strcmp(argv[
i],
"-help") == 0)) {
107 input = (instr*) malloc(
sizeof (instr));
109 fprintf(
stderr,
"-E- %s %d: Error allocating input structure.\n", __FILE__,
125 fprintf(
stderr,
"-E- %s: Error reading program options.\n", __FILE__);
126 return (EXIT_FAILURE);
133 fprintf(
stderr,
"-E- %s: Error loading options into input structure.\n",
135 return (EXIT_FAILURE);
138 if (
input->verbose == 1) {
144 fprintf(
stderr,
"%s: Error: Unable to open %s for reading.\n",
145 argv[0],
input->ifile);
151 fprintf(
stderr,
"%s: Error: Product %s not found in file.\n",
152 argv[0],
input->l3bprod);
157 if (strlen(
input->ofile) > 0) {
159 if ((outfp = fopen(outfile,
"w")) ==
NULL) {
160 fprintf(
stderr,
"%s: Error: Unable to open %s for writing.\n",
169 if (strcmp(
input->oformat,
"SeaBASS") == 0) {
170 fprintf(outfp,
"/begin_header\n");
171 fprintf(outfp,
"/delimiter=space\n");
172 fprintf(outfp,
"/missing=-999\n");
173 if (
input->north > -999) {
174 fprintf(outfp,
"/north_latitude=%10.5f\n",
input->north);
175 fprintf(outfp,
"/south_latitude=%10.5f\n",
input->south);
176 fprintf(outfp,
"/east_longitude=%10.5f\n",
input->east);
177 fprintf(outfp,
"/west_longitude=%10.5f\n",
input->west);
179 fprintf(outfp,
"/fields=bin,lat,lon,north,south,west,east,nobs,nscenes,sum,sum_squared,weight,mean,stdev\n");
180 fprintf(outfp,
"/end_header\n");
183 fprintf(outfp,
"%80s%15.15s %15.15s\n",
" ",
input->l3bprod,
input->l3bprod);
184 fprintf(outfp,
" bin centerlat centerlon");
185 fprintf(outfp,
" north south west east");
186 fprintf(outfp,
" n N sum sum_squared weight");
187 fprintf(outfp,
" mean stdev\n");
188 fprintf(outfp,
"------- --------- ----------");
189 fprintf(outfp,
" --------- --------- ---------- ----------");
190 fprintf(outfp,
" ---- --- --------------- --------------- ---------------");
191 fprintf(outfp,
" ---------- ----------\n");
195 fprintf(outfp,
"! Input file: %s\n",
input->ifile);
201 int32_t startRow=0, stopRow=0;
203 fprintf(outfp,
"! Number of Rows: %d\n", shape->
getNumRows());
206 if(
input->radius == -999 &&
input->lat != -999 &&
input->lon != -999) {
210 if (
input->bin_number > 0) {
214 l3Bin = l3File.
getBin(row, col);
216 printBin(outfp, row, col, l3Bin, shape);
219 fprintf(
stderr,
"Requested bin number = %ld was not in the file.\n", (
long)
input->bin_number);
224 }
else if (
input->radius > 0) {
231 if (radius_degrees > 180) {
239 north =
input->lat + radius_degrees;
240 south =
input->lat - radius_degrees;
244 stopRow = shape->
lat2row(north) + 1;
249 if (south <= -90.0) {
252 startRow = shape->
lat2row(south) - 1;
260 }
else if (
input->north != -999) {
271 fprintf(
stderr,
"-W- %s line %d: ", __FILE__, __LINE__);
273 "Specified south latitude is greater than specified north latitude.\n");
274 fprintf(
stderr,
"I will swap the two.\n");
280 if (
input->north == 90.0 &&
input->south == -90.0 &&
281 input->east == 180.0 &&
input->west == -180.0) {
294 return (EXIT_FAILURE);
298 bool binFound =
false;
299 for (row = startRow; row <= stopRow; row++) {
300 for (col = 0; col < shape->
getNumCols(row); col++) {
303 l3Bin = l3File.
getBin(row, col);
306 printBin(outfp, row, col, l3Bin, shape);
312 fprintf(
stderr,
"No bins found in file.\n");
double constrainLat(double lat)
virtual int64_t latlon2bin(double lat, double lon) const =0
list(APPEND LIBS ${PGSTK_LIBRARIES}) add_executable(atteph_info_modis atteph_info_modis.c) target_link_libraries(atteph_info_modis $
virtual int32_t getNumCols(int32_t row) const =0
virtual bool isInside(double lat, double lon)=0
virtual void bin2rowcol(int64_t bin, int32_t &row, int32_t &col)=0
float getSumSquares(int32_t prodId=0) const
virtual bool open(const char *fileName)
int main(int argc, char *argv[])
virtual L3Bin * getBin(int32_t row, int32_t col)
virtual int32_t lat2row(double lat) const =0
virtual void rowcol2bounds(int32_t row, int32_t col, double &north, double &south, double &east, double &west) const =0
double constrainLon(double lon)
virtual L3Shape * getShape() const
virtual bool setActiveProductList(const char *prodStr)
clo_optionList_t * clo_createList()
virtual void rowcol2latlon(int32_t row, int32_t col, double &lat, double &lon) const =0
void printWholeFile(FILE *outfp, L3File &l3File)
int64_t getBinNum() const
float getMean(int32_t prodId=0) const
virtual int32_t getNumRows() const
int l3bindump_init_options(clo_optionList_t *list)
float getStdev(int32_t prodId=0) const
void l3bindump_input_init(instr *input)
int l3bindump_load_input(clo_optionList_t *list, instr *input)
int l3bindump_read_options(clo_optionList_t *list, int argc, char *argv[])
void printBin(FILE *outfp, int32_t row, int32_t col, L3Bin *l3Bin, L3Shape *shape)
int32_t getNscenes() const
How many dimensions is the output array Default is Not sure if anything above will work correctly strcpy(l2prod->title, "no title yet")
float getSum(int32_t prodId=0) const