Class: NetCDF

Inherits:
Object
  • Object
show all
Defined in:
lib/netcdf/file.rb,
lib/netcdf/group.rb,
lib/netcdf/netcdf.rb,
lib/netcdf/cdm_node.rb,
lib/netcdf/variable.rb,
lib/netcdf/attribute.rb,
lib/netcdf/dimension.rb,
lib/netcdf/file_writer.rb

Overview

Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation, without fee and without a signed licensing agreement, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies, modifications, and distributions.

IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED “AS IS”. RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Defined Under Namespace

Classes: Attribute, AttributeWriter, CDMNode, Dimension, DimensionWriter, File, FileParent, FileWriter, Group, GroupWriter, TimeVariable, Variable, VariableWriter

Class Method Summary collapse

Class Method Details

.define(home_dir, file_name, version, outside_scope = nil, &block) ⇒ Object





35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/netcdf/netcdf.rb', line 35

def self.define(home_dir, file_name, version, outside_scope = nil, &block)

  writer = NetCDF::FileWriter.new_file(home_dir, file_name, version, outside_scope)
  begin
    writer.open
    writer.instance_eval(&block)
    writer.create
    writer.close
    writer
  rescue
    writer.close
    raise "Illegal opperation occured on file: #{writer.file_name}"
  end

end

.get_dtype(type) ⇒ Object





132
133
134
# File 'lib/netcdf/netcdf.rb', line 132

def self.get_dtype(type)
  DataType.valueOf(type.upcase)
end

.output(file_name) ⇒ Object


Outputs the data format




124
125
126
# File 'lib/netcdf/netcdf.rb', line 124

def self.output(file_name)
  print `ncdump #{file_name}`
end

.read(home_dir, file_name, outside_scope = nil, &block) ⇒ Object





103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/netcdf/netcdf.rb', line 103

def self.read(home_dir, file_name, outside_scope = nil, &block)

  reader = NetCDF::File.new(home_dir, file_name, outside_scope)
  begin
    reader.open
    reader.instance_eval(&block)
    reader.close
    reader
  rescue Exception => e
    reader.close
    p e.message
    # raise "Illegal opperation occured on file: #{file_name}"
    raise e
  end

end

.redefine(home_dir, file_name, outside_scope = nil, &block) ⇒ Object





55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/netcdf/netcdf.rb', line 55

def self.redefine(home_dir, file_name, outside_scope = nil, &block)

  writer = NetCDF::FileWriter.existing_file(home_dir, file_name, outside_scope)
  begin
    writer.open
    writer.redefine = true
    # we are not really adding a root group, but actually getting the root group
    # can only be done in define mode
    writer.add_root_group
    writer.instance_eval(&block)
    writer.redefine = false
    writer.close
    writer
  rescue Exception =>e
    writer.close
    p e.message
    # p e.backtrace.inspect
    # raise "Illegal opperation occured on file: #{writer.file_name}"
    raise e
  end

end

.write(home_dir, file_name, outside_scope = nil, &block) ⇒ Object





82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/netcdf/netcdf.rb', line 82

def self.write(home_dir, file_name, outside_scope = nil, &block)

  writer = NetCDF::FileWriter.existing_file(home_dir, file_name, outside_scope)

  begin
    writer.open
    writer.instance_eval(&block)
    writer.close
    writer
  rescue Exception => e
    writer.close
    # raise "Illegal opperation occured on file: #{file_name}"
    raise e
  end

end

.writer_version(name) ⇒ Object





140
141
142
# File 'lib/netcdf/netcdf.rb', line 140

def self.writer_version(name)
  NetcdfFileWriter::Version.valueOf(name)
end