Skip to content

Commit

Permalink
Merge pull request #219 from rigoudyg/V2.0.2_fix_small_issues
Browse files Browse the repository at this point in the history
V2.0.2 fix small issues
  • Loading branch information
rigoudyg authored Nov 17, 2021
2 parents e52d65f + 7c9d228 commit d835f49
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
13 changes: 11 additions & 2 deletions climaf/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ def __init__(self, **kwargs):
Some attributes have a special format or processing :
- period : see :py:func:`~climaf.period.init_period`
- period : see :py:func:`~climaf.period.init_period`. See also
function :py:func:`climaf.classes.ds` for added
flexibility in defining periods as last of first set of years
among available data
- domain : allowed values are either 'global' or a list for
latlon corners ordered as in : [ latmin, latmax, lonmin,
Expand Down Expand Up @@ -781,20 +784,26 @@ def baseFiles(self, force=False, ensure_dataset=True):
for the dataset
Use cached value (i.e. attribute 'files') unless called with arg force=True
If ensure_dataset is True, forbid ambiguous datasets
"""
if (force and self.project != 'file') or self.files is None:
if ensure_dataset:
self.explore()
else:
self.explore(option='choices')
cases = self.explore(option='choices')
list_keys = [ k for k in cases if type(cases[k]) is list and k != 'period' ]
if len(list_keys) > 0:
clogger.error("The dataset is ambiguous on %s; its CRS is %s"%(cases,self))
return None
return self.files

def listfiles(self, force=False, ensure_dataset=True):
""" Returns the list of (local or remote) files which include the data
for the dataset
Use cached value unless called with arg force=True
If ensure_dataset is True, forbid ambiguous datasets
"""
return self.baseFiles(force=force, ensure_dataset=ensure_dataset)
Expand Down
2 changes: 1 addition & 1 deletion climaf/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def fadd(dat1, dat2):

def fsub(dat1, dat2):
"""
Substraction of two CliMAF object, or multiplication of the CliMAF object given as first argument
Substraction of two CliMAF object, or substraction of the CliMAF object given as first argument
and a constant as second argument (string, float or integer)
Shortcut to ccdo(dat,operator='subc,'+str(c)) and ccdo2(dat1,dat2,operator='sub')
Expand Down
10 changes: 5 additions & 5 deletions climaf/projects/em.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@

# User simulations
pathg = "${root}/${group}/${simulation}/"
pathA = pathg + "${realm}/${simulation}PLYYYY.nc" # GSAG
pathL = pathg + "${realm}/${simulation}SFXYYYY.nc"
pathI = pathg + "${realm}/${variable}_O1_YYYY-YYYY.nc" # HISTNATr8
pathA = pathg + "${realm}/${simulation}PL${PERIOD}.nc" # GSAG
pathL = pathg + "${realm}/${simulation}SFX${PERIOD}.nc"
pathI = pathg + "${realm}/${variable}_O1_${PERIOD}-${PERIOD}.nc" # HISTNATr8
pathO = pathg + "${realm}/${simulation}_1${frequency}_${PERIOD}_grid_${variable}.nc" # var:T_table2.2
pathO2 = pathg + "${realm}/${simulation}_1${frequency}_${PERIOD}_scalar_table2.2.nc" # PICTLWS2, PRE6CPLCr2alb

dataloc(project="em", organization="generic", url=[pathA, pathL, pathI, pathO, pathO2])

# Shared simulations - example : group=SC
pathg = "/cnrm/cmip/cnrm/simulations/${group}/"
pathgA = pathg + "${realm}/Regu/${frequency}/${simulation}/${simulation}PLYYYY.nc" # C1P60
pathgL = pathg + "${realm}/Regu/${frequency}/${simulation}/${simulation}SFXYYYY.nc" # C1P60
pathgA = pathg + "${realm}/Regu/${frequency}/${simulation}/${simulation}PL${PERIOD}.nc" # C1P60
pathgL = pathg + "${realm}/Regu/${frequency}/${simulation}/${simulation}SFX${PERIOD}.nc" # C1P60
pathgI = pathg + "${realm}/Origin/Monthly/${simulation}/${variable}_O1_${PERIOD}.nc" # HISTNATr8
pathgO = pathg + "${realm}/Origin/Monthly/${simulation}/${simulation}_1${frequency}_${PERIOD}_grid_${variable}.nc"

Expand Down
4 changes: 2 additions & 2 deletions climaf/projects/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
cproject("example", ("frequency", "monthly"), separator='|')
cfreqs('example', {'monthly': 'mon'})

data_pattern_L = cpath + "/../examples/data/${simulation}/L/${simulation}SFXYYYY.nc"
data_pattern_A = cpath + "/../examples/data/${simulation}/A/${simulation}PLYYYY.nc"
data_pattern_L = cpath + "/../examples/data/${simulation}/L/${simulation}SFX${PERIOD}.nc"
data_pattern_A = cpath + "/../examples/data/${simulation}/A/${simulation}PL${PERIOD}.nc"
data_pattern_histmth = cpath + "/../examples/data/${simulation}_SE_1982_1991_1M_ua_pres.nc"
dataloc(project="example", organization="generic", url=[data_pattern_A, data_pattern_L, data_pattern_histmth])

Expand Down
1 change: 0 additions & 1 deletion climaf/projects/ref_climatos_and_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@
calias(project='ref_ts', variable='moc', fileVariable='stream_function_mar', filenameVar='moc')

if root:
# pattern1=root+"ts/*/${frequency}/${variable}/${variable}_*mon_${product}*_YYYYMM-YYYYMM.nc"
pattern1 = root + "ts/*/${frequency}/${variable}/${variable}_${table}_${product}_${obs_type}_${PERIOD}.nc"
dataloc(project='ref_ts', organization='generic', url=[pattern1])
5 changes: 5 additions & 0 deletions doc/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ What's new

Changes, newest first:

- V2.0.2:

- Fix `issue 193<https://github.com/rigoudyg/climaf/issues/193>` regarding behaviour of listfiles
for ambiguous cases

- V2.0.1:

- **Scripts can now process multiple ensembles, and ensembles which are not the first argument**:
Expand Down
2 changes: 1 addition & 1 deletion doc/scripts/ccdo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ccdo : |sk| invoke CDO with a unary operator

Apply CDO on a single dataset or object, with a CDO operator as argument

**References** : https://code.zmaw.de/projects/cdo/embedded/1.6.4/cdo.html
**References** : https://code.zmaw.de/projects/cdo/embedded/index.html

**Provider / contact** : climaf at meteo dot fr

Expand Down

0 comments on commit d835f49

Please sign in to comment.