Skip to content

HRRR : Failed to get CRS from crs variable LambertConfor mal_Projection #38

Closed

Description

@captcha1
import psyplot.project
import matplotlib.pyplot as plt

n1 = 'GFS/Global_onedeg'
# n1 = 'HRRR/CONUS_2p5km' # XXX psy_maps/plotters.py:309: UserWarning: Failed to get CRS from crs variable LambertConformal_Projection
#n1 = 'NAM/Polar_90km' # XXX psy_maps/plotters.py:309: UserWarning: Failed to get CRS from crs variable PolarStereographic_Projection
nwp0 = f'https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/{n1}/Best'

map0 = psyplot.project.plot.mapplot(nwp0,
    name = 'Geopotential_height_isobaric',
    clabel='{desc}', title = n1 + ' %FT%H:%M'
)
map0.update(z=500, method='nearest') # XXX KeyError: 'Unknown formatoption keyword lev! Possible similiar frasings are levels.'
map0.update(t = '2021-10-02', method='nearest') # XXX KeyError: 'Unknown formatoption keyword time! Possible similiar frasings are title.'

plt.show()

n0 = 'u-component_of_wind_isobaric'
vectors = psyplot.project.plot.mapvector(nwp0, name=[[n0, n0.replace('u-', 'v-')]])
plt.show()

Problem description

First off : cool software !

However, I've noticed some technical difficulties :

  1. The first plot (w/ GFS) works fine, but if you uncomment the "n1 = 'HRRR/CONUS_2p5km'", it gives a warning :

psy_maps/plotters.py:309: UserWarning: Failed to get CRS from crs variable LambertConformal_Projection

... and then kind of hangs.

  1. The plot.mapvector call dies (after some time) w/ RuntimeError: NetCDF: Access failure

  2. The calls to select time & level don't seem to work. RFE : some way to put the "level" info in the title.

  3. From the command line :

psyplot https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/GFS/Global_onedeg/Best -n Pressure_reduced_to_MSL_msl

... seems like it should work, but I get : AttributeError: 'NoneType' object has no attribute 'variables'

FYI, this is on Fedora 34.

Output of psyplot -aV

Details psy_maps.plugin: requirements: cartopy: 0.19.0 version: 1.4.0 psy_simple.plugin: version: 1.4.0 psyplot: requirements: matplotlib: 3.4.3 numpy: 1.20.1 pandas: 1.2.5 python: 3.9.7 (default, Aug 30 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] xarray: 0.17.0 version: 1.4.0

