Learn R Programming

⚠️There's a newer version (0.12.0) of this package.Take me there.

photobiology

Package ‘photobiology’ defines a system of classes for storing spectral data and accompanying metadata. For each of these classes specialised summary methods, maths operators and functions are provided. In addition, classes for storing collections of objects of the classes for individual spectra are defined as well as ‘apply’ functions. Extraction and replacement operators are also implemented. Functions for calculation of the position of the sun, times of sunrise and sunset, day length and night length are also provided.

The package supports storage and manipulation of data for radiation quantities and for optical properties of objects.

This package is the core of a suite of R packages for photobiological calculations described at the r4photobiology web site.

Examples

The first example shows you how to estimate solar irradiance in W/m2 under a filter. We use a measured solar spectrum and a measured filter transmission spectrum.

library(photobiology)
e_irrad(sun.spct * yellow_gel.spct)
#>  E_Total 
#> 146.5044 
#> attr(,"time.unit")
#> [1] "second"
#> attr(,"radiation.unit")
#> [1] "total energy irradiance"

The second example shows some simple astronomical calculations for the sun.

geocode <- data.frame(lon = 0, lat = 55)
date <- lubridate::today(tzone = "UTC")
sunrise_time(date, tz = "UTC", geocode = geocode)
#> [1] "2021-07-28 04:02:37 UTC"
day_length(date, tz = "UTC", geocode = geocode)
#> [1] 16.12984

Installation

Installation of the most recent stable version from CRAN:

install.packages("photobiology")

Once package ‘photobiology’ is installed, installation of the remaining or missing packages in the suite from CRAN:

intalled_pkgs <- installed.packages()[ , 1]
missing_pkgs <- setdiff(photobiology::r4p_pkgs, intalled_pkgs)
if (length(missing_pkgs) > 0) {
 install.packages(missing_pkgs)
}

Installation of the current unstable version from GitHub:

# install.packages("devtools")
devtools::install_github("aphalo/photobiology")

Documentation

