where_measured()
, what_measured()
, how_measured()
and
when_measured()
for data frames (and tibbles).setHowMeasured()
and setWhatMeasured()
methods for collections of spectra.color_of.numeric()
by changing
sign. This is temporary patch to allow reverse transform in scale in 'ggspectra'.Bug fixes and improved printing of spectra and their summaries. This changes the printed header text, but should not break code.
s_mean_se_band()
.s_mean()
, s_mean_se()
, s_mean_se_band()
,
s_median()
, s_sd()
, s_se()
, s_var()
, s_sum()
, s_prod()
, s_range()
for class generic_spct
.idfactor
with setIdFactor()
.make_var_labels()
dynamically creates a named list of labels for
the variables in spectral objects [labels' texts may change in next version].print.generic_spct()
to include variable labels in header, instead
of showing metadata directly.summary.generic_spct()
to save variable labels in returned object.print.summary_generic_spct()
to print a header equal to the one
printed by the updated print()
methods.summary.generic_spct()
to optionally expand objects containing
multiple spectra in long form into collections of spectra in advance of creating
the summary.summary.generic_mspct()
to optionally expand member objects and
call summary.generic_spct()
on each of them.Mostly a bug-fix release.
normalize.solute_mspct()
and
normalize.generic_mspct()
fscale()
methods.fscale()
methods when applied to <xxx>_spct
objects
containing multiple spectra in long form.rbindspct()
non-default idfactor
values could be ignored in
some cases.normalise()
, fscale()
, and smooth_spct()
methods: dropped
idfactor
attribute when operating on <xxx>_spct
objects containing multiple
spectra in long form.origin
in two calls to
as.POSIXct()
.The main enhancements in this update are 1) the implementation of proper handling of metadata attributes in objects containing multiple spectra in long form and during their two way conversion to collections of spectra, and 2) improved performance of the computation of irradiances for spectra stored in long or tidy form.
subset()
method and the extraction
operator []
for objects of class generic_spct
and derived classes. This
makes it possible to extract a subset of spectra from an object containing
multiple spectra in long form, such as a time series of spectra, with no
extraneous metadata attribute values carried along. In earlier
versions metadata were not subset.rbindspct()
implement simplification of metadata by removing unnecessary
duplication of invariant values.pull_sample()
specialization for generic_spct
for faster
performance.irrad()
, e_irrad()
and q_irrad()
adding parameter return.tb
making it possible to force the return of a tibble even for summaries of
individual spectra.irrad()
, e_irrad()
and q_irrad()
for faster performance with
multiple spectra in long-form. (Adding attributes to the returned tibble is not
yet supported except for when.measured
.)normalise()
, fscale()
and smooth_spct()
methods to accept
multiple spectra in long form as their argument returning a similar object, with
the spectra individually normalised or scaled.peaks()
, valleys()
, wls_at_target()
, spikes()
and despike()
methods to consistently return an object as the same class as their x
argument.when_measured2tb()
to support generic_spct
in addition to
generic_mspct
objects. (Methods to add other attributes are not yet revised.)span
to thin_wl()
methods, with the previously hard-coded
value of 21 as default.idFactor
and other non-numeric variables in clip_wl()
and trim_wl()
so that they are filled with good values instead of NA when
possible and fix a bug that converted non-numeric variables into numeric ones
in the returned value.getNormalized()
, getNormalised()
, getNormalization()
,
getNormalisation()
, is_normalized()
, and is_normalised()
to support
collections of spectra as their argument in addition to individual spectra. In
this case they return a named list.sun_evening.spct
and
sun_evening.mspct
.raw_spct
and cps_spct
do not emit a message about renaming
columns if option photobiology.verbose
is set to FALSE
.irrad()
, e_irrad()
and q_irrad()
causing a crash with
argument use.hinges = FALSE
.idFactor
in subset2mspct()
.polyester.spct
and yellow_gel.spct
have
changed slightly as storage use was optimized. This is a code breaking change
if positional indexes have been used, but otherwise differences in computed
values are minor.print.instr_desc()
.trimInstrDesc()
so that by default it keeps the entrance.optics
field.pull_sample()
for pulling random samples of spectra, replacing
functions functions sample_spct()
and sample_mspct()
added in 0.10,17.normalized_diff_ind()
methods, rename plus.w.band
into w.band.plus
and minus.w.band
into w.band.minus
for consistency with Tfr_normdiff()
,
Rfr_normdiff()
and other functions.subset2mspct()
when applied to the case of a collection
containing a single spct object containing a single spectrum.sample_spct()
and sample_mspct()
.smooth_spct()
method for class "cps_spct"
.e_fraction()
and q_fraction
methods.Rfr_ratio()
, Rfr_fraction()
and Rfr_normdiff()
.Tfr_ratio()
, Tfr_fraction()
and Tfr_normdiff()
.quantity
to q_ratio()
and e_ratio()
methods."filter_spct"
and fix a bug affecting setting of metadata attribute during
updates to the normalization of "source_spct"
and "response_spct"
objects.subset2mspct()
introduced in 0.10.15 affecting collections of
spectra with a single spct object with multiple spectra in long form as only
member.log2()
and log10()
.spct_wide2long()
a simple pure R replacement for
dplyr::pivot_longer()
for spectra.subset2mspct()
to accept collections of spectra and
subset (split) members containing multiple spectra in long form.subset2mspct()
to accept any valid spct
object and
always return a mspct
object.is_daytime()
a wrapper on day_night()
returning a logical
vector.waveband()
accepting all
defaults argument more informative.e2q()
and q2e()
to better handle previously normalized spectra
passed as arguments: re-normalization is applied by default.e2q()
and q2e()
. The change in
computed values is at most 20 parts per million.wl2wavenumber()
, wavenumber2wl()
, wl2frequency()
, frequency2wl()
,
wl2energy()
and energy2wl()
.illuminance()
.irrad()
and in
trim_waveband()
.filter.properties
attribute.summary()
method for collections of spectra.[
) operator for collections of spectra, resulting in
wrong values for dimension attribute ("mspct.dim"
).Conversions between Date
and POSIXct
objects are tricky because the
former do not store information on the time zone. A change in
'lubridate' 1.8.0 made a previously working approach to these
conversions silently fail to apply the shift to the hours. In the
current version of 'photobiology', if no time zone argument is passed
concurrently with a date, the date is assumed to be in UTC. If this time
zone does not match the location given by the geocode, the date used for
the calculations can be wrong by one day.
This release corrects problems triggered by recent updates to packages
'lubridate' and possibly 'tibble' (reported by putmanlab in issue
#7) and adds
enhancements for class solute_spct
.
day_night()
, sunrise_time()
, noon_time()
and
sunset_time()
would return wrong time values when non-default
arguments to parameter tz
were passed together with objects of
class Date
passed as arguments to date
.as.filter_spct()
and as.solute_spct
specialised for
two-way conversion between objects of classes solute_spct
and
filter_spct
.solute.properties
adding fields solvent.name
and solvent.ID
.solute_spct
and solute_mspct
to be
used to store molar (default) and mass based coefficients of
attenuation describing overall attenuation, or attenuation by
absorption or by scattering. Implement the corresponding methods.
(Unstable: interface may change).water.spct
and
phenylalanine.spct
.join_mspct()
to use interpolation when wavelengths differ
among member spectra. This should not break old code but output can
slightly differ.character
arguments passed to parameter
target
in all wls_at_target()
methods.rbindspct()
and
find_wls()
.rowwise_filter()
affecting parallel summaries of
absorptance.s_mean_se_band_band()
.normalize()
methods to support updating an already present
normalization (norm = "update"
) and skipping the normalization
altogether (norm = "skip"
).normalize()
methods to store range
in the attribute, and
getNormalized()
to return it.normalize()
methods to correctly handle normalization of
previously normalized spectra, and add flexibility to the
normalization of previously scaled spectra.getScaling()
and fix minor inconsistency in value returned by
getScaled()
.getNormalization()
(wrong named member in returned
value from spectra with no normalization data)."normalization"
attribute not being copied.summary.generic_spct()
.shared_member_class()
(wrong value returned for empty
collections).smooth_spct()
to handle bad arguments passed to method
without crashing and add support for skipping smoothing
(method = "skip"
).smooth_spct()
methods so that NA
values in wl.range
are
handled as documented and consistently with other methods in the
package.normalize()
, setNormalized()
and
getNormalized()
, and add new function getNormalization()
. These
changes implement the storage in attribute normalization
of the
operation done.mat2mspct()
affecting matrices with more than 26
columns and without colnames
previously set.rowwise
methods.ET_ref()
for computation of reference
evapotranspiration, implementing the original FAO56 formulation of
the Penman-Monteith method as well as modified in 2005 for tall and
short vegetation according to ASCE-EWRI. The formulation is that for
ET expressed in mm/h, but modified to use as input flux rates in
W/m2 and pressures expressed in Pa.net_radiation()
that computes the long wave net
radiation balance if down-welling long wave radiation is available
and otherwise estimates it.irrad_extraterrestrial()
that computes down-welling
solar irradiance on a horizontal plane at the top of the atmosphere.sun_angles()
to also return the Sun to Earth
distance.msmsply()
.dyn.range
in cps2Tfr()
and cps2Rfr()
so that it takes into account the relative signal in
the reference spectrum.missing.pixs
to cps2irrad()
so that corrupted
too-short spectra can be converted if the location of missing pixels
is known.raw_mspct
and cps_mspct
objects.irrad()
,
e_irrad()
, q_irrad()
, q_ratio()
, e_ratio()
, qe_ratio()
,
eq_ratio()
, absorbance()
, absorptance()
, trasmittance()
,
reflectance()
methods.integrate_spct()
method.na.rm = TRUE
in find_peaks()
.drop_user_cols()
to remove user-defined columns from
spectra.collect2mspct()
and rename method uncollect()
into
uncollect2spct()
.spct_metadata()
to query the value of metadata
attributes.add_attr2tb()
expanding support to all metadata attributes.rbindspct()
to gracefully handle duplicate member names in
its input.smooth_spct()
methods: new parameter wl.range and bug fix
handling of strength in "custom"
method.compare_spct()
function to accept scaled and normalized
spectra with a warning."response.type"
to distinguish between
response spectra and action spectra stored in response_spct
objects. Add methods setResponseType()
and getResponseType()
.Bug fixes.
Improved performance in color-related functions, mainly benefiting package 'ggspectra'.
Handle gracefully and consistently special input in
fast_color_of_wl()
.
Add fast_wb2rect_spct()
, which uses precomputed color definitions
for narrow wavebands and optionally simplifies the returned spectrum
by merging neighboring rectangles of identical color.
Add fast_color_of_wb()
that uses precomputed color definitions for
narrow wavebands.
Add parameter force to check_spct()
methods, so that critical
checks cannot be disabled.
Implement math functions for class generic_spct
.
BUG FIX: ERROR in CRAN check because of bad example in docs.
BUG FIX: tag()
would fail to assign wb.color
and wb.name
to
longest w.length
value in spectrum.
normalised_diff_ind()
.as_tod()
and implement format()
and print()
methods
for time-of-day.tag()
to use precomputed color definitions, when possible,
to improve performance.color_of()
.merge2object_spct()
.merge_attributes()
.interpolate_spct()
.[ ]
.setFilterProperties()
, getFilterProperties()
,
filter_properties()
and filter_properties<-()
.convertTfrType()
, convertThickness()
.Afr2T()
, any2T()
, any2A()
, and any2Afr()
.print()
method for filter properties.T2Afr()
was causing wrong values to be returned!!clean.object_spct()
.find_peaks()
so that ignore.threshold
and strict
arguments are respected also when span = NULL
. This affects all
peaks- and valleys-related methods. Changes return values for the
previously undocumented use of negative threshold values and with
span = NULL
and strict = TRUE
as arguments.wls_at_target()
method for data frames.wls_at_target()
methods for consistency, add examples.rbindspct()
to not add columns to returned value when input
is consistent.rbindspct()
to allow control of metadata copying.is_absorptance_based()
`.T2T()
, setAfrType()
, getAfrType()
. No deprecation as not used.Full functionality of convertThickness()
and convertTfrType()
requires that filter_spct
objects have the new "filter.properties"
attribute or that they contain a column "Rfr"
with spectral
reflectance data like object_spct
objects do.
peaks()
and valleys()
methods to support peak fitting.
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.)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 function find_spikes()
for numeric vectors, useful for Raman
spectra.
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 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
overridden 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 labeled
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 triggered now 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.
Some small internal changes were needed to avoid errors in calls to
'dplyr' methods. 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 is also useful for optimizing code
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 guaranteed or even expected for attributes in the R language,
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
Tidyverse 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' verbselect()
on spectral objects now
fails, while extraction with [
and [[
works as expected. However,
filter()
and mutate()
work correctly.
compare_spct()
for comparisons between pairs of
spectra based on summaries computed over multiple ranges of
wavelengths.uncollect()
for extracting all members of a
collection of spectra.wl_thin()
for reducing the storage size of
_spct objects by removing data points in regions with only minor
features.when_measured()
and when_measured<-()
, where_measured()
and where_measured<-()
, what_measured()
and what_measured<-()
,
how_measured()
and how_measured<-()
as an alternative syntax
consistent with base R for setting and querying the attributes
when.measured, where.measured, how.measured and what.measured used
to store metadata in spectral objects and collections.normalized_difference_ind()
.summary.generic_spct()
to store the name of the summarized
spectrum object and revise print.summary_generic_spct()
to display
the name of the summarized object.get_attributes()
methods."address"
to setWhereMeasured()
, revise print()
methods for spectra to display address when available.getWhereMeasured()
to consistently return a data.frame,
even when a geocode is missing.na_geocode()
, a constructor for a valid geocode data
frame with all fields set to NA
s of correct modes.One of these changes to handling of geocodes is potentially code-breaking as the returned value for missing geocode data is now a data.frame containing NAs instead of a bare NA. In contrast, handling of geocodes stored in objects created with earlier versions of the package is fully consistent with that for new objects.
clean.object_spct()
, na.rm.object_spct()
and
na.omit.object_spct()
methods, which were missing.Ler_leaf.spct
data.getTimeUnit()
.setHowMeasured()
and getHowMeasured()
using attribute
"how.measured"
.sun_angles()
and day_night()
and
implement Meuus algorithm for julian day. End result is slightly
slower performance but much higher precision and broader range of
dates that are handled correctly.sun_angles()
and day_night()
have changed
very slightly as a result of the improved julian day calculation.cps2irrad()
to ensure that all attributes are copied.s_mean()
, s_median()
, s_range()
, s_sd()
,
s_var()
, s_sum()
, s_prod()
and s_mean_se()
methods for
collections of spectra that operate across spectra returning
computed values at each wavelength---i.e. a single computed spectral
object.na.action = "replace"
to methods na.omit()
and
na.exclude()
.na.rm
to smooth_spct()
methods, with unchanged
default behaviour.smooth_spct()
: metadata not copied to returned
spectrum.insert_hinges_spct()
: metadata not fully copied to
returned spectrum."wexler"
and "goff.gratch"
for water vapor
pressure estimates. Add function water_RH()
to compute relative
humidity from water VP and air temperature.merge_attributes()
which in certain cases triggered fatal errors when using operators
or other methods taking two spectra as arguments. This also affected
indirectly package 'ooacquire'.wls_at_target()
implementing search and interpolation
of wavelengths at which the spectral quantity matches a target
value. This method is implemented for all spectral classes and
collections of spectra, expect raw_spct
, chroma_spct
and
object_spct
and corresponding collections.getWhenMeasured()
always returns an object of
class "POSIXct"
."scale.factor"
as formal parameter to methods irrad()
,
q_irrad()
, e_irrad()
, response()
, q_response()
and
e_response()
.idx
in the various summary
methods for collections of spectra. Also add parameter idx
to add
attributes to tibble methods and rewrite the get methods for
attributes using a simpler, and possibly faster approach.sep
to function convolve_each()
.Remove dependency on 'caTools' which is no longer maintained and is scheduled to be archived in CRAN.
copy_attributes()
function (some attributes were not
copied).cps2irrad()
,
cps2Tfr()
and cps2Rfr()
.merge_attributes()
function and fix bugs in handling of
metadata attributes in math operators, affecting operations between
two spectral objects.setMultipleWl()
to
guess number of copies when multiple.wl
argument is NULL
. Add
setIdFactor()
and getIdFactor()
, and add parameter 'idfactor'
to setGenericSpct()
and equivalent functions.smooth_spct()
method to
spectra containing NA
s. (Warn and return as is.)na.rm
to peaks()
, valleys()
and related methods
and functions.na.rm
to normalize()
methods."photobiology.verbose"
is initialized to the value of R's
option "verbose"
at the time the package is attached.photobiology.verbose == TRUE
, starting from this version the
presence of NA
s in spectral data triggers warnings.max()
, min()
, range()
, midpoint()
, and spread()
with names
with wl_
prepended (e.g. wl_max()
). Rename method spread()
to
expanse()
and deprecate use of spread()
. In the case of
wl_expanse()
and expanse()
the new names prevent a name clash
with tidyr::spread()
.as.
' class-coercion functions into generic methods,
and add specializations. Default behaviour remains unchanged.relative_AM()
to compute relative air mass from sun
elevation.sun_angles()
that resulted in wrong azimuth values
returned in some circumstances. (Bug introduced in version 0.9.12
when the astronomy code was overhauled in December 2016.)day_night()
that resulted in a small time shift when a
time was passed instead of a date as an argument to parameter
date
.irrad()
, e_irrad()
and q_irrad()
methods for
collections of spectra which was resulting in arguments passed to
parameter quantity
being silently ignored.merge2object_spct()
that constructs an object_spct
from a filter_spct
and a reflector_spct
, even if wavelengths
differ. Add methods T2Afr()
and Afr2T()
for converting
transmittance to absorptance and vice versa.T2T()
for converting between internal and total
transmittance when total reflectance is available.Afr
).using_photon()
, using_energy()
, using_Tfr()
,
using_Afr()
, using_A()
.photon_as_default()
, energy_as_default()
, Tfr_as_default()
,
Afr_as_default()
, A_as_default()
.verbose_as_default()
, strict_range_as_default()
.wb_trim_as_default()
, use_cached_mult_as_default()
.unset_user_defaults()
to clear all private options recognized
by this package."Afr.type"
and methods setAfrType()
and
getAfrType()
. Update copy_attributes()
function and
check_spct()
methods to support this new attribute. (subject to
changes)cps2Tfr()
and cps2Rfr()
: simplify validity tests and fix
bug in cps2Rfr()
.join_mspct()
to convert a collection of spectra into a
data.frame with multiple columns. This method is mainly intended for
use when exporting spectral data.object_spct
,
filter_spct
, and reflector_spct
objects, and two
raw_mspct`
objects with the corresponding raw detector
counts from the spectrometer.Rename S3 method color()
to color_of()
to avoid a name clash with an
S4 method. A function color()
calling method color_of()
maintains
backwards compatibility, but use of color()
is now deprecated.
Improve performance of sun_angles()
. Convenience functions returning
individual angles, sun_azimuth()
, sun_zenith_angle()
, and
sun_elevation()
, also benefit. Optimize performance of day_night()
.
Other functions returning individual times for sun positions,
sunrise_time()
, noon_time()
, sunset_time()
, day_length()
,
night_length()
, also benefit. Performance optimization does not
alter the returned values.
Revise the documentation corresponding to these functions and the "astronomy" vignette to better describe how vectorization works for these functions.
Laxen range test for cps in check_spct.cps_spct()
, so as to avoid
spurious warnings and/or errors. Make waveband()
with no arguments
valid. Add na.omit()
and na.exclude()
methods for all spectral
classes. Functions na.pass()
and na.fail()
as defined in R work as
expected for spectra.
Add methods isValidIntrDesc()
and isValidInstrSettings()
. Add
methods trimIntrDesc()
and trimInstrSettings()
. Improve handling of
metadata attributes when row-binding spectra with rbindspct()
so that
all metadata can be restored by subset2mspct()
. Revise print methods
so that they are compatible with new format of attributes in row-bound
spectra. Fix bugs in print method for summaries of spectra, and make
output match that of the print method for spectra (some metadata was not
printed). Fix bug in tag.mspct()
method (bad default waveband resulted
in no tagging). Add example data for spectral reflectance. Add test
cases for all new code, and add additional tests cases for old code. Add
example data for white LED bulb as raw_spct
, cps_spct
and
source_spct
objects. Improve documentation.
Add functions sun_elevation()
and sun_azimuth()
. Add convenience
functions trim2overlap()
and extend2extremes()
. Add print()
methods for instr_desc
and instr_settings
classes. Change threshold
for automatic use of hinges when calculating summaries, so that hinges
are used by default in more cases. Allow lists of length zero as
argument to w.band, and treat them as equivalent to NULL
. Make
argument span = NULL
behave in the same way in peak and valley related
summary functions as it has for some time in statistics in package
'ggspectra'. Fix bug in the range check for counts per second which
triggered warnings too easily. Change scaling of D2 and FEL spectra so
that they are expressed in W m-2 nm-1.
Enhancements: Overhaul the astronomy related functions. Non-backward compatible changes in their parameters. Code rewritten using Meeus' astronomical algorithms resulting in better accuracy, much faster calculation of times for solar noon, sunrise and sunset. In addition the new algorithm can be used for a broader range of years, limited only by function julian() in R, which ignores leap seconds. Not fully backward compatible as returned values differ slightly from those in older versions, as long as indexing has been done by name. Add classes "solar_time" and "solar_date", constructor solar_time() and methods is.solar_time(), is.solar_date(), as.solar_date(), format() and print(). Add conversion function as_tod() returning 'time of day' from a datetime object. sun_angles() and day_night() now return a data.frame instead of a list. * The default for twilight argument is no longer "none", but instead "sunlight". The string "none" is accepted, and is as before interpreted as the center of the solar disk at the horizon, without correction for atmospheric diffraction, which is a solar elevation of zero degrees. In contrast, "sunlight" is interpreted as the upper rim of the solar disk at the horizon after approximate correction for atmospheric diffraction, which is a solar elevation of -0.833 degrees, resulting in longer days.
Revise cbindspct() so that it stores the name of "idfactor" as an attribute and set the retrieved value of the attribute as default in subset2mspct(). This makes the conversion from a long form spectral object back into a collection of spectra 'automatic' in many additional use cases.
Fix bugs: normalize() now sets scaled attribute to FALSE. fscale() now sets normalized attribute to FALSE. Allow all summary calculations on re-scaled data, with a warning. Fix bug in operator '*' between reflector.spct and source.spct, which triggered an error.
Fix bug in print.generic_spct().
Argument range.check = NA and range.check = NULL now trigger a message instead of skipping the test altogether. Logical values retain earlier behaviour. Fix bug in set functions for spectral classes: option "photobiology.strict.range" was not obeyed. Revise irrad(), e_irrad() and q_irrad() to accept as input scaled or normalized source_spct objects as long as returned quantity is not "total" or "mean", or its synonym "average". If the returned value will be in relative units linear scaling or normalization will not invalidate the result, so earlier restriction was unnecessarily strict. Fix bug in cps2irrad().
Fix bug in rbindspct() affecting binding of object_spct objects. Fix bug in sunrise_time() and sunset_time() with vector of dates input at polar region latitudes. Fix bug in e_ratio(). Convert User Guide from PDF (Rnw) to HTML (Rmd). Fix some minor mistakes in documentation and build a documentation web site with package 'staticdocs'.
Fix bug: insert_hinges() would fail for "raw_spct" and "cps_spct" objects. Fix bug: leap year for year 2000. Test, improve and document function sun_angles(). Clean code for handling of "range" arguments. Make more consistent handling of "w.band" argument in spectral summary functions such as irrad(): a numeric range is now a valid argument which is converted on-the-fly into a waveband object. Add "guard code" to summary functions triggering errors or warnings when the spct object passed as argument contains data for multiple spectra in long form. Fix bug in stepsize.generic_spct() and improve print() output for spct objects containing data for multiple spectra (in long form) and their summaries. Improve how print() handles large collections of spectra.
Edit to track changes to the behaviour of functions in package 'lubridate' which triggered errors in several use cases of package 'photobiology'.
Optimize R code for performance: high-level functions faster than in version 0.9.4 (last version using Rcpp and C++). Add support for "what.measured" attribute. Allow multiple "countsXXXX" columns in "raw_spct" objects. Allow multiple "cpsXXXX" columns in "cps_spct" objects. Fix bug in getInstrSettings(). Allow small rounding and instrument errors to pass validity checks. Fix bug in setRawSpct(). Implement clean(), normalize(), fscale() and fshift() methods for "generic_spct", "raw_spct" and "cps_spct" objects.
New functions: cps2irrad(), cps2Tfr() and cps2Rfr(). Preliminary versions. Constructors for _spct objects gain a ... formal argument which allows addition of arbitrary columns to the objects created. Reorganize documentation into fewer help files. Fix bug leading to loss of special attributes. Add test cases. Fix bug in "extract" operator [.object_spct. Update for compatibility with dplyr (>= 0.4.3.9001). Update tests for testthat (>= 0.11.0.9000).
Remove buggy C++ code and replace it with R code. Performance cost: 20 to 30% slower in high-level functions.
Prepare for CRAN submission. Rename check() -> check_spct() to avoid name clash with 'devtools'. Fix bug in clean() methods for collections of spectra.
Cosmetic changes.
Change tag.generic_spct() and wb2rect_spct() so that "wb.color" is also added as a column to make it easier to define new ggplot2 stats based on them. Make tagging compatible with raw_spct and cps_spct objects. Change behaviour of w.band = NULL as argument to using a single waveband covering the whole wavelength range of the spectral object, for consistency with other methods. In addition change behaviour so that the same columns are added independently of the value supplied as argument for "w.band", filling the unused columns with NAs when w.band = NA.
Rename some "low level" functions and their formal parameters.
Rename the default methods for midpoint() and stepsize() as methods for numeric and add a new default method that handles unsupported classes more gracefully.
Revise color() method to work correctly in borderline cases. Returned value is always of class character (character() or NA_character_ in some cases). The default for the formal parameter 'type' is now consistently "CMF", instead of in a few cases "both".
Revise interpolate_spct() (interpolate_wl.generic_spct()) to work correctly in borderline cases and to handle gracefully numeric(). Also returned value always has the same class and columns, irrespective of the values of other arguments.
This version removes all two-way dependencies between this package and other packages in the r4photobiology suite. This should make installation of the source distribution a lot easier.
All spectral object constructors return an object with length equal to zero when called without arguments, or with argument "w.length" of length equal to zero. Earlier behaviour was to return NA, which is not consistent with R's usual expectations.
All constructors for collections of spectra return an object with length equal to zero when called without arguments or with a list of length zero as first argument "l". Earlier behaviour was to trigger an error, which is not consistent with R's usual expectations.
Function trim_waveband() was not returning the values described in some cases. Now the function really behaves as originally documented.
Several functions and methods have a 'range' argument, but semantics was not identical in all. Now they all use the same semantics, similar to that used in recent versions of ggplot2 for xlim() and ylim(). Setting a boundary to NA means that the range extends to include all available data on a given 'end'. Whenever it makes sense a NULL range means that the range includes the whole available range of wavelengths. The default value of 'range' for the recently added method 'fshift()' has changed to be the first 10 nm at the short wavelength end of the spectrum.
Function calc_filter_multipliers() has been deleted.
Add example data to make this package's documentation independent of other packages in the suite.
Filters: clear.spct, opaque.spct, polyester.spct, yellow.gel.spct Sensors: photodiode.spct, ccd.spct Objects: black_body.spct, white_body.spct, clear_body.spct
Add method clip_wl() to more easily select data for a range of wavelengths. Add method trim_wl() from trimming, and method interpolate_wl(). All three methods are implemented for individual spectra and for collections of spectra. Methods clip_wl() and trim_wl() have been also implemented for individual waveband objects and for lists of waveband objects.
Add new classes raw_spct and raw_mspct to store raw counts from spectrometers, constructors raw_spct() and raw_mspct(), and corresponding setRawSpct() and is.raw_spct() and as.raw_spct() functions.
Add methods getInstrDesc() and getInstrSettings(), and the corresponding setInstrDesc() and setInstrSettings() to handle metadata about instrument and instrument settings used to acquire the spectral data. These classes and methods are building blocks to be used in the development of spectral-data acquisition packages.
Changes are backwards compatible but new classes were added and several existing methods were implemented for them. Seven new methods were added and implemented for all spectral classes and collections of spectra classes. The new classes are being used for writing a new package intended to replace package MayaCalc.
Add method clean() for removing out-of-range spectral observations. Add method fshift() for shifting the zero of the scale used to express spectral data. Add 'geocode' formal parameter to all functions related to sun angles.
Clean-up code and vignette. Update vignette.
Add support for "when.measured" and "where.measured" attributes in generic_spct objects. Add methods setWhereMeasured(), getWhereMeasured(), setWhenMeasured() and getWhenMeasured(). The first two methods are compatible with the output of ggmap::geocode() and the last two with POSIXct objects as returned by many functions in package lubridate, such as lubridate::now() and lubridate::today(). All these methods are implemented for both generic_spct and generic_mspct classes.
Implement methods to 'get' and 'set' attributes of summary objects of spectra.
Revise print() method for spectra to include the new attributes when available. Rewrite summary() methods and print() method for spectral summaries. Now output parallels the output of the print() method for spectra.
Small edit to msdply() to allow setting of column names. Update to _mspct summary methods to use the names in the list of wavebands, if present, as column names for the returned data frame.
Add function trim_mspct(). Implement normalize(), fscale(), peaks(), valleys(), tag() and untag() methods for generic_mspct and derived classes. Implement dim<- for generic_mspct and derived classes. Fix bugs in msmsply() and mslply(). Implement sign(), round(), signif(), floor(), ceiling() methods for generic_mspct and derived classes. Implement log2(), cos(), sin(), tan(), acos(), asin(), acos(), cospi(), sinpi() and tanpi() methods for generic_mspct and derived classes.
Make internal changes needed for an update to photobiologyInOut. Add option "photobiolgy.strict.range" to allow changing the default behaviour for out-of-range values. (Used internally to avoid redundant checks and repeated warning messages.)
Update package Title in docs. Update User Guide, tables and their formatting.
Many bug fixes, mostly minor. Rename f_mspct() to msdply() to respect name conventions in common use. Add mslply() and msaply(). Implement operators %/% and %%, and function abs() for spectra. Update documentation. Revise titles of help files.
Bug fixes related to imports from other packages. Rename mutate_mspct() to msmsply() to respect name conventions in common use. Add constructor chroma_spct(). Update documentation.
Implement extract and replacement methods for collections of spectra. (Please, let me know if you encounter any errors with these methods, as some testthat tests give infinite recursion errors that I cannot reproduce outside testthat.)
Implement combine method c() for collections of spectra.
Add function convolve_each().
Add helper function shared_member_class().
Expand sun.spct and sun.daily.spct down to 280 nm with zeros.
Add methods for construction of collections of spectra from data frames with different spectra in side-by-side columns ('untidy' or wide data): split2source_mspct(), split2response_mscpt(), split2filter_mspct(), split2reflector_mspct(), and split2cps_mspsct()
Add method for construction of collections of spectra from data frames with spectral data for different spectra in a single column ('tidy' or long data), and spectral objects containing several spectra, such as those returned by function rbindspct(): subset2mspct()
Add print() method for collections of spectra.
Fix minor bug in trim_spct() which was inserting hinges on head and/or tail expansion even if use.hinges was set to FALSE.
Fix bug in rare borderline cases where NA was being returned instead of empty spectral objects (objects with zero rows).
Improve handling of multiple.wl > 1 to avoid spurious warnings. Fix minor bugs in spread().
Fix bugs in trim_spct() and reduce trimming rounding protection in operators for spectra.
tag() and untag() by default use copy semantics. Spectral objects with zero rows are handled cleanly. $<- defined for spectra. Fix bugs.
No longer use data.table as a base class for spectral objects. ** Given the size of spectral data the advantages were too limited compared to the complications introduced. **
Extract and replacement methods "[" and "[<-" and the subset() function should now work as expected when applied to spectral objects! Subscripting of spectra can be used without any restrictions.
Argument passing and assignment semantics follows normal R semantics of passing of making, `lazily', a copy, except in a few exceptions.
Improved accuracy of returned values (from the earlier level of approximately 4 significant digits to close to 7 or 8 significant digits when using hinges) and improved consistency of returned values between functions and operators.
New print method for spectral objects.
Several rather minor bugs and inconsistencies fixed, specially in operators.
Several dependencies and suggests removed. No imports are now visible to users, which should avoid clashes.
** code is not yet optimized for performance **
** Hopefully not many bugs have been introduced **
Fix bug in new code added in 0.7.0. Update rbinspct() to work well with _mspct objects as argument. Add is. and as. functions for all _mspct classes. Add function msmsply() and improve code of function f_mspct() using package plyr. Implement e2q() and q2e() methods for objects of classes source_mspct and response_mspct. Implement T2A() and A2T() methods for objects of class filter_mspct. Implement min(), max(), range(), spread(), midpoint() and stepsize() for objects of class generic_mspct and derived classes. Implement dim() for objects of class generic_mspct and derived classes, which also makes available functions ncol() and nrow() for objects of these classes. Add function rmDerivedMspct(). Change returned value of rmDerivedSpct() into a character vector containing the removed class attributes. Update and reorganize User Guide. Add tests for new code.
Make ratio functions into methods, and add 'wb.trim' as a parameter. Remove 'pc.out' parameter from methods that had it.
Add _mspct classes and summary methods for collections of spectral objects (the 'm' in _mspct comes from 'multi'. The idea for these new classes came from a question from Susan Holmes after my talk at UseR!2015 in Aalborg. She asked whether my package could handle hyperspectral image data. I answer not, but that this feature could be easily added. As with the rest of the package I have now a first design that avoids as much as possible making assumptions about the data, and allows as much extensibility as possible.
Add attribute 'spct.version' to all spectral objects, and function getObjectVersion() to query it.
Changed upgrade() method into upgrade_spct() function, and now it also adds the attribute 'spct.version' during object update.
Add function normalized_diff_ind() usable for calculation of indexes similar to NDVI (normalized difference vegetation index) for reflectance and any other spectral summary quantity and two waveband objects. This was inspired by a poster in Aalborg about package hsdar for analysis of hyperspectral images.
Revise User Guide and Upgrade Guide.
Functions sunrise_time(), noon_time(), sunset_time(), day_length(), night_length() and day_night() gain formal parameter 'unit.out', but its default value preserves earlier behaviour.
New generic functions peaks() and valleys().
subset() methods for spectral objects gain a new parameter 'idx'. During sub-setting, tags are removed from the returned spectrum.
Functions is.photon_based(), is.energy_based(), is.absorbance_based() and is.transmittance_based() have been renamed by replacing the dot with an underscore for consistency with other functions not test for object class.
Fixed bug in trim_waveband().
Fix bug in functions day_length() and night_length() added in 0.6.6. The bug was triggering an error in calculations for polar regions. (Test cases added.)
Package 'lubridate' is no longer imported, so to use functions from this package, users must explicitly load it.
A user reported that day_night() was not vectorized as stated in the documentation. This bug has been fixed, and now day_night() and the new functions noon_time(), sunrise_time(), sunset_time(), day_length() and night_length() are all vectorized for the 'date' parameter. The default 'tz' for all the functions in now "UTC", to match the default time zone used to obtain the default for 'date'. The 't' argument of day_night() has been renamed 'date' for clarity.
These changes, may break old user code! (but needed changes will be minor).
Add support for "twilight" definition as angle in degrees in function day_night(), and different angles for sunrise and sunset.
Fix bug in calc_multipliers() that resulted in NAs in cases where normalization wavelengths fell outside the range of a waveband object but could be anyway computed without errors because the BSWF was defined over a wider range of wavelengths than the waveband itself.
Updated dependency versions.
Add support for lubridate::duration: Parameter "time.unit" in methods and functions related for source_spct and response_spect objects accepts durations.
New function convertTimeUnit() can be used to modify the time.unit attribute, re-expressing the spectral data using the new "time.unit".
Old function setTimeUnit() issues a warning when it is used to override an already set "time.unit" attribute.
Methods irrad(), e_irrad() and q_irrad(), and response(), e_response() and q_response() gain parameter 'time.unit' which can be used to obtain their result expressed on a different time-unit basis.
New methods fluence(), e_fluence() and q_fluence().
Fixed bug in absorptance.filter_spct().
Replaced "." by "_" in the names of the classes returned by summary() methods for spectra.
Fixed long-standing bug in twilight calculation in function day_night(). irrad(), e_irrad(), and q_irrad() modified so that NAs in the spectral data outside the range of waveband(s) do not cause the result to be an NA.
Documentation and User Guide updated.
Added new class cps_spct for uncalibrated spectral data in counts per second. These are not raw instrument counts, but data linerized and re-expressed per unit time in seconds. Maths operators and functions are supported.
Added new accepted value for attribute time.unit: "exposure", meaning the total exposure time, in which case instead of spectral irradiances, the objects store spectral fluence or spectral dose.
Added data for CIE standard A illuminant.
Changed package data files to contain each only one R object.
Updated User Guide adding summary tables for spectral objects and their variables and attributes.
Added User Guide vignette with upgrade instructions.
Added new functions is.old_spct() and upgrade_spectra()
I am reading the new book "R Packages", authored by Hadley Wickham, and I have found several things to improve in the package, especially with naming conventions and documentation. I have earlier followed "common practice" or tried to make names consistent with data.table. As the package has not yet been publicly released, I am taking this last chance I have of getting the naming conventions improved.
Major backwards-incompatible changes to function names to avoid method dispatch problems. All function and class names use underscores. Only S3 methods have dots, and only between method name and class names. Although many names have changed, they should be still easily recognizable to current users.
Added test for non-unique wavelength values during spectral object construction, and added a new formal argument to check() and set...() functions to allow setting the maximum number of copies allowed. Current version only triggers a warning.
Generic function Rescale() has been replaced by methods for the generic function scale() defined in R base, and is_rescaled() has been renamed is_scaled().
IMPORTANT: because the .spct classes have been renamed, objects created with earlier versions of the package are not recognized. They need to be "upgraded" with function upgrade().
Full overhaul of the documentation, using features of latest version of package roxygen2. Documentation for related functions is now on the same file, and most pages are cross- referenced.
Added specialized subset() methods for spectral objects as subset.data.table drops attributes. The new methods are wrappers that copy the attributes used by this package after the subset() operation is done by subscripting, including comment, but still drop any attributes added by users.
Edited check.generic.spct() to generate a warning instead of an error for spectra of length zero, as can be returned by subset when the 'subset' condition is FALSE for all rows.
Fixed bug in rbindspct().
Updated version requirements for all dependencies.
New options "photobiology.use.hinges" (NULL, TRUE, FALSE) with default NULL and "photobiology.auto.hinges.limit" (wavelength step in nm) with new default 0.5 nm. Default behaviour is changed both for a bug in irrad() functions where the limit was 1.1 nm instead of 0.7 nm and as a result of changing to a smaller default value. Existing and new options "photobiology.waveband.trim", "photobiology.use.cached.mult" are now used throughout.
Bug fix: in version 0.5.? the behaviour of the product of a BSWF and a source spectrum was changed to return a response spectrum. This was not consistent with the idea that a BSWF is used for quantifying radiation rather predicting a biological response. The result should remain as radiation and continue to be expressed in energy or photon based units. This has been fixed. Starting from the current version, if the waveband is used with the '*' operator is a BSWF (tested with function is_effective()) the resulting spectrum is tagged as being "effective". The irrad() methods for source.spct have been updated to 'recognize' effective spectral irradiance when supplied as input.
rbindspct() modified so that if at least one of the spectra in the list is of effective irradiance, but not all spectra have been calculated with the same BSWF and normalization, a factor named BSWF is added with the BSWFs retrieved from the spectra used as levels. The optional factor selected through parameter idfactor has now its levels always reflecting the order of the spectra in the input list, even when using a named input list of spectra. Several rather minor bugs were fixed, including improved handling of comments and attributes.
summary() methods for spectra have been updated to report the BSWF that have been used if source spectra contain effective spectral irradiances.
Long-standing unsolved problem partly fixed: interpolate_spct() now in most cases applies smoothing to the spectrum before attempting interpolation if the vector of output wavelengths has length > 1, but is sparser than then original spectral data.
A few inconsistencies in the formal parameters among similar functions were fixed by adding the missing parameters. Also some problems in the documentation for a few functions were fixed.
User guide updated.
Fixed handling of attributes in insert_spct_hinges() and added support for object.spct to this function. Also fixed small bugs here and there in the handling of attributes, to make behaviour more consistent. Added tests to avoid already set attributes to be overwritten by defaults when using set...() and as....() functions on existing .spct objects.
Added warnings to default methods of generic functions to easy the diagnostic of problems.
New functions normalize() and rescale() for spectra. Both functions set object attributes to flag the spectra that have been modified, and no longer are expressed in absolute units. In addition, tests were added to summary functions to disallow use of rescaled or normalized spectral data as input, with the exception of function integrate_spct().
Function rbindspct() was revised to issue a warning when only some of the spectral objects are rescaled or normalized.
Changes in the code for handling 'time.unit', 'Tfr.type' and 'Rfr.type' attributes. Added new functions getTimeUnit(), getTfrType() and getRfrType().
New test cases were added.
New class and methods added: object.spct, with the corresponding as.object.spct(), is.object.spct(), setObjetcSpct(), and check.object.spct() functions. Also functions reflectance() and transmittance() are implemented. New function absorptance() is implemented only for object.spct objects. Objects of this class can be used to store corresponding spectral transmittance and spectral reflectance values. No operators are defined for this class as they would be ambiguous. The class attribute needs to be changed to either filter.spct or reflector.spct before using operators, however, no data is lost in the process, or written except for the class attribute, so the class can be changed back to object.spct if needed.
New function added: merge.generic.spct() is a wrapper on merge.data.table() that sets the correct class to the returned merged spectra, preserves attributes used with .spct objects and by default merges by w.length.
New function smooth_spct() for spectra added. Based on the smoothing code in package MayaCalc and optionally behaving as a wrapper to other smoothers available in R. Implemented for source.spct, filter.spct, reflector.spct and response.spct objects. Its interface may change. Now package caTools is needed.
Operations between .spct objects and numeric vectors, possibly of length one, now preserve other variables (e.g. ID factors) contained in the spectral objects.
Fixed bug in reflectance() function.
Bad input error reporting improved for off-range Tfr and Rfr values in check(). Warning given by T2A() when Tfr = 0 result in A = Inf. Added na.rm = TRUE when min() and max() are called on spectral data.
The formal arguments added to function rbindspct() in version 0.5.7 have been changed to more closely follow the development version 1.9.5 of package data.table. This will break user code that uses the previous syntax as added a few weeks ago to this package.
Fixed bug in handling of 'quantity' arguments "contribution.pc" and "relative.pc" in function absorbance() which was affecting plot annotations.
Changed code of irrad() and set___Spct() functions to be able to
handle locked data.table objects such as .SD when using by within
$$ $$
on spct objects. irrad() copies the spectrum only if needed, and the
sorting key is set to "w.length" only if not already set to this same
value.
Added automatic testing based on package testthat.
Test cases for operators and math functions. Test cases for constructors of spectral objects.
Updated operators' code so that unary '-' and unary '+' now work for spectra.
Rewrote the code for math functions, removing redundancy, and adding support for chroma.spct objects.
Fixed a major bug in binary operators code for non-transitive operations, triggered when the first operand is numeric.
Added a table to the User Guide summarizing the valid and invalid binary operations, and a second table listing unary operators and math functions.
Edited the constructors of spct objects so that they recognize additional variable names for the input data, and rename them.
Added warning messages informing of forbidden operations between dissimilar spectral objects and between spectral objects and wavebands are attempted.
Bug in q2e.response.spct() fixed.
rbindspct() now will add, if requested, a factor 'spct.idx' to the returned spct object, with a different level for each spectrum in the input list. rbindspct() now works as expected even if spectra of the same class contain data stored using different types of quantities, e.g. energy or photon based, or transmittance vs. absorbance. User Guide text was edited. Code formatting in chunks improved.
Added function clear_photobio.cache() and renamed the cache itself to "protect"" it from accidental deletion by making it invisible. Optimized colour calculations for improved speed and debugged the changes. Revised User Guide. Fixed bug that was causing response() not to be exported. Fixed bug in operations between spectra and wavebands and added also a small safety margin to protect from rounding errors. A few minor bugs also fixed. Fixed an important bug causing error in plot(sun.spct * CIE()) (a difficult one to track).
Changed the default for the trimming of wavebands to TRUE, and added a global option so that the default can be changed globally by setting the option: e.g. using options(photobiology.waveband.trim = FALSE)
Also added waveband trimming handling to function tag().
Fixed bug in split_bands() function. Handling of names has changed to some extent, and handling of list objects supplied as x argument is now done by recursion, adding some additional flexibility.
The User Guide was updated to include examples of the use of split_bands().
Added function is_tagged() to easily test if an spectrum has been tagged for plotting. Added function untag() to delete tag data from spectra.
Fixed bug in operators that caused the 'time.unit' attribute not to propagate to returned values. Fixed bug in operations between wavebands and spectra which resulted in the returned spectrum being expanded to the range of the waveband even if the operand spectrum did not overlap this range.
The option "photobiology.base.unit" has been renamed "photobiology.radiation.unit", for consistency with package photobiologygg and for clarity.
Added missing response.spct() function. Fixed two bugs in new_waveband:
Added new function trim_waveband(). Edited irrad(), response(), transmittance(), absorbance(), reflectance(), ratio() functions for spectra to use this function internally, and gaining the wb.trim parameter, which defaults to FALSE. Fixed small numeric errors in the creation of the waveband for the whole spectrum.
The default data in spectral objects has changed in the present and the previous versions. This is to avoid, when possible, conversions when creating spectral objects. Instead, the input is checked in the functions accepting spectral objects as input. However, values are never stored as percentages, only as fractions, as this does not affect later computations, and when a percent is needed the result of the computation is just multiplied by 100.
I added absorbance related functions, similar to the transmittance and reflectance ones: absorbance_spct() and absorbance(). All these functions, as well as those for irradiances and ratios, and responses now return values with the "radiation.unit" attribute set. In addition several edits were done to simplify the code when possible. Irradiance, response, transmittance, reflectance and absorbance functions have gained a new parameter 'quantity', that can take one value out of "total", "contribution" (to total as a fraction), "percent" (contribution as percent), or "average" (the total divided by the 'spread' or width of the waveband in nm). New function response().
Options for operators and functions added: options(photobiology.base.unit = "energy") options(photobiology.base.unit = "photon") These options determine whether operations are carried using energy based or a photon based quantities. This affects operations involving source.spct and response.spct objects when using operators, and the defaults for "unit.out" for functions accepting spectral objects as arguments.
options(photobiology.filter.qty = "transmittance") options(photobiology.filter.qty = "absorbance") determine whether operations are carried using transmittance or absorbance quantities (this affects operations involving filter.spct objects).
The defaults remain the same as in earlier versions, except for irrad() which instead of having no default for "unit.out" now uses the one set by the option, if the option is set. Options can be unset with NULL. options(photobiology.base.unit = NULL) options(photobiology.filter.qty = NULL)
Moved functions find_peaks(), get_peaks() and get_valleys() from photobiologygg to this package.
User Guide thoroughly updated to reflect currently available functionality, including the options described above.
Fixed bug in trim_spct() which led to wrongly copied attribute for filter.spct objects.
The code for the operators has been rewritten almost from scratch. The code for the special functions has been edited. In addition to cleaner and more compact code, now the order of the operators does no longer affect the dispatch of the operators for spectral objects. There are some changes in which combinations of arguments are accepted. The checking is now more strict with respect to what may make sense from the point of view of the physics behind the calculations. Failed checks return NA.
All calls to invisible(), except in the \texttt{set___Spct} functions, have been replaced with return() as the lack of visible output was confusing. It is now documented in the User Guide how to use options() to control the length of the print output.
Generic functions e_response() and q_response() added, and debugged. Changed check() for source.spct and response.spct so that it does not add "energy" or "photon" based spectral data on building objects, as this adds unneeded computation and complicates the logic by changing the data on copy operations (which is surprising and can lead to difficult-to-trace bugs.) This change can be NOT BACKWARDS compatible in some cases of user code, but should be fine for other functions defined in the photobiology packages, as they have been edited to maintain the same visible behaviour.
Fixed a spurious warning by trim_spct() due to minute differences in wavelengths.
Tweaked handling of w.high by new_waveband(). Fixed bug in function waveband() which caused it not to properly create weighted wavebands. Improved handling of names by split_wavebands() and improved the documentation.
Added function is_waveband().
Fixed various small bugs. Removed rbindlist(), for spectra rbindspct() should be used instead.
Added waveband() constructor function. Fixed bug in reflectance_spct() and reflectance() functions. Fixed bug in class_spct(). Revised the user guide to reflect all changes to the code done in the last few versions.
Added the remaining as.xxxx.spct() functions. Added object creation functions source.spct(), filter.spct() and reflector.spct(). Cleaned code to avoid some warnings.
Fixed bug in functions transmittance_spct() and reflectance_spct(), and added aliases transmittance() and reflectance().
New function rmDerivedSpct() now used internally for setting xxx.spct classes consistently by removing derived class attributes when class is set to parent class.
New as.generic.spct() and as.private.spct() functions for spct objects to easy use of operators.
Bug in default arguments to rbindspct() fixed.
Fixed a troublesome bug caused by a couple of missing exports. MayaCalc was broken because of this.
Moved functions D2_spectrum() and FEL_spectrum() to this package from photobiologyLamps
Started new development branch. Added is.xxx.spct() functions for all classes defined and is_any_spct() and class_spct() functions to query class of spectral objects.
Edited wb2xx functions. Added other required variables and set their values to zero, so that the generic.spct objects returned by the waveband to spectra functions can be safely converted to any of the specialized spct spectral objects. This makes then labelling of all types of spectral plots equally easy.
Never released, changes reversed.
The required component of response.spct objects was renamed from 'response' to 's.e.response'. 'response' is also accepted and renamed into 's.e.response'. If 's.q.response' is present it is accepted and maintained. New methods e2q() and q2e() for response.spct class.
Replaced several 'return' statements with 'invisible'. Replaced all remaining data.frame() calls with data.table().
Changed the name of two of the variables added by wb2rect_spct() to more meaningful ones.
Added setGenericSpct() as a synonym for setGenSpct() to keep naming consistent. Added functions wb2tagged_spct() and wb2rect_spct() for creating a tagged generic.spct objects suitable from a list of wavebands.
Updated vignette to use new package photobiologyWavebands. Added a generic function tag() and methods for generic.spct and source.spct objects. tag() can be used to 'tag' the rows based on a list of wavebands, or simply with rgb color equivalents. A color() method for source.spct() was added, which returns the overall colour of the spectrum as a whole. Fixed a 'bug' in tag() that increased execution speed a lot. Added CIE2008 human luminous efficiency function data. Added functions irrad(), q_irrad() and e_irrad() as synonyms for irrad_spct(), q_irrad_spct() and e_irrad_spct(). Added functions irrad(), q_ratio(), e_ratio(), eq_ratio(), and qe_ratio() as synonyms for q_ratio_spct(), e_ratio_spct(), eq_ratio_spct() and qe_ratio_spct(). eq_ratio_spct() is also a new function. Added function split_bands() for creating lists of unweighted wavebands. Several bug fixes, and new function put_hinges(). Added function rbindspct() and redefined rbindlist() (hiding data.table::rbindlist() by exporting photobiology::rbindlist() instead.) Also some changes to color() with new methods for numeric and lists.
Added summary() and corresponding print() methods for spectral objects, and stepsize() default and "generic.spct" methods. Changed SetSourceSpct() to accept a "time.unit" argument, which is used to set an attribute in "source.spct" objects (defaults to "second" making it transparently backwards compatible).
Performance tests show that with default settings the irradiance functions for "source.spct" objects execute significantly faster than the vector based ones. Operators for spectra are at the moment relatively very slow.
Now chromaticity and colour matching function data are as chroma.spct objects. This required also edits to many of the colour related functions. Added CMF for honeybees and example daily solar spectral data. Edited irrad_spct() so that results always include waveband names.
Added new class response.spct and revised the operators' definitions.
The set...Spct() functions until 0.3.5 had different semantics than setDT in data.table. This has now been fixed. Data for CIE D65 illuminant has been added. The imports and re-exports from data.table now include additional functions including some new to data.table 1.9.3. Added new class chroma.spct for storing x y z chromaticy data and the corresponding functions setChromaSpct and operators * and /.
Fixed "bug"" in trim_spct(), which was returning data.table objects instead of objects of the same type as supplied as argument. A bug in version 1.9.2 of data.table was behind some other problems, so added requirement for data.table 1.9.3+ to DESCRIPTION.
Added a class for reflectance spectra and updated operator definitions. Added function setReflectorSpct(). New functions interpolate_spct(), reflectance_spct(), transmittance_spct(), q_ratio_spct(), e_ratio_spct(), qe_ratio_spct(), rgb_spct() and check(), check.generic.spct(), check.filter.spct(), check.reflector.spct(), and check.source.spct(). Operator *.generic.spct now accepts wavebands as second argument. Debugged min(), max(), range(), midpoint(), spread(), labels() for spectra. Updated setGenericSpct(), setFilterSpct() and setSourceSpct() to use check() to check and fix if possible missing variable, or add the missing variables as a vector of NAs.
Updated the vignette with examples of the use of spct objects and the functions and operators defined for them. Modified packages so as to consistently use .spct as the name tag of all objects representing spectra. Recently .dt was used and earlier, .data, that is still a fall-back in the current version.
TODO: make sure all spct functions and operators work correctly when the argument spct objects are incomplete.
New functions insert_spct_hinges(), trim_spct(), integrate_spct(), average_spct(), irrad_spct(), e_irrad_spct(), q_irrad_scpt(), transmittance_spct(), reflectance_spct(), ... , is_effective.waveband(), Small edits to new_waveband() Example solar spectrum data now available as "source.spct" objects and as "data.table" and "data.frame" so as not to break any old code.
Function day_night had bugs, now fixed.
Added functions sun_angles and day_night.
MAJOR UPDATE
There are some backward incompatibilities
Saved wavebands will give an error, but any code used to create them should still work unchanged.
If you used the parameter use.cpp.code in your code, you will just need to delete the corresponding arguments. C++ code is always used.
I hope I haven't broken anything else but I have made quite major internal changes.
At the moment the code is a bit slower than before. I will most likely be able to cure this at a later stage.
The package now depends on data.table which is now imported. As MayaCalc already returns data.table objects, hopefully this will help optimize performance and memory use. Users should be aware that data.tables are copied by reference, and a true copy is needed, function copy should be used.
I am making the code more object (S3) oriented. Three new classes are exported "filter.spct", "source.spct", and "generic.spct", and three new functions were added to set the class of objects to these classes. If the object is not already a data.table, it is setDT. This allows me to create a more user-friendly interface by overloading operators. Now the four basic operations work on spectra, and one can also use these same operations and ^between a spectrum a numerical vector of length one or longer. Many maths functions and some summary functions have specialized versions for spectra. This is my attempt to make calculations intuitive, but do not expect them to be fast.
Added generic functions A2T and T2A for converting absorbance to transmittance and back. The generic function takes a numerical argument, and there are special versions for spectra. When the argument is a "filter.spc" object they return a copy of the original object with the calculated quantity added. If the requested output already exists, it is NOT recalculated, just a copy of the argument is returned, if the input data is missing, the corresponding output is set to NA.
Added a label field to waveband object to store an optional label for plotting, which by default is set equal to the name of the waveband. labels.waveband was changed to return in field label this label instead of the name, and the name is returned in the field name. Also added a new function normalization.waveband that returns the normalization wavelength.
calc_filter_multipliers now accepts both a filter name as a character string or an object of class "filter.spct" as argument to parameter filter (which was renamed from filter.name). In addition the function acquired a pc.in logical parameter, an the pc parameter was renamed pc.out. This allows any combination of input and output as percentages or fractions.
Modified calc_filter_multipliers to work with photobiologyFilters 0.1.8 and later Both calc_filter_multipliers and calc_source_multipliers now find by name both objects with ending .dt and .data. If both exist .dt is used.
Added functions oper_spectra, prod_spectra, div_spectra, and subt_spectra, and redefined sum_spectra based on oper_spectra. Behaviour of sum_spectra has not changed.
Removed center_wl center_wl.generic and center_wl.waveband Added spread spread.generic and spread.waveband Added midpoint midpoint.generic and midpoint.waveband
Moved from photobiologyLamps and renamed function calc_lamp_output() to calc_source_output(). Moved from photobiologyLamps calc_filter_multipliers(). Added two examples of how to draw Maxwell's triangles.
Fixed a bug in s.e.irrad2rgb() caused by not explicitly handling the case when the wavelength range was completely outside outside the range of the the CMF or CC data. In other words the function crashed when the colour of invisible radiation was requested. Now "black" is returned in this case.
New function w_length_range2rgb(), which takes a range of wavelengths, and returns the equivalent RGB colour assuming equal spectral (energy) irradiance at all wave lengths within the range. Modified the calculation of color for wavebands, using this new function.
Added waveband versions of generic functions, min(), max(), range() and labels(). Updated trim_tails() so that it can also expand a spectrum. New functions: w_length2rgb() to calculate RGB colour definitions for monochromatic light. s.e.irrad2rgb() to calculate RGB colour definition from spectral irradiance data or reflectance data. Data on x, y, z coordinates for CIE chromaticity coordinates and colour matching functions added.
Fixed a bug in split_irradiance() and improved handling of cut point values outside the data range, unsorted cut-points, and redundant cut-points. For 'good' data there are no changes in output, except in the case when three cut points were supplied, as the third one was being ignored. The handling of out-of-range cut points has been changed so that the endpoints are moved to the extreme wavelengths of the data.
The cache is now created in the "emptyenv". This solves a long-standing error message during installation.
Changed irradiance() so that it optionally accepts a list of wave_bands and returns a vector or irradiances. The returned values have a names attribute set to the names of the elements in the wave_band list. If the names are missing, it returns the "name"s stored in the wave_band objects.
wave_band objects are now S3 objects with class "waveband", a print.waveband() function was added, which is called whenever the generic print function is called on a "waveband" object.
New convenience functions split_irradiance(), split_energy_irradiance() and split_photon_irradiance() for integrating unweighted irradiances for a series of contiguous wavelength ranges.
Updated NAMESPACE to fix error caused by changes in Rcpp or R.
Updated User Guide. Modified interpolate_spectrum so that it uses cubic spline interpolation when the number of data points is small, and linear interpolation otherwise.
Moved peaks-related functions to new package photobiologygg and removed dependence on splus2R.
Added new functions find_peaks and get_peaks, which are wrappers built on top of function peaks from package splus2R, which becomes a new dependency.
Added Rcpp version of insert_hinges() using the much faster binary search algorithm.
Small, backward compatible change to trim_tails: added fill parameter. If NULL (default) the function works as earlier deleting the tails. If another value is passed as fill, the s.irrad values in the tails are replaced with this value.
Added two new functions: interpolate_spectrum() and sum_spectra()
The vignette "Examples" was moved to a separate package because it used a very large data set. An "benign"" error in new_waveband() was fixed (this has no effect on calculations). The data set sun.data was updated to contain instantaneous data, and its documentation updated to better describe the data.
A vignette "Examples" was added. Other examples will be added later on. No changes to R or C++ code.
A vignette "Manual" was added. No changes to R or C++ code.
As profiling showed that calls to insert_hinges() and within this function to which() were using most of run time of the functions, a new parameter was added to functions so that the use of hinges can be switched on and off. The default is to use hinges for interpolation only if the wavelength resolution of the spectrum is worse than 1.0 nm. This causes only small errors in the results of calculations (< 1%) but reduces run time very significantly. The defaults should work just fine in most cases, in which case there is no need to do any changes to user code. In addition new_waveband() was modified so that if no SWF is used, then hinges are not included in the waveband defined.
Revised photon_ratio() to use same optimizations.
Improved implementation of cache. Now it is enclosed in an environment that is created when the package is loaded and removed when it is unloaded.
Factored to a separate function the code to check spectral data, and added argument to irradiance to switch off the checking.
Added a "name" field to wavebands and a wb.name argument to new_waveband(), with a default so that no old code will be broken.
Added argument to calc_multipliers() to enable caching. Disabled by default.
Added argument to irradiance() to enable/disable checking of spectral data. Enabled by default.
Added argument to irradiance() to enable use of speed optimizations.
Defaults to arguments ensure that nothing changes from earlier versions unless new features are explicitly enabled.
Reimplemented irradiance(), calc_multipliers, e2qmol_multipliers(), and added e2quantum_multipliers(). Also reimplemented new_waveband(), changing its interface. Some changes in other photobiologyxxxx will be needed.