rigoudyg / climaf

CliMAF - a Climate Model Analysis Framework - doc at : http://climaf.readthedocs.org/
Other
16 stars 7 forks source link

Add function xfmul and script xmul #173

Open rigoudyg opened 4 years ago

rigoudyg commented 4 years ago

xmul.py (in directory scripts) make multiplications of fields using xarray. There is no limit in the number of input files, masks and constant can also be provided. The function xfmul call this script.

It can be used to apply a mask to netcdf files containing a temporal axis. In this case, it seems that CDO discards the temporal axis...

senesis commented 4 years ago

Some items are missing :

But, maybe more important, here is what I get with CDO when multiplying a file with a time axis by a file with no time axis :

cdo mul rlds.nc msk1.nc rldsm.nc cdo mul: Filling up stream2 >msk1.nc< by copying the first timestep. cdo mul: Processed 98304 values from 2 variables over 3 timesteps [0.04s 15MB]

which weakens the rationale for the new operator

The CDO I used is :

cdo -V Climate Data Operators version 1.9.6 (http://mpimet.mpg.de/cdo)

rigoudyg commented 4 years ago

Concerning the documentation and example, I will push it once complete.

With CDO version 1.9.8, I have issues multiplying a CORDEX like file with its mask. It may be due to the input files, but I did not managed to modified the mask to obtain the result expected using CDO. With xmul, it works well.

The result of the CDO command line is the following and the output file does not contain the time line or the variable tas (only the mask variable):

cdo mul tas_MED-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN64_v1_mon_197901-201908.nc new_mask_MedSea_AAD12.nc new_tas_MED-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN64_v1_mon_197901-201908.nc Warning (cdfScanVarAttr): NetCDF: Variable not found - Lambert_Conformal Warning (cdfScanVarAttr): NetCDF: Variable not found - bounds_lon Warning (cdfScanVarAttr): NetCDF: Variable not found - bounds_lat cdo mul: Filling up stream1 >tas_MED-11_ECMWF-ERAINT_evaluation_r1i1p1_CNRM-ALADIN64_v1_mon_197901-201908.nc< by copying the first variable of each timestep. Warning (cdfCheckVarname): Changed double entry of variable name 'lon' to 'lon_2'! Warning (cdfCheckVarname): Changed double entry of variable name 'lat' to 'lat_2'! cdo mul: Processed 4 variables over 2 timesteps [0.08s 58MB].

senesis commented 4 years ago

Maybe the meaningful difference between both test is that my mask1.nc has a time dimension (of size 1). But CDO behavior in your case is odd : it tries to "fill up" the wrong stream, the one which already has a time dimension ...