Project

General

Profile

Help with pow expression

Added by John Young 8 months ago

I have 2 netcdf files

nc1="day01.nc", variable = pr_bc
nc2="exponent.nc", variable = b1
out="result.nc"

basically I want to be able to do result=nc1^nc2 i.e. pr_bc^b1

how would i do this in cdo, currently running cdo 2.0.5, gdal 3.8.3

to test I did
cdo -O expr,"result=pr_bc^100;" $nc1 $out ........... this worked

then tested
cdo -O expr,"result=pr_br^b1;" $nc1 $nc2 $out ......... this fails

then tested
cdo -O expr,"result=pr_br^$nc2;" $nc1 $out ............. this fails

help would be greatly appreciated


Replies (3)

RE: Help with pow expression - Added by Uwe Schulzweida 7 months ago

The CDO operator expr accepts only one inputfile. So, you have to merge both file:

cdo expr,'result=pr_br^b1' -merge day01.nc exponent.nc  result.nc

RE: Help with pow expression - Added by John Young 7 months ago

Thank you for the response.

The base nc, variable = pr_bc and is a daily timeseries for a year of rainfall
The exponent is a geotiff to nc, but is only a single band, not a time series

I can see how the merged works, but when I try this of course it fails due to time series.

Is there a way to apply same exponent to ever timestep??

Appreciated

RE: Help with pow expression - Added by Uwe Schulzweida 7 months ago

This should also work without any problems for all time steps. If this is not the case, we need data to test this. Can you upload an example?

    (1-3/3)