Module: NumRu::NetCDF_Conventions

Defined in:
lib/numru/gphys/netcdf_convention.rb

Overview

Other implicit convention

* to use the "units" attribute to indicate the physical units
  (which is assumed in VArray, the super class of VArrayNetCDF).

Constant Summary collapse

@@fixed =
nil

Class Method Summary collapse

Class Method Details

.add_history(netcdf, str = nil) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/numru/gphys/netcdf_convention.rb', line 176

def add_history(netcdf, str=nil)
  hstatt = netcdf.att('history')
  if hstatt
	history = hstatt.get.chomp + "\n"
  else
	history = ''
  end
  time = Time.now
  history += ( time.respond_to?(:strftime) ? 
               time.strftime('%Y-%m-%d %H:%M:%S %Z ') : time.to_s ) +
             ( ENV['USER'] || '' ) + '>'
  history += (' '+str) if str
  netcdf.put_att('history', history)
end

.find(netcdf) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/numru/gphys/netcdf_convention.rb', line 158

def find( netcdf )
  # netcdf is assumed to be a NetCDF
  if @@fixed
	@@fixed
  else
	convention = (att=netcdf.att('Conventions')) && att.get
	case convention
	#when /gtool/
	#  raise "Sorry, the gtool convention is yet to be supported"
	when /^Wind Profiler/
	  NetCDF_Convention_Wind_Profiler
	else
	  #NetCDF_Convention_Users_Guide
      NetCDF_Convention_CF
	end
  end
end

.fix_to(convention) ⇒ Object



154
155
156
# File 'lib/numru/gphys/netcdf_convention.rb', line 154

def fix_to( convention )
  @@fixed == convention
end