Class: Radiation::Resource::Nucleideorg

Inherits:
Base
  • Object
show all
Defined in:
lib/radiation/resource/nucleideorg.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Radiation::Resource::Base

Instance Method Details

#fetch(nuclide) ⇒ Object



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
41
# File 'lib/radiation/resource/nucleideorg.rb', line 12

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"

		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|
			# Intensities in DDEP are % based
			{:energy => row[0].to_f.pm(row[1].to_f), :intensity => (row[2].to_f/100).pm(row[3].to_f/100)}
		end
	rescue
		raise "No Data for #{@nuclide}"
	end
	self
end

#listObject



43
44
45
# File 'lib/radiation/resource/nucleideorg.rb', line 43

def list
	open("http://www.nucleide.org/DDEP_WG/DDEPdata.htm").read.scan(/Nuclides\/(.*).lara.txt/).flatten
end