Attempting to perform simple gridded image plot using pygmt.grdimage .
I know this is some issue with my understanding so this is not a bug report, and hopefully it is easy enough for a someone to quickly see the solution.
Here is the data:
<xarray.DataArray (y: 185, x: 148)> Size: 110kB
array([[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
…,
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan]], dtype=float32)
Coordinates:
lon (y, x) float32 110kB -18.88 -18.62 -18.38 … 17.38 17.62 17.88
lat (y, x) float32 110kB -79.92 -79.92 -79.92 … -60.08 -60.08 -60.08
Dimensions without coordinates: y, x
Attributes:
description: Fast ice thickness
units: m
This is code that I used to create the xarray data array.
hi_plt = xr.DataArray(data=hi_mask.values,
dims=["y", "x"],
coords=dict(lon=(["y", "x"], lon_mask.values),
lat=(["y", "x"], lat_mask.values)),
attrs=dict(description="Fast ice thickness",
units="m"))
This is code that I’m using to attempt to visualise this data:
proj = f"B{lonC:.1f}/{latC:.1f}/{ext_plt[2]:.1f}/{ext_plt[3]:.1f}/20c"
pygmt.makecpt(cmap="cmocean/amp", series=[0,5], output="hi_mask.cpt")
fig = pygmt.Figure()
fig.grdimage(grid=hi_plt, cmap="hi_mask.cpt", projection=proj, region=ext_plt, frame="a")
fig.coast(land="white", water="black")
fig.colorbar(cmap="hi_mask.cpt",
frame="a1f.5+lThickness (m)",
position="JBC+w10c/0.4c+mc+h")
fig.show()
And this is the warning that it results in:
grdimage [WARNING]: Your grid y’s or latitudes appear to be outside the map region and will be skipped.
grdimage [WARNING]: No grid or image inside plot domain
I also attached the xarray simple visualisation of the data that I’m attempting to reprsent geographically with pygmt.
Thanks for your help.