Function to compute opersvarfiles: operation of variables from different files (OPER1.FILE1_VAR1 OPER2.FILE2_VAR2), operations are going to be sequentially
compute_opersvarsfiles(values, varinfo)
NOTE: Values from the first file (with always operation 'add')
[prevalues]: values from the previous operations
values= '%' separated list of dimension ranges and file,operation,variable to compute
[dimranges1]@[operfile1var]%[dimranges2]@[operfile2var]%[...[dimrangesM]@[operfileMvar]]
dimranges: ';' separated list of dimension, dimension-variable names and their ranges ('|' separated)
[dim1]|[dimv1]|[range];[dim2]|[dimv2]|[range];[...|[dimN]|[dimvN]|[range]]
with [range] as:
-1, all the values
-9, last values
int, a single value
[beg,end,frq], from a beginning to an end with a given frequency
operfilevar: [oper]|[file]|[var] '|' separated list of triplets of [operation], [file], [variable name to use]
* [oper]: operations (being [prevalues] the values computed until the operation)
'add': adding [var] ([prevalues] + [var])
'addc',[modval1]: add [modval1] to [prevalues]
'arctan', arctangent [-p1, pi]
'centerderiv',[N],[ord],[dim]: un-scaled center [N]-derivative of order [ord] along dimension [dim] of [var]
'div': dividing by [var] ([prevalues] / [var])
'divc',[modval1]: [prevalues] divide by [modval1]
'forwrdderiv',[N],[ord],[dim]: un-scaled forward [N]-derivative of order [ord] along dimension [dim] of [var]
'inv': inverting [prevalues] (1/[prevalues])
'lowthres',[modval1],[modval2]: if [prevalues] < [modval1]; prevalues = [modval2]
'lowthres@oper',[modval1],[oper],[modval2]: if [prevalues] < [modval1]; prevalues = [oper] (operation as [modval2])
'mul': multiplying by [var] ([prevvalues] * [var])
'mulc',[modval1]: [prevalues] multiplied by [modval1]
'norm_meanminmax',[NOTnormdims]: normalization of data as: (val-)/(max(val)-min(val)) except along
dimensions [NOTnormdims] (':' list of dimension names, or 'any' for using all dimensions)
'norm_minmax',[NOTnormdims]: normalization of data as: [2val-(max(val)-min(val)]/[max(val)+min(val)]
except along dimensions [NOTnormdims] (':' list of dimension names, or 'any' for using all dimensions)
'norm_meanstd',[NOTnormdims]: normalization of data as: (val-)/stdev(val) except along
dimensions [NOTnormdims] (':' list of dimension names, or 'any' for using all dimensions)
dimensions [NOTnormdims] (':' list of dimension names)
'pot': powering with [var] ([prevalues] ** [var])
'potc',[modval1]: [prevalues] ** [modval1]
'repl',[modval1]: replace values of [prevalues] with values from [operfile2var] except
values in second file = [modval1]
'replbig',[modval1]: replace values of [prevalues] with values from [operfile2var] except
values in second file > [modval1]
'repless',[modval1]: replace values of [prevalues] with values from [operfile2var] except
values in second file < [modval1]
'sub': substracting [var] ([prevalues] - [var])
'subc',[modval1]: remove [modval1] of [prevalues]
'upthres',[modval1],[modval2]: if [prevalues] > [modval1]; prevalues = [modval2]
'upthres@oper',[modval1],[oper],[modval2]: if [prevalues] > [modval1]; prevalues = [oper] (operation with [modval2])
* [file]: name of the file
* [var]: variable to use ('None' for the case with constant operations: 'addc', 'divc', 'inv', 'lowthres',
'lowthres@oper', 'mulc', 'potc', 'subc', 'upthres', 'upthres@oper'
varinfo= [varname],[Lvarname],[varunits]
varname: name of the final variable
Lvarname: long name of the final variable ('!' for spaces)
varunits: units of the final variable ('!' for spaces)
* Transforming temperature from Kelvin to °C
$ python ${pyHOME}/nc_var.py -o compute_opersvarsfiles -S 'west_east|XLONG|-1;south_north|XLAT|-1;Time|Times|3@subc,273.15|wrfout_d01_2001-11-11_00:00:00|T2' -v 'tempC,air!temperature,C'
* Computing the x-derivative of first order
$ python ${pyHOME}/nc_var.py -o compute_opersvarsfiles -S 'lon|lon|-1;lat|lat|-1;time_counter|time_counter|-1@forwrdderiv,1,1,2|histday.nc|t2m' -v 'tasderiv,x-derivative|of|air|temperature,K'
* Normalizing a variable by substracting its mean and weighting by its standard-deviation
$ python ${pyHOME}/nc_var.py -o compute_opersvarsfiles -S 'west_east|XLONG|-1;south_north|XLAT|-1;Time|WRFtime|-1@norm_meanstd,Time|wrfout_d01_1995-01-01_00:00:00|T2' -v 'tasnorm,normalized!2m!temperature!substracting!mean!and!weighting!by!standard!deviation,K'
* Getting height of the frist level from surface from a WRF file
$ python $pyHOME/nc_var.py -o compute_opersvarsfiles -S 'west_east|XLONG|-1;south_north|XLAT|-1;bottom_top_stag|ZNW|1@addc,0|wrfout_d01_1995-01-01_00:00:00|PH%west_east|XLONG|-1;south_north|XLAT|-1;bottom_top_stag|ZNW|1@add|wrfout_d01_1995-01-01_00:00:00|PHB%contoperation@divc,9.81%west_east|XLONG|-1;south_north|XLAT|-1;Time|WRFtime|-1@sub|wrfout_d01_1995-01-01_00:00:00|HGT' -v 'height1lev,height!above!surface!of!first!level,m'
* Computing wind-direction from a WRF file
$ python $pyHOME/nc_var.py -o compute_opersvarsfiles -S 'west_east|XLONG|-1;south_north|XLAT|-1;Time|WRFtime|-1@addc,0|wrfout_d01_1995-01-01_00:00:00|V10%west_east|XLONG|-1;south_north|XLAT|-1;Time|WRFtime|-1@arctan|wrfout_d01_1995-01-01_00:00:00|U10%contoperation@mulc,57.2957795131' -v 'wsdir,2m!wind!direction,Degrees'