Continuing with the work released in version 0.10.0, this version includes significant new functionality as well as bug fixes and the rewriting of some smelly/ugly code previously used for the dispatch of math operators and functions. It also includes performance optimizations in the computations of color definitions from wavelengths.
In brief, this update brings: 1) improved handling of conversions among quantities used to describe filters, which required adding a mechanism to store properties of filters as metadata, and revising the code behind mathematical operations and mathematical functions related to filter_spct objects; 2) Support for use of arbitrary chromaticity definitions for tagging of spectra; 3) Changes to error checking and messages, including changing several earlier warnings into errors; several important bug fixes.
Changes from version0.10.0 the most recent CRAN release, are:
setFilterProperties(), getFilterProperties(), filter_properties() and filter_properties<-().
print() method for filter properties.
Example data for filters updated with filter properties.
Afr2T(), T2Afr(), any2T(), any2A(), and any2Afr().
wls_at_target() method for data frames.
rbindspct() now allows control of metadata copying
Serious bug in T2Afr() was causing wrong values to be returned!!
Serious bug in clean.object_spct().
Revise find_peaks() so that arguments passed to ignore.threshold and strict are obeyed also when span = NULL.
T2T(), setAfrType(), getAfrType().
Full functionality of convertThickness() and convertTfrType() requires filter_spct objects to have the new "filter.properties" attribute or contain a column "Rfr" with reflectance data like object_spct objects. This means that until packages ‘photobiologyFilters’ and ‘photobiologyPlants’ are updated, these functions cannot be used with the spectral data they contain.
After 30 releases in the 0.9.xx version series, we have reached version 1.10.1. The change to a new series is because of some potentially code-breaking changes in the returned values of summary functions. This update also coincides with major updates to ‘tidyverse’ packages. Compatibility required some rather minor changes to the code in this package. Compatibility with ‘tibble’ (3.0.0) and with the soon to be released versions of ‘dplyr’ (1.0.0), ‘rlang’ and ‘vctrs’ has been tested. This version also includes significant new functionality.
Changes from version0.9.30 the most recent CRAN release, are:
Enhance peak- and valley-related functions
Revise peaks() and valleys() methods to support peak fitting or “refinement”. Currently only spline interpolation is implemented. Default behaviour remains unchanged. (The implementation of peak fitting is still experimental and returned values may not be reproducible with future versions of the package.)
Enhance summary functions
Revise q_ratio(), e_ratio(), qe_ratio() and eq_ratio() adding new parameter scale.factor.
Revise irrad(), q_irrad() and e_irrad(); fluence(), q_fluence(), and e_fluence(); q_ratio(), e_ratio(), qe_ratio() and eq_ratio(); response(), q_response(), and e_response() methods so that they add shorter but still informative names to returned numeric values and to columns in returned data frames. Add formal parameters naming and name.tag to allow user control of the names.
Revise absorbance(), absorptance(), transmittance() and reflectance() so that they create shorter, and more informative names for returned values.
Revise msdply() to treat as special cases all the methods described above, to support the especializations of these methods for collections of spectra. For those functions not handled as special cases, returned values are, as earlier, tagged with the name of the applied function.
Add methods for extraction of spikes and for despiking
Add function find_spikes() for numeric vectors, useful for Raman spectra or array detectors with hot pixels.
Add function replace_bad_pixs() operating on numeric vectors.
Add method spikes() for vectors, data frames and spectra.
Add method despike() for vectors, data frames and spectra.
Add example data
Add data for cone fundamentals for human vision.
Revise trim_waveband() so that it preserves the names of list members. This bug affected computations of irradiances and ratios so that names used in lists of wavebands where not reflected in the output, and the label from the waveband definitions could not be overriden as intended by design.
Ensure that irrad() and response() always label the returned values correctly. Values are now always tagged according to the units used, even when these are selected by setting R options; i.e., values returned by irrad() and response() are always labelled identically as those returned by q_irrad(), e_irrad(), q_response() and e_response().
Relax check for w.length range allowing longer wavelengths (IR). In addition triggering of an error for unlikely wavelengths has been replaced by a warning, emitted only when verbose output is enabled. An error is trigegred now and only for wavelengths < 1 nm.
Update clean.object_spct() adding parameter min.Afr that can be used to set a different target than the default of zero and in addition implement clean.object_mspct(), which was missing.
Ensure compatibility with ‘dplyr’ (1.0.0)
Some small internal changes were needed to avoid errors in calls to ‘dplyr’ methods from the upcoming version 1.0.0. From user’s perspective as ‘dplyr’ now seems to retain classes derived from tibble, it may be necessary in certain cases to disable some checks during calls to dplyr methods on spectral objects in users’ scripts. We have implemented R option “photobiology.check.spct” to allow checks to be enabled and disabled as needed. This option might be also useful for optimizing performance.
Code-breaking changes in R for photobiology
By changing the labels used for values returned by summary functions, this update can break older code. Additionally, bug fixes that correct the behaviour of irrad(), fluence(), ratio() and response(), and trim_waveband() can potentially break old code. The order in which attributes are stored has in some cases changed, and while a fixed order is not normally expected, equality tests can return FALSE for objects that are functionally identical but differ in their structure because of their vintage.
Code breaking changes in the tidyverse
Packages in the tidyverse are evolving to use package ‘vctrs’ for their implementation (see https://www.tidyverse.org/blog/ for news). ‘tibble’ (3.0.0) seems to handle row names differently than previous versions. The ‘photobiology’ code is not affected, but user code might be affected. Contrary to earlier versions, ‘tibble’ (3.0.0) retains member names in vectors, which means that "wl.colors" column created by tag() after the update to ‘tibble’ will contain named color values. ‘dplyr’ (1.0.0), not yet released, better preserves object attributes, causing some differences in the returned values, as now columns retain S3 class attributes. The use of ‘dplyr’ verb select() on spectral objects now fails, while extraction with [ and [[ works as expected as well as filter() and mutate() work correctly.