33#include "netcdf-cxx4/netcdf"
55 : std::runtime_error(
"Error in NetCDF parser: " + errorMessage)
56 , m_error_message(
"Error in NetCDF parser: " + errorMessage)
65 m_error_message.append(
"\nError in NetCDF parser: " + errormessage);
70 const char*
what() const noexcept
override
72 return m_error_message.c_str();
76 string m_error_message;
131 enum DIMENSION_NUMBER
140 enum DIMENSION_BITMASK
146 T2_MASK = 1 << T2_NUM,
147 VOID_DIMENSION_MASK = 1 << 5
149 static const DIMENSION_BITMASK SURFACE = (DIMENSION_BITMASK)(X_MASK | Y_MASK);
150 static const DIMENSION_BITMASK DEPTH = Z_MASK;
151 static const DIMENSION_BITMASK SPACE = (DIMENSION_BITMASK)(SURFACE | DEPTH);
152 static const DIMENSION_BITMASK SPACE_TIME = (DIMENSION_BITMASK)(SPACE | T_MASK);
153 static const DIMENSION_BITMASK SURFACE_TIME = (DIMENSION_BITMASK)(SURFACE | T_MASK);
154 static const DIMENSION_BITMASK EXPANDED_TIME = (DIMENSION_BITMASK)(T_MASK | T2_MASK);
155 static const DIMENSION_BITMASK ALL_SPACE_AND_TIME = (DIMENSION_BITMASK)(SPACE | EXPANDED_TIME);
162 DIMENSION_BITMASK required_dimensions;
165 struct system_variables
171 variable_info layer_depth;
179 string m_t2_dim_name;
190 void read_dynamic_variable_data(
double* value_array, variable_info variable);
198 void read_variable_info_from_file(variable_info& variable);
207 void check_dimension_order(
const variable_info& variable);
214 int dimension_size(
const string& dimension_name);
217 void read_resolution();
223 void report_exception(
string error_message);
225 std::unique_ptr<netCDF::NcFile> m_ncfile;
227 int m_current_time_offset;
229 system_variables m_variables;
232 string m_fill_value_attribute_name;
233 string m_offset_value_attribute_name;
234 string m_scaling_value_attribute_name;
235 string m_resolution_attribute_name;
237 std::optional<Exception> m_exception_collector;
NetCDF exception for error reporting; what() is the full message.
Definition NetCDFParser.h:48
Exception(const string &errorMessage)
Definition NetCDFParser.h:54
void AppendErrorMessage(const string &errormessage)
Definition NetCDFParser.h:63
const char * what() const noexcept override
Definition NetCDFParser.h:70
Definition NetCDFParser.h:85
void GetStaticData(double *layer_depth, double *depth_map, Date *timeline)
Parser(const Parser &)=delete
Owns the file handle: not copyable.
~Parser(void)
Destructor - closes file.
void LoadFile(string NetCDF_Filepath)
Parser & operator=(const Parser &)=delete
Owns the file handle: not copyable.
void GetDynamicData(double *x_velocity, double *y_velocity, double *z_velocity)
void SetCurrentTime(int offset_from_start_time)
Parser()
Construct parser with null values.
Definition NetCDFParser.h:9
@ Grid
An edge of a gridded wake's box.
Date structure for time coordinates.
Definition NetCDFParser.h:12
int hour
Hour.
Definition NetCDFParser.h:16
int minute
Minute.
Definition NetCDFParser.h:17
int day
Day.
Definition NetCDFParser.h:15
int year
Year.
Definition NetCDFParser.h:13
int second
Second.
Definition NetCDFParser.h:18
int month
Month.
Definition NetCDFParser.h:14
Grid dimensions structure.
Definition NetCDFParser.h:23
double sizeY
Size of grid cells in Y-direction [m].
Definition NetCDFParser.h:29
int numX
Number of grid cells in X-direction (xc, NED north)
Definition NetCDFParser.h:24
int numT
Number of time steps.
Definition NetCDFParser.h:27
int numY
Number of grid cells in Y-direction (yc, NED east)
Definition NetCDFParser.h:25
int numZ
Number of grid cells in Z-direction.
Definition NetCDFParser.h:26
double sizeX
Size of grid cells in X-direction [m].
Definition NetCDFParser.h:28