-
-
-
epr_api.h
Go to the documentation of this file.00001
-00002
-00003
-00004
-00005
-00006
-00007
-00008
-00009
-00010
-00011
-00012
-00013
-00014
-00015
-00016
-00017
-00018 #ifndef EPR_API_H_INCL
-00019 #define EPR_API_H_INCL
-00020
-00021
-00022 #ifdef __cplusplus
-00023 extern "C"
-00024 {
-00025 #endif
-00026
-00027
-00028 #include <stdio.h>
-00029
-00030
-00031 #include "epr_ptrarray.h"
-00032
-00033 #define EPR_PRODUCT_API_NAME_STR "ENVISAT Product Reader API"
-00034 #define EPR_PRODUCT_API_VERSION_STR "2.2"
-00035
-00036
-00045 enum EPR_DataTypeId
-00046 {
-00048 e_tid_unknown = 0,
-00050 e_tid_uchar = 1,
-00052 e_tid_char = 2,
-00054 e_tid_ushort = 3,
-00056 e_tid_short = 4,
-00058 e_tid_uint = 5,
-00060 e_tid_int = 6,
-00062 e_tid_float = 7,
-00064 e_tid_double = 8,
-00066 e_tid_string = 11,
-00068 e_tid_spare = 13,
-00070 e_tid_time = 21
-00071 };
-00072
-00073
-00078 enum EPR_ErrCode
-00079 {
-00080
-00081 e_err_none = 0,
-00082
-00083
-00084 e_err_null_pointer = 1,
-00085 e_err_illegal_arg = 2,
-00086 e_err_illegal_state = 3,
-00087 e_err_out_of_memory = 4,
-00088 e_err_index_out_of_range = 5,
-00089 e_err_illegal_conversion = 6,
-00090 e_err_illegal_data_type = 7,
-00091
-00092
-00093 e_err_file_not_found = 101,
-00094 e_err_file_access_denied = 102,
-00095 e_err_file_read_error = 103,
-00096 e_err_file_write_error = 104,
-00097 e_err_file_open_failed = 105,
-00098 e_err_file_close_failed = 106,
-00099
-00100
-00101 e_err_api_not_initialized = 201,
-00102 e_err_invalid_product_id = 203,
-00103 e_err_invalid_record = 204,
-00104 e_err_invalid_band = 205,
-00105 e_err_invalid_raster = 206,
-00106 e_err_invalid_dataset_name = 207,
-00107 e_err_invalid_field_name = 208,
-00108 e_err_invalid_record_name = 209,
-00109 e_err_invalid_product_name = 210,
-00110 e_err_invalid_band_name = 211,
-00111 e_err_invalid_data_format = 212,
-00112 e_err_invalid_value = 213,
-00113 e_err_invalid_keyword_name = 214,
-00114 e_err_unknown_endian_order = 216,
-00115
-00116
-00117 e_err_flag_not_found = 301,
-00118
-00119
-00120
-00121 e_err_invalid_ddbb_format = 402
-00122 };
-00123
-00124
-00129 enum EPR_LogLevel
-00130 {
-00131 e_log_debug = -1,
-00132 e_log_info = 0,
-00133 e_log_warning = 1,
-00134 e_log_error = 2
-00135 };
-00136
-00137 enum EPR_SampleModel
-00138 {
-00139 e_smod_1OF1 = 0,
-00140 e_smod_1OF2 = 1,
-00141 e_smod_2OF2 = 2,
-00142 e_smod_3TOI = 3,
-00143 e_smod_2TOF = 4
-00144 };
-00145
-00146 enum EPR_ScalingMethod
-00147 {
-00148 e_smid_non = 0,
-00149 e_smid_lin = 1,
-00150 e_smid_log = 2
-00151 };
-00152
-00153 struct EPR_ProductId;
-00154 struct EPR_DatasetId;
-00155 struct EPR_BandId;
-00156 struct EPR_Record;
-00157 struct EPR_RecordInfo;
-00158 struct EPR_Field;
-00159 struct EPR_FieldInfo;
-00160 struct EPR_ProductInfo;
-00161 struct EPR_DSD;
-00162 struct EPR_Raster;
-00163 struct EPR_DatasetRef;
-00164 struct EPR_Flag;
-00165 struct EPR_BandId;
-00166 struct EPR_ParamElem;
-00167 struct EPR_Time;
-00168
-00169 typedef enum EPR_DataTypeId EPR_EDataTypeId;
-00170 typedef enum EPR_ErrCode EPR_EErrCode;
-00171 typedef enum EPR_LogLevel EPR_ELogLevel;
-00172 typedef enum EPR_SampleModel EPR_ESampleModel;
-00173 typedef enum EPR_ScalingMethod EPR_EScalingMethod;
-00174 typedef struct EPR_ProductId EPR_SProductId;
-00175 typedef struct EPR_DatasetId EPR_SDatasetId;
-00176 typedef struct EPR_BandId EPR_SBandId;
-00177 typedef struct EPR_Record EPR_SRecord;
-00178 typedef struct EPR_RecordInfo EPR_SRecordInfo;
-00179 typedef struct EPR_Field EPR_SField;
-00180 typedef struct EPR_FieldInfo EPR_SFieldInfo;
-00181 typedef struct EPR_DSD EPR_SDSD;
-00182 typedef struct EPR_Raster EPR_SRaster;
-00183 typedef struct EPR_FlagDef EPR_SFlagDef;
-00184 typedef struct EPR_ParamElem EPR_SParamElem;
-00185 typedef struct EPR_Time EPR_STime;
-00186 typedef struct EPR_DatasetRef EPR_SDatasetRef;
-00187 typedef struct EPR_BitmaskTerm EPR_SBitmaskTerm;
-00188 typedef struct EPR_FlagSet EPR_SFlagSet;
-00189 typedef void (*EPR_FErrHandler)(EPR_EErrCode err_code, const char* err_message);
-00190 typedef void (*EPR_FLogHandler)(EPR_ELogLevel log_level, const char* log_message);
-00191
-00192
-00193 typedef int epr_boolean;
-00194 typedef unsigned char uchar;
-00195 typedef unsigned short ushort;
-00196 typedef unsigned int uint;
-00197 typedef unsigned long ulong;
-00198
-00199
-00200 typedef int EPR_Magic;
-00201
-00202 #define EPR_MAGIC_PRODUCT_ID 0xCAFFEE64
-00203 #define EPR_MAGIC_DATASET_ID 0xEFEABDCA
-00204 #define EPR_MAGIC_BAND_ID 0xFEC21ABD
-00205 #define EPR_MAGIC_RECORD 0x7BABACAE
-00206 #define EPR_MAGIC_FIELD 0xBA0BABBA
-00207 #define EPR_MAGIC_RASTER 0x0BABA0EB
-00208 #define EPR_MAGIC_FLAG_DEF 0xCABA11AD
-00209
-00210 #define TRUE 1
-00211 #define FALSE 0
-00212
-00213 #define EPR_PRODUCT_ID_STRLEN 48
-00214
-00215
-00216
-00217
-00218
-00219
-00227 struct EPR_ProductId
-00228 {
-00233 EPR_Magic magic;
-00234
-00238 char* file_path;
-00239
-00244 FILE* istream;
-00245
-00249 uint tot_size;
-00250
-00254 uint scene_width;
-00255
-00259 uint scene_height;
-00260
-00269 char id_string[EPR_PRODUCT_ID_STRLEN + 1];
-00270
-00274 EPR_SRecord* mph_record;
-00275
-00279 EPR_SRecord* sph_record;
-00280
-00285 EPR_SPtrArray* dsd_array;
-00286
-00296 EPR_SPtrArray* record_info_cache;
-00297
-00304 EPR_SPtrArray* param_table;
-00305
-00309 EPR_SPtrArray* dataset_ids;
-00310
-00314 EPR_SPtrArray* band_ids;
-00315
-00319 int meris_iodd_version;
-00320 };
-00321
-00322
-00323
-00324
-00337 struct EPR_DatasetId
-00338 {
-00343 EPR_Magic magic;
-00344
-00348 EPR_SProductId* product_id;
-00349
-00353 char* dsd_name;
-00354
-00358 const EPR_SDSD* dsd;
-00359
-00363 char* dataset_name;
-00364
-00368 const struct RecordDescriptor* record_descriptor;
-00369
-00373 EPR_SRecordInfo* record_info;
-00374
-00375
-00379 char* description;
-00380 };
-00381
-00382
-00390 struct EPR_DSD
-00391 {
-00396 EPR_Magic magic;
-00397
-00401 int index;
-00402
-00406 char* ds_name;
-00407
-00411 char* ds_type;
-00412
-00416 char* filename;
-00417
-00421 uint ds_offset;
-00422
-00426 uint ds_size;
-00427
-00431 uint num_dsr;
-00432
-00436 uint dsr_size;
-00437 };
-00438
-00439
-00447 struct EPR_Record
-00448 {
-00453 EPR_Magic magic;
-00454
-00458 EPR_SRecordInfo* info;
-00459
-00465 uint num_fields;
-00466
-00471 EPR_SField** fields;
-00472 };
-00473
-00481 struct EPR_Field
-00482 {
-00487 EPR_Magic magic;
-00488
-00493 EPR_SFieldInfo* info;
-00494
-00515 void* elems;
-00516 };
-00517
-00523 struct EPR_Raster
-00524 {
-00529 EPR_Magic magic;
-00530
-00535 EPR_EDataTypeId data_type;
-00536
-00540 uint elem_size;
-00541
-00545 uint source_width;
-00546
-00550 uint source_height;
-00551
-00555 uint source_step_x;
-00556
-00560 uint source_step_y;
-00561
-00566 uint raster_width;
-00567
-00572 uint raster_height;
-00573
-00578 void* buffer;
-00579 };
-00580
-00581
-00596 struct EPR_DatasetRef
-00597 {
-00598 EPR_SDatasetId* dataset_id;
-00599 int field_index;
-00600 int elem_index;
-00601 };
-00602
-00607 struct EPR_FlagDef
-00608 {
-00613 EPR_Magic magic;
-00614
-00618 char* name;
-00619
-00623 uint bit_mask;
-00624
-00628 char* description;
-00629 };
-00630
-00631
-00643 struct EPR_BandId
-00644 {
-00649 EPR_Magic magic;
-00650
-00654 EPR_SProductId* product_id;
-00655
-00660 char* band_name;
-00661
-00665 int spectr_band_index;
-00666
-00673 EPR_SDatasetRef dataset_ref;
-00674
-00684 EPR_ESampleModel sample_model;
-00685
-00693 EPR_EDataTypeId data_type;
-00694
-00703 EPR_EScalingMethod scaling_method;
-00704
-00714 float scaling_offset;
-00715
-00726 float scaling_factor;
-00727
-00731 char* bm_expr;
-00732
-00738 EPR_SPtrArray* flag_coding;
-00739
-00743 char* unit;
-00744
-00748 char* description;
-00749
-00755 epr_boolean lines_mirrored;
-00756 };
-00757
-00764 struct EPR_Time
-00765 {
-00766 int days;
-00767 uint seconds;
-00768 uint microseconds;
-00769 };
-00770
-00771
-00772
-00773
-00774
-00775
-00776
-00777
-00778
-00779
-00780
-00801 int epr_init_api(EPR_ELogLevel log_level,
-00802 EPR_FLogHandler log_handler,
-00803 EPR_FErrHandler err_handler);
-00804
-00805
-00812 void epr_close_api();
-00816
-00817
-00818
-00819
-00835 int epr_set_log_level(EPR_ELogLevel log_level);
-00836
-00846 void epr_set_log_handler(EPR_FLogHandler log_handler);
-00847
-00856 void epr_log_message(EPR_ELogLevel log_level, const char* log_message);
-00857
-00860
-00861
-00862
-00863
-00875 void epr_set_err_handler(EPR_FErrHandler err_handler);
-00876
-00883 EPR_EErrCode epr_get_last_err_code();
-00884
-00891 const char* epr_get_last_err_message();
-00892
-00898 void epr_clear_err();
-00899
-00902
-00903
-00904
-00905
-00911
-00912
-00913
-00914
-00933 EPR_SProductId* epr_open_product(const char* product_file_path);
-00934
-00942 int epr_close_product(EPR_SProductId* product_id);
-00947
-00948
-00949
-00950
-00977 void epr_print_record(const EPR_SRecord* record, FILE* ostream);
-00978 void epr_print_field(const EPR_SField* field, FILE* ostream);
-00979 void epr_print_element(const EPR_SRecord* record, uint field_index, uint element_index, FILE* ostream);
-00980 void epr_dump_record(const EPR_SRecord* record);
-00981 void epr_dump_field(const EPR_SField* field);
-00982 void epr_dump_element(const EPR_SRecord* record, uint field_index, uint element_index);
-00985
-00986
-00987
-00988
-01001 uint epr_get_scene_width(const EPR_SProductId* product_id);
-01002
-01010 uint epr_get_scene_height(const EPR_SProductId* product_id);
-01011
-01014
-01015
-01016
-01017
-01030 uint epr_get_num_datasets(EPR_SProductId* product_id);
-01031
-01040 EPR_SDatasetId* epr_get_dataset_id_at(EPR_SProductId* product_id, uint index);
-01041
-01049 EPR_SDatasetId* epr_get_dataset_id(EPR_SProductId* product_id, const char* dataset_name);
-01050
-01057 const char* epr_get_dataset_name(EPR_SDatasetId* dataset_id);
-01058
-01065 const char* epr_get_dsd_name(const EPR_SDatasetId* dataset_id);
-01066
-01073 EPR_SRecord* epr_get_mph(const EPR_SProductId* product_id);
-01074
-01081 EPR_SRecord* epr_get_sph(const EPR_SProductId* product_id);
-01082
-01089 const EPR_SDSD* epr_get_dsd(const EPR_SDatasetId* dataset_id);
-01090
-01097 uint epr_get_num_records(const EPR_SDatasetId* dataset_id);
-01098
-01099
-01100 uint epr_get_num_dsds(const EPR_SProductId* product_id);
-01101 EPR_SDSD* epr_get_dsd_at(const EPR_SProductId* product_id, uint dsd_index);
-01102
-01105
-01106
-01107
-01108
-01123 EPR_SRecord* epr_create_record(EPR_SDatasetId* dataset_id);
-01124
-01143 EPR_SRecord* epr_read_record(EPR_SDatasetId* dataset_id,
-01144 uint record_index,
-01145 EPR_SRecord* record);
-01146
-01154 void epr_free_record(EPR_SRecord* record);
-01155
-01158
-01159
-01160
-01161
-01178 const EPR_SField* epr_get_field(const EPR_SRecord* record, const char* field_name);
-01179
-01186 uint epr_get_num_fields(const EPR_SRecord* record);
-01187
-01196 const EPR_SField* epr_get_field_at(const EPR_SRecord* record, uint field_index);
-01197
-01204 const char* epr_get_field_unit(const EPR_SField* field);
-01205
-01213 const char* epr_get_field_description(const EPR_SField* field);
-01214
-01222 uint epr_get_field_num_elems(const EPR_SField* field);
-01223
-01231 const char* epr_get_field_name(const EPR_SField* field);
-01232
-01240 EPR_EDataTypeId epr_get_field_type(const EPR_SField* field);
-01241
-01244
-01245
-01246
-01247
-01263 char epr_get_field_elem_as_char(const EPR_SField* field, uint elem_index);
-01264 uchar epr_get_field_elem_as_uchar(const EPR_SField* field, uint elem_index);
-01265 short epr_get_field_elem_as_short(const EPR_SField* field, uint elem_index);
-01266 ushort epr_get_field_elem_as_ushort(const EPR_SField* field, uint elem_index);
-01267 int epr_get_field_elem_as_int(const EPR_SField* field, uint elem_index);
-01268 uint epr_get_field_elem_as_uint(const EPR_SField* field, uint elem_index);
-01269 float epr_get_field_elem_as_float(const EPR_SField* field, uint elem_index);
-01270 double epr_get_field_elem_as_double(const EPR_SField* field, uint elem_index);
-01271 const EPR_STime* epr_get_field_elem_as_mjd(const EPR_SField* field);
-01272 const char* epr_get_field_elem_as_str(const EPR_SField* field);
-01275
-01276
-01277
-01278
-01291 const char* epr_get_field_elems_char(const EPR_SField* field);
-01292 const uchar* epr_get_field_elems_uchar(const EPR_SField* field);
-01293 const short* epr_get_field_elems_short(const EPR_SField* field);
-01294 const ushort* epr_get_field_elems_ushort(const EPR_SField* field);
-01295 const int* epr_get_field_elems_int(const EPR_SField* field);
-01296 const uint* epr_get_field_elems_uint(const EPR_SField* field);
-01297 const float* epr_get_field_elems_float(const EPR_SField* field);
-01298 const double* epr_get_field_elems_double(const EPR_SField* field);
-01317 uint epr_copy_field_elems_as_ints(const EPR_SField* field, int* buffer, uint num_elems);
-01318 uint epr_copy_field_elems_as_uints(const EPR_SField* field, uint* buffer, uint num_elems);
-01319 uint epr_copy_field_elems_as_floats(const EPR_SField* field, float* buffer, uint num_elems);
-01320 uint epr_copy_field_elems_as_doubles(const EPR_SField* field, double* buffer, uint num_elems);
-01325
-01326
-01327
-01328
-01336
-01337
-01338
-01339
-01380 EPR_SRaster* epr_create_compatible_raster(EPR_SBandId* band_id,
-01381 uint source_width,
-01382 uint source_height,
-01383 uint source_step_x,
-01384 uint source_step_y);
-01385
-01398 EPR_SRaster* epr_create_raster(EPR_EDataTypeId data_type,
-01399 uint source_width,
-01400 uint source_height,
-01401 uint source_step_x,
-01402 uint source_step_y);
-01403
-01404
-01415 EPR_SRaster* epr_create_bitmask_raster(uint source_width,
-01416 uint source_height,
-01417 uint source_step_x,
-01418 uint source_step_y);
-01419
-01437 int epr_read_band_raster(EPR_SBandId* band_id,
-01438 int offset_x,
-01439 int offset_y,
-01440 EPR_SRaster* raster);
-01441
-01442
-01446 uint epr_get_raster_elem_size(const EPR_SRaster* raster);
-01447
-01451 void* epr_get_raster_elem_addr(const EPR_SRaster* raster, uint offset);
-01452
-01456 void* epr_get_raster_pixel_addr(const EPR_SRaster* raster, uint x, uint y);
-01457
-01461 void* epr_get_raster_line_addr(const EPR_SRaster* raster, uint y);
-01462
-01463
-01471 uint epr_get_raster_width(EPR_SRaster* raster);
-01472
-01480 uint epr_get_raster_height(EPR_SRaster* raster);
-01481
-01482
-01483
-01490 uint epr_get_num_bands(EPR_SProductId* product_id);
-01491
-01500 EPR_SBandId* epr_get_band_id_at(EPR_SProductId* product_id, uint index);
-01501
-01509 EPR_SBandId* epr_get_band_id(EPR_SProductId* product_id, const char* band_name);
-01510
-01517 const char* epr_get_band_name(EPR_SBandId* band_id);
-01518
-01524 void epr_free_raster(EPR_SRaster* raster);
-01525
-01528
-01529
-01530
-01531
-01548 uint epr_get_pixel_as_uint(const EPR_SRaster* raster, int x, int y);
-01549 int epr_get_pixel_as_int(const EPR_SRaster* raster, int x, int y);
-01550 float epr_get_pixel_as_float(const EPR_SRaster* raster, int x, int y);
-01551 double epr_get_pixel_as_double(const EPR_SRaster* raster, int x, int y);
-01554
-01555
-01556
-01557
-01583 int epr_read_bitmask_raster(EPR_SProductId* product_id,
-01584 const char* bm_expr,
-01585 int offset_x,
-01586 int offset_y,
-01587 EPR_SRaster* raster);
-01588
-01591
-01592
-01593
-01594
-01603 uint epr_get_data_type_size(EPR_EDataTypeId data_type_id);
-01604
-01608 const char* epr_data_type_id_to_str(EPR_EDataTypeId data_type_id);
-01609
-01612 #ifdef __cplusplus
-01613 }
-01614 #endif
-01615 #endif
-
-
-
ENVISAT Product Reader C API Documentation
2.2
-
1. Introduction
-
- The ENVISAT Product Reader API for C (epr-c-api) is a library of data
- structures and functions for simple access to MERIS, AATSR and ASAR products as well as ATSR-2
- products stored in the ENVISAT format. You can use
- them in your programs to retrieve directly the geophysically coded values, e.g.
- such as the chlorophyll concentration in mg/m³, in a data matrix.
-
- The epr-c-api is generic, i.e. it has no instrument specific functions
- but utilises the generic ENVISAT product format. However, it is not necessary for a user of the
- epr-c-api to know the ENVISAT product format - the
- epr-c-api knows it, and that's sufficient.
-
- All a user of the epr-c-api has to know are a few functions and the name
- of the geophysical variable he wants to get. In fact, the epr-c-api can
- do more: all information stored in ENVISAT products can be retrieved in a unique way, just by
- requesting it identified by its name, without worrying too much where and how it is stored in the
- world of the ENVISAT product format.
-
- Now, here's the tricky bit: there are many different products and the number of items stored
- in each product is huge. Therefore a
-
- ENVISAT Data Products
- documentation is included in the BEAM software homepage, which describes the internal
- structure of each supported product. In order to access a certain item such as a dataset,
- record, band or flag you have to consult the data product documentation for he correct
- name or ID for the dataset, record, band or flag you want to access.
-
-
2. Using the API in your own C-Programs
-
-
- The epr-c-api is written in pure ANSI C and should compile with
- every ANSI conformant C-compiler:
-
- - Copy all
*.h *.c files contained in the
- distribution's src folder to your own source folder of your project
- and include them in your development environment (makefile or IDE).
- - Include the public API header
epr-api.h in your C source files.
- - Optionally refer to the example code in
src/examples directory
-
-
-
-
3. API Design
-
-
3.1 Basic Concepts
-
-
Given here are some of the basic concepts of the API.
-
- - The API works exclusively with pointers to dynamically allocated structures.
- For every structure type in the API a constructor/desctructor function pair always exists:
-
X epr_create_X(...) and void epr_free_X(X). Example: For the type
- EPR_SRecord* these functions are EPR_SRecord* epr_create_record(...)
- and void epr_free_record(EPR_SRecord*).
-
- -
- In most cases, the first parameter is the object on which the function is operating.
- For example,
uint epr_get_num_fields(const EPR_SRecord* record).
-
- - Access functions exist for all important members of structures. So, the
- user of the API should not need to work directly with the API structures but
- with functions to get values. For example, if you use the
epr_get_pixel_as_float
- to access a pixel value of raster, your code is less dependent on API changes as if
- you would have directly accessed a structure member.
-
-
- - A central concept is that all items, which can be retrieved from ENVISAT
- products, are identified by name. For example, to access the MERIS L1B radiance
- of band 1, you have to call
epr_get_dataset_id(product_id, "Radiance_1")
- But how do you know, what name you should use for the data you want to retrieve? There are three
- possibilities:
-
- -
- The
-
- ENVISAT Data Products
-
- documentation provides all valid names used in the all supported data products.
- All tables in the documentation have a similar structure, the first column is
- always contains the longed-for name.
-
- -
- One can use VISAT to open a product. The names shown in VISAT in the product
- browser are the same as in the ENVISAT data product tables documentation and
- are hence those needed.
-
- -
- One can open a product using the
epr-c-api, scan all datasets in a look
- and print the names of the datasets and records by the access function.
- The same can be done with all fields of a record.
-
-
-
-
-
-
3.2 Data Access Types
-
-
The API provides two access types for ENVISAT data:
-
- -
- Access of data as it is stored in the product (we call this basic or raw data access) and
-
- -
- Access to the geophysical raster data (what we call this geophysical data access).
-
-
-
- The difference between the two is how they treat the measurement data: Access type
- (1) returns the data in its native data product structure: as datasets, records and fields.
- This gives a direct read access to the raw data as it is stored in the data product,
- without any interpretation of the content.
- For example, the MERIS L1B measurement data set MDS 15 stores chlorophyll, vegetation index
- or cloud top height in the same byte. The content has to be interpreted depending
- on the surface type, which itself is coded in MDS 20. To get the true geophysical
- value one needs to retrieve the proper scaling factors from a certain GADS. Access type
- (2) decodes all this and provides, for example, a data matrix with the chlorophyll
- concentration in a float variable in its geophysical units, i.e. mg/m³. The data of the
- measurement datasets and the tie-point values, i.e. geometry, geo-location and meteorological data,
- are available by this method. The tie-point data are interpolated to the corresponding
- image grid.
-
-
3.3 Working with the Basic/Raw Data Access
-
-
-
-
- |
- Level
- |
-
- Correspondence in ENVISAT product
- |
-
-
- |
- Product
- |
-
- ENVISAT product file
- |
-
-
- |
- Dataset
- |
-
- Dataset, e.g. Main Product Header MPH, or a Measurement Data Set MDS.
- A dataset contains records. For example, the MERIS L1b MDS1 contains many
- records with radiance values.
- |
-
-
- |
- Record
- |
-
- A single record within a dataset. A record contains many fields. For
- example, a record within the MERIS L1b MDS1 contains a time-stamp field,
- a quality flag field and then a field with as many radiance values as
- contained in the width of the image.
- |
-
-
- |
- Field
- |
-
- A field within a record. Fields can be a scalar or a vector. In the
- example, the time stamp and quality flag are scalars while the radiance
- field is a vector of the length of an image line.
- |
-
-
- |
- Element
- |
-
- Optional. If a field is a vector, these are the elements of that vector.
- In the example each element of the radiance field is the radiance of a
- certain pixel.
- |
-
-
-
-
-
- On each level of the hierarchy, functions exist to point to
- a certain instance of it, e.g. a certain product, dataset or record and so
- on. That function generally requires the name of the item to be retrieved.
- All possible names can be found in the
-
- DDDB
- ,
- and the name of the most important items are listed here. The function returns
- an identifier of that instance. The identifier is not the instance but a pointer
- to it. It is used to get the values of the instance by using access functions.
-
- For example,
-
- my_product_id = epr_open_product("my_MERIS_product");
-
- returns the identifier to the my_product_id
- which points to the product contained in the file "my_MERIS_product".
-
- rad1_id = epr_get_dataset_id(my_product_id, "Radiance_1");
-
-
- This my_product_id is used
- get the identifier rad1_id
- which points to the Radiance_1
- dataset. Now, one can call
-
-
- num_rec = epr_get_num_records(rad1_id);
-
-
- to get the number of records which this dataset contains. Finally one
- can loop over all records and gets its fields and elements. See the examples
- to get a complete code example.
-
-
-
-
-
3.4 Working with Geophysical Data Access
-
-
-
- To work with geophysical data is easier than the basic access. No such deep
- hierarchy exists. Instead of accessing datasets, so called bands will be accessed.
- A band directly includes one single geophysical variable.
-
- For example,
-
- my_product_id = epr_open_product(my_product_file_path);
-
- my_chl_id = epr_create_band_id(my_product_id, "algal_1");
-
- returns the identifier to a band containing the chlorophyll product. Now, the
- actual data are read into a raster.
-
- chl_raster = epr_create_compatible_raster(my_chl_id, ...);
-
- status = epr_read_band_raster(chl_raster, ...);
-
- The raster
- chl_raster now contains the data as two dimensional
- matrix of pixel. To get the value of a pixel at a certain index
- (i,j), one should use the access function:
-
- chl_pixel = epr_get_pixel_as_float(chl_raster, i, j);
-
- (See also the examples ndvi.c for complete example codes.)
-
- The concept of the raster allows spatial subsets and undersampling: A certain
- portion of the ENVISAT product will be read into the raster. This is called
- the source. The complete ENVISAT product can be much greater than the source.
- One can move the raster over the complete ENVISAT product and read in turn different
- parts - always of the size of the source - of it into the raster.
-
- A typical example is a processing in blocks. Lets say, a block has 64x32 pixel.
- Then, the source has a width of 64 pixel and a height of 32 pixel. Another example
- is a processing of complete image lines. Then, the source has a widths of the
- complete product (for example 1121 for a MERIS RR product), and a height of
- 1. One can loop over all blocks or image lines, read into the raster and process
- it. It is, of course, also possible to define a raster of the size of the complete
- product.
-
- In addition, it is possible to define a subsampling step for a raster. This
- means, that the source is not read 1:1 into the raster, but that only every
- 2nd or 3rd pixel is read. This step can be set differently for the across track
- and along track directions.
-
-
3.5 Bit masks
-
- MERIS and AATSR provide many so called flags, which are binary information
- indicating a certain state of a pixel. For example, this can be a quality indicator,
- which, if set, indicates that the value of the pixel is invalid. Other example
- are a cloud flag, indicating that this pixel is a measurement above a cloud,
- or a coastline flag. The flags are stored in a packed format inside the ENVISAT
- products, but the epr-c-api provides a function to easily
- access the flags.
- It returns a bit-mask, which is a byte array that matches the corresponding
- image raster and is 1 where the flag is set and 0 elsewhere. Even more, this
- functions permits to formulate a bit-mask expression to combine any number of
- flags in a logical expression and returns the resulting combined bit-mask:
-
- bm_expr = "flags.LAND OR flags.CLOUD";
-
- status = epr_read_bitmask_raster(product_id, bm_expr, ..., bm_raster);
-
- This is an example to get a bit-mask which masks out all land and cloud pixels.
- The names of the flags are found in the
- DDDB.
- The epr_read_bitmask_raster function read from product,
- identified by product_id, the flags and stores the resulting
- bit-mask in the raster bm_raster.
- See the examples for the complete code.
-
-
4. API Function Group Index
-
-
The epr-c-api provides the following group of functions:
-
-
-
-
- | (1) |
- Initialisation |
- Functions for setting up the environment of the API and releasing
- memory when the API is closed. |
-
-
- | (2) |
- Logging |
- Functions to manage logging information |
-
-
- | (3) |
- Error handling |
- Functions for determining the behaviour of the API in case
- of errors, and of getting information about runtime errors |
-
-
- | (4) |
- Input / Output |
- Opening and closing ENVISAT products and writing data to a
- file or stdout. |
-
-
- | (5) |
- Basic data access |
- Functions to retrieve raw data as stored in ENVISAT products
- |
-
-
- | (6) |
- Geophysical data access |
- Functions to retrieve geophysically interpreted data in a
- raster matrix |
-
-
- | (7) |
- Bit masks |
- Functions for generating bit masks from the flags included
- in ENVISAT products. |
-
-
-
-
-
-
EPR_DatasetRef Struct Reference
-
The EPR_DatasetRef structure represents the information from dddb
-with the reference to data name (in dddb), field-name and index of the element in field-array, in which (by name) searchable values are located.
-More...
-
-
#include <epr_api.h>
-
-
Detailed Description
-
The EPR_DatasetRef structure represents the information from dddb
-with the reference to data name (in dddb), field-name and index of the element in field-array, in which (by name) searchable values are located.
-
Example for the search for a scaling_offset information: This information for the reflec_10 is described with the Scaling_Factor_GADS.22.10 In dataset_id the searched ENVISAT product name (e.g. MER_RR__2P) is located.
-In the corresponding file (e.g. /product/MER_RR__2P.dd) the path, how to find that information will be decribed. In that file, in the field number 22 there is an information about the location of the searched value in the ENVISAT product data.
-
- See also:
- EPR_SDatasetId
-
Field Documentation
-
-
-
-
-
-
-
The documentation for this struct was generated from the following file:
-
-