glotaran / pyglotaran

A Python library for Global and Target Analysis of time-resolved spectroscopy data
GNU Lesser General Public License v3.0
53 stars 18 forks source link

[staging] ♻️ Improve specification of clp_constraints #1537

Open jsnel opened 1 month ago

jsnel commented 1 month ago

One of the current pain points is related to specifying clp_constraints (type zero) where you are somewhat left 'guessing' the internals to know what target to write.

For instance, at the end of the model specification, 200 lines down from where the complex/element is fist specified you may find a clp_constraint tht looks like this:

clp_constraints:
  - type: zero
    target: coherent_artifact_1_artifact
    interval:
      - [1100, 1900]

Here coherent_artifact_1_artifact is not explicitly defined anywhere, you just need to 'know' it exists, because you have a coherent artifact, with at least order 1, named artifact. :see_no_evil: Even worse are the mixin of pfid and damped-oscillation related oscillation components. Needing to name the oscillation of doas dosc1, docs2, etc

SO that in zero constraints you can figure out that

 - type: zero
   target: osc2_sin
   interval:
   - [1450, 2000]

is related to PFID, whereas

 - type: zero
   target: dosc2_sin
   interval:
   - [1450, 2000]

is a zero constraint related to doas.

I think we could take advantage of the fact that the new library/elements definition could allow for easier close to the source definitions.

Proposed refactoring

Benefits

Possible cons

Additional context

It should be investigated if the other constraints (equality, equal area) could benefit from a similar refactor.