radiation 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGQ3OGQyOWMzYWFjMGFjMjMzNTE4OGM0YTMxNmQ1MjdjZGNmOGZmZA==
4
+ NDQxMmMyNzdkMmY0NzUxMTE0NmQ4NzQ2ZTYwMTBiNzhlZWI5ZTViMQ==
5
5
  data.tar.gz: !binary |-
6
- YTliN2YzZGYwNmEzODgwMDdkOTRiOWQ5NTkyNzIxMjYwZjhlMThlNw==
6
+ ZjU3MzFhMTA1YzA2ODgyZTJlYzhhNjRlYjhmMjQ1MjQ4MzRkZTM1OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjI5NmZjMGRkMDMzMjQyMzBkYWRhODU3ZTNjMTYwYzY0YTcwOWM4N2JiMTJi
10
- NWYxMWRjMmViNGJhNTY0MzJiMzMyYTIwODU3ZGM1ZmU3MjFlMTk1OThkMjQ2
11
- MTkwZTg2MWMxMjZmZDBlNjdlNWNiNDEzOWYyYTg5Mzg4MzM1M2U=
9
+ MjJhYzU4ZmZmYjY1NTUyM2I5MzU4ZWRkOWY0ODViZjM4NGVmY2U4MGJlY2Q1
10
+ MTU5ZGNmZTY2ZjQwY2QyZGIyYjcxNWRhYWExMjdmZTgyOWUzODBiZTBlMjQy
11
+ OGY0MmIxZjBkMzM5NzhjMzcyZGMzOGIyZGYzZWUzYjI2ZTdkYjU=
12
12
  data.tar.gz: !binary |-
13
- NDMwNjczZWQyMjM2YmIyYjFhODRlY2FmMDUzNDE3ZGZjNzI1ZDQwNWU2NTVk
14
- ODM5MTI2ODUyOWIzOTlkNWExZTA5OWZlOGM2NDdlYzE3NDEyNDhhMTMyMjkz
15
- YWM2ZjU4Nzg2MTAwM2U2ODEwOTI0ZGJjZWU5NWQwZmEzN2NjMmQ=
13
+ ZDBkZTg1OWY1Y2IxYzQzMWEzMjJhODU0YmExNWJkNTczOWMwMGZiY2FjMjI4
14
+ MTYwN2M5MTczNzc5NGRiMmZmMzM2NTJmMTFkNDkxNzQ2YWY0MDBkNzQwZGQx
15
+ ZmZlODEwYzlmM2JiYjAyY2MzNjlmMjljOTVlNTljMzYwYzIwMmM=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.0.3
2
+
3
+ * Added basic parsing for hdtv xml files
4
+ * Changed dependency for linefit
5
+
1
6
  ## v0.0.2
2
7
 
3
8
  * Added spectrum class with energy calibration options
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "linefit", git: "https://github.com/janmayer/linefit.git"
3
+ #gem "linefit", git: "https://github.com/janmayer/linefit.git"
4
4
  # Specify your gem's dependencies in radiation.gemspec
5
5
  gemspec
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Radiation [![Build Status](https://travis-ci.org/janmayer/radiation.png?branch=master)](https://travis-ci.org/janmayer/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)
2
5
 
3
6
  This gem provides easy access to energies and intensities from the decay of radioactive nuclei.
4
7
  Currently two data sources are accessible: Internal (see bib files in `./data/`) and recommended values
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "linefit"
3
3
  require "plusminus"
4
+ require "xmlsimple"
4
5
 
5
6
  class Radiation::Spectrum
6
7
  attr_accessor :peaks, :source, :calibration
@@ -39,7 +40,7 @@ class Radiation::Spectrum
39
40
  def match_channels(energies=@source.energies, rounding=4)
40
41
  @peaks.each do |peak|
41
42
  energies.each do |energy|
42
- peak[:energy] = energy if channel_energy(peak[:channel]).approx_equal?(energy, rounding)
43
+ peak[:energy] = energy if channel_energy(peak[:channel]).to_f.approx_equal?(energy, rounding)
43
44
  end
44
45
  end
45
46
  return self
@@ -58,6 +59,15 @@ class Radiation::Spectrum
58
59
  @calibration[0] + @calibration[1]*chn
59
60
  end
60
61
 
62
+ def parse_hdtv(file)
63
+ xml = XmlSimple.xml_in(file, { 'KeyAttr' => 'name' })
64
+ @peaks = xml["fit"].collect{|p| p["peak"]}.flatten.collect{|p| p["uncal"]}.flatten.collect do |p|
65
+ {:channel => p["pos"].first["value"].first.to_f.pm(p["pos"].first["error"].first.to_f),
66
+ :counts => p["vol"].first["value"].first.to_f.pm(p["vol"].first["error"].first.to_f) }
67
+ end
68
+ return self
69
+ end
70
+
61
71
  end
62
72
 
63
73
 
@@ -1,3 +1,3 @@
1
1
  module Radiation
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/radiation.gemspec CHANGED
@@ -21,7 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "plusminus"
22
22
  spec.add_dependency "open-uri-cached"
23
23
  spec.add_dependency "combinatorics"
24
- spec.add_dependency "linefit", "~> 0.3.1"
24
+ spec.add_dependency "linefit"
25
+ spec.add_dependency "xml-simple"
25
26
 
26
27
 
27
28
  spec.add_development_dependency "bundler", "~> 1.3"
Binary file