1 | #!/usr/bin/env python3 |
---|
2 | ### |
---|
3 | ### Script to check water conservation in the IPSL coupled model |
---|
4 | ### |
---|
5 | ## Warning, to install, configure, run, use any of included software or |
---|
6 | ## to read the associated documentation you'll need at least one (1) |
---|
7 | ## brain in a reasonably working order. Lack of this implement will |
---|
8 | ## void any warranties (either express or implied). Authors assumes |
---|
9 | ## no responsability for errors, omissions, data loss, or any other |
---|
10 | ## consequences caused directly or indirectly by the usage of his |
---|
11 | ## software by incorrectly or partially configured personal |
---|
12 | ## |
---|
13 | ## |
---|
14 | ## SVN information |
---|
15 | # $Author$ |
---|
16 | # $Date$ |
---|
17 | # $Revision$ |
---|
18 | # $Id$ |
---|
19 | # $HeadURL$ |
---|
20 | |
---|
21 | |
---|
22 | ## Define Experiment |
---|
23 | if False : |
---|
24 | JobName="TEST-CM72-SIMPLE-ROUTING.12" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
25 | Freq = 'MO' ; YearBegin = 1970 ; YearEnd = 1979 ; PackFrequency = 10 |
---|
26 | ATM = 'ICO40' ; Routing = 'SIMPLE' |
---|
27 | |
---|
28 | if False : |
---|
29 | JobName="TEST-CM72-SIMPLE-ROUTING.10" ; TagName="IPSLCM7" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
30 | Freq = 'MO' ; YearBegin = 1860 ; YearEnd = 1869 ; PackFrequency = 10 |
---|
31 | ATM = 'ICO40' ; Routing = 'SIMPLE' |
---|
32 | |
---|
33 | if False : |
---|
34 | JobName="VALID-CM622-LR.01" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p86caub" ; Project="gencmip6" |
---|
35 | Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10 |
---|
36 | ATM = 'LMD144142' ; Routing = 'ORCHIDEE' |
---|
37 | |
---|
38 | if True : |
---|
39 | JobName="CM65v420-LR-SKL-pi-05" ; TagName="IPSLCM6" ; SpaceName="DEVT" ; ExperimentName="piControl" ; User="p48ethe" ; Project="gencmip6" |
---|
40 | Freq = 'MO' ; YearBegin = 1890 ; YearEnd = 1899 ; PackFrequency = 10 |
---|
41 | ORCA = 'eORCA1.2' ; ATM = 'LMD144142' ; Routing = 'ORCHIDEE' ; NEMO=4.2 ; OCE_relax = False ; OCE_icb = False ; Coupled = True |
---|
42 | |
---|
43 | Coupled = True |
---|
44 | |
---|
45 | import numpy as np |
---|
46 | ##-- Some physical constants |
---|
47 | #-- Earth Radius |
---|
48 | Ra = 40.e6 / (2. * np.pi) |
---|
49 | #-- Gravity |
---|
50 | g = 9.81 |
---|
51 | #-- Ice density (kg/m3) in LIM3 |
---|
52 | ICE_rho_ice = 917.0 |
---|
53 | #-- Snow density (kg/m3) in LIM3 |
---|
54 | ICE_rho_sno = 330.0 |
---|
55 | #-- Ocean water density (kg/m3) in NEMO |
---|
56 | OCE_rho_liq = 1026. |
---|
57 | |
---|
58 | ### |
---|
59 | ICO = False |
---|
60 | if 'ICO' in ATM : ICO = True |
---|
61 | LMDZ = False |
---|
62 | if 'LMD' in ATM : LMDZ = True |
---|
63 | |
---|
64 | ### |
---|
65 | ## Import system modules |
---|
66 | import sys, os, shutil, subprocess |
---|
67 | |
---|
68 | # Where do we run ? |
---|
69 | TGCC = False ; IDRIS = False |
---|
70 | SysName, NodeName, Release, Version, Machine = os.uname() |
---|
71 | if 'irene' in NodeName : TGCC = True |
---|
72 | if 'jeanzay' in NodeName : IDRIS = True |
---|
73 | |
---|
74 | ## Set site specific libIGCM directories, and other specific stuff |
---|
75 | if TGCC : |
---|
76 | CPU = subprocess.getoutput ( 'lscpu | grep "Model name"' ) |
---|
77 | if "Intel(R) Xeon(R) Platinum" in CPU : Machine = 'irene' |
---|
78 | if "AMD" in CPU : Machine = 'irene-amd' |
---|
79 | |
---|
80 | ARCHIVE = subprocess.getoutput ( f'ccc_home --cccstore -d {Project} -u {User}' ) |
---|
81 | STORAGE = subprocess.getoutput ( f'ccc_home --cccwork -d {Project} -u {User}' ) |
---|
82 | SCRATCHDIR = subprocess.getoutput ( f'ccc_home --cccscratch -d {Project} -u {User}' ) |
---|
83 | R_IN = os.path.join ( subprocess.getoutput ( f'ccc_home --cccwork -d igcmg -u igcmg' ), 'IGCM') |
---|
84 | rebuild = os.path.join ( subprocess.getoutput ( f'ccc_home --ccchome -d igcmg -u igcmg' ), 'Tools', Machine, 'rebuild_nemo', 'bin', 'rebuild_nemo' ) |
---|
85 | |
---|
86 | ## Specific to run at TGCC. |
---|
87 | # Needed before importing a NetCDF library (netCDF4, xarray, cmds, etc ...) |
---|
88 | import mpi4py |
---|
89 | mpi4py.rc.initialize = False |
---|
90 | |
---|
91 | ## Creates output directory |
---|
92 | TmpDir = os.path.join ( subprocess.getoutput ( 'ccc_home --cccscratch' ), f'WATER_{JobName}_{YearBegin}_{YearEnd}' ) |
---|
93 | |
---|
94 | if IDRIS : |
---|
95 | raise Exception("Pour IDRIS : repertoires et chemins a definir") |
---|
96 | |
---|
97 | ## Import specific module |
---|
98 | import nemo, lmdz |
---|
99 | ## Now import needed scientific modules |
---|
100 | import xarray as xr |
---|
101 | |
---|
102 | # Output file |
---|
103 | FileOut = f'ATM_waterbudget_{JobName}_{YearBegin}_{YearEnd}.out' |
---|
104 | f_out = open ( FileOut, mode = 'w' ) |
---|
105 | |
---|
106 | # Function to print to stdout *and* output file |
---|
107 | def echo (string) : |
---|
108 | print ( string ) |
---|
109 | f_out.write ( string + '\n' ) |
---|
110 | f_out.flush () |
---|
111 | return None |
---|
112 | |
---|
113 | ## Set libIGCM directories |
---|
114 | R_OUT = os.path.join ( ARCHIVE , 'IGCM_OUT') |
---|
115 | R_BUF = os.path.join ( SCRATCHDIR, 'IGCM_OUT') |
---|
116 | |
---|
117 | L_EXP = os.path.join (TagName, SpaceName, ExperimentName, JobName) |
---|
118 | R_SAVE = os.path.join ( R_OUT, L_EXP ) |
---|
119 | R_BUFR = os.path.join ( R_BUF, L_EXP ) |
---|
120 | POST_DIR = os.path.join ( R_BUF, L_EXP, 'Out' ) |
---|
121 | REBUILD_DIR = os.path.join ( R_BUF, L_EXP, 'REBUILD' ) |
---|
122 | R_BUF_KSH = os.path.join ( R_BUFR, 'Out' ) |
---|
123 | R_FIGR = os.path.join ( STORAGE, 'IGCM_OUT', L_EXP ) |
---|
124 | |
---|
125 | #if os.path.isdir (TmpDir) : shutil.rmtree ( TmpDir ) |
---|
126 | if not os.path.isdir (TmpDir) : os.mkdir (TmpDir) |
---|
127 | TmpDirOCE = os.path.join (TmpDir, 'OCE') |
---|
128 | TmpDirICE = os.path.join (TmpDir, 'ICE') |
---|
129 | if not os.path.exists (TmpDirOCE) : os.mkdir (TmpDirOCE ) |
---|
130 | if not os.path.exists (TmpDirICE) : os.mkdir (TmpDirICE ) |
---|
131 | |
---|
132 | echo ( f'Working in TMPDIR : {TmpDir}' ) |
---|
133 | |
---|
134 | echo ( f'\nDealing with {L_EXP}' ) |
---|
135 | |
---|
136 | #-- Model output directories |
---|
137 | if Freq == "MO" : FreqDir = os.path.join ('Output' , 'MO' ) |
---|
138 | if Freq == "SE" : FreqDir = os.path.join ('Analyse', 'SE' ) |
---|
139 | dir_ATM_his = os.path.join ( R_SAVE, "ATM", FreqDir ) |
---|
140 | dir_SRF_his = os.path.join ( R_SAVE, "SRF", FreqDir ) |
---|
141 | |
---|
142 | echo ( f'The analysis relies on files from the following model output directories : ' ) |
---|
143 | echo ( f'{dir_ATM_his}' ) |
---|
144 | echo ( f'{dir_SRF_his}' ) |
---|
145 | |
---|
146 | #-- Files Names |
---|
147 | if Freq == 'MO' : File = f'{JobName}_{YearBegin}0101_{YearEnd}1231_1M' |
---|
148 | if Freq == 'SE' : File = f'{JobName}_SE_{YearBegin}0101_{YearEnd}1231_1M' |
---|
149 | |
---|
150 | echo ('\nOpen history files' ) |
---|
151 | file_ATM_his = os.path.join ( dir_ATM_his, f'{File}_histmth.nc' ) |
---|
152 | file_SRF_his = os.path.join ( dir_SRF_his, f'{File}_sechiba_history.nc' ) |
---|
153 | |
---|
154 | d_ATM_his = xr.open_dataset ( file_ATM_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
155 | d_SRF_his = xr.open_dataset ( file_SRF_his, use_cftime=True, decode_times=True, decode_cf=True ).squeeze() |
---|
156 | |
---|
157 | echo ( file_ATM_his ) |
---|
158 | echo ( file_SRF_his ) |
---|
159 | |
---|
160 | ## Compute run length |
---|
161 | dtime = ( d_ATM_his.time_counter_bounds.max() - d_ATM_his.time_counter_bounds.min() ) |
---|
162 | echo ('\nRun length : {:8.2f} days'.format ( (dtime/np.timedelta64(1, "D")).values ) ) |
---|
163 | dtime_sec = (dtime/np.timedelta64(1, "s")).values.item() # Convert in seconds |
---|
164 | |
---|
165 | ## Compute length of each period |
---|
166 | dtime_per = (d_ATM_his.time_counter_bounds[:,-1] - d_ATM_his.time_counter_bounds[:,0] ) |
---|
167 | echo ('\nPeriods lengths (days) : {:} days'.format ( (dtime_per/np.timedelta64(1, "D")).values ) ) |
---|
168 | dtime_per_sec = (dtime_per/np.timedelta64(1, "s")).values # In seconds |
---|
169 | dtime_per_sec = xr.DataArray (dtime_per_sec, dims=["time_counter", ], coords=[d_ATM_his.time_counter,] ) |
---|
170 | |
---|
171 | #-- Open restart files |
---|
172 | YearRes = YearBegin - 1 # Year of the restart of beginning of simulation |
---|
173 | YearPre = YearBegin - PackFrequency # Year to find the tarfile of the restart of beginning of simulation |
---|
174 | |
---|
175 | echo (f'Restart dates - Start : {YearRes}-12-31 / End : {YearEnd}-12-31 ') |
---|
176 | |
---|
177 | file_restart_beg = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearPre}0101_{YearRes}1231_restart.tar' ) |
---|
178 | file_restart_end = os.path.join ( R_SAVE, 'RESTART', f'{JobName}_{YearBegin}0101_{YearEnd}1231_restart.tar' ) |
---|
179 | |
---|
180 | echo ( f'{file_restart_beg}' ) |
---|
181 | echo ( f'{file_restart_end}' ) |
---|
182 | |
---|
183 | file_ATM_beg = f'ATM_{JobName}_{YearRes}1231_restartphy.nc' |
---|
184 | file_ATM_end = f'ATM_{JobName}_{YearEnd}1231_restartphy.nc' |
---|
185 | if LMDZ : |
---|
186 | file_DYN_beg = f'ATM_{JobName}_{YearRes}1231_restart.nc' |
---|
187 | file_DYN_end = f'ATM_{JobName}_{YearEnd}1231_restart.nc' |
---|
188 | if ICO : |
---|
189 | file_DYN_beg = f'ICO_{JobName}_{YearRes}1231_restart.nc' |
---|
190 | file_DYN_end = f'ICO_{JobName}_{YearEnd}1231_restart.nc' |
---|
191 | file_SRF_beg = f'SRF_{JobName}_{YearRes}1231_sechiba_rest.nc' |
---|
192 | file_SRF_end = f'SRF_{JobName}_{YearEnd}1231_sechiba_rest.nc' |
---|
193 | liste_beg = [file_ATM_beg, file_DYN_beg, file_SRF_beg, ] |
---|
194 | liste_end = [file_ATM_end, file_DYN_end, file_SRF_end, ] |
---|
195 | echo ( f'{file_ATM_beg}') |
---|
196 | echo ( f'{file_ATM_end}') |
---|
197 | echo ( f'{file_SRF_beg}') |
---|
198 | echo ( f'{file_SRF_end}') |
---|
199 | |
---|
200 | if Routing == 'SIMPLE' : |
---|
201 | file_RUN_beg = f'SRF_{JobName}_{YearRes}1231_routing_restart.nc' |
---|
202 | file_RUN_end = f'SRF_{JobName}_{YearEnd}1231_routing_restart.nc' |
---|
203 | liste_beg.append ( file_RUN_beg ) |
---|
204 | liste_end.append ( file_RUN_end ) |
---|
205 | echo ( f'{file_RUN_beg}') |
---|
206 | echo ( f'{file_RUN_end}') |
---|
207 | |
---|
208 | echo ('\nExtract restart files from tar : ATM, ICO and SRF') |
---|
209 | for resFile in liste_beg : |
---|
210 | if not os.path.exists ( os.path.join (TmpDir, resFile) ) : |
---|
211 | command = f'cd {TmpDir} ; tar xf {file_restart_beg} {resFile}' |
---|
212 | echo ( command ) |
---|
213 | os.system ( command ) |
---|
214 | |
---|
215 | for resFile in liste_end : |
---|
216 | if not os.path.exists ( os.path.join (TmpDir, resFile) ) : |
---|
217 | command = f'cd {TmpDir} ; tar xf {file_restart_end} {resFile}' |
---|
218 | echo ( command ) |
---|
219 | os.system ( command ) |
---|
220 | |
---|
221 | echo ('\nOpening ATM SRF and ICO restart files') |
---|
222 | d_ATM_beg = xr.open_dataset ( os.path.join (TmpDir, file_ATM_beg), decode_times=False, decode_cf=True).squeeze() |
---|
223 | d_ATM_end = xr.open_dataset ( os.path.join (TmpDir, file_ATM_end), decode_times=False, decode_cf=True).squeeze() |
---|
224 | d_SRF_beg = xr.open_dataset ( os.path.join (TmpDir, file_SRF_beg), decode_times=False, decode_cf=True).squeeze() |
---|
225 | d_SRF_end = xr.open_dataset ( os.path.join (TmpDir, file_SRF_end), decode_times=False, decode_cf=True).squeeze() |
---|
226 | d_DYN_beg = xr.open_dataset ( os.path.join (TmpDir, file_DYN_beg), decode_times=False, decode_cf=True).squeeze() |
---|
227 | d_DYN_end = xr.open_dataset ( os.path.join (TmpDir, file_DYN_end), decode_times=False, decode_cf=True).squeeze() |
---|
228 | |
---|
229 | for var in d_SRF_beg.variables : |
---|
230 | #d_SRF_beg[var].attrs['_FillValue'] = 1.e20 |
---|
231 | #d_SRF_end[var].attrs['_FillValue'] = 1.e20 |
---|
232 | d_SRF_beg[var] = d_SRF_beg[var].where ( d_SRF_beg[var]<1.e20, 0.) |
---|
233 | d_SRF_end[var] = d_SRF_end[var].where ( d_SRF_end[var]<1.e20, 0.) |
---|
234 | |
---|
235 | if ICO : |
---|
236 | d_RUN_beg = xr.open_dataset ( os.path.join (TmpDir, file_RUN_beg), decode_times=False, decode_cf=True).squeeze() |
---|
237 | d_RUN_end = xr.open_dataset ( os.path.join (TmpDir, file_RUN_end), decode_times=False, decode_cf=True).squeeze() |
---|
238 | |
---|
239 | echo ( file_ATM_beg ) |
---|
240 | echo ( file_ATM_end ) |
---|
241 | echo ( file_DYN_beg ) |
---|
242 | echo ( file_DYN_end ) |
---|
243 | echo ( file_SRF_beg ) |
---|
244 | echo ( file_SRF_end ) |
---|
245 | if Routing == 'SIMPLE' : |
---|
246 | echo ( file_RUN_beg ) |
---|
247 | echo ( file_RUN_end ) |
---|
248 | |
---|
249 | # ATM grid with cell surfaces |
---|
250 | if ICO : |
---|
251 | ATM_aire = d_ATM_his ['aire'][0] |
---|
252 | ATM_fsea = d_ATM_his ['fract_ter'][Ã] + d_ATM_his ['fract_sic'][Ã] |
---|
253 | if LMDZ : |
---|
254 | ATM_aire = lmdz.geo2point ( d_ATM_his ['aire'][0] ) |
---|
255 | ATM_fsea = lmdz.geo2point ( d_ATM_his ['fract_ter'][0] + d_ATM_his ['fract_sic'][0] ) |
---|
256 | ATM_aire[0] = np.sum ( d_ATM_his ['aire'][0, 0] ) |
---|
257 | ATM_aire[-1] = np.sum ( d_ATM_his ['aire'][0,-1] ) |
---|
258 | |
---|
259 | if ICO : |
---|
260 | file_DYN_aire = os.path.join ( R_IN, 'ATM', 'GRID', ATM+'_grid.nc' ) |
---|
261 | d_DYN_aire = xr.open_dataset ( file_DYN_aire, decode_times=False).squeeze() |
---|
262 | d_DYN_aire = d_DYN_aire.rename( {'cell':'cell_mesh'}) |
---|
263 | DYN_aire = d_DYN_aire['aire'] |
---|
264 | if LMDZ : |
---|
265 | DYN_aire = ATM_aire |
---|
266 | |
---|
267 | #if LMDZ : |
---|
268 | # d_ATM_beg = d_ATM_beg.assign ( coords={'lon':d_ATM_beg.lon*180./np.pi} ) |
---|
269 | |
---|
270 | ATM_aire_tot = np.sum (ATM_aire).values.item() |
---|
271 | ATM_aire_sea_tot = np.sum (ATM_aire*ATM_fsea).values.item() |
---|
272 | |
---|
273 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
274 | echo ( '-- LMDZ changes in stores (for the records)' ) |
---|
275 | |
---|
276 | #-- Change in precipitable water from the atmosphere daily and monthly files |
---|
277 | #-- Compute sum weighted by gridcell area (kg/m2) then convert to Sv |
---|
278 | |
---|
279 | # ATM vertical grid |
---|
280 | ATM_Ahyb = d_ATM_his['Ahyb'].squeeze() |
---|
281 | ATM_Bhyb = d_ATM_his['Bhyb'].squeeze() |
---|
282 | klevp1 = ATM_Ahyb.shape[0] |
---|
283 | |
---|
284 | # Surface pressure |
---|
285 | if ICO : |
---|
286 | ATM_ps_beg = d_DYN_beg['ps'] |
---|
287 | ATM_ps_end = d_DYN_end['ps'] |
---|
288 | |
---|
289 | if LMDZ : |
---|
290 | ATM_ps_beg = lmdz.geo2point ( d_DYN_beg['ps'].isel(rlonv=slice(0,-1)) ) |
---|
291 | ATM_ps_end = lmdz.geo2point ( d_DYN_end['ps'].isel(rlonv=slice(0,-1)) ) |
---|
292 | |
---|
293 | # 3D Pressure |
---|
294 | ATM_p_beg = ATM_Ahyb + ATM_Bhyb * ATM_ps_beg |
---|
295 | ATM_p_end = ATM_Ahyb + ATM_Bhyb * ATM_ps_end |
---|
296 | |
---|
297 | # Layer thickness |
---|
298 | ATM_sigma_beg = ATM_p_beg[0:-1]*0. |
---|
299 | ATM_sigma_end = ATM_p_end[0:-1]*0. |
---|
300 | |
---|
301 | for k in np.arange (klevp1-1) : |
---|
302 | ATM_sigma_beg[k,:] = (ATM_p_beg[k,:] - ATM_p_beg[k+1,:]) / g |
---|
303 | ATM_sigma_end[k,:] = (ATM_p_end[k,:] - ATM_p_end[k+1,:]) / g |
---|
304 | |
---|
305 | ATM_sigma_beg = ATM_sigma_beg.rename ( {'klevp1':'sigs'} ) |
---|
306 | ATM_sigma_end = ATM_sigma_end.rename ( {'klevp1':'sigs'} ) |
---|
307 | |
---|
308 | ##-- Vertical and horizontal integral, and sum of liquid, solid and vapor water phases |
---|
309 | if LMDZ : |
---|
310 | try : |
---|
311 | ATM_wat_beg = lmdz.geo3point ( (d_DYN_beg['H2Ov'] + d_DYN_beg['H2Ol'] + d_DYN_beg['H2Oi']).isel(rlonv=slice(0,-1) ) ) |
---|
312 | ATM_wat_end = lmdz.geo3point ( (d_DYN_end['H2Ov'] + d_DYN_end['H2Ol'] + d_DYN_end['H2Oi']).isel(rlonv=slice(0,-1) ) ) |
---|
313 | except : |
---|
314 | ATM_wat_beg = lmdz.geo3point ( (d_DYN_beg['H2O_g'] + d_DYN_beg['H2O_l'] + d_DYN_beg['H2O_s']).isel(rlonv=slice(0,-1) ) ) |
---|
315 | ATM_wat_end = lmdz.geo3point ( (d_DYN_end['H2O_g'] + d_DYN_end['H2O_l'] + d_DYN_end['H2O_s']).isel(rlonv=slice(0,-1) ) ) |
---|
316 | if ICO : |
---|
317 | ATM_wat_beg = ( d_DYN_beg['q'][0:4] ).sum (dim = ['nq',] ).rename ( {'lev':'sigs'} ) |
---|
318 | ATM_wat_end = ( d_DYN_end['q'][0:4] ).sum (dim = ['nq',] ).rename ( {'lev':'sigs'} ) |
---|
319 | |
---|
320 | ATM_mas_wat_beg = np.sum (ATM_sigma_beg * ATM_wat_beg * ATM_aire).values.item() |
---|
321 | ATM_mas_wat_end = np.sum (ATM_sigma_end * ATM_wat_end * ATM_aire).values.item() |
---|
322 | |
---|
323 | dATM_mas_wat = ATM_mas_wat_end - ATM_mas_wat_beg |
---|
324 | |
---|
325 | echo ( 'Variation du contenu en eau atmosphere ' ) |
---|
326 | echo ( 'ATM_mass_beg = {:12.6e} kg - ATM_mass_end = {:12.6e} kg'.format (ATM_mas_wat_beg, ATM_mas_wat_end) ) |
---|
327 | echo ( 'dMass(atm) = {:12.3e} kg '.format (dATM_mas_wat) ) |
---|
328 | echo ( 'dMass(atm) = {:12.3e} Sv '.format (dATM_mas_wat/dtime_sec*1.E-9) ) |
---|
329 | echo ( 'dMass(atm) = {:12.3e}m '.format (dATM_mas_wat/ATM_aire_sea_tot*1E-3) ) |
---|
330 | |
---|
331 | ATM_sno_beg = d_ATM_beg['SNOW01']*d_ATM_beg['FTER']+d_ATM_beg['SNOW02']*d_ATM_beg['FLIC']+d_ATM_beg['SNOW03']*d_ATM_beg['FOCE']+d_ATM_beg['SNOW04']*d_ATM_beg['FSIC'] |
---|
332 | ATM_sno_end = d_ATM_end['SNOW01']*d_ATM_end['FTER']+d_ATM_end['SNOW02']*d_ATM_end['FLIC']+d_ATM_end['SNOW03']*d_ATM_end['FOCE']+d_ATM_end['SNOW04']*d_ATM_end['FSIC'] |
---|
333 | if ICO : |
---|
334 | ATM_sno_beg = ATM_sno_beg.rename ( {'points_physiques':'cell_mesh'} ) |
---|
335 | ATM_sno_end = ATM_sno_end.rename ( {'points_physiques':'cell_mesh'} ) |
---|
336 | |
---|
337 | ATM_mas_sno_beg = np.sum ( ATM_sno_beg * DYN_aire ).values.item() |
---|
338 | ATM_mas_sno_end = np.sum ( ATM_sno_end * DYN_aire ).values.item() |
---|
339 | |
---|
340 | dATM_mas_sno = ATM_mas_sno_end - ATM_mas_sno_beg |
---|
341 | |
---|
342 | echo ( 'Variation du contenu en neige atmosphere ' ) |
---|
343 | echo ( 'ATM_mas_sno_beg = {:12.6e} kg - ATM_mas_sno_end = {:12.6e} kg'.format (ATM_mas_sno_beg, ATM_mas_sno_end) ) |
---|
344 | echo ( 'dMass(neige atm) = {:12.3e} kg '.format (dATM_mas_sno) ) |
---|
345 | echo ( 'dMass(neige atm) = {:12.3e} Sv '.format (dATM_mas_sno/dtime_sec*1E-6/ICE_rho_ice) ) |
---|
346 | echo ( 'dMass(neige atm) = {:12.3e} m '.format (dATM_mas_sno/ATM_aire_sea_tot*1E-3) ) |
---|
347 | |
---|
348 | echo ( '\nVariation du contenu en eau+neige atmosphere ' ) |
---|
349 | echo ( 'dMass(eau + neige atm) = {:12.3e} kg '.format ( dATM_mas_wat + dATM_mas_sno) ) |
---|
350 | echo ( 'dMass(eau + neige atm) = {:12.3e} Sv '.format ( (dATM_mas_wat + dATM_mas_sno)/dtime_sec*1E-9) ) |
---|
351 | echo ( 'dMass(eau + neige atm) = {:12.3e} m '.format ( (dATM_mas_wat + dATM_mas_sno)/ATM_aire_sea_tot*1E-3) ) |
---|
352 | |
---|
353 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
354 | echo ( '-- SRF changes in routing reservoirs' ) |
---|
355 | |
---|
356 | if Routing == 'SIMPLE' : |
---|
357 | RUN_mas_wat_beg = np.sum ( d_RUN_beg ['fast_reservoir'] + d_RUN_beg ['slow_reservoir'] + d_RUN_beg ['stream_reservoir']).values.item() |
---|
358 | RUN_mas_wat_end = np.sum ( d_RUN_end ['fast_reservoir'] + d_RUN_end ['slow_reservoir'] + d_RUN_end ['stream_reservoir']).values.item() |
---|
359 | |
---|
360 | if Routing == 'ORCHIDEE' : |
---|
361 | RUN_mas_wat_beg = np.sum ( d_SRF_beg['fastres'] + d_SRF_beg['slowres'] + d_SRF_beg['streamres'] \ |
---|
362 | + d_SRF_beg['floodres'] + d_SRF_beg['lakeres'] + d_SRF_beg['pondres'] ) .values.item() |
---|
363 | RUN_mas_wat_end = np.sum ( d_SRF_end['fastres'] + d_SRF_end['slowres'] + d_SRF_end['streamres'] \ |
---|
364 | + d_SRF_end['floodres'] + d_SRF_end['lakeres'] + d_SRF_end['pondres'] ) .values.item() |
---|
365 | |
---|
366 | dRUN_mas_wat = RUN_mas_wat_end - RUN_mas_wat_beg |
---|
367 | |
---|
368 | echo ( '\nWater content in routing ' ) |
---|
369 | echo ( 'RUN_mas_wat_beg = {:12.6e} kg '.format (RUN_mas_wat_beg) ) |
---|
370 | echo ( 'RUN_mas_wat_end = {:12.6e} kg '.format (RUN_mas_wat_end) ) |
---|
371 | echo ( 'dMass(routing) = {:12.3e} kg '.format(dRUN_mas_wat) ) |
---|
372 | echo ( 'dMass(routing) = {:12.3e} Sv '.format(dRUN_mas_wat/dtime_sec*1E-9) ) |
---|
373 | echo ( 'dMass(routing) = {:12.3e} m '.format(dRUN_mas_wat/ATM_aire_sea_tot*1E-3) ) |
---|
374 | |
---|
375 | SRF_mas_wat_beg = d_SRF_beg['tot_watveg_beg']+d_SRF_beg['tot_watsoil_beg'] + d_SRF_beg['snow_beg'] |
---|
376 | SRF_mas_wat_end = d_SRF_end['tot_watveg_beg']+d_SRF_end['tot_watsoil_beg'] + d_SRF_end['snow_beg'] |
---|
377 | |
---|
378 | if LMDZ : |
---|
379 | SRF_mas_wat_beg = SRF_mas_wat_beg.rename ( {'y':'points_phyiques'} ) |
---|
380 | SRF_mas_wat_end = SRF_mas_wat_end.rename ( {'y':'points_phyiques'} ) |
---|
381 | if ICO : |
---|
382 | SRF_mas_wat_beg = SRF_mas_wat_beg.rename ( {'y':'cell_mesh'} ) |
---|
383 | SRF_mas_wat_end = SRF_mas_wat_end.rename ( {'y':'cell_mesh'} ) |
---|
384 | |
---|
385 | SRF_mas_wat_beg = np.sum ( SRF_mas_wat_beg * SRF_aire ).values.item() |
---|
386 | SRF_mas_wat_end = np.sum ( SRF_mas_wat_end * SRF_aire ).values.item() |
---|
387 | |
---|
388 | dSRF_mas_wat = SRF_mas_wat_end - SRF_mas_wat_beg |
---|
389 | |
---|
390 | echo ( '\nWater content in and surface ' ) |
---|
391 | echo ( 'SRF_mas_wat_beg = {:12.6e} kg - SRF_mas_wat_end = {:12.6e} kg '.format (SRF_mas_wat_beg, SRF_mas_wat_end) ) |
---|
392 | echo ( 'dMass(water srf) = {:12.3e} kg '.format (dSRF_mas_wat) ) |
---|
393 | echo ( 'dMass(water srf) = {:12.3e} Sv '.format (dSRF_mas_wat/dtime_sec*1E-9) ) |
---|
394 | echo ( 'dMass(water srf) = {:12.3e} m '.format (dSRF_mas_wat/ATM_aire_sea_tot*1E-3) ) |
---|
395 | |
---|
396 | echo ( '\n------------------------------------------------------------------------------------' ) |
---|
397 | echo ( '\nWater content in ATM + SRF + RUN ' ) |
---|
398 | echo ( 'mas_wat_beg = {:12.6e} kg '.format (ATM_mas_wat_beg + ATM_mas_sno_beg + RUN_mas_wat_beg + SRF_mas_wat_beg) ) |
---|
399 | echo ( 'mas_wat_end = {:12.6e} kg '.format (ATM_mas_wat_end + ATM_mas_sno_end + RUN_mas_wat_end + SRF_mas_wat_end) ) |
---|
400 | echo ( 'dMass(water atm+srf+run) = {:12.6e} kg '.format ( dATM_mas_wat + dATM_mas_sno + dRUN_mas_wat + dSRF_mas_wat) ) |
---|
401 | echo ( 'dMass(water atm+srf+run) = {:12.3e} Sv '.format ((dATM_mas_wat + dATM_mas_sno + dRUN_mas_wat + dSRF_mas_wat)/dtime_sec*1E-9) ) |
---|
402 | echo ( 'dMass(water atm+srf+run) = {:12.3e} m '.format ((dATM_mas_wat + dATM_mas_sno + dRUN_mas_wat + dSRF_mas_wat)/ATM_aire_sea_tot*1E-3) ) |
---|
403 | |
---|
404 | |
---|
405 | echo ( "\n-----------------" ) |
---|
406 | echo ( " Atm -> Oce fluxes" ) |
---|
407 | |
---|
408 | ATM_wbilo_sea = np.sum ( lmdz.geo2point (d_ATM_his['wbilo_oce'] + d_ATM_his['wbilo_sic'])*dtime_per_sec*ATM_aire ).values.item() |
---|
409 | ATM_runoff = np.sum ( lmdz.geo2point (d_ATM_his['runofflic'])*ATM_aire*dtime_per_sec ).values.item() |
---|
410 | ATM_calving = np.sum ( lmdz.geo2point (d_ATM_his['fqcalving'])*ATM_aire*dtime_per_sec ).values.item() |
---|
411 | |
---|
412 | echo (' wbilo oce+sic = {:12.5e} (kg) '.format ( ATM_wbilo_sea ) ) |
---|
413 | echo (' runoff liq = {:12.5e} (kg) '.format ( ATM_runoff ) ) |
---|
414 | echo (' calving = {:12.5e} (kg) '.format ( ATM_calving ) ) |
---|
415 | echo (' total = {:12.5e} (kg) '.format ( ATM_wbilo_sea - ATM_runoff - ATM_calving ) ) |
---|