AntSimi / py-eddy-tracker

Eddy identification and tracking
https://py-eddy-tracker.readthedocs.io/en/latest/
GNU General Public License v3.0
133 stars 55 forks source link

Cartopy projection #238

Closed berzinastella closed 6 months ago

berzinastella commented 7 months ago

transform=projection Hi, I want to plot the eddy trajectories by centering the map over the Pacific instead of the Atlantic (central_longitude=180). the background cartopy map changes how I want, but the eddy trajectories stay centered as before even if I use transform=projection. As far as I have tries, also changing the ref in .plot does not help. All that I'm saying is in the code below

Code


%matplotlib inline
lonshift = 180
proj=ccrs.PlateCarree(central_longitude = lonshift)
fig, ax = plt.subplots(1, 1, figsize=(40, 15), subplot_kw={'projection': proj})
gl = ax.gridlines(draw_labels=True, y_inline=True) # need cartopy version 0.18!!!
gl.top_labels = False
gl.xformatter = LongitudeFormatter()
gl.yformatter = LatitudeFormatter()

land = cfeature.NaturalEarthFeature(
        category='physical',
        name='land',
        scale='10m',
        facecolor='grey')
ax.add_feature(land)

# a_20y  and c_20y are just eddy trajectory datasets in the pyeddytracker format
a_20y.plot(ax, ref=180, label="Anticyclonic ({nb_tracks} tracks)", color="r", lw=1, transform=proj) 
c_20y.plot(ax, ref=180, label="Cyclonic ({nb_tracks} tracks)", color="b", lw=1, transform=proj)
ax.legend(fontsize=20, loc='lower right')
Screenshot 2024-04-08 at 11 38 33

How could I get the trajectoreis to also transform in the projection that I want? Is there some function I'm missing?

Thank you! Stella

AntSimi commented 7 months ago

Problem come from transform option, you need to specify data projection and not target projection : transform=ccrs.PlateCarree()