CALIPSO-project / SPINacc

A spinup acceleration procedure for land surface models (LSM)
4 stars 0 forks source link

ORCHIDEEv3 : pb with clayfraction #28

Closed gaillardr closed 1 year ago

gaillardr commented 1 year ago

In ORCHIDEEv3, clayfraction is vertically discretized on the 11 hydrological layers but its value is the same for each layer. So reading only the 1st layer values is enough to get the forcing.

I propose to add it in readvar.py in 0.2 : read other variables :

# 0.2 read other variables, including Edaphic variables, N and P deposition variables 
  predvar=varlist['pred']
  for ipred in predvar.keys():
    if ipred[:3]=='var':
      f=Dataset(predvar[ipred]['sourcefile'],'r')
      vname=predvar[ipred]['variables']
      if 'rename' in predvar[ipred].keys():
        rename=predvar[ipred]['rename']
      else:
        rename=vname
      for ivar in range(len(vname)):
        check.display('reading %s...'%vname[ivar],logfile)
        if (vname[ivar]=='LAI' or vname[ivar]=='NPP' or vname[ivar]=='P_DEPOSITION') and len(f[vname[ivar]].shape)>3:
          # one can modify here to use annual mean
          check.verbose('warning: using %s at the last year'%vname[ivar],logfile)
          da=np.squeeze(f[vname[ivar]][-1])
        # N deposition fluxes miss PFT dimension
        elif (vname[ivar]=='NOY_DEPOSITION' or vname[ivar]=='NHX_DEPOSITION' ) and len(f[vname[ivar]].shape)>2:
          # one can modify here to use annual mean
          check.verbose('warning: using %s at the last year'%vname[ivar],logfile)
          da=np.squeeze(f[vname[ivar]][-1])
        elif (vname[ivar]=='clayfraction') and len(f[vname[ivar]].shape)>2:
            #if clayfraction is discretized vertically, use 1st soil layer (same value for each layer in v3) 
            check.verbose('warning: using first soil layer value for %s'%vname[ivar],logfile)
            da=np.squeeze(f[vname[ivar]][0])
        else:
          da=np.squeeze(f[vname[ivar]][:])
        if 'missing_value' in predvar[ipred].keys():
          da[da==predvar[ipred]['missing_value']]=np.nan
        if isinstance(da,np.ma.masked_array):
          packdata.__dict__[rename[ivar]]=da.filled(np.nan)
        else:
          packdata.__dict__[rename[ivar]]=da
dsgoll123 commented 1 year ago

I agree. the proposed changes are committed in commit: ae12f086da1de451458fc623599d8e3eb8ecaff6