RAVE
raveutil.c File Reference

Utilities for translating between different units and other useful functions. More...

#include "raveutil.h"
#include <limits.h>
#include <math.h>

Functions

double RAVEMAX (double a, double b)
 Returns the maximum value of a and b.
 
double RAVEMIN (double a, double b)
 Returns the minimum value of a and b.
 
double dBZ2Z (double dbz)
 Converts dBZ to Z.
 
double dBZ2R (double dbz, double A, double b)
 Converts dBZ to mm/h, given an input dBZ and Z-R constants A and b.
 
double Z2dBZ (double Z)
 Converts Z to dBZ.
 
double R2dBZ (double R, double A, double b)
 Converts mm/h to dBZ, given an input dBZ and Z-R constants A and b.
 
double raw2dbz (double raw, double gain, double offset)
 Converts raw to dBZ using linear gain and offset.
 
double dbz2raw (double dbz, double gain, double offset)
 Converts dBZ to raw and makes sure it fits within an 8-bit word using gain and offset.
 
double raw2R (double raw, double gain, double offset, double A, double b)
 Converts raw to R (mm/h) using linear gain and offset, and Z-R coefficients A and b.
 
double R2raw (double R, double gain, double offset, double A, double b)
 Converts R (mm/h) to raw using linear gain and offset, and Z-R coefficients A and b.
 
int mytrunc (double d)
 Truncates a double to an integer.
 
int myround_int (double d, double minlimit, double maxlimit)
 Rounds a double to an integer.
 

Detailed Description

Utilities for translating between different units and other useful functions.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
1998-

Function Documentation

◆ dBZ2R()

double dBZ2R ( double dbz,
double A,
double b )

Converts dBZ to mm/h, given an input dBZ and Z-R constants A and b.

Parameters
[in]dbzthe dbz value to be converted
[in]Athe A value
[in]bthe b value
Returns
mm/h

◆ dbz2raw()

double dbz2raw ( double dbz,
double gain,
double offset )

Converts dBZ to raw and makes sure it fits within an 8-bit word using gain and offset.

Parameters
[in]dbzthe dBZ value
[in]gainthe gain value, May NOT be 0.0
[in]offsetthe offset
Returns
the 8 bit raw ((dbz - offset)/gain)

◆ dBZ2Z()

double dBZ2Z ( double dbz)

Converts dBZ to Z.

Parameters
[in]dbzthe dbz value to be converted
Returns
the Z value

◆ myround_int()

int myround_int ( double d,
double minlimit,
double maxlimit )

Rounds a double to an integer.

Parameters
[in]dthe double v
[in]minlimitthe minumim allowed value. if the rounded value becomes lower than this, the minlimit is used.
[in]maxlimitthe maximum allowed value. if the rounded value becomes higher than this, the maxlimit is used.
Returns
the rounded int value

◆ mytrunc()

int mytrunc ( double d)

Truncates a double to an integer.

Parameters
[in]dthe double v
Returns
the truncated int value

◆ R2dBZ()

double R2dBZ ( double R,
double A,
double b )

Converts mm/h to dBZ, given an input dBZ and Z-R constants A and b.

Parameters
[in]Rmm/h
[in]Athe A value
[in]bthe b value
Returns
dBZ

◆ R2raw()

double R2raw ( double R,
double gain,
double offset,
double A,
double b )

Converts R (mm/h) to raw using linear gain and offset, and Z-R coefficients A and b.

Parameters
[in]Rmm/h
[in]gainthe gain
[in]offsetthe offset
[in]Athe A coefficient
[in]bthe b coefficient
Returns
the raw value

◆ RAVEMAX()

double RAVEMAX ( double a,
double b )

Returns the maximum value of a and b.

Parameters
[in]a
[in]b
Returns
the maximum value of a and b

◆ RAVEMIN()

double RAVEMIN ( double a,
double b )

Returns the minimum value of a and b.

Parameters
[in]a
[in]b
Returns
the mainimum value of a and b

◆ raw2dbz()

double raw2dbz ( double raw,
double gain,
double offset )

Converts raw to dBZ using linear gain and offset.

Parameters
[in]rawthe raw value
[in]gainthe gain
[in]offsetthe offset
Returns
dBZ (raw * gain + offset)

◆ raw2R()

double raw2R ( double raw,
double gain,
double offset,
double A,
double b )

Converts raw to R (mm/h) using linear gain and offset, and Z-R coefficients A and b.

Parameters
[in]rawthe raw value
[in]gainthe gain
[in]offsetthe offset
[in]Athe A coefficient
[in]bthe b coefficient
Returns
mm/h

◆ Z2dBZ()

double Z2dBZ ( double Z)

Converts Z to dBZ.

Parameters
[in]Z
Returns
dBZ