HTML documentation is available at (https://docs.r4photobiology.info/photobiology/), including three User Guides.

News on updates to the different packages of the ‘r4photobiology’ suite are regularly posted at (https://www.r4photobiology.info/).

Two articles introduce the basic ideas behind the design of the suite and describe its use: Aphalo P. J. (2015) (https://doi.org/10.19232/uv4pb.2015.1.14) and Aphalo P. J. (2016) (https://doi.org/10.19232/uv4pb.2016.1.15).

A book is under preparation, and the draft is currently available at (https://leanpub.com/r4photobiology/).

A handbook written before the suite was developed contains useful information on the quantification and manipulation of ultraviolet and visible radiation: Aphalo, P. J., Albert, A., Björn, L. O., McLeod, A. R., Robson, T. M., & Rosenqvist, E. (Eds.) (2012) Beyond the Visible: A handbook of best practice in plant UV photobiology (1st ed., p. xxx + 174). Helsinki: University of Helsinki, Department of Biosciences, Division of Plant Biology. ISBN 978-952-10-8363-1 (PDF), 978-952-10-8362-4 (paperback). PDF file available from (https://hdl.handle.net/10138/37558).

Contributing

Pull requests, bug reports, and feature requests are welcome at (https://github.com/aphalo/photobiology).

Citation

If you use this package to produce scientific or commercial publications, please cite according to:

citation("photobiology")
#> 
#> To cite package 'photobiology' in publications, please use:
#> 
#>   Aphalo, Pedro J. (2015) The r4photobiology suite. UV4Plants Bulletin,
#>   2015:1, 21-29. DOI:10.19232/uv4pb.2015.1.14
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Article{,
#>     author = {Pedro J. Aphalo},
#>     title = {The r4photobiology suite},
#>     journal = {UV4Plants Bulletin},
#>     volume = {2015},
#>     number = {1},
#>     pages = {21-29},
#>     year = {2015},
#>     doi = {10.19232/uv4pb.2015.1.14},
#>   }

License

© 2012-2021 Pedro J. Aphalo (pedro.aphalo@helsinki.fi). Released under the GPL, version 2 or greater. This software carries no warranty of any kind.

Copy Link

Version

Install

install.packages('photobiology')

Monthly Downloads

649

Version

0.10.7

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Pedro Aphalo

Last Published

September 29th, 2021

Functions in photobiology (0.10.7)

ET_ref

Evapotranspiration
D2_spectrum

Calculate deuterium lamp output spectrum from fitted constants
Afr2T

Convert transmittance into absorptance.
D2.UV586

Data for typical calibration lamps
A2T

Convert absorbance into transmittance
A.illuminant.spct

CIE A illuminant data
D2.UV654

Data for typical calibration lamps
D2.UV653

Data for typical calibration lamps
FEL.BN.9101.165

Data for typical calibration lamps
D65.illuminant.spct

CIE D65 illuminant data
MathFun

Miscellaneous Mathematical Functions
Ler_leaf_rflt.spct

Green Arabidopsis leaf spectral reflectance.
Ler_leaf_trns_i.spct

Green Arabidopsis leaf spectral transmittance.
FEL_spectrum

Incandescent "FEL" lamp emission spectrum
T2A

Convert transmittance into absorbance.
as.chroma_mspct

Coerce to a collection-of-spectra
Rfr_from_n

Reflectance at a planar boundary
as.calibration_spct

Coerce to a spectrum
any2T

Convert filter quantities.
as.calibration_mspct

Coerce to a collection-of-spectra
Ler_leaf_trns.spct

Green Arabidopsis leaf spectral transmittance.
as.cps_spct

Coerce to a spectrum
as.filter_mspct

Coerce to a collection-of-spectra
as.object_spct

Coerce to a spectrum
as.object_mspct

Coerce to a collection-of-spectra
as.filter_spct

Coerce to a spectrum
adaptive_smoothing

Custom smoothing
add_attr2tb

Copy attributes from members of a generic_mspct
T2Afr

Convert transmittance into absorptance.
Trig

Trigonometric Functions
Ler_leaf.spct

Green Arabidopsis leaf reflectance and transmittance.
as.generic_spct

Coerce to a spectrum
as.generic_mspct

Coerce to a collection-of-spectra
absorptance

Absorptance
as.matrix-mspct

Coerce a collection of spectra into a matrix
as.raw_mspct

Coerce to a collection-of-spectra
as.raw_spct

Coerce to a spectrum
as.chroma_spct

Coerce to a spectrum
as.cps_mspct

Coerce to a collection-of-spectra
absorbance

Absorbance
absorbance_spct

Calculate absorbance from spectral absorbance.
as_quantum_mol

Convert spectral energy irradiance into spectral photon irradiance
as_quantum

Convert spectral energy irradiance into spectral photon irradiance
as.solar_date

Convert a solar_time object into solar_date object
as.reflector_mspct

Coerce to a collection-of-spectra
calc_multipliers

Spectral weights
as.source_mspct

Coerce to a collection-of-spectra
calc_source_output

Scaled and/or interpolated light-source spectral output
class_spct

Query which is the class of a spectrum
cps2irrad

Conversion from counts per second to physical quantities
ciev10.spct

Linear energy CIE 2008 luminous efficiency function 10 deg data
copy_attributes

Copy attributes
check_w.length

Sanity check of wavelengths (internal function).
as.response_mspct

Coerce to a collection-of-spectra
as.reflector_spct

Coerce to a spectrum
ciexyzCMF2.spct

Linear energy CIE xyz colour matching function (CMF) 2 deg data
clear.spct

Theoretical spectrum of a clear material
checkSpctVersion

Check that the "spct.version" attribute is set
average_spct

Average spectral data.
convertTimeUnit

Convert the "time.unit" attribute of an existing source_spct object
clear_photobio.cache

Clear the spectral weights cache
day_night

Times for sun positions
convolve_each

Convolve function for collections of spectra
clip_wl

Clip head and/or tail of a spectrum
ciev2.spct

Linear energy CIE 2008 luminous efficiency function 2 deg data
ciexyzCC10.spct

CIE xyz chromaticity coordinates (CC) 10 deg data
absorptance_spct

Calculate absorptance from spectral absorptance.
div_spectra

Divide two spectra, even if the wavelengths values differ
as.response_spct

Coerce to a spectrum
beesxyzCMF.spct

Honeybee xyz chromaticity colour matching function data
as_tod

Convert datetime to time-of-day
eq_ratio

Energy:photon ratio
energy_ratio

Energy:energy ratio
defunct

Defunct functions and methods
find_peaks

Find peaks in a spectrum
find_spikes

Find spikes
clear_body.spct

Theoretical clear body
convertTfrType

Convert the "Tfr.type" attribute
convertThickness

Convert the "thickness" attribute of an existing filter_spct object.
dim.generic_mspct

Dimensions of an Object
div-.generic_spct

Arithmetic Operators
drop_user_cols

Drop user columns
auto_hinges

Guess whether insertion of hinges is needed or not
ccd.spct

Spectral response of a back-thinned CCD image sensor.
checkMspctVersion

Check that the "mspct.version" attribute is set
e_ratio

Energy:energy ratio
f_dispatcher_spct

Math function dispatcher for spectra
generic_mspct

Collection-of-spectra constructor
Extract_mspct

Extract or replace members of a collection of spectra
e_irrad

Energy irradiance
as.source_spct

Coerce to a spectrum
fit_peaks

Refine position and value of extremes by fitting
find_wls

Find wavelength values in a spectrum
as_energy

Convert spectral photon irradiance into spectral energy irradiance
black_body.spct

Theoretical black body
getMultipleWl

Get the "multiple.wl" attribute
fshift

Shift the scale of a spectrum using a summary function
c

Combine collections of spectra
check_spectrum

Sanity check a spectrum
check_spct

Check validity of spectral objects
getRfrType

Get the "Rfr.type" attribute
integrate_spct

Integrate spectral data.
getResponseType

Get the "response.type" attribute
getScaled

Get the "scaled" attribute
getSpctVersion

Get the "spct.version" attribute
fshift_spct

fshift a spectrum
insert_spct_hinges

Insert new wavelength values into a spectrum
checkTimeUnit

Check the "time.unit" attribute of an existing source_spct object
ciexyzCC2.spct

CIE xyz chromaticity coordinates 2 deg data
getNormalized

Get the "normalized" attribute
clean

Clean (=replace) off-range values in a spectrum
l_insert_hinges

Insert wavelength values into spectral data.
na.omit

Handle Missing Values in Objects
is.old_spct

Query if an object has old class names
normalize

Normalize spectral data
is.generic_spct

Query class of spectrum objects
mspct_classes

Names of multi-spectra classes
insert_hinges

Insert wavelength values into spectral data.
head_tail

Return the First and Last Part of an Object
calendar_change

Solar astronomy using Meeus' algorithm
clean_spct

Clean a spectrum
isValidInstrSettings

Check the "instr.settings" attribute
getIdFactor

Get the "idfactor" attribute
getInstrDesc

Get the "instr.desc" attribute
getBSWFUsed

Get the "bswf.used" attribute
wl_min

Wavelength minimum
log

Logarithms and Exponentials
labels

Find labels from "waveband" object
is_absorbance_based

Query if a spectrum contains absorbance or transmittance data
getTfrType

Get the "Tfr.type" attribute
normalize_range_arg

Normalize a range argument into a true numeric range
ciexyzCMF10.spct

Linear energy CIE xyz colour matching function (CMF) 10 deg data
print.summary_generic_spct

Print spectral summary
despike

Remove spikes from spectrum
getTimeUnit

Get the "time.unit" attribute of an existing source_spct object
energy_as_default

Set spectral-data options
format.tod_time

Encode in a Common Format
diffraction_single_slit

Diffraction
energy_irradiance

Calculate (energy) irradiance from spectral irradiance
getMspctVersion

Get the "mspct.version" attribute
formatted_range

Compute range and format it
getInstrSettings

Get the "instr.settings" attribute
e2quantum_multipliers

Calculate energy to quantum multipliers
compare_spct

Coarse-grained comparison of two spectra
cone_fundamentals10.spct

Ten-degree cone fundaamentals
getWhatMeasured

Get the "what.measured" attribute
reflectance_spct

Calculate reflectance from spectral reflectance
minus-.generic_spct

Arithmetic Operators
irrad

Irradiance
e_fluence

Energy fluence
color_of

Color of an object
e2qmol_multipliers

Calculate energy to quantum (mol) multipliers
collect2mspct

Form a new collection
e2q

Convert energy-based quantities into photon-based quantities.
fscale

Rescale a spectrum using a summary function
filter_cps.mspct

Counts per second from a measurement of a plastic film
e_response

Energy-based photo-response
findMultipleWl

Find repeated w.length values
enable_check_spct

Enable or disable checks
print.tod_time

Print time-of-day objects
spread

Expanse
setRfrType

Set the "Rfr.type" attribute
setScaled

Set the "scaled" attribute
relative_AM

Relative Air Mass (AM)
getWhenMeasured

Get the "when.measured" attribute
get_peaks

Get peaks and valleys in a spectrum
fluence

Fluence
Extract

Extract or replace parts of a spectrum
format.solar_time

Encode in a Common Format
green_leaf.spct

Green birch leaf reflectance.
is_photon_based

Query if a spectrum contains photon- or energy-based data.
is.waveband

Query if it is a waveband
isValidInstrDesc

Check the "instr.desc" attribute
fscale_spct

fscale a spectrum
r4p_pkgs

Packages in R for Photobiology suite
interpolate_spectrum

Calculate spectral values at a different set of wavelengths
getHowMeasured

Get the "how.measured" attribute
getFilterProperties

Get the "filter.properties" attribute
split2mspct

Convert a 'wide' or untidy data frame into a collection of spectra
wl_range

Wavelength range
wl_max

Wavelength maximum
merge2object_spct

Merge into object_spct
irrad_extraterrestrial

Extraterrestrial irradiance
mod-.generic_spct

Arithmetic Operators
is_scaled

Query whether a generic spectrum has been scaled
interpolate_wl

Map spectra to new wavelength values.
irradiance

Photon or energy irradiance from spectral energy or photon irradiance.
print.waveband

Print a "waveband" object
plus-.generic_spct

Arithmetic Operators
photons_energy_ratio

Photon:energy ratio
join_mspct

Join all spectra in a collection
photodiode.spct

Spectral response of a GaAsP photodiode
is_tagged

Query if a spectrum is tagged
photobiology-package

photobiology: Photobiological Calculations
is.generic_mspct

Query class of spectrum objects
rmDerivedMspct

Remove "generic_mspct" and derived class attributes.
prod_spectra

Multiply two spectra, even if the wavelengths values differ
setNormalized

Set the "normalized" attribute
s_mean_se

Mean and standard error from collection of spectra
setWhereMeasured

Set the "where.measured" attribute
setIdFactor

Set the "idfactor" attribute
setInstrDesc

Set the "instr.desc" attribute
rmDerivedSpct

Remove "generic_spct" and derived class attributes.
setResponseType

Set the "response.type" attribute
s_median

Median of a collection of spectra
msmsply

Multi-spct transform methods
shared_member_class

Classes common to all collection members.
replace_bad_pixs

Replace bad pixels in a spectrum
is_normalized

Query whether a generic spectrum has been normalized.
get_attributes

Get the metadata attributes
is.summary_generic_spct

Query class of spectrum summary objects
interpolate_spct

Map a spectrum to new wavelength values.
is.solar_time

Query class
getWhereMeasured

Get the "where.measured" attribute
is_effective

Is an R object "effective"
integrate_xy

Gives irradiance from spectral irradiance.
merge_attributes

Merge and copy attributes
oper_spectra

Binary operation on two spectra, even if the wavelengths values differ
split_bands

List-of-wavebands constructor
s_prod

Product from collection of spectra
setTfrType

Set the "Tfr.type" attribute
setGenericSpct

Convert an R object into a spectrum object.
sign

Sign
s_range

Range of a collection of spectra
resp_spct

Calculate response from spectral response
setTimeUnit

Set the "time.unit" attribute of an existing source_spct object
setHowMeasured

Set the "how.measured" attribute
split_photon_irradiance

Photon irradiance for split spectrum regions
sinc

sinc
normalized_diff_ind

Calculate a normalized index.
sum_spectra

Add two spectra
subt_spectra

Subtract two spectra
wl_stepsize

Stepsize
times-.generic_spct

Arithmetic Operators
using_Tfr

Use photobiology options
thin_wl

Thin the density of wavelength values
v_insert_hinges

Insert spectral data values at new wavelength values.
print.solar_time

Print solar time and solar date objects
print

Print a spectral object
peaks

Peaks or local maxima
sun_angles

Solar angles
q2e

Convert photon-based quantities into energy-based quantities
net_irradiance

Net radiation flux
s_sd

Standard Deviation of a collection of spectra
polyester.spct

Transmittance spectrum of clear polyester film
^.generic_spct

Arithmetic Operators
wl_midpoint

Midpoint
normalization

Normalization of an R object
q_fluence

Photon fluence
tag

Tag a spectrum
spct_metadata

Access metadata
valleys

Valleys or local minima
opaque.spct

Theoretical spectrum of an opaque material
verbose_as_default

Set error reporting options
white_led.cps_spct

White led bulb spectrum
white_led.raw_spct

White led bulb spectrum
reflectance

Reflectance
q_ratio

Photon:photon ratio
rowwise

rowwise functions for collections of spectra
rbindspct

Row-bind spectra
round

Rounding of Numbers
q_irrad

Photon irradiance
spikes

Spikes
photon_ratio

Photo:photon ratio
setBSWFUsed

Set the "bswf.used" attribute
photon_irradiance

Photon irradiance
summary

Summary of a spectral object
setWhatMeasured

Set the "what.measured" attribute
setFilterProperties

Set the "filter.properties" attribute
setWhenMeasured

Set the "when.measured" attribute
slash-.generic_spct

Arithmetic Operators
setMultipleWl

Set the "multiple.wl" attribute
s_se

Standard Error of a collection of spectra
select_spct_attributes

Merge user supplied attribute names with default ones
se

Standard error of the mean
setInstrSettings

Set the "instr.settings" attribute
spct_attr2tb

Copy attributes into a tibble
spct_classes

Function that returns a vector containing the names of spectra classes.
split_energy_irradiance

Energy irradiance for split spectrum regions
split_irradiance

Energy or photon irradiance for split spectrum regions
smooth_spct

Smooth a spectrum
response

Integrated response
rgb_spct

RGB color values
qe_ratio

Photon:energy ratio
q_response

Photon-based photo-response
s_e_irrad2rgb

Spectral irradiance to rgb color conversion
sun.daily.data

Daily solar spectral irradiance (simulated)
summary_spct_classes

Function that returns a vector containing the names of spectral summary classes.
sun.daily.spct

Daily solar spectral irradiance (simulated)
subset2mspct

Convert 'long' or tidy spectral data into a collection of spectra
Subset

Subsetting spectra
sun.spct

Solar spectral irradiance (simulated)
sun.data

Solar spectral irradiance (simulated)
s_sum

Sum from collection of spectra
solar_time

Local solar time
s_var

Variance of a collection of spectra
source_spct

Spectral-object constructor
s_mean

Mean from collection of spectra
trim_spct

Trim (or expand) head and/or tail of a spectrum
trim_wl

Trim head and/or tail of a spectrum
trim_waveband

Trim (or expand) head and/or tail
trimInstrDesc

Trim the "instr.desc" attribute
v_replace_hinges

Overwrite spectral data values at existing wavelength values.
trimInstrSettings

Trim the "instr.settings" attribute
trim_tails

Trim (or expand) head and/or tail
waveband

Waveband constructor method
water_vp_sat

Water vapour pressure
validate_geocode

Validate a geocode
tz_time_diff

Time difference between two time zones
twilight2angle

twilight argument check and conversion
w_length_range2rgb

Wavelength range to rgb color conversion
w_length2rgb

Wavelength to rgb color conversion
wb_trim_as_default

Set computation options
white_body.spct

Theoretical white body
upgrade_spct

Upgrade one spectral object
transmittance

Transmittance
upgrade_spectra

Upgrade one or more spectral objects
transmittance_spct

Calculate transmittance from spectral transmittance.
wb2spct

Create spectrum from wavebands
uncollect2spct

Extract all members from a collection
untag

Remove tags
waveband_ratio

Photon or energy ratio
yellow_gel.spct

Transmittance spectrum of yellow theatrical gel.
wb2rect_spct

Create tagged spectrum from wavebands
wb2tagged_spct

Create tagged spectrum from wavebands
wls_at_target

Find wavelengths values corresponding to a target spectral value
white_led.source_spct

White led bulb spectrum