Source code for physicslab.experiment

"""
Modules for particular experiments and general functions.
"""


from types import ModuleType
from typing import Union

import pandas as pd

from . import curie_temperature
from . import hall
from . import magnetism_type
from . import profilometer
from . import sem
from . import van_der_pauw


#: :attr:`pandas.Dataframe.attrs` tag.
UNITS = 'units'


[docs]def process(data_list: list, by_module: ModuleType, **kwargs) -> pd.DataFrame: """ Genereal process function calling appropriate :func:`process` function from selected :mod:`experiment` module. Include units attribute. :param data_list: List of measurements, which are passed to the appropriate :func:`process` function :type data_list: list(pandas.DataFrame) :param by_module: Submodule of :mod:`experiment` by which the individual measurements are to be processed :type by_module: :mod:`experiment` submodule :param kwargs: Additional keyword arguments are forwarded to :func:`by_module.process` function :return: Collection of results indexed by measurement's :attr:`name` :rtype: pandas.DataFrame """ results = [] for i, data in enumerate(data_list): series = by_module.process(data, **kwargs) series.name = data.name if hasattr(data, 'name') else i results.append(series) df = pd.DataFrame(results) df.attrs[UNITS] = by_module.process(None) return df