RAVE
Lib.rave_area Namespace Reference

Classes

class  AREA
 Area object. More...
 

Functions

 keys ()
 Returns a list of keys in the registry.
 
 items ()
 Returns a list of tuples containing key:item pairs in the registry where the key is the area's identifier and the item is its object.
 
 init ()
 Initializer.
 
 area (Id)
 Returns the area instance corresponding with the given identifier.
 
 register (A)
 Registers a new AREA instance.
 
 make_tuple (text)
 Convenience function for converting a text representation of a tuple to a tuple.
 
 makearg (parent, id, text, Type=None)
 Convenience function for creating XML.
 
 add (id, description, projection_id, extent, xsize, ysize, xscale, yscale, filename=AREA_REGISTRY)
 Adds a new area to the registry.
 
 remove (id, filename=AREA_REGISTRY)
 Removes an area from the registry.
 
 write (filename=AREA_REGISTRY)
 Writes the contents of the registry to file.
 
 describe (id)
 Prints an area's characteristics to stdout.
 
 llToSc (lonlat, pcs_id)
 Translates lonlat (as radians) into surface coordinates according to specified pcs_id.
 
 MakeCornersFromExtent (id)
 Calculates the corner coordinates in lon/lat based on an area's extent.
 
 MakeAreaFromPolarFiles (files, proj_id='llwgs84', xscale=2000.0, yscale=2000.0)
 Convenience function that automatically derives a new area from several input ODIM_H5 polar volume or scan files.
 
 MakeAreaFromPolarObjects (objects, proj_id='llwgs84', xscale=2000.0, yscale=2000.0)
 Convenience function that automatically derives a new area from several input ODIM_H5 polar volume or scan objects.
 
 MakeSingleAreaFromSCAN (scan, pcsid, xscale, yscale)
 Helper for defining new areas.
 

Variables

bool got_arearegistry = True
 
 AREAS = os.path.join(RAVECONFIG, '*area_registry.xml')
 There's only one official area registry, but this module allows greater flexibility as long as files use the same naming convention.
 
dict _registry = {}
 Empty registry to be filled.
 
int initialized = 0
 

Detailed Description

Copyright (C) 1998 - Swedish Meteorological and Hydrological Institute (SMHI)

This file is part of RAVE.

RAVE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

RAVE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with RAVE.  If not, see <http://www.gnu.org/licenses/>.

Function Documentation

◆ add()

Lib.rave_area.add ( id,
description,
projection_id,
extent,
xsize,
ysize,
xscale,
yscale,
filename = AREA_REGISTRY )

Adds a new area to the registry.

If an existing entry with the same identifier exists, it is overwritten.

Parameters
idstring identifier of this area
descriptionstring free-text description of this area
projection_idstring identifier of the projection used to define this area
extenttuple of floats giving the PCS coordinates of the lower-left and upper-right pixels in the form (LLlon, LLlat, URlon, URlat). Note that the PCS coordinates of the UR pixel are for the lower-left corner of the upper-right pixel.
xsizeint number of pixels in the X dimension
ysizeint number of pixels in the Y dimension
xscalefloat X scale in PCS space (commonly expressed in meters)
yscalefloat Y scale in PCS space (commonly expressed in meters)
filenameFull path to the XML file containing the registry

◆ area()

Lib.rave_area.area ( Id)

Returns the area instance corresponding with the given identifier.

Parameters
IdString identifier of the desired area
Returns
an AREA instance representing the desired area

◆ describe()

Lib.rave_area.describe ( id)

Prints an area's characteristics to stdout.

Parameters
idThe area's string identifier

◆ init()

Lib.rave_area.init ( )

Initializer.

◆ items()

Lib.rave_area.items ( )

Returns a list of tuples containing key:item pairs in the registry where the key is the area's identifier and the item is its object.

◆ keys()

Lib.rave_area.keys ( )

Returns a list of keys in the registry.

◆ llToSc()

Lib.rave_area.llToSc ( lonlat,
pcs_id )

