source: TOOLS/CMIP6_FORCING/SCENARIOS/create_O3_hybrid_CNRM_Tier2.sh @ 4226

Last change on this file since 4226 was 4226, checked in by tlurton, 4 years ago

Added script for generation of hybrid CNRM ozone files for Tier 2 scenarios.

  • Property svn:executable set to *
File size: 12.3 KB
Line 
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
10ici=/data/tlurton/CMIP6/O3_Tier2/
11repout=${ici}Tier2_OUT/
12
13# Chemin des données fournies par le CNRM
14repCNRM=/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.
18for year in {2015..2099}
19do
20
21echo "========================================================================="
22echo "================================= "${year}" ================================="
23echo "========================================================================="
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
31for ssp in "ssp119" "ssp126" "ssp245" "ssp370" "ssp434" "ssp460" "ssp534-over"
32do
33
34echo "Processing year "${year}" for "${ssp}"..."
35
36fileCNRM=${repCNRM}o3_HOMEPmon_CNRM-ESM2-1_${ssp}_r1i1p1f2_gr_${year}01-${year}12.nc
37
38filetmp1=${ici}${ssp}_${year}_CNRM_hPa.nc
39filetmp2=${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
56echo "... Converting CNRM pressure levels towards hPa..."
57cdo setzaxis,CNRM_axis_en_hPa ${fileCNRM} ${filetmp1}
58
59# Projection sur les niveaux Reading
60echo "... Interpolating CNRM file onto UReading pressure levels..."
61cdo 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
63rm -f ${filetmp1}
64
65# --> Fin des deux boucles sur les ssp
66done
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
74for sspT2 in "ssp119" "ssp434" "ssp460" "ssp534-over"
75do
76
77# choix des ssp-Tier1 associés
78if [ ${sspT2} = "ssp119" ]
79then
80sspT1a=ssp126
81sspT1b=ssp126
82fi
83if [ ${sspT2} = "ssp434" ]
84then
85sspT1a=ssp126
86sspT1b=ssp245
87fi
88if [ ${sspT2} = "ssp460" ]
89then
90sspT1a=ssp245
91sspT1b=ssp370
92fi
93if [ ${sspT2} = "ssp534-over" ]
94then
95sspT1a=ssp126
96sspT1b=ssp245
97fi
98
99fileCNRMT1a=${ici}${sspT1a}_${year}_CNRM_hPa_interpURea.nc
100fileCNRMT1b=${ici}${sspT1b}_${year}_CNRM_hPa_interpURea.nc
101fileCNRMT2=${ici}${sspT2}_${year}_CNRM_hPa_interpURea.nc
102
103if [ ${year} -le 2049 ]
104then
105fileURead1aori=/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
106fileURead1bori=/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
107else
108fileURead1aori=/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
109fileURead1bori=/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
110fi
111
112fileUReadayear=${ici}o3_URead_${sspT1a}_${year}.nc
113fileUReadbyear=${ici}o3_URead_${sspT1b}_${year}.nc
114
115fileUReadatronq=${ici}o3_URead_${sspT1a}_${year}_tronq.nc
116fileUReadbtronq=${ici}o3_URead_${sspT1b}_${year}_tronq.nc
117
118# Fichier contenant les latitudes UReading exactes
119latURead=${ici}lat_URead.nc
120
121filevsa=${ici}o3_${sspT2}_${year}_vs_${sspT1a}.nc
122filevsb=${ici}o3_${sspT2}_${year}_vs_${sspT1b}.nc
123
124echo "... Selecting year "${year}" in Tier-1 UReading ssp "${sspT1a}"..."
125# Extraction de l'année d'intérêt du ssp-Tier1 de UReading
126cdo selyear,${year} ${fileURead1aori} ${fileUReadayear}
127# Pas besoin de la seconde borne Tier1 si on est dans le cas ssp119 :
128if [ ${sspT1a} != ${sspT1b} ]
129then
130echo "... Selecting year "${year}" in Tier-1 UReading ssp "${sspT1b}"..."
131cdo selyear,${year} ${fileURead1bori} ${fileUReadbyear}
132fi
133
134rm -f ${latURead}
135ncks -s 'lat=double(lat)' ${fileUReadayear} ${latURead}
136
137echo "... Chopping up pressure levels, retaining only > 3 Pa..."
138# Troncature des niveaux verticaux
139cdo 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.
142if [ ${sspT1a} != ${sspT1b} ]
143then
144cdo 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}
145fi
146
147# Remappage horizontal des fichiers CNRM
148fileCNRMT1arem=${ici}o3_CNRM_${sspT1a}_${year}_remap.nc
149fileCNRMT1brem=${ici}o3_CNRM_${sspT1b}_${year}_remap.nc
150fileCNRMT2rem=${ici}o3_CNRM_${sspT2}_${year}_remap.nc
151
152echo "... Remapping CNRM file for "${sspT2}" and year "${year}"..."
153cdo remapcon,grid_URead_144x96 ${fileCNRMT2} ${fileCNRMT2rem}
154echo "... Remapping CNRM file for "${sspT1a}" and year "${year}"..."
155cdo remapcon,grid_URead_144x96 ${fileCNRMT1a} ${fileCNRMT1arem}
156rm -f ${fileCNRMT1a}
157if [ ${sspT1a} != ${sspT1b} ]
158then
159echo "... Remapping CNRM file for "${sspT1b}" and year "${year}"..."
160cdo remapcon,grid_URead_144x96 ${fileCNRMT1b} ${fileCNRMT1brem}
161fi
162
163# Fix des latitudes, qui ne tombent pas juste
164echo "... Fixing latitudes..."
165ncks -3 -A -v lat ${latURead} ${fileCNRMT2rem}
166ncks -3 -A -v lat ${latURead} ${fileCNRMT1arem}
167if [ ${sspT1a} != ${sspT1b} ]
168then
169ncks -3 -A -v lat ${latURead} ${fileCNRMT1brem}
170fi
171
172# La rÚgle de trois en soi : l'ozone s'appelle "o3" dans les fichiers CNRM, et "vmro3" dans les fichiers UReading.
173echo "... Performing scaling : "${sspT2}" created by scaling against "${sspT1a}", for year "${year}"..."
174cdo -div -mul -selname,o3 ${fileCNRMT2rem} -selname,vmro3 ${fileUReadatronq} -selname,o3 ${fileCNRMT1arem} ${filevsa}
175if [ ${sspT1a} != ${sspT1b} ]
176then
177echo "... Performing scaling : "${sspT2}" created by scaling against "${sspT1b}", for year "${year}"..."
178cdo -div -mul -selname,o3 ${fileCNRMT2rem} -selname,vmro3 ${fileUReadbtronq} -selname,o3 ${fileCNRMT1brem} ${filevsb}
179fi
180
181# Fin des boucles ssp-Tier2
182done
183
184
185# PHASE 3
186# "CHAPEAUTAGE"
187
188if [ ${year} -le 2049 ]
189then
190fileURead1ori=/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
191fileURead2ori=/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
192else
193fileURead1ori=/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
194fileURead2ori=/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
195fi
196
197fileURead1year=${ici}o3_URead_${sspT1a}_${year}.nc
198fileURead2year=${ici}o3_URead_${sspT1b}_${year}.nc
199
200echo "... Preparing hat for year "${year}"..."
201if [ ${sspT1a} != ${sspT1b} ]
202then
203cdo selyear,${year} ${fileURead1ori} ${fileURead1year}
204cdo selyear,${year} ${fileURead2ori} ${fileURead2year}
205else
206cdo selyear,${year} ${fileURead1ori} ${fileURead1year}
207fi
208
209fileURead1chapo=${ici}o3_URead_${sspT1a}_${year}_chapo.nc
210fileURead2chapo=${ici}o3_URead_${sspT1b}_${year}_chapo.nc
211
212if [ ${sspT1a} != ${sspT1b} ]
213then
214cdo 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}
215cdo 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}
216else
217cdo 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}
218fi
219
220fileUReadchapo=${ici}o3_URead_${year}_chapo.nc
221
222# Moyenne des chapeaux des deux ssp
223if [ ${sspT1a} != ${sspT1b} ]
224then
225echo "... Averaging hats for Tier 1 UReading "${sspT1a}" and "${sspT1b}", for "${year}"..."
226cdo mulc,.5 -add -selname,vmro3 ${fileURead1chapo} -selname,vmro3 ${fileURead2chapo} ${fileUReadchapo}
227else
228echo "... Using solely hat from Tier 1 UReading "${sspT1a}", for year "${year}"..."
229cp ${fileURead1chapo} ${fileUReadchapo}
230fi
231
232echo "... Cleaning up..."
233if [ ${sspT1a} != ${sspT1b} ]
234then
235rm -f ${fileURead1year} ${fileURead2year} ${fileURead1chapo} ${fileURead2chapo}
236else
237rm -f ${fileURead1year} ${fileURead1chapo}
238fi
239
240# Ajout du chapeau aux ssp Tier2 créés à l'étape 2
241
242for sspT2 in "ssp119" "ssp434" "ssp460" "ssp534-over"
243do
244
245# choix des ssp-Tier1 associés
246if [ ${sspT2} = "ssp119" ]
247then
248sspT1a=ssp126
249sspT1b=ssp126
250fi
251if [ ${sspT2} = "ssp434" ]
252then
253sspT1a=ssp126
254sspT1b=ssp245
255fi
256if [ ${sspT2} = "ssp460" ]
257then
258sspT1a=ssp245
259sspT1b=ssp370
260fi
261if [ ${sspT2} = "ssp534-over" ]
262then
263sspT1a=ssp126
264sspT1b=ssp245
265fi
266
267filevsa=${ici}o3_${sspT2}_${year}_vs_${sspT1a}.nc
268filevsb=${ici}o3_${sspT2}_${year}_vs_${sspT1b}.nc
269
270fileUReadfinala=${repout}${sspT2}/o3_${sspT2}_${year}_vs_${sspT1a}.nc
271fileUReadfinalb=${repout}${sspT2}/o3_${sspT2}_${year}_vs_${sspT1b}.nc
272
273echo "... Renaming O3 variable and fixing NetCDF-3 inconsistency..."
274ncrename -v o3,vmro3 ${filevsa}
275ncks -3 ${filevsa} ${ici}tmp.nc
276mv ${ici}tmp.nc ${filevsa}
277if [ ${sspT1a} != ${sspT1b} ]
278then
279ncrename -v o3,vmro3 ${filevsb}
280ncks -3 ${filevsb} ${ici}tmp.nc
281mv ${ici}tmp.nc ${filevsb}
282fi
283
284echo "... Topping newly created "${sspT2}" (against "${sspT1a}") for year "${year}" with hat..."
285cdo merge ${filevsa} ${fileUReadchapo} ${fileUReadfinala}
286if [ ${sspT1a} != ${sspT1b} ]
287then
288echo "... Topping newly created "${sspT2}" (against "${sspT1b}") for year "${year}" with hat..."
289cdo merge ${filevsb} ${fileUReadchapo} ${fileUReadfinalb}
290fi
291
292# Je moyenne les deux versions
293echo "... Merging "${sspT2}" against "${sspT1a}" and "${sspT2}" against "${sspT1b}" into a single file..."
294filemerge=${repout}${sspT2}/o3_${sspT2}_${year}.nc
295if [ ${sspT1a} != ${sspT1b} ]
296then
297cdo add -mulc,.5 -selname,vmro3 ${fileUReadfinala} -mulc,.5 -selname,vmro3 ${fileUReadfinalb} ${filemerge}
298else
299cp ${fileUReadfinala} ${filemerge}
300fi
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...)
303echo "... Fixing z-axis for year "${year}"..."
304cdo setzaxis,URead_axis_en_hPa ${filemerge} ${repout}tmp.nc
305mv ${repout}tmp.nc ${filemerge}
306
307# Fix des latitudes
308ncks -3 -A -v lat ${latURead} ${filemerge}
309
310# Fin de la boucle sur les sspT2
311done
312
313rm -f ${fileUReadchapo}
314
315# Ménage
316rm -f ${ici}o3*${year}*.nc ${ici}ssp*${year}*.nc
317
318# Fin de la grande boucle sur les années
319done
Note: See TracBrowser for help on using the repository browser.