Activity

  1. self-assigned this
    on Oct 15, 2021
  2. Chilipp commented on Oct 15, 2021

    @Chilipp
    Member

    hey @captcha1!

    thanks for reporting! I'll have a closer look at it but already found one issue that at least should solve the update problem with map0.update(z=500, method='nearest') (see #39).

    Is it an option that you update your xarray to 0.19? I see that you are still using 0.17. I get different error messages, that's why...

    map0.update(t = '2021-10-02', method='nearest')

    This one is a bit tricky and I am not sure, whether psyplot should really interfer... You have 8 time-stamps on 2021-10-02 and apparently xarray takes all if you do a ds["Geopotential_height_isobaric"].sel(time='2021-10-02', method='nearest')

    see here
    In [8]: ds["Geopotential_height_isobaric"].sel(time='2021-10-02', method='nearest')
    Out[8]: 
    <xarray.DataArray 'Geopotential_height_isobaric' (time: 8, isobaric1: 41, lat: 181, lon: 360)>
    [21372480 values with dtype=float32]
    Coordinates:
      * lat                (lat) float32 90.0 89.0 88.0 87.0 ... -88.0 -89.0 -90.0
      * lon                (lon) float32 0.0 1.0 2.0 3.0 ... 356.0 357.0 358.0 359.0
      * time               (time) datetime64[ns] 2021-10-02 ... 2021-10-02T21:00:00
        reftime            (time) datetime64[ns] ...
      * isobaric1          (isobaric1) float32 1.0 2.0 4.0 ... 9.75e+04 1e+05
        LatLon_Projection  int32 0
    Attributes:
        long_name:                      Geopotential height @ Isobaric surface
        units:                          gpm
        abbreviation:                   HGT
        grid_mapping:                   LatLon_Projection
        Grib_Variable_Id:               VAR_0-3-5_L100
        Grib2_Parameter:                [0 3 5]
        Grib2_Parameter_Discipline:     Meteorological products
        Grib2_Parameter_Category:       Mass
        Grib2_Parameter_Name:           Geopotential height
        Grib2_Level_Type:               100
        Grib2_Level_Desc:               Isobaric surface
        Grib2_Generating_Process_Type:  Forecast

    So maybe you should use map0.update(t = '2021-10-02T00:00:00', method='nearest')

    vectors = psyplot.project.plot.mapvector(nwp0, name=[[n0, n0.replace('u-', 'v-')]])

    No idea about this one. It looks like it wants to download the entire netCDF file because I am getting the following message:

    oc_open: server error retrieving url: code=403 message="Request too big=3964.59504 Mbytes, max=500.0"
    

    So something is going wrong here because the entire data should not be loaded, only what is needed for visualization. I'll need to have a look.

    I'll also have a look into the other files and keep you posted.

  3. captcha1 commented on Oct 15, 2021

    @captcha1
    Author

    Great !

    FYI, HRRR mapplot works OK direct from nomads (mapvector slow (ok w/ sref)) :

    import psyplot.project
    import matplotlib.pyplot as plt
    import datetime
    
    nwp0 = 'sref_bc/sref%Y%m%d/srefbc_arw_p1_03z' ; f0 = 'prmslmsl' ; n0 = 'ugrd500mb' # XXX hack : p1 & 03z hardcoded
    nwp0 = 'gfs_1p00/gfs%Y%m%d/gfs_1p00_%Hz' ; f0 = 'prmslmsl' ; n0 = 'ugrdprs'
    nwp0 = 'hrrr/hrrr%Y%m%d/hrrr_sfc.t%Hz' ; f0 = 'mslmamsl' ; n0 = 'ugrdprs'
    
    dt0 = datetime.datetime(2021, 10, 15)
    ds0 = psyplot.data.open_dataset(dt0.strftime('https://nomads.ncep.noaa.gov/dods/' + nwp0))
    
    map0 = ds0.psy.plot.mapplot(name = f0, clabel='{desc}', title = nwp0.split('/')[0] + ' %FT%H:%M')
    plt.show()
    
    vectors = ds0.psy.plot.mapvector(name=[[n0, n0.replace('u', 'v')]],
        plot='stream', color='absolute',
        clabel='{desc}', title = nwp0.split('/')[0] + ' %FT%H:%M'
    )
    plt.show()
    

    FYI, apparently thredds.ucar.edu gets it's data from nomads via NOAAPORT (satellite broadcast).

  4. Chilipp commented on Oct 15, 2021

    @Chilipp
    Member

    I'll also have a look into the other files and keep you posted.

    alright, seems the current implementation in psy-maps assumed the false_easting and false_northing attributes for the grid mapping are mandatory. They are now made optional in psyplot/psy-maps#41

  5. captcha1 commented on Oct 16, 2021

    @captcha1
    Author

    thanks for reporting! I'll have a closer look at it but already found one issue that at least should solve the update problem with map0.update(z=500, method='nearest') (see #39).

    Is it an option that you update your xarray to 0.19? I see that you are still using 0.17. I get different error messages, that's why...

    map0.update(t = '2021-10-02', method='nearest')

    This one is a bit tricky and I am not sure, whether psyplot should really interfer... You have 8 time-stamps on 2021-10-02 and apparently xarray takes all if you do a ds["Geopotential_height_isobaric"].sel(time='2021-10-02', method='nearest')

    see here
    So maybe you should use map0.update(t = '2021-10-02T00:00:00', method='nearest')

    I used a datetime object and that seems to work better.

    I installed xarray to 0.19, but got the same symptom. It seems to work fine w/ the nomads.ncep.noaa.gov data source. The thredds.ucar.edu data source has a lot of extra coordinates, eg : time1, time2, isobaric1, etc. That said, thredds.ucar.edu works with MetPy.

    Also, mapvector works OK w/ the nomads sref data (takes about 10 seconds to plot), but it's slow w/ gfs (5 minues) & hrrr.

  6. Chilipp commented on Oct 16, 2021

    @Chilipp
    Member

    Also, mapvector works OK w/ the nomads sref data (takes about 10 seconds to plot), but it's slow w/ gfs (5 minues) & hrrr.

    Sure! I already found the cause but need a few minutes to fix it (it's weekend 😉).

  7. Chilipp commented on Oct 18, 2021

    @Chilipp
    Member

    hey @captcha1! Apologies for the delay. I fixed everything (I suppose) and it would be great if you could quickly test it. Just use the fix/38 branch of psyplot and psy-maps.

    To do this, update your local installation from github (pip install -U git+https://github.com/psyplot/psyplot.git@fix/38 git+https://github.com/psyplot/psy-maps.git@fix/38) and please rerun you script with all the datasets that you mentioned above

  8. captcha1 commented on Oct 19, 2021

    @captcha1
    Author

    Thanks for your quick fix !

    The "ucar hrrr" data (ei : https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/HRRR/CONUS_2p5km/Best ) doesn't error out, but has the wrong plot : the latitude goes from 25.003 to 25.03 and longitude goes from 95.01 to 94.99.

  9. Chilipp commented on Oct 19, 2021

    @Chilipp
    Member

    hmm, ok. Thanks for the feedback! The cartopy projection assumes coordinates to be in meter, whereas your coordinates are in units of km. That is why. I need to transform this

  10. Chilipp commented on Oct 19, 2021

    @Chilipp
    Member

    alright @captcha1! I added a fix with psyplot/psy-maps@37121cf and it seems to work. But it would be great if you could verify once more. Just update psy-maps via pip install -U git+https://github.com/psyplot/psy-maps.git@fix/38

    Thanks a lot for your patience =)

  11. Chilipp commented on Oct 20, 2021

    @Chilipp
    Member

    I added a fix with psyplot/psy-maps@37121cf and it seems to work.

    but thinking about it, the solution there is not bulletproof. It does not take bounds into account and it cannot be used for unstructured grids, for instance. So it's probably better to generalize the conversion handling that I already implemented for radians

    https://github.com/psyplot/psy-simple/blob/ac305c052b6bc9da47465ee1f35a1c64e489aca6/psy_simple/plotters.py#L126-L143

    I can take care of that tomorrow

  12. Chilipp commented on Oct 28, 2021

    @Chilipp
    Member

    hey @captcha1! I did implement the fix now (apologies for the delay). Could you please verify that it works by running

    pip install -U git+https://github.com/psyplot/psy-maps.git@fix/38 git+https://github.com/psyplot/psyplot.git@fix/38 git+https://github.com/psyplot/psy-simple.git@fix/38

    and testing your script above? Then I'll merge the three PRs #39, psyplot/psy-simple#30 and psyplot/psy-maps#41 and close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions