RAVE
scansun.c File Reference

KNMI's sun scanning functionality. More...

#include "scansun.h"

Functions

int getDoubleAttribute (RaveCoreObject *obj, const char *aname, double *tmpd)
 Returns a double attribute value from any polar object type.
 
int getDoubleArrayAttribute (PolarScan_t *scan, const char *aname, double **array, PolarScanParam_t *param)
 Returns a double attribute array from a polar scan object.
 
void fill_toplevelmeta (RaveCoreObject *object, SCANMETA *meta)
 Reads metadata into the SCANMETA structure from top-level object, whether it be volume or scan, where required metadata are located in top-level 'how'.
 
void fill_meta (PolarScan_t *scan, PolarScanParam_t *param, SCANMETA *meta)
 Reads metadata into the SCANMETA structure from volume, scan, param.
 
double ElevHeig2Rang (double elev, float heig)
 This function calculates the height and range from the Radar corresponding to a point with a known elevation and on-ground distance from the Radar.
 
void datetime (long date1, long time1, long ss, long *date2, long *time2)
 This function returns the date/time of (date1,time1) and 'ss' later.
 
double refraction (double *elev)
 This function calculates the refraction correction of the solar position.
 
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, date, and time.
 
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.
 
int processData (PolarScan_t *scan, SCANMETA *meta, RaveList_t *list)
 Finds sun hits in reflectivity data.
 
void outputMeta (SCANMETA *meta)
 Debug function that writes metadata to file.
 
int processScan (PolarScan_t *scan, SCANMETA *meta, RaveList_t *list)
 Helper function that calls processReflectivity for each of a number of given parameters/quantities.
 
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.
 
int scansun (const char *filename, RaveList_t *list, char **source)
 Masterminds the scanning of polar data and determination of sun hits.
 

Detailed Description

KNMI's sun scanning functionality.

Author
Original algorithm and code: Iwan Holleman, KNMI, and Integration: Daniel Michelson, SMHI
Date
2010-10-29

Function Documentation

◆ datetime()

void datetime ( long date1,
long time1,
long ss,
long * date2,
long * time2 )

This function returns the date/time of (date1,time1) and 'ss' later.

The date should be given in yyyymmhh format and the time in hhmmss format. The time lapse between the input and output date/time is given in seconds.

Parameters
[in]date1- long int of the input date
[in]time1- long int of the input time
[in]date2- long int of the output date
[in]time2- long int of the output time
Returns
nothing

◆ ElevHeig2Rang()

double ElevHeig2Rang ( double elev,
float heig )

This function calculates the height and range from the Radar corresponding to a point with a known elevation and on-ground distance from the Radar.

The formulae used are exact. For details see lab book.

Parameters
[in]elev- Elevation angle as a double
[in]heig- Height (above the radar) in meters
Returns
Range from the radar in meters, as a double

◆ fill_meta()

void fill_meta ( PolarScan_t * scan,
PolarScanParam_t * dbzh,
SCANMETA * meta )

Reads metadata into the SCANMETA structure from volume, scan, param.

Parameters
[in]scan- PolarScan_t object containing the sweep
[in]dbzh- PolarScanParam_t object containing the sweep's parameter
[in]meta- SCANMETA struct that will be filled with metadata

◆ fill_toplevelmeta()

void fill_toplevelmeta ( RaveCoreObject * object,
SCANMETA * meta )

Reads metadata into the SCANMETA structure from top-level object, whether it be volume or scan, where required metadata are located in top-level 'how'.

Parameters
[in]object- RaveCoreObject containing either volume or scan
[in]meta- SCANMETA struct that will be filled with metadata

◆ getDoubleArrayAttribute()

int getDoubleArrayAttribute ( PolarScan_t * scan,
const char * aname,
double ** array,
PolarScanParam_t * param )

Returns a double attribute array from a polar scan object.

Parameters
[in]obj- a polar scan
[in]aname- a string of the attribute to retrieve
[in]array- the double array to retrieve
[in]param- if attribute not found in scan, try this parameter. May be NULL and in that case, only scan will be checked.
Returns
1 on success or 0 if the attribute doesn't exist

◆ getDoubleAttribute()

int getDoubleAttribute ( RaveCoreObject * obj,
const char * aname,
double * tmpd )

Returns a double attribute value from any polar object type.

Parameters
[in]obj- a polar volume, scan, or scan parameter
[in]aname- a string of the attribute to retrieve
[in]tmpd- the double value to retrieve
Returns
1 on success or 0 if the attribute doesn't exist

◆ outputMeta()

void outputMeta ( SCANMETA * meta)

Debug function that writes metadata to file.

Parameters
[in]meta- internal metadata structure

◆ processData()

int processData ( PolarScan_t * scan,
SCANMETA * meta,
RaveList_t * list )

Finds sun hits in reflectivity data.

Parameters
[in]scan- polar scan object
[in]meta- internal metadata structure
[in]list- RAVE list object containing hits
Returns
1 upon success, otherwise 0

◆ processScan()

int processScan ( PolarScan_t * scan,
SCANMETA * meta,
RaveList_t * list )

Helper function that calls processReflectivity for each of a number of given parameters/quantities.

Called internally by scansun.

Parameters
[in]scan- polar scan object
[in]meta- internal metadata structure
[in]list- RAVE list object containing hits
Returns
1 upon success, otherwise 0

◆ readoutTiming()

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.

Parameters
[in]meta- internal metadata structure
[in]theindex of the ray (azimuth), as an int
[in]datein the form YYYYMMDD as a long
[in]timein the form HHMMSS as a long
[in]sub-secondtime (r="remainder") as a double

◆ refraction()

double refraction ( double * elev)

This function calculates the refraction correction of the solar position.

The function uses the true elevation, i.e., the calculated elevation of the sun in degrees. Formulas derived from the Equivalent Earth Model are used to calculated the refraction in degrees. (Holleman & Huuskonen, 2013, Rad. Sci.)

Returns
a double containing the value of the refracted (perceived) elevation angle in degrees.

◆ scansun()

int scansun ( const char * filename,
RaveList_t * list,
char ** source )

Masterminds the scanning of polar data and determination of sun hits.

Parameters
[in]filename- string containing the name (and path if somewhere else) of the file to process
[out]list- RaveList_t object for holding one or more sets of return values
[out]source- string containing the value of /what/source
Returns
1 upon success, otherwise 0

◆ scansunFromObject()

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.

Parameters
[in]object- Polar scan or volume object in memory
[in]ot- Object type identifier enum, preferably Rave_ObjectType_SCAN or Rave_ObjectType_PVOL
[out]list- RaveList_t object for holding one or more sets of return values
[out]source- string containing the value of /what/source
Returns
1 upon success, otherwise 0

◆ solar_elev_azim()

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, date, and time.

The equations and constants are taken from the WMO guide on Meteorological Instruments and Methods of Observations (CIMO, WMO no. 8), annex 7.D. The equations have been slightly modified and extended to include the calculation of both the sine and cosine of the azimuth. Modified slightly further to include the refracted (perceived) elevation angle.

Parameters
[in]lon- double containing the longitude position
[in]lat- double containing the latitude position
[in]yyyymmdd- year-month-day as a long
[in]hhmmss- hour-minute-second as a long
[out]elev- elevation angle above the horizon in degrees, as a pointer to a double
[out]azim- azimuth angle clockwise from true north, as a pointer to a double
[out]relev- refracted elevation angle, based on elev, as a pointer to a double
Returns
nothing