Plotting data which is already in Lambert projection

72 Views Asked by At

Recently I am trying to plot the meteorological field from HRRR datasets. However, HRRR datasets are already in Lambert projection (not gridded). The datasets provide x,y as an index (1~len(x) and 1~len(y)) and latitude/longitude consisting of (x,y). Here's the printed information of the datasets:

Coordinates:
  * time           (time) datetime64[ns] 2022-01-01
    step           timedelta64[ns] ...
    isobaricInhPa  float64 1e+03
    latitude       (y, x) float64 ...
    longitude      (y, x) float64 ...
    valid_time     (time) datetime64[ns] ...
Dimensions without coordinates: y, x
Attributes:
    GRIB_paramId:                             131
    GRIB_dataType:                            fc
    GRIB_numberOfPoints:                      1905141
    GRIB_typeOfLevel:                         isobaricInhPa
    GRIB_stepUnits:                           1
    GRIB_stepType:                            instant
    GRIB_gridType:                            lambert
    GRIB_DxInMetres:                          3000.0
    GRIB_DyInMetres:                          3000.0
    GRIB_LaDInDegrees:                        38.5
    GRIB_Latin1InDegrees:                     38.5
    GRIB_Latin2InDegrees:                     38.5
    GRIB_LoVInDegrees:                        262.5
    GRIB_NV:                                  0
    GRIB_Nx:                                  1799
    GRIB_Ny:                                  1059
    GRIB_cfName:                              eastward_wind
    GRIB_cfVarName:                           u
    GRIB_gridDefinitionDescription:           Lambert Conformal can be secant...
    GRIB_iScansNegatively:                    0
    GRIB_jPointsAreConsecutive:               0
    GRIB_jScansPositively:                    1
    GRIB_latitudeOfFirstGridPointInDegrees:   21.138123
    GRIB_latitudeOfSouthernPoleInDegrees:     0.0
    GRIB_longitudeOfFirstGridPointInDegrees:  237.280472
    GRIB_longitudeOfSouthernPoleInDegrees:    0.0
    GRIB_missingValue:                        9999
    GRIB_name:                                U component of wind
    GRIB_shortName:                           u
    GRIB_units:                               m s**-1
    long_name:                                U component of wind
    units:                                    m s**-1
    standard_name:                            eastward_wind

I followed the example codes provided here https://mesowest.utah.edu/html/hrrr/zarr_documentation/html/xarray_one_day_analysis_example.html. Here's the screenshot of the code and figures provided by HRRR community: enter image description here

However, it seems that the wind field is not transform correctly when I run my code (both quiver and contourf) because the coastlines is not shown.

projection = ccrs.LambertConformal(central_longitude=262.5,
                                   central_latitude=38.5,
                                   standard_parallels=(38.5, 38.5),
                                    globe=ccrs.Globe(semimajor_axis=6371229,
                                                     semiminor_axis=6371229))

# plot
ax = plt.axes(projection=ccrs.Mercator())
ax.contourf(u_plt.x, u_plt.y, u_plt, transform=projection)
ax.coastlines()
plt.show()

enter image description here

To be honest, I am very confused why the example code works because it does not provide any longitude/latitude information when plotting! I also tried to reproduce their results, but their environment yml have problems when using metpy. (I guess it is because the version is too old but not sure.)

Anyway, I just want to know how to plot the datasets with transformed coordinates. Thank you!

1

There are 1 best solutions below

2
Stéphane On

As far as I understand, you should discard contourf arguments x and y, and provide argument extent. It worked for me.