Skip to content

DcExperiment

Any future classes pertaining to dc magnetometry experiments should follow the interface defined by DcExperiment.

DcExperiment

Bases: Protocol

The protocol for a DC magnetometry experiment, e.g. M vs H, ZFC/FC, etc.

Attributes:

Name Type Description
data pd.DataFrame

The data as read in from the experiment file. It should include the columns "uncorrected_moment" and "uncorrected_moment_err", which are the moment and moment error directly from the experiment file, whether the measurement was DC or VSM. Scaling methods will act on these columns.

scaling list[str]

A list of identifiers used to track what scaling was applied to the data, e.g., "mass", "eicosane_mass", "molecular_weight", "diamagnetic_correction".

Source code in magnetopy\experiments\dc_experiment.py
class DcExperiment(Protocol):
    """The protocol for a DC magnetometry experiment, e.g. M vs H, ZFC/FC, etc.

    Attributes
    ----------
    data : pd.DataFrame
        The data as read in from the experiment file. It should include the columns
        `"uncorrected_moment"` and `"uncorrected_moment_err"`, which are the moment
        and moment error directly from the experiment file, whether the measurement
        was DC or VSM. Scaling methods will act on these columns.
    scaling : list[str]
        A list of identifiers used to track what scaling was applied to the data, e.g.,
        `"mass"`, `"eicosane_mass"`, `"molecular_weight"`, `"diamagnetic_correction"`.
    """

    data: pd.DataFrame
    scaling: list[str]

    def __init__(self, *args, parse_raw: bool = False, **kwargs) -> None:
        """Creates the `DcExperiment` object.

        Parameters
        ----------
        parse_raw : bool, optional
            If True and there is a corresponding .rw.dat file, the raw data will be
            parsed and added to the data attribute in the `"raw_scan"` column when
            creating the underlying `DatFile` object.

        """

    def scale_moment(
        self,
        mass: float = 0,
        eicosane_mass: float = 0,
        molecular_weight: float = 0,
        diamagnetic_correction: float = 0,
    ) -> None:
        """Scale the moment by the given values. Scaled values are added to the `data`
        attribute in the following columns: `"chi"`, `"chi_err"`, `"chi_t"`,
        `"chi_t_err"`, `"moment"`, and `"moment_err"`. The units of these columns will
        be determined by what scaling was applied.

        Parameters
        ----------
        mass : float, optional
            Mass in mg, by default 0
        eicosane_mass : float, optional
            Eicosane mass in mg, by default 0
        molecular_weight : float, optional
            Molecular weight in g/mol, by default 0
        diamagnetic_correction : float, optional
            Diamagnetic Correction in cm^3/mol, by default 0
        """
        ...

    def simplified_data(self, *args, **kwargs) -> pd.DataFrame:
        """Returns a simplified version of the data, with only the columns needed for
        most analyses and plotting. These columns are: `"time"` (in seconds),
        `"temperature"` (in Kelvin), `"field"` (in Oe), `"moment"`, `"moment_err"`,
        `"chi"`, `"chi_err"`, `"chi_t"`, and `"chi_t_err"`. Where units are not
        specified, they are determined by what scaling was applied.

        Returns
        -------
        pd.DataFrame
            A `DataFrame` with the columns: `"time"` (in seconds),
            `"temperature"` (in Kelvin), `"field"` (in Oe), `"moment"`, `"moment_err"`,
            `"chi"`, `"chi_err"`, `"chi_t"`, and `"chi_t_err"`. Where units are not
            specified, they are determined by what scaling was applied.
        """
        ...

__init__(*args, parse_raw=False, **kwargs)

Creates the DcExperiment object.

Parameters:

Name Type Description Default
parse_raw bool

If True and there is a corresponding .rw.dat file, the raw data will be parsed and added to the data attribute in the "raw_scan" column when creating the underlying DatFile object.

False
Source code in magnetopy\experiments\dc_experiment.py
def __init__(self, *args, parse_raw: bool = False, **kwargs) -> None:
    """Creates the `DcExperiment` object.

    Parameters
    ----------
    parse_raw : bool, optional
        If True and there is a corresponding .rw.dat file, the raw data will be
        parsed and added to the data attribute in the `"raw_scan"` column when
        creating the underlying `DatFile` object.

    """

scale_moment(mass=0, eicosane_mass=0, molecular_weight=0, diamagnetic_correction=0)

Scale the moment by the given values. Scaled values are added to the data attribute in the following columns: "chi", "chi_err", "chi_t", "chi_t_err", "moment", and "moment_err". The units of these columns will be determined by what scaling was applied.

Parameters:

Name Type Description Default
mass float

Mass in mg, by default 0

0
eicosane_mass float

Eicosane mass in mg, by default 0

0
molecular_weight float

Molecular weight in g/mol, by default 0

0
diamagnetic_correction float

Diamagnetic Correction in cm^3/mol, by default 0

0
Source code in magnetopy\experiments\dc_experiment.py
def scale_moment(
    self,
    mass: float = 0,
    eicosane_mass: float = 0,
    molecular_weight: float = 0,
    diamagnetic_correction: float = 0,
) -> None:
    """Scale the moment by the given values. Scaled values are added to the `data`
    attribute in the following columns: `"chi"`, `"chi_err"`, `"chi_t"`,
    `"chi_t_err"`, `"moment"`, and `"moment_err"`. The units of these columns will
    be determined by what scaling was applied.

    Parameters
    ----------
    mass : float, optional
        Mass in mg, by default 0
    eicosane_mass : float, optional
        Eicosane mass in mg, by default 0
    molecular_weight : float, optional
        Molecular weight in g/mol, by default 0
    diamagnetic_correction : float, optional
        Diamagnetic Correction in cm^3/mol, by default 0
    """
    ...

simplified_data(*args, **kwargs)

Returns a simplified version of the data, with only the columns needed for most analyses and plotting. These columns are: "time" (in seconds), "temperature" (in Kelvin), "field" (in Oe), "moment", "moment_err", "chi", "chi_err", "chi_t", and "chi_t_err". Where units are not specified, they are determined by what scaling was applied.

Returns:

Type Description
pd.DataFrame

A DataFrame with the columns: "time" (in seconds), "temperature" (in Kelvin), "field" (in Oe), "moment", "moment_err", "chi", "chi_err", "chi_t", and "chi_t_err". Where units are not specified, they are determined by what scaling was applied.

Source code in magnetopy\experiments\dc_experiment.py
def simplified_data(self, *args, **kwargs) -> pd.DataFrame:
    """Returns a simplified version of the data, with only the columns needed for
    most analyses and plotting. These columns are: `"time"` (in seconds),
    `"temperature"` (in Kelvin), `"field"` (in Oe), `"moment"`, `"moment_err"`,
    `"chi"`, `"chi_err"`, `"chi_t"`, and `"chi_t_err"`. Where units are not
    specified, they are determined by what scaling was applied.

    Returns
    -------
    pd.DataFrame
        A `DataFrame` with the columns: `"time"` (in seconds),
        `"temperature"` (in Kelvin), `"field"` (in Oe), `"moment"`, `"moment_err"`,
        `"chi"`, `"chi_err"`, `"chi_t"`, and `"chi_t_err"`. Where units are not
        specified, they are determined by what scaling was applied.
    """
    ...