Skip to content

Add function xfmul and script xmul#173

Open
rigoudyg wants to merge 1 commit intoV2.0.2from
V2.0.0_xfmul
Open

Add function xfmul and script xmul#173
rigoudyg wants to merge 1 commit intoV2.0.2from
V2.0.0_xfmul

Conversation

@rigoudyg
Copy link
Owner

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...

This was needed when wanted to apply a mask to a file with a temporal axis.
cdo seems to keep only the first time step...
@rigoudyg rigoudyg requested review from jservonnat and senesis August 18, 2020 10:01
@senesis
Copy link
Collaborator

senesis commented Aug 19, 2020

Some items are missing :

  • a file doc/scripts/xfmul.rst providing a description of the new operator
  • an entry in new.rst
  • an maybe an example in dir examples/

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
Copy link
Owner Author

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
Copy link
Collaborator

senesis commented Aug 20, 2020

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 ...

@rigoudyg rigoudyg force-pushed the V2.0.0 branch 6 times, most recently from 610370a to 9454f68 Compare January 11, 2021 09:58
@rigoudyg rigoudyg changed the base branch from V2.0.0 to V2.0.2 November 29, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants