66import numpy as np
77from scipy .signal import argrelextrema
88
9- from . import conf , error , field , misc , phyvars
9+ from . import conf , error , field , phyvars
10+ from ._helpers import saveplot
1011from .stagyydata import StagyyData
1112
1213
@@ -283,7 +284,7 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
283284 plot_plate_limits (ax3 , ridge , trench , conf .plates .vmin ,
284285 conf .plates .vmax )
285286
286- misc . saveplot (fig0 , 'sveltempconc' , timestep )
287+ saveplot (fig0 , 'sveltempconc' , timestep )
287288
288289 # plotting velocity and velocity derivative
289290 fig0 , (ax1 , ax2 ) = plt .subplots (2 , 1 , sharex = True , figsize = (12 , 8 ))
@@ -314,7 +315,7 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
314315 conf .plates .dvmax , facecolor = '#8b6914' , alpha = 0.2 )
315316 ax2 .set_ylim (conf .plates .dvmin , conf .plates .dvmax )
316317
317- misc . saveplot (fig0 , 'sveldvel' , timestep )
318+ saveplot (fig0 , 'sveldvel' , timestep )
318319
319320 # plotting velocity and second invariant of stress
320321 if 'str' in conf .plates .plot :
@@ -350,7 +351,7 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
350351 conf .plates .dvmax ,
351352 facecolor = '#8B6914' , alpha = 0.2 )
352353
353- misc . saveplot (fig0 , 'svelstress' , timestep )
354+ saveplot (fig0 , 'svelstress' , timestep )
354355
355356 # plotting velocity
356357 fig1 , (ax1 , ax2 ) = plt .subplots (2 , 1 , sharex = True , figsize = (12 , 8 ))
@@ -449,7 +450,7 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
449450 plot_plate_limits (ax2 , ridge , trench , conf .plates .topomin ,
450451 conf .plates .topomax )
451452 ax1 .set_title (timestep )
452- misc . saveplot (fig1 , 'sveltopo' , timestep )
453+ saveplot (fig1 , 'sveltopo' , timestep )
453454
454455 if 'age' in conf .plates .plot :
455456 ax4 .set_ylabel ("Seafloor age [My]" )
@@ -463,7 +464,7 @@ def plot_plates(step, time, vrms_surface, trench, ridge, agetrench,
463464 plot_plate_limits (ax4 , ridge , trench , conf .plates .agemin ,
464465 conf .plates .agemax )
465466 ax3 .set_title (timestep )
466- misc . saveplot (fig2 , 'svelage' , timestep )
467+ saveplot (fig2 , 'svelage' , timestep )
467468
468469 # writing the output into a file, all time steps are in one file
469470 for isubd in np .arange (len (distance_subd )):
@@ -505,7 +506,7 @@ def lithospheric_stress(step, trench, ridge, time):
505506 # Annotation with time and step
506507 axis .text (1. , 0.9 , str (round (time , 0 )) + ' My' , transform = axis .transAxes )
507508 axis .text (1. , 0.1 , str (timestep ), transform = axis .transAxes )
508- misc . saveplot (fig , 'lith' , timestep )
509+ saveplot (fig , 'lith' , timestep )
509510
510511 # velocity
511512 vphi = step .fields ['v2' ][0 , :, :, 0 ]
@@ -576,7 +577,7 @@ def lithospheric_stress(step, trench, ridge, time):
576577 conf .plates .lstressmax , facecolor = '#8b6914' , alpha = 0.2 )
577578 ax2 .set_ylim (conf .plates .stressmin , conf .plates .lstressmax )
578579
579- misc . saveplot (fig0 , 'svelslith' , timestep )
580+ saveplot (fig0 , 'svelslith' , timestep )
580581
581582
582583def set_of_vars (arg_plot ):
@@ -686,7 +687,7 @@ def main_plates(sdat):
686687 # Put arrow where ridges and trenches are
687688 plot_plate_limits_field (axis , rcmb , ridges , trenches )
688689
689- misc . saveplot (fig , 'eta' , timestep , close = False )
690+ saveplot (fig , 'eta' , timestep , close = conf . plates . zoom is None )
690691
691692 # Zoom
692693 if conf .plates .zoom is not None :
@@ -704,8 +705,7 @@ def main_plates(sdat):
704705 yzoom = (rcmb + 1 ) * np .sin (np .radians (conf .plates .zoom ))
705706 axis .set_xlim (xzoom - ladd , xzoom + radd )
706707 axis .set_ylim (yzoom - dadd , yzoom + uadd )
707- misc .saveplot (fig , 'etazoom' , timestep , close = False )
708- plt .close (fig )
708+ saveplot (fig , 'etazoom' , timestep )
709709
710710 # plot stress field with position of trenches and ridges
711711 if 'str' in conf .plates .plot :
@@ -721,14 +721,13 @@ def main_plates(sdat):
721721 # Put arrow where ridges and trenches are
722722 plot_plate_limits_field (axis , rcmb , ridges , trenches )
723723
724- misc . saveplot (fig , 's' , timestep , close = False )
724+ saveplot (fig , 's' , timestep , close = conf . plates . zoom is None )
725725
726726 # Zoom
727727 if conf .plates .zoom is not None :
728728 axis .set_xlim (xzoom - ladd , xzoom + radd )
729729 axis .set_ylim (yzoom - dadd , yzoom + uadd )
730- misc .saveplot (fig , 'szoom' , timestep , close = False )
731- plt .close (fig )
730+ saveplot (fig , 'szoom' , timestep )
732731
733732 # calculate stresses in the lithosphere
734733 lithospheric_stress (step , trenches , ridges , time )
@@ -759,7 +758,7 @@ def main_plates(sdat):
759758 # Put arrow where ridges and trenches are
760759 plot_plate_limits_field (axis , rcmb , ridges , trenches )
761760
762- misc . saveplot (fig , 'sx' , timestep )
761+ saveplot (fig , 'sx' , timestep )
763762
764763
765764def cmd ():
@@ -814,7 +813,7 @@ def cmd():
814813 plt .hist (sizeplates , 10 , (0 , nphi / 2 ))
815814 plt .subplot (224 )
816815 plt .plot (water_profile )
817- misc . saveplot (fig , 'plates' , step .isnap )
816+ saveplot (fig , 'plates' , step .isnap )
818817
819818 nb_plates .append (len (limits ))
820819
@@ -829,4 +828,4 @@ def cmd():
829828 plt .plot (time , nb_plates )
830829 plt .subplot (122 )
831830 plt .plot (time , ch2o )
832- misc . saveplot (figt , f'plates_{ istart } _{ iend } ' )
831+ saveplot (figt , f'plates_{ istart } _{ iend } ' )
0 commit comments