RAVE
scansun.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2010 Royal Netherlands Meteorological Institute, KNMI and
3 Swedish Meteorological and Hydrological Institute, SMHI,
4
5This is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This software is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License
16along with HLHDF. If not, see <http://www.gnu.org/licenses/>.
17------------------------------------------------------------------------*/
18
24#ifndef SCANSUN_H
25#define SCANSUN_H
26#include <time.h>
27#include <stdio.h>
28#include <string.h>
29#include <stdlib.h>
30#include <math.h>
31
32#include "rave_debug.h"
33#include "rave_io.h"
34#include "polarscan.h"
35#include "polarvolume.h"
36#include "rave_object.h"
37#include "rave_types.h"
38#include "rave_attribute.h"
39#include "rave_alloc.h"
40#include "rave_list.h"
41
42/******************************************************************************/
43/*Definition of analysis parameters. */
44/******************************************************************************/
45
46#define HEIGMIN1 (8.0) /*Minimum height for first analyses in km.*/
47#define HEIGMIN2 (4.0) /*Minimum height for second analyses in km.*/
48#define RAYMIN (20.0) /*Minimum length of rays for analyses in km.*/
49#define FRACDATA (0.70) /*Fraction of rangebins passing the analyses.*/
50#define DBDIFX (2.0) /*Maximum dev. of power from 1st fit in dB.*/
51#define ANGLEDIF (5.0) /*Maximum dev. from calculated sun in deg.*/
52#define GASATTN (0.016) /*Two-way gaseous attenuation in dB/km.*/
53#define CWIDTH (1.2) /*Factor between bandwidth and 1/pulselength.*/
54
55/******************************************************************************/
56/*Definition of radar parameters for solar analysis: */
57/******************************************************************************/
58
59#define WAVELENGTH (0.053) /*Default wavelength in meters*/
60#define ANTVEL (18.0) /*Default antenna velocity in deg/s*/
61#define ANTGAIN (45.0) /*Default antenna gain in dB*/
62#define ASTART (0.0) /*Default azimuthal offset from 0 in degrees*/
63#define PULSEWIDTH (2.0) /*Default pulse width in microseconds*/
64#define RXLOSS (0.0) /*Default receiver chain loss in dB*/
65#define RADCNST (64.0) /*Super-arbitrary default radar constant*/
66
67#define ONEPOL (3.01) /*Losses due to one-pol RX only in dB.*/
68#define AVGATTN (1.39) /*Averaging and overlap losses in dB for 1deg.*/
69
70/******************************************************************************/
71/*Definition of standard parameters. */
72/******************************************************************************/
73
74#define DEG2RAD (0.017453293) /*Degrees to radians.*/
75#define RAD2DEG (57.29578) /*Radians to degrees.*/
76#define LSTR (128) /*Length of all strings used.*/
77#define NELEVX (64) /*Maximum number of elevations.*/
78#define RADIUS43 (8495.0) /*Earth radius used for height calculations.*/
79
80/******************************************************************************/
81/*Definition of parameters for refraction correction. */
82/******************************************************************************/
83
84#define EARTHRAD (6371.0) /*Radius of spherical earth in km.*/
85#define KFACT (1.25) /*K-factor in Equivalent Earth Model.*/
86#define N0 (313.0) /*Atmospherc refractivity at the surface.*/
87
96
97/******************************************************************************/
98/*Structure for containing SCAN metadata: */
99/******************************************************************************/
100
101struct scanmeta {
102 long date;
103 long time;
104 double elev; /*Elevation of scan in deg.*/
105 long nrang; /*Number of range bins in scan.*/
106 long nazim; /*Number of azimuth rays in scan.*/
107 double rscale; /*Size of range bins in scan in km.*/
108 double ascale; /*Size of azimuth steps in scan in deg.*/
109 long azim0; /*Ray number with which radar scan started.*/
110 double astart; /*Azimuthal offset in degrees from 0*/
111 double pulse; /*Pulse length in microsec.*/
112 double bandwidth; /*Receiver bandwidth in MHz.*/
113 double radcnst; /*Radar constant in dB.*/
114 double antvel; /*Antenna velocity in deg/s.*/
115 double lon; /*Longitude of radar in deg.*/
116 double lat; /*Latitude of radar in deg.*/
117 double RXLoss; /*Total losses between reference and feed (dB).*/
118 double AntGain; /*Antenna gain (dB)*/
119 double LAntGain; /*Linear antenna gain*/
120 double AntArea; /*Effective antenna area (m2)*/
121 double wavelength; /*Wavelength in meters*/
122 char quant1[1024]; /*what/quantity for the given scan's parameter, either TH or DBZH*/
123 char quant2[1024]; /*ZDR or either TV or DBZV*/
124 double* startazA; /*Simple array of starting azimuth angles in degrees*/
125 double* stopazA; /*Simple array of ending azimuth angles in degrees*/
126 double* elangles; /*Simple array of elevation angles (mid-point) in degrees*/
127 double* startazT; /*Simple array of starting ray acquisition times in epoch seconds*/
128 double* stopazT; /*Simple array of ending ray acquisition times in epoch seconds*/
129 ZdrType Zdr; /*Flag used to note presence of ZDR, either read or calculated*/
130};
131typedef struct scanmeta SCANMETA;
132
133/*
134 * Structure for containing output values:
135 */
136struct rvals {
137 long date; /* Date of scan data in YYYYMMDD */
138 long time; /* Time of scan data in HHMMSS */
139 double timer; /* Time of scan data in HHMMSS.DCm */
140 double Elev; /* Elevation of scan in deg. */
141 double Azimuth; /* Azimuth of scan in deg. */
142 double ElevSun; /* Elevation angle of the sun in deg. */
143 double AzimSun; /* Azimuth angle of the sun in deg. */
144 double SunMean; /* Sun's reflectivity in dBm */
145 double SunStdd; /* Standard deviation of the sun's reflectivity in dBm */
146 double dBSunFlux; /* Sun flux in dB */
147 double ZdrMean; /* Zdr mean */
148 double ZdrStdd; /* Zdr standard deviation */
149 char quant1[1024]; /* what/quantity for the given scan's parameter: TH, DBZH, TV, or DBZV */
150 char quant2[1024]; /* ZDR or either TV or DBZV */
151 double RelevSun; /* Refraction-corrected (perceived) elevation angle of the sun in deg. */
152 int n; /* Sample size along the ray comprising a hit */
153};
154typedef struct rvals RVALS;
155
156/******************************************************************************/
157/*Prototypes of local functions: */
158/******************************************************************************/
159
167int getDoubleAttribute(RaveCoreObject* obj, const char* aname, double* tmpd);
168
177int getDoubleArrayAttribute(PolarScan_t* scan, const char* aname, double** array, PolarScanParam_t* param);
178
186void fill_toplevelmeta(RaveCoreObject* object, SCANMETA *meta);
187
194void fill_meta(PolarScan_t* scan, PolarScanParam_t* dbzh, SCANMETA *meta);
195
204double ElevHeig2Rang(double elev,float heig);
205
216void datetime(long date1, long time1, long ss, long *date2, long *time2);
217
227double refraction(double *elev);
228
246void solar_elev_azim(double lon, double lat, long yyyymmdd, long hhmmss, double *elev, double *azim, double *relev);
247
256void readoutTiming(SCANMETA* meta, int ia, long* date, long* time, double* timer);
257
265int processData(PolarScan_t* scan, SCANMETA* meta, RaveList_t* list);
266
275int processScan(PolarScan_t* scan, SCANMETA* meta, RaveList_t* list);
276
281void outputMeta(SCANMETA* meta);
282
291int scansunFromObject(RaveCoreObject* object, Rave_ObjectType ot, RaveList_t* list, char** source);
292
300int scansun(const char* filename, RaveList_t* list, char** source);
301
302#endif
Defines the functions available when working with polar scans.
Defines the functions available when working with polar volumes.
Allocation routines for keeping track on memory.
Used for keeping track on attributes.
Defines the functions for debugging rave.
Functions for performing rave related IO operations, mostly ODIM-formatted HDF5 files.
Implementation of a simple list.
Generic implementation of an object that is used within rave.
Type definitions for RAVE.
Rave_ObjectType
Object types that defines the /what/object in the ODIM format.
Definition rave_types.h:82
int getDoubleArrayAttribute(PolarScan_t *scan, const char *aname, double **array, PolarScanParam_t *param)
Returns a double attribute array from a polar scan object.
Definition scansun.c:77
int getDoubleAttribute(RaveCoreObject *obj, const char *aname, double *tmpd)
Returns a double attribute value from any polar object type.
Definition scansun.c:58
void outputMeta(SCANMETA *meta)
Debug function that writes metadata to file.
Definition scansun.c:592
int processScan(PolarScan_t *scan, SCANMETA *meta, RaveList_t *list)
Helper function that calls processReflectivity for each of a number of given parameters/quantities.
Definition scansun.c:624
double refraction(double *elev)
This function calculates the refraction correction of the solar position.
Definition scansun.c:307
void solar_elev_azim(double lon, double lat, long yyyymmdd, long hhmmss, double *elev, double *azim, double *relev)
This function calculates the solar elevation and azimuth using the geographical position,...
Definition scansun.c:325
void datetime(long date1, long time1, long ss, long *date2, long *time2)
This function returns the date/time of (date1,time1) and 'ss' later.
Definition scansun.c:278
int processData(PolarScan_t *scan, SCANMETA *meta, RaveList_t *list)
Finds sun hits in reflectivity data.
Definition scansun.c:422
void fill_meta(PolarScan_t *scan, PolarScanParam_t *dbzh, SCANMETA *meta)
Reads metadata into the SCANMETA structure from volume, scan, param.
Definition scansun.c:178
int scansunFromObject(RaveCoreObject *object, Rave_ObjectType ot, RaveList_t *list, char **source)
Masterminds the scanning of polar data and determination of sun hits, from object in memory.
Definition scansun.c:657
double ElevHeig2Rang(double elev, float heig)
This function calculates the height and range from the Radar corresponding to a point with a known el...
Definition scansun.c:269
int scansun(const char *filename, RaveList_t *list, char **source)
Masterminds the scanning of polar data and determination of sun hits.
Definition scansun.c:689
ZdrType
Different value types for whether ZDR is its own quantity or must be calculated.
Definition scansun.h:91
@ ZdrType_READ
ZDR is in its own quantity and can be read as such.
Definition scansun.h:93
@ ZdrType_None
Non-existant.
Definition scansun.h:92
@ ZdrType_CALCULATE
Vertical reflectivity is read and ZDR needs to be calculated.
Definition scansun.h:94
void fill_toplevelmeta(RaveCoreObject *object, SCANMETA *meta)
Reads metadata into the SCANMETA structure from top-level object, whether it be volume or scan,...
Definition scansun.c:103
void readoutTiming(SCANMETA *meta, int ia, long *date, long *time, double *timer)
Determines the exact observation times based on acquired readout times for each ray.
Definition scansun.c:400
Represents one param in a scan.
Definition polarscanparam.c:41
Represents one scan in a volume.
Definition polarscan.c:47
Represents a list.
Definition rave_list.c:36
The basic raveobject that contains the header information for all rave objects.
Definition rave_object.h:42
Definition scansun.h:136
Definition scansun.h:101
long time
Time of scan data in HHMMSS.
Definition scansun.h:103
long date
Date of scan data in YYYYMMDD.
Definition scansun.h:102