aphalo / photobiology

Package ‘photobiology’ defines a system of classes for storing spectral data and accompanying methods and operators. This is the core of a suite of R packages for photobiological calculations.
4 stars 1 forks source link

Handling normalizations in filter_spct qty conversions #14

Closed aphalo closed 1 year ago

aphalo commented 1 year ago

The improved approach implemented in v0.10.15 in e2q() and q2e() needs to be implements also in Afr2T, A2T, etc., any2T, etc.

aphalo commented 1 year ago

Once this is implemented, there will be a guarantee that normalization multipliers are always valid. Possibly, we will need to label new spct objects as of version 3 to easily check this. A couple of versions later, we could implement the reversion of normalization. But, would this be of any use? Possibly not. This needs to be thought out as rounding errors could make reverted data different from the original.

aphalo commented 1 year ago

setNormalized() needs to be updated, adding a warning, as setting only a logical without the normalization data makes tests fail in multiple places, especially in 'ggspectra'.

aphalo commented 1 year ago

This is now implemented. One could in principle undo the previous normalization before a new normalization so that the new scale factors would be expressed relative to the original data in physical units. This is possible only for objects created with recent versions of 'photobiology'. The reversion of normalization can be implemented as an internal function and called before applying a new normalization. This is needed only when the variable or quantity to be renormalized is not linearly related to the one already normalized. When changing the normalization criterion without changing the data column, the current implementation adjusts the norm.factors to remain valid, otherwise they are set to NA.