Skip to content

Commit 4d42ceb

Browse files
authored
Merge pull request #162 from rigoudyg/V1.2.13
Finalize new version.
2 parents 00d3391 + dd5cf26 commit 4d42ceb

File tree

226 files changed

+87208
-13619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+87208
-13619
lines changed

bin/climaf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ fi
1717

1818
if [ "$*" ] ; then
1919
if [ -f "$1" ] ; then
20-
(echo 'from climaf.api import *'; cat $*) | python
20+
(echo 'from climaf.api import *'; cat $*) | python2
2121
else
22-
echo -e 'from climaf.api import *\n'$* | python 2> climaf.stderr
22+
echo -e 'from climaf.api import *\n'$* | python2 2> climaf.stderr
2323
rep=$?
2424
[ $rep -ne 0 ] && cat climaf.stderr >&2
2525
rm climaf.stderr
2626
exit $rep
2727
fi
2828
else
2929
# Interactive session (or read stdin)
30-
if [ ! -d /cnrm ] ; then
30+
if [ ! -d /cnrm ] && [ "$EMACS" != t ]; then
3131
# Can use ipython
3232
ipython -i -c 'from climaf.api import *'
3333
else
3434
# ipython at CNRM for now implies Python3, which is notcompatible with CliMAF
35-
python -i -c 'from climaf.api import *'
35+
python2 -i -c 'from climaf.api import *'
3636
fi
3737
fi
3838

bin/climaf-notebook

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
myport=$( grep $USER /ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V1.2.13/bin/cmip6.notebook.txt | awk '{print $2 }' )
3+
4+
SHORT_HOST="$(hostname -s)"
5+
echo
6+
case $SHORT_HOST in
7+
ciclad-ng|ciclad2|loholt*|camelot)
8+
echo -e "\033[1;31mplease do not run this on login node $SHORT_HOST use:\033[m"
9+
echo -e "First, submit an interactive session then load module and run notebook:"
10+
echo -e "\033[1;31mYou could cut and past the 3 command line under:\033[m"
11+
echo -e "qsub -IVX -l mem=9g,vmem=9g,walltime=06:00:00"
12+
echo -e "module load climaf"
13+
echo -e "climaf-notebook"
14+
exit 1 ;;
15+
ciclad*) SSH_TUNNEL="ssh -L ${myport}:${SHORT_HOST}:${myport} ${USER}@ciclad2.ipsl.jussieu.fr" ;;
16+
merlin*) SSH_TUNNEL="ssh -L ${myport}:${SHORT_HOST}:${myport} ${USER}@loholt2.ipsl.polytechnique.fr" ;;
17+
esac
18+
if netstat -at | grep -w $myport > /dev/null
19+
then
20+
echo "You already have a climaf-notebook running"
21+
echo "only one per user could be running"
22+
lsof|grep "$myport (LISTEN)"
23+
exit 1
24+
fi
25+
echo
26+
echo -e "\033[1;31m FIRST STEP: Open your port \033[m"
27+
echo " - open a terminal on your computer (!! not on Ciclad, Loholt, Cerbere, Idefix... on your local machine)"
28+
echo " - and connect to the Mesocenter with this blue command: "
29+
echo -e "\033[1;34m $SSH_TUNNEL \033[m"
30+
echo
31+
echo -e "\033[1;31m And keep this terminal open until the end of your jupyter session. \033[m"
32+
echo
33+
#echo -e "\033[1;31mCOMMAND 2 IN THE URL PRODUCED BY NOTEBOOK, YOU HAVE TO REPLACE \033[m$SHORT_HOST\033[1;31m BY \033[mlocalhost"
34+
#echo -e "\033[1;31m BEFORE PASTING IN YOUR LOCAL LAPTOP OR WORKSTATION BROWSER (firefox,chrome ...)\033[m"
35+
if [ ! "analyse_env_2.7"="$CONDA_DEFAULT_ENV" ]
36+
then
37+
source activate analyse_env_2.7
38+
fi
39+
echo
40+
echo -e "\033[1;31m SECOND STEP: \033[m"
41+
echo " - in the url below (returned by Jupyter), replace --> $SHORT_HOST with --> localhost"
42+
echo " - and paste in a browser on your computer (Chrome, Firefox...)"
43+
echo " # Example: this is what Jupyter should typically return:"
44+
echo " http://ciclad17:7144/?token=fa3b97e0ecf84afa9954da15056e9c6aef8bf6353e64ba81&token=fa3b97e0ecf84afa9954da15056e9c6aef8bf6353e64ba81"
45+
echo " # And this is what you should copy and paste in your local browser:"
46+
echo " http://localhost:7144/?token=fa3b97e0ecf84afa9954da15056e9c6aef8bf6353e64ba81&token=fa3b97e0ecf84afa9954da15056e9c6aef8bf6353e64ba81"
47+
echo
48+
echo -e "\033[1;31m Have fun! \033[m"
49+
echo
50+
echo -e "\033[1;31m (wait until Jupyter returns the url... it might take some seconds...) \033[m"
51+
52+
jupyter notebook --no-browser --port=${myport} --ip=$SHORT_HOST
53+
# dommage ca marche pas 2>&1 |sed -e 's/$SHORT_HOST/localhost/'

