Stoner.Data

class Stoner.Data(*args)[source]

The principal class for representing a data file.

This merges:

Also has the Stoner.formats loaded redy for use.

Methods

SG_Filter([col, xcol, points, poly, order, ...])

Implement a Savitsky-Golay filtering of data for smoothing and differentiating data.

__init__(*args, **kargs)

Import plt and then calls the parent constructor.

add(col_a, col_b[, replace, header, index])

Add one column, number or array (col_b) to another column (col_a).

add_column(column_data[, header, index])

Append a column of data or inserts a column to a datafile instance.

annotate_fit(model[, x, y, z, text_only])

Annotate a plot with some information about a fit.

append(value)

S.append(value) -- append value to the end of the sequence

apply(func[, col, replace, header])

Apply the given function to each row in the data set and adds to the data set.

asarray()

Provide a consistent way to get at the underlying array data.

bin([xcol, ycol, bins, mode, clone])

Bin x-y data into new values of x with an error bar.

clear()

clip(clipper[, column])

Clips the data based on the column and the clipper value.

closest(value[, xcol])

Return the row in a data file which has an x-column value closest to the given value.

colormap_xyz([xcol, ycol, zcol])

Make a xyz plot that forces the use of plt.colormap.

column(col)

Extract one or more columns of data from the datafile.

columns([not_masked, reset])

Iterate over the columns of data int he datafile.

contour_xyz([xcol, ycol, zcol, shape, xlim, ...])

Make a xyz plot that forces the use of plt.contour.

count([value, axis, col])

Count the number of un-masked elements in the DataFile.

curve_fit(func[, xcol, ycol, sigma])

General curve fitting function passed through from scipy.

decompose([xcol, ycol, sym, asym, replace])

Given (x,y) data, decomposes the y part into symmetric and antisymmetric contributions in x.

del_column([col, duplicates])

Delete a column from the current DataFile object.

del_nan([col, clone])

Remove rows that have nan in them.

del_rows([col, val, invert])

Search in the numerica data for the lines that match and deletes the corresponding rows.

differential_evolution(model[, xcol, ycol, ...])

Fit model to the data using a differential evolution algorithm.

diffsum(col_a, col_b[, replace, header, index])

Calculate \(\frac{a-b}{a+b}\) for the two columns a and b.

dir([pattern])

Return a list of keys in the metadata, filtering with a regular expression if necessary.

divide(col_a, col_b[, replace, header, index])

Divide one column (col_a) by another column, number or array (col_b).

extend(values)

S.extend(iterable) -- extend sequence by appending elements from the iterable

extrapolate(new_x[, xcol, ycol, yerr, ...])

Extrapolate data based on local fit to x,y data.

figure([figure, projection])

Set the figure used by Stoner.plot.PlotMixin.

filter([func, cols, reset])

Set the mask on rows of data by evaluating a function for each row.

find_col(col[, force_list])

Indexes the column headers in order to locate a column of data.shape.

find_duplicates([xcol, delta])

Find rows with duplicated values of the search column(s).

find_peaks(**kargs)

Interface to scipy.signal.find_peaks() for locating peaks in data.

format(key, **kargs)

Return the contents of key pretty formatted using format_error().

get(k[,d])

get_filename(mode)

Force the user to choose a new filename using a system dialog box.

griddata([xcol, ycol, zcol, ucol, shape, ...])

Convert xyz data onto a regular grid.

image_plot([xcol, ycol, zcol, shape, xlim, ylim])

Grid up the three columns of data and plot.

index(value, [start, [stop]])

Raises ValueError if the value is not present.

insert(index, obj)

Implement the insert method.

insert_rows(row, new_data)

Insert new_data into the data array at position row.

inset([parent, loc, width, height])

Add a new set of axes as an inset to the current plot.

integrate([xcol, ycol, result, header, ...])

Integrate a column of data, optionally returning the cumulative integral.

interpolate(newX[, kind, xcol, replace])

Interpolate a dataset to get a new set of values for a given set of x data.

items()

Make sure we implement an items that doesn't just iterate over self.

keys()

Return the keys of the metadata dictionary.

legend(*args, **kargs)

Pass Through to stop attribute access over-riding a handy method.

lmfit(model[, xcol, ycol, p0, sigma])

Wrap the lmfit module fitting.

load(*args, **kargs)

Create a new DataFile from a file on disc guessing a better subclass if necessary.

make_bins(xcol, bins[, mode])

Generate bin boundaries and centres along an axis.

max([column, bounds])

Find maximum value and index in col_a column of data.

mean([column, sigma, bounds])

Find mean value of col_a data column.

min([column, bounds])

Find minimum value and index in col_a column of data.

multiply(col_a, col_b[, replace, header, index])

Multiply one column (col_a) by another column, number or array (col_b).

normalise([target, base, replace, header, ...])

Normalise data columns by dividing through by a base column value.

odr(model[, xcol, ycol])

Wrap the scipy.odr orthogonal distance regression fitting.

outlier_detection([column, window, shape, ...])

Detect outliers in a column of data.

peaks(**kargs)

Locates peaks and/or troughs in a column of data by using SG-differentiation.

plot(*args, **kargs)

Try to make an appropriate plot based on the defined column assignments.

plot_matrix([xvals, yvals, rectang, cmap, ...])

Plot a surface plot by assuming that the current dataset represents a regular matrix of points.

plot_voxels([xcol, ycol, zcol, ucol, cmap])

Make a volumetric plot of data arranged as x,y,z,u.

plot_xy([xcol, ycol, fmt, xerr, yerr])

Makesa simple X-Y plot of the specified data.

plot_xyuv([xcol, ycol, ucol, vcol, wcol])

Make an overlaid image and quiver plot.

plot_xyuvw([xcol, ycol, ucol, vcol, wcol])

Make an overlaid image and quiver plot.

plot_xyz([xcol, ycol, zcol, shape, xlim, ...])

Plot a surface plot based on rows of X,Y,Z data using matplotlib.pcolor().

plot_xyzuvw([xcol, ycol, zcol, ucol, vcol, wcol])

Plot a vector field plot based on rows of X,Y,Z (U,V,W) data using ,ayavi.

polyfit([xcol, ycol, polynomial_order, ...])

Pass through to numpy.polyfit.

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

quiver_plot([xcol, ycol, ucol, vcol])

Make a 2D Quiver plot from the data.

remove(value)

S.remove(value) -- remove first occurrence of value.

remove_duplicates([xcol, delta, strategy, ...])

Find and remove rows with duplicated values of the search column(s).

rename(old_col, new_col)

Rename columns without changing the underlying data.

reorder_columns(cols[, headers_too, setas_too])

Construct a new data array from the original data by assembling the columns in the order given.

reverse()

S.reverse() -- reverse IN PLACE

rolling_window([window, wrap, exclude_centre])

Iterate with a rolling window section of the data.

rows([not_masked, reset])

Iterate over rows of data.

save([filename])

Save a string representation of the current DataFile object into the file 'filename'.

scale(other[, xcol, ycol])

Scale the x and y data in this DataFile to match the x and y data in another DataFile.

search([xcol, value, columns, accuracy])

Search the numerica data part of the file for lines that match and returns the corresponding rows.

section(**kargs)

Assuming data has x,y or x,y,z coordinates, return data from a section of the parameter space.

select(*args, **kargs)

Produce a copy of the DataFile with only data rows that match a criteria.

setdefault(k[,d])

smooth([window, xcol, ycol, size])

Smooth data by convoluting with a window.

sort(*order, **kargs)

Sort the data by column name.

span([column, bounds])

Return a tuple of the maximum and minimum values within the given column and bounds.

spline([xcol, ycol, sigma])

Construct a spline through x and y data and replace, add new data or return spline function.

split(*args[, final])

Recursively splits the current DataFile into a Stoner.Folders.DataFolder.

std([column, sigma, bounds])

Find standard deviation value of col_a data column.

stitch(other[, xcol, ycol, overlap, ...])

Apply a scaling to this data set to make it stich to another dataset.

subplot(*args, **kargs)

Pass throuygh for matplotlib.pyplot.subplot().

subplot2grid(*args, **kargs)

Provide a pass through to matplotlib.pyplot.subplot2grid().

subtract(col_a, col_b[, replace, header, index])

Subtract one column, number or array (col_b) from another column (col_a).

swap_column(*swp, **kargs)

Swap pairs of columns in the data.

threshold(threshold, **kargs)

Find partial indices where the data in column passes the threshold, rising or falling.

to_pandas()

Create a pandas DataFrame from a Stoner.Data object.

unique(col[, return_index, return_inverse])

Return the unique values from the specified column - pass through for numpy.unique.

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values()

Return the values of the metadata dictionary.

x2()

Generate a new set of axes with a second x-scale.

y2()

Generate a new set of axes with a second y-scale.

Attributes

T

Get the current data transposed.

ax

Return the current axis number.

axes

Return the current axes object.

basename

Return the basename of the current filename.

clone

Get a deep copy of the current DataFile.

cmap

Get the current cmap.

column_headers

Pass through to the setas attribute.

data

Property Accessors for the main numerical data.

dict_records

Return the data as a dictionary of single columns with column headers for the keys.

dims

Alias for self.data.axes.

dtype

Return the np dtype attribute of the data.

fig

Get the current figure.

fignum

Return the current figure number.

filename

Return DataFile filename, or make one up.

filepath

Return DataFile filename, or make one up, returning as a pathlib.Path.

header

Make a pretty header string that looks like the tabular representation.

labels

Return the labels for the plot columns.

mask

Return the mask of the data array.

metadata

Read the metadata dictionary.

mime_type

multiple

no_fmt

patterns

positional_fmt

priority

records

Return the data as a np structured data array.

setas

Get the list of column assignments.

shape

Pass through the numpy shape attribute of the data.

showfig

Return either the current figure or self or None.

subplots

Return the subplot instances.

template

Return the current plot template.