OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
epr_bitmask.h
Go to the documentation of this file.
1 /*
2  * $Id: epr_bitmask.h,v 1.1.1.1 2004-10-28 19:22:22 norman Exp $
3  *
4  * Copyright (C) 2002 by Brockmann Consult (info@brockmann-consult.de)
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation. This program is distributed in the hope it will
9  * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #ifndef EPR_BITMASK_H_INCL
19 #define EPR_BITMASK_H_INCL
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 
26 #define FLAG_MASK_NOT_COMPUTED ((epr_uint) -1)
27 
28 typedef struct EPR_BmTerm EPR_SBmTerm;
29 typedef struct EPR_BmEvalContext EPR_SBmEvalContext;
30 typedef struct EPR_BmFlagDataset EPR_SBmFlagDataset;
32 
33 /* private implementations */
34 
35 
42 };
43 
44 enum EPR_Tok {
49 };
50 
60 struct EPR_BmTerm {
62 
63  union {
64 
65  struct /*BMT_REF*/ {
66  char* band_name;
67  char* flag_name;
69  EPR_SRaster* flag_raster;
70  } ref;
71 
72  struct /*BMT_NOT*/ {
73  EPR_SBmTerm* arg;
74  } unary;
75 
76  struct /*BMT_AND and BMT_OR*/ {
77  EPR_SBmTerm* arg1;
78  EPR_SBmTerm* arg2;
79  } binary;
80  } op;
81 };
82 
99  EPR_SProductId* product_id;
100 
104  int offset_x;
105 
109  int offset_y;
110 
114  EPR_SRaster* bitmask_raster;
115 
119  EPR_SPtrArray* flag_band_ids;
120 
124  EPR_SPtrArray* flag_rasters;
125 };
126 
132  /*The name of bitmask dataset*/
133  char* name;
134  /*The value of bitmask dataset (the number of the relevant bit in bitmask)*/
136  /*The description of bitmask dataset*/
137  char* description;
138 };
139 
140 
152 EPR_SBmEvalContext* epr_create_bm_eval_context(EPR_SProductId* product_id,
153  int offset_x,
154  int offset_y,
155  EPR_SRaster* raster);
156 
157 
165 void epr_free_bm_eval_context(EPR_SBmEvalContext* context);
166 
167 
217 int epr_read_bitmask_data(const EPR_SProductId* product_id,
218  const char* bm_expr,
219  int xo,
220  int yo,
221  int raster_width,
222  int raster_height,
223  int s_x,
224  int s_y,
225  void* raster_buffer);
226 
227 
228 
236 epr_boolean epr_eval_bm_term(EPR_SBmEvalContext* context,
237  EPR_SBmTerm* term,
238  int x,
239  int y);
240 
241 
242 
296 EPR_SBmTerm* epr_parse_bm_expr_str(const char* bm_expr);
297 
299  const char* bm_expr;
303  char* token;
304  char* err_message;
305 };
306 
307 
308 typedef struct EPR_ParseInfo EPR_SParseInfo;
309 
319 EPR_SBmTerm* epr_parse_bm_expr(EPR_SParseInfo* parse_info, epr_boolean term_required);
320 EPR_SBmTerm* epr_parse_bm_OR_expr(EPR_SParseInfo* parse_info, epr_boolean term_required);
321 EPR_SBmTerm* epr_parse_bm_AND_expr(EPR_SParseInfo* parse_info, epr_boolean term_required);
322 EPR_SBmTerm* epr_parse_bm_unary_expr(EPR_SParseInfo* parse_info, epr_boolean term_required);
323 EPR_SBmTerm* epr_parse_bm_primary_expr(EPR_SParseInfo* parse_info, epr_boolean term_required);
334 epr_boolean epr_is_bm_OR_keyword(EPR_SParseInfo* parse_info);
335 epr_boolean epr_is_bm_AND_keyword(EPR_SParseInfo* parse_info);
336 epr_boolean epr_is_bm_NOT_keyword(EPR_SParseInfo* parse_info);
347 epr_boolean epr_is_bm_AND_operator(EPR_SParseInfo* parse_info);
348 epr_boolean epr_is_bm_OR_operator(EPR_SParseInfo* parse_info);
349 epr_boolean epr_is_bm_NOT_operator(EPR_SParseInfo* parse_info);
359 epr_boolean epr_is_bm_name_token(EPR_SParseInfo* parse_info);
360 
368 epr_boolean epr_is_bm_EOS_token(EPR_SParseInfo* parse_info);
369 
377 epr_boolean epr_is_bm_expr_error(EPR_SParseInfo* parse_info);
378 
386 int epr_get_token_char(EPR_SParseInfo* parse_info);
387 
395 char* epr_consume_token(EPR_SParseInfo* parse_info);
396 
402 void epr_next_bm_expr_token(EPR_SParseInfo* parse_info);
403 
404 void epr_push_back_bm_expr_token(EPR_SParseInfo* parse_info);
405 
406 void epr_set_bm_expr_error(EPR_SParseInfo* parse_info, const char* message);
407 
408 int epr_tokenize_bm_expr(const char* bm_expr, int* bm_expr_pos, char** token);
409 
413 EPR_SBmTerm* epr_create_bm_term(EPR_EBmOpCode op_code);
414 
418 EPR_SBmTerm* epr_create_bm_REF_term(char* ds_name, char* flag_name);
419 
423 EPR_SBmTerm* epr_create_bm_NOT_term(EPR_SBmTerm* arg);
424 
428 EPR_SBmTerm* epr_create_bm_OR_term(EPR_SBmTerm* arg1, EPR_SBmTerm* arg2);
429 
433 EPR_SBmTerm* epr_create_bm_AND_term(EPR_SBmTerm* arg1, EPR_SBmTerm* arg2);
434 
438 void epr_free_bm_term(EPR_SBmTerm* term);
439 
440 
448 char* epr_create_bm_expr(EPR_SBmTerm* term);
452 void epr_print_bm_term(EPR_SBmTerm* term);
453 
457 void epr_write_bm_term(EPR_SBmTerm* term, FILE* ostream);
458 
466 EPR_SPtrArray* epr_create_flag_coding(EPR_SProductId* product_id, const char* str);
472 EPR_SFlagDef* epr_create_flag_def();
476 void epr_free_flag_def(EPR_SFlagDef* flag_def);
477 
481 void epr_free_flag_coding(EPR_SPtrArray* flag_coding);
482 
483 #ifdef __cplusplus
484 } /* extern "C" */
485 #endif
486 
487 #endif
488 /* #ifndef EPR_BITMASK_H_INCL */
epr_boolean epr_is_bm_NOT_keyword(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:552
void epr_free_flag_def(EPR_SFlagDef *flag_def)
Definition: epr_bitmask.c:430
epr_boolean pushed_back
Definition: epr_bitmask.h:301
epr_boolean epr_eval_bm_term(EPR_SBmEvalContext *context, EPR_SBmTerm *term, int x, int y)
Definition: epr_bitmask.c:174
EPR_SBmTerm * epr_create_bm_OR_term(EPR_SBmTerm *arg1, EPR_SBmTerm *arg2)
Definition: epr_bitmask.c:718
EPR_SBmTerm * epr_parse_bm_expr_str(const char *bm_expr)
Definition: epr_bitmask.c:307
EPR_SPtrArray * epr_create_flag_coding(EPR_SProductId *product_id, const char *str)
Definition: epr_bitmask.c:333
char * flag_name
Definition: epr_bitmask.h:67
@ BMT_REF
Definition: epr_bitmask.h:38
unsigned int epr_uint
Definition: epr_api.h:188
int epr_tokenize_bm_expr(const char *bm_expr, int *bm_expr_pos, char **token)
Definition: epr_bitmask.c:635
EPR_SBmEvalContext * epr_create_bm_eval_context(EPR_SProductId *product_id, int offset_x, int offset_y, EPR_SRaster *raster)
Definition: epr_bitmask.c:39
@ BMT_UNKNOWN
Definition: epr_bitmask.h:37
epr_boolean epr_is_bm_OR_operator(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:560
@ BME_EOS
Definition: epr_bitmask.h:46
void epr_push_back_bm_expr_token(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:608
epr_boolean epr_is_bm_name_token(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:568
epr_boolean epr_is_bm_NOT_operator(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:564
const char * bm_expr
Definition: epr_bitmask.h:299
@ BMT_OR
Definition: epr_bitmask.h:40
epr_boolean epr_is_bm_OR_keyword(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:544
EPR_SFlagDef * epr_create_flag_def()
Definition: epr_bitmask.c:414
int epr_boolean
Definition: epr_api.h:185
char * epr_consume_token(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:587
EPR_SBmTerm * epr_parse_bm_unary_expr(EPR_SParseInfo *parse_info, epr_boolean term_required)
Definition: epr_bitmask.c:492
int epr_read_bitmask_data(const EPR_SProductId *product_id, const char *bm_expr, int xo, int yo, int raster_width, int raster_height, int s_x, int s_y, void *raster_buffer)
void epr_free_bm_eval_context(EPR_SBmEvalContext *context)
Definition: epr_bitmask.c:62
struct EPR_BmTerm::@143::@146 binary
epr_boolean epr_is_bm_AND_keyword(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:548
enum EPR_BmOpCode EPR_EBmOpCode
Definition: epr_bitmask.h:31
void epr_free_flag_coding(EPR_SPtrArray *flag_coding)
Definition: epr_bitmask.c:395
struct EPR_BmTerm::@143::@145 unary
EPR_SBmTerm * epr_create_bm_NOT_term(EPR_SBmTerm *arg)
Definition: epr_bitmask.c:711
EPR_SProductId * product_id
Definition: epr_bitmask.h:99
@ BME_SPECIAL
Definition: epr_bitmask.h:47
EPR_EBmOpCode op_code
Definition: epr_bitmask.h:61
EPR_SBmTerm * arg1
Definition: epr_bitmask.h:77
char * band_name
Definition: epr_bitmask.h:66
void epr_write_bm_term(EPR_SBmTerm *term, FILE *ostream)
Definition: epr_bitmask.c:933
EPR_SBmTerm * epr_create_bm_term(EPR_EBmOpCode op_code)
Definition: epr_bitmask.c:694
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to already in place for MODIS TERRA was implemented for MODIS AQUA A time dependent LUT was added which gives coefficients for a detector specific crosstalk correction based on the aggregated Band radiances The Band scaled integers are adjusted by the Band correction term
Definition: HISTORY.txt:439
What value is used by your function when the data value is bad Default is BAD_FLT l2prod product_id[0]
EPR_SPtrArray * flag_band_ids
Definition: epr_bitmask.h:119
instead the metadata field ProcessingEnvinronment is filled in from the output of a call to the POSIX compliant function uname from within the L1B code A small bug in L1B_Tables an incorrect comparison of RVS coefficients for TEBs to RVS coefficients for RSBs was being made This was replaced with a comparison between TEB coefficients This error never resulted in an incorrect RVS correction but did lead to recalculating the coefficients for each detector in a thermal band even if the coefficients were the same for all detectors To reduce to overall size of the reflective LUT HDF fill values were eliminated from all LUTs previously dimensioned where and where NUM_TIMES is the number of time dependent table pieces In Preprocess a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed This counter is internal only and is not yet used for any chiefly to casting of were added to make it LINUX compatible Output of code run on LINUX machines displays differences of at most scaled sector incalculable values of the Emissive calibration factor and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal c since none of these quantities are frame dependent Initialization of b1 and XMS values in Preprocess c routine Process_OBCENG_Emiss was moved inside the detector loops The code was altered so that if up to five scans are dropped between the leading middle or middle trailing the leading or trailing granule will still be used in emissive calibration to form a cross granule average QA bits and are set for a gap between the leading middle and middle trailing granules respectively This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule A small bug in the Band correction algorithm was corrected an uncertainty value was being checked against an upper bound whereas the proper quantity to be checked was the corresponding which is the product of the Band radiance times the ratio of the Band to Band scaling factors times the LUT correction value for that detector In addition a new LUT which allows for a frame offset with regard to the Band radiance was added A LUT which switches the correction off or on was also added Changes which do not affect scientific output of the the pixel is flagged with the newly created flag and the number of pixels for which this occurs is counted in the QA_common table The array of b1s in Preprocess c was being initialized to outside the loop over which meant that if b1 could not be the value of b1 from the previous band for that scan detector combination was used The initialization was moved inside the band loop Minor code changes were made to eliminate compiler warnings when the code is compiled in bit mode Temperature equations were upgraded to be MODIS AQUA or MODIS TERRA specific and temperature conversion coefficients for AQUA were MOD_PR02 will not cease execution if the value of this parameter is not but will print a message
Definition: HISTORY.txt:644
void epr_next_bm_expr_token(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:597
EPR_SRaster * bitmask_raster
Definition: epr_bitmask.h:114
EPR_SBmTerm * epr_create_bm_AND_term(EPR_SBmTerm *arg1, EPR_SBmTerm *arg2)
Definition: epr_bitmask.c:726
void epr_print_bm_term(EPR_SBmTerm *term)
Definition: epr_bitmask.c:925
EPR_SBmTerm * epr_parse_bm_expr(EPR_SParseInfo *parse_info, epr_boolean term_required)
Definition: epr_bitmask.c:445
void epr_set_bm_expr_error(EPR_SParseInfo *parse_info, const char *message)
Definition: epr_bitmask.c:612
int epr_get_token_char(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:580
EPR_SBmTerm * epr_create_bm_REF_term(char *ds_name, char *flag_name)
Definition: epr_bitmask.c:701
epr_uint flag_mask
Definition: epr_bitmask.h:68
const char * str
Definition: l1c_msi.cpp:35
EPR_SBmTerm * arg2
Definition: epr_bitmask.h:78
EPR_SBmTerm * epr_parse_bm_OR_expr(EPR_SParseInfo *parse_info, epr_boolean term_required)
Definition: epr_bitmask.c:451
union EPR_BmTerm::@143 op
epr_boolean epr_is_bm_EOS_token(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:572
struct EPR_BmTerm::@143::@144 ref
@ BME_NAME
Definition: epr_bitmask.h:48
EPR_SBmTerm * epr_parse_bm_AND_expr(EPR_SParseInfo *parse_info, epr_boolean term_required)
Definition: epr_bitmask.c:471
@ BME_UNKNOWN
Definition: epr_bitmask.h:45
@ BMT_AND
Definition: epr_bitmask.h:39
EPR_SBmTerm * arg
Definition: epr_bitmask.h:73
EPR_Tok
Definition: epr_bitmask.h:44
void epr_free_bm_term(EPR_SBmTerm *term)
Definition: epr_bitmask.c:844
@ BMT_NOT
Definition: epr_bitmask.h:41
epr_boolean epr_is_bm_expr_error(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:576
epr_boolean epr_is_bm_AND_operator(EPR_SParseInfo *parse_info)
Definition: epr_bitmask.c:556
EPR_BmOpCode
Definition: epr_bitmask.h:36
char * epr_create_bm_expr(EPR_SBmTerm *term)
Definition: epr_bitmask.c:880
epr_uint bit_index
Definition: epr_bitmask.h:135
EPR_SBmTerm * epr_parse_bm_primary_expr(EPR_SParseInfo *parse_info, epr_boolean term_required)
Definition: epr_bitmask.c:508
EPR_SPtrArray * flag_rasters
Definition: epr_bitmask.h:124
char * err_message
Definition: epr_bitmask.h:304
EPR_SRaster * flag_raster
Definition: epr_bitmask.h:69