Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SasView/sasview.git
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerpd committed Oct 2, 2016
2 parents d186319 + e74274a commit ed0b796
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 84 deletions.
3 changes: 1 addition & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Vagrant.configure(2) do |config|

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu1404"
config.vm.box_url = "https://github.com/hnakamur/packer-templates/releases/download/v1.0.2/ubuntu-14-04-x64-virtualbox.box"
config.vm.box = "ubuntu/trusty64"
#config.vm.box = "fedora19"
#config.vm.box_url = "https://dl.dropboxusercontent.com/u/86066173/fedora-19.box"
#config.vm.box = "fedora20"
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx-docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# The short X.Y version.
version = '4.0'
# The full version, including alpha/beta/rc tags.
release = '4.0b1'
release = '4.0.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
1 change: 0 additions & 1 deletion sasview.latestversion

This file was deleted.

128 changes: 69 additions & 59 deletions sasview/README.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sasview/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "4.0b1"
__version__ = "4.0"
__build__ = "GIT_COMMIT"
try:
import logging
Expand Down
11 changes: 8 additions & 3 deletions sasview/local_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@
_acknowledgement_preamble_bullet1 =\
'''Acknowledge its use in your publications as suggested below'''
_acknowledgement_preamble_bullet2 =\
'''Reference the following website: http://www.sasview.org'''
'''Reference SasView as : Doucet M, et. al. SasView version 4.0, Zenodo''' +\
''', http://doi.org/10.5281/zenodo.159083'''
_acknowledgement_preamble_bullet3 =\
'''Reference the model you used if appropriate (see documentation for refs)'''
_acknowledgement_preamble_bullet4 =\
'''Send us your reference for our records: [email protected]'''
_acknowledgement_publications = \
'''This work benefited from the use of the SasView application, originally
developed under NSF award DMR-0520547.
developed under NSF award DMR-0520547. SasView contains code developed with
funding from the European Union's Horizon 2020 research and innovation programme
under the SINE2020 project, grant agreement No 654000.
'''
_acknowledgement = \
'''This work originally developed as part of the DANSE project funded by the NSF
under grant DMR-0520547, and currently maintained by NIST, UMD, ORNL, ISIS, ESS
and ILL.
and ILL. SasView contains code developed with funding from the European Union's
Horizon 2020 research and innovation programme under the SINE2020 project, grant
agreement No 654000.
'''
_homepage = "http://www.sasview.org"
Expand Down
94 changes: 77 additions & 17 deletions src/sas/sascalc/dataloader/readers/anton_paar_saxs_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Reader(XMLreader):
## List of files to return
output = None

