Skip to content

Commit ed0b796

Browse files
committed
Merge branch 'master' of https://github.com/SasView/sasview.git
2 parents d186319 + e74274a commit ed0b796

File tree

8 files changed

+174
-84
lines changed

8 files changed

+174
-84
lines changed

Vagrantfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Vagrant.configure(2) do |config|
2020

2121
# Every Vagrant development environment requires a box. You can search for
2222
# boxes at https://atlas.hashicorp.com/search.
23-
config.vm.box = "ubuntu1404"
24-
config.vm.box_url = "https://github.com/hnakamur/packer-templates/releases/download/v1.0.2/ubuntu-14-04-x64-virtualbox.box"
23+
config.vm.box = "ubuntu/trusty64"
2524
#config.vm.box = "fedora19"
2625
#config.vm.box_url = "https://dl.dropboxusercontent.com/u/86066173/fedora-19.box"
2726
#config.vm.box = "fedora20"

docs/sphinx-docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# The short X.Y version.
6262
version = '4.0'
6363
# The full version, including alpha/beta/rc tags.
64-
release = '4.0b1'
64+
release = '4.0.0'
6565

6666
# The language for content autogenerated by Sphinx. Refer to documentation
6767
# for a list of supported languages.

sasview.latestversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

sasview/README.txt

Lines changed: 69 additions & 59 deletions
Large diffs are not rendered by default.

sasview/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.0b1"
1+
__version__ = "4.0"
22
__build__ = "GIT_COMMIT"
33
try:
44
import logging

sasview/local_config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,24 @@
3434
_acknowledgement_preamble_bullet1 =\
3535
'''Acknowledge its use in your publications as suggested below'''
3636
_acknowledgement_preamble_bullet2 =\
37-
'''Reference the following website: http://www.sasview.org'''
37+
'''Reference SasView as : Doucet M, et. al. SasView version 4.0, Zenodo''' +\
38+
''', http://doi.org/10.5281/zenodo.159083'''
3839
_acknowledgement_preamble_bullet3 =\
3940
'''Reference the model you used if appropriate (see documentation for refs)'''
4041
_acknowledgement_preamble_bullet4 =\
4142
'''Send us your reference for our records: developers@sasview.org'''
4243
_acknowledgement_publications = \
4344
'''This work benefited from the use of the SasView application, originally
44-
developed under NSF award DMR-0520547.
45+
developed under NSF award DMR-0520547. SasView contains code developed with
46+
funding from the European Union's Horizon 2020 research and innovation programme
47+
under the SINE2020 project, grant agreement No 654000.
4548
'''
4649
_acknowledgement = \
4750
'''This work originally developed as part of the DANSE project funded by the NSF
4851
under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS
49-
and ILL.
52+
and ILL. SasView contains code developed with funding from the European Union's
53+
Horizon 2020 research and innovation programme under the SINE2020 project, grant
54+
agreement No 654000.
5055
5156
'''
5257
_homepage = "http://www.sasview.org"

src/sas/sascalc/dataloader/readers/anton_paar_saxs_reader.py

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Reader(XMLreader):
4444
## List of files to return
4545
output = None
4646

