User Guide"

knitr::opts_chunk$set(fig.width=8, fig.height=4)


This package, is a data only package, part of a suite, which has package 'photobiology' at its core. Please visit ( for more details. For information on plotting spectra, please consult the documentation for package 'ggspectra', and for information on the calculation of summaries and maths operations between spectra, please, consult the documentation for package 'photobiology'.


One collection of spectra, sun_reference.mspct, contains published reference solar spectra used in model simulations and for calculations. Another collection, gap.mspct contains a rapid sequence of spectra measured in a forest gap. Another two time series of simulated hourly spectra sun_hourly_june.spct and sun_hourly_august.spct, are each in the format of a single spectral object. Other measured spectra is inlcuded, as well as energy- and photon-irradiance time series from broadband sensors.

Accessing individual spectra

The source_spct member objects in sun_reference.mspct and gap.mspct can be accessed through their names or through a numeric index. As the numeric indexes are likely to change with updates to the package, their use is discouraged. Names as character strings should be used instead. They can also be retrieved with method names().


We can use a character string as index to extract an individual source_spct object.


Be aware that according to R's rules, using single square brackets will return a source_mspct object possibly of length one. This statement is not equivalent to the one in the chunk immediately above.


Accessing subsets of spectra

We can subset sensors.mspct object by indexing with vectors of character strings. More generally one can search for matching names within the collection of spectra.

sun_reference.mspct[grep("AM0", names(sun_reference.mspct), = TRUE)]

Plotting the spectra

Using autoplot() methods for spectra defined in package 'ggspectra' annotated plotting is automatic. The defaults can be easily changed, please see the documentation in package 'ggspectra'.


Using the ggplot() method for spectra from package 'ggspectra' plus geometries and statistics from package 'ggplot2' we gain additional control on the design.

ggplot(gap.mspct$spct.1, unit.out = "photon") +
  geom_line(linetype = "dashed")

In the case of spectral objects containing a time series of spectra, the index variable UTC containing time and date in universal time coordinates ("UTC") can be used to select and/or highlight individual spectra.

              UTC %in% 
                ymd_hms(c("2014-08-21 06:30:00",
                          "2014-08-21 09:30:00",
                          "2014-08-21 12:30:00"))),
       unit.out = "photon") +
       aes(linetype = factor(UTC)) +
  labs(linetype = "Day and time (UTC)")

Using the data in other contexts

As source_spct is a class derived from list, and source_spct is derived from tibble::tible which is a compatible reimplementation of data.frame the data can be used very easily with any R function.


Of course attach and with also work as expected.

q_response(spct.1, Red())
with(spct.1, max(w.length))
with(gap.mspct, q_response(spct.1, Red()))

Try the photobiologySun package in your browser

Any scripts or data that you put into this service are public.

photobiologySun documentation built on May 2, 2019, 8:51 a.m.