metview-python icon indicating copy to clipboard operation
metview-python copied to clipboard

Error with metview.regrid when attempted regrid to Lambert Conformal

Open wxworkoff opened this issue 7 months ago • 0 comments

What happened?

Hi all--

I've run into issues trying to re-grid a dataset already on a Lambert Conformal grid to a slightly different Lambert Conformal grid. The grid I'm trying to re-project to is NCEP grid 227, the details of which can be found here: https://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID227

  I'm having trouble parsing through the error message to find out what the exact issue may be...but it does appear that the bounding box (corners) are not what they are supposed to be. For whatever that is worth.

I've noticed that NCEP LCC grids are normally written/read in SW:NE format, so the first lat/lon point information provided is the south/west corner, not the north/west corner that metview.regrid requests. However, the NCEP documentation does give the coordinates of all 4 corners....but providing the north/west corner as the 'first_point' coordinate does not appear to be working.

I fully acknowledge user error is a possibility here, as I'm far from a grid projection expert and am having a hard time seeing the forest through the trees. Hopefully I'm just missing something small...but hours of tinkering has proven unsuccessful here.

The error, verbatim, is below (with offending code example to follow below).

Python - ERROR - 20240717.142350 - Line 0 in 'PythonScript': Serious Bug: Representation::extendBoundingBox() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -4.22613e+06 , end => 3.25015e+06 , N => 1473 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => 4.36869e+06 , end => -832210 , N => 1025 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 265 , latitude0 => 25 , latitude1 => 25 , latitude2 => 25}],firstPointBottomLeft=0,bbox=BoundingBox[north=61.2801,west=207.144,south=12.194,east=310.606]] Traceback (most recent call last): File "/home/awips/Tom/testing/ensemble/metview_regrid.py", line 168, in test3 = regrid_to_lambert_conformal(originalgrib2file,cfgrib_shortName,newgrib2file) File "/home/awips/Tom/testing/ensemble/metview_regrid.py", line 133, in regrid_to_lambert_conformal newgrid1 = mv.regrid( File "/fewxops/software/anaconda3/envs/fewx_dev/lib/python3.10/site-packages/metview/bindings.py", line 1285, in wrapped return value_from_metview(val) File "/fewxops/software/anaconda3/envs/fewx_dev/lib/python3.10/site-packages/metview/bindings.py", line 1239, in value_from_metview raise retval Exception: Metview error: Serious Bug: Representation::extendBoundingBox() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -4.22613e+06 , end => 3.25015e+06 , N => 1473 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => 4.36869e+06 , end => -832210 , N => 1025 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 265 , latitude0 => 25 , latitude1 => 25 , latitude2 => 25}],firstPointBottomLeft=0,bbox=BoundingBox[north=61.2801,west=207.144,south=12.194,east=310.606]]

What are the steps to reproduce the bug?

A streamlined version of the offending code is below. Note that original data ingest, in this case, is done via Xarray/cfgrib. The file used here can be acquired from NCEP's NOMADS database, with a location (date need may to be adjusted) of: https://nomads.ncep.noaa.gov/pub/data/nccf/com/hrrr/prod/hrrr.20240717/conus/

ds=xr.open_dataset('hrrr.t00z.wrfsfcf18.grib2',engine='cfgrib',backend_kwargs={'read_keys':['stepRange','typeOfStatisticalProcessing', 'productDefinitionTemplateNumber', 'centre', 'subCentre', 'tablesVersion', 'masterDir', 'localTablesVersion'], 'filter_by_keys': {'shortName': 'tp'}})

value = ds['tp']

##Values from NCEP Grid 227 ##wgrib2 output/NCEP documentation from grid gives south/west point for first point, and north/west is needed by MetView newgrid1 = mv.regrid( grid_definition_mode = "lambert_conformal", first_point = [54.536,-152.856], dx_in_metres = 5079, dy_in_metres = 5079, nx = 1473, ny = 1025, lad_in_degrees = 25, lov_in_degrees = 265, data = value, interpolation = 'nearest_neighbor' )

Python - ERROR - 20240717.142350 - Line 0 in 'PythonScript': Serious Bug: Representation::extendBoundingBox() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -4.22613e+06 , end => 3.25015e+06 , N => 1473 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => 4.36869e+06 , end => -832210 , N => 1025 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 265 , latitude0 => 25 , latitude1 => 25 , latitude2 => 25}],firstPointBottomLeft=0,bbox=BoundingBox[north=61.2801,west=207.144,south=12.194,east=310.606]] Traceback (most recent call last): File "/home/awips/Tom/testing/ensemble/metview_regrid.py", line 168, in test3 = regrid_to_lambert_conformal(originalgrib2file,cfgrib_shortName,newgrib2file) File "/home/awips/Tom/testing/ensemble/metview_regrid.py", line 133, in regrid_to_lambert_conformal newgrid1 = mv.regrid( File "/fewxops/software/anaconda3/envs/fewx_dev/lib/python3.10/site-packages/metview/bindings.py", line 1285, in wrapped return value_from_metview(val) File "/fewxops/software/anaconda3/envs/fewx_dev/lib/python3.10/site-packages/metview/bindings.py", line 1239, in value_from_metview raise retval Exception: Metview error: Serious Bug: Representation::extendBoundingBox() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -4.22613e+06 , end => 3.25015e+06 , N => 1473 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => 4.36869e+06 , end => -832210 , N => 1025 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 265 , latitude0 => 25 , latitude1 => 25 , latitude2 => 25}],firstPointBottomLeft=0,bbox=BoundingBox[north=61.2801,west=207.144,south=12.194,east=310.606]]

Version

metview-python: v1.16.1 metview: v5.18.0

Platform (OS and architecture)

RHEL 8.9

Relevant log output

No response

Accompanying data

No response

Organisation

FirstEnergy (USA)

wxworkoff avatar Jul 17 '24 15:07 wxworkoff