Class: Radiation::Resource::Nucleideorg
- Defined in:
- lib/radiation/resource/nucleideorg.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Radiation::Resource::Base
Instance Method Details
#fetch(nuclide) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/radiation/resource/nucleideorg.rb', line 11 def fetch(nuclide) @nuclide = nuclide @nuclide = "Ra-226D" if @nuclide == "Ra-226" #Ra-226 in equilibrium with daughters begin @data[:nuclide] = @nuclide.to_s @data[:reference] = "A. Pluquet et al. (2013). Recommended data for #{@nuclide} by the Decay Data Evaluation Project working group. Decay Data Evaluation Project, Laboratoire National Henri Becquerel, C.E. Saclay. Retrieved from http://www.nucleide.org/DDEP_WG/Nuclides/#{@nuclide}.lara.txt" OpenURI::Cache.cache_path = "#{Dir.tmpdir}/radiation/" uri = open("http://www.nucleide.org/DDEP_WG/Nuclides/#{@nuclide}.lara.txt").readlines start = 0 uri.each_with_index do |line, lineno| if line.start_with?("Half-life (s)") row = line.split(' ; ') @data[:halflife] = row[1].to_f.pm(row[2].to_f) end if line.start_with?("------") start = lineno + 2 break end end return @data[:transitions] = [] if start == 0 or uri.count < start @data[:transitions] = uri[start...-1].collect{|line| line.split(' ; ')}.select!{|row| row[4] == "g"}.collect do |row| {:energy => row[0].to_f.pm(row[1].to_f), :intensity => row[2].to_f.pm(row[3].to_f)} end rescue raise "No Data for #{@nuclide}" end self end |