CALIPSO-project / SPINacc

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

Climate forcing file: differences in shape between 2. and 0.5 degree files #14

Closed yansun8 closed 3 years ago

yansun8 commented 3 years ago

The routine reading in climate forcing cannot deal with .5 degree forcing files. This is because the forcing files for half-degree are with a dimension of "tstep land". The number for “land” is 67420 but not 360720.

The reading routine is Tools/readvar.py ; file with .5 forcing is e.g. :/home/orchideeshare/igcmg/IGCM/SRF/METEO/CRUJRA/v2/halfdeg/

Potential solution: adjust the reading depending on the resolution, and re-shape in case of .5 degree to 360*720 at the beginning of 'readvar.py'.

vbast commented 3 years ago

The .5 degree forcing files are normally written in "compressed" form. Instead of the three dimensions (time, lat, lon) the variables have two dimensions (time, land) and the data are stored only for the land points, whereas all ocean points are just dropped. Thus, the size of the forcing file in compressed form is 4 times less.

You need to add few lines to uncompress the variable data. In readvar.py after reading the variable data in line 56 you can add the following:

  da=f[varname_clim[index]][:]
  if "land" in f[varname_clim[index]].dimensions:
    land=f["land"][:]-1
    ntime=len(da)
    nlat=len(f.dimensions["y"])
    nlon=len(f.dimensions["x"])
    uncomp=np.ma.masked_all((ntime,nlat*nlon))
    uncomp[:,land]=da
    da=uncomp.reshape((ntime,nlat,nlon))
dsgoll123 commented 3 years ago

Perfect, thanks Vlad - crash is avoided. I do some additional test before comitting the change set