Skip to content

Commit

Permalink
Update GenXFile for version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed May 13, 2024
1 parent a149faa commit eec8072
Show file tree
Hide file tree
Showing 126 changed files with 97 additions and 159 deletions.
1 change: 0 additions & 1 deletion Stoner/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class AnalysisMixin:

"""A mixin calss designed to work with :py:class:`Stoner.Core.DataFile` to provide additional analysis methods."""

def __dir__(self):
Expand Down
2 changes: 1 addition & 1 deletion Stoner/Core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Stoner.Core provides the core classes for the Stoner package."""

__all__ = [
"StonerLoadError",
"StonerSetasError",
Expand Down Expand Up @@ -64,7 +65,6 @@ class DataFile(
metadataObject,
MutableSequence,
):

"""Base class object that represents a matrix of data, associated metadata and column headers.
Attributes:
Expand Down
3 changes: 1 addition & 2 deletions Stoner/Folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
The core classes provides a means to access them as an ordered collection or as a mapping.
"""

__all__ = ["DataFolder", "PlotFolder"]

from Stoner.tools import make_Data
Expand All @@ -11,7 +12,6 @@


class DataFolder(DataMethodsMixin, DiskBasedFolderMixin, baseFolder):

"""Provide an interface to manipulating lots of data files stored within a directory structure on disc.
By default, the members of the DataFolder are instances of :class:`Stoner.Data`. The DataFolder emplys a lazy
Expand All @@ -28,5 +28,4 @@ def __init__(self, *args, **kargs):


class PlotFolder(PlotMethodsMixin, DataFolder):

"""A :py:class:`Stoner.folders.baseFolder` that knows how to ploth its underlying data files."""
8 changes: 1 addition & 7 deletions Stoner/HDF5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
to :py:class:`Stoner.Core.Data`.
"""

__all__ = ["HDF5File", "HDF5Folder", "HGXFile", "SLS_STXMFile", "STXMImage", "HDFFileManager"]
import importlib
import os.path as path
Expand Down Expand Up @@ -52,7 +53,6 @@ def get_hdf_loader(f, default_loader=lambda *args, **kargs: None):


class HDFFileManager:

"""Context manager for HDF5 files."""

def __init__(self, filename, mode="r"):
Expand Down Expand Up @@ -115,7 +115,6 @@ def __exit__(self, _type, _value, _traceback):


class HDF5File(DataFile):

"""A sub class of DataFile that sores itself in a HDF5File or group.
Args:
Expand Down Expand Up @@ -287,7 +286,6 @@ def to_hdf(self, filename=None, **kargs): # pylint: disable=unused-argument


class HGXFile(DataFile):

"""A subclass of DataFile for reading GenX HDF Files.
These files typically have an extension .hgx. This class has been based on a limited sample
Expand Down Expand Up @@ -372,7 +370,6 @@ def main_data(self, data_grp):


class HDF5FolderMixin:

"""Provides a method to load and save data from a single HDF5 file with groups.
See :py:class:`Stoner.Folders.DataFolder` for documentation on constructor.
Expand Down Expand Up @@ -568,7 +565,6 @@ def save(self, root=None):


class HDF5Folder(HDF5FolderMixin, DataFolder):

"""Just enforces the loader attriobute to be an HDF5File."""

def __init__(self, *args, **kargs):
Expand All @@ -578,7 +574,6 @@ def __init__(self, *args, **kargs):


class SLS_STXMFile(DataFile):

"""Load images from the Swiss Light Source Pollux beamline."""

priority = 16
Expand Down Expand Up @@ -671,7 +666,6 @@ def scan_meta(self, group):


class STXMImage(ImageFile):

"""An instance of KerrArray that will load itself from a Swiss Light Source STXM image."""

# pylint: disable=no-member
Expand Down
2 changes: 0 additions & 2 deletions Stoner/Image/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def _proxy(self, *args, **kargs):

@class_modifier(draw, adaptor=_draw_apaptor, RTD_restrictions=False, no_long_names=True)
class DrawProxy:

"""Provides a wrapper around :py:mod:`skimage.draw` to allow easy drawing of objects onto images.
This class allows access the user to draw simply shapes on an image (or its mask) by specifying the desired shape
Expand Down Expand Up @@ -205,7 +204,6 @@ def square(self, r, c, w, angle=0.0, shape=None, value=1.0):


class MaskProxy:

"""Provides a wrapper to support manipulating the image mask easily.
The actual mask of a :py:class:`Stonmer.ImageFile` is held by the mask attribute of the underlying
Expand Down
2 changes: 0 additions & 2 deletions Stoner/Image/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def copy_into(source: "ImageFile", dest: "ImageFile") -> "ImageFile":
@class_modifier([ndi], transpose=True)
@class_modifier(imagefuncs, overload=True)
class ImageArray(np.ma.MaskedArray, metadataObject):

