CALIPSO-project / SPINacc

A spinup acceleration procedure for land surface models (LSM) . Developer team Mandresy Rasolonjatovo, Tianzhang Cai, Matthew Archer, Daniel Goll
4 stars 0 forks source link

ORCHIDEE-MICT: som #16

Open dsgoll123 opened 3 years ago

dsgoll123 commented 3 years ago

The Tool cannot handle read in the information in the stomate restart file for som of MICT (see the DEF_MICT/varlist.json for paths on obelix)

The info is is stored in a single variable (i.e. carbon) for MICT in the restart instead of multiple variables (i.e. carbon_* ) as for e.g. trunk.

changjf-github commented 3 years ago

There are several other variables that stored soil carbon content for restarting MICT. Here are the variables and their dimensions: carbon(time, l_d, z_d, y, x): total soil carbon of the whole soil profile for 3 pools (active, slow and passive); dimension: (1 time-step, 19 PFTs, 3 soil pools, 360, 720) deepC_a(time, l_d, z_h, y, x): active soil carbon pool for different soil layers; dimension: (1 time-step, 19 PFTs, 32 soil layers, 360, 720) deepC_s(time, l_d, z_h, y, x): slow soil carbon pool for different soil layers; dimension: (1 time-step, 19 PFTs, 32 soil layers, 360, 720) deepC_p(time, l_d, z_h, y, x): passive soil carbon pool for different soil layers; dimension: (1 time-step, 19 PFTs, 32 soil layers, 360, 720) biomass(time, m_a, l_a, z_a, y, x) : vegetation pool dimension: (1 time-step, 1 nelements (carbon), 8 nparts (ileaf, isapabove, isapbelow, iheartabove, ihartbelow, iroot, ifruit, icarbres), 19 PFTs, 360, 720) litter(time, n_a, m_b, l_d, z_b, y, x): litter pool dimension: (1 time-step,1 nelements (carbon), 2 nlevs (above/below), 19 PFTs, 2 nlitt (metabolic/structure) 360, 720)

Here are the depth of the 32 nodes, and the depth of the bottom of each layer: Depth of the nodes in thermosoil (m): znt= 4.887585535000000E-004 1.955034214000000E-003 5.865102642000001E-003 1.368523949800000E-002 2.932551321000000E-002 6.060606063400000E-002 0.123167155482000 0.248289345178000 0.498533724570000 0.999022483354000 1.74975562060800 2.50048875878400 3.50146627635200 4.55249266979840 5.65607038291712 6.81482698169178 8.03152141040517 9.30905056055422 10.6504561682107 12.0589320562501 13.5378317386914 15.0906764052547 16.7211633051463 18.4331745500324 20.2307863571628 22.1182787546498 24.1001457720111 26.1811061402404 28.3661145268812 30.6603733328541 33.0693450791256 35.5987654127107 Depth of lower layer-interface for thermosoil (m): zlt= 9.775171070000000E-004 3.910068428000000E-003 9.775171070000001E-003 2.150537635400000E-002 4.496578692200000E-002 9.188660805800000E-002 0.185728250330000 0.373411534874000 0.748778103962000 1.49951124167700 2.00000000000000 3.00097751756800 4.02697947307520 5.10428152635776 6.23544868230445 7.42317419604847 8.67028598547969 9.97975336438248 11.3546941122304 12.7983818974707 14.3142540719731 15.9059198552005 17.5771689275893 19.3319804535976 21.1745325559063 23.1092122633304 25.1406259561257 27.2736103335608 29.5132439298677 31.8648592059899 34.3340552459182 38.0000000000000

Note: Not sure if the code can be suitable for applying over different layers. It should be noted that deep soil pools may be more affected by the root depth, root distribution, and factors impacting vertical transport.

vbast commented 3 years ago

I would suggest to change the syntax in varlist.json used to define the variables to be read from restart files. The syntax should be universal and independent from the variable structure, so that for example the PFT can be either the part of its name or the part of its dimensions. And it should be applicable to any variable (carbon, litter, biomass or other). For that the variable definition should represent the full mask for its name and dimensions in the way it is meant to be read from netcdf file by python code.

For simplicity I demonstrate it below using python dictionaries (to drop all other json data). For example, to read carbon pools from ORCHIDEE_2 you define variable as follows:

var = { "name":"['carbon_%(pft)02d'][:,%(pool)s,:,:]", "items":["pft","pool"], "pft":[2,3,4,5,6,7,8,9,10,11,12,13,14,15], "pool":[0,1,2] }

to read carbon pools from ORCHIDEE_MICT:

var = { "name":"['carbon'][:,%(pft)s,%(pool)s,:,:]", "items":["pft","pool"], "pft":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], "pool":[0,1,2] }

to read litter from ORCHIDEE_2:

var = { "name":"['litter%(pft)02d%(part)s'][:,%(zb)s,:,:]", "items":["pft","part","zb"], "pft":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], "part":["ab","be"], "zb":[0,1] }

to read litter from ORCHIDEE_MICT:

var = { "name":"['litter'][:,%(na)s,%(mb)s,%(pft)s,%(zb)s,:,:]", "items":["na","mb","pft","zb"], "na":[0], "mb":[0,1], "pft":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19], "zb":[0,1] }

In these examples the first square brackets of 'name' represent the variable name in restart file, the second - its dimensions. You can have any arbitrary number of iterable items, but you just need to define them in the attribute "items". The particular name you put for an item does not matter, but it should be defined as well with all possible values given in the corresponding array. Note also, that in the first example I put the mask "%(pft)02d", meaning that one-digit PFT number should contain a leading zero in the resulting variable name.

Then of course the reading part should be re-implemented. First, you need to define all item combinations, this can be easily done with 'product' function from 'itertools' library:

import itertools combs = list(itertools.product(*[var[item] for item in var["items"]]))

And then you can loop over those combinations and read variable data from restart file one-by-one, and each time you get a 3D-array with dimensions [time,lat,lon]:

responseY=Dataset(varlist['resp']['sourcefile'],'r') for comb in combs: subitems = {item:comb[idx] for idx,item in enumerate(items)} readvar = var["name"] % subitems vardata = exec("responseY"+readvar)

The rest is to write the resulting vardata into the code variables. I'm not yet familiar with the code enough to be able to do that. Do you have someone to apply it? Of course if you accept the idea?