From df8d366f1b6daf56f0a23134d15a13578401e36e Mon Sep 17 00:00:00 2001 From: Andreas Pedersen Date: Thu, 10 Oct 2024 06:50:31 +0200 Subject: [PATCH] ready to expose data --- src/easyreflectometry/data/__init__.py | 2 ++ src/easyreflectometry/project.py | 37 +++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/easyreflectometry/data/__init__.py b/src/easyreflectometry/data/__init__.py index 3676d427..fdecf1dd 100644 --- a/src/easyreflectometry/data/__init__.py +++ b/src/easyreflectometry/data/__init__.py @@ -1,7 +1,9 @@ +from .data_store import DataSet1D from .data_store import ProjectData from .measurement import load __all__ = [ load, ProjectData, + DataSet1D, ] diff --git a/src/easyreflectometry/project.py b/src/easyreflectometry/project.py index e3b02018..8b80988d 100644 --- a/src/easyreflectometry/project.py +++ b/src/easyreflectometry/project.py @@ -10,7 +10,7 @@ from easyscience import global_object from easyscience.fitting import AvailableMinimizers -from easyreflectometry.data.data_store import DataSet1D +from easyreflectometry.data import DataSet1D from easyreflectometry.model import Model from easyreflectometry.model import ModelCollection from easyreflectometry.sample import Layer @@ -19,6 +19,29 @@ from easyreflectometry.sample import Sample from easyreflectometry.sample.collections.base_collection import BaseCollection +MODELS_SAMPLE_DATA = [ + DataSet1D( + name='Sample Data 0', + x=np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + y=np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + ) +] +MODELS_MODEL_DATA = [ + DataSet1D( + name='Model Data 0', + x=np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + y=np.array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5]), + ) +] +EXPERIMENTAL_DATA = [ + DataSet1D( + name='Example Data 0', + x=np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), + y=np.array([0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]), + ye=np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]), + ) +] + class Project: def __init__(self): @@ -36,9 +59,6 @@ def __init__(self): self._created = False self._with_experiments = False - self._xArrays = [np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])] - self._yCalcArrays = [np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])] - def reset(self): del self._models del self._materials @@ -99,6 +119,15 @@ def experiments(self, experiments: List[DataSet1D]) -> None: def path_json(self): return self.path / 'project.json' + def sample_data_for_model_at_index(self, index: int = 0) -> DataSet1D: + return MODELS_SAMPLE_DATA[index] + + def model_data_for_model_at_index(self, index: int = 0) -> DataSet1D: + return MODELS_MODEL_DATA[index] + + def experimental_data_for_model_at_index(self, index: int = 0) -> DataSet1D: + return EXPERIMENTAL_DATA[index] + def default_model(self): self._replace_collection(MaterialCollection(), self._materials)