OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
val_extract.h File Reference
#include "argpar.h"
#include "olog.h"
#include "shash.h"
#include <netcdf.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for val_extract.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  val_extract_valid_range
 
struct  val_extract_arguments
 
struct  nc_point
 
struct  nc_box
 
struct  nc_file
 
struct  nc_region
 
struct  nc_var_stats
 
struct  nc_var
 

Macros

#define VALEXTRACT_API_VERSION   2007005
 
#define VALEXTRACT_API_VERSION_STR   "2.7.5"
 
#define VALEXTRACT_ERR_NONE   EXIT_SUCCESS
 
#define VALEXTRACT_ERR_POINT_NOT_FOUND   99
 
#define VALEXTRACT_ERR_UNKNOWN   100
 
#define VALEXTRACT_ERR_NCFILE_ERR   101
 
#define VALEXTRACT_ERR_NCFILE_INVALID   102
 
#define VALEXTRACT_ERR_FLAG   103
 
#define VALEXTRACT_ERR_VARIABLE   104
 
#define VALEXTRACT_ERR_INPUT   105
 
#define VALEXTRACT_ERR_L2QC   106
 
#define VALEXTRACT_KEY_INIT   1
 
#define VALEXTRACT_KEY_FILE   2
 
#define VALEXTRACT_KEY_VAR   3
 
#define VALEXTRACT_KEY_SUCCESS   4
 
#define VALEXTRACT_KEY_ERROR   5
 
#define VALEXTRACT_KEY_FINI   6
 
#define VALEXTRACT_CMD_STOP   2
 
#define VALEXTRACT_UNSET   -255
 
#define declare_nc_get_varr(type, suffix)
 
#define declare_compare(type, suffix)   int compare ## suffix(const void *a, const void *b)
 

Typedefs

typedef int(* val_extract_parser) (int key, void *nc_input, void *user_input)
 

Functions

int val_extract (val_extract_arguments *arguments)
 
int val_extract_clean (val_extract_arguments *arguments)
 
void val_extract_clear_args (val_extract_arguments *arguments)
 
void unflatten_index (int index, int ndims, const int *dims, int *result)
 
const char * val_extract_version ()
 
const char * val_extract_api_version ()
 
size_t nc_get_region_size (nc_region *region)
 
