Project

General

Profile

Calculating the average of several NETCDF files

Added by nazanin tavakoli over 3 years ago

Hello,
I have 37 cloud cover data in different levels, and I want to calculate the average of the cc variable in these NetCDF files. I have used the following code:
#!/usr/bin/env bash
cdo -add 1000.nc -add 975.nc -add 950.nc 925.nc f1.nc
cdo -add 900.nc -add 875.nc -add 850.nc 825.nc f2.nc
cdo -add 800.nc -add 775.nc -add 750.nc 700.nc f3.nc
cdo -add 600.nc -add 500.nc -add 650.nc 550.nc f4.nc
cdo -add 400.nc -add 300.nc -add 450.nc 350.nc f5.nc
cdo -add 200.nc -add 175.nc -add 250.nc 225.nc f6.nc
cdo -add 100.nc -add 70.nc -add 150.nc 125.nc f7.nc
cdo -add 30.nc -add 50.nc -add 20.nc 10.nc f8.nc
cdo -add 3.nc -add 5.nc -add 7.nc 2.nc f9.nc
cdo -add f1.nc -add f2.nc -add f3.nc f4.nc final_1.nc
cdo -add f5.nc -add f6.nc -add f7.nc f8.nc final_2.nc
cdo -add f9.nc -add 1.nc -add final_1.nc final_2.nc final.nc
cdo divc,37 final.nc c.nc

but I have this error:
cdo add (Warning): Some data values (min=-32766 max=69913) are outside the
valid range (-32768 - 32767) of the used output precision!
Use the CDO option -b 32 or -b 64 to increase the output precision.
cdf_put_vara_double: name=cc type=NC_SHORT minval=-32766.000000 maxval=69913.000000

Error (cdf_put_vara_double): NetCDF: Numeric conversion not representable
cdo add: Started child process "add 875.nc -add 850.nc 825.nc (pipe1.1)".
cdo(2) add: Started child process "add 850.nc 825.nc (pipe2.1)".
cdo add (Warning): Some data values (min=-32766 max=85829) are outside the
valid range (-32768 - 32767) of the used output precision!
Use the CDO option -b 32 or -b 64 to increase the output precision.
cdf_put_vara_double: name=cc type=NC_SHORT minval=-32766.000000 maxval=85829.000000

Could somebody help me to handle this problem?


Replies (2)

RE: Calculating the average of several NETCDF files - Added by Ralf Mueller over 3 years ago

hi!

the problem is that your data type (short) together with the given values in your inputs is too small to hold the sum of all these values.

One possible solution is already given by CDO itself:

Use the CDO option -b 32 or -b 64 to increase the output precision.

Another options is to convert to double. check

 cdo -h
for all the possible options.

cheers
ralf

RE: Calculating the average of several NETCDF files - Added by nazanin tavakoli over 3 years ago

Thank you for your help.
Adding -b 32 has solved the problem.

    (1-2/2)