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

Representation::croppedRepresentation() not implemented for RegularGrid #52

Open
MiNeEU opened this issue Oct 5, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@MiNeEU
Copy link

MiNeEU commented Oct 5, 2023

What happened?

When I try to process grb in Lambert it is not possible to crop it

CLSTEMPERATURE_00.grb

filename = 'CLSTEMPERATURE_00.grb'
f = mv.read(filename)
f = mv.read(data=f, area=[47,15,50,23])

Is it possible to implement it? Thanks

Python - ERROR - 20231005.095534 - Line 0 in 'PythonScript': Exception: Serious Bug: Representation::croppedRepresentation() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -1.28924e+06 , end => 1.23076e+06 , N => 561 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => -827936 , end => 1.14306e+06 , N => 439 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 17 , latitude0 => 46.244 , latitude1 => 46.244 , latitude2 => 46.244}],firstPointBottomLeft=0,bbox=BoundingBox[north=56.4659,west=-3.18266,south=37.759,east=36.3038]]
Python - ERROR - 20231005.095534 - Line 0 in 'PythonScript': MIR: Serious Bug: Representation::croppedRepresentation() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -1.28924e+06 , end => 1.23076e+06 , N => 561 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => -827936 , end => 1.14306e+06 , N => 439 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 17 , latitude0 => 46.244 , latitude1 => 46.244 , latitude2 => 46.244}],firstPointBottomLeft=0,bbox=BoundingBox[north=56.4659,west=-3.18266,south=37.759,east=36.3038]]
Python - ERROR - 20231005.095534 - Line 0 in 'PythonScript': Interpolation failed (-2)
Python - ERROR - 20231005.095534 - Line 0 in 'PythonScript': Retrieve-> Error code: -2
Traceback (most recent call last):

What are the steps to reproduce the bug?

When I try to process grb in Lambert it is not possible to crop it

CLSTEMPERATURE_00.grb

filename = 'CLSTEMPERATURE_00.grb'
f = mv.read(filename)
f = mv.read(data=f, area=[47,15,50,23])

Is it possible to implement it? Thanks

Version

1.15.0

Platform (OS and architecture)

Linux x86_64

Relevant log output

Python - ERROR  - 20231005.095534 - Line 0 in 'PythonScript': Exception: Serious Bug: Representation::croppedRepresentation() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -1.28924e+06 , end => 1.23076e+06 , N => 561 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => -827936 , end => 1.14306e+06 , N => 439 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 17 , latitude0 => 46.244 , latitude1 => 46.244 , latitude2 => 46.244}],firstPointBottomLeft=0,bbox=BoundingBox[north=56.4659,west=-3.18266,south=37.759,east=36.3038]]
Python - ERROR  - 20231005.095534 - Line 0 in 'PythonScript': MIR: Serious Bug: Representation::croppedRepresentation() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -1.28924e+06 , end => 1.23076e+06 , N => 561 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => -827936 , end => 1.14306e+06 , N => 439 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 17 , latitude0 => 46.244 , latitude1 => 46.244 , latitude2 => 46.244}],firstPointBottomLeft=0,bbox=BoundingBox[north=56.4659,west=-3.18266,south=37.759,east=36.3038]]
Python - ERROR  - 20231005.095534 - Line 0 in 'PythonScript': Interpolation failed (-2)
Python - ERROR  - 20231005.095534 - Line 0 in 'PythonScript': Retrieve-> Error code: -2
Traceback (most recent call last):
  File "test_final_griborg_mask_area.py", line 46, in <module>
    f = mv.read(data=f, area=[47,15,50,23])
  File "/users/hips001/bin/Python-hips/lib/python3.7/site-packages/metview/bindings.py", line 1278, in wrapped
    return value_from_metview(val)
  File "/users/hips001/bin/Python-hips/lib/python3.7/site-packages/metview/bindings.py", line 1232, in value_from_metview
    raise retval
Exception: Metview error: Exception: Serious Bug: Representation::croppedRepresentation() not implemented for RegularGrid[x=LocalConfiguration[root={type => linear , start => -1.28924e+06 , end => 1.23076e+06 , N => 561 , endpoint => true}],y=LocalConfiguration[root={type => linear , start => -827936 , end => 1.14306e+06 , N => 439 , endpoint => true}],projection=LocalConfiguration[root={type => lambert_conformal_conic , longitude0 => 17 , latitude0 => 46.244 , latitude1 => 46.244 , latitude2 => 46.244}],firstPointBottomLeft=0,bbox=BoundingBox[north=56.4659,west=-3.18266,south=37.759,east=36.3038]]

Accompanying data

https://aladin.nowcasting.eu/shmu/alaro/oper/CLSTEMPERATURE_00.grb

Organisation

SHMU

@MiNeEU MiNeEU added the bug Something isn't working label Oct 5, 2023
@iainrussell
Copy link
Member

Hi @MiNeEU,

Many thanks for the report. I can confirm that we do not support the direct cropping of these Lambert Conformal grids. You do have a couple of options though, depending on what you want to do with the data next.

  1. You can change the grid to be regular lat/lon within that read command, e.g.
f = mv.read(data=f, area=[47,15,50,23], grid=[0.1,0.1])

This will crop and interpolate onto the regular grid in one step. Your data will now be on a regular grid - the finer the grid you choose (I used 0.1 degrees in this example, but you can change it), the closer it will be to the original data.

  1. You could convert to Geopoints if you don't mind the data becoming 'scattered' points. e.g.
geo = mv.grib_to_geo(geopoints_format = "x_y_v", data = f)
inside_mask = geo.mask([47,15,50,23])
inside = geo.filter(inside_mask)

I hope this helps!

Cheers,
Iain

@MiNeEU
Copy link
Author

MiNeEU commented Oct 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants