1#ifndef C_NETCDF_PARSER_H
2#define C_NETCDF_PARSER_H
6 struct Date {
int year;
int month;
int day;
int hour;
int minute;
int second;};
17#ifdef NETCDFCPP_AVAILABLE
18#include "netcdf-cxx4/netcdf"
35 void LoadFile(
string NetCDF_Filepath);
37 void GetStaticData(
double* layer_depth,
double* depth_map, Date* timeline);
39 void SetCurrentTime(
int offset_from_start_time);
40 void GetDynamicData(
double* x_velocity,
double* y_velocity,
double* z_velocity);
43 enum DIMENSION_NUMBER {X_NUM = 0, Y_NUM = 1, Z_NUM = 2, T_NUM = 3, T2_NUM = 4};
44 enum DIMENSION_BITMASK {X_MASK = 1<<X_NUM, Y_MASK = 1<<Y_NUM, Z_MASK = 1<<Z_NUM, T_MASK = 1<<T_NUM, T2_MASK = 1<<T2_NUM, VOID_DIMENSION_MASK = 1<<5};
45 static const DIMENSION_BITMASK SURFACE = (DIMENSION_BITMASK)(X_MASK | Y_MASK);
46 static const DIMENSION_BITMASK DEPTH = Z_MASK;
47 static const DIMENSION_BITMASK SPACE = (DIMENSION_BITMASK)(SURFACE | DEPTH);
48 static const DIMENSION_BITMASK SPACE_TIME = (DIMENSION_BITMASK)(SPACE | T_MASK);
49 static const DIMENSION_BITMASK SURFACE_TIME = (DIMENSION_BITMASK)(SURFACE | T_MASK);
50 static const DIMENSION_BITMASK EXPANDED_TIME = (DIMENSION_BITMASK)(T_MASK | T2_MASK);
51 static const DIMENSION_BITMASK ALL_SPACE_AND_TIME = (DIMENSION_BITMASK)(SPACE | EXPANDED_TIME);
53 struct variable_info {
string name; netCDF::NcVar ncvar; DIMENSION_BITMASK required_dimensions;};
54 struct system_variables {variable_info vx; variable_info vy; variable_info vz; variable_info depth; variable_info layer_depth; variable_info time;};
67 void read_dynamic_variable_data(
double* value_array, variable_info variable);
69 void read_variable_info_from_file(variable_info& variable);
70 void report_exception(
string error_message);
74 netCDF::NcFile* m_ncfile;
76 int m_current_time_offset;
78 system_variables m_variables;
81 string m_fill_value_attribute_name;
82 string m_offset_value_attribute_name;
83 string m_scaling_value_attribute_name;
84 string m_resolution_attribute_name;
86 Exception* m_exception_collector;
92 Exception(
string errorMessage){
93 m_error_message =
"Error in NetCDF parser: "+errorMessage;
95 void AppendErrorMessage(
string errormessage){
96 m_error_message.append(
"\nError in NetCDF parser: "+errormessage);
98 string GetErrorMessage(){
99 return m_error_message;
102 string m_error_message;
Definition: NetCDFParser.h:6
Definition: NetCDFParser.h:7
double sizeX
number of time steps
Definition: NetCDFParser.h:12
double sizeY
size of grid cells in X-direction
Definition: NetCDFParser.h:13
int numT
number of grid cells in Z-direction
Definition: NetCDFParser.h:11
int numY
number of grid cells in X-direction
Definition: NetCDFParser.h:9
int numZ
number of grid cells in Y-direction
Definition: NetCDFParser.h:10