Translates lonlat (as radians) into surface coordinates according to specified pcs_id.

◆ make_tuple()

Lib.rave_area.make_tuple ( text)

Convenience function for converting a text representation of a tuple to a tuple.

Parameters
textInput string
Returns
a tuple containing the converted string

◆ MakeAreaFromPolarFiles()

Lib.rave_area.MakeAreaFromPolarFiles ( files,
proj_id = 'llwgs84',
xscale = 2000.0,
yscale = 2000.0 )

Convenience function that automatically derives a new area from several input ODIM_H5 polar volume or scan files.

Mandatory single input file will give an area for that single site. If more files are given, the derived area will represent the coverage of all these radars. Depending on the characteristics of the given projection, different radars will determine the north, south, east, and west edges of the derived area.

Parameters
filesList of file strings of input ODIM_H5 files
proj_ididentifier string of the projection to use for this area
xscalefloat Horizontal X-dimension resolution in projection-specific units (commonly meters)
yscalefloat Horizontal Y-dimension resolution in projection-specific units (commonly meters)
Returns
Don't know

◆ MakeAreaFromPolarObjects()

Lib.rave_area.MakeAreaFromPolarObjects ( objects,
proj_id = 'llwgs84',
xscale = 2000.0,
yscale = 2000.0 )

Convenience function that automatically derives a new area from several input ODIM_H5 polar volume or scan objects.

Mandatory single input object will give an area for that single site. If more objects are given, the derived area will represent the coverage of all these radars. Depending on the characteristics of the given projection, different radars will determine the north, south, east, and west edges of the derived area.

Parameters
filesList of polar objects
proj_ididentifier string of the projection to use for this area
xscalefloat Horizontal X-dimension resolution in projection-specific units (commonly meters)
yscalefloat Horizontal Y-dimension resolution in projection-specific units (commonly meters)
Returns
Don't know

◆ makearg()

Lib.rave_area.makearg ( parent,
id,
text,
Type = None )

Convenience function for creating XML.

Parameters
parentparent XML element
idstring identifier for the tag
textstring containing a test representation of the SubElement's contents
Typecan be any of 'float', 'int', or 'sequence'
Returns
the formatted SubElement

◆ MakeCornersFromExtent()

Lib.rave_area.MakeCornersFromExtent ( id)

Calculates the corner coordinates in lon/lat based on an area's extent.

NOTE: the corners in lon/lat are the true outside corners of each pixel, whereas the extent always represents the position of the lower-left corner of each corner pixel.

Parameters
idstring identifying the area
Returns
tuple of tuples containing floats with lon/lat coordinates for lower-left, upper-right, upper-left, and lower-right corner coordinates

◆ MakeSingleAreaFromSCAN()

Lib.rave_area.MakeSingleAreaFromSCAN ( scan,
pcsid,
xscale,
yscale )

Helper for defining new areas.

Parameters
scanPolarScanCore object
pcsidstring containing the output projection identifier
xscalefloat Horizontal X-dimension resolution in projection-specific units (commonly meters)
yscalefloat Horizontal Y-dimension resolution in projection-specific units (commonly meters)
Returns
an XML Element

◆ register()

Lib.rave_area.register ( A)

Registers a new AREA instance.

Parameters
AAREA instance

◆ remove()

Lib.rave_area.remove ( id,
filename = AREA_REGISTRY )

Removes an area from the registry.

Parameters
idString containing the identifier of the area to remove
filenameFull path to the XML file containing the area registry

◆ write()

Lib.rave_area.write ( filename = AREA_REGISTRY)

Writes the contents of the registry to file.

This is a bit overworked, but it bridges the gap between old and new interfaces.

Parameters
filenameComplete path of the XML file to which to write the contents of the registry.

Variable Documentation

◆ _registry

dict Lib.rave_area._registry = {}
protected

Empty registry to be filled.

◆ AREAS

Lib.rave_area.AREAS = os.path.join(RAVECONFIG, '*area_registry.xml')

There's only one official area registry, but this module allows greater flexibility as long as files use the same naming convention.