Closed CdeMills closed 5 months ago
Dear Pascal,
Thanks for raising this issue. Indeed there is a bug affecting response_spct
methods. I will try to fix this bug by the end of the day. I am sorry about this!
Meanwhile, below is a comparison between the source_spct
methods, working as expected, and the response_spct
method failing. The errors messages are different, I think, because I am using the latest version 0.11.1.
library(ggspectra)
#> Loading required package: photobiology
#> News at https://www.r4photobiology.info/
#> Loading required package: ggplot2
library(photobiology)
autoplot(sun.spct)
autoplot(fscale(sun.spct, f = e_irrad, target = 10))
autoplot(fscale(normalise(sun.spct), f = e_irrad, target = 10))
autoplot(ciev2.spct)
autoplot(fscale(ciev2.spct, f = e_response, target = 10))
autoplot(fscale(normalise(ciev2.spct), f = e_response, target = 10))
Created on 2024-02-28 with reprex v2.1.0
The source of the problem is in the autoplot()
method in 'ggspectra' . The reason for the apparent bug is a badly chosen default argument for parameter norm
in the autoplot()
method for response_spct'. Adding
norm = "skip"` to the call solves the problem, at least with the most recent version of 'photobiology' (0.11.1 now in CRAN).
(The error "Normalization not updated: action not supported for objects created with 'photobiology' (<= 0.10.9)." was caused in the previous version by a version mismatch between the data object and the function.)
library(ggspectra)
#> Loading required package: photobiology
#> News at https://www.r4photobiology.info/
#> Loading required package: ggplot2
library(photobiology)
autoplot(ciev2.spct, norm = "skip")
autoplot(fscale(ciev2.spct, f = e_response, target = 10), norm = "skip")
autoplot(fscale(normalise(ciev2.spct), f = e_response, target = 10), norm = "skip")
Created on 2024-02-28 with reprex v2.1.0
This is fixed in the under development version.
Hello
the following code:
generates the warning:
In normalize_spct(spct = q2e(x, action = "replace.raw"), range = range, : Normalization not updated: action not supported for objects created with 'photobiology' (<= 0.10.9).
Which can be traced to spct.normalize.r, line 753:
Clearly, there is some discrepancy between "normalize" and fscale, as cie2.spct is normalized; while mycie2.spct is scaled. The generated image place both maxima at "1"; meaning mycie2.spct scaling is ignored. Any hint ?
Regards
Pascal