Exemple #1
0
class ThreeComponentNoIrf:
    model = load_model(MODEL_3C_NO_IRF, format_name="yml_str")
    initial_parameters = load_parameters(PARAMETERS_3C_NO_IRF_INITIAL,
                                         format_name="yml_str")
    wanted_parameters = load_parameters(PARAMETERS_3C_NO_IRF_WANTED,
                                        format_name="yml_str")
    time = np.arange(0, 100, 1.5)
    spectral = np.arange(600, 750, 10)
    axis = {"time": time, "spectral": spectral}
Exemple #2
0
def test_save_model(
    tmp_path: Path,
):
    """Check all files exist."""

    model_path = tmp_path / "testmodel.yml"
    save_model(file_name=model_path, format_name="yml", model=MODEL)

    assert model_path.is_file()
    assert model_path.read_text() == want
    assert load_model(model_path).valid()
Exemple #3
0
 def setup(self):
     dataset1 = load_dataset(SCRIPT_DIR / "data/data1.ascii")
     dataset2 = load_dataset(SCRIPT_DIR / "data/data2.ascii")
     model = load_model(str(SCRIPT_DIR / "models/model.yml"))
     parameters = load_parameters(str(SCRIPT_DIR / "models/parameters.yml"))
     self.scheme = Scheme(
         model,
         parameters,
         {
             "dataset1": dataset1,
             "dataset2": dataset2
         },
         maximum_number_function_evaluations=11,
         non_negative_least_squares=True,
         optimization_method="TrustRegionReflection",
     )
def read_model_from_yaml_file(model_file: str) -> Model:
    """Parse ``model.yaml`` file to :class:`Model`.

    Warning
    -------
    Deprecated use ``glotaran.io.load_model(model_file)`` instead.

    Parameters
    ----------
    model_file : str
        File with model spec description as yaml.

    Returns
    -------
    Model
        Model described in ``model_file``.
    """
    return load_model(model_file)
def read_model_from_yaml(model_yml_str: str) -> Model:
    """Parse ``yaml`` string to :class:`Model`.

    Warning
    -------
    Deprecated use ``glotaran.io.load_model(model_yml_str, format_name="yml_str")``
    instead.

    Parameters
    ----------
    model_yml_str : str
        Model spec description in yaml.

    Returns
    -------
    Model
        Model described in ``model_yml_str``.
    """
    return load_model(model_yml_str, format_name="yml_str")
Exemple #6
0
DATA_PATH1 = "data/data1.ascii"
DATA_PATH2 = "data/data2.ascii"
MODEL_PATH = "models/model.yml"
PARAMETERS_FILE_PATH = "models/parameters.yml"

# %% Setup necessary (output) paths
results_folder, script_folder = setup_case_study(Path(__file__))
output_folder = results_folder.joinpath("target_analysis")
print(f"- Using folder {output_folder.name} to read/write files for this run")

# %% Load in data, model and parameters
# dataset1 = ExplicitFile(script_folder.joinpath(DATA_PATH1)).read()
# dataset2 = ExplicitFile(script_folder.joinpath(DATA_PATH2)).read()
dataset1 = load_dataset(script_folder.joinpath(DATA_PATH1))
dataset2 = load_dataset(script_folder.joinpath(DATA_PATH2))
model = load_model(script_folder.joinpath(MODEL_PATH))
parameters = load_parameters(script_folder.joinpath(PARAMETERS_FILE_PATH))

# %% Validate model and parameters
print(model.validate(parameters=parameters))

# %% Construct the analysis scheme
scheme = Scheme(
    model,
    parameters,
    {
        "dataset1": dataset1,
        "dataset2": dataset2
    },
    maximum_number_function_evaluations=11,
    non_negative_least_squares=True,
Exemple #7
0
def load_model_file(filename, verbose=False):
    return _load_file(filename,
                      lambda file: load_model(file, format_name="yml"),
                      "model", verbose)
Exemple #8
0
from glotaran.analysis.simulation import simulate
from glotaran.io import load_model
from glotaran.project import Scheme
from glotaran.project.generators import generate_model_yml
from glotaran.testing.simulated_data.shared_decay import PARAMETERS
from glotaran.testing.simulated_data.shared_decay import SIMULATION_COORDINATES
from glotaran.testing.simulated_data.shared_decay import SIMULATION_PARAMETERS

SIMULATION_MODEL_YML = generate_model_yml(
    generator_name="spectral_decay_parallel",
    generator_arguments={
        "nr_compartments": 3,
        "irf": True
    },
)
SIMULATION_MODEL = load_model(SIMULATION_MODEL_YML, format_name="yml_str")

MODEL_YML = generate_model_yml(
    generator_name="decay_parallel",
    generator_arguments={
        "nr_compartments": 3,
        "irf": True
    },
)
MODEL = load_model(MODEL_YML, format_name="yml_str")

DATASET = simulate(
    SIMULATION_MODEL,
    "dataset_1",
    SIMULATION_PARAMETERS,
    SIMULATION_COORDINATES,
Exemple #9
0
class MultiCenterIrfDispersion:
    model = load_model(MODEL_MULTIPULSE_IRF_DISPERSION, format_name="yml_str")
    parameters = load_parameters(PARAMETERS_MULTIPULSE_IRF_DISPERSION,
                                 format_name="yml_str")
    axis = {"time": _time_axis(), "spectral": _spectral_axis()}
Exemple #10
0
class SimpleIrfDispersion:
    model = load_model(MODEL_SIMPLE_IRF_DISPERSION, format_name="yml_str")
    parameters = load_parameters(PARAMETERS_SIMPLE_IRF_DISPERSION,
                                 format_name="yml_str")
    axis = {"time": _time_axis(), "spectral": _spectral_axis()}
Exemple #11
0
class MultiIrfDispersion:
    model = load_model(MODEL_MULTI_IRF_DISPERSION, format_name="yml_str")
    parameters = load_parameters(PARAMETERS_MULTI_IRF_DISPERSION, format_name="yml_str")
    time = np.arange(-1, 5, 0.2)
    spectral = np.arange(300, 500, 100)
    axis = {"time": time, "spectral": spectral}
Exemple #12
0
def model():
    spec_path = join(THIS_DIR, "test_model_spec.yml")
    m = load_model(spec_path)
    print(m.markdown())
    return m