1 | # Script générant les fichiers ozone hybride CNRM pour les ssp du Tier 2 (en l'absence de l'ozone officiel UReading) |
---|
2 | # ----------------------------------- |
---|
3 | # Th. Lurton - janvier 2019 |
---|
4 | # ----------------------------------- |
---|
5 | # Ce script est à exécuter sur Ciclad |
---|
6 | # inclus dans un job. |
---|
7 | # ----------------------------------- |
---|
8 | |
---|
9 | # Chemins à personnaliser |
---|
10 | ici=/data/tlurton/CMIP6/O3_Tier2/ |
---|
11 | repout=${ici}Tier2_OUT/ |
---|
12 | |
---|
13 | # Chemin des données fournies par le CNRM |
---|
14 | repCNRM=/data/tlurton/CMIP6/OzoneCNRM/ |
---|
15 | |
---|
16 | # Grande boucle sur les années |
---|
17 | # On a 2100 du CNRM, mais pas 2100 d'UReading, ce qui nous oblige à ne pas traiter la derniÚre année. Au final on dupliquera 2100 = 2099. |
---|
18 | for year in {2015..2099} |
---|
19 | do |
---|
20 | |
---|
21 | echo "=========================================================================" |
---|
22 | echo "================================= "${year}" =================================" |
---|
23 | echo "=========================================================================" |
---|
24 | |
---|
25 | # PHASE 1 |
---|
26 | # INTERPOLATION VERTICALE NIVEAUX CNRM --> NIVEAUX UREADING |
---|
27 | |
---|
28 | # --> ici boucle sur tous les ssp |
---|
29 | # On n'aura pas besoin de ssp585 |
---|
30 | |
---|
31 | for ssp in "ssp119" "ssp126" "ssp245" "ssp370" "ssp434" "ssp460" "ssp534-over" |
---|
32 | do |
---|
33 | |
---|
34 | echo "Processing year "${year}" for "${ssp}"..." |
---|
35 | |
---|
36 | fileCNRM=${repCNRM}o3_HOMEPmon_CNRM-ESM2-1_${ssp}_r1i1p1f2_gr_${year}01-${year}12.nc |
---|
37 | |
---|
38 | filetmp1=${ici}${ssp}_${year}_CNRM_hPa.nc |
---|
39 | filetmp2=${ici}${ssp}_${year}_CNRM_hPa_interpURea.nc |
---|
40 | |
---|
41 | # Attention ! |
---|
42 | # Les niveaux plev des fichiers CNRM sont en Pa |
---|
43 | # Les niveaux plev des fichiers UReading sont en hPa |
---|
44 | |
---|
45 | # Niveaux CNRM entre 1000 hPa 3 Pa : |
---|
46 | # [Pa] 100000,92500,85000,70000,60000,50000,40000,30000,25000,20000,17000,15000,13000,11500,10000,9000,8000,7000,5000,3000,2000,1500,1000,700,500,300,200,150,100,70,50,40,30,20,15,10,7,5,3 |
---|
47 | # [hPa] 1000,925,850,700,600,500,400,300,250,200,170,150,130,115,100,90,80,70,50,30,20,15,10,7,5,3,2,1.5,1,.7,.5,.4,.3,.2,.15,.1,.07,.05,.03 |
---|
48 | |
---|
49 | # Niveaux Reading, liste totale |
---|
50 | # [hPa] 1000,925,850,800,780,750,700,650,600,500,450,400,350,300,285,250,200,170,150,130,115,100,90,80,70,60,50,40,35,30,25,20,15,10,7,5,4,3,2,1.5,1,0.7,0.5,0.4,0.3,0.2,0.15,0.1,0.07,0.05,0.04,0.03,0.02,0.015,0.01,0.007,0.005,0.004,0.003,0.002,0.0015,0.001,0.0008,0.0005,0.0003,0.0001 |
---|
51 | |
---|
52 | # Niveaux Reading entre 1000 hPa et 3 Pa |
---|
53 | # [hPa] 1000,925,850,800,780,750,700,650,600,500,450,400,350,300,285,250,200,170,150,130,115,100,90,80,70,60,50,40,35,30,25,20,15,10,7,5,4,3,2,1.5,1,0.7,0.5,0.4,0.3,0.2,0.15,0.1,0.07,0.05,0.04,0.03 |
---|
54 | |
---|
55 | # Conversion des plev CNRM vers hPa, en utilisant le fichier "CNRM_axis_en_hPa" : overwrite de la dimension verticale |
---|
56 | echo "... Converting CNRM pressure levels towards hPa..." |
---|
57 | cdo setzaxis,CNRM_axis_en_hPa ${fileCNRM} ${filetmp1} |
---|
58 | |
---|
59 | # Projection sur les niveaux Reading |
---|
60 | echo "... Interpolating CNRM file onto UReading pressure levels..." |
---|
61 | cdo intlevel,1000,925,850,800,780,750,700,650,600,500,450,400,350,300,285,250,200,170,150,130,115,100,90,80,70,60,50,40,35,30,25,20,15,10,7,5,4,3,2,1.5,1,0.7,0.5,0.4,0.3,0.2,0.15,0.1,0.07,0.05,0.04,0.03 ${filetmp1} ${filetmp2} |
---|
62 | |
---|
63 | rm -f ${filetmp1} |
---|
64 | |
---|
65 | # --> Fin des deux boucles sur les ssp |
---|
66 | done |
---|
67 | |
---|
68 | |
---|
69 | # PHASE 2 |
---|
70 | # "RÃGLE DE TROIS" |
---|
71 | |
---|
72 | # --> Boucle sur les ssp du Tier 2 uniquement : ssp119, ssp434, ssp460 et ssp534-over |
---|
73 | |
---|
74 | for sspT2 in "ssp119" "ssp434" "ssp460" "ssp534-over" |
---|
75 | do |
---|
76 | |
---|
77 | # choix des ssp-Tier1 associés |
---|
78 | if [ ${sspT2} = "ssp119" ] |
---|
79 | then |
---|
80 | sspT1a=ssp126 |
---|
81 | sspT1b=ssp126 |
---|
82 | fi |
---|
83 | if [ ${sspT2} = "ssp434" ] |
---|
84 | then |
---|
85 | sspT1a=ssp126 |
---|
86 | sspT1b=ssp245 |
---|
87 | fi |
---|
88 | if [ ${sspT2} = "ssp460" ] |
---|
89 | then |
---|
90 | sspT1a=ssp245 |
---|
91 | sspT1b=ssp370 |
---|
92 | fi |
---|
93 | if [ ${sspT2} = "ssp534-over"Â ] |
---|
94 | then |
---|
95 | sspT1a=ssp126 |
---|
96 | sspT1b=ssp245 |
---|
97 | fi |
---|
98 | |
---|
99 | fileCNRMT1a=${ici}${sspT1a}_${year}_CNRM_hPa_interpURea.nc |
---|
100 | fileCNRMT1b=${ici}${sspT1b}_${year}_CNRM_hPa_interpURea.nc |
---|
101 | fileCNRMT2=${ici}${sspT2}_${year}_CNRM_hPa_interpURea.nc |
---|
102 | |
---|
103 | if [ ${year} -le 2049 ] |
---|
104 | then |
---|
105 | fileURead1aori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1a}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1a}-1-0_gn_201501-204912.nc |
---|
106 | fileURead1bori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1b}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1b}-1-0_gn_201501-204912.nc |
---|
107 | else |
---|
108 | fileURead1aori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1a}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1a}-1-0_gn_205001-209912.nc |
---|
109 | fileURead1bori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1b}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1b}-1-0_gn_205001-209912.nc |
---|
110 | fi |
---|
111 | |
---|
112 | fileUReadayear=${ici}o3_URead_${sspT1a}_${year}.nc |
---|
113 | fileUReadbyear=${ici}o3_URead_${sspT1b}_${year}.nc |
---|
114 | |
---|
115 | fileUReadatronq=${ici}o3_URead_${sspT1a}_${year}_tronq.nc |
---|
116 | fileUReadbtronq=${ici}o3_URead_${sspT1b}_${year}_tronq.nc |
---|
117 | |
---|
118 | # Fichier contenant les latitudes UReading exactes |
---|
119 | latURead=${ici}lat_URead.nc |
---|
120 | |
---|
121 | filevsa=${ici}o3_${sspT2}_${year}_vs_${sspT1a}.nc |
---|
122 | filevsb=${ici}o3_${sspT2}_${year}_vs_${sspT1b}.nc |
---|
123 | |
---|
124 | echo "... Selecting year "${year}" in Tier-1 UReading ssp "${sspT1a}"..." |
---|
125 | # Extraction de l'année d'intérêt du ssp-Tier1 de UReading |
---|
126 | cdo selyear,${year} ${fileURead1aori} ${fileUReadayear} |
---|
127 | # Pas besoin de la seconde borne Tier1 si on est dans le cas ssp119 : |
---|
128 | if [ ${sspT1a} != ${sspT1b} ] |
---|
129 | then |
---|
130 | echo "... Selecting year "${year}" in Tier-1 UReading ssp "${sspT1b}"..." |
---|
131 | cdo selyear,${year} ${fileURead1bori} ${fileUReadbyear} |
---|
132 | fi |
---|
133 | |
---|
134 | rm -f ${latURead} |
---|
135 | ncks -s 'lat=double(lat)' ${fileUReadayear} ${latURead} |
---|
136 | |
---|
137 | echo "... Chopping up pressure levels, retaining only > 3 Pa..." |
---|
138 | # Troncature des niveaux verticaux |
---|
139 | cdo sellevel,1000,925,850,800,780,750,700,650,600,500,450,400,350,300,285,250,200,170,150,130,115,100,90,80,70,60,50,40,35,30,25,20,15,10,7,5,4,3,2,1.5,1,0.7,0.5,0.4,0.3,0.2,0.15,0.1,0.07,0.05,0.04,0.03 ${fileUReadayear} ${fileUReadatronq} |
---|
140 | # On vient d'enlever les 14 niveaux supérieurs du fichier UReading. 66-14 = 52 niveaux restent. |
---|
141 | # On fait la même chose pour la seconde borne Tier1, sauf dans le cas ssp119, où on n'en a pas besoin. |
---|
142 | if [ ${sspT1a} != ${sspT1b} ] |
---|
143 | then |
---|
144 | cdo sellevel,1000,925,850,800,780,750,700,650,600,500,450,400,350,300,285,250,200,170,150,130,115,100,90,80,70,60,50,40,35,30,25,20,15,10,7,5,4,3,2,1.5,1,0.7,0.5,0.4,0.3,0.2,0.15,0.1,0.07,0.05,0.04,0.03 ${fileUReadbyear} ${fileUReadbtronq} |
---|
145 | fi |
---|
146 | |
---|
147 | # Remappage horizontal des fichiers CNRM |
---|
148 | fileCNRMT1arem=${ici}o3_CNRM_${sspT1a}_${year}_remap.nc |
---|
149 | fileCNRMT1brem=${ici}o3_CNRM_${sspT1b}_${year}_remap.nc |
---|
150 | fileCNRMT2rem=${ici}o3_CNRM_${sspT2}_${year}_remap.nc |
---|
151 | |
---|
152 | echo "... Remapping CNRM file for "${sspT2}" and year "${year}"..." |
---|
153 | cdo remapcon,grid_URead_144x96 ${fileCNRMT2} ${fileCNRMT2rem} |
---|
154 | echo "... Remapping CNRM file for "${sspT1a}" and year "${year}"..." |
---|
155 | cdo remapcon,grid_URead_144x96 ${fileCNRMT1a} ${fileCNRMT1arem} |
---|
156 | rm -f ${fileCNRMT1a} |
---|
157 | if [ ${sspT1a} != ${sspT1b} ] |
---|
158 | then |
---|
159 | echo "... Remapping CNRM file for "${sspT1b}" and year "${year}"..." |
---|
160 | cdo remapcon,grid_URead_144x96 ${fileCNRMT1b} ${fileCNRMT1brem} |
---|
161 | fi |
---|
162 | |
---|
163 | # Fix des latitudes, qui ne tombent pas juste |
---|
164 | echo "... Fixing latitudes..." |
---|
165 | ncks -3 -A -v lat ${latURead} ${fileCNRMT2rem} |
---|
166 | ncks -3 -A -v lat ${latURead} ${fileCNRMT1arem} |
---|
167 | if [ ${sspT1a} != ${sspT1b} ] |
---|
168 | then |
---|
169 | ncks -3 -A -v lat ${latURead} ${fileCNRMT1brem} |
---|
170 | fi |
---|
171 | |
---|
172 | # La rÚgle de trois en soi : l'ozone s'appelle "o3" dans les fichiers CNRM, et "vmro3" dans les fichiers UReading. |
---|
173 | echo "... Performing scaling : "${sspT2}" created by scaling against "${sspT1a}", for year "${year}"..." |
---|
174 | cdo -div -mul -selname,o3 ${fileCNRMT2rem} -selname,vmro3 ${fileUReadatronq} -selname,o3 ${fileCNRMT1arem} ${filevsa} |
---|
175 | if [ ${sspT1a} != ${sspT1b} ] |
---|
176 | then |
---|
177 | echo "... Performing scaling : "${sspT2}" created by scaling against "${sspT1b}", for year "${year}"..." |
---|
178 | cdo -div -mul -selname,o3 ${fileCNRMT2rem} -selname,vmro3 ${fileUReadbtronq} -selname,o3 ${fileCNRMT1brem} ${filevsb} |
---|
179 | fi |
---|
180 | |
---|
181 | # Fin des boucles ssp-Tier2 |
---|
182 | done |
---|
183 | |
---|
184 | |
---|
185 | # PHASE 3 |
---|
186 | # "CHAPEAUTAGE" |
---|
187 | |
---|
188 | if [ ${year} -le 2049 ] |
---|
189 | then |
---|
190 | fileURead1ori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1a}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1a}-1-0_gn_201501-204912.nc |
---|
191 | fileURead2ori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1b}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1b}-1-0_gn_201501-204912.nc |
---|
192 | else |
---|
193 | fileURead1ori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1a}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1a}-1-0_gn_205001-209912.nc |
---|
194 | fileURead2ori=/prodigfs/project/input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-${sspT1b}-1-0/atmos/mon/vmro3/gn/v20181101/vmro3_input4MIPs_ozone_ScenarioMIP_UReading-CCMI-${sspT1b}-1-0_gn_205001-209912.nc |
---|
195 | fi |
---|
196 | |
---|
197 | fileURead1year=${ici}o3_URead_${sspT1a}_${year}.nc |
---|
198 | fileURead2year=${ici}o3_URead_${sspT1b}_${year}.nc |
---|
199 | |
---|
200 | echo "... Preparing hat for year "${year}"..." |
---|
201 | if [ ${sspT1a} != ${sspT1b} ] |
---|
202 | then |
---|
203 | cdo selyear,${year} ${fileURead1ori} ${fileURead1year} |
---|
204 | cdo selyear,${year} ${fileURead2ori} ${fileURead2year} |
---|
205 | else |
---|
206 | cdo selyear,${year} ${fileURead1ori} ${fileURead1year} |
---|
207 | fi |
---|
208 | |
---|
209 | fileURead1chapo=${ici}o3_URead_${sspT1a}_${year}_chapo.nc |
---|
210 | fileURead2chapo=${ici}o3_URead_${sspT1b}_${year}_chapo.nc |
---|
211 | |
---|
212 | if [ ${sspT1a} != ${sspT1b} ] |
---|
213 | then |
---|
214 | cdo sellevel,0.02,0.015,0.01,0.007,0.005,0.004,0.003,0.002,0.0015,0.001,0.0008,0.0005,0.0003,0.0001 ${fileURead1year} ${fileURead1chapo} |
---|
215 | cdo sellevel,0.02,0.015,0.01,0.007,0.005,0.004,0.003,0.002,0.0015,0.001,0.0008,0.0005,0.0003,0.0001 ${fileURead2year} ${fileURead2chapo} |
---|
216 | else |
---|
217 | cdo sellevel,0.02,0.015,0.01,0.007,0.005,0.004,0.003,0.002,0.0015,0.001,0.0008,0.0005,0.0003,0.0001 ${fileURead1year} ${fileURead1chapo} |
---|
218 | fi |
---|
219 | |
---|
220 | fileUReadchapo=${ici}o3_URead_${year}_chapo.nc |
---|
221 | |
---|
222 | # Moyenne des chapeaux des deux ssp |
---|
223 | if [ ${sspT1a} != ${sspT1b} ] |
---|
224 | then |
---|
225 | echo "... Averaging hats for Tier 1 UReading "${sspT1a}" and "${sspT1b}", for "${year}"..." |
---|
226 | cdo mulc,.5 -add -selname,vmro3 ${fileURead1chapo} -selname,vmro3 ${fileURead2chapo} ${fileUReadchapo} |
---|
227 | else |
---|
228 | echo "... Using solely hat from Tier 1 UReading "${sspT1a}", for year "${year}"..." |
---|
229 | cp ${fileURead1chapo} ${fileUReadchapo} |
---|
230 | fi |
---|
231 | |
---|
232 | echo "... Cleaning up..." |
---|
233 | if [ ${sspT1a} != ${sspT1b} ] |
---|
234 | then |
---|
235 | rm -f ${fileURead1year} ${fileURead2year} ${fileURead1chapo} ${fileURead2chapo} |
---|
236 | else |
---|
237 | rm -f ${fileURead1year} ${fileURead1chapo} |
---|
238 | fi |
---|
239 | |
---|
240 | # Ajout du chapeau aux ssp Tier2 créés à l'étape 2 |
---|
241 | |
---|
242 | for sspT2 in "ssp119" "ssp434" "ssp460" "ssp534-over" |
---|
243 | do |
---|
244 | |
---|
245 | # choix des ssp-Tier1 associés |
---|
246 | if [ ${sspT2} = "ssp119" ] |
---|
247 | then |
---|
248 | sspT1a=ssp126 |
---|
249 | sspT1b=ssp126 |
---|
250 | fi |
---|
251 | if [ ${sspT2} = "ssp434" ] |
---|
252 | then |
---|
253 | sspT1a=ssp126 |
---|
254 | sspT1b=ssp245 |
---|
255 | fi |
---|
256 | if [ ${sspT2} = "ssp460" ] |
---|
257 | then |
---|
258 | sspT1a=ssp245 |
---|
259 | sspT1b=ssp370 |
---|
260 | fi |
---|
261 | if [ ${sspT2} = "ssp534-over"Â ] |
---|
262 | then |
---|
263 | sspT1a=ssp126 |
---|
264 | sspT1b=ssp245 |
---|
265 | fi |
---|
266 | |
---|
267 | filevsa=${ici}o3_${sspT2}_${year}_vs_${sspT1a}.nc |
---|
268 | filevsb=${ici}o3_${sspT2}_${year}_vs_${sspT1b}.nc |
---|
269 | |
---|
270 | fileUReadfinala=${repout}${sspT2}/o3_${sspT2}_${year}_vs_${sspT1a}.nc |
---|
271 | fileUReadfinalb=${repout}${sspT2}/o3_${sspT2}_${year}_vs_${sspT1b}.nc |
---|
272 | |
---|
273 | echo "... Renaming O3 variable and fixing NetCDF-3 inconsistency..." |
---|
274 | ncrename -v o3,vmro3 ${filevsa} |
---|
275 | ncks -3 ${filevsa} ${ici}tmp.nc |
---|
276 | mv ${ici}tmp.nc ${filevsa} |
---|
277 | if [ ${sspT1a} != ${sspT1b} ] |
---|
278 | then |
---|
279 | ncrename -v o3,vmro3 ${filevsb} |
---|
280 | ncks -3 ${filevsb} ${ici}tmp.nc |
---|
281 | mv ${ici}tmp.nc ${filevsb} |
---|
282 | fi |
---|
283 | |
---|
284 | echo "... Topping newly created "${sspT2}" (against "${sspT1a}") for year "${year}" with hat..." |
---|
285 | cdo merge ${filevsa} ${fileUReadchapo} ${fileUReadfinala} |
---|
286 | if [ ${sspT1a} != ${sspT1b} ] |
---|
287 | then |
---|
288 | echo "... Topping newly created "${sspT2}" (against "${sspT1b}") for year "${year}" with hat..." |
---|
289 | cdo merge ${filevsb} ${fileUReadchapo} ${fileUReadfinalb} |
---|
290 | fi |
---|
291 | |
---|
292 | # Je moyenne les deux versions |
---|
293 | echo "... Merging "${sspT2}" against "${sspT1a}" and "${sspT2}" against "${sspT1b}" into a single file..." |
---|
294 | filemerge=${repout}${sspT2}/o3_${sspT2}_${year}.nc |
---|
295 | if [ ${sspT1a} != ${sspT1b} ] |
---|
296 | then |
---|
297 | cdo add -mulc,.5 -selname,vmro3 ${fileUReadfinala} -mulc,.5 -selname,vmro3 ${fileUReadfinalb} ${filemerge} |
---|
298 | else |
---|
299 | cp ${fileUReadfinala} ${filemerge} |
---|
300 | fi |
---|
301 | |
---|
302 | # Petite entourloupe finale pour avoir précisément les niveaux de pression d'origine (entre-temps, on est passés en double avec petite erreur d'arrondi...) |
---|
303 | echo "... Fixing z-axis for year "${year}"..." |
---|
304 | cdo setzaxis,URead_axis_en_hPa ${filemerge} ${repout}tmp.nc |
---|
305 | mv ${repout}tmp.nc ${filemerge} |
---|
306 | |
---|
307 | # Fix des latitudes |
---|
308 | ncks -3 -A -v lat ${latURead} ${filemerge} |
---|
309 | |
---|
310 | # Fin de la boucle sur les sspT2 |
---|
311 | done |
---|
312 | |
---|
313 | rm -f ${fileUReadchapo} |
---|
314 | |
---|
315 | # Ménage |
---|
316 | rm -f ${ici}o3*${year}*.nc ${ici}ssp*${year}*.nc |
---|
317 | |
---|
318 | # Fin de la grande boucle sur les années |
---|
319 | done |
---|