Class: NetCDF::File
- Inherits:
-
FileParent
- Object
- FileParent
- NetCDF::File
- 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
-
#can_open? ⇒ Boolean
———————————————————————————— Find out if the file can be opened, but dont actually open it.
-
#close ⇒ Object
———————————————————————————— closes the file ————————————————————————————.
-
#detail_info ⇒ Object
———————————————————————————— Find all dimensions in the file ————————————————————————————.
-
#empty ⇒ Object
———————————————————————————— Completely empty the objects in the netcdf file.
-
#file_type_description ⇒ Object
———————————————————————————— Get a human-readable description for this file type.
-
#file_type_id ⇒ Object
———————————————————————————— Get the file type id for the underlying data source.
-
#find_attribute(name) ⇒ Object
———————————————————————————— Find an attribute, with the specified (escaped full) name.
-
#find_dimension(name) ⇒ Object
———————————————————————————— Finds a dimension by full name ————————————————————————————.
-
#find_global_attribute(name, ignore_case = false) ⇒ Object
———————————————————————————— Find an global attribute, with the specified (full) name.
-
#find_group(name) ⇒ Object
———————————————————————————— Find a Group, with the specified (full) name.
-
#find_unlimited_dimension ⇒ Object
(also: #get_unlimited_dimension)
———————————————————————————— Return the unlimited (record) dimension, or null if not exist.
-
#find_variable(name) ⇒ Object
———————————————————————————— Finds a variable by name ————————————————————————————.
-
#get_dimensions ⇒ Object
———————————————————————————— Find all dimensions in the file ————————————————————————————.
-
#id ⇒ Object
———————————————————————————— Get the globally unique dataset identifier, if it exists.
-
#last_modified ⇒ Object
————————————————————————————.
-
#location ⇒ Object
———————————————————————————— Get the NetcdfFile location.
-
#open ⇒ Object
———————————————————————————— Opens a file for reading ————————————————————————————.
-
#title ⇒ Object
———————————————————————————— Get the human-readable title, if it exists.
-
#unlimited_dimension? ⇒ Boolean
———————————————————————————— Get the human-readable title, if it exists.
-
#write_cdl(out = $stdout, strict = false) ⇒ Object
———————————————————————————— Outputs the data CDL to an output stream * TODO: allow writing to other output streams.
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.
83 84 85 |
# File 'lib/netcdf/file.rb', line 83 def can_open? @netcdf_elmt.canOpen(@file_name) end |
#close ⇒ Object
closes the file
91 92 93 |
# File 'lib/netcdf/file.rb', line 91 def close @netcdf_elmt.close() end |
#detail_info ⇒ Object
Find all dimensions in the file
178 179 180 |
# File 'lib/netcdf/file.rb', line 178 def detail_info @netcdf_elmt.getDetailInfo() end |
#empty ⇒ Object
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_description ⇒ Object
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_id ⇒ Object
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_dimension ⇒ Object 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_dimensions ⇒ Object
Find all dimensions in the file
245 246 247 |
# File 'lib/netcdf/file.rb', line 245 def get_dimensions @netcdf_elmt.getDimensions() end |
#id ⇒ Object
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_modified ⇒ Object
210 211 212 |
# File 'lib/netcdf/file.rb', line 210 def last_modified @netcdf_elmt.getLastModified() end |
#location ⇒ Object
Get the NetcdfFile location.
218 219 220 |
# File 'lib/netcdf/file.rb', line 218 def location @netcdf_elmt.getLocation() end |
#open ⇒ Object
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 |
#title ⇒ Object
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.
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 |