1 | # Script prenant en entrÃe les outputs des simulations historical gÃnÃrant les forÃages aÃrosols tropo |
---|
2 | # Une moyenne glissante sur 3 ans est effectuÃe, avec pondÃration [0.25 ; 0.5 ; 0.25]. |
---|
3 | # Un fichier climato par an est gÃnÃrà au final. |
---|
4 | # Th. Lurton IPSL nov. 2017 |
---|
5 | |
---|
6 | #!/bin/sh |
---|
7 | |
---|
8 | for year in {1850..2014} |
---|
9 | do |
---|
10 | |
---|
11 | if [ ${year} -ge 1850 ] && [ ${year} -le 1882 ] |
---|
12 | then |
---|
13 | lettreprec='' |
---|
14 | lettre=A |
---|
15 | lettresuiv=B |
---|
16 | elif [ ${year} -ge 1883 ] && [ ${year} -le 1915 ] |
---|
17 | then |
---|
18 | lettreprec=A |
---|
19 | lettre=B |
---|
20 | lettresuiv=C |
---|
21 | elif [ ${year} -ge 1916 ] && [ ${year} -le 1948 ] |
---|
22 | then |
---|
23 | lettreprec=B |
---|
24 | lettre=C |
---|
25 | lettresuiv=D |
---|
26 | elif [ ${year} -ge 1949 ] && [ ${year} -le 1981 ] |
---|
27 | then |
---|
28 | lettreprec=C |
---|
29 | lettre=D |
---|
30 | lettresuiv=E |
---|
31 | elif [ ${year} -ge 1982 ] && [ ${year} -le 2014 ] |
---|
32 | then |
---|
33 | lettreprec=D |
---|
34 | lettre=E |
---|
35 | lettresuiv='' |
---|
36 | fi |
---|
37 | |
---|
38 | nomsimu=LOI6012-histAER-part${lettre} |
---|
39 | nomsimuprec=LOI6012-histAER-part${lettreprec} |
---|
40 | nomsimusuiv=LOI6012-histAER-part${lettresuiv} |
---|
41 | |
---|
42 | # Chemins |
---|
43 | chemin=/ccc/store/cont003/gencmip6/lurtont/IGCM_OUT/LMDZORINCA/PROD/historicalAER/${nomsimu}/CHM/Output/MO/ |
---|
44 | cheminprec=/ccc/store/cont003/gencmip6/lurtont/IGCM_OUT/LMDZORINCA/PROD/historicalAER/${nomsimuprec}/CHM/Output/MO/ |
---|
45 | cheminsuiv=/ccc/store/cont003/gencmip6/lurtont/IGCM_OUT/LMDZORINCA/PROD/historicalAER/${nomsimusuiv}/CHM/Output/MO/ |
---|
46 | |
---|
47 | workchemin=/ccc/scratch/cont003/gencmip6/lurtont/aerosols_from_inca/ |
---|
48 | |
---|
49 | # On effectue une moyenne glissante sur trois années, centrée en l'année d'intérêt, |
---|
50 | # et de poids [ 1/4 ; 1/2 ; 1/4 ]. |
---|
51 | prec=$((${year}-1)) |
---|
52 | suiv=$((${year}+1)) |
---|
53 | |
---|
54 | # Override des années précédente pour 1850, et suivante pour 2014 : |
---|
55 | if [ ${year} = 1850 ] |
---|
56 | then |
---|
57 | prec=1850 |
---|
58 | echo '*** Comme on est en 1850, je prends aussi 1850 pour an (n-1).' |
---|
59 | fi |
---|
60 | if [ ${year} = 2014 ] |
---|
61 | then |
---|
62 | suiv=2014 |
---|
63 | echo '*** Comme on est en 2014, je prends aussi 2014 pour an (n+1).' |
---|
64 | fi |
---|
65 | |
---|
66 | echo '***** Annee '${year}' : Moyenne glissante sur ans '${prec}', '${year}', et '${suiv}'.' |
---|
67 | |
---|
68 | # Adresses generiques des fichiers a traiter |
---|
69 | fileprec=${chemin}${nomsimu}_${prec}0101_${prec}1230_1M_aerosols_from_inca.nc |
---|
70 | fileyear=${chemin}${nomsimu}_${year}0101_${year}1230_1M_aerosols_from_inca.nc |
---|
71 | filesuiv=${chemin}${nomsimu}_${suiv}0101_${suiv}1230_1M_aerosols_from_inca.nc |
---|
72 | |
---|
73 | # Override pour les cas des annees-charnieres |
---|
74 | # Si l'on est en fin de periode (sauf la derniere), il faut regarder dans la simulation suivante pour le fichier (n+1) |
---|
75 | if [ ${year} = 1882 ] || [ ${year} = 1915 ] || [ ${year} = 1948 ] || [ ${year} = 1981 ] |
---|
76 | then |
---|
77 | filesuiv=${cheminsuiv}${nomsimusuiv}_${suiv}0101_${suiv}1230_1M_aerosols_from_inca.nc |
---|
78 | # si l'on est en debut de periode (sauf la premiere), on regarde dans la simulation precedente pour le fichier (n-1) |
---|
79 | fi |
---|
80 | if [ ${year} = 1883 ] || [ ${year} = 1916 ] || [ ${year} = 1949 ] || [ ${year} = 1982 ] |
---|
81 | then |
---|
82 | fileprec=${cheminprec}${nomsimuprec}_${prec}0101_${prec}1230_1M_aerosols_from_inca.nc |
---|
83 | fi |
---|
84 | |
---|
85 | # Fichiers temporaires avec ponderation (cas generique) |
---|
86 | pondprec=${workchemin}${nomsimu}_${prec}0101_${prec}1230_pond.nc |
---|
87 | pondyear=${workchemin}${nomsimu}_${year}0101_${year}1230_pond.nc |
---|
88 | pondsuiv=${workchemin}${nomsimu}_${suiv}0101_${suiv}1230_pond.nc |
---|
89 | |
---|
90 | # Cas particulier pour 1850 : il ne faut pas que ${pondprec} et ${pondyear} s'écrivent l'un sur l'autre |
---|
91 | if [ ${year} = 1850 ] |
---|
92 | then |
---|
93 | pondprec=${workchemin}${nomsimu}_18490101_18491230_pond.nc |
---|
94 | fi |
---|
95 | # Cas particulier pour 2014 : il ne faut pas que ${pondsuiv} et ${pondyear} s'écrivent l'un sur l'autre |
---|
96 | if [ ${year} = 2014 ] |
---|
97 | then |
---|
98 | pondsuiv=${workchemin}${nomsimu}_20150101_20151230_pond.nc |
---|
99 | fi |
---|
100 | |
---|
101 | # Pondération des trois années successives par 1/4 ; 1/2 ; 1/4 ] |
---|
102 | # et multiplication par un facteur 3 qui disparaîtr lors de la moyenne par mois. |
---|
103 | |
---|
104 | cdo mulc,.75 ${fileprec} ${pondprec} |
---|
105 | cdo mulc,1.5 ${fileyear} ${pondyear} |
---|
106 | cdo mulc,.75 ${filesuiv} ${pondsuiv} |
---|
107 | |
---|
108 | # Fix du vecteur temps pour les cas 1849 et 2015 : comme ils sont issus d'une duplication de fichier, il faut lui faire croire |
---|
109 | # que l'on a le vecteur temps de l'annee precedente/suivante |
---|
110 | if [ ${year} = 1850 ] |
---|
111 | then |
---|
112 | tmp=${workchemin}${nomsimu}_tmp.nc |
---|
113 | mv ${pondprec} ${tmp} |
---|
114 | cdo shifttime,-1year ${tmp} ${pondprec} |
---|
115 | rm -f ${tmp} |
---|
116 | fi |
---|
117 | if [ ${year} = 2014 ] |
---|
118 | then |
---|
119 | tmp=${workchemin}${nomsimu}_tmp.nc |
---|
120 | mv ${pondsuiv} ${tmp} |
---|
121 | cdo shifttime,1year ${tmp} ${pondsuiv} |
---|
122 | rm -f ${tmp} |
---|
123 | fi |
---|
124 | |
---|
125 | # Alignement de tout le monde sur 1850 |
---|
126 | ncatted -O -a units,time_counter,o,c,"seconds since 1850-01-01 00:00:00" ${pondyear} |
---|
127 | ncatted -O -a units,time_counter,o,c,"seconds since 1850-01-01 00:00:00" ${pondprec} |
---|
128 | ncatted -O -a units,time_counter,o,c,"seconds since 1850-01-01 00:00:00" ${pondsuiv} |
---|
129 | |
---|
130 | # Fix du vecteur temps pour les annees-charnieres : chacune des cinq parties de simulation a sa propre origine des temps |
---|
131 | # partA commence en 1847, partB en 1880, partC en 1913, partD en 1946 et partE en 1979 |
---|
132 | # si on est en fin de periode, on doit decaler l'axe des temps du fichier (n+1) de 33 ans |
---|
133 | if [ ${year} = 1882 ] || [ ${year} = 1915 ] || [ ${year} = 1948 ] || [ ${year} = 1981 ] |
---|
134 | then |
---|
135 | tmp=${workchemin}${suiv}_tmp.nc |
---|
136 | mv ${pondsuiv} ${tmp} |
---|
137 | cdo shifttime,33years ${tmp} ${pondsuiv} |
---|
138 | fi |
---|
139 | # si on est en debut de periode, on doit decaler l'axe des temps du fichier (n-1) de -33 ans |
---|
140 | # (normalement on reste en positif, car la simu fait 36 ans au total en incluant le spin-up de 3 ans, et on regarde la derniere annee) |
---|
141 | if [ ${year} = 1883 ] || [ ${year} = 1916 ] || [ ${year} = 1949 ] || [ ${year} = 1982 ] |
---|
142 | then |
---|
143 | tmp=${workchemin}${prec}_tmp.nc |
---|
144 | mv ${pondprec} ${tmp} |
---|
145 | cdo shifttime,-33years ${tmp} ${pondprec} |
---|
146 | fi |
---|
147 | |
---|
148 | pondtroisans=${workchemin}aerosols_${prec}0101_${suiv}1230_pond.nc |
---|
149 | |
---|
150 | # Override pour les cas 1850 et 2014, renommage propre du fichier trois ans |
---|
151 | if [ ${year} = 1850 ] |
---|
152 | then |
---|
153 | pondtroisans=${workchemin}aerosols_18490101_18511230_pond.nc |
---|
154 | fi |
---|
155 | if [ ${year} = 2014 ] |
---|
156 | then |
---|
157 | pondtroisans=${workchemin}aerosols_20130101_20151230_pond.nc |
---|
158 | fi |
---|
159 | |
---|
160 | cdo mergetime ${pondprec} ${pondyear} ${pondsuiv} ${pondtroisans} |
---|
161 | rm -f ${pondprec} ${pondyear} ${pondsuiv} |
---|
162 | |
---|
163 | fileout=${workchemin}final_AER/aerosols${year}_from_inca.nc |
---|
164 | |
---|
165 | cdo ymonmean ${pondtroisans} ${fileout} |
---|
166 | rm -f ${pondtroisans} |
---|
167 | |
---|
168 | # Fix du vecteur temps : ymonmean s'aligne sur la derniere annee, ici (n+1) |
---|
169 | # on recule donc d'un an pour bien avoir l'annee (n) |
---|
170 | tmp=${workchemin}${nomsimu}_tmp.nc |
---|
171 | mv ${fileout} ${tmp} |
---|
172 | cdo shifttime,-1year ${tmp} ${fileout} |
---|
173 | rm -f ${tmp} |
---|
174 | |
---|
175 | # Dernier point : on s'aligne sur 1850 pour l'origine des temps de tout le monde |
---|
176 | tmp=${workchemin}tmp.nc |
---|
177 | mv ${fileout} ${tmp} |
---|
178 | if [ ${lettre} = 'A' ] |
---|
179 | then |
---|
180 | cdo shifttime,-3years ${tmp} ${fileout} |
---|
181 | elif [ ${lettre} = 'B' ] |
---|
182 | then |
---|
183 | cdo shifttime,30years ${tmp} ${fileout} |
---|
184 | elif [ ${lettre} = 'C' ] |
---|
185 | then |
---|
186 | cdo shifttime,63years ${tmp} ${fileout} |
---|
187 | elif [ ${lettre} = 'D' ] |
---|
188 | then |
---|
189 | cdo shifttime,96years ${tmp} ${fileout} |
---|
190 | elif [ ${lettre} = 'E' ] |
---|
191 | then |
---|
192 | cdo shifttime,129years ${tmp} ${fileout} |
---|
193 | fi |
---|
194 | rm -f ${tmp} |
---|
195 | |
---|
196 | # Fin de boucle sur les années |
---|
197 | done |
---|