source: BOL/Multi_atlas/atlas/ferret2py.sh @ 3684

Last change on this file since 3684 was 3684, checked in by idelkadi, 4 years ago

Repository under svn of a first version of Multiatlas diagnostics for LMDZ. This version is adapted to be able to run a LMDZ multiatlas on an individual account on the ciclad machine of the IPSL. In this version, the parts to be modified are identified so as to subsequently adapt it to other machines.
This version is still under development.

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/bash
2
3
4#########################################################
5# Transformation des contours de (xmin,xmax,dx) en x0 x1 ...
6#########################################################
7cat <<eod>| contours.sh
8#!/bin/bash
9
10sed -e 's/(Inf)//' -e 's/(-Inf)//' -e 's/^.*.=.(//' -e 's/(//g' -e s:\'.*.\$:: -e 's/)/ /g' -e s/[\"\']//g tt  > ttt
11
12
13n=\`wc -w ttt | awk ' { print \$1 } '\`
14i=0
15cont=""
16while [ \$i -lt \$n ] ; do
17   (( i = \$i + 1 ))
18   sub=\`cut -d" " -f\$i ttt\`
19   if [ "\`echo \$sub | grep , \`" = "" ] ; then
20      cont="\$cont \$sub"
21   else
22      ci=\`echo \$sub | cut -d, -f1\`
23      cf=\`echo \$sub | cut -d, -f2\`
24      dc=\`echo \$sub | cut -d, -f3\`
25      c=\$ci
26      cont="\$cont \$c"
27      diff="-"
28      while [ "\$diff" = "-" ] ; do
29         c=\`echo \$c \$dc | awk ' { print \$1 + \$2 } '\`
30         cont="\$cont \$c"
31         diff=\`echo \$c \$cf | awk ' { print \$1 - \$2 } ' | cut -c1\`
32      done
33   fi
34done
35echo \$cont
36eod
37chmod +x contours.sh
38
39#########################################################
40# Entete du fichier plot_params.py.ferret
41#########################################################
42cat <<eod>| plot_params.py.ferret
43# -*- coding: iso-8859-1 -*-
44# Created : S.Sénési - nov 2015
45
46"""
47Une fonction qui rend des paramètres régissant l'apparence de
48graphiques, en fonction de la variable géophysique et du contexte
49
50Encore au stade de brouilllon ; peu de variables traitées
51
52"""
53
54def plot_params(variable,context) :
55    """
56    Return plot parameters as a dict() , according to LMDZ habits , for a given
57    variable and a context (among full_field, bias, model_model)
58
59    """
60
61    defaults = {
62        'contours' : 1 ,
63        'color'    :'temp_19lev',
64    }
65
66    per_variable = {
67eod
68
69
70######################################################################
71# Boucle sur les variables
72######################################################################
73
74vars1="pr hurs rstt rlut rtt crelt crest crett hfns hfss hfls tas tasc tauu tauv pslhPa zg500"
75vars2="rsah rsahcs rsahcre rlah rlahcs rlahcre rah rahcs rahcre cress rsts rsut rlutcs albs albt cress crels crets rts crelt"
76vars3="cltcalipso clhcalipso clmcalipso cllcalipso"
77
78file_ferret=/data/hourdin/LMDZ6/cartes.sh
79
80for vvv in $vars1 $vars2 $vars3 ; do
81
82case $vvv in
83   "pslhPa") var=psl ;;
84   *) var=$vvv
85esac
86
87
88lev=`grep ${vvv}"[)\|]" $file_ferret | grep 'lev=' | awk ' { print $2 } ' `
89#| sed -e 's/lev=.//' -e 's/(Inf)//' -e 's/(-Inf)//' -e s:[\)\(\']:\ :g`
90
91levd=`grep ${vvv}"[)\|]" $file_ferret | grep 'lev=' | awk ' { print $4 } ' `
92if [  `echo $levd | cut -d\" -f2 | cut -c1` = "\$" ] ; then
93   vard=`echo $levd | cut -d\" -f2 | sed -e 's/^.//'`
94   levd=`grep ${vard}"\=" $file_ferret`
95fi
96
97echo $lev >| tt
98lev=`./contours.sh`
99
100echo $levd >| tt
101levd=`./contours.sh`
102
103echo VAR $var
104echo $lev
105echo $levd
106
107cat <<eod>> plot_params.py.ferret
108       '$var' : {
109eod
110grep ' '$var' ' default.txt | sed -e 's/ '$var' //' >>  plot_params.py.ferret
111offset=`grep ' '$var' ' offset.txt | awk ' { print $2 } '`
112echo $offset
113if [ "$offset" != "" ] ; then offset=" , 'offset' : $offset" ; fi
114cat <<eod>> plot_params.py.ferret
115            'full_field'   : {'colors':'$lev' $offset },
116            'bias'        : {'colors': '$levd' , 'color':'BlueDarkRed18' },
117            'model_model' : {'colors': '$levd'},
118        },
119eod
120
121
122done
123
124
125########################################################################
126# Fin du fichier
127########################################################################
128cat <<eod>> plot_params.py.ferret
129    }
130    #
131    rep=defaults.copy()
132    if variable in per_variable :
133        var_entry=per_variable[variable]
134        for cont in [ 'default', context ] :
135            if cont in var_entry : rep.update(var_entry[cont])
136    return rep
137
138eod
Note: See TracBrowser for help on using the repository browser.