47-
def __init__(self):
47+
def reset_state(self):
4848
self.current_dataset = Data1D(np.empty(0), np.empty(0),
4949
np.empty(0), np.empty(0))
5050
self.datasets = []
@@ -71,7 +71,7 @@ def read(self, filename):
7171
"""
7272

7373
## Reinitialize the class when loading a new data file to reset all class variables
74-
self.__init__()
74+
self.reset_state()
7575
## Check that the file exists
7676
if os.path.isfile(filename):
7777
basename = os.path.basename(filename)
@@ -83,9 +83,6 @@ def read(self, filename):
8383
buff = input_f.read()
8484
self.raw_data = buff.splitlines()
8585
self.read_data()
86-
xml_intermediate = self.raw_data[self.upper:]
87-
xml = ''.join(xml_intermediate)
88-
self.set_xml_file(xml)
8986
return self.output
9087

9188
def read_data(self):
@@ -99,20 +96,83 @@ def read_data(self):
9996
self.data_points = int(line3[0])
10097
self.lower = 5
10198
self.upper = self.lower + self.data_points
102-
self.detector.distance = float(line4[1])
99+
self.source.radiation = 'x-ray'
100+
normal = float(line4[3])
103101
self.current_dataset.source.radiation = "x-ray"
104102
self.current_dataset.source.name = "Anton Paar SAXSess Instrument"
105103
self.current_dataset.source.wavelength = float(line4[4])
106-
normal = line4[3]
104+
xvals = []
105+
yvals = []
106+
dyvals = []
107107
for i in range(self.lower, self.upper):
108+
index = i - self.lower
108109
data = self.raw_data[i].split()
109-
x_val = [float(data[0])]
110-
y_val = [float(data[1])]
111-
dy_val = [float(data[2])]
112-
self.current_dataset.x = np.append(self.current_dataset.x, x_val)
113-
self.current_dataset.y = np.append(self.current_dataset.y, y_val)
114-
self.current_dataset.dy = np.append(self.current_dataset.dy, dy_val)
115-
self.current_dataset.xaxis("Q (%s)" % (q_unit), q_unit)
116-
self.current_dataset.yaxis("Intensity (%s)" % (i_unit), i_unit)
117-
self.current_dataset.detector.append(self.detector)
118-
self.output.append(self.current_dataset)
110+
xvals.insert(index, normal * float(data[0]))
111+
yvals.insert(index, normal * float(data[1]))
112+
dyvals.insert(index, normal * float(data[2]))
113+
self.current_dataset.x = np.append(self.current_dataset.x, xvals)
114+
self.current_dataset.y = np.append(self.current_dataset.y, yvals)
115+
self.current_dataset.dy = np.append(self.current_dataset.dy, dyvals)
116+
if self.data_points != self.current_dataset.x.size:
117+
self.errors.add("Not all data was loaded properly.")
118+
if self.current_dataset.dx.size != self.current_dataset.x.size:
119+
dxvals = np.zeros(self.current_dataset.x.size)
120+
self.current_dataset.dx = dxvals
121+
if self.current_dataset.x.size != self.current_dataset.y.size:
122+
self.errors.add("The x and y data sets are not the same size.")
123+
if self.current_dataset.y.size != self.current_dataset.dy.size:
124+
self.errors.add("The y and dy datasets are not the same size.")
125+
self.current_dataset.errors = self.errors
126+
self.current_dataset.xaxis("Q", q_unit)
127+
self.current_dataset.yaxis("Intensity", i_unit)
128+
xml_intermediate = self.raw_data[self.upper:]
129+
xml = ''.join(xml_intermediate)
130+
self.set_xml_string(xml)
131+
dom = self.xmlroot.xpath('/fileinfo')
132+
self._parse_child(dom)
133+
self.output.append(self.current_dataset)
134+
135+
def _parse_child(self, dom, parent=''):
136+
"""
137+
Recursive method for stepping through the embedded XML
138+
:param dom: XML node with or without children
139+
"""
140+
for node in dom:
141+
tagname = node.tag
142+
value = node.text
143+
attr = node.attrib
144+
key = attr.get("key", '')
145+
if len(node.getchildren()) > 1:
146+
self._parse_child(node, key)
147+
if key == "SampleDetector":
148+
self.current_dataset.detector.append(self.detector)
149+
self.detector = Detector()
150+
else:
151+
if key == "value":
152+
if parent == "Wavelength":
153+
self.current_dataset.source.wavelength = value
154+
elif parent == "SampleDetector":
155+
self.detector.distance = value
156+
elif parent == "Temperature":
157+
self.current_dataset.sample.temperature = value
158+
elif parent == "CounterSlitLength":
159+
self.detector.slit_length = value
160+
elif key == "unit":
161+
value = value.replace("_", "")
162+
if parent == "Wavelength":
163+
self.current_dataset.source.wavelength_unit = value
164+
elif parent == "SampleDetector":
165+
self.detector.distance_unit = value
166+
elif parent == "X":
167+
self.current_dataset.xaxis(self.current_dataset._xaxis, value)
168+
elif parent == "Y":
169+
self.current_dataset.yaxis(self.current_dataset._yaxis, value)
170+
elif parent == "Temperature":
171+
self.current_dataset.sample.temperature_unit = value
172+
elif parent == "CounterSlitLength":
173+
self.detector.slit_length_unit = value
174+
elif key == "quantity":
175+
if parent == "X":
176+
self.current_dataset.xaxis(value, self.current_dataset._xunit)
177+
elif parent == "Y":
178+
self.current_dataset.yaxis(value, self.current_dataset._yunit)

src/sas/sascalc/dataloader/readers/xml_reader.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ def set_xml_file(self, xml):
7676
self.xmldoc = None
7777
self.xmlroot = None
7878

79+
def set_xml_string(self, tag_soup):
80+
"""
81+
Set an XML string as the working XML.
82+
83+
:param tag_soup: XML formatted string
84+
"""
85+
try:
86+
self.xml = tag_soup
87+
self.xmldoc = tag_soup
88+
self.xmlroot = etree.fromstring(tag_soup)
89+
except etree.XMLSyntaxError as xml_error:
90+
logging.info(xml_error)
91+
except Exception:
92+
self.xml = None
93+
self.xmldoc = None
94+
self.xmlroot = None
95+
7996
def set_schema(self, schema):
8097
"""
8198
Set the schema file and parse

0 commit comments

Comments
 (0)