Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪Project API Tryout - Fluorescence example 🚧 #83

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ plot_results

# DOAS data file
!pyglotaran_examples/ex_doas_beta/data/2008Polli_betacar_chex_sim.nc

pyglotaran_examples/study_fluorescence/results/*
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ kinetic:
- 0.07
- 0.02
- 0.00016
- {non-negative: true}
# - {non-negative: true}
1 change: 1 addition & 0 deletions pyglotaran_examples/study_fluorescence/project.gta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: 0.7.0.dev0
13 changes: 13 additions & 0 deletions pyglotaran_examples/study_fluorescence/scheme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
model: models/model.yml
parameters: parameters/parameters.yml
data:
dataset1: dataset1.nc
clp_link_tolerance: 0.0
clp_link_method: nearest
maximum_number_function_evaluations: null
add_svd: true
ftol: 1e-08
gtol: 1e-08
xtol: 1e-08
optimization_method: TrustRegionReflection
result_path: null
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from pyglotaran_extras.plotting.plot_overview import plot_overview
from pyglotaran_extras.plotting.style import PlotStyle

GLOBAL_MODEL = "models/model.yaml"
GLOBAL_PARAMS = "models/parameters.yaml"
GLOBAL_MODEL = "models/model.yml"
GLOBAL_PARAMS = "parameters/parameters.yml"
TARGET_MODEL = "models/model-target.yaml"
TARGET_PARAMS = "models/parameters-target.yaml"
TARGET_PARAMS = "parameters/parameters-target.yaml"
SKIP_FIT = False

# %%
Expand All @@ -26,7 +26,7 @@


# %%
data_path = script_folder.joinpath("data/data.ascii")
data_path = script_folder.joinpath("data/dataset1.ascii")
# model_path = script_folder.joinpath(GLOBAL_MODEL)
# parameter_path = script_folder.joinpath(GLOBAL_PARAMS)
model_path = script_folder.joinpath(TARGET_MODEL)
Expand Down
36 changes: 36 additions & 0 deletions pyglotaran_examples/study_fluorescence/tryout_project_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pathlib import Path
from timeit import default_timer as timer

import matplotlib.pyplot as plt # 3.3 or higher
from glotaran.project.project import Project
from pyglotaran_extras.plotting.plot_overview import plot_overview

if __name__ == "__main__":
project_file = Path(".") / "project.gta"
project_folder = project_file.parent

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'project_folder' is not used.
project = Project.open(project_file)

project.load_data("dataset1.ascii")
# Would prefer to decouple dataset label and filename

start = timer()
project.optimize(
# model_name="model.yml", # note if you use 'model' it will pick the wrong file
# parameters_name="parameters.yml",
model_name="model-target.yaml",
parameters_name="parameters-target.yaml",
maximum_number_function_evaluations=100,
result_name="dummy",
)
end = timer()
print(f"Total time: {end - start}")

result = project.load_latest_result("dummy")

print(result.markdown(True))

res = result.data["dataset1"]
print(res)

fig, _ = plot_overview(result, linlog=False, figure_only=False)
plt.show(block=True)