RAVE
pygra.c File Reference

Python version of the Gra API. More...

#include "pyravecompat.h"
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "pyrave_debug.h"
#include "pygra.h"
#include "pyravefield.h"
#include "pycartesianparam.h"
#include "rave_alloc.h"

Macros

#define PYGRA_MODULE
 to get correct part in pygra.h
 
#define raiseException_gotoTag(tag, type, msg)
 Sets a python exception and goto tag.
 
#define raiseException_returnNULL(type, msg)
 Sets a python exception and return NULL.
 

Functions

 PYRAVE_DEBUG_MODULE ("_gra")
 Debug this module.
 
 PyDoc_STRVAR (_pygra_module_doc, "Gauge radar adjustment (GRA). This class performs the actual gauge adjustment\n" "using the derived coefficients. This can be done in two ways: one for ACRR products\n" "(most common) and another for reflectivity (any of DBZH, DBZV, TH, TV).\n" "In the case of ACRR, the parameter is already mm which is good.\n" "In the case of reflectivity, the parameter needs to be converted to R (mm/hr), the correction applied, and\n" "then the result converted back to reflectivity. This should be done in C. Functionality exists already in\n" "raveutil.c/h: dBZ2R or raw2R and back.\n" "Default Z-R coefficients are given in rave_defined.ZR_A and ZR_b. The C could look something like this (from N2):\n" " F = A + B*DIST + C*pow(DIST, 2.0);\n" " F = RAVEMIN(F, 2.0); upper threshold 20 dBR\n" " F = RAVEMAX(F, -0.25); lower threshold -2.5 dBR\n" " out = R*pow(10.0, F);\n" "\n" "final lower threhold on gauge-adjusted result\n" "\n" "if (out < lt) { out=0.0; }\n" "\n" "The member variables are:\n" " A - The A coefficient in the formula A + B*DIST + C*pow(DIST, 2.0);\n" " B - The B coefficient in the formula A + B*DIST + C*pow(DIST, 2.0);\n" " C - The C coefficient in the formula A + B*DIST + C*pow(DIST, 2.0);\n" " upperThreshold - The upper threshold in 10ths of dBR. Default is 2.0 (20 dBR)\n" " lowerThreshold - The lower threshold in 10ths of dBR. Default is -0.25 (-2.5 dBR)\n" " zrA - ZR A coefficient.\n" " zrB - ZR B coefficient when converting from reflectivity to MM/H\n\n" "Usage:\n" " import _gra\n" " gra = _gra.new()\n" " swecomp = _raveio.open(\"swecomposite_20200225.h5\").object\n" " dt = create_datetime_from(swecomp)\n" " dt = dt - datetime.timedelta(seconds=3600*12) # 12 hours back in time\n" " (A,B,C) = db.get_gra_coefficient(dt)\n" " gra.A = A\n" " gra.B = B\n" " gra.C = C\n" " gra.zrA = ZR_A\n" " gra.zrb = ZR_b\n" " distanceField = swecomp.findQualityFieldByHowTask(\"se.smhi.composite.distance.radar\")\n" " gra_field = gra.apply(distanceField, swecomp.getParameter(\"DBZH\"))\n" " gra_field.quantity = \"DBZH_CORR\"\n")
 
 MOD_INIT (_gra)
 

Variables

PyTypeObject PyGra_Type
 

Detailed Description

Python version of the Gra API.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2014-03-28

Macro Definition Documentation

◆ PYGRA_MODULE

#define PYGRA_MODULE

to get correct part in pygra.h

◆ raiseException_gotoTag

#define raiseException_gotoTag ( tag,
type,
msg )
Value:
{PyErr_SetString(type, msg); goto tag;}

Sets a python exception and goto tag.

◆ raiseException_returnNULL

#define raiseException_returnNULL ( type,
msg )
Value:
{PyErr_SetString(type, msg); return NULL;}

Sets a python exception and return NULL.

Function Documentation

◆ PYRAVE_DEBUG_MODULE()

PYRAVE_DEBUG_MODULE ( "_gra" )

Debug this module.