77from climaf import __path__ as cpath
88from climaf import operators
99from climaf .operators import cscript , fixed_fields
10+ from climaf .cache import cdrop
1011
1112scriptpath = cpath [0 ] + '/../scripts/'
1213binpath = cpath [0 ] + '/../bin/'
@@ -95,8 +96,10 @@ def load_plot_operators():
9596 "--contours_map_max='${cntx}' "
9697 "--contours_map_scale='${contours_map_scale}' "
9798 "--contours_map_scale='${cnts}' "
99+ "--scale_aux=${scale_aux} "
98100 "--contours_map_offset='${contours_map_offset}' "
99101 "--contours_map_offset='${cnto}' "
102+ "--offset_aux=${offset_aux} "
100103 #
101104 # Vector map
102105 #
@@ -180,15 +183,22 @@ def load_plot_operators():
180183
181184
182185def plot (* largs , forbid_plotmap = False , ** kwargs ):
183- """
184- A replacement for old CliMAF plot operator, which uses plotmap,
185- simplifies the plot if needed, and keep tracks of arguments not managed by plotmaps
186+ """
187+ A replacement for old CliMAF plot operator, which uses plotmap
188+ if possible, simplifies the plot if needed, and keep tracks of
189+ arguments not managed by plotmap
190+
186191 """
187192 caller = sys ._getframe ().f_back .f_code .co_name
188193
189194 if not env .environment .plot_use_plotmap or forbid_plotmap :
195+ if not env .environment .plot_use_plotmap :
196+ reason = "because of global setting"
197+ else :
198+ reason = "because of call argument"
190199 rep = operators .plot (* largs , ** kwargs )
191- clogger .info ("Plotmap warning: using old plot for %s. Caller is :%s" % (rep .crs , caller ))
200+ clogger .info ("Plotmap warning: using old plot for %s %s. Caller is :%s" %
201+ (rep .crs , reason , caller ))
192202 return (rep )
193203
194204 # Should check that input data has two horizontal dimensions ...
@@ -226,7 +236,6 @@ def plot(*largs, forbid_plotmap=False, **kwargs):
226236 "Gnomonic" , "Mercator" , "LambertConformal" , "Robinson" ,
227237 "Hammer" , "Mollweide" , "PlateCarree" ]
228238 must_use_old_plot = False
229-
230239 # shade_above et al. : a affiner
231240 outargs = dict ()
232241 for arg in kwargs .keys ():
@@ -245,9 +254,10 @@ def plot(*largs, forbid_plotmap=False, **kwargs):
245254 ". Caller is :%s" % caller )
246255 outargs .pop (arg )
247256
248- # "proj" : change Ncl names in Cartopy's , when applicable
257+ # "proj" : check that projection is known by plotmap; adapt default options
249258 if arg == "proj" :
250259 proj = kwargs ["proj" ]
260+ clogger .info ("Processing proj %s" % proj )
251261 if proj [0 :2 ] in ["NH" , "SH" ]:
252262 pass
253263 elif proj in compatible_projections :
@@ -329,7 +339,14 @@ def plot(*largs, forbid_plotmap=False, **kwargs):
329339 outargs [oarg ] = 'streamplot'
330340
331341 elif arg .lower () == "mpcenterlonf" :
332- outargs ["proj_options" ] = {'central_longitude' : kwargs [arg ]}
342+ if "proj" in kwargs and kwargs ['proj' ][0 :2 ] not in ["NH" , "SH" ]:
343+ if 'proj_options' not in outargs :
344+ outargs ['proj_options' ] = dict ()
345+ outargs ['proj_options' ]['central_longitude' ] = kwargs [arg ]
346+ else :
347+ # Mimic NCl behaviour, which just neglect that option
348+ # for polar stereo projections
349+ pass
333350
334351 elif arg == "gsnLeftString" :
335352 if "title_options" not in outargs :
@@ -381,13 +398,20 @@ def plot(*largs, forbid_plotmap=False, **kwargs):
381398 # if 'proj' not in outargs:
382399 # outargs["proj"] = "PlateCarree"
383400
401+ if 'proj' in outargs :
402+ if outargs ['proj' ] == 'Robinson' :
403+ if 'proj_options' not in outargs :
404+ outargs ['proj_options' ] = dict ()
405+ if 'central_longitude' not in outargs ['proj_options' ]:
406+ outargs ['proj_options' ]['central_longitude' ] = 180.
407+
384408 if must_use_old_plot :
385409 rep = operators .plot (* largs , ** kwargs )
386410 clogger .info ("Plotmap warning: using old plot for %s" % rep .crs +
387411 ". Caller is :%s" % caller )
388- return ( rep )
389-
390- rep = operators . plotmap ( main , aux , u , v , shade2 , ** outargs )
391- if env . environment . teach_me_plotmap :
392- print ( "Plotmap call: %s" % rep . crs )
412+ else :
413+ rep = operators . plotmap ( main , aux , u , v , shade2 , ** outargs )
414+ if env . environment . teach_me_plotmap :
415+ print ( "Plotmap call: %s" % rep . crs )
416+ #cdrop( rep)
393417 return (rep )
0 commit comments