def __init__(self):
def reset_state(self):
self.current_dataset = Data1D(np.empty(0), np.empty(0),
np.empty(0), np.empty(0))
self.datasets = []
Expand All @@ -71,7 +71,7 @@ def read(self, filename):
"""

## Reinitialize the class when loading a new data file to reset all class variables
self.__init__()
self.reset_state()
## Check that the file exists
if os.path.isfile(filename):
basename = os.path.basename(filename)
Expand All @@ -83,9 +83,6 @@ def read(self, filename):
buff = input_f.read()
self.raw_data = buff.splitlines()
self.read_data()
xml_intermediate = self.raw_data[self.upper:]
xml = ''.join(xml_intermediate)
self.set_xml_file(xml)
return self.output

def read_data(self):
Expand All @@ -99,20 +96,83 @@ def read_data(self):
self.data_points = int(line3[0])
self.lower = 5
self.upper = self.lower + self.data_points
self.detector.distance = float(line4[1])
self.source.radiation = 'x-ray'
normal = float(line4[3])
self.current_dataset.source.radiation = "x-ray"
self.current_dataset.source.name = "Anton Paar SAXSess Instrument"
self.current_dataset.source.wavelength = float(line4[4])
normal = line4[3]
xvals = []
yvals = []
dyvals = []
for i in range(self.lower, self.upper):
index = i - self.lower
data = self.raw_data[i].split()
x_val = [float(data[0])]
y_val = [float(data[1])]
dy_val = [float(data[2])]
self.current_dataset.x = np.append(self.current_dataset.x, x_val)
self.current_dataset.y = np.append(self.current_dataset.y, y_val)
self.current_dataset.dy = np.append(self.current_dataset.dy, dy_val)
self.current_dataset.xaxis("Q (%s)" % (q_unit), q_unit)
self.current_dataset.yaxis("Intensity (%s)" % (i_unit), i_unit)
self.current_dataset.detector.append(self.detector)
self.output.append(self.current_dataset)
xvals.insert(index, normal * float(data[0]))
yvals.insert(index, normal * float(data[1]))
dyvals.insert(index, normal * float(data[2]))
self.current_dataset.x = np.append(self.current_dataset.x, xvals)
self.current_dataset.y = np.append(self.current_dataset.y, yvals)
self.current_dataset.dy = np.append(self.current_dataset.dy, dyvals)
if self.data_points != self.current_dataset.x.size:
self.errors.add("Not all data was loaded properly.")
if self.current_dataset.dx.size != self.current_dataset.x.size:
dxvals = np.zeros(self.current_dataset.x.size)
self.current_dataset.dx = dxvals
if self.current_dataset.x.size != self.current_dataset.y.size:
self.errors.add("The x and y data sets are not the same size.")
if self.current_dataset.y.size != self.current_dataset.dy.size:
self.errors.add("The y and dy datasets are not the same size.")
self.current_dataset.errors = self.errors
self.current_dataset.xaxis("Q", q_unit)
self.current_dataset.yaxis("Intensity", i_unit)
xml_intermediate = self.raw_data[self.upper:]
xml = ''.join(xml_intermediate)
self.set_xml_string(xml)
dom = self.xmlroot.xpath('/fileinfo')
self._parse_child(dom)
self.output.append(self.current_dataset)

def _parse_child(self, dom, parent=''):
"""
Recursive method for stepping through the embedded XML
:param dom: XML node with or without children
"""
for node in dom:
tagname = node.tag
value = node.text
attr = node.attrib
key = attr.get("key", '')
if len(node.getchildren()) > 1:
self._parse_child(node, key)
if key == "SampleDetector":
self.current_dataset.detector.append(self.detector)
self.detector = Detector()
else:
if key == "value":
if parent == "Wavelength":
self.current_dataset.source.wavelength = value
elif parent == "SampleDetector":
self.detector.distance = value
elif parent == "Temperature":
self.current_dataset.sample.temperature = value
elif parent == "CounterSlitLength":
self.detector.slit_length = value
elif key == "unit":
value = value.replace("_", "")
if parent == "Wavelength":
self.current_dataset.source.wavelength_unit = value
elif parent == "SampleDetector":
self.detector.distance_unit = value
elif parent == "X":
self.current_dataset.xaxis(self.current_dataset._xaxis, value)
elif parent == "Y":
self.current_dataset.yaxis(self.current_dataset._yaxis, value)
elif parent == "Temperature":
self.current_dataset.sample.temperature_unit = value
elif parent == "CounterSlitLength":
self.detector.slit_length_unit = value
elif key == "quantity":
if parent == "X":
self.current_dataset.xaxis(value, self.current_dataset._xunit)
elif parent == "Y":
self.current_dataset.yaxis(value, self.current_dataset._yunit)
17 changes: 17 additions & 0 deletions src/sas/sascalc/dataloader/readers/xml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ def set_xml_file(self, xml):
self.xmldoc = None
self.xmlroot = None

def set_xml_string(self, tag_soup):
"""
Set an XML string as the working XML.
:param tag_soup: XML formatted string
"""
try:
self.xml = tag_soup
self.xmldoc = tag_soup
self.xmlroot = etree.fromstring(tag_soup)
except etree.XMLSyntaxError as xml_error:
logging.info(xml_error)
except Exception:
self.xml = None
self.xmldoc = None
self.xmlroot = None

def set_schema(self, schema):
"""
Set the schema file and parse
Expand Down

0 comments on commit ed0b796

Please sign in to comment.