Class: NetCDF::File

Inherits:
FileParent show all
Defined in:
lib/netcdf/file.rb

Overview

Read-only scientific datasets that are accessible through the netCDF API. Immutable after setImmutable() is called. However, reading data is not thread-safe.

Instance Attribute Summary

Attributes inherited from FileParent

#file_name, #home_dir, #netcdf_elmt, #outside_scope, #root_group

Instance Method Summary collapse

Methods inherited from FileParent

#global_attributes, #initialize

Constructor Details

This class inherits a constructor from NetCDF::FileParent

Instance Method Details

#can_open?Boolean


Find out if the file can be opened, but dont actually open it.


Returns:

  • (Boolean)


83
84
85
# File 'lib/netcdf/file.rb', line 83

def can_open?
  @netcdf_elmt.canOpen(@file_name)
end

#closeObject


closes the file




91
92
93
# File 'lib/netcdf/file.rb', line 91

def close
  @netcdf_elmt.close()
end

#detail_infoObject


Find all dimensions in the file




178
179
180
# File 'lib/netcdf/file.rb', line 178

def detail_info
  @netcdf_elmt.getDetailInfo()
end

#emptyObject


Completely empty the objects in the netcdf file.




99
100
101
# File 'lib/netcdf/file.rb', line 99

def empty
  @netcdf_elmt.empty()
end

#file_type_descriptionObject


Get a human-readable description for this file type.




186
187
188
# File 'lib/netcdf/file.rb', line 186

def file_type_description
  @netcdf_elmt.getFileTypeDescription()
end

#file_type_idObject


Get the file type id for the underlying data source.




194
195
196
# File 'lib/netcdf/file.rb', line 194

def file_type_id
  @netcdf_elmt.getFileTypeId()
end

#find_attribute(name) ⇒ Object


Find an attribute, with the specified (escaped full) name.




115
116
117
# File 'lib/netcdf/file.rb', line 115

def find_attribute(name)
  NetCDF::Attribute.new(@netcdf_elmt.findAttribute(name))
end

#find_dimension(name) ⇒ Object


Finds a dimension by full name




135
136
137
# File 'lib/netcdf/file.rb', line 135

def find_dimension(name)
  NetCDF::Dimension.new(@netcdf_elmt.findDimension(name))
end

#find_global_attribute(name, ignore_case = false) ⇒ Object


Find an global attribute, with the specified (full) name.




123
124
125
126
127
128
129
# File 'lib/netcdf/file.rb', line 123

def find_global_attribute(name, ignore_case = false)
  if (ignore_case)
    NetCDF::Attribute.new(@netcdf_elmt.findGlobalAttributeIgnoreCase(name))
  else
    NetCDF::Attribute.new(@netcdf_elmt.findGlobalAttribute(name))
  end
end

#find_group(name) ⇒ Object


Find a Group, with the specified (full) name.




107
108
109
# File 'lib/netcdf/file.rb', line 107

def find_group(name)
  NetCDF::Group.new(@netcdf_elmt.findGroup(name))
end

#find_unlimited_dimensionObject Also known as: get_unlimited_dimension


Return the unlimited (record) dimension, or null if not exist. If there are multiple unlimited dimensions, it will return the first one. Returns: the unlimited Dimension, or null if none.




145
146
147
# File 'lib/netcdf/file.rb', line 145

def find_unlimited_dimension
  NetCDF::Dimension.new(@netcdf_elmt.getUnlimitedDimension())
end

#find_variable(name) ⇒ Object


Finds a variable by name




157
158
159
# File 'lib/netcdf/file.rb', line 157

def find_variable(name)
  NetCDF::Variable.new(@netcdf_elmt.findVariable(name))
end

#get_dimensionsObject


Find all dimensions in the file




245
246
247
# File 'lib/netcdf/file.rb', line 245

def get_dimensions
  @netcdf_elmt.getDimensions()
end

#idObject


Get the globally unique dataset identifier, if it exists.




202
203
204
# File 'lib/netcdf/file.rb', line 202

def id
  @netcdf_elmt.getId()
end

#last_modifiedObject





210
211
212
# File 'lib/netcdf/file.rb', line 210

def last_modified
  @netcdf_elmt.getLastModified() 
end

#locationObject


Get the NetcdfFile location.




218
219
220
# File 'lib/netcdf/file.rb', line 218

def location
  @netcdf_elmt.getLocation() 
end

#openObject


Opens a file for reading




74
75
76
77
# File 'lib/netcdf/file.rb', line 74

def open
  @netcdf_elmt = NetcdfFile.open(@file_name)
  @root_group = @netcdf_elmt.findGroup(nil)
end

#titleObject


Get the human-readable title, if it exists.




226
227
228
# File 'lib/netcdf/file.rb', line 226

def title
  @netcdf_elmt.getTitle() 
end

#unlimited_dimension?Boolean


Get the human-readable title, if it exists.


Returns:

  • (Boolean)


234
235
236
# File 'lib/netcdf/file.rb', line 234

def unlimited_dimension?
  @netcdf_elmt.hasUnlimitedDimension() 
end

#write_cdl(out = $stdout, strict = false) ⇒ Object


Outputs the data CDL to an output stream

  • TODO: allow writing to other output streams. Need to interface with java streams

  • strict if true, make it stricly CDL, otherwise, add a little extra info




170
171
172
# File 'lib/netcdf/file.rb', line 170

def write_cdl(out = $stdout, strict = false)
  @netcdf_elmt.writeCDL(out.to_outputstream, strict)
end