Skip to content

Commit

Permalink
Rename check.py to runcheck and use execfile
Browse files Browse the repository at this point in the history
Huge speedup!
  • Loading branch information
stefraynaud committed Nov 3, 2017
1 parent d496186 commit 51b35ff
Show file tree
Hide file tree
Showing 46 changed files with 293 additions and 212 deletions.
21 changes: 21 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
=============
Expand Down
14 changes: 7 additions & 7 deletions lib/python/vacumm/misc/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Expand All @@ -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:
Expand All @@ -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'
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/tutorials/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
all: checks

checks: check.py
python check.py
checks: runcheck
python runcheck
8 changes: 6 additions & 2 deletions scripts/tutorials/bathy.bathy.gridded.base.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -52,3 +55,4 @@
# - sauvegarde
from vacumm.misc.plot import savefigs
savefigs(__file__)
P.close()
4 changes: 3 additions & 1 deletion scripts/tutorials/bathy.bathy.gridded.merging.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -44,4 +46,4 @@
add_grid(grid_large, color='r', **kwgrid)
add_grid(var_small.getGrid(), color='#00ff00', **kwgrid)
savefigs(__file__)

P.close()
11 changes: 6 additions & 5 deletions scripts/tutorials/bathy.bathy.xyz.base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -82,17 +82,18 @@
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)
# - interpole manuellement
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()

7 changes: 4 additions & 3 deletions scripts/tutorials/bathy.bathy.xyz.bathybank.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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']
Expand All @@ -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()
8 changes: 4 additions & 4 deletions scripts/tutorials/bathy.bathy.xyz.merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()

4 changes: 2 additions & 2 deletions scripts/tutorials/bathy.shorelines.compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 4 additions & 3 deletions scripts/tutorials/bathy.shorelines.readplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
3 changes: 3 additions & 0 deletions scripts/tutorials/bathy.shorelines.sealevel.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -11,3 +13,4 @@

# Plot
xyz.plot(size=10, savefigs=__file__, show=False)#, savefigs_pdf=True)
P.close()
130 changes: 0 additions & 130 deletions scripts/tutorials/check.py

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/tutorials/data.misc.sigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion scripts/tutorials/general.scripts.level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Loading

0 comments on commit 51b35ff

Please sign in to comment.