From 51b35ffb36ccd189e74cb1715c53ef1cbe03ed73 Mon Sep 17 00:00:00 2001 From: Stephane Raynaud Date: Fri, 3 Nov 2017 14:35:03 +0100 Subject: [PATCH] Rename check.py to runcheck and use execfile Huge speedup! --- CHANGES.rst | 21 +++ lib/python/vacumm/misc/file.py | 14 +- scripts/tutorials/Makefile | 4 +- scripts/tutorials/bathy.bathy.gridded.base.py | 8 +- .../tutorials/bathy.bathy.gridded.merging.py | 4 +- scripts/tutorials/bathy.bathy.xyz.base.py | 11 +- .../tutorials/bathy.bathy.xyz.bathybank.py | 7 +- scripts/tutorials/bathy.bathy.xyz.merging.py | 8 +- scripts/tutorials/bathy.shorelines.compare.py | 4 +- .../tutorials/bathy.shorelines.readplot.py | 7 +- .../tutorials/bathy.shorelines.sealevel.py | 3 + scripts/tutorials/check.py | 130 ---------------- scripts/tutorials/data.misc.sigma.py | 3 +- scripts/tutorials/general.scripts.level1.py | 2 +- scripts/tutorials/general.scripts.level2a.py | 5 +- scripts/tutorials/general.scripts.level2b.py | 5 +- scripts/tutorials/general.scripts.level3.py | 3 +- scripts/tutorials/misc.config.argparse.py | 15 +- scripts/tutorials/misc.file.find.py | 16 +- .../misc.grid.masking.erode_coast.py | 1 + scripts/tutorials/misc.grid.masking.lakes.py | 2 +- scripts/tutorials/misc.grid.polygons.py | 7 +- .../misc.grid.regridding.cellerr1d.py | 2 +- .../misc.grid.regridding.conserv1d.py | 2 +- .../misc.grid.regridding.curv2curv.py | 1 + .../tutorials/misc.grid.regridding.fill1d.py | 1 + .../tutorials/misc.grid.regridding.fill2d.py | 3 +- .../tutorials/misc.grid.regridding.grid2xy.py | 8 +- .../misc.grid.regridding.griddata.py | 1 + .../misc.grid.regridding.interp1d.py | 2 +- .../misc.grid.regridding.regrid1dx.py | 2 +- .../misc.grid.regridding.regrid2d.py | 3 +- ...misc.grid.regridding.remap_vs_interp_1d.py | 1 + .../tutorials/misc.grid.regridding.xy2xy.py | 3 +- scripts/tutorials/misc.io.config.py | 1 + scripts/tutorials/misc.io.xyz.py | 7 +- scripts/tutorials/misc.plot.basic.curve.py | 4 +- scripts/tutorials/misc.plot.basic.hov.py | 4 +- scripts/tutorials/misc.plot.basic.map2.py | 2 +- scripts/tutorials/misc.plot.basic.stick.py | 2 +- scripts/tutorials/misc.plot.basic.taylor.py | 6 +- scripts/tutorials/misc.plot.basic.vectors.py | 18 +-- scripts/tutorials/runcheck | 144 ++++++++++++++++++ scripts/tutorials/tide.filters.extrema.py | 4 +- scripts/tutorials/tide.filters.smooth.py | 1 + scripts/tutorials/tide.marigraph.py | 3 +- 46 files changed, 293 insertions(+), 212 deletions(-) delete mode 100755 scripts/tutorials/check.py create mode 100755 scripts/tutorials/runcheck diff --git a/CHANGES.rst b/CHANGES.rst index b5ea4e1..c984829 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,27 @@ Release notes ############# +Version 3.5.0 +============= + +- Added new classes for MesoNh, Symp張onie and WW3 models +- Added cfgui: graphical user interface to ConfigMgr +- Added support for 4D interpolation to grid2xy +- Added linear4dto1dxx +- Add tcompress, bound_ops and haversine to vcmq +- Rename check.py to runcheck +- Fix kinetic_energy: bad indexes +- Fix cfgm merging +- Fix vacumm.misc.file.strfsize +- Fix OceanDataset.get_mld density issue +- Fix missing datetime import for tfind +- Fix ConfigManager warning when default value is not scalar +- Fix fix xml text nodes load +- Fix Logger defaults +- Fix Object class logging funcName +- Fix spherical variogram +- Fix imports in basemap +- Fix cdtime validator in config Version 3.4.1 ============= diff --git a/lib/python/vacumm/misc/file.py b/lib/python/vacumm/misc/file.py index 6416a11..fea55b4 100644 --- a/lib/python/vacumm/misc/file.py +++ b/lib/python/vacumm/misc/file.py @@ -151,9 +151,9 @@ def rollover(filepath, count=1, suffix='.%d', keep=True, verbose=False): def strfsize(size, fmt=None, unit=None, si=False, suffix=True): ''' Format a size in bytes using the appropriate unit multiplicator (Ko, Mo, Kio, Mio) - + :Params: - + * **size**: the size in bytes * **fmt**: @@ -163,15 +163,15 @@ def strfsize(size, fmt=None, unit=None, si=False, suffix=True): use an auto determinated unit if None, or the given one among %s * **si**: whether to use SI (International System) units (10^3, ...) or binary units (2^10, ...) - + :Return: a string ''' - + units_dict = _si_size_units if si else _size_units units = reversed(_sorted_si_size_units if si else _sorted_size_units) unit_suffix = 'o' if si else 'io' size = float(size) - + fmt_unit, fmt_ratio = '', 1 if unit is None: for unit, threshold in units: @@ -183,7 +183,7 @@ def strfsize(size, fmt=None, unit=None, si=False, suffix=True): if unit not in units_dict: raise ValueError('Invalid unit, must be one of: %s'%(_strfsize_doc_sorted_units)) fmt_unit, fmt_ratio = unit, units_dict[unit] - + fmt_size = size / fmt_ratio if fmt is None: fmt = '%(size).3f %(unit)s' if float(fmt_size) % 1 else '%(size)d %(unit)s' @@ -201,7 +201,7 @@ def strpsize(size, si=False): :Params: - **size**: the size string (eg. "1Ko", "1Kio", "2 Mo", " 10 Go" - - **si**: when unit does not ends with 'io' force interpretation as + - **si**: when unit does not ends with 'io' force interpretation as International System units (10^3, ...) instead of binary units (2^10, ...) :Return: the float number of bytes diff --git a/scripts/tutorials/Makefile b/scripts/tutorials/Makefile index 26508bb..0609c27 100644 --- a/scripts/tutorials/Makefile +++ b/scripts/tutorials/Makefile @@ -1,4 +1,4 @@ all: checks -checks: check.py - python check.py +checks: runcheck + python runcheck diff --git a/scripts/tutorials/bathy.bathy.gridded.base.py b/scripts/tutorials/bathy.bathy.gridded.base.py index e24cc92..d883bb8 100644 --- a/scripts/tutorials/bathy.bathy.gridded.base.py +++ b/scripts/tutorials/bathy.bathy.gridded.base.py @@ -1,4 +1,7 @@ # -*- coding: utf8 -*- + +import pylab as P + # Récupération d'une bathy sous la forme d'une variable cdat import cdms2 cdms2.axis.latitude_aliases.append('y') @@ -35,8 +38,8 @@ # Plots from matplotlib import rc ; rc('font', size=9);rc('axes', titlesize=9) -kwplot = dict(resolution=None, show=False, colorbar=False, contour=False, - top=.97, hspace=.25, bottom=.03, right=.98, +kwplot = dict(resolution=None, show=False, colorbar=False, contour=False, + top=.97, hspace=.25, bottom=.03, right=.98, autoresize=False, vmax=bathy_orig.max(), vmin=bathy_orig.min()) # - colormap from vacumm.misc.color import auto_cmap_topo, land @@ -52,3 +55,4 @@ # - sauvegarde from vacumm.misc.plot import savefigs savefigs(__file__) +P.close() diff --git a/scripts/tutorials/bathy.bathy.gridded.merging.py b/scripts/tutorials/bathy.bathy.gridded.merging.py index 1eb7e74..1ef9dd9 100644 --- a/scripts/tutorials/bathy.bathy.gridded.merging.py +++ b/scripts/tutorials/bathy.bathy.gridded.merging.py @@ -1,4 +1,6 @@ # -*- coding: utf8 -*- +import pylab as P + # Création de bathymétries fictives à partir de Smith and Sandwell import cdms2 from vacumm.config import data_sample @@ -44,4 +46,4 @@ add_grid(grid_large, color='r', **kwgrid) add_grid(var_small.getGrid(), color='#00ff00', **kwgrid) savefigs(__file__) - +P.close() diff --git a/scripts/tutorials/bathy.bathy.xyz.base.py b/scripts/tutorials/bathy.bathy.xyz.base.py index c78467c..3fcc6bf 100644 --- a/scripts/tutorials/bathy.bathy.xyz.base.py +++ b/scripts/tutorials/bathy.bathy.xyz.base.py @@ -67,7 +67,7 @@ # Extraction d'une sous-zone (xmin,ymin...) avec marge xyz_up = xyz.clip(zone=(None, None, None, 48.3), margin=2) # - si None, valeurs limites internes (i.e xyz.xmin(), ...) -# - margin : marge relative en unite de resolution +# - margin : marge relative en unite de resolution # -> ici : ymax = 48.3 + xyz.resol()[1]*2 # Sauvegarde @@ -82,10 +82,10 @@ P.figure(figsize=(4.5, 8)) P.rc('font', size=8) P.subplots_adjust(top=.95, hspace=.25, left=.1, bottom=.05, right=.98) -m = map2(lon=(xc-xr, xc+xr), lat=(yc-yr, yc+yr), proj='merc', - subplot=311, autoresize=0, resolution='f', show=False, drawmeridians_rotation=45, +m = map2(lon=(xc-xr, xc+xr), lat=(yc-yr, yc+yr), proj='merc', + subplot=311, autoresize=0, resolution='f', show=False, drawmeridians_rotation=45, ticklabel_size=9, xhide=True) -kwplot = dict(vmin=xyz.get_zmin(False), vmax=xyz.get_zmax(False), +kwplot = dict(vmin=xyz.get_zmin(False), vmax=xyz.get_zmax(False), m=m, show=False, colorbar=False) # - xyz xyz.plot(size=10, mode='both', masked_alpha=.1, **kwplot) @@ -93,6 +93,7 @@ kwplot.update(autoresize=0, ticklabel_size=9) map2(gridded_manual, subplot=312, xhide=True, title='Sur grille manuelle', **kwplot) # - interpole auto -map2(gridded_auto, subplot=313, title='Sur grille auto', savefigs=__file__, **kwplot) +map2(gridded_auto, subplot=313, title='Sur grille auto', savefigs=__file__, + close=True, **kwplot) #P.show() diff --git a/scripts/tutorials/bathy.bathy.xyz.bathybank.py b/scripts/tutorials/bathy.bathy.xyz.bathybank.py index b68bfdd..5626edf 100644 --- a/scripts/tutorials/bathy.bathy.xyz.bathybank.py +++ b/scripts/tutorials/bathy.bathy.xyz.bathybank.py @@ -1,5 +1,5 @@ # Creation de fausses bathymetries xyz -import numpy as N, os +import numpy as N, os, pylab as P from vacumm.bathy.bathy import XYZBathy, XYZBathyBank # - fonction generatrice def gene_bathy(xc, yc, r, n): @@ -44,7 +44,7 @@ def gene_bathy(xc, yc, r, n): # Suppression d'une bathy bank.remove('south') -# on peut aussi utiliser: +# on peut aussi utiliser: # >>> bank -= 'south' # >>> bank -= bsouth # >>> del bank['south'] @@ -53,5 +53,6 @@ def gene_bathy(xc, yc, r, n): bsouth = bank['north'].load() # Plot de l'ensemble -bank.plot(size=15, map_proj='cyl', map_res=None, savefigs=__file__, +bank.plot(size=15, map_proj='cyl', map_res=None, savefigs=__file__, savefigs_pdf=True, show=False) +P.close() diff --git a/scripts/tutorials/bathy.bathy.xyz.merging.py b/scripts/tutorials/bathy.bathy.xyz.merging.py index 57e8445..fe6fa07 100644 --- a/scripts/tutorials/bathy.bathy.xyz.merging.py +++ b/scripts/tutorials/bathy.bathy.xyz.merging.py @@ -24,7 +24,7 @@ def gene_bathy(xc, yc, xr, yr, n=500, amp=30.): import pylab as P ; P.figure(figsize=(5., 8.5)) ; P.subplot(311) P.rcParams['font.size'] = 9 P.subplots_adjust(bottom=.03, top=.97, hspace=.25) -kwplot = dict(show=False, colorbar=False,map_res=None, margin=0., map_autoresize=0, +kwplot = dict(show=False, colorbar=False,map_res=None, margin=0., map_autoresize=0, xmin=xyz.xmin, xmax=xyz.xmax, ymin=xyz.ymin, ymax=xyz.ymax) xyz.plot(title='Fusion directe', **kwplot) @@ -53,13 +53,13 @@ def gene_bathy(xc, yc, xr, yr, n=500, amp=30.): merger.plot(mode='value', title='Merger : valeurs', **kwplot) # - cluster P.subplot(313) -merger.plot(mode='cluster', size=10, title='Merger : cluster', marker='o', +merger.plot(mode='cluster', size=10, title='Merger : cluster', marker='o', legend_loc='upper left', savefigs=__file__, savefigs_pdf=True, **kwplot) - + # On recupere le tout dans un xyz merged_xyz = merger.get_xyz(long_name='Merged') # On peut donc le sauvegarder merged_xyz.save(__file__[:-2]+'merged.xyz') - +P.close() diff --git a/scripts/tutorials/bathy.shorelines.compare.py b/scripts/tutorials/bathy.shorelines.compare.py index af20dae..16a5819 100644 --- a/scripts/tutorials/bathy.shorelines.compare.py +++ b/scripts/tutorials/bathy.shorelines.compare.py @@ -14,9 +14,9 @@ m='auto', show=False) # Fin de plot -from pylab import show, legend, title +from pylab import show, legend, title, close from vacumm.misc.plot import savefigs legend() title("Ushant shorelines") savefigs(__file__, pdf=True) - +close() diff --git a/scripts/tutorials/bathy.shorelines.readplot.py b/scripts/tutorials/bathy.shorelines.readplot.py index fe73b4d..1c72abc 100644 --- a/scripts/tutorials/bathy.shorelines.readplot.py +++ b/scripts/tutorials/bathy.shorelines.readplot.py @@ -4,7 +4,7 @@ from vcmq import code_base_name m = map2(lat=(48.41, 48.49), lon=(-5.15, -5), show=False, - fillcontinents=False, drawcoastlines=False, figsize=(5.5, 4), + fillcontinents=False, drawcoastlines=False, figsize=(5.5, 4), bgcolor=ocean, left=.12, top=.9) # Fichier au 1/25000eme avec selection de la zone de la carte @@ -28,8 +28,9 @@ xx, yy = poly.boundary.transpose() # coordonnees P.fill(xx, yy, alpha=.5, facecolor='g', linewidth=0) # coloriage -# Fin du trace -from pylab import show, title +# Fin du trace +from pylab import show, title, close from vacumm.misc.plot import savefigs title('Trait de cote SHOM/IGN 1/25000') savefigs(code_base_name(ext='png'), pdf=True) +close() diff --git a/scripts/tutorials/bathy.shorelines.sealevel.py b/scripts/tutorials/bathy.shorelines.sealevel.py index 9d9387c..d8fafa8 100644 --- a/scripts/tutorials/bathy.shorelines.sealevel.py +++ b/scripts/tutorials/bathy.shorelines.sealevel.py @@ -1,4 +1,6 @@ # -*- coding: utf8 -*- +import pylab as P + # Definition de la region de travail Bretagne zone = (-6.5, 47.2, -2, 49.05) @@ -11,3 +13,4 @@ # Plot xyz.plot(size=10, savefigs=__file__, show=False)#, savefigs_pdf=True) +P.close() diff --git a/scripts/tutorials/check.py b/scripts/tutorials/check.py deleted file mode 100755 index e66c9a6..0000000 --- a/scripts/tutorials/check.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python -"""This script run all tutorial script to check if they work - -Help: - - check --help -""" - -# Parse arguments -from argparse import ArgumentParser -import sys, os -parser = ArgumentParser( - description="Check the execution of tutorials.\n\n[pattern] defaults to *.py.",) -parser.add_argument('pattern', default='*.py', help='file pattern [%(default)s]', - nargs='*') -parser.add_argument('-e','--exclude', action='append', - help='add a glob pattern to exclude') -parser.add_argument('-l','--loglevel', - choices=['debug', 'info', 'error'], default='info', - help='logging level to console [%(default)s]') -parser.add_argument('-c', '--cfgfile', default='check.cfg', help='configuration file') -args = parser.parse_args() - -# Retreive the list of scripts -include = [] -from glob import glob -# - include -if not isinstance(args.pattern, list): - args.pattern = [args.pattern] -for pat in args.pattern: - include.extend(glob(pat)) -include = [os.path.abspath(fn) for fn in include] -# - exclude -if args.exclude is not None: - exclude = [] - for pat in args.exclude: - exclude.extend(glob(pat)) - exclude = [os.path.abspath(fn) for fn in exclude] + [os.path.abspath(__file__)] - files = [] - for fn in include: - if fn not in exclude: - files.append(fn) -else: - files = include -files.sort() - -# Setup the logger -import logging -logfile = '.'.join([os.path.splitext(__file__)[0], 'log']) -if os.path.exists(logfile): - os.remove(logfile) -logger = logging.getLogger('CHECK') -file = logging.FileHandler(logfile) -file.setFormatter( - logging.Formatter('%(asctime)s: %(name)s [%(levelname)-8s] %(message)s', - '%Y-%m-%d %H:%M')) -console = logging.StreamHandler() -console.setFormatter(logging.Formatter('%(name)s [%(levelname)-8s] %(message)s')) -file.setLevel('DEBUG') -console.setLevel(args.loglevel.upper()) -logger.setLevel('DEBUG') -logger.addHandler(file) -logger.addHandler(console) - -# Configuration: arguments to scripts -from ConfigParser import SafeConfigParser -from vacumm.config import data_sample -import re -cfg = SafeConfigParser() -cfg.read(args.cfgfile) -re_data_sample = re.compile(r'(data_sample\([^\)]+\))', re.I) -def convert_data_samples(argline, split=True): - aargs = re_data_sample.split(argline) - for i, arg in enumerate(aargs): - m = re_data_sample.match(arg) - if m: - arg = eval(arg) - aargs[i] = arg - aargs = ''.join(aargs) - if split: - aargs = aargs.split() - return aargs -def get_args(scriptname, split=True): - if scriptname.endswith('.py'): - scriptname = scriptname[:-3] - scriptname = os.path.basename(scriptname) - if cfg.has_option('args', scriptname): - argline = cfg.get('args', scriptname) - return convert_data_samples(argline, split=split) - - -# Run them all -import subprocess -igood = 0 -ibad = 0 -for script in files: - if os.path.realpath(script)==os.path.realpath(__file__): - logger.debug('%s: %s', os.path.basename(script), 'SKIPPED') - continue - logger.debug('Trying %s...'%os.path.basename(script)) - script = os.path.basename(script) - cmd = ["python", script] + (get_args(script) or []) - logger.debug(' CMD: '+' '.join(cmd)) - try: - out = subprocess.check_output(cmd, stderr=subprocess.STDOUT) - logger.info('%s: %s', script, 'OK') - logger.debug(' OUT: '+out) - igood +=1 - except subprocess.CalledProcessError as e: - logger.error('%s: %s', script, 'FAILED') - logger.debug(' OUT: '+e.output) - ibad +=1 -# out, err = subprocess.Popen(["python", script] + (get_args(script) or []), -# stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() -# script = os.path.basename(script) -# if len(err)==0 or 'Traceback' not in err: -# logger.info('%s: %s', script, 'OK') -# igood +=1 -# else: -# logger.error('%s: %s', script, 'FAILED') -# ibad +=1 -# if len(out): logger.debug(' OUT: '+out) -# if len(err): logger.debug(' ERR: '+err) -gb = [] -if igood: - gb.append('%i OK'%igood) -if ibad: - gb.append('%i FAILED'%ibad) -msg = 'Results (%i checks): %s'%(igood+ibad, ', '.join(gb)) -logger.info(msg) diff --git a/scripts/tutorials/data.misc.sigma.py b/scripts/tutorials/data.misc.sigma.py index 2638dfb..889bfee 100644 --- a/scripts/tutorials/data.misc.sigma.py +++ b/scripts/tutorials/data.misc.sigma.py @@ -46,7 +46,8 @@ # Plot kw = dict(show=False, vmin=10, vmax=14, xhide='auto', add_grid=True, ymax=0) section2(data_in[0, :, 10], yaxis=depths_in[0, :, 10], subplot=211, title='Sigma', **kw) -s = section2(data_out[0, :, 10], subplot=212, title='Z', savefigs=__file__, **kw) +s = section2(data_out[0, :, 10], subplot=212, title='Z', savefigs=__file__, + close=True, **kw) # Sauvegarde outfile = __file__[:-2]+'nc' diff --git a/scripts/tutorials/general.scripts.level1.py b/scripts/tutorials/general.scripts.level1.py index b6a86ab..7533381 100644 --- a/scripts/tutorials/general.scripts.level1.py +++ b/scripts/tutorials/general.scripts.level1.py @@ -32,7 +32,7 @@ print 'plot' map2(mld, proj='merc', figsize=(6, 4), autoresize=0, fill='pcolormesh', contour=False, show=False, - colorbar_shrink=0.7, right=1, savefigs=__file__) + colorbar_shrink=0.7, right=1, savefigs=__file__, close=True) print 'Done' diff --git a/scripts/tutorials/general.scripts.level2a.py b/scripts/tutorials/general.scripts.level2a.py index 314c129..c1521c1 100755 --- a/scripts/tutorials/general.scripts.level2a.py +++ b/scripts/tutorials/general.scripts.level2a.py @@ -17,8 +17,9 @@ mld = mixed_layer_depth(temp, depth, mode='deltatemp') # Plot -map2(mld, proj='merc', figsize=(6, 6), autoresize=0, - colorbar_shrink=0.7, right=1, savefigs=__file__, show=False) +map2(mld, proj='merc', figsize=(6, 6), autoresize=0, + colorbar_shrink=0.7, right=1, savefigs=__file__, show=False, + close=True) print 'Done' diff --git a/scripts/tutorials/general.scripts.level2b.py b/scripts/tutorials/general.scripts.level2b.py index 340ff68..38c1df2 100755 --- a/scripts/tutorials/general.scripts.level2b.py +++ b/scripts/tutorials/general.scripts.level2b.py @@ -12,8 +12,9 @@ mld = ds.get_mld(mode='deltatemp', squeeze=1) # Plot -map2(mld, proj='merc', figsize=(6, 6), autoresize=0, - colorbar_shrink=0.7, right=1, savefigs=__file__, show=False) +map2(mld, proj='merc', figsize=(6, 6), autoresize=0, + colorbar_shrink=0.7, right=1, savefigs=__file__, show=False, + close=True) print 'Done' diff --git a/scripts/tutorials/general.scripts.level3.py b/scripts/tutorials/general.scripts.level3.py index 8c35935..5ba350c 100755 --- a/scripts/tutorials/general.scripts.level3.py +++ b/scripts/tutorials/general.scripts.level3.py @@ -50,6 +50,7 @@ # Plot map2(mld, proj='merc', figsize=(6, 6), autoresize=0, title=options.title, colorbar_shrink=0.7, right=1, - show=options.disp, savefig=options.outputfig, savefig_verbose=True) + show=options.disp, savefig=options.outputfig, savefig_verbose=True, + close=True) diff --git a/scripts/tutorials/misc.config.argparse.py b/scripts/tutorials/misc.config.argparse.py index e310021..31c9439 100755 --- a/scripts/tutorials/misc.config.argparse.py +++ b/scripts/tutorials/misc.config.argparse.py @@ -1,8 +1,18 @@ #!/bin/env python """Sample executable script using config""" +# FORCE COMMANDLINE ARGUMENTS FOR THE EXAMPLE +from vcmq import data_sample, code_file_name +ARGUMENTS = "--var=temp --zoom-lat-min=48 "+data_sample('mars3d.xy.nc') +import sys +sys.argv = sys.argv[:1] + ARGUMENTS.split() + +############################################################################ +############################################################################ +############################################################################ + # Init commandline parser -import sys, os +import os from argparse import ArgumentParser parser = ArgumentParser(description="Script to plot a 2D netcdf variable") parser.add_argument('ncfile', help='input netcdf file') @@ -24,5 +34,6 @@ # - plot from vacumm.misc.plot import map2 long_name = var.long_name -map2(var, title=cfg['title']%locals(), savefigs=__file__, show=False) +map2(var, title=cfg['title']%locals(), savefigs=code_file_name(), show=False, + close=True) diff --git a/scripts/tutorials/misc.file.find.py b/scripts/tutorials/misc.file.find.py index 6574003..1c962e2 100755 --- a/scripts/tutorials/misc.file.find.py +++ b/scripts/tutorials/misc.file.find.py @@ -8,6 +8,7 @@ print 'Changing the working directory to vacumm\'s root directory' print +PWD = os.getcwd() os.chdir(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))) searchdir = '.' fkw = dict(abspath=False) @@ -23,7 +24,8 @@ # Controlling the search depth print 'Searching any file starting with "misc.file." (depth=None):\n' -print ' ','\n '.join(F.find('misc.file.*', searchdir, depth=None, **fkw)) +print ' ','\n '.join(F.find('misc.file.*', searchdir, depth=None, + exclude=('*/build/*', ), **fkw)) print # we've set the depth to None to supress the limit in recursion (which defaults # to 0 meaning 0 levels from the search directory) @@ -37,7 +39,8 @@ # How to exclude print 'Searching any file starting with "misc.file.", excluding "library" and ".svn" directories and "*.rst" files:\n' -print ' ','\n '.join(F.find('*/misc.file.*', searchdir, depth=None, exclude=('*/library/*', '*/.svn/*', '*.rst'), matchall=True, **fkw)) +print ' ','\n '.join(F.find('*/misc.file.*', searchdir, depth=None, + exclude=('*/library/*', '*/.svn/*', '*.rst'), matchall=True, **fkw)) print # by default only file names are evaluated # we've set matchall to True because .svn is part of the whole paths to be evaluated @@ -58,15 +61,17 @@ print 'Showing search results with callbacks:\n' def ondir(e): # we want to limit the outputs of this tutorial... - if '/.svn' not in e: + if '/.svn' not in e and '/.git' not in e and '/build' not in e: print ' + evaluating directory:', e def onfile(e): # we want to limit the outputs of this tutorial... - if '/.svn' not in e and 'misc.file.' in e: + if '/.svn' not in e and 'misc.file.' in e and '/.git' not in e and '/build' not in e: print ' - evaluating file:', e def onmatch(e): print ' * matching entry:', e -F.find('*/misc.file.*', searchdir, depth=None, exclude=('*/library/*', '*/.svn/*', '*.rst'), matchall=True, ondir=ondir, onfile=onfile, onmatch=onmatch, **fkw) +F.find('*/misc.file.*', searchdir, depth=None, + exclude=('*/library/*', '*/.svn/*', '*.rst', '*/.??*', '*/build/*'), + matchall=True, ondir=ondir, onfile=onfile, onmatch=onmatch, **fkw) print # note that ondir and onfile callbacks are called even if the path does not matches @@ -91,3 +96,4 @@ def onmatch(e): # this is not the case here, just an example +os.chdir(PWD) diff --git a/scripts/tutorials/misc.grid.masking.erode_coast.py b/scripts/tutorials/misc.grid.masking.erode_coast.py index 7072ebc..0aa070d 100644 --- a/scripts/tutorials/misc.grid.masking.erode_coast.py +++ b/scripts/tutorials/misc.grid.masking.erode_coast.py @@ -33,6 +33,7 @@ P.pcolormesh(vare.asma()) P.title('With coastal erosion') ; add_key(3, color='w') savefigs(__file__) +P.close() diff --git a/scripts/tutorials/misc.grid.masking.lakes.py b/scripts/tutorials/misc.grid.masking.lakes.py index 19cd512..db3e6ab 100644 --- a/scripts/tutorials/misc.grid.masking.lakes.py +++ b/scripts/tutorials/misc.grid.masking.lakes.py @@ -47,4 +47,4 @@ # Save savefigs(__file__, pdf=True) - +P.close() diff --git a/scripts/tutorials/misc.grid.polygons.py b/scripts/tutorials/misc.grid.polygons.py index 22d3bd1..3d9f6f0 100644 --- a/scripts/tutorials/misc.grid.polygons.py +++ b/scripts/tutorials/misc.grid.polygons.py @@ -12,7 +12,7 @@ # -> 300.0 # - plot grace a 'boundary'='get_coord()' (= pp) import pylab as P -P.fill(poly.boundary[:, 0], poly.boundary[:, 1], +P.fill(poly.boundary[:, 0], poly.boundary[:, 1], facecolor=(.9, .9, .9)) # Points aleatoires et inclusion @@ -30,7 +30,7 @@ # - plot grace a 'boundary' x, y = pt.boundary P.plot([x], [y], 'o'+color) - + # Ligne de points et intersection # - coordonnees xy = N.array([[2., 7., 20., 26.], [2., 2., 28., 28.]]) @@ -45,7 +45,7 @@ for subline in line.intersection(poly): # = poly.intersection(line) xyl = subline.boundary P.plot(xyl[:, 0], xyl[:, 1], '-', color=(0, 1, 0)) - + # Autre polygone # - creation et plot xyp = N.array([[22., 3], [25., 7], [28, 3]]) @@ -60,3 +60,4 @@ from vacumm.misc.plot import savefigs P.axis([0, 30, 0, 30]) savefigs(__file__, pdf=True) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.cellerr1d.py b/scripts/tutorials/misc.grid.regridding.cellerr1d.py index db8bffb..2e63306 100644 --- a/scripts/tutorials/misc.grid.regridding.cellerr1d.py +++ b/scripts/tutorials/misc.grid.regridding.cellerr1d.py @@ -52,5 +52,5 @@ show=False, subplot=212, label='Original') curve2(sph, '-r', err=speh.asma()/2., linewidth=1.5, show=False, key=2, savefigs=__file__, label='Interpolated', legend=True, tight_layout=True, - legend_loc='lower right') + legend_loc='lower right', close=True) diff --git a/scripts/tutorials/misc.grid.regridding.conserv1d.py b/scripts/tutorials/misc.grid.regridding.conserv1d.py index c1e4cd4..ede8750 100644 --- a/scripts/tutorials/misc.grid.regridding.conserv1d.py +++ b/scripts/tutorials/misc.grid.regridding.conserv1d.py @@ -35,4 +35,4 @@ b.figtext('Precipitations', style='italic') bar2(precip2, subplot=212, **kwplot) savefigs(__file__, pdf=True) - +b.close() diff --git a/scripts/tutorials/misc.grid.regridding.curv2curv.py b/scripts/tutorials/misc.grid.regridding.curv2curv.py index d22419f..ddd09ad 100644 --- a/scripts/tutorials/misc.grid.regridding.curv2curv.py +++ b/scripts/tutorials/misc.grid.regridding.curv2curv.py @@ -47,3 +47,4 @@ map2(hs_scripbilin, title=u'SCRIP : bilinéaire', subplot=313, m=m, **kwplot) add_grid(cgridi, lw=.7, alpha=.3) savefigs(__file__) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.fill1d.py b/scripts/tutorials/misc.grid.regridding.fill1d.py index f762c6c..7496f37 100644 --- a/scripts/tutorials/misc.grid.regridding.fill1d.py +++ b/scripts/tutorials/misc.grid.regridding.fill1d.py @@ -29,3 +29,4 @@ curve2(xef, show=False, linewidth=1.5, title='Niveau de la mer') P.legend() savefigs(__file__, pdf=True) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.fill2d.py b/scripts/tutorials/misc.grid.regridding.fill2d.py index 2b3ef4e..19f2cbd 100644 --- a/scripts/tutorials/misc.grid.regridding.fill2d.py +++ b/scripts/tutorials/misc.grid.regridding.fill2d.py @@ -24,6 +24,7 @@ from vacumm.misc.plot import map2 as map, P P.rc('font', size=9) kw = dict(vmin=9, vmax=13) -map(temp, show=False, subplot=211, hspace=.2, bottom=.05, +map(temp, show=False, subplot=211, hspace=.2, bottom=.05, left=.08, top=.97, figsize=(4.5, 8), nmax=10, **kw) map(tempf, show=False, subplot=212, savefigs=code_base_name(ext='png'), **kw) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.grid2xy.py b/scripts/tutorials/misc.grid.regridding.grid2xy.py index 57e5d0b..25df213 100644 --- a/scripts/tutorials/misc.grid.regridding.grid2xy.py +++ b/scripts/tutorials/misc.grid.regridding.grid2xy.py @@ -20,13 +20,13 @@ # Plot # - variable interpolee from vacumm.misc.plot import hov2 as hov, savefigs, map2 as map -hov(vo, cmap='jet', show=False, top=.9, date_fmt='%H', +hov(vo, cmap='jet', show=False, top=.9, date_fmt='%H', colorbar_shrink=.5, left=.13) # - carte + diagonal import pylab as P -m = map(v[0], xhide=True, yhide=True, contour=False, - title=False, autoresize=0, cmap='cmap_bwr', +m = map(v[0], xhide=True, yhide=True, contour=False, + title=False, autoresize=0, cmap='cmap_bwr', colorbar=False, axes_rect=[.78, .78, .2, .2], show=False) m.map.plot(xo, yo, 'r-', lw=2) savefigs(__file__) - +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.griddata.py b/scripts/tutorials/misc.grid.regridding.griddata.py index 7d47872..60382f5 100644 --- a/scripts/tutorials/misc.grid.regridding.griddata.py +++ b/scripts/tutorials/misc.grid.regridding.griddata.py @@ -45,3 +45,4 @@ P.xlim(xrb.min(), xrb.max()) ; P.ylim(yrb.min(), yrb.max()) P.title('Minicargen (err = %02i%%)'%((zzr-zirk).std()*100/stdref)) savefigs(__file__) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.interp1d.py b/scripts/tutorials/misc.grid.regridding.interp1d.py index a527bdf..53e1472 100644 --- a/scripts/tutorials/misc.grid.regridding.interp1d.py +++ b/scripts/tutorials/misc.grid.regridding.interp1d.py @@ -71,4 +71,4 @@ xscale(1.1, keep_min=1) # - save savefigs(__file__) - +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.regrid1dx.py b/scripts/tutorials/misc.grid.regridding.regrid1dx.py index 398776d..6497d3e 100644 --- a/scripts/tutorials/misc.grid.regridding.regrid1dx.py +++ b/scripts/tutorials/misc.grid.regridding.regrid1dx.py @@ -36,4 +36,4 @@ section2(tr, subplot=212, **kwplot) add_grid((tr.getLongitude(), dep[:]), linewidth=.3) savefigs(__file__) - +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.regrid2d.py b/scripts/tutorials/misc.grid.regridding.regrid2d.py index fdb5820..dfb84e7 100644 --- a/scripts/tutorials/misc.grid.regridding.regrid2d.py +++ b/scripts/tutorials/misc.grid.regridding.regrid2d.py @@ -11,4 +11,5 @@ vari = MV2.reshape(MV2.arange(ggi.size(), dtype='f'), ggi.shape) vari.setGrid(ggi) varo = regrid2d(vari, ggo, 'bilinear') -map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__) +map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__, + close=True) diff --git a/scripts/tutorials/misc.grid.regridding.remap_vs_interp_1d.py b/scripts/tutorials/misc.grid.regridding.remap_vs_interp_1d.py index 6118736..ad27e54 100644 --- a/scripts/tutorials/misc.grid.regridding.remap_vs_interp_1d.py +++ b/scripts/tutorials/misc.grid.regridding.remap_vs_interp_1d.py @@ -44,4 +44,5 @@ if not ilh: P.legend(loc='lower left').legendPatch.set_alpha(.6) savefigs(__file__, pdf=True) +P.close() diff --git a/scripts/tutorials/misc.grid.regridding.xy2xy.py b/scripts/tutorials/misc.grid.regridding.xy2xy.py index 11d6531..06c8ac9 100644 --- a/scripts/tutorials/misc.grid.regridding.xy2xy.py +++ b/scripts/tutorials/misc.grid.regridding.xy2xy.py @@ -19,7 +19,7 @@ # Plots import pylab as P from vacumm.misc.plot import savefigs -P.figure(figsize=(5, 7)) +P.figure(figsize=(5, 7)) P.subplot(211) P.title('Original') P.scatter(xi, yi, c=zi, s=50, vmin=zi.min(), vmax=zi.max()) @@ -32,3 +32,4 @@ P.legend().legendPatch.set_alpha(.5) P.axis(axlims) savefigs(__file__, pdf=True) +P.close() diff --git a/scripts/tutorials/misc.io.config.py b/scripts/tutorials/misc.io.config.py index 8bd29b9..a4dbb79 100644 --- a/scripts/tutorials/misc.io.config.py +++ b/scripts/tutorials/misc.io.config.py @@ -2,6 +2,7 @@ # On charge le fichier from ConfigParser import SafeConfigParser config = SafeConfigParser() +import os;print os.getcwd() config.read('misc.io.config.in.ini') # List des sections diff --git a/scripts/tutorials/misc.io.xyz.py b/scripts/tutorials/misc.io.xyz.py index b995387..3d21db4 100644 --- a/scripts/tutorials/misc.io.xyz.py +++ b/scripts/tutorials/misc.io.xyz.py @@ -24,14 +24,15 @@ P.figure(figsize=(5.5, 8)) P.subplots_adjust(left=.12, top=.96, right=1, bottom=.06) P.subplot(211) -xyz.plot(title='Mer celtique', units='m', m=True, - show=False, size=2, cmap='cmap_bathy') +xyz.plot(title='Mer celtique', units='m', m=True, + show=False, size=2, cmap='cmap_bathy') # Zoom xyz_zoom = xyz.clip((-6, 51.5, -4, 52.5), long_name='Zoom') P.subplot(212) -xyz_zoom.plot(m=True, savefigs=__file__, size=7, +xyz_zoom.plot(m=True, savefigs=__file__, size=7, show=False, cmap='cmap_bathy') +P.close() # Sauvegarde xyz_zoom.save('zoom.xyz') diff --git a/scripts/tutorials/misc.plot.basic.curve.py b/scripts/tutorials/misc.plot.basic.curve.py index d77c5ca..1631313 100644 --- a/scripts/tutorials/misc.plot.basic.curve.py +++ b/scripts/tutorials/misc.plot.basic.curve.py @@ -18,8 +18,8 @@ zsst = cdms2.MV2.average(f('temp'), axis=0) f.close() # - plot -curve2(zsst, title=u'SST zonale', color='r', show=False, - subplot=212,top=.9,hspace=.4,left=.15,bottom=.07, +curve2(zsst, title=u'SST zonale', color='r', show=False, close=True, + subplot=212,top=.9,hspace=.4,left=.15,bottom=.07, savefigs=__file__) diff --git a/scripts/tutorials/misc.plot.basic.hov.py b/scripts/tutorials/misc.plot.basic.hov.py index 2e57070..d8ea2c4 100644 --- a/scripts/tutorials/misc.plot.basic.hov.py +++ b/scripts/tutorials/misc.plot.basic.hov.py @@ -11,7 +11,7 @@ from vacumm.misc.plot import hov2 import vacumm.misc.plot print vacumm.misc.plot -h = hov2(xe, fmt='%.1f', left=.15, right=.98, linewidths=1.5, - clabel_glow=2, nmax=20, figsize=(6, 6), +h = hov2(xe, fmt='%.1f', left=.15, right=.98, linewidths=1.5, + clabel_glow=2, nmax=20, figsize=(6, 6), close=True, fill='contour', show=False, savefigs=__file__, savefigs_pdf=True) diff --git a/scripts/tutorials/misc.plot.basic.map2.py b/scripts/tutorials/misc.plot.basic.map2.py index 960eff9..96484c9 100644 --- a/scripts/tutorials/misc.plot.basic.map2.py +++ b/scripts/tutorials/misc.plot.basic.map2.py @@ -10,4 +10,4 @@ m = map(sst, title='SST in the Iroise Sea', linewidth=.7, fill='pcolormesh', cmap='cmocean_thermal', clabel=True, vmin=9, top=.9, figsize=(6, 5), clabel_glow=True, clabel_glow_alpha=.4, - colorbar_shrink=.8, show=False, savefigs=__file__) + colorbar_shrink=.8, show=False, savefigs=__file__, close=True) diff --git a/scripts/tutorials/misc.plot.basic.stick.py b/scripts/tutorials/misc.plot.basic.stick.py index 6f31d24..821322c 100644 --- a/scripts/tutorials/misc.plot.basic.stick.py +++ b/scripts/tutorials/misc.plot.basic.stick.py @@ -11,7 +11,7 @@ # Plot stick2(u, v, title='Current in the Iroise Sea', units='m/s', - bottom=.2, top=.85, quiver_headwidth=2, + bottom=.2, top=.85, quiver_headwidth=2, close=True, quiverkey_value=.5, quiver_width=0.002, quiver_scale=5., savefigs=__file__, figsize=(5.5, 3), show=False) diff --git a/scripts/tutorials/misc.plot.basic.taylor.py b/scripts/tutorials/misc.plot.basic.taylor.py index 6fcbb9a..f2b506d 100644 --- a/scripts/tutorials/misc.plot.basic.taylor.py +++ b/scripts/tutorials/misc.plot.basic.taylor.py @@ -12,7 +12,7 @@ # Plot from vacumm.misc.plot import taylor -taylor([model1, model2], ref, figsize=(8, 8), label_size='large', size=15, - labels = ['Good model', None], colors='cyan', title_size=18, - savefigs=__file__, savefigs_pdf=True, show=False) +taylor([model1, model2], ref, figsize=(8, 8), label_size='large', size=15, + labels = ['Good model', None], colors='cyan', title_size=18, + savefigs=__file__, savefigs_pdf=True, show=False, close=True) diff --git a/scripts/tutorials/misc.plot.basic.vectors.py b/scripts/tutorials/misc.plot.basic.vectors.py index 99e4bad..6e8a6e8 100644 --- a/scripts/tutorials/misc.plot.basic.vectors.py +++ b/scripts/tutorials/misc.plot.basic.vectors.py @@ -3,8 +3,8 @@ from vacumm.config import data_sample zoom = dict(lat=(48.3, 48.55), lon=(-5.2, -4.8)) f = cdms2.open(data_sample('mars3d.xy.nc')) -u = f('u', **zoom) -v = f('v', **zoom) +u = f('u', **zoom) +v = f('v', **zoom) f.close() for var in u, v: var[:]*100. @@ -13,11 +13,11 @@ # Trace des vecteurs from vacumm.misc.plot import map2 import pylab as P ; P.rc('font', size=9) -map2((u, v), title='Vitesses en surface', show=False, - units='$cm s^{-1}$', figsize=(6, 5.), - quiver_alpha=.5, quiver_samp=2, - quiver_scale=15, quiver_width=0.006, #quiver_headaxislength=2, - quiverkey_value = 2., nofill=True, - left=.08, right=1., top=.9, proj='merc', quiver_norm=1, - savefigs=__file__, savefigs_pdf=True,) +map2((u, v), title='Vitesses en surface', show=False, + units='$cm s^{-1}$', figsize=(6, 5.), + quiver_alpha=.5, quiver_samp=2, + quiver_scale=15, quiver_width=0.006, #quiver_headaxislength=2, + quiverkey_value = 2., nofill=True, + left=.08, right=1., top=.9, proj='merc', quiver_norm=1, + savefigs=__file__, savefigs_pdf=True, close=True) diff --git a/scripts/tutorials/runcheck b/scripts/tutorials/runcheck new file mode 100755 index 0000000..a79b8fe --- /dev/null +++ b/scripts/tutorials/runcheck @@ -0,0 +1,144 @@ +#!/usr/bin/env python +"""This script run all tutorial script to check if they work + +Help: + + check --help +""" + +# Parse arguments +from argparse import ArgumentParser +import sys, os +from time import time as _time_ +parser = ArgumentParser( + description="Check the execution of tutorials.\n\n[pattern] defaults to *.py.",) +parser.add_argument('pattern', default='*.py', help='file pattern [%(default)s]', + nargs='*') +parser.add_argument('-e', '--exclude', action='append', + help='add a glob pattern to exclude') +parser.add_argument('-l', '--loglevel', + choices=['debug', 'info', 'error'], default='info', + help='logging level to console [%(default)s]') +parser.add_argument('-c', '--cfgfile', default='check.cfg', help='configuration file') +args = parser.parse_args() + +# Retreive the list of scripts +include = [] +from glob import glob +# - include +if not isinstance(args.pattern, list): + args.pattern = [args.pattern] +for pat in args.pattern: + include.extend(glob(pat)) +include = [os.path.abspath(fn) for fn in include] +# - exclude +if args.exclude is None: + args.exclude = ['check.py'] +if args.exclude is not None: + exclude = [] + for pat in args.exclude: + exclude.extend(glob(pat)) + exclude = [os.path.abspath(fn) for fn in exclude] + [os.path.abspath(__file__)] + files = [] + for fn in include: + if fn not in exclude: + files.append(fn) +else: + files = include +files.sort() + +# Setup the logger +import logging +logfile = '.'.join([os.path.splitext(__file__)[0], 'log']) +if os.path.exists(logfile): + os.remove(logfile) +logger = logging.getLogger('RUNCHECK') +file = logging.FileHandler(logfile) +file.setFormatter( + logging.Formatter('%(asctime)s: %(name)s [%(levelname)-8s] %(message)s', + '%Y-%m-%d %H:%M')) +console = logging.StreamHandler() +console.setFormatter(logging.Formatter('%(name)s [%(levelname)-8s] %(message)s')) +file.setLevel('DEBUG') +console.setLevel(args.loglevel.upper()) +logger.setLevel('DEBUG') +logger.addHandler(file) +logger.addHandler(console) + +# Warnings +import warnings, matplotlib, numpy +warnings.simplefilter('ignore', matplotlib.cbook.MatplotlibDeprecationWarning) +warnings.simplefilter('ignore', numpy.VisibleDeprecationWarning) +warnings.simplefilter('ignore', numpy.ma.core.MaskedArrayFutureWarning) +warnings.filterwarnings('ignore', r'converting a masked element to nan.*') +warnings.filterwarnings('ignore', r'comparison to `None` will result.*') + +# Redirections +class Redirector(object): + def __init__(self, func, prefix=''): + self.func = func + self.prefix = prefix + def write(self, buf): + self.func(self.prefix+buf.rstrip().strip('\n')) + def flush(self): + pass +class Warner(object): + def __init__(self, logger): + self.logger = logger + def showwarning(self, message, category, filename, lineno, + file=None): + self.logger.warning( + 'REDIRECTED: %s:%s: %s:%s', + filename, lineno, + category.__name__, message, + ) +#old_sys_stdout = sys.stdout +#old_sys_stderr = sys.stderr +#old_showwarnings = warnings.showwarning +sys.stdout = Redirector(logger.debug, 'STDOUT: ') +sys.stderr = Redirector(logger.warning, 'STDERR: ') +warnings.showwarning = Warner(logger).showwarning + + +# Run them all +import subprocess, traceback +igood = 0 +ibad = 0 +PWD = os.getcwd() +for script in files: + base_script = os.path.basename(script) + if os.path.realpath(script)==os.path.realpath(__file__): + logger.debug('{}: {}'.format(base_script, 'SKIPPED')) + continue + if os.getcwd()!=PWD: + xxx + os.chdir(PWD) + sys.argv = [script] + logger.debug('Trying {}...'.format(base_script)) + t0_ = _time_() +# execfile(script, {'__file__':script}) + try: + execfile(script, {'__file__':script}) + igood +=1 + result = 'OK' + report_func = logger.info + except: + ibad +=1 + logger.debug(traceback.format_exc()) + result = 'FAILED' + report_func = logger.error + report_func('{}: {} [{:.1f}s]'.format(base_script, result, _time_()-t0_)) + +# Finalize +gb = [] +if igood: + gb.append('%i OK'%igood) +if ibad: + gb.append('%i FAILED'%ibad) +msg = 'Results (%i checks): %s'%(igood+ibad, ', '.join(gb)) +logger.info(msg) + +## Clean redirections +#sys.stdout = old_sys_stdout +#sys.stderr = old_sys_stderr +#warnings.showwarning = old_showwarnings diff --git a/scripts/tutorials/tide.filters.extrema.py b/scripts/tutorials/tide.filters.extrema.py index ae0db92..86c1323 100644 --- a/scripts/tutorials/tide.filters.extrema.py +++ b/scripts/tutorials/tide.filters.extrema.py @@ -16,5 +16,5 @@ curve(sea_level, 'ko', markersize=3, figsize=(6, 4), show=False) curve(zz, 'go', linewidth=0, show=False, xstrict=False) curve(pm, 'ro', linewidth=0, show=False, xstrict=False) -curve(bm, 'bo', linewidth=0, xstrict=False, title="Niveau de la mer", - savefigs=__file__, savefigs_pdf=True, show=False) +curve(bm, 'bo', linewidth=0, xstrict=False, title="Niveau de la mer", + savefigs=__file__, savefigs_pdf=True, show=False, close=True) diff --git a/scripts/tutorials/tide.filters.smooth.py b/scripts/tutorials/tide.filters.smooth.py index efc0665..0e3d796 100644 --- a/scripts/tutorials/tide.filters.smooth.py +++ b/scripts/tutorials/tide.filters.smooth.py @@ -19,3 +19,4 @@ curve2(cotes, 'r', subplot=212, hspace=.3, label='Demerliac', **kwplot) P.legend().legendPatch.set_alpha(.7) savefigs(__file__, savefigs_pdf=True) +P.close() diff --git a/scripts/tutorials/tide.marigraph.py b/scripts/tutorials/tide.marigraph.py index 2ab0bc2..252f6ce 100644 --- a/scripts/tutorials/tide.marigraph.py +++ b/scripts/tutorials/tide.marigraph.py @@ -20,7 +20,7 @@ cotes = mg.cotes() # Calcul des pleines et basses mers -ref = 'mean' +ref = 'mean' highs = mg.highs(ref=ref) lows = mg.lows(ref=ref) zeros = mg.zeros(ref=ref) @@ -36,3 +36,4 @@ # - seules les surcotes decotes P.subplot(212) mg.plot('cotes', savefigs=__file__, savefigs_pdf=True, title='Surcotes et decotes', **kwplot) +P.close()