OasisLMF / ktools

In-memory simulation kernel for loss modelling.
BSD 3-Clause "New" or "Revised" License
28 stars 19 forks source link

Add runtime user-supplied relative secondary and absolute factor options to placalc + add tests for Post Loss Amplifcation components #354

Closed hchagani-oasislmf closed 11 months ago

hchagani-oasislmf commented 1 year ago

Add runtime user-supplied relative, secondary factor option to placalc

An optional, relative flat-factor can be specified by the user and applied to all loss factors with the command line argument -f. For example, to apply a relative secondary factor of 0.8 the following can be entered:

$ placalc -f 0.8 < gulcalc_output.bin > placalc_output.bin

The relative secondary factor must lie within the range [0, 1] and is applied to the deviation of the factor from 1. For example:

event_id factor from model relative factor from user applied factor
1 1.10 0.8 1.08
2 1.20 0.8 1.16
3 1.00 0.8 1.00
4 0.90 0.8 0.92

Add runtime user-supplied absolute, uniform factor option to placalc

Alternatively, an absolute, uniform post loss amplification/reduction factor can be applied to all losses by the user with the command line argument -F. For example, to specify a uniform factor of 0.8 across all losses, the following can be entered:

$ placalc -F 0.8 < gulcalc_output.bin > placalc_output.bin

If specified, the loss factors from the model (those in lossfactors.bin) are ignored. This factor must be positive and is applied uniformly across all losses. For example:

event_id factor from model uniform factor from user applied factor
1 1.10 0.8 0.8
2 1.20 0.8 0.8
3 1.00 0.8 0.8
4 0.90 0.8 0.8

The absolute, uniform factor is incompatible with the relative, secondary factor given above. Therefore, if both are given by the user, a warning is issued and the relative, secondary factor is ignored:

$ placalc -f 0.8 -F 0.8 < gulcalc_output.bin > placalc_output
WARNING: Relative secondary and absolute factors are incompatible
INFO: Ignoring relative secondary factor

Add tests for Post Loss Amplification (PLA) components

Acceptance tests for placalc, amplificationstobin, amplificationstocsv, lossfactorstobin and lossfactorstocsv have been included.

hchagani-oasislmf commented 1 year ago

Hi @johcarter. When you get the chance, would you mind checking the output for placalc makes sense? It looks good to me but it would be good to get a second pair of eyes on it. I've updated the acceptance tests to include placalc.

hchagani-oasislmf commented 1 year ago

Hi @johcarter. As discussed, I've added the option to specify an absolute, uniform factor across the losses. Would you mind taking another look when convenient please?

hchagani-oasislmf commented 11 months ago

Passes all tests: numbers look good within floating point errors. Ready to merge.