Skip to content

Commit

Permalink
Bugfix 2968 point2grid set attr grid (#2969)
Browse files Browse the repository at this point in the history
* #2968 Corrected set_attr_grid for point2grid_cice_set_attr_grid

* #2968 Compare the DataPlane size and the variable data size

* #2968 nx and ny are not ignored with set_attr_grid

* #2968 Compare the DataPlane size and the variable data size

---------

Co-authored-by: Howard Soh <[email protected]>
  • Loading branch information
hsoh-u and Howard Soh authored Sep 10, 2024
1 parent 2e14724 commit 06ac57b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/Users_Guide/reformat_point.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ Only 4 interpolation methods are applied to the field variables; MIN/MAX/MEDIAN/
For the GOES-16 and GOES-17 data, the computing lat/long is time consuming. The computed coordinate (lat/long) is saved to a temporary NetCDF file, as described in :numref:`Contributor's Guide Section %s <tmp_files_point2grid>`. The computing lat/long step can be skipped if the coordinate file is given through the environment variable MET_GEOSTATIONARY_DATA. The grid mapping to the target grid is saved to MET_TMP_DIR to save the execution time. Once this file is created, the MET_GEOSTATIONARY_DATA is ignored. The grid mapping file should be deleted manually in order to apply a new MET_GEOSTATIONARY_DATA environment variable or to re-generate the grid mapping file. An example of call point2grid to process GOES-16 AOD data is shown below:


The grid name or the grid definition can be given with the -field option when the grid information is missing from the input NetCDF file for the latitude_longitude projection. The latitude and longitude variable names should be defined by the user, and the grid information from the set_attr_grid is ignored in this case
The grid name or the grid definition can be given with the -field option when the grid information is missing from the input NetCDF file for the latitude_longitude projection. The latitude and longitude variable names should be defined by the user, and the grid information from the set_attr_grid is ignored in this case except nx and ny.

.. code-block:: none
Expand Down
2 changes: 1 addition & 1 deletion internal/test_unit/xml/unit_point2grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
G231 \
&OUTPUT_DIR;/point2grid/point2grid_cice_to_G231.nc \
-config &CONFIG_DIR;/Point2GridConfig_tlat_tlon \
-field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 180 360 -80 -180 1 1";' \
-field 'name="hi_d"; level="(0,*,*)"; set_attr_grid="latlon 1440 1080 -80 -180 0.1 0.1";' \
-v 1
</param>
<output>
Expand Down
12 changes: 12 additions & 0 deletions src/libcode/vx_data2d_nc_cf/nc_cf_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,18 @@ bool NcCfFile::getData(NcVar * v, const LongArray & a, DataPlane & plane) const
const int nx = grid.nx();
const int ny = grid.ny();

size_t data_size = 1;
for (int k=0; k<dim_count; k++) {
if (a[k] == vx_data2d_star) data_size *= v->getDim(k).getSize();
}
if (data_size == 1) data_size = v->getDim(x_slot).getSize() * v->getDim(y_slot).getSize();
if (!is_eq(data_size, (size_t)nx*ny)) {
mlog << Error << "\n" << method_name
<< "Allocated DataPlane from Grid (" << nx*ny << ") does not match with the variable size ("
<< data_size << "). Please check set_attr_grid settings (nx and ny) if applied.\n\n";
exit(1);
}

plane.clear();
plane.set_size(nx, ny);

Expand Down

0 comments on commit 06ac57b

Please sign in to comment.