Class: NetCDF::TimeVariable

Inherits:
Variable show all
Defined in:
lib/netcdf/variable.rb

Overview

Instance Attribute Summary collapse

Attributes inherited from Variable

#attributes, #dimensions, #index_iterator

Attributes inherited from CDMNode

#netcdf_elmt

Instance Method Summary collapse

Methods inherited from Variable

#cached_data?, #caching=, #caching?, #coordinate_variable?, #create_new_cache, #extra_info, #find_attribute, #find_attributes, #find_dimension_index, #find_dimensions, #get_data_type, #get_description, #get_dimension, #get_dimensions_string, #get_element_size, #get_name_and_dimensions, #get_rank, #get_shape, #get_size, #get_units_string, #immutable?, #invalidate_cache, #metadata?, #print, #read, #read_scalar, #scalar?, #section, #set_cached_data, #to_string, #to_string_debug, #unlimited?, #unsigned?, #variable_length?

Methods inherited from CDMNode

#get_full_name, #get_short_name

Constructor Details

#initialize(netcdf_variable) ⇒ TimeVariable


Initializes the Variable by giving a java netcdf_variable



484
485
486
487
488
489
490
491
492
# File 'lib/netcdf/variable.rb', line 484

def initialize(netcdf_variable)

  super(netcdf_variable)
  @calendar = @netcdf_elmt.findAttribute("calendar").getStringValue()
  @units = @netcdf_elmt.findAttribute("units").getStringValue()
  date_unit = CalendarDateUnit.of(@calendar, @units)
  @base_date = date_unit.getBaseCalendarDate()

end

Instance Attribute Details

#base_dateObject (readonly)

Returns the value of attribute base_date


478
479
480
# File 'lib/netcdf/variable.rb', line 478

def base_date
  @base_date
end

#calendarObject (readonly)

Returns the value of attribute calendar


476
477
478
# File 'lib/netcdf/variable.rb', line 476

def calendar
  @calendar
end

#unitsObject (readonly)

Returns the value of attribute units


477
478
479
# File 'lib/netcdf/variable.rb', line 477

def units
  @units
end

Instance Method Details

#nextObject




510
511
512
513
514
515
# File 'lib/netcdf/variable.rb', line 510

def next

  millisec_date = super
  @base_date.add(millisec_date, CalendarPeriod.fromUnitString("Millisec")).toString()

end

#to_msec(iso_date) ⇒ Object


Returns the number of milliseconds elapsed from the base_date to the given date. The given date should be in iso_format.



499
500
501
502
503
504
# File 'lib/netcdf/variable.rb', line 499

def to_msec(iso_date)

  date = CalendarDate.parseISOformat(@calendar, iso_date)
  date.getDifferenceInMsecs(@base_date)

end