NAME

Weather::GHCN::Station - class for Station metadata

VERSION

version v0.0.007

SYNOPSIS

use Weather::GHCN::Station;

my $stn_obj = Weather::GHCN::Station->new (
    id      => 'CA006105976',
    country => 'CA',
    state   => 'ON',
    active  => '1899-2022',
    lat     => '45.3833',
    long    => '-75.7167',
    elev    => 79,
    name    => 'OTTAWA CDA',
    gsn     => '',
);

DESCRIPTION

The Weather::GHCN::Station class is used to encapsulate the metadata for a station as obtained from the NOAA Global Historical Climatology Network data repository. Data is sourced from the station list and the station inventory.

The module is primarily for use by Weather::GHCN::Fetch and Weather::GHCN::StationTable.

FIELD ACCESSORS

id

Returns the Station id.

country

Returns the two-character GEC country code for the station.

state

Returns the two-character state code for US stations, or province code for Canadian stations.

active

Returns the active range of the station.

lat

Returns the station latitude.

long

Returns the station longitude.

elev

Returns the station elevation.

name

Returns the station name.

gsn

Returns the boolean indicating whether this is a GSN station.

elems_href

Returns a hash reference for the measurements available from the station daily data records.

idx

Returns an index number which is shared by stations that have the same physical location; i.e. latitude and longitude. When station instrumentation is changed or there are other significant changes, a new station id may be assigned. This index enables you to group together stations that represent the same spot but which may have different active time periods.

note_nrs

Returns a number range string that represents notes which are errors or warnings about the station.

CLASS METHODS

new ()

Create a new Station object.

Headings ()

Column headings may be needed prior to creating any Station instances, for example to print them before any data is loaded. This Headings class method is provided to handle that situation. There is a corresponding instance method.

If called in list context, a list is return; in scalar context, a list reference is returned.

INSTANCE METHODS

headings

See Headings in Class Methods.

add_note ($note_id, $msg=undef, $verbose=$FALSE)

This method allows you to add numbered notes to each station object. It is up to the caller to assign meaning to the numbers. They are stored in a range list (i.e. a Set::IntSpan::Fast object) so that they can be printed compactly even if there a gaps in the number ranges. For example, notes 1, 5 and 20 through 25 will print as 1,5,20-25.

The message argument is optional, but if you provide a message then it will be display on STDERR if it is considered an error message. The threshold is 50 (as established by the hard coded constant $ERR_THRESHOLD). Anything below that is considered an error. Otherwise it's considered a warning.

When the $VERBOSE argument is true, it causes warnings to also print to STDERR.

row

Returns the station object as a list of field values. The fields are:

$id, $country, $state, $active, $lat, $long, $elev, $name,
  $note_text, $idx, $grid>

The second last value, $idx is a unique serial index number provided by GHCH::StationTable during load_stations(). Unless set by a consumer of this module, its value will be undef.

The last value, $grid, is a string derived by truncating $lat and $long to 1 decimal place, converting them to N/S W/E format, and concatenting them. This results in a box that defines an area within which there may be other nearby stations of interest.

If called in list context, a list is return; in scalar context, a list reference is returned.

coordinates

Returns the latitude and longitude coordinates of the station in decimal format as a space-separated string.

description

Return lines of text which describe the station in attribute: value format.

error_count

Returns a count of the number of errors that were flagged for this station. Errors generally make the station unsuitable for use. Warnings are not included.

grid

Returns the latitude and longitude to a single decimal place and using cardinal (N/S E/W) notation. This value can be used for grouping together stations that are within a 1/10th degree grid and which may be assumed to experience similar weather conditions.

selected

Returns a boolean indicating whether the station was selected for data loading. Selected stations are those that meet the filtering criteria (station id, station name, active range etc.) and that are not flagged with errors.

url

Returns the URL for the station's daily data web page in the NOAA GHCN data repository.

DOES

Defined by Object::Pad. Included for POD::Coverage.

META

Defined by Object::Pad. Included for POD::Coverage.

AUTHOR

Gary Puckering (jgpuckering@rogers.com)

LICENSE AND COPYRIGHT

Copyright 2022, Gary Puckering