size_t nc_get_region_dim_size (nc_region *region, int dim_index)
 
 declare_nc_get_varr (char, _text) declare_nc_get_varr(unsigned char
 
_uchar declare_nc_get_varr (signed char, _schar) declare_nc_get_varr(short
 
_uchar _short declare_nc_get_varr (int, _int) declare_nc_get_varr(long
 
_uchar _short _long declare_nc_get_varr (float, _float) declare_nc_get_varr(double
 
_uchar _short _long _double declare_nc_get_varr (unsigned short, _ushort) declare_nc_get_varr(unsigned int
 
_uchar _short _long _double _uint declare_nc_get_varr (long long, _longlong) declare_nc_get_varr(unsigned long long
 
_uchar _short _long _double _uint _ulonglong declare_nc_get_varr (char *, _string) declare_nc_get_varr(void
 
 declare_compare (int8_t, _int8)
 
 declare_compare (uint8_t, _uint8)
 
 declare_compare (int16_t, _int16)
 
 declare_compare (uint16_t, _uint16)
 
 declare_compare (int32_t, _int32)
 
 declare_compare (uint32_t, _uint32)
 
 declare_compare (int64_t, _int64)
 
 declare_compare (uint64_t, _uint64)
 
 declare_compare (float, _float)
 
 declare_compare (double, _double)
 

Variables

argpar val_extract_argpar
 

Detailed Description

Process a small section of a Level-2 NetCDF file.

Definition in file val_extract.h.

Macro Definition Documentation

◆ declare_compare

#define declare_compare (   type,
  suffix 
)    int compare ## suffix(const void *a, const void *b)

Definition at line 315 of file val_extract.h.

◆ declare_nc_get_varr

#define declare_nc_get_varr (   type,
  suffix 
)
Value:
int nc_get_varr ## suffix(int ncid, int varid, nc_region *region, type *p); \
int nc_get_varrd ## suffix(int ncid, int varid, nc_region *region, int dim_index, type *p);

Definition at line 294 of file val_extract.h.

◆ VALEXTRACT_API_VERSION

#define VALEXTRACT_API_VERSION   2007005

Current API version. If already defined, use API defined first.

Definition at line 20 of file val_extract.h.

◆ VALEXTRACT_API_VERSION_STR

#define VALEXTRACT_API_VERSION_STR   "2.7.5"

Current API version as a string.

Definition at line 22 of file val_extract.h.

◆ VALEXTRACT_CMD_STOP

#define VALEXTRACT_CMD_STOP   2

Returned from a parser to stop processing.

Definition at line 65 of file val_extract.h.

◆ VALEXTRACT_ERR_FLAG

#define VALEXTRACT_ERR_FLAG   103

Returned when the something goes wrong processing l2_flags.

Definition at line 37 of file val_extract.h.

◆ VALEXTRACT_ERR_INPUT

#define VALEXTRACT_ERR_INPUT   105

Returned when given bad or no arguments.

Definition at line 42 of file val_extract.h.

◆ VALEXTRACT_ERR_L2QC

#define VALEXTRACT_ERR_L2QC   106

Not a real error, but returned when the L2QC step says it's a poor quality file.

Definition at line 44 of file val_extract.h.

◆ VALEXTRACT_ERR_NCFILE_ERR

#define VALEXTRACT_ERR_NCFILE_ERR   101

Returned when the NetCDF file can't be opened (due to errors or corruption).

Definition at line 33 of file val_extract.h.

◆ VALEXTRACT_ERR_NCFILE_INVALID

#define VALEXTRACT_ERR_NCFILE_INVALID   102

Returned when the NetCDF file isn't in the format expected (not an L2, etc).

Definition at line 35 of file val_extract.h.

◆ VALEXTRACT_ERR_NONE

#define VALEXTRACT_ERR_NONE   EXIT_SUCCESS

Returned on successful processing.

Definition at line 26 of file val_extract.h.

◆ VALEXTRACT_ERR_POINT_NOT_FOUND

#define VALEXTRACT_ERR_POINT_NOT_FOUND   99

Returned when the desired point is not in the file boundaries.

Definition at line 28 of file val_extract.h.

◆ VALEXTRACT_ERR_UNKNOWN

#define VALEXTRACT_ERR_UNKNOWN   100

Returned for unexpected errors like malloc failures or, possibly, permissions problems and the like.

Definition at line 31 of file val_extract.h.

◆ VALEXTRACT_ERR_VARIABLE

#define VALEXTRACT_ERR_VARIABLE   104

Returned when the something goes wrong processing a product or when finding a product specified on the command line.

Definition at line 40 of file val_extract.h.

◆ VALEXTRACT_KEY_ERROR

#define VALEXTRACT_KEY_ERROR   5

Passed to parser when the processing is finished and an error was encountered.

Definition at line 60 of file val_extract.h.

◆ VALEXTRACT_KEY_FILE

#define VALEXTRACT_KEY_FILE   2

Passed to parser when first opening the NetCDF file. The parser is passed a pointer to an nc_region structure as input.

Definition at line 53 of file val_extract.h.

◆ VALEXTRACT_KEY_FINI

#define VALEXTRACT_KEY_FINI   6

Passed to parser when ending the processing.

Definition at line 62 of file val_extract.h.

◆ VALEXTRACT_KEY_INIT

#define VALEXTRACT_KEY_INIT   1

Passed to parser when beginning the processing.

Definition at line 50 of file val_extract.h.

◆ VALEXTRACT_KEY_SUCCESS

#define VALEXTRACT_KEY_SUCCESS   4

Passed to parser when the processing is finished and no errors were encountered.

Definition at line 58 of file val_extract.h.

◆ VALEXTRACT_KEY_VAR

#define VALEXTRACT_KEY_VAR   3

Passed to parser when a variable is processed. The parser is passed a pointer to an nc_var structure as input.

Definition at line 56 of file val_extract.h.

◆ VALEXTRACT_UNSET

#define VALEXTRACT_UNSET   -255

Initial value for location arguments (lat/lon/line/pixl) before argument parsing.

Definition at line 68 of file val_extract.h.

Typedef Documentation

◆ val_extract_parser

typedef int(* val_extract_parser) (int key, void *nc_input, void *user_input)

Pointer to a callback function to call for each argument parsed.

Parameters
[in]keyOne of the VALEXTRACT_KEY_ macros.
[in]nc_inputEither NULL, an nc_region or nc_var pointer, depending on they key. All pointers should persist until after the VALEXTRACT_KEY_FINI call.
[in]user_inputInput pointer from the val_extract_arguments structure.
Returns
0 on success, 1 on error.

Definition at line 79 of file val_extract.h.

Function Documentation

◆ declare_compare() [1/10]

declare_compare ( double  ,
_double   
)

◆ declare_compare() [2/10]

declare_compare ( float  ,
_float   
)

◆ declare_compare() [3/10]

declare_compare ( int16_t  ,
_int16   
)

◆ declare_compare() [4/10]

declare_compare ( int32_t  ,
_int32   
)

◆ declare_compare() [5/10]

declare_compare ( int64_t  ,
_int64   
)

◆ declare_compare() [6/10]

declare_compare ( int8_t  ,
_int8   
)

◆ declare_compare() [7/10]

declare_compare ( uint16_t  ,
_uint16   
)

◆ declare_compare() [8/10]

declare_compare ( uint32_t  ,
_uint32   
)

◆ declare_compare() [9/10]

declare_compare ( uint64_t  ,
_uint64   
)

◆ declare_compare() [10/10]

declare_compare ( uint8_t  ,
_uint8   
)

◆ declare_nc_get_varr() [1/7]

_uchar _short _long _double _uint _ulonglong declare_nc_get_varr ( char *  ,
_string   
)

◆ declare_nc_get_varr() [2/7]

declare_nc_get_varr ( char  ,
_text   
)

◆ declare_nc_get_varr() [3/7]

_uchar _short _long declare_nc_get_varr ( float  ,
_float   
)

◆ declare_nc_get_varr() [4/7]

_uchar _short declare_nc_get_varr ( int  ,
_int   
)

◆ declare_nc_get_varr() [5/7]

_uchar _short _long _double _uint declare_nc_get_varr ( long long  ,
_longlong   
)

◆ declare_nc_get_varr() [6/7]

_uchar declare_nc_get_varr ( signed char  ,
_schar   
)

◆ declare_nc_get_varr() [7/7]

_uchar _short _long _double declare_nc_get_varr ( unsigned short  ,
_ushort   
)

◆ nc_get_region_dim_size()

size_t nc_get_region_dim_size ( nc_region region,
int  dim_index 
)

Definition at line 2683 of file val_extract.c.

◆ nc_get_region_size()

size_t nc_get_region_size ( nc_region region)

Definition at line 2675 of file val_extract.c.

◆ unflatten_index()

void unflatten_index ( int  index,
int  ndims,
const int *  dims,
int *  result 
)

Given dimension lengths from an nc_file and a one dimensional index, find the corresponding n-dimension index.

Definition at line 2604 of file val_extract.c.

◆ val_extract()

int val_extract ( val_extract_arguments arguments)

Process a small section of a Level-2 NetCDF file.

Parameters
[in]argumentsval_extract_argument structure.
Returns
0 on success, one of VALEXTRACT_ERR_ on error.

Definition at line 589 of file val_extract.c.

◆ val_extract_api_version()

const char* val_extract_api_version ( )

Returns a string representation of the library's implemented API version number, without a label.

Definition at line 2635 of file val_extract.c.

◆ val_extract_clean()

int val_extract_clean ( val_extract_arguments arguments)

Clean up stuff malloc'd by the argpar callback. Should be called at the end of processing if val_extract_argpar is used.

Definition at line 2540 of file val_extract.c.

◆ val_extract_clear_args()

void val_extract_clear_args ( val_extract_arguments arguments)

Clear an argument struct to make it suitable for using the library without using argpar.

This is sometimes necessary because a freshly malloc'd struct can have valid values for arguments that a user may not want; for example, if start and end coords aren't explicitly unset, omitting them from the arguments won't grab the entire file, as would be expected.

Parameters
[in]argumentsval_extract_argument structure.

Definition at line 127 of file val_extract.c.

◆ val_extract_version()

const char* val_extract_version ( )

Returns a string representation of the library's version number, without a label.

Definition at line 2632 of file val_extract.c.

Variable Documentation

◆ val_extract_argpar

argpar val_extract_argpar

argpar structure used for making programs that inherit options from this library.

Definition at line 523 of file val_extract.c.

float p[MODELMAX]
Definition: atrem_corl1.h:131