-
Notifications
You must be signed in to change notification settings - Fork 388
Closed
Description
I'm trying to plot raster data over a Spilhaus
projection but I'm getting some artefacts
This code is MWE to produce the image
import xarray as xr
import fsspec
import pandas as pd
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import numpy as np
import time
from aiohttp.client_exceptions import ServerDisconnectedError
date = pd.Timestamp("2024-01-01")
url = f"https://www.star.nesdis.noaa.gov/pub/socd/mecb/crw/data/5km/v3.1_op/nc/v1.0/daily/sst/{date.year}/coraltemp_v3.1_{date.strftime('%Y%m%d')}.nc"
while True:
try:
file = fsspec.open_local(
f"simplecache::{url}", simplecache={"cache_storage": "/tmp/"}
)
ds = xr.open_dataset(file, engine="netcdf4").squeeze()
break
except ServerDisconnectedError:
time.sleep(0.5)
# Set up the figure and the projection for the plot
fig, ax = plt.subplots(
figsize=(10, 10),
subplot_kw={
"projection": ccrs.Spilhaus()
},
)
ax.add_feature(
cfeature.LAND.with_scale("110m"), edgecolor="black" , linewidth=0.25, zorder=2
)
lon2d, lat2d = np.meshgrid(ds["lon"].values, ds["lat"].values)
ax.pcolormesh(
lon2d,
lat2d,
ds["analysed_sst"].values,
transform=ccrs.PlateCarree(),
)
when trying with imshow
I get this instead, I guess the data is not properly rotated (but no artefacts).
Metadata
Metadata
Assignees
Labels
No labels