| 1 | # Weather::GHCN::Station.pm - class for Station metadata | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Weather::GHCN::Station - class for Station metadata | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | version v0.0.002 | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | use Weather::GHCN::Station; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | my $stn_obj = Weather::GHCN::Station->new ( | ||||||||||||||||||||||||||||
| 16 | id => 'CA006105976', | ||||||||||||||||||||||||||||
| 17 | country => 'CA', | ||||||||||||||||||||||||||||
| 18 | state => 'ON', | ||||||||||||||||||||||||||||
| 19 | active => '1899-2022', | ||||||||||||||||||||||||||||
| 20 | lat => '45.3833', | ||||||||||||||||||||||||||||
| 21 | long => '-75.7167', | ||||||||||||||||||||||||||||
| 22 | elev => 79, | ||||||||||||||||||||||||||||
| 23 | name => 'OTTAWA CDA', | ||||||||||||||||||||||||||||
| 24 | gsn => '', | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | The B<Weather::GHCN::Station> class is used to encapsulate the metadata for a | ||||||||||||||||||||||||||||
| 30 | station as obtained from the NOAA Global Historical Climatology | ||||||||||||||||||||||||||||
| 31 | Network data repository. Data is sourced from the station list and | ||||||||||||||||||||||||||||
| 32 | the station inventory. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | The module is primarily for use by Weather::GHCN::Fetch and Weather::GHCN::StationTable. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | ▶ | use v5.18; # minimum for Object::Pad | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 4 | ▶ | use Object::Pad 0.66 qw( :experimental(init_expr) ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | package Weather::GHCN::Station; | ||||||||||||||||||||||||||||
| 42 | class Weather::GHCN::Station; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 4 | our $VERSION = 'v0.0.002'; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 4 | ▶ | use Weather::GHCN::Common qw( rng_new iso_date_time ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | 4 | ▶ | use Const::Fast; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | const my $EMPTY => q(); # empty string | |||||||||||||||||||||||||||
| 50 | 4 | const my $TAB => qq(\t); # tab character | |||||||||||||||||||||||||||
| 51 | 4 | const my $TRUE => 1; # perl's usual TRUE | |||||||||||||||||||||||||||
| 52 | 4 | const my $FALSE => not $TRUE; # a dual-var consisting of '' and 0 | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 4 | const my $NOAA_DATA => 'https://www1.ncdc.noaa.gov/pub/data/ghcn/daily/all/'; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # below this value is an error causing stn rejection | ||||||||||||||||||||||||||||
| 57 | 4 | const my $ERR_THRESHOLD => 50; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # attributes | ||||||||||||||||||||||||||||
| 60 | 1 | ▶ | field $id :reader :param; # [0] | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 1 | ▶ | field $country :reader :param; # [1] | ||||||||||||||||||||||||||
|
Subroutine
country: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 1 | ▶ | field $state :reader :param; # [2] | ||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | field $active :mutator :param; # [3] | ||||||||||||||||||||||||||
|
Subroutine
active: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | field $lat :reader :param; # [4] | ||||||||||||||||||||||||||
|
Subroutine
lat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 1 | ▶ | field $long :reader :param; # [5] | ||||||||||||||||||||||||||
|
Subroutine
long: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | field $elev :reader :param; # [6] | ||||||||||||||||||||||||||
|
Subroutine
elev: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 1 | ▶ | field $name :reader :param; # [7] | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | field $gsn :reader :param; # [8] | ||||||||||||||||||||||||||
|
Subroutine
gsn: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 1 | ▶ | field $elems_href :reader { {} }; # [9] | ||||||||||||||||||||||||||
|
Subroutine
elems_href: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | field $idx :mutator; # [10] | ||||||||||||||||||||||||||
|
Subroutine
idx: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 5 | ▶ | field $note_nrs :mutator { rng_new() }; # [11] | ||||||||||||||||||||||||||
|
Subroutine
note_nrs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head1 FIELD ACCESSORS | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =over 4 | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =item id | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Returns the Station id. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =item country | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Returns the two-character GEC country code for the station. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item state | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | Returns the two-character state code for US stations, or province code for | ||||||||||||||||||||||||||||
| 88 | Canadian stations. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item active | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Returns the active range of the station. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =item lat | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Returns the station latitude. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =item long | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Returns the station longitude. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =item elev | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Returns the station elevation. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =item name | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | Returns the station name. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =item gsn | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Returns the boolean indicating whether this is a GSN station. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =item elems_href | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Returns a hash reference for the measurements available from the | ||||||||||||||||||||||||||||
| 117 | station daily data records. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =item idx | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Returns an index number which is shared by stations that have the | ||||||||||||||||||||||||||||
| 122 | same physical location; i.e. latitude and longitude. When station | ||||||||||||||||||||||||||||
| 123 | instrumentation is changed or there are other significant changes, | ||||||||||||||||||||||||||||
| 124 | a new station id may be assigned. This index enables you to group | ||||||||||||||||||||||||||||
| 125 | together stations that represent the same spot but which may have | ||||||||||||||||||||||||||||
| 126 | different active time periods. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =item note_nrs | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | Returns a number range string that represents notes which are errors | ||||||||||||||||||||||||||||
| 131 | or warnings about the station. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =back | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||||||||||
| 136 | ###################################################################### | ||||||||||||||||||||||||||||
| 137 | # Class (:common) methods | ||||||||||||||||||||||||||||
| 138 | ###################################################################### | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =head1 CLASS METHODS | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head2 new () | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Create a new Station object. | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head2 Headings () | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | Column headings may be needed prior to creating any Station instances, | ||||||||||||||||||||||||||||
| 150 | for example to print them before any data is loaded. This Headings | ||||||||||||||||||||||||||||
| 151 | class method is provided to handle that situation. There is a | ||||||||||||||||||||||||||||
| 152 | corresponding instance method. | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | If called in list context, a list is return; in scalar context, a | ||||||||||||||||||||||||||||
| 155 | list reference is returned. | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | method Headings :common { | ||||||||||||||||||||||||||||
| 160 | my @h = qw(StationId Country State Active Lat Long Elev Location Notes StnIdx Grid ); | ||||||||||||||||||||||||||||
| 161 | return wantarray ? @h : \@h; | ||||||||||||||||||||||||||||
| 162 | 4 | } | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | ###################################################################### | ||||||||||||||||||||||||||||
| 165 | # Instance methods | ||||||||||||||||||||||||||||
| 166 | ###################################################################### | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =head1 INSTANCE METHODS | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =head2 headings | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | See Headings in Class Methods. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | method headings { | ||||||||||||||||||||||||||||
| 177 | 2 | ▶ | my @h = Headings; | ||||||||||||||||||||||||||
|
Subroutine
headings: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 2 | ▶ | return wantarray ? @h : \@h; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 4 | } | |||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head2 add_note ($note_id, $msg=undef, $verbose=$FALSE) | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | This method allows you to add numbered notes to each station object. | ||||||||||||||||||||||||||||
| 184 | It is up to the caller to assign meaning to the numbers. They are | ||||||||||||||||||||||||||||
| 185 | stored in a range list (i.e. a Set::IntSpan::Fast object) so that | ||||||||||||||||||||||||||||
| 186 | they can be printed compactly even if there a gaps in the number ranges. | ||||||||||||||||||||||||||||
| 187 | For example, notes 1, 5 and 20 through 25 will print as 1,5,20-25. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | The message argument is optional, but if you provide a message then | ||||||||||||||||||||||||||||
| 190 | it will be display on STDERR if it is considered an error message. | ||||||||||||||||||||||||||||
| 191 | The threshold is 50 (as established by the hard coded constant | ||||||||||||||||||||||||||||
| 192 | $ERR_THRESHOLD). Anything below that is considered an error. Otherwise | ||||||||||||||||||||||||||||
| 193 | it's considered a warning. | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | When the $VERBOSE argument is true, it causes warnings to also print | ||||||||||||||||||||||||||||
| 196 | to STDERR. | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 4 | ▶ | method add_note ($note_id, $msg=undef, $verbose=$FALSE) { | ||||||||||||||||||||||||||
|
Subroutine
add_note: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 201 | 4 | $note_nrs->add_from_string($note_id); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 4 | ▶ | return unless $msg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 3 | ▶ | if ($note_id < $ERR_THRESHOLD) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 1 | say {*STDERR} '*E* ', $msg; | |||||||||||||||||||||||||||
| 207 | } else { | ||||||||||||||||||||||||||||
| 208 | 2 | ▶ | say {*STDERR} '*W* ', $msg if $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 3 | return; | |||||||||||||||||||||||||||
| 212 | 4 | } | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =head2 row | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | Returns the station object as a list of field values. The fields | ||||||||||||||||||||||||||||
| 217 | are: | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | $id, $country, $state, $active, $lat, $long, $elev, $name, | ||||||||||||||||||||||||||||
| 220 | $note_text, $idx, $grid> | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | The second last value, $idx is a unique serial index number provided | ||||||||||||||||||||||||||||
| 223 | by GHCH::StationTable during load_stations(). Unless set by a consumer | ||||||||||||||||||||||||||||
| 224 | of this module, its value will be B<undef>. | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | The last value, $grid, is a string derived by truncating $lat and | ||||||||||||||||||||||||||||
| 227 | $long to 1 decimal place, converting them to N/S W/E format, and | ||||||||||||||||||||||||||||
| 228 | concatenting them. This results in a box that defines an area within | ||||||||||||||||||||||||||||
| 229 | which there may be other nearby stations of interest. | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | If called in list context, a list is return; in scalar context, a | ||||||||||||||||||||||||||||
| 232 | list reference is returned. | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | =cut | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | method row { | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 3 | ▶ | my $note_text = $note_nrs->cardinality ? '[' . $note_nrs->as_string . ']' : $EMPTY; | ||||||||||||||||||||||||||
|
Subroutine
row: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 3 | my @row = ( | |||||||||||||||||||||||||||
| 241 | $id, | ||||||||||||||||||||||||||||
| 242 | $country, | ||||||||||||||||||||||||||||
| 243 | $state, | ||||||||||||||||||||||||||||
| 244 | $active, | ||||||||||||||||||||||||||||
| 245 | $lat, | ||||||||||||||||||||||||||||
| 246 | $long, | ||||||||||||||||||||||||||||
| 247 | $elev, | ||||||||||||||||||||||||||||
| 248 | $name, | ||||||||||||||||||||||||||||
| 249 | $note_text, | ||||||||||||||||||||||||||||
| 250 | $idx, | ||||||||||||||||||||||||||||
| 251 | $self->grid, | ||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 3 | ▶ | return wantarray ? @row : \@row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 4 | } | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =head2 coordinates | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | Returns the latitude and longitude coordinates of the station in | ||||||||||||||||||||||||||||
| 260 | decimal format as a space-separated string. | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =cut | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | method coordinates { | ||||||||||||||||||||||||||||
| 265 | # uncoverable branch true | ||||||||||||||||||||||||||||
| 266 | # uncoverable condition left | ||||||||||||||||||||||||||||
| 267 | # uncoverable condition right | ||||||||||||||||||||||||||||
| 268 | 1 | ▶ | return $EMPTY unless $lat and $long; | ||||||||||||||||||||||||||
|
Subroutine
coordinates: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
Condition100%3/3
$lat and $long
MC/DC0%0/2
$lat and $long
-$lat
-$long
Truth table33%1/3
A and B
A= $latB= $long
| |||||||||||||||||||||||||||||
| 269 | 1 | return sprintf '%f %f', $lat, $long; | |||||||||||||||||||||||||||
| 270 | 4 | } | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 description | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Return lines of text which describe the station in attribute: value | ||||||||||||||||||||||||||||
| 275 | format. | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =cut | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | method description { | ||||||||||||||||||||||||||||
| 280 | # uncoverable branch true | ||||||||||||||||||||||||||||
| 281 | 1 | ▶ | my $is_gsn = $gsn ? 'yes' : 'no'; | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | 1 | my $elems = join q( ), sort keys $elems_href->%*; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | # note: those the values are lined up here, they won't be when | ||||||||||||||||||||||||||||
| 285 | # imported into Google Earth | ||||||||||||||||||||||||||||
| 286 | 1 | my $text = <<~"_EOT_"; | |||||||||||||||||||||||||||
| 287 | Id: $id | ||||||||||||||||||||||||||||
| 288 | Name: $name | ||||||||||||||||||||||||||||
| 289 | Country: $country | ||||||||||||||||||||||||||||
| 290 | State: $state | ||||||||||||||||||||||||||||
| 291 | Active: $active | ||||||||||||||||||||||||||||
| 292 | Coord: $lat $long | ||||||||||||||||||||||||||||
| 293 | Elev: $elev | ||||||||||||||||||||||||||||
| 294 | Is GSN? $is_gsn | ||||||||||||||||||||||||||||
| 295 | Metrics: $elems | ||||||||||||||||||||||||||||
| 296 | _EOT_ | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 1 | return $text; | |||||||||||||||||||||||||||
| 299 | 4 | } | |||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head2 error_count | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Returns a count of the number of errors that were flagged for this | ||||||||||||||||||||||||||||
| 304 | station. Errors generally make the station unsuitable for use. | ||||||||||||||||||||||||||||
| 305 | Warnings are not included. | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =cut | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | method error_count { | ||||||||||||||||||||||||||||
| 310 | 1 | ▶ | my $err_count = grep { $_ < $ERR_THRESHOLD } $note_nrs->as_array; | ||||||||||||||||||||||||||
|
Subroutine
error_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 1 | return $err_count; | |||||||||||||||||||||||||||
| 313 | 4 | } | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | =head2 grid | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | Returns the latitude and longitude to a single decimal place and using | ||||||||||||||||||||||||||||
| 318 | cardinal (N/S E/W) notation. This value can be used for grouping | ||||||||||||||||||||||||||||
| 319 | together stations that are within a 1/10th degree grid and which | ||||||||||||||||||||||||||||
| 320 | may be assumed to experience similar weather conditions. | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | =cut | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | method grid { | ||||||||||||||||||||||||||||
| 325 | 4 | ▶ | my ($x, $y) = ($lat, $long); | ||||||||||||||||||||||||||
|
Subroutine
grid: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 326 | # uncoverable branch true | ||||||||||||||||||||||||||||
| 327 | 4 | ▶ | my $xh = $x < 0 ? 'S' : 'N'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | # uncoverable branch false | ||||||||||||||||||||||||||||
| 329 | 4 | ▶ | my $yh = $y < 0 ? 'W' : 'E'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | ## no critic [ProhibitMagicNumbers] | ||||||||||||||||||||||||||||
| 332 | # uncoverable branch true | ||||||||||||||||||||||||||||
| 333 | 4 | ▶ | $x *= $x < 0 ? -1 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | # uncoverable branch false | ||||||||||||||||||||||||||||
| 335 | 4 | ▶ | $y *= $y < 0 ? -1 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 4 | my $grid = sprintf '%4.1f%s %4.1f%s', $x, $xh, $y, $yh; | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 4 | return $grid; | |||||||||||||||||||||||||||
| 340 | 4 | } | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | =head2 selected | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | Returns a boolean indicating whether the station was selected for | ||||||||||||||||||||||||||||
| 345 | data loading. Selected stations are those that meet the filtering | ||||||||||||||||||||||||||||
| 346 | criteria (station id, station name, active range etc.) and that | ||||||||||||||||||||||||||||
| 347 | are not flagged with errors. | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | method selected { | ||||||||||||||||||||||||||||
| 352 | # uncoverable branch true | ||||||||||||||||||||||||||||
| 353 | 1 | ▶ | return $note_nrs->cardinality == 0 ? $TRUE : $FALSE; | ||||||||||||||||||||||||||
|
Subroutine
selected: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 4 | } | |||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =head2 url | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | Returns the URL for the station's daily data web page in the NOAA | ||||||||||||||||||||||||||||
| 359 | GHCN data repository. | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =cut | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | method url { | ||||||||||||||||||||||||||||
| 364 | 1 | ▶ | return $NOAA_DATA . $id . '.dly'; | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 365 | 4 | } | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | =head2 DOES | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | Defined by Object::Pad. Included for POD::Coverage. | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =head2 META | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | Defined by Object::Pad. Included for POD::Coverage. | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | Gary Puckering (jgpuckering@rogers.com) | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | Copyright 2022, Gary Puckering | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =cut | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 4 | 1; | |||||||||||||||||||||||||||