diff --git a/src/libcode/vx_data2d_factory/data2d_factory.cc b/src/libcode/vx_data2d_factory/data2d_factory.cc index ff422493d0..2eacd00539 100644 --- a/src/libcode/vx_data2d_factory/data2d_factory.cc +++ b/src/libcode/vx_data2d_factory/data2d_factory.cc @@ -159,7 +159,7 @@ MetPythonDataFile * p = nullptr; //////////////////////////////////////////////////////////////////////// -Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename) { +Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, ConcatString attr_grid) { GrdFileType type; Met2dDataFile *mtddf = (Met2dDataFile *) nullptr; @@ -179,7 +179,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename) if(mtddf && type != FileType_Python_Numpy && type != FileType_Python_Xarray) { - if(!(mtddf->open(filename))) { + if(!(mtddf->open(filename, attr_grid))) { mlog << Error << "\nMet2dDataFileFactory::new_met_2d_data_file() -> " << "error opening file \"" << filename << "\"\n\n"; exit(1); @@ -191,7 +191,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename) //////////////////////////////////////////////////////////////////////// -Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, GrdFileType type) +Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, GrdFileType type, ConcatString attr_grid) { @@ -223,7 +223,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, if(mtddf && type != FileType_Python_Numpy && type != FileType_Python_Xarray) { - if(!(mtddf->open(filename))) { + if(!(mtddf->open(filename, attr_grid))) { mlog << Error << "\nMet2dDataFileFactory::new_met_2d_data_file() -> " << "error opening file \"" << filename << "\"\n\n"; exit(1); @@ -235,7 +235,7 @@ Met2dDataFile * Met2dDataFileFactory::new_met_2d_data_file(const char *filename, // Otherwise determine the type from the file name // else { - mtddf = new_met_2d_data_file(filename); + mtddf = new_met_2d_data_file(filename, attr_grid); } return mtddf; diff --git a/src/libcode/vx_data2d_factory/data2d_factory.h b/src/libcode/vx_data2d_factory/data2d_factory.h index 0ad9072900..15fc9cc4da 100644 --- a/src/libcode/vx_data2d_factory/data2d_factory.h +++ b/src/libcode/vx_data2d_factory/data2d_factory.h @@ -22,8 +22,8 @@ class Met2dDataFileFactory { public: static Met2dDataFile *new_met_2d_data_file(GrdFileType type); - static Met2dDataFile *new_met_2d_data_file(const char *filename); - static Met2dDataFile *new_met_2d_data_file(const char *filename, GrdFileType type); + static Met2dDataFile *new_met_2d_data_file(const char *filename, ConcatString attr_grid=""); + static Met2dDataFile *new_met_2d_data_file(const char *filename, GrdFileType type, ConcatString attr_grid=""); }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib/data2d_grib.cc b/src/libcode/vx_data2d_grib/data2d_grib.cc index be22e02005..1a9c9802fd 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.cc +++ b/src/libcode/vx_data2d_grib/data2d_grib.cc @@ -137,7 +137,7 @@ return; //////////////////////////////////////////////////////////////////////// -bool MetGrib1DataFile::open(const char * _filename) +bool MetGrib1DataFile::open(const char * _filename, ConcatString grid_str) { diff --git a/src/libcode/vx_data2d_grib/data2d_grib.h b/src/libcode/vx_data2d_grib/data2d_grib.h index bcfbc45ab9..bdea14026f 100644 --- a/src/libcode/vx_data2d_grib/data2d_grib.h +++ b/src/libcode/vx_data2d_grib/data2d_grib.h @@ -74,7 +74,7 @@ class MetGrib1DataFile : public Met2dDataFile { // do stuff // - bool open(const char * filename); + bool open(const char * filename, ConcatString grid_str=""); void close(); diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.cc b/src/libcode/vx_data2d_grib2/data2d_grib2.cc index 67b456764b..2f0875d4a0 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.cc +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.cc @@ -99,7 +99,7 @@ void MetGrib2DataFile::close() { //////////////////////////////////////////////////////////////////////// -bool MetGrib2DataFile::open(const char * _filename) { +bool MetGrib2DataFile::open(const char * _filename, ConcatString grid_str) { Filename = _filename; if( nullptr == (FileGrib2 = met_fopen(Filename.c_str(), "r")) ){ mlog << Error << "\nMetGrib2DataFile::open() -> " diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.h b/src/libcode/vx_data2d_grib2/data2d_grib2.h index 3811f7cfa8..96b2285af8 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.h +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.h @@ -150,7 +150,7 @@ class MetGrib2DataFile : public Met2dDataFile { // do stuff // - bool open (const char * filename); + bool open (const char * filename, ConcatString grid_str=""); void close (); diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 8c4373a62c..59b53d41f9 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -117,13 +117,13 @@ void MetNcCFDataFile::close() { //////////////////////////////////////////////////////////////////////// -bool MetNcCFDataFile::open(const char * _filename) { +bool MetNcCFDataFile::open(const char * _filename, ConcatString attr_grid) { close(); _file = new NcCfFile; - if(!_file->open(_filename)) { + if(!_file->open(_filename, attr_grid)) { mlog << Error << "\nMetNcCFDataFile::open(const char *) -> " << "unable to open NetCDF file \"" << _filename << "\"\n\n"; close(); diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h index 05e68fc54f..4de81d2a5f 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.h @@ -96,7 +96,7 @@ class MetNcCFDataFile : public Met2dDataFile { // do stuff // - bool open (const char * filename); + bool open (const char * filename, ConcatString grid_str=""); void close (); diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index 3038965ab6..940b79818c 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -26,6 +26,7 @@ #include "vx_cal.h" #include "vx_log.h" +#include "data2d_utils.h" #include "nc_cf_file.h" using namespace std; @@ -169,7 +170,7 @@ void NcCfFile::close() //////////////////////////////////////////////////////////////////////// -bool NcCfFile::open(const char * filepath) +bool NcCfFile::open(const char * filepath, ConcatString grid_str) { unixtime ut; int sec_per_unit; @@ -189,6 +190,8 @@ bool NcCfFile::open(const char * filepath) // FIXME: Commented out with NetCDF4 enabling // NcError err(NcError::silent_nonfatal); + _grid_str = grid_str; + // Open the file _ncFile = open_ncfile(filepath); @@ -438,7 +441,12 @@ bool NcCfFile::open(const char * filepath) StringArray dimNames; string var_x_dim_name, var_y_dim_name; if (IS_VALID_NC_P(_xDim)) var_x_dim_name = GET_NC_NAME_P(_xDim); +cout << " DEBUG HS var_x_dim_name = " << var_x_dim_name << "\n"; +cout << " DEBUG HS IS_VALID_NC_P(_yDim) = " << IS_VALID_NC_P(_yDim) << "\n"; + if (IS_VALID_NC_P(_yDim)) cout << " DEBUG HS _yDim->getName() = " << _yDim->getName() << "\n"; + if (IS_VALID_NC_P(_yDim)) cout << " DEBUG HS GET_NC_NAME_P(_yDim) = " << GET_NC_NAME_P(_yDim) << "\n"; if (IS_VALID_NC_P(_yDim)) var_y_dim_name = GET_NC_NAME_P(_yDim); +cout << " DEBUG HS var_y_dim_name = " << var_y_dim_name << "\n"; for (int j=0; j " + mlog << Error << "\n" << method_name << "Couldn't figure out projection from information in netCDF file.\n\n"; exit(1); } @@ -3406,7 +3421,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, << i-1 << "]=" << lat_values[i-1] << " lat[" << i << "]=" << lat_values[i] << " " << fabs(curr_delta - dlat) << " > " << degree_tolerance << "\n"; - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Latitude/Longitude files where the latitudes are evenly spaced (dlat=" << dlat <<", delta[" << i << "]=" << curr_delta << ")\n\n"; sanity_check_failed = true; @@ -3426,7 +3441,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, << i-1 << "]=" << lon_values[i-1] << " lon[" << i << "]=" << lon_values[i] << " " << fabs(curr_delta - dlon) << " > " << degree_tolerance << "\n"; - mlog << Error << "\n" << method_name << " -> " + mlog << Warning << "\n" << method_name << " -> " << "MET can only process Latitude/Longitude files where the longitudes are evenly spaced (dlon=" << dlon <<", delta[" << i << "]=" << curr_delta << ")\n\n"; sanity_check_failed = true; @@ -3434,7 +3449,7 @@ LatLonData NcCfFile::get_data_from_lat_lon_vars(NcVar *lat_var, NcVar *lon_var, } } - if (sanity_check_failed) { + if (sanity_check_failed && _grid_str.empty()) { mlog << Error << "\n" << method_name << " -> " << "Please check the input data is the lat/lon projection\n\n"; exit(1); diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h index 5e29896459..46032fd330 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.h +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.h @@ -47,7 +47,7 @@ class NcCfFile { NcCfFile(); ~NcCfFile(); - bool open(const char * filename); + bool open(const char * filename, ConcatString attr_grid=""); void close(); @@ -117,11 +117,14 @@ class NcCfFile { NcVarInfo* find_var_name(const char * var_name) const; NcVarInfo* find_var_by_dim_name(const char *dim_name) const; + //void set_attr_grid(ConcatString grid_str); + private: static const double DELTA_TOLERANCE; netCDF::NcFile * _ncFile; // allocated + ConcatString _grid_str; // // dimensions @@ -198,6 +201,12 @@ class NcCfFile { //////////////////////////////////////////////////////////////////////// +//inline void NcCfFile::set_attr_grid(ConcatString grid_str) { attr_grid = grid_str; }; + + +//////////////////////////////////////////////////////////////////////// + + #endif /* __NC_CF_FILE_H__ */ diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc index 3cda55bcfe..e1a72dde8b 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.cc @@ -82,7 +82,7 @@ void MetNcMetDataFile::close() { //////////////////////////////////////////////////////////////////////// -bool MetNcMetDataFile::open(const char * _filename) { +bool MetNcMetDataFile::open(const char * _filename, ConcatString grid_str) { close(); diff --git a/src/libcode/vx_data2d_nc_met/data2d_nc_met.h b/src/libcode/vx_data2d_nc_met/data2d_nc_met.h index d4ae16fc55..53892d6f2c 100644 --- a/src/libcode/vx_data2d_nc_met/data2d_nc_met.h +++ b/src/libcode/vx_data2d_nc_met/data2d_nc_met.h @@ -73,7 +73,7 @@ class MetNcMetDataFile : public Met2dDataFile { // do stuff // - bool open (const char * filename); + bool open (const char * filename, ConcatString grid_str=""); void close (); diff --git a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc index 2dc8ddedad..42b16b40e5 100644 --- a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc +++ b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.cc @@ -83,7 +83,7 @@ void MetNcWrfDataFile::close() { //////////////////////////////////////////////////////////////////////// -bool MetNcWrfDataFile::open(const char * _filename) { +bool MetNcWrfDataFile::open(const char * _filename, ConcatString grid_str) { close(); diff --git a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.h b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.h index a9a1e081c4..5b86e26b35 100644 --- a/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.h +++ b/src/libcode/vx_data2d_nc_wrf/data2d_nc_wrf.h @@ -75,7 +75,7 @@ class MetNcWrfDataFile : public Met2dDataFile { // do stuff // - bool open (const char * filename); + bool open (const char * filename, ConcatString grid_str=""); void close (); diff --git a/src/libcode/vx_data2d_python/data2d_python.cc b/src/libcode/vx_data2d_python/data2d_python.cc index cefd04cf79..d607484d49 100644 --- a/src/libcode/vx_data2d_python/data2d_python.cc +++ b/src/libcode/vx_data2d_python/data2d_python.cc @@ -145,7 +145,7 @@ return; //////////////////////////////////////////////////////////////////////// -bool MetPythonDataFile::open(const char * cur_command) +bool MetPythonDataFile::open(const char * cur_command, ConcatString grid_str) { diff --git a/src/libcode/vx_data2d_python/data2d_python.h b/src/libcode/vx_data2d_python/data2d_python.h index ff205885bd..351ca12292 100644 --- a/src/libcode/vx_data2d_python/data2d_python.h +++ b/src/libcode/vx_data2d_python/data2d_python.h @@ -79,7 +79,7 @@ class MetPythonDataFile : public Met2dDataFile { // do stuff // - bool open(const char * cur_command); + bool open(const char * cur_command, ConcatString grid_str=""); void close(); diff --git a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc index 7b9ea3b25f..df77782d98 100644 --- a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc +++ b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc @@ -102,7 +102,7 @@ void MetUGridDataFile::close() { //////////////////////////////////////////////////////////////////////// -bool MetUGridDataFile::open(const char * _filename) { +bool MetUGridDataFile::open(const char * _filename, ConcatString grid_str) { close(); diff --git a/src/libcode/vx_data2d_ugrid/data2d_ugrid.h b/src/libcode/vx_data2d_ugrid/data2d_ugrid.h index de549b0640..68f6ffaefb 100644 --- a/src/libcode/vx_data2d_ugrid/data2d_ugrid.h +++ b/src/libcode/vx_data2d_ugrid/data2d_ugrid.h @@ -107,7 +107,7 @@ class MetUGridDataFile : public Met2dDataFile { // do stuff // - bool open (const char * filename); + bool open (const char * filename, ConcatString grid_str=""); bool open_metadata(const char * filename); ConcatString coordinate_file() const; void set_ugrid_configs(ConcatString dataset_name, double max_distance_km,