Skip to content

[Option Appraisal Module] [Package 1: Measures] Split 1: Adds MeasureConfig dataclasses for serializable measure configuration.#1276

Merged
spjuhel merged 31 commits into
developfrom
feature/option-appraisal-dataclasses
Jun 10, 2026
Merged

[Option Appraisal Module] [Package 1: Measures] Split 1: Adds MeasureConfig dataclasses for serializable measure configuration.#1276
spjuhel merged 31 commits into
developfrom
feature/option-appraisal-dataclasses

Conversation

@spjuhel

@spjuhel spjuhel commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Changes proposed in this PR:

This PR introduces a new module defining a family of dataclasses that encode adaptation measure parameters in a serializable, declarative form. This is a preparatory step for the broader Measure/MeasureSet rework.

The objective is to retain the possibility to define measures from modifiers in addition to the upcoming system that will use python functions directly, and provide a (better) user interface for this.

no existing code is changed.

New dataclasses:

  • MeasureConfig top-level configuration for a single measure, aggregating all modifier configs below.
  • ImpfsetModifierConfig parameters for modifying impact functions (intensity, MDD, PAA scaling, optional replacement)
  • HazardModifierConfig parameters for modifying hazard (intensity scaling, frequency cutoff, optional replacement)
  • ExposuresModifierConfig parameters for modifying exposures (impact function remapping, zeroing regions, optional replacement)
  • CostIncomeConfig serializable representation of cost/income cash flow parameters

All configs inherit from the abstract _ModifierConfig base, which provides shared to_dict/from_dict and a __repr__ that highlights non-default fields.

MeasureConfig supports full serialization to/from dict, YAML, and legacy Excel rows (from_row), which will serve as the migration path for the existing file-based I/O in MeasureSet.

PR Author Checklist

PR Reviewer Checklist

Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py
@chahank

chahank commented Apr 7, 2026

Copy link
Copy Markdown
Member

Excellent idea!

spjuhel added 7 commits April 7, 2026 10:22
Cleans-up, Docstringfies

Better to_dict, color parser, and post_inits

Removes duplicate docstring
…MADA-project/climada_python into feature/option-appraisal-dataclasses
@spjuhel spjuhel changed the title [Option Appraisal Module] - Adds MeasureConfig dataclasses for serializable measure configuration. [Option Appraisal Module] [Package 1: Measures] Split 1: Adds MeasureConfig dataclasses for serializable measure configuration. Apr 7, 2026
@spjuhel

spjuhel commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

@chahank

Question: Should measures (defined by MeasureConfig) be specific to a hazard? (I see reasons for both yes and no)

Currently, they are specific (thus configs require you to provide haz_type).

I see how you could want modifications of impact function to be for multiple hazards
But also you should probably not be able to apply a shift in intensity for multiple hazards?

Any opinion on that?

@spjuhel spjuhel marked this pull request as ready for review April 8, 2026 14:04
@spjuhel

spjuhel commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

This PR is officially open for review! Review is advised after #1274 is merged.

Actual changes to be reviewed are in:

  • climada/entity/measures/measure_config.py
  • climada/entity/measures/test/test_measure_config.py
  • doc/user-guide/climada_measure_config.ipynb (and a few other tutos where a target was added at the top)

@chahank

chahank commented Apr 9, 2026

Copy link
Copy Markdown
Member

@chahank

Question: Should measures (defined by MeasureConfig) be specific to a hazard? (I see reasons for both yes and no)

Currently, they are specific (thus configs require you to provide haz_type).

I see how you could want modifications of impact function to be for multiple hazards But also you should probably not be able to apply a shift in intensity for multiple hazards?

Any opinion on that?

Good question. I would then to keep it hazard type specific. But maybe best is to ask core users of the model :).
@ChrisFairless : any opinion?

@peanutfun peanutfun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed mostly on a technical level. Very nice code quality overall, nice class structure! I found a few issues. Sorry for the brevity 😬 ✌️

Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/measure_config.py Outdated
Comment thread climada/entity/measures/test/test_measure_config.py Outdated
Comment thread climada/entity/measures/test/test_measure_config.py Outdated
@spjuhel

spjuhel commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author

@ValentinGebhart This has been reviewed on the technical aspects. Can you give a look at the guide here and tell me if its clear enough?

Note: The "measure tutorial" link at the end does not work yet and is a placeholder.

@ValentinGebhart ValentinGebhart left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this very clear tutorial! I added only a few rephrasings and some comments at points where I thought it was not perfectly clear. However all are only minor things, and I find the explanations very clear about how to define the MeasureConfigs.

Comment thread doc/user-guide/climada_measure_config.ipynb
Comment thread doc/user-guide/climada_measure_config.ipynb Outdated
Comment thread doc/user-guide/climada_measure_config.ipynb Outdated
Comment thread doc/user-guide/climada_measure_config.ipynb Outdated
Comment thread doc/user-guide/climada_measure_config.ipynb
Comment thread doc/user-guide/climada_measure_config.ipynb
Comment thread doc/user-guide/climada_measure_config.ipynb Outdated
Comment thread doc/user-guide/climada_measure_config.ipynb Outdated
Comment thread doc/user-guide/climada_measure_config.ipynb
@spjuhel spjuhel merged commit a99b10b into develop Jun 10, 2026
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants