Class: TCD::Station
- Inherits:
-
Struct
- Object
- Struct
- TCD::Station
- Defined in:
- lib/tcd/station.rb
Overview
Base station record with fields common to all station types
Instance Attribute Summary collapse
-
#amplitudes ⇒ Object
Returns the value of attribute amplitudes.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#confidence ⇒ Object
Returns the value of attribute confidence.
-
#country ⇒ Object
Returns the value of attribute country.
-
#date_imported ⇒ Object
Returns the value of attribute date_imported.
-
#datum ⇒ Object
Returns the value of attribute datum.
-
#datum_offset ⇒ Object
Returns the value of attribute datum_offset.
-
#direction_units ⇒ Object
Returns the value of attribute direction_units.
-
#ebb_begins ⇒ Object
Returns the value of attribute ebb_begins.
-
#epochs ⇒ Object
Returns the value of attribute epochs.
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#flood_begins ⇒ Object
Returns the value of attribute flood_begins.
-
#last_date_on_station ⇒ Object
Returns the value of attribute last_date_on_station.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#legalese ⇒ Object
Returns the value of attribute legalese.
-
#level_units ⇒ Object
Returns the value of attribute level_units.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#max_direction ⇒ Object
Returns the value of attribute max_direction.
-
#max_level_add ⇒ Object
Returns the value of attribute max_level_add.
-
#max_level_multiply ⇒ Object
Returns the value of attribute max_level_multiply.
-
#max_time_add ⇒ Object
Returns the value of attribute max_time_add.
-
#min_direction ⇒ Object
Returns the value of attribute min_direction.
-
#min_level_add ⇒ Object
Returns the value of attribute min_level_add.
-
#min_level_multiply ⇒ Object
Returns the value of attribute min_level_multiply.
-
#min_time_add ⇒ Object
Returns the value of attribute min_time_add.
-
#months_on_station ⇒ Object
Returns the value of attribute months_on_station.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#record_number ⇒ Object
Returns the value of attribute record_number.
-
#record_size ⇒ Object
Returns the value of attribute record_size.
-
#record_type ⇒ Object
Returns the value of attribute record_type.
-
#reference_station ⇒ Object
Returns the value of attribute reference_station.
-
#restriction ⇒ Object
Returns the value of attribute restriction.
-
#source ⇒ Object
Returns the value of attribute source.
-
#station_id ⇒ Object
Returns the value of attribute station_id.
-
#station_id_context ⇒ Object
Returns the value of attribute station_id_context.
-
#tzfile ⇒ Object
Returns the value of attribute tzfile.
-
#xfields ⇒ Object
Returns the value of attribute xfields.
-
#zone_offset ⇒ Object
Returns the value of attribute zone_offset.
Instance Method Summary collapse
-
#active_constituents ⇒ Object
Count of non-zero amplitude constituents.
-
#current? ⇒ Boolean
Check if this station has current (not tide) data.
- #reference? ⇒ Boolean
-
#simple? ⇒ Boolean
Check if this is a “simple” subordinate station.
- #subordinate? ⇒ Boolean
-
#tide? ⇒ Boolean
Check if this station has tide (not current) data.
- #to_s ⇒ Object
Instance Attribute Details
#amplitudes ⇒ Object
Returns the value of attribute amplitudes
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def amplitudes @amplitudes end |
#comments ⇒ Object
Returns the value of attribute comments
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def comments @comments end |
#confidence ⇒ Object
Returns the value of attribute confidence
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def confidence @confidence end |
#country ⇒ Object
Returns the value of attribute country
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def country @country end |
#date_imported ⇒ Object
Returns the value of attribute date_imported
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def date_imported @date_imported end |
#datum ⇒ Object
Returns the value of attribute datum
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def datum @datum end |
#datum_offset ⇒ Object
Returns the value of attribute datum_offset
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def datum_offset @datum_offset end |
#direction_units ⇒ Object
Returns the value of attribute direction_units
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def direction_units @direction_units end |
#ebb_begins ⇒ Object
Returns the value of attribute ebb_begins
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def ebb_begins @ebb_begins end |
#epochs ⇒ Object
Returns the value of attribute epochs
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def epochs @epochs end |
#expiration_date ⇒ Object
Returns the value of attribute expiration_date
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def expiration_date @expiration_date end |
#flood_begins ⇒ Object
Returns the value of attribute flood_begins
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def flood_begins @flood_begins end |
#last_date_on_station ⇒ Object
Returns the value of attribute last_date_on_station
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def last_date_on_station @last_date_on_station end |
#latitude ⇒ Object
Returns the value of attribute latitude
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def latitude @latitude end |
#legalese ⇒ Object
Returns the value of attribute legalese
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def legalese @legalese end |
#level_units ⇒ Object
Returns the value of attribute level_units
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def level_units @level_units end |
#longitude ⇒ Object
Returns the value of attribute longitude
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def longitude @longitude end |
#max_direction ⇒ Object
Returns the value of attribute max_direction
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def max_direction @max_direction end |
#max_level_add ⇒ Object
Returns the value of attribute max_level_add
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def max_level_add @max_level_add end |
#max_level_multiply ⇒ Object
Returns the value of attribute max_level_multiply
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def max_level_multiply @max_level_multiply end |
#max_time_add ⇒ Object
Returns the value of attribute max_time_add
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def max_time_add @max_time_add end |
#min_direction ⇒ Object
Returns the value of attribute min_direction
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def min_direction @min_direction end |
#min_level_add ⇒ Object
Returns the value of attribute min_level_add
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def min_level_add @min_level_add end |
#min_level_multiply ⇒ Object
Returns the value of attribute min_level_multiply
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def min_level_multiply @min_level_multiply end |
#min_time_add ⇒ Object
Returns the value of attribute min_time_add
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def min_time_add @min_time_add end |
#months_on_station ⇒ Object
Returns the value of attribute months_on_station
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def months_on_station @months_on_station end |
#name ⇒ Object
Returns the value of attribute name
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def notes @notes end |
#record_number ⇒ Object
Returns the value of attribute record_number
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def record_number @record_number end |
#record_size ⇒ Object
Returns the value of attribute record_size
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def record_size @record_size end |
#record_type ⇒ Object
Returns the value of attribute record_type
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def record_type @record_type end |
#reference_station ⇒ Object
Returns the value of attribute reference_station
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def reference_station @reference_station end |
#restriction ⇒ Object
Returns the value of attribute restriction
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def restriction @restriction end |
#source ⇒ Object
Returns the value of attribute source
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def source @source end |
#station_id ⇒ Object
Returns the value of attribute station_id
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def station_id @station_id end |
#station_id_context ⇒ Object
Returns the value of attribute station_id_context
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def station_id_context @station_id_context end |
#tzfile ⇒ Object
Returns the value of attribute tzfile
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def tzfile @tzfile end |
#xfields ⇒ Object
Returns the value of attribute xfields
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def xfields @xfields end |
#zone_offset ⇒ Object
Returns the value of attribute zone_offset
9 10 11 |
# File 'lib/tcd/station.rb', line 9 def zone_offset @zone_offset end |
Instance Method Details
#active_constituents ⇒ Object
Count of non-zero amplitude constituents
68 69 70 71 |
# File 'lib/tcd/station.rb', line 68 def active_constituents return 0 unless amplitudes amplitudes.count { |a| a && a > 0 } end |
#current? ⇒ Boolean
Check if this station has current (not tide) data. Current stations have direction fields and/or flood/ebb slack times. These are the definitive indicators of current data.
96 97 98 99 100 101 102 103 104 |
# File 'lib/tcd/station.rb', line 96 def current? # Reference stations with direction data are current stations return true if min_direction || max_direction # Subordinate stations with flood/ebb times are current stations return true if flood_begins || ebb_begins false end |
#reference? ⇒ Boolean
59 60 61 |
# File 'lib/tcd/station.rb', line 59 def reference? record_type == 1 end |
#simple? ⇒ Boolean
Check if this is a “simple” subordinate station. A simple subordinate has identical high/low offsets, no direction data, and no flood/ebb slack times. This is common for tide stations (as opposed to current stations which have direction/slack data).
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/tcd/station.rb', line 79 def simple? return false unless subordinate? max_time_add == min_time_add && max_level_add == min_level_add && max_level_multiply == min_level_multiply && min_direction.nil? && max_direction.nil? && flood_begins.nil? && ebb_begins.nil? end |
#subordinate? ⇒ Boolean
63 64 65 |
# File 'lib/tcd/station.rb', line 63 def subordinate? record_type == 2 end |
#tide? ⇒ Boolean
Check if this station has tide (not current) data. Tide stations do not have current-specific indicators (direction, flood/ebb). Note: subordinate tide stations may have different high/low corrections.
111 112 113 |
# File 'lib/tcd/station.rb', line 111 def tide? !current? end |
#to_s ⇒ Object
115 116 117 118 |
# File 'lib/tcd/station.rb', line 115 def to_s type_str = reference? ? "Reference" : "Subordinate" "#{name} (#{type_str}) @ #{format('%.5f', latitude)}, #{format('%.5f', longitude)}" end |