Changing units and values Precipitation and temperature
Added by Jeisson Javier Leal Rojas over 1 year ago
Hi.
I just want to check if the steps I will show are correct or not.
I want to convert temperature in Kelvin to Celsious, as well as changing the units from K to degC.
Same goes for precipitation. Precipitation is given in kg m-2 s-1 and I want it in mm/day, as well as changing units.
This is what I've done
1) For temperature:
cdo subc, 273.15 input.nc output.nc
cdo -setattribute,temp@units=degC output.nc final_output.nc
2) For Precipitation:
cdo mulc, 86400 input.nc output.nc
cdo -setattribute,pre@units=mm/day output.nc final_output.nc
I think what I am doing is ok. However, I would like to ask if there are other simpler or shorter way to do it, or if I am wrong somehow.
Regards,
Jeisson Leal.
Replies (5)
RE: Changing units and values Precipitation and temperature - Added by Karin Meier-Fleischer over 1 year ago
You can use the operator chaining:
1) e.g. for temperature variable 'temp'
cdo -setattribute,temp@units="degC" -subc,273.15 -selname,temp input.nc temp_output.nc
2) e.g. for precipitation variable 'pre'
cdo -setattribute,pre@units="mm/day" -mulc,86400 input.nc pre_output.nc
RE: Changing units and values Precipitation and temperature - Added by Jeisson Javier Leal Rojas over 1 year ago
Why is it different from each one? I mean for temperature `-selname` is used, but not for precipitation
RE: Changing units and values Precipitation and temperature - Added by Karin Meier-Fleischer over 1 year ago
Sorry, I forgot to explain. If a data file contains only one data variable you do not need to use -selname,variable but if there are multiple variables the computation like for -mulc,86400 or -subc,273.15 would be executed for each data variable in the file.
RE: Changing units and values Precipitation and temperature - Added by Saumya Singh 12 days ago
Hi, I have a precipitation data from ECMWF in m/s and want to convert in mm/day. Will the above code cdo -setattribute,pre@units="mm/day" -mulc,86400 input.nc pre_output.nc work? or we need to modify it by multiplying by 86400000?
Thanks
RE: Changing units and values Precipitation and temperature - Added by Karin Meier-Fleischer 12 days ago
For the conversion of m/s to mm/day you have to multiply the precipitation by 86400000.
cdo -setattribute,pre@units="mm/day" -mulc,86400000 infile outfile