Skip to content

Commit

Permalink
2638 Override vertical level from the dimension name
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Aug 17, 2023
1 parent 572af4f commit 8f7b559
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/libcode/vx_data2d_nccf/data2d_nccf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,19 @@ bool MetNcCFDataFile::data_plane(VarInfo &vinfo, DataPlane &plane)
}
else {
long z_cnt = (long)_file->vlevels.n();
if (z_cnt > 0) {

zdim_slot = idx;
// Checks if the data veriable has a vertical dimension
if (0 <= data_var->z_slot) {
org_z_offset = dim_offset;
long z_offset = dim_offset;
string z_dim_name;

zdim_slot = idx;
if (0 <= data_var->z_slot) {
NcDim z_dim = get_nc_dim(data_var->var, data_var->z_slot);
if (IS_VALID_NC(z_dim)) z_dim_name = GET_NC_NAME(z_dim);
if (IS_VALID_NC(z_dim)) {
z_dim_name = GET_NC_NAME(z_dim);
z_cnt = get_dim_size(&z_dim); // override the virtical level count
}
}
if (!is_offset[idx]) {
// convert the value to index for slicing
Expand Down Expand Up @@ -663,12 +667,11 @@ long MetNcCFDataFile::convert_value_to_offset(double z_value, string z_dim_name)
}
}

if (!found && 0 < z_dim_name.length()) {
NcVarInfo *var_info = find_var_info_by_dim_name(_file->Var, z_dim_name, _file->Nvars);
if (var_info) {
long new_offset = get_index_at_nc_data(var_info->var, z_value, z_dim_name);
if (new_offset != bad_data_int) z_offset = new_offset;
}
// Overrides if the variable specific vertical dimension exists
NcVarInfo *var_info = find_var_info_by_dim_name(_file->Var, z_dim_name, _file->Nvars);
if (var_info) {
long new_offset = get_index_at_nc_data(var_info->var, z_value, z_dim_name);
z_offset = new_offset;
}

return z_offset;
Expand Down

0 comments on commit 8f7b559

Please sign in to comment.