refnx.dataset¶

class
refnx.dataset.
Data1D
(data=None, mask=None, **kwds)[source]¶ Bases:
object
A basic representation of a 1D dataset.
 Parameters
data (str, filelike or tuple of np.ndarray, optional) –
data can be a string or filelike object referring to a File to load the dataset from. The file should be plain text and have 2 to 4 columns separated by space, comma or tab. The columns represent x, y [y_err [, x_err]].
Alternatively it is a tuple containing the data from which the dataset will be constructed. The tuple should have between 2 and 4 members.
data[0]  x
data[1]  y
data[2]  uncertainties on y, y_err
data[3]  uncertainties on x, x_err
data must be at least two long, x and y. If the tuple is at least 3 long then the third member is y_err. If the tuple is 4 long then the fourth member is x_err. All arrays must have the same shape.
mask (arraylike) – Specifies which data points are (un)masked. Must be broadcastable to the ydata. Data1D.mask = None clears the mask. If a mask value equates to True, then the point is included, if a mask value equates to False it is excluded.

data
¶ The data, (x, y, y_err, x_err)
 Type
tuple of np.ndarray

finite_data
¶ Data points that are finite
 Type
tuple of np.ndarray

x
¶ x data (possibly masked)
 Type
np.ndarray

y
¶ y data (possibly masked)
 Type
np.ndarray

y_err
¶ uncertainties on the y data (possibly masked)
 Type
np.ndarray

x_err
¶ uncertainties on the x data (possibly masked)
 Type
np.ndarray

mask
¶ mask
 Type
np.ndarray

add_data
(data_tuple, requires_splice=False, trim_trailing=True)[source]¶ Adds more data to the dataset.
 Parameters
data_tuple (tuple) – 2 to 4 member tuple containing the (x, y, y_err, x_err) data to add to the dataset. y_err and x_err are optional.
requires_splice (bool, optional) – When the new data is added to the dataset do you want to scale it vertically so that it overlaps with the existing data? y and y_err in data_tuple are both multiplied by the scaling factor.
trim_trailing (bool, optional) – When the new data is concatenated do you want to remove points from the existing data that are in the overlap region? This might be done because the datapoints in the data_tuple you are adding have have lower y_err than the preceding data.
Notes
Raises ValueError if there are no points in the overlap region and requires_splice was True. The added data is not masked.

property
data
4tuple containing the (x, y, y_err, x_err) data

property
finite_data
4tuple containing the (x, y, y_err, x_err) datapoints that are finite.

load
(f)[source]¶ Loads a dataset from file. Must be 2 to 4 column ASCII.
 Parameters
f (filehandle or string) – File to load the dataset from.

property
mask

plot
(fig=None)[source]¶ Plot the dataset.
Requires matplotlib be installed.
 Parameters
fig (Figure instance, optional) – If fig is not supplied then a new figure is created. Otherwise the graph is created on the current axes on the supplied figure.
 Returns
fig, ax – matplotlib figure and axes objects.
 Return type
matplotlib.Figure
,matplotlib.Axes

save
(f)[source]¶ Saves the data to file. Saves the data as 4 column ASCII.
 Parameters
f (filehandle or string) – File to save the dataset to.

scale
(scalefactor=1.0)[source]¶ Scales the y and y_err data by dividing by scalefactor.
 Parameters
scalefactor (float) – The scalefactor to divide by.

synthesise
()[source]¶ Synthesise a new dataset by adding Gaussian noise onto each of the datapoints of the existing data.
 Returns
dataset – A new synthesised dataset
 Return type

property
unmasked_data
¶ 4tuple containing unmasked (x, y, y_err, x_err) data

property
x

property
x_err

property
y

property
y_err

class
refnx.dataset.
ReflectDataset
(data=None, **kwds)[source]¶ Bases:
refnx.dataset.data1d.Data1D
A 1D Reflectivity dataset.

refnx.dataset.
test
= <refnx._lib._testutils.PytestTester object>¶