bin/cmip6.notebook.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,11 @@ jllod 7223
124124
ledel 7224
125125
jypmce 7225
126126
gevin 7226
127+
mlalande 7227
128+
mbeaudor 7228
129+
jharle 7229
130+
loruba 7230
131+
jbeaumet 7231
132+
cjlmd 7232
133+
cjunquas 7233
134+
fpalliser 7234

climaf/__init__.py

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
"""
44
Climaf is documented at ReadTheDocs : http://climaf.readthedocs.org/
@@ -11,11 +11,11 @@
1111

1212
# Created : S.Sénési - 2014
1313

14-
__all__ = ["site_settings", "cache", "classes", "clogging", "dataloc", "driver", "netcdfbasics",
14+
__all__ = ["cache", "classes", "dataloc", "driver", "netcdfbasics",
1515
"operators", "period", "standard_operators", "cmacro", "html", "functions", "plot",
1616
"projects", "derived_variables"]
1717

18-
version = "1.2.12"
18+
version = "1.2.13"
1919

2020

2121
def tim(string=None):
@@ -52,52 +52,89 @@ def tim(string=None):
5252

5353
tim("atexit")
5454
#
55-
import clogging
56-
import site_settings
55+
import env.clogging as clogging
56+
import env.site_settings as site_settings
5757
import cache
5858
import standard_operators
5959
import cmacro
6060
import operators
6161
import subprocess
6262
import commands
63-
63+
64+
6465
def my_which(soft):
65-
p = subprocess.Popen(["which",soft], stdout=subprocess.PIPE)
66-
return str.replace(p.stdout.readlines()[0],'\n','')
66+
p = subprocess.Popen(["which", soft], stdout=subprocess.PIPE)
67+
return str.replace(p.stdout.readlines()[0], '\n', '')
68+
69+
6770
def bash_command_to_str(cmd):
68-
return str.replace(subprocess.Popen(str.split(cmd,' '), stdout=subprocess.PIPE).stdout.readlines()[0],'\n','')
71+
return str.replace(subprocess.Popen(str.split(cmd, ' '), stdout=subprocess.PIPE).stdout.readlines()[0], '\n',
72+
'')
73+
6974

7075
tim("imports")
7176
print("CliMAF version = " + version, file=sys.stderr)
7277
print("CliMAF install => " + "/".join(__file__.split("/")[:-2]))
73-
print("python => "+my_which('python'))
74-
print("---")
75-
print("Required softwares to run CliMAF => you are using the following versions/installations:")
76-
try:
77-
print("ncl "+commands.getoutput(my_which('ncl')+' -V')+" => "+my_which('ncl'))
78-
except:
79-
print("Warning: ncl not found -> can't use CliMAF plotting scripts")
80-
try:
81-
tmp = str.split(commands.getstatusoutput(my_which('cdo')+' -V')[1],' ')
82-
print("cdo "+tmp[tmp.index('version')+1]+" => "+my_which('cdo'))
83-
except:
84-
print("Error: cdo not found -> CDO is mandatory to run CliMAF")
85-
my_which('cdo')
86-
try:
87-
tmp = str.split(commands.getstatusoutput(my_which('ncks')+' --version')[1], ' ')
88-
print("nco (ncks) "+tmp[tmp.index('version')+1]+" => "+my_which('ncks'))
89-
except:
90-
print("Warning: nco not found -> can't use nco from CliMAF")
91-
try:
92-
if site_settings.atTGCC or site_settings.atIPSL or site_settings.onCiclad:
93-
print("ncdump "+commands.getstatusoutput('/prodigfs/ipslfs/dods/jservon/miniconda/envs/cesmep_env/bin/ncdump')[-1].split('\n')[-1].split()[3]+" => "+my_which('ncdump'))
94-
else:
95-
binary_info = commands.getstatusoutput(my_which("ncdump") + " --version")[-1].split("\n")[-1]
96-
binary_info = binary_info.split("version")[-1].split("of")[0].strip()
97-
print("ncdump "+binary_info+" => "+my_which('ncdump'))
98-
except:
99-
print("Warning: ncdump not found -> can't use ncdump from CliMAF")
100-
print("---")
78+
if os.environ.get('CLIMAF_CHECK_DEPENDENCIES', "yes") == "yes" :
79+
print("python => " + my_which('python'))
80+
print("---")
81+
print("Required softwares to run CliMAF => you are using the following versions/installations:")
82+
try:
83+
print("ncl " + commands.getoutput(my_which('ncl') + ' -V') + " => " + my_which('ncl'))
84+
except:
85+
print("Warning: ncl not found -> can't use CliMAF plotting scripts")
86+
try:
87+
tmp = str.split(commands.getstatusoutput(my_which('cdo') + ' -V')[1], ' ')
88+
print("cdo " + tmp[tmp.index('version') + 1] + " => " + my_which('cdo'))
89+
except:
90+
print("Error: cdo not found -> CDO is mandatory to run CliMAF")
91+
try:
92+
tmp = str.split(commands.getstatusoutput(my_which('ncks') + ' --version')[1], ' ')
93+
print("nco (ncks) " + tmp[tmp.index('version') + 1] + " => " + my_which('ncks'))
94+
except:
95+
print("Warning: nco not found -> can't use nco from CliMAF")
96+
try:
97+
if site_settings.atTGCC or site_settings.atIPSL or site_settings.onCiclad:
98+
ncdump_ret = commands.getstatusoutput('/prodigfs/ipslfs/dods/jservon/miniconda/envs/cesmep_env/bin/ncdump')
99+
print("ncdump " + ncdump_ret[-1].split('\n')[-1].split()[3] + " => " + my_which('ncdump'))
100+
else:
101+
binary_info = commands.getstatusoutput(my_which("ncdump") + " --version")[-1].split("\n")[-1]
102+
binary_info = binary_info.split("version")[-1].split("of")[0].strip()
103+
print("ncdump " + binary_info + " => " + my_which('ncdump'))
104+
except:
105+
print("Warning: ncdump not found -> can't use ncdump from CliMAF")
106+
# Check that tools for stamping are available or enforce stamping to None
107+
print("Check stamping requirements")
108+
do_stamping = True
109+
try:
110+
print("nco (ncatted) found -> " + my_which("ncatted"))
111+
except:
112+
print("nco (ncatted) not available, can not stamp netcdf files")
113+
do_stamping = False
114+
try:
115+
print("convert found -> " + my_which("convert"))
116+
except:
117+
print("convert not available, can not stamp png files")
118+
do_stamping = False
119+
try:
120+
print("pdftk found -> " + my_which("pdftk"))
121+
except:
122+
print("pdftk not available, can not stamp pdf files")
123+
do_stamping = False
124+
try:
125+
print("exiv2 found -> " + my_which("exiv2"))
126+
except:
127+
print("exiv2 not available, can not stamp eps files")
128+
do_stamping = False
129+
if not do_stamping and cache.stamping is True:
130+
print("At least one stamping requirement is not fulfilled, turn it to None.")
131+
cache.stamping = None
132+
print("---")
133+
#
134+
# Check that the variable TMPDIR, if defined, points to an existing directory
135+
if "TMPDIR" in os.environ and not os.path.isdir(os.environ["TMPDIR"]):
136+
# raise OSError("TMPDIR points to a non existing directory! Change the value of the variable to go on.")
137+
os.makedirs(os.environ["TMPDIR"])
101138

102139
logdir = os.path.expanduser(os.getenv("CLIMAF_LOG_DIR", "."))
103140
#

climaf/anynetcdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
from climaf.clogging import clogger
4+
from env.clogging import clogger
55

66
try:
77
from Scientific.IO.NetCDF import NetCDFFile as ncf

climaf/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
"""
44
CliMAF module ``api`` defines functions for basic CliMAF use : a kind of Application Program Interface for scripting in
@@ -87,8 +87,8 @@
8787
from dataloc import dataloc
8888
from operators import cscript, scripts as cscripts, operators, fixed_fields, derive
8989
from cache import craz, csync, cdump, cdrop, clist, cls, crm, cdu, cwc, cprotect
90-
from clogging import clogger, clog, clog_file, logdir
91-
from site_settings import atCNRM, onCiclad, atTGCC, atIDRIS, atIPSL, onSpip
90+
from env.clogging import clogger, clog, clog_file, logdir
91+
from env.site_settings import atCNRM, onCiclad, atTGCC, atIDRIS, atIPSL, onSpip
9292
from plot.plot_params import plot_params, hovm_params
9393
from plot.varlongname import varlongname
9494
from derived_variables import *

0 commit comments

Comments
 (0)