Class: Radiation::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/radiation/cli.rb

Instance Method Summary collapse

Instance Method Details

#calibrate(nuclide, file) ⇒ Object



46
47
48
49
50
51
# File 'lib/radiation/cli.rb', line 46

def calibrate(nuclide, file)
	resource = options[:resource] ? options[:resource] : "iaea"
	source   = Radiation::Source.new(nuclide: nuclide, resource: resource)
	spectrum = Radiation::Spectrum.new(source: source ).parse_hdtv(file)
	spectrum.calibrate.calibration.each{|c| puts c}
end

#efficiency(nuclide, file) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/radiation/cli.rb', line 63

def efficiency(nuclide, file)
	resource = options[:resource] ? options[:resource] : "iaea"
	mini = options[:mini] ? options[:mini].to_f : 0.003
	source   = Radiation::Source.new(nuclide: nuclide, resource: resource)
	spectrum = Radiation::Spectrum.new(source: source ).parse_hdtv(file)
	puts ["#E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ", "e", "Δe"].join("\t")
	spectrum.calibrate.efficiencies.peaks.select{|p| p[:intensity] > mini}.sort_by{|k| k[:energy]}.each do |p|
		puts [ p[:energy].nio_write, p[:energy].delta, p[:intensity].nio_write, p[:intensity].delta, p[:efficiency].nio_write, "%.0E" % p[:efficiency].delta ].join("\t")
	end
end

#listObject



24
25
26
27
28
29
30
31
# File 'lib/radiation/cli.rb', line 24

def list
	resource = options[:resource] ? options[:resource] : "iaea"
	puts case resource
		when "iaea" then Radiation::Resource::IAEA.new.list
		when "nucleide.org" then Radiation::Resource::Nucleideorg.new.list
		else raise "Unknown Datasource"
	end
end

#resourcesObject



34
35
36
# File 'lib/radiation/cli.rb', line 34

def resources
	puts Radiation::Source.new.resources
end

#source(nuclide) ⇒ Object



16
17
18
19
20
# File 'lib/radiation/cli.rb', line 16

def source(nuclide)
	resource = options[:resource] ? options[:resource] : "iaea"
	puts ["#E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ"].join("\t")
	puts Radiation::Source.new(nuclide: nuclide, resource: resource).intensities.collect{|l| [l[:energy].nio_write, l[:energy].delta, l[:intensity].nio_write, "%.0E" % l[:intensity].delta].join("\t") }
end

#versionObject



9
10
11
# File 'lib/radiation/cli.rb', line 9

def version
	puts "radiation version #{Radiation::VERSION}"
end