Skip to content

Commit

Permalink
small fixes and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew McCluskey committed Nov 18, 2020
1 parent 8cb3bc6 commit 3124cc5
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 23 deletions.
66 changes: 66 additions & 0 deletions docs/source/i07yaml.rst
@@ -0,0 +1,66 @@
I07 YAML
========

A custom YAML input has been designed to enable the automated use of islatu at the I07 beamline.
Here we document all of the options that are available in this interface.

.. code-block:: yaml
# This is the beamline being used (optional, default 'i07')
instrument: 'i07'
visit:
# The instrument scientist name (optional, default 'My Local Contact')
local contact: 'A Local Contact'
# The name or names of the users (optional, default 'Unknown')
user: 'A User & Their Friend)'
# Where the user has come from (optional, default 'Unknown')
user affiliation: 'Some University'
# The visit id
visit id: 'siXXXXX-1'
# The current date (or starting date of the beamtime) (optional, default today)
date: 2020-XX-XX
crop:
# The cropping method to be used (either 'crop_peak' or 'crop')
# (optional, default 'crop_peak')
method: crop
# Kwargs as a dict (optional, default 'None')
# An example if 'crop' is used the pixel numbers are given
kwargs: {'x_start': 200, 'x_end':220, 'y_start': 70, 'y_end': 105}
background:
# How the background subtraction should be performed
# (either gaussian_1d or gaussian_2d)
# (optional, default gaussian_1d)
method: gaussian_1d
# The qxy axis of the detector image (optional, defaults 0)
axis: 0
setup:
# Full path to dcd normalisation file (required for dcd normalisation)
dcd normalisation: /dls/i07/data/2020/si24357-1/380396.dat
# Size of the sample if a tuple is passed these are taken as the value and uncertainty
sample size: (9e-3, 1e-3)
# Beam width at half maximum
beam width: 180e-6
# Name of the theta axis (optional, defaults 'dcdtheta')
theta axis: 'dcdtheta'
# Name of the q axis (optional, defaults 'qdcd')
q axis: qdcd
# If data should be transposes (rotated 90 degrees)
# (optional, defaults False)
transpose: False
# The maximum single pixel intensity (optional, defaults 1e6)
pixel max: 1e6
# The threshold for something to be investigated as a hot pixel
# (optional, 1e5)
hot pixel max: 1e5
# If rebin is not present the data will not be rebinned at all
rebin:
# Number of q vectors to be used (optional, default 50)
n qvectors: 50
# Alternatively a step size can be given (only used if n qvectors
# not given)
step: None
# A shape of binning can be set (either 'linear' or 'log')
# (optional, default 'log')
shape: log
# The number of columns to be output (optional, default 4)
output columns: 4
7 changes: 4 additions & 3 deletions docs/source/index.rst
Expand Up @@ -6,10 +6,10 @@
X-ray reflectometry reduction in Python
=======================================

:py:mod:`islatu` is an open-source pacakge for the reduction of x-ray reflectometry datasets.
Currently, :py:mod:`islatu` is developed at and supports data from `Diamond Light Source`_, however we are happy to work with others to enable data from other sources (including neutron sources).
:py:mod:`islatu` is an open-source pacakge for the reduction of x-ray reflectometry datasets.
Currently, :py:mod:`islatu` is developed at and supports data from `Diamond Light Source`_, however we are happy to work with others to enable data from other sources (including neutron sources).

These webpages include `API-level documentation`_ and information about some `workflows`_ that can be used for data reduction.
These webpages include `API-level documentation`_ and information about some `workflows`_ that can be used for data reduction.

Contributors
------------
Expand All @@ -32,6 +32,7 @@ We acknowledge the support of the Ada Lovelace Centre – a joint initiative bet

installation
workflows
i07yaml
modules

Searching
Expand Down
2 changes: 1 addition & 1 deletion islatu/__init__.py
@@ -1,4 +1,4 @@
MAJOR = 0
MINOR = 0
MICRO = 59
MICRO = 60
__version__ = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
35 changes: 16 additions & 19 deletions islatu/runner.py
Expand Up @@ -32,12 +32,12 @@ def __init__(self, name='Unknown', affiliation='Unknown'):


