radiation 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b5bfb4c9fc90f1e6af82e9453053767b9483ade2
4
- data.tar.gz: afb5250753754a77fe44e655c9026c663f7b0b51
5
- SHA512:
6
- metadata.gz: e95bb41b2be01ff2539dc2ea16310c3a789cf5b5d55ee790da0e13bccf58ff0fece8f1a8ea5e3d1061f8787708bb0341a4d97e8c7710f29eccf4bfe36b11686b
7
- data.tar.gz: 215a30b97034057ae3b2f56a97742cf7718f313d8f0de2ea9fb65111abbd8fbda55db9cf5f14475fcef53315d248283c00897d6203952c88e2aa9d2c1f6777e4
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmQ1ZGI5OTEzZDA5M2E3ODRhNWU4YzI4OTM1NzEyNDk5ODcxYWVlNw==
5
+ data.tar.gz: !binary |-
6
+ ZTUyYzhjMzhjZGI1MmRlOTljZTRkMDBkZmFjMmM5ZmQ1NWRlYzJjMg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YzQwZjVkZGExMmY4MGYyZDM4MGYzYzY5MTUwMDZmYzFjMGQ1MDVlZjRiY2Vk
10
+ NjQyMjI1MDEzZjYzYTUyZGM0Mzk0ZDI5ZjNlMDVjNjZjZGU3NjJlNTAzZTMz
11
+ OGIyNjljMTY5MjZjNjE5M2JjMDNhNDNkMDMyNDQ4YjI0YzJkYTM=
12
+ data.tar.gz: !binary |-
13
+ OGY4NmY5OGRmODQ4MDFjMjkzYjExNDdjZGUxYTBlNTI4OTgwMTM1N2JlNThk
14
+ YWY4MmM0M2Q4MTJjMDAyODZlOTI1ZGExNWRhM2I3Y2FlNjUyMGNkNDc1Y2U1
15
+ NDM2ZDMzNDRmZGRmMDVkOGI2N2U2NzNkMjFkZGZlZWExOTM1ZGM=
data/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec CHANGED
@@ -1 +1 @@
1
- #--color
1
+ #--color
data/CHANGELOG.md CHANGED
@@ -1,12 +1,42 @@
1
- ## v0.0.3
2
-
3
- * Added basic parsing for hdtv xml files
4
- * Changed dependency for linefit
5
-
6
- ## v0.0.2
7
-
8
- * Added spectrum class with energy calibration options
9
-
10
- ## v0.0.1
11
-
12
- * initial release
1
+ ## v0.1.4
2
+
3
+ * Added list to resources and CLI
4
+ * Example for 30 seconds en
5
+ * Changed number formatting in CLI, see plusminus nio_write
6
+
7
+ ## v0.1.3
8
+
9
+ * Removed internal resource in favor of IAEA Data
10
+
11
+ ## v0.1.2
12
+
13
+ * Fixing bug with percentage based intensities
14
+ * Gnuplot fitting experiments
15
+
16
+ ## v0.1.1
17
+
18
+ * Weighted fits
19
+ * Added IAEA recommended data
20
+
21
+ ## v0.1.0
22
+
23
+ * Added initial efficiency calculations
24
+ * Modified class structure of resources.
25
+ * Fixed rspec: Replaced round() with be_within
26
+
27
+ ## v0.0.4
28
+
29
+ * Added CLI
30
+
31
+ ## v0.0.3
32
+
33
+ * Added basic parsing for hdtv xml files
34
+ * Changed dependency for linefit
35
+
36
+ ## v0.0.2
37
+
38
+ * Added spectrum class with energy calibration options
39
+
40
+ ## v0.0.1
41
+
42
+ * initial release
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
- source 'https://rubygems.org'
2
-
3
- #gem "linefit", git: "https://github.com/janmayer/linefit.git"
4
- # Specify your gem's dependencies in radiation.gemspec
5
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'coveralls', require: false
4
+ #gem "linefit", git: "https://github.com/janmayer/linefit.git"
5
+ # Specify your gem's dependencies in radiation.gemspec
6
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2013 Jan Mayer
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2013 Jan Mayer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,45 +1,52 @@
1
- # Radiation
2
- [![Gem Version](https://badge.fury.io/rb/radiation.png)](http://badge.fury.io/rb/radiation)
3
- [![Build Status](https://travis-ci.org/janmayer/radiation.png?branch=master)](https://travis-ci.org/janmayer/radiation)
4
- [![Code Climate](https://codeclimate.com/github/janmayer/radiation.png)](https://codeclimate.com/github/janmayer/radiation)
5
-
6
- This gem provides easy access to energies and intensities from the decay of radioactive nuclei.
7
- Currently two data sources are accessible: Internal (see bib files in `./data/`) and recommended values
8
- by [Laboratoire National Henri Becquerel](http://www.nucleide.org/DDEP_WG/DDEPdata.htm).
9
-
10
- ## Example Usage
11
-
12
- ### Command line interface
13
-
14
- $> radiation
15
-
16
- ### In your ruby files:
17
-
18
- require "radiation"
19
- Radiation::Source.new(nuclide: "Ra-226").energies.collect{|e| e.value}
20
-
21
- See also files in `./samples/`.
22
-
23
- ## Planned features
24
-
25
- * Efficiency calibration for given peaks or spectra
26
- * Better access to resources
27
-
28
-
29
- ## Installation
30
-
31
- Requirement is a (local) ruby with rubygems. Using rvm is recommended
32
-
33
- $ \curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
34
-
35
- Add this line to your application's Gemfile:
36
-
37
- gem 'radiation'
38
-
39
- And then execute:
40
-
41
- $ bundle
42
-
43
- Or install it yourself as:
44
-
45
- $ gem install radiation
1
+ # Radiation
2
+ [![Gem Version](https://badge.fury.io/rb/radiation.png)](http://badge.fury.io/rb/radiation)
3
+ [![Build Status](https://travis-ci.org/janmayer/radiation.png?branch=master)](https://travis-ci.org/janmayer/radiation)
4
+ [![Code Climate](https://codeclimate.com/github/janmayer/radiation.png)](https://codeclimate.com/github/janmayer/radiation)
5
+
6
+ This gem provides easy access to energies and intensities from the decay of radioactive nuclei.
7
+ Currently two data sources are accessible:
8
+
9
+ * IAEA [xgamma](http://www-nds.iaea.org/xgamma_standards/) recommended values (default)
10
+ * Laboratoire National Henri Becquerel [DDEP](http://www.nucleide.org/DDEP_WG/DDEPdata.htm) recommended data
11
+
12
+ Note that IAEA data is compiled and filtered with energy and efficiency calibration in mind, while DDEP data ist focused on completeness.
13
+
14
+
15
+ ## Example Usage
16
+
17
+ The radiation gem can be use in two ways:
18
+
19
+ ### Command line interface
20
+
21
+ $ radiation
22
+ $ radiation source Na-22
23
+ => E_ɣ ΔE_ɣ I_ɣ ΔI_ɣ
24
+ => 511.0 0.0 1.798 2E-03
25
+ => 1274.537 0.003 0.9994 1E-04
26
+
27
+ Refer to the CLI for more options.
28
+
29
+ ### In your ruby files:
30
+
31
+ require "radiation"
32
+ Radiation::Source.new(nuclide: "Ra-226").energies.collect{|e| e.value}
33
+
34
+ See files in `./samples/`.
35
+
36
+
37
+ ## Installation
38
+
39
+ Requirement is a (local) ruby with rubygems. Using rvm is recommended
40
+
41
+ ### Installing ruby locally on a debian based system
42
+
43
+ $ \curl -L https://get.rvm.io | bash -s stable
44
+ $ source ~/.bashrc
45
+ $ rvm mount -r http://rvm.io/binaries/debian/7.0/x86_64/ruby-2.0.0-p247.tar.bz2 --verify-downloads 1
46
+ $ rvm use --default 2.0.0
47
+
48
+ ### Installing the gem
49
+
50
+ $ gem install radiation
51
+
52
+ Or use bundler.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/lib/radiation/cli.rb CHANGED
@@ -15,8 +15,19 @@ class CLI < Thor
15
15
  desc "source NUCLIDE", "decay radiation data"
16
16
  def source(nuclide)
17
17
  resource = options[:resource] ? options[:resource] : "iaea"
18
- puts ["E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ"].join("\t")
19
- puts Radiation::Source.new(nuclide: nuclide, resource: resource).intensities.collect{|l| [l[:energy].value, l[:energy].delta, l[:intensity].value, l[:intensity].delta].join("\t") }
18
+ puts ["#E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ"].join("\t")
19
+ 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") }
20
+ end
21
+
22
+ option :resource
23
+ desc "list", "List available nuclei"
24
+ def list
25
+ resource = options[:resource] ? options[:resource] : "iaea"
26
+ puts case resource
27
+ when "iaea" then Radiation::Resource::IAEA.new.list
28
+ when "nucleide.org" then Radiation::Resource::Nucleideorg.new.list
29
+ else raise "Unknown Datasource"
30
+ end
20
31
  end
21
32
 
22
33
  desc "resources", "List available data resources"
@@ -54,9 +65,9 @@ class CLI < Thor
54
65
  mini = options[:mini] ? options[:mini].to_f : 0.003
55
66
  source = Radiation::Source.new(nuclide: nuclide, resource: resource)
56
67
  spectrum = Radiation::Spectrum.new(source: source ).parse_hdtv(file)
57
- puts ["E_ɣ", "I_ɣ", "ΔI_ɣ", "e", "Δe"].join("\t")
68
+ puts ["#E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ", "e", "Δe"].join("\t")
58
69
  spectrum.calibrate.efficiencies.peaks.select{|p| p[:intensity] > mini}.sort_by{|k| k[:energy]}.each do |p|
59
- puts [ p[:energy].to_f.round(1), p[:intensity].value, p[:intensity].delta, p[:efficiency].value.round(1), p[:efficiency].delta.round(1) ].join("\t")
70
+ 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")
60
71
  end
61
72
  end
62
73
 
@@ -10,7 +10,7 @@ module Radiation::Resource
10
10
  def fetch(nuclide)
11
11
  @nuclide = nuclide
12
12
  begin
13
- @data = load_data(@nuclide)
13
+ @data = load_data.select{|n| n[:nuclide] == nuclide}.first
14
14
  # FIXME: Better conversion from x, x_uncertainty to pm
15
15
  @data[:transitions].collect!{|t| { :energy => t[:energy].to_f.pm(t[:energy_uncertainty].to_f), :intensity => t[:intensity].to_f.pm(t[:intensity_uncertainty].to_f)} }
16
16
  rescue
@@ -19,9 +19,13 @@ module Radiation::Resource
19
19
  self
20
20
  end
21
21
 
22
+ def list
23
+ load_data.collect{|n| n[:nuclide]}
24
+ end
25
+
22
26
  private
23
- def load_data(nuclide)
24
- JSON.parse( IO.read("#{PATH}/#{FILENAME}"), {:symbolize_names => true} ).select{|n| n[:nuclide] == nuclide}.first
27
+ def load_data
28
+ JSON.parse( IO.read("#{PATH}/#{FILENAME}"), {:symbolize_names => true} )
25
29
  end
26
30
 
27
31
  end
@@ -7,7 +7,8 @@ require 'tmpdir'
7
7
 
8
8
  module Radiation::Resource
9
9
  class Nucleideorg < Base
10
-
10
+ OpenURI::Cache.cache_path = "#{Dir.tmpdir}/radiation/"
11
+
11
12
  def fetch(nuclide)
12
13
  @nuclide = nuclide
13
14
  @nuclide = "Ra-226D" if @nuclide == "Ra-226" #Ra-226 in equilibrium with daughters
@@ -16,7 +17,6 @@ module Radiation::Resource
16
17
 
17
18
  @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"
18
19
 
19
- OpenURI::Cache.cache_path = "#{Dir.tmpdir}/radiation/"
20
20
  uri = open("http://www.nucleide.org/DDEP_WG/Nuclides/#{@nuclide}.lara.txt").readlines
21
21
  start = 0
22
22
  uri.each_with_index do |line, lineno|
@@ -40,5 +40,9 @@ module Radiation::Resource
40
40
  self
41
41
  end
42
42
 
43
+ def list
44
+ open("http://www.nucleide.org/DDEP_WG/DDEPdata.htm").read.scan(/Nuclides\/(.*).lara.txt/).flatten
45
+ end
46
+
43
47
  end
44
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module Radiation
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/radiation.gemspec CHANGED
@@ -1,32 +1,32 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'radiation/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "radiation"
8
- spec.version = Radiation::VERSION
9
- spec.authors = ["Jan Mayer"]
10
- spec.email = ["jan.mayer@ikp.uni-koeln.de"]
11
- spec.description = %q{Decay Radiation}
12
- spec.summary = %q{This gem provides easy access to energies and intensities from the decay of radioactive nuclei}
13
- spec.homepage = "https://github.com/janmayer/radiation"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency "plusminus"
22
- spec.add_dependency "open-uri-cached"
23
- spec.add_dependency "combinatorics"
24
- spec.add_dependency "linefit"
25
- spec.add_dependency "xml-simple"
26
- spec.add_dependency "thor"
27
-
28
-
29
- spec.add_development_dependency "bundler", "~> 1.3"
30
- spec.add_development_dependency "rake"
31
- spec.add_development_dependency "rspec"
32
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'radiation/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "radiation"
8
+ spec.version = Radiation::VERSION
9
+ spec.authors = ["Jan Mayer"]
10
+ spec.email = ["jan.mayer@ikp.uni-koeln.de"]
11
+ spec.description = %q{Decay Radiation}
12
+ spec.summary = %q{This gem provides easy access to energies and intensities from the decay of radioactive nuclei}
13
+ spec.homepage = "https://github.com/janmayer/radiation"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "plusminus"
22
+ spec.add_dependency "open-uri-cached"
23
+ spec.add_dependency "combinatorics"
24
+ spec.add_dependency "linefit"
25
+ spec.add_dependency "xml-simple"
26
+ spec.add_dependency "thor"
27
+
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.3"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "rspec"
32
+ end