Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 2638 nccf coordinate dimension main v11.1 #2653

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ jobs:
needs: [job_control]
if: ${{ needs.job_control.outputs.run_unit_tests == 'true' }}
steps:
- uses: dtcenter/metplus-action-data-update@v2
- uses: dtcenter/metplus-action-data-update@v3
with:
docker_name: ${{ secrets.DOCKER_USERNAME }}
docker_pass: ${{ secrets.DOCKER_PASSWORD }}
repo_name: ${{ github.repository }}
data_prefix: unit_test
branch_name: ${{ needs.job_control.outputs.branch_name }}
branch_name: ${{ needs.job_control.outputs.truth_data_version }}
docker_data_dir: /data/input/MET_test_data
data_repo_dev: met-data-dev

Expand Down
14 changes: 14 additions & 0 deletions internal/test_unit/xml/unit_plot_data_plane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,18 @@
</output>
</test>

<test name="plot_data_plane_NCCF_not_standard_vertical_levels">
<exec>&MET_BIN;/plot_data_plane</exec>
<param> \
&DATA_DIR_MODEL;/nccf/percentile_extract_20230729T1200Z-B20230725T0030Z-visibility_at_screen_level.nc \
&OUTPUT_DIR;/plot_data_plane/visibility_in_air_by_percentile.ps \
'name="visibility_in_air"; level="(6,*,*)";' \
-title "Visibility in air" \
-v 1
</param>
<output>
<ps>&OUTPUT_DIR;/plot_data_plane/visibility_in_air_by_percentile.ps</ps>
</output>
</test>

</met_test>
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
11 changes: 9 additions & 2 deletions src/libcode/vx_data2d_nccf/nccf_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ bool NcCfFile::open(const char * filepath)
else if( "latitude" == att_value ) _latVar = Var[j].var;
else if( "longitude" == att_value ) _lonVar = Var[j].var;
else if( ("air_pressure" == att_value || "height" == att_value)
&& (0 == z_var) ) z_var = Var[j].var;
&& (nullptr==z_var && 1==get_dim_count(Var[j].var))) z_var = Var[j].var;
}
if ( Var[j].name == "time" && (valid_time_var == 0)) {
if ( Var[j].name == "time" && (valid_time_var == nullptr)) {
valid_time_var = Var[j].var;
_time_var_info = &Var[j];
}
Expand Down Expand Up @@ -490,6 +490,13 @@ bool NcCfFile::open(const char * filepath)
if (info) z_var = info->var;
}

mlog << Debug(5) << method_name << "coordinate variables:"
<< " x=" << (IS_VALID_NC_P(_xCoordVar) ? GET_NC_NAME_P(_xCoordVar) : "N/A")
<< ", y=" << (IS_VALID_NC_P(_yCoordVar) ? GET_NC_NAME_P(_yCoordVar) : "N/A")
<< ", z=" << (IS_VALID_NC_P(z_var) ? GET_NC_NAME_P(z_var) : "N/A")
<< ", t=" << (IS_VALID_NC_P(valid_time_var) ? GET_NC_NAME_P(valid_time_var) : "N/A")
<< "\n";

// Pull out the vertical levels
if (IS_VALID_NC_P(z_var)) {

Expand Down