class Origin:
def __init__(self, contact=None, facility='Diamond Light Source', id=None,
def __init__(self, contact='My Local Contact', facility='Diamond Light Source', id=None,
title=None, directory_path=None):
self.contact = contact
self.facility = facility
self.id = id
self.time = None
self.date = str(datetime.datetime.now())
self.year = None
self.title = title
self.directory_path = directory_path
Expand Down Expand Up @@ -121,16 +121,14 @@ def __init__(self,
columns=['Qz / Aa^-1', 'RQz', 'sigma RQz, standard deviation',
'sigma Qz / Aa^-1, standard deviation'],
n_qvectors=50, q_min=None, q_max=None, q_step=None,
q_shape='linear'):
q_shape='log'):
self.column_1 = columns[0]
self.column_2 = columns[1]
self.column_3 = columns[2]
if len(columns) == 4:
self.column_4 = columns[3]
self.rebin = True
self.n_qvectors = n_qvectors
self.q_min = q_min
self.q_max = q_max
self.q_step = q_step
self.q_shape = 'linear'

Expand Down Expand Up @@ -230,9 +228,9 @@ def setup(self, recipe):
else:
raise ValueError("No beam width given in setup of {}.".format(
yaml_file))
if 'theta_axis' in recipe['setup'].keys():
if 'theta axis' in recipe['setup'].keys():
self.data_source.experiment.measurement.theta_axis_name = (
recipe['setup']['theta_axis'])
recipe['setup']['theta axis'])
if 'q axis' in recipe['setup'].keys():
self.data_source.experiment.measurement.q_axis_name = (
recipe['setup']['q axis'])
Expand All @@ -242,12 +240,12 @@ def setup(self, recipe):
if self.data_source.experiment.measurement.transpose:
self.data_source.experiment.measurement.qz_dimension = 0
self.data_source.experiment.measurement.qxy_dimension = 1
if 'pixel_max' in recipe['setup'].keys():
if 'pixel max' in recipe['setup'].keys():
self.data_source.experiment.measurement.pixel_max = recipe[
'setup']['pixel_max']
if 'hot_pixel_max' in recipe['setup'].keys():
'setup']['pixel max']
if 'hot pixel max' in recipe['setup'].keys():
self.data_source.experiment.measurement.hot_pixel_max = recipe[
'setup']['hot_pixel_max']
'setup']['hot pixel max']
else:
raise ValueError("No setup given in {}.".format(yaml_file))
if 'output_columns' in keys:
Expand All @@ -260,8 +258,6 @@ def setup(self, recipe):
self.data.n_qvectors = recipe['rebin']['n qvectors']
elif 'min' in recipe['rebin'].keys() and 'max' in recipe[
'rebin'].keys() and 'step' in recipe['rebin'].keys():
self.data.q_min = recipe['rebin']['min']
self.data.q_max = recipe['rebin']['max']
self.data.q_step = recipe['rebin']['step']
if 'shape' in recipe['rebin'].keys():
self.data.q_shape = recipe['rebin']['shape']
Expand All @@ -272,7 +268,7 @@ def setup(self, recipe):
self.data.rebin=False


def reduce(run_numbers, yaml_file, directory='/dls/{}/data/{}/{}/',
def i07reduce(run_numbers, yaml_file, directory='/dls/{}/data/{}/{}/',
title='Unknown'):
"""
The runner that parses the yaml file and performs the data reduction.
Expand Down Expand Up @@ -344,24 +340,25 @@ def reduce(run_numbers, yaml_file, directory='/dls/{}/data/{}/{}/',
spacing = np.linspace
elif the_boss.data.q_space == 'log':
spacing = np.logspace
refl.rebin(new_q=spacing(the_boss.data.q_min, the_boss.data.q_max,
refl.rebin(new_q=spacing(refl.q.min(), refl.q.max(),
the_boss.data.q_step))
the_boss.reduction.data_state.rebinned = the_boss.data.q_shape

the_boss.data_source.experiment.measurement.q_range = [
str(refl.q.min()), str(refl.q.max())]
the_boss.data.n_qvectors = str(len(refl.R))
try:
_ = the_boss.data.column_4
data = np.array([refl.q, refl.R, refl.dR, refl.dq]).T
np.savetxt(
(the_boss.directory_path + '/processing/XRR_' +
run_numbers[0] + '.dat'), data,
(the_boss.directory_path + '/processing/XRR_{}.dat'.format(
run_numbers[0])), data,
header='{}\n 1 2 3 4'.format(dump(vars(the_boss))))
except:
data = np.array([refl.q, refl.R, refl.dR]).T
np.savetxt(
(the_boss.directory_path + '/processing/XRR_' +
run_numbers[0] + '.dat'), data,
(the_boss.directory_path + '/processing/XRR_{}.dat'.format(
run_numbers[0])), data,
header='{}\n 1 2 3'.format(dump(vars(the_boss))))

print("-" * 10)
Expand Down

0 comments on commit 3124cc5

Please sign in to comment.