"""A numpy array like class with a metadata parameter and pass through to skimage methods.
ImageArray is for manipulating images stored as a 2d numpy array.
Expand Down Expand Up @@ -701,7 +700,6 @@ def save(self, filename=None, **kargs):
@class_modifier(imagefuncs, overload=True, adaptor=image_file_adaptor)
@class_wrapper(target=ImageArray, exclude_below=metadataObject)
class ImageFile(metadataObject):

"""An Image file type that is analogous to :py:class:`Stoner.Data`.
This contains metadata and an image attribute which
Expand Down
2 changes: 0 additions & 2 deletions Stoner/Image/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class ImageFolderMixin:

"""Mixin to provide a folder object for images.
ImageFolderMixin is designed to behave pretty much like DataFolder but with
Expand Down Expand Up @@ -474,7 +473,6 @@ def to_tiff(self, filename):


class ImageFolder(ImageFolderMixin, DiskBasedFolderMixin, baseFolder):

"""Folder object for images.
ImageFolder is designed to behave pretty much like DataFolder but with
Expand Down
6 changes: 0 additions & 6 deletions Stoner/Image/kerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

@class_modifier(kerrfuncs)
class KerrArray(ImageArray):

"""A subclass for Kerr microscopy specific image functions."""

# useful_keys are metadata keys that we'd usually like to keep from a
Expand Down Expand Up @@ -90,7 +89,6 @@ def save(self, filename=None, **kargs):

@class_modifier(kerrfuncs, adaptor=image_file_adaptor)
class KerrImageFile(ImageFile):

"""Subclass of ImageFile that keeps the data as a KerrArray so that extra functions are available."""

priority = 16
Expand Down Expand Up @@ -127,7 +125,6 @@ def image(self, v): # pylint: disable=function-redefined


class KerrStackMixin:

"""A mixin for :py:class:`ImageStack` that adds some functionality particular to Kerr images.
Attributes:
Expand Down Expand Up @@ -331,7 +328,6 @@ def average_Hcmap(self, weights=None, ignore_zeros=False):


class MaskStackMixin:

"""A Mixin for :py:class:`Stoner.Image.ImageStack` but made for stacks of boolean or binary images."""

def __init__(self, *args, **kargs):
Expand Down Expand Up @@ -398,10 +394,8 @@ def switch_index(self, saturation_end=True, saturation_value=True):


class KerrStack(KerrStackMixin, ImageStack):

"""Represent a stack of Kerr images."""


class MaskStack(MaskStackMixin, KerrStackMixin, ImageStack):

"""Represent a set of masks for Kerr images."""
3 changes: 0 additions & 3 deletions Stoner/Image/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def _load_ImageArray(f, **kargs):


class ImageStackMixin:

"""Implement an interface for a baseFolder to store images in a 3D numpy array for faster access."""

_defaults = {"type": ImageFile}
Expand Down Expand Up @@ -481,7 +480,6 @@ def show(self):


class StackAnalysisMixin:

"""Add some analysis capability to ImageStack.
These functions may override :py:class:`Stoner,Image.ImageFile` functions but do them efficiently for a numpy
Expand Down Expand Up @@ -520,5 +518,4 @@ def subtract(self, background):


class ImageStack(StackAnalysisMixin, ImageStackMixin, ImageFolderMixin, DiskBasedFolderMixin, baseFolder):

"""An alternative implementation of an image stack based on baseFolder."""
3 changes: 0 additions & 3 deletions Stoner/Image/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def _rotated_ellipse(p, data):


class LineSelect:

"""Show an Image and slow the user to draw a line on it using cursors."""

def __init__(self):
Expand Down Expand Up @@ -171,7 +170,6 @@ def draw_line(self, event):


class RegionSelect:

"""Show an Image and slow the user to select a rectangular section."""

def __init__(self):
Expand Down Expand Up @@ -257,7 +255,6 @@ def finish(self, key_event):


class ShapeSelect:

"""Show an Image and slow the user to draw a line on it using cursors."""

def __init__(self):
Expand Down
3 changes: 0 additions & 3 deletions Stoner/Zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def test_is_zip(filename, member=""):


class ZippedFile(DataFile):

"""A sub class of DataFile that sores itself in a zip file.
If the first non-keyword argument is not an :py:class:`zipfile:ZipFile` then
Expand Down Expand Up @@ -228,7 +227,6 @@ def save(self, filename=None, **kargs):


class ZipFolderMixin:

"""Provides methods to load and save data from a single Zip file.
See :py:class:`Stoner.Folders.DataFolder` for documentation on constructor.
Expand Down Expand Up @@ -511,7 +509,6 @@ def _save(self, f, trail):


class ZipFolder(ZipFolderMixin, DiskBasedFolderMixin, baseFolder):

"""A sub class of DataFile that sores itself in a zip file.
If the first non-keyword argument is not an :py:class:`zipfile:ZipFile` then
Expand Down
1 change: 1 addition & 0 deletions Stoner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
It has been developed by members of the `Condensed Matter Group<http://www.stoner.leeds.ac.uk/>` at the
`University of Leeds<http://www.leeds.ac.uk>`.
"""

# pylint: disable=import-error
__all__ = [
"core",
Expand Down
1 change: 1 addition & 0 deletions Stoner/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Subpaclage to support the data analysis functions."""

from . import fitting, utils, columns

__all__ = ["fitting", "utils", "columns", "filtering", "features"]
1 change: 0 additions & 1 deletion Stoner/analysis/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class ColumnOpsMixin:

"""A mixin calss designed to work with :py:class:`Stoner.Core.DataFile` to provide additional stats methods."""

def _do_error_calc(self, col_a, col_b, error_type="relative"):
Expand Down
1 change: 0 additions & 1 deletion Stoner/analysis/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class FeatureOpsMixin:

"""Mixin to provide additional functions to support finding features in a dataset."""

def peaks(self, **kargs):
Expand Down
1 change: 0 additions & 1 deletion Stoner/analysis/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class FilteringOpsMixin:

"""Provide additional filtering sndsmoothing methods to :py:class:`Stoner.Data`."""

def SG_Filter(
Expand Down
1 change: 1 addition & 0 deletions Stoner/analysis/fitting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provides additional functionality for doing curve fitting to data."""

__all__ = ["odr_Model", "FittingMixin", "models"]
from .mixins import odr_Model, FittingMixin
from . import models
4 changes: 0 additions & 4 deletions Stoner/analysis/fitting/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class odr_Model(odrModel):

"""A wrapper for converting lmfit models to odr models."""

def __init__(self, *args, **kargs):
Expand Down Expand Up @@ -109,7 +108,6 @@ def param_names(self):


class MimizerAdaptor:

"""Work with an lmfit.Model or generic callable to use with scipy.optimize global minimization functions.
The :pymod:`scipy.optimize` module's minimizers generally expect functions which take an array like parameter
Expand Down Expand Up @@ -171,7 +169,6 @@ def wrapper(beta, x, y, sigma, *args):


class _curve_fit_result:

"""Represent a result from fitting using :py:func:`scipy.optimize.curve_fit`
as a class to make handling easier.
"""
Expand Down Expand Up @@ -471,7 +468,6 @@ def _prep_lmfit_p0(model, ydata, xdata, p0, kargs):


class FittingMixin:

"""A mixin calss for :py:class:`Stoner.Core.DataFile` to provide additional curve_fiotting methods."""

def annotate_fit(self, model, x=None, y=None, z=None, text_only=False, **kargs):
Expand Down
1 change: 1 addition & 0 deletions Stoner/analysis/fitting/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sub package of various built-in models for the Stoner package."""

__all__ = [
"generic",
"thermal",
Expand Down
3 changes: 0 additions & 3 deletions Stoner/analysis/fitting/models/e_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def blochGrueneisen(T, thetaD, rho0, A, n):


class WLfit(Model):

"""Weak localisation model class.
Args:
Expand Down Expand Up @@ -175,7 +174,6 @@ def guess(self, data, x=None, **kwargs):


class FluchsSondheimer(Model):

"""Evaluate a Fluchs-Sondheumer model function for conductivity.
Args:
Expand Down Expand Up @@ -210,7 +208,6 @@ def guess(self, data, t=None, **kwargs): # pylint: disable=unused-argument


class BlochGrueneisen(Model):

"""BlochGrueneiseen Function for fitting R(T).
Args:
Expand Down
1 change: 0 additions & 1 deletion Stoner/analysis/fitting/models/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def lorentzian_diff(x, A, sigma, mu):


class Linear(_Linear):

"""Simple linear fit class."""


Expand Down
6 changes: 1 addition & 5 deletions Stoner/analysis/fitting/models/magnetism.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ def inverse_kittel(f, g, M_s, H_k):
\gamma^{2} \mu_{0}^{2} + 16 \pi^{2} f^{2}}`
"""
gamma = g * cnst.e / (2 * cnst.m_e)
return (
-H_k
- M_s / 2
+ np.sqrt(M_s**2 * gamma**2 * cnst.mu_0**2 + 16 * np.pi**2 * f**2) / (2 * gamma * cnst.mu_0)
)
return -H_k - M_s / 2 + np.sqrt(M_s**2 * gamma**2 * cnst.mu_0**2 + 16 * np.pi**2 * f**2) / (2 * gamma * cnst.mu_0)


def fmr_power(H, H_res, Delta_H, K_1, K_2):
Expand Down
Loading

0 comments on commit eec8072

Please sign in to comment.