diving each field by its global maximum
Added by Marco Miani about 5 years ago
Hello.
Please consider this case:
My hourly model output, spans over the whole globe, for a couple of decades. The nc file is immense.
My aim is to normalize each field, of a given variable (say Temp), with the global maximum over space:
normTemp_{t} = Temp_{t} / max(Temp_{t})_{lon,lat} , for each t in [0, numel(t)]
What I could achieve so far, is the sole fieldmax:@
cdo = Cdo()
cdo.fldmax(input=ifile, output= "output_fieldmax.nc")
I was trying to then combine field with field max, but this somehow smells like inefficiency.
Any better way to do it, in one go? Maybe chaining?
Thank you
Marco
Replies (2)
RE: diving each field by its global maximum - Added by Karin Meier-Fleischer about 5 years ago
Hi Marco,
assuming that the variable is tas and
infile = infile.nc
outfile = outfile.nc
You can do either
cdo.div(input = infile + ' -enlarge,' + infile + ' -fldmax ' + infile, output = outfile)
or
cdo.expr("'tasdiv = tas / fldmax(tas)'", input=infile, output=outfile)
-Karin
RE: diving each field by its global maximum - Added by Marco Miani about 5 years ago
Dear Karin,
Your solution works like charm, thank you for making my day!
I have only recently started using cdo (in python), and it proved to be a Copernican revolution to me.
Best regards
Marco