dtcenter / MET

Model Evaluation Tools
https://dtcenter.org/community-code/model-evaluation-tools-met
Apache License 2.0
78 stars 24 forks source link

Fix support for reading rotated lat/lon grids from GRIB1 files (grid type 10) #2118

Closed CPKalb closed 2 years ago

CPKalb commented 2 years ago

Describe the Enhancement

When trying to read cosmo data, the following error is generated: ERROR : gds_to_order() -> Grid type 10 not currently supported. These files are rotated latitude and longitude grids in grib1 format. lfff03080000.gz

Time Estimate

1-2 days

Sub-Issues

Consider breaking the enhancement down into sub-issues. None needed.

Relevant Deadlines

ASAP

Funding Source

7740181 WRF Modeling Using 4D for UAE

Define the Metadata

Assignee

Labels

Projects and Milestone

Define Related Issue(s)

Consider the impact to the other METplus components.

Enhancement Checklist

See the METplus Workflow for details.

JohnHalleyGotway commented 2 years ago

I sure wish we actually had a sample GRIB1 file on a rotated lat/lon grid that did not have the south pole at (lat, lon) = (-90, 0). It's also curious that dx = dy = 0.

Following the log message to turn off strict GRIB1 checking leads to this next error:

Screen Shot 2022-04-05 at 4 48 06 PM

So Panpoly doesn't like it.

The curious thing is that while this is encoded as a rotated lat/lon grid, I don't see any rotation. Might just as well be a regular lat/lon projection.

CPKalb commented 2 years ago

Thanks. I'm not as savvy with wgrib, so didn't manage to get that much information from the file. The dx and dy in python looked to be 0.025, so it seems like maybe that isn't not specified correctly in the file? Could that cause issues getting it into MET directly as a grib file?

I wondered if it actually was rotated, as it didn't seem rotated when I read it into python. I'm going to see if I can get something that looks reasonable through plot_data_plane using python embedding

JohnHalleyGotway commented 2 years ago

@CPKalb I made some local edits to the main_v10.1 branch and was able to get plot_data_plane to make this plot using that sample file.

Screen Shot 2022-04-06 at 1 03 43 PM

Some details.

I wish we had a much wider variety of GRIB1 files on rotated lat/lon grids with which to test!

CPKalb commented 2 years ago

I'm not sure if that is what python is doing. I just printed the lat/lon values and could see that the spacing was 0.025. Probably it would be good to have logic to get dx and dy in the case that they are 0. I agree that more data would be better.

I guess the question on my end would be should I go ahead and use python embedding to read these files for uae, or is this addition to MET close to being ready?

JohnHalleyGotway commented 2 years ago

I can add the logic for accommodating this specific grid pretty easily, but I'm very concerned about the underlying assumptions. I can't imagine that these changes are correct.

They'd basically just hard code the south pole location as (lat, lon) = (-90, 0) and the rotation angle as 0.0. That's my concern. It may work for this one grid and no others, but we can't really confirm without more sample data files.

So is it a good idea to create a "partial bugfix" for a specific project/grid even though you suspect it isn't a sufficient solution?

JohnHalleyGotway commented 2 years ago

How about it make my proposed hack of a fix on a feature branch and compile it on seneca for you to test out.

While you're doing that, I'll see if I can use cnvgrib and/or wgrib to generate additional sample GRIB1 files on rotated lat/lon grids. The trouble is that I don't see in the GRIB1 spec how a rotation would even be specified. I could also inspect the wgrib source code for clues as to if/how it's done there.

CPKalb commented 2 years ago

Yes, that will work! Thanks

JohnHalleyGotway commented 2 years ago

@CPKalb you can find the bugfix branch for testing in seneca:/d1/personal/johnhg/MET/MET_development/MET-bugfix_2118_main_v10.1_grib1_rotll/met/bin. It's compiling now.

I tested this on my laptop in 2 ways:

  1. Plotting the 2m TMP data directly:
    bin/plot_data_plane lfff03080000.grib lfff03080000.ps 'name="TMP"; level="Z2";' -v 4
  2. Regridding that field to a global lat/lon grid and then plotting the result:
    bin/regrid_data_plane lfff03080000.grib G004 lfff03080000_G004.nc -field 'name="TMP"; level="Z2";' -v 10 -method NEAREST
    bin/plot_data_plane lfff03080000_G004.nc lfff03080000_G004.ps 'name="TMP_Z2"; level="(*,*)";'

Here's the resulting images.

Screen Shot 2022-04-06 at 2 58 38 PM

They look reasonable to me.