Commit bd64c5c1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

New operator: reci - Reciprocal value

parent d29999b1
2009-01-12 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
2009-01-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.3.0
* New operator: remapcon2 - Second order conservative remapping
* New operator: remaplaf - Largest area fraction remapping
* New operator: remapnn - Nearest neighbor remapping
* New operator: reci - Reciprocal value
* add support for GRID type Sinusoidal
* add support for GRID type Lambert Azimuthal Equal Area
* import_cmsaf: add support for monthly mean diurnal cycle
......@@ -11,6 +12,7 @@
* remap: check grid and weights
* remap: set num_srch_bins to nlat/2 (speedup)
* sinfo: extent grid description
* diff: check variable names
* sellonlatbox: bug fix for curvilinear grids
* setzaxis: change float to double (bug fix) [report: Pier Giuseppe Fogli]
* Arith: add filltype FILL_RECTS [request: Wolfgang Mueller]
......
CDO NEWS
--------
Version 1.3.0 (12 January 2009):
Version 1.3.0 (15 January 2009):
* New features:
o add support for Sinusoidal and Lambert Azimuthal Equal Area projections
......@@ -9,6 +9,7 @@ Version 1.3.0 (12 January 2009):
o Second order conservative remapping - remapcon2
o Nearest neighbor remapping - remapnn
o Largest area fraction remapping - remaplaf
o Reciprocal value - reci
* Changed operators:
o import_cmsaf: add support for monthly mean diurnal cycle
o remap: set num_srch_bins to nlat/2 (speedup)
......@@ -18,7 +19,7 @@ Version 1.3.0 (12 January 2009):
o merge: bug fix for usage in CDO pipes
o gridarea, gridweights: bug fix for gridboxes with delta lon >= 180 degree
o intlevel: bug fix for datasets with missing values
o yseasstd, yseasvar: wrong array index
o yseasstd, yseasvar: fixed wrong array index
Version 1.2.1 (13 November 2008):
......
......@@ -5,7 +5,7 @@
@Section = Arithmetic
@Class = Arithmetic
@Arguments = ifile ofile
@Operators = abs int nint pow sqr sqrt exp ln log10 sin cos tan asin acos atan
@Operators = abs int nint pow sqr sqrt exp ln log10 sin cos tan asin acos reci
@BeginDescription
This module contains some standard mathematical functions.
......@@ -269,6 +269,23 @@ o(t,x) = \arctan(i(t,x))
@EndOperator
@BeginOperator_reci
@Title = Reciprocal value
@BeginDescription
@IfMan
o(t,x) = 1 / i(t,x)
@EndifMan
@IfDoc
@BeginMath
o(t,x) = 1 / i(t,x)
@EndMath
@EndifDoc
@C Calculates the reciprocal value of i(t,x).
@EndDescription
@EndOperator
@BeginExample
To calculate the square root for all field elements use:
@BeginVerbatim
......
......@@ -49,6 +49,7 @@ void *Diff(void *argument)
int ndrec = 0, nd2rec = 0, ngrec = 0;
char varname[128];
int year, month, day, hour, minute;
int lfunc;
double *array1, *array2;
double absm, relm;
double missval1, missval2;
......@@ -70,7 +71,14 @@ void *Diff(void *argument)
vlistID1 = streamInqVlist(streamID1);
vlistID2 = streamInqVlist(streamID2);
vlistCompare(vlistID1, vlistID2, func_sft);
lfunc = func_sftn;
/*
if ( operatorID == DIFFV )
lfunc = func_sftn;
else
lfunc = func_sftc;
*/
vlistCompare(vlistID1, vlistID2, lfunc);
gridsize = vlistGridsizeMax(vlistID1);
......
......@@ -2,7 +2,7 @@
This file is part of CDO. CDO is a collection of Operators to
manipulate and analyse Climate model Data.
Copyright (C) 2003-2008 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
Copyright (C) 2003-2009 Uwe Schulzweida, Uwe.Schulzweida@zmaw.de
See COPYING file for copying and redistribution conditions.
This program is free software; you can redistribute it and/or modify
......@@ -30,6 +30,8 @@
Math asin Arc sine
Math acos Arc cosine
Math atan Arc tangent
Math pow Power
Math reci Reciprocal
*/
......@@ -42,7 +44,7 @@
void *Math(void *argument)
{
static char func[] = "Math";
enum {ABS, FINT, FNINT, SQR, SQRT, EXP, LN, LOG10, SIN, COS, TAN, ASIN, ACOS, ATAN, POW};
enum {ABS, FINT, FNINT, SQR, SQRT, EXP, LN, LOG10, SIN, COS, TAN, ASIN, ACOS, ATAN, POW, RECI};
int operatorID;
int operfunc;
int streamID1, streamID2;
......@@ -75,6 +77,7 @@ void *Math(void *argument)
cdoOperatorAdd("acos", ACOS, 0, NULL);
cdoOperatorAdd("atan", ATAN, 0, NULL);
cdoOperatorAdd("pow", POW, 0, NULL);
cdoOperatorAdd("reci", RECI, 0, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorFunc(operatorID);
......@@ -187,6 +190,10 @@ void *Math(void *argument)
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : pow(array1[i], rc);
break;
case RECI:
for ( i = 0; i < gridsize; i++ )
array2[i] = DBL_IS_EQUAL(array1[i], missval1) || DBL_IS_EQUAL(array1[i], 0) ? missval1 : 1/array1[i];
break;
default:
cdoAbort("operator not implemented!");
}
......
......@@ -54,10 +54,31 @@ void vlistCompare(int vlistID1, int vlistID2, int function)
zaxisInqSize(vlistInqVarZaxis(vlistID2, varID)) )
cdoAbort("Number of levels of the input fields do not match!");
}
else if ( function == func_sft )
else if ( function == func_sft || function == func_sftn /* || function == func_sftc */ )
{
for ( varID = 0; varID < nvars; varID++ )
{
if ( function == func_sftn )
{
char name1[256], name2[256];
vlistInqVarName(vlistID1, varID, name1);
vlistInqVarName(vlistID2, varID, name2);
if ( strcmp(name1, name2) != 0 )
{
cdoWarning("Input streams have different variable names!");
break;
}
}
/*
if ( function == func_sftc )
{
if ( vlistInqVarCode(vlistID1, varID) != vlistInqVarCode(vlistID2, varID) )
{
cdoWarning("Input streams have different code numbers!");
break;
}
}
*/
if ( gridInqSize(vlistInqVarGrid(vlistID1, varID)) !=
gridInqSize(vlistInqVarGrid(vlistID2, varID)) )
cdoAbort("Grid size of the input fields do not match!");
......
......@@ -18,7 +18,9 @@
#define func_hrd 31
#define func_sft 32
#define func_code 33
#define func_sftn 33
#define func_sftc 34
#define func_code 35
#define func_add 41
#define func_sub 42
......
......@@ -288,7 +288,7 @@ void *Wct(void *argument);
#define MaskregionOperators {"maskregion"}
#define MastrfuOperators {"mastrfu"}
#define MathOperators {"abs", "int", "nint", "sqr", "sqrt", "exp", "ln", "log10", "sin", \
"cos", "tan", "asin", "acos", "atan", "pow"}
"cos", "tan", "asin", "acos", "atan", "pow", "reci"}
#define MergeOperators {"merge"}
#define MergegridOperators {"mergegrid"}
#define MergetimeOperators {"mergetime"}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment