Module: CodeRunner::Trinity::ReadNetcdf

Included in:
CodeRunner::Trinity
Defined in:
lib/trinitycrmod/read_netcdf.rb

Instance Method Summary collapse

Instance Method Details

#new_nccloseObject



30
31
32
33
# File 'lib/trinitycrmod/read_netcdf.rb', line 30

def new_ncclose
  cache[:new_netcdf_file].close
  cache.delete(:new_netcdf_file)
end

#new_netcdf_fileObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trinitycrmod/read_netcdf.rb', line 12

def new_netcdf_file
  if (open = @runner.run_list.keys.find_all{|id|  @runner.run_list[id].cache[:new_netcdf_file]}).size > 200
    open = open.sort_by{|id| @runner.run_list[id].cache[:new_netcdf_file_otime]}
    @runner.run_list[open[0]].new_ncclose
  end

  if cache[:new_netcdf_file] and not [:Complete, :Failed].include? @status
    new_ncclose
  end
  cache[:new_netcdf_file_otime] = Time.now.to_i
  cache[:new_netcdf_file] ||= NumRu::NetCDF.open(new_netcdf_filename)
  #cache[:new_netcdf_file].sync
  cache[:new_netcdf_file]
end

#new_netcdf_filenameObject



27
28
29
# File 'lib/trinitycrmod/read_netcdf.rb', line 27

def new_netcdf_filename
  @directory + '/' +  @run_name + '.out.nc'
end