1212from parcels .tools .loggers import logger
1313
1414
15- def plotparticles (particles , with_particles = True , show_time = None , field = None , domain = None , projection = None ,
16- land = True , vmin = None , vmax = None , savefile = None , animation = False , ** kwargs ):
15+ def plotparticles (particles , with_particles = True , show_time = None , field = None , domain = None ,
16+ projection = 'PlateCarree' , land = True , vmin = None , vmax = None , savefile = None ,
17+ animation = False , ** kwargs ):
1718 """Function to plot a Parcels ParticleSet
1819
1920 :param show_time: Time at which to show the ParticleSet
@@ -48,7 +49,7 @@ def plotparticles(particles, with_particles=True, show_time=None, field=None, do
4849 return # creating axes was not possible
4950 ax .set_title ('Particles' + parsetimestr (particles .fieldset .U .grid .time_origin , show_time ))
5051 latN , latS , lonE , lonW = parsedomain (domain , particles .fieldset .U )
51- if cartopy is None or projection is None :
52+ if ( cartopy is None ) or ( projection is None ) :
5253 if domain is not None :
5354 if isinstance (particles .fieldset .U .grid , CurvilinearGrid ):
5455 ax .set_xlim (particles .fieldset .U .grid .lon [latS , lonW ], particles .fieldset .U .grid .lon [latN , lonE ])
@@ -99,7 +100,7 @@ def plotparticles(particles, with_particles=True, show_time=None, field=None, do
99100 plt .close ()
100101
101102
102- def plotfield (field , show_time = None , domain = None , depth_level = 0 , projection = None , land = True ,
103+ def plotfield (field , show_time = None , domain = None , depth_level = 0 , projection = 'PlateCarree' , land = True ,
103104 vmin = None , vmax = None , savefile = None , ** kwargs ):
104105 """Function to plot a Parcels Field
105106
@@ -263,24 +264,21 @@ def plotfield(field, show_time=None, domain=None, depth_level=0, projection=None
263264 return plt , fig , ax , cartopy
264265
265266
266- def create_parcelsfig_axis (spherical , land = True , projection = None , central_longitude = 0 , cartopy_features = []):
267+ def create_parcelsfig_axis (spherical , land = True , projection = 'PlateCarree' , central_longitude = 0 , cartopy_features = []):
267268 try :
268269 import matplotlib .pyplot as plt
269270 except :
270271 logger .info ("Visualisation is not possible. Matplotlib not found." )
271272 return None , None , None , None # creating axes was not possible
272273
273- if projection is not None and not spherical :
274- raise RuntimeError ('projection not accepted when Field doesn' 't have geographic coordinates' )
275-
276- if spherical :
274+ if spherical and projection :
277275 try :
278276 import cartopy
279277 except :
280278 logger .info ("Visualisation of field with geographic coordinates is not possible. Cartopy not found." )
281279 return None , None , None , None # creating axes was not possible
282280
283- projection = cartopy .crs .PlateCarree (central_longitude ) if projection is None else projection
281+ projection = cartopy .crs .PlateCarree (central_longitude ) if projection == 'PlateCarree' else projection
284282 fig , ax = plt .subplots (1 , 1 , subplot_kw = {'projection' : projection })
285283 try : # gridlines not supported for all projections
286284 if isinstance (projection , cartopy .crs .PlateCarree ) and central_longitude != 0 :
@@ -299,7 +297,7 @@ def create_parcelsfig_axis(spherical, land=True, projection=None, central_longit
299297 if isinstance (land , str ):
300298 ax .coastlines (land )
301299 elif land :
302- ax .coastlines ()
300+ ax .coastlines (zorder = 10 )
303301 else :
304302 cartopy = None
305303 fig , ax = plt .subplots (1 , 1 )
0 commit comments