Class: TCD::Station

Inherits:
Struct
  • Object
show all
Defined in:
lib/tcd/station.rb

Overview

Base station record with fields common to all station types

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amplitudesObject

Returns the value of attribute amplitudes

Returns:

  • (Object)

    the current value of amplitudes



9
10
11
# File 'lib/tcd/station.rb', line 9

def amplitudes
  @amplitudes
end

#commentsObject

Returns the value of attribute comments

Returns:

  • (Object)

    the current value of comments



9
10
11
# File 'lib/tcd/station.rb', line 9

def comments
  @comments
end

#confidenceObject

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



9
10
11
# File 'lib/tcd/station.rb', line 9

def confidence
  @confidence
end

#countryObject

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



9
10
11
# File 'lib/tcd/station.rb', line 9

def country
  @country
end

#date_importedObject

Returns the value of attribute date_imported

Returns:

  • (Object)

    the current value of date_imported



9
10
11
# File 'lib/tcd/station.rb', line 9

def date_imported
  @date_imported
end

#datumObject

Returns the value of attribute datum

Returns:

  • (Object)

    the current value of datum



9
10
11
# File 'lib/tcd/station.rb', line 9

def datum
  @datum
end

#datum_offsetObject

Returns the value of attribute datum_offset

Returns:

  • (Object)

    the current value of datum_offset



9
10
11
# File 'lib/tcd/station.rb', line 9

def datum_offset
  @datum_offset
end

#direction_unitsObject

Returns the value of attribute direction_units

Returns:

  • (Object)

    the current value of direction_units



9
10
11
# File 'lib/tcd/station.rb', line 9

def direction_units
  @direction_units
end

#ebb_beginsObject

Returns the value of attribute ebb_begins

Returns:

  • (Object)

    the current value of ebb_begins



9
10
11
# File 'lib/tcd/station.rb', line 9

def ebb_begins
  @ebb_begins
end

#epochsObject

Returns the value of attribute epochs

Returns:

  • (Object)

    the current value of epochs



9
10
11
# File 'lib/tcd/station.rb', line 9

def epochs
  @epochs
end

#expiration_dateObject

Returns the value of attribute expiration_date

Returns:

  • (Object)

    the current value of expiration_date



9
10
11
# File 'lib/tcd/station.rb', line 9

def expiration_date
  @expiration_date
end

#flood_beginsObject

Returns the value of attribute flood_begins

Returns:

  • (Object)

    the current value of flood_begins



9
10
11
# File 'lib/tcd/station.rb', line 9

def flood_begins
  @flood_begins
end

#last_date_on_stationObject

Returns the value of attribute last_date_on_station

Returns:

  • (Object)

    the current value of last_date_on_station



9
10
11
# File 'lib/tcd/station.rb', line 9

def last_date_on_station
  @last_date_on_station
end

#latitudeObject

Returns the value of attribute latitude

Returns:

  • (Object)

    the current value of latitude



9
10
11
# File 'lib/tcd/station.rb', line 9

def latitude
  @latitude
end

#legaleseObject

Returns the value of attribute legalese

Returns:

  • (Object)

    the current value of legalese



9
10
11
# File 'lib/tcd/station.rb', line 9

def legalese
  @legalese
end

#level_unitsObject

Returns the value of attribute level_units

Returns:

  • (Object)

    the current value of level_units



9
10
11
# File 'lib/tcd/station.rb', line 9

def level_units
  @level_units
end

#longitudeObject

Returns the value of attribute longitude

Returns:

  • (Object)

    the current value of longitude



9
10
11
# File 'lib/tcd/station.rb', line 9

def longitude
  @longitude
end

#max_directionObject

Returns the value of attribute max_direction

Returns:

  • (Object)

    the current value of max_direction



9
10
11
# File 'lib/tcd/station.rb', line 9

def max_direction
  @max_direction
end

#max_level_addObject

Returns the value of attribute max_level_add

Returns:

  • (Object)

    the current value of max_level_add



9
10
11
# File 'lib/tcd/station.rb', line 9

def max_level_add
  @max_level_add
end

#max_level_multiplyObject

Returns the value of attribute max_level_multiply

Returns:

  • (Object)

    the current value of max_level_multiply



9
10
11
# File 'lib/tcd/station.rb', line 9

def max_level_multiply
  @max_level_multiply
end

#max_time_addObject

Returns the value of attribute max_time_add

Returns:

  • (Object)

    the current value of max_time_add



9
10
11
# File 'lib/tcd/station.rb', line 9

def max_time_add
  @max_time_add
end

#min_directionObject

Returns the value of attribute min_direction

Returns:

  • (Object)

    the current value of min_direction



9
10
11
# File 'lib/tcd/station.rb', line 9

def min_direction
  @min_direction
end

#min_level_addObject

Returns the value of attribute min_level_add

Returns:

  • (Object)

    the current value of min_level_add



9
10
11
# File 'lib/tcd/station.rb', line 9

def min_level_add
  @min_level_add
end

#min_level_multiplyObject

Returns the value of attribute min_level_multiply

Returns:

  • (Object)

    the current value of min_level_multiply



9
10
11
# File 'lib/tcd/station.rb', line 9

def min_level_multiply
  @min_level_multiply
end

#min_time_addObject

Returns the value of attribute min_time_add

Returns:

  • (Object)

    the current value of min_time_add



9
10
11
# File 'lib/tcd/station.rb', line 9

def min_time_add
  @min_time_add
end

#months_on_stationObject

Returns the value of attribute months_on_station

Returns:

  • (Object)

    the current value of months_on_station



9
10
11
# File 'lib/tcd/station.rb', line 9

def months_on_station
  @months_on_station
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



9
10
11
# File 'lib/tcd/station.rb', line 9

def name
  @name
end

#notesObject

Returns the value of attribute notes

Returns:

  • (Object)

    the current value of notes



9
10
11
# File 'lib/tcd/station.rb', line 9

def notes
  @notes
end

#record_numberObject

Returns the value of attribute record_number

Returns:

  • (Object)

    the current value of record_number



9
10
11
# File 'lib/tcd/station.rb', line 9

def record_number
  @record_number
end

#record_sizeObject

Returns the value of attribute record_size

Returns:

  • (Object)

    the current value of record_size



9
10
11
# File 'lib/tcd/station.rb', line 9

def record_size
  @record_size
end

#record_typeObject

Returns the value of attribute record_type

Returns:

  • (Object)

    the current value of record_type



9
10
11
# File 'lib/tcd/station.rb', line 9

def record_type
  @record_type
end

#reference_stationObject

Returns the value of attribute reference_station

Returns:

  • (Object)

    the current value of reference_station



9
10
11
# File 'lib/tcd/station.rb', line 9

def reference_station
  @reference_station
end

#restrictionObject

Returns the value of attribute restriction

Returns:

  • (Object)

    the current value of restriction



9
10
11
# File 'lib/tcd/station.rb', line 9

def restriction
  @restriction
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



9
10
11
# File 'lib/tcd/station.rb', line 9

def source
  @source
end

#station_idObject

Returns the value of attribute station_id

Returns:

  • (Object)

    the current value of station_id



9
10
11
# File 'lib/tcd/station.rb', line 9

def station_id
  @station_id
end

#station_id_contextObject

Returns the value of attribute station_id_context

Returns:

  • (Object)

    the current value of station_id_context



9
10
11
# File 'lib/tcd/station.rb', line 9

def station_id_context
  @station_id_context
end

#tzfileObject

Returns the value of attribute tzfile

Returns:

  • (Object)

    the current value of tzfile



9
10
11
# File 'lib/tcd/station.rb', line 9

def tzfile
  @tzfile
end

#xfieldsObject

Returns the value of attribute xfields

Returns:

  • (Object)

    the current value of xfields



9
10
11
# File 'lib/tcd/station.rb', line 9

def xfields
  @xfields
end

#zone_offsetObject

Returns the value of attribute zone_offset

Returns:

  • (Object)

    the current value of zone_offset



9
10
11
# File 'lib/tcd/station.rb', line 9

def zone_offset
  @zone_offset
end

Instance Method Details

#active_constituentsObject

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.

Returns:

  • (Boolean)

    true if this is a current station



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

Returns:

  • (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).

Returns:

  • (Boolean)

    true if simple, false otherwise (always false for reference stations)



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

Returns:

  • (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.

Returns:

  • (Boolean)

    true if this is a tide station



111
112
113
# File 'lib/tcd/station.rb', line 111

def tide?
    !current?
end

#to_sObject



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