Skip to content

Commit

Permalink
#2231 Renamed to metadata_map to ugrid_metadata_map. Allow to overrid…
Browse files Browse the repository at this point in the history
…e ugrid_metadata_map
  • Loading branch information
Howard Soh committed Sep 18, 2023
1 parent 0218ae2 commit 8818d62
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 291 deletions.
6 changes: 4 additions & 2 deletions data/config/UGridConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
//
// Unstructured Grid configuration file.
//
// For additional information, please see the MET User's Guide.
// UGridConfig_user at the current working directory overrides the default.
// For additional or updated information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////

//
// Default mapping for Metadata.
// The first values are for MPAS and the second values are for LFric.
//
metadata_map = [
ugrid_metadata_map = [
{ key = "dim_face"; val = "nCells,nMesh2d_face"; },
{ key = "dim_node"; val = "nVertices,nMesh2d_node"; },
{ key = "dim_edge"; val = "nEdges,nMesh2d_edge"; },
Expand Down
45 changes: 12 additions & 33 deletions src/libcode/vx_data2d_ugrid/data2d_ugrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,6 @@ void MetUGridDataFile::ugrid_init_from_scratch() {
return;
}

////////////////////////////////////////////////////////////////////////
/*
NcVarInfo *MetUGridDataFile::find_first_data_var() {
NcVarInfo *first_data_var = nullptr;
// Store the name of the first data variable
for (int i = 0; i < _file->Nvars; ++i) {
if (is_nc_unit_time(_file->Var[i].units_att.c_str()) ||
is_nc_unit_longitude(_file->Var[i].units_att.c_str()) ||
is_nc_unit_latitude(_file->Var[i].units_att.c_str()) ||
_file->get_time_var_info() == &_file->Var[i]
) continue;
if (strcmp(_file->Var[i].name.c_str(), ugrid_lat_var_name) != 0 &&
strcmp(_file->Var[i].name.c_str(), ugrid_lon_var_name) != 0) {
first_data_var = &(_file->Var[i]);
break;
}
}
return first_data_var;
}
*/
////////////////////////////////////////////////////////////////////////

void MetUGridDataFile::close() {
Expand Down Expand Up @@ -211,7 +190,7 @@ cout << " FIXME MetUGridDataFile::data_plane(VarInfo &vinfo, DataPlane &plane)
LongArray dimension = vinfo_nc->dimension();
BoolArray is_offset = vinfo_nc->is_offset();

data_var = _file->find_var_name(vinfo_nc->req_name().c_str());
data_var = _file->find_by_name(vinfo_nc->req_name().c_str());
/*
if (nullptr != data_var) {
time_dim_slot = data_var->t_slot;
Expand Down Expand Up @@ -361,7 +340,7 @@ cout << " FIXME MetUGridDataFile::data_plane(VarInfo &vinfo, DataPlane &plane)
////////////////////////////////////////////////////////////////////////

int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
DataPlaneArray &plane_array) {
DataPlaneArray &plane_array) {
int n_rec = 0;
DataPlane plane;
bool status = false;
Expand All @@ -371,14 +350,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
// Initialize
plane_array.clear();

VarInfoUGrid *vinfo_nc = (VarInfoUGrid *)&vinfo;
if ( vinfo_nc->req_name() == na_str ) {
// Store the name of the first data variable
cout << " FIXME MetUGridDataFile::data_plane_array() calling find_first_data_var()\n";
// NcVarInfo *data_var = find_first_data_var();
// if (nullptr != data_var) vinfo_nc->set_req_name(data_var->name.c_str());
}

LongArray time_offsets = collect_time_offsets(vinfo);
if (0 < time_offsets.n_elements()) {
LevelInfo level = vinfo.level();
Expand Down Expand Up @@ -420,7 +391,7 @@ LongArray MetUGridDataFile::collect_time_offsets(VarInfo &vinfo) {
= "MetUGridDataFile::collect_time_offsets(VarInfo &) -> ";

LongArray time_offsets;
NcVarInfo *info = _file->find_var_name(vinfo_nc->req_name().c_str());
NcVarInfo *info = _file->find_by_name(vinfo_nc->req_name().c_str());

// Check for variable not found
if(!info) {
Expand Down Expand Up @@ -622,7 +593,7 @@ LongArray MetUGridDataFile::collect_time_offsets(VarInfo &vinfo) {

int MetUGridDataFile::index(VarInfo &vinfo){

if( nullptr == _file->find_var_name( vinfo.name().c_str() ) ) return -1;
if( nullptr == _file->find_by_name( vinfo.name().c_str() ) ) return -1;

if( ( vinfo.valid() != 0 && _file->ValidTime[0] != vinfo.valid() ) ||
( vinfo.init() != 0 && _file->InitTime != vinfo.init() ) ||
Expand Down Expand Up @@ -704,3 +675,11 @@ long MetUGridDataFile::convert_value_to_offset(double z_value, string z_dim_name
}

////////////////////////////////////////////////////////////////////////


void MetUGridDataFile::set_map_config_file(ConcatString filename) {
_file->set_map_config_file(filename);
}


////////////////////////////////////////////////////////////////////////
1 change: 1 addition & 0 deletions src/libcode/vx_data2d_ugrid/data2d_ugrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class MetUGridDataFile : public Met2dDataFile {

bool open (const char * filename);
bool open_metadata(const char * filename);
void set_map_config_file(ConcatString filename);

void close ();

Expand Down
Loading

0 comments on commit 8818d62

Please sign in to comment.