Learn R Programming

⚠️There's a newer version (0.13.1) 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.

Example

This first basic example shows you how to calculate solar irradiance in W/m2 below a filter. We use a measured solar spectrum and a measured filter transmission spectrum.

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

The second basic 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] "2018-06-12 03:21:02 UTC"
day_length(date, tz = "UTC", geocode = geocode)
#> [1] 17.29626

Installation

Installation of the most recent stable version from CRAN:

install.packages("photobiology")

Installation of the current unstable version from Bitbucket:

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

Documentation

HTML documentation is available at (http://docs.r4photobiology.info/photobiology/), including a User Guide.

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

Two articles introduce the basic ideas behind the design of the suite and 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 (http://hdl.handle.net/10138/37558).

Contributing

Pull requests, bug reports, and feature requests are welcome at (http://bitbucket.org/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-2018 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

450

Version

0.9.21

License

GPL (>= 2)

Maintainer

Pedro Aphalo

Last Published

June 28th, 2018

Functions in photobiology (0.9.21)

D2.UV653

Data for typical calibration lamps
FEL_spectrum

Incandescent "FEL" lamp emission spectrum
absorbance

Absorbance
absorptance

Absorptance
Ler_leaf.spct

Green Arabidopsis leaf reflectance and transmittance.
absorbance_spct

Calculate absorbance from spectral absorbance.
T2Afr

Convert transmittance into absorptance.
D2.UV654

Data for typical calibration lamps
D2_spectrum

Calculate deuterium lamp output spectrum from fitted constants
as.filter_spct

Coerce to a spectrum
as.generic_mspct

Coerce to a collection-of-spectra
as.solar_date

Convert a solar_time object into solar_date object
Ler_leaf_rflt.spct

Green Arabidopsis leaf spectral reflectance.
as.source_mspct

Coerce to a collection-of-spectra
average_spct

Average spectral data.
Ler_leaf_trns.spct

Green Arabidopsis leaf spectral transmittance.
beesxyzCMF.spct

Honeybee xyz chromaticity colour matching function data
absorptance_spct

Calculate absorptance from spectral absorptance.
ciev2.spct

Linear energy CIE 2008 luminous efficiency function 2 deg data
as_tod

Convert date to time-of-day in hours, minutes or seconds
as.cps_spct

Coerce to a spectrum
ciexyzCC10.spct

CIE xyz chromaticity coordinates (CC) 10 deg data
as.filter_mspct

Coerce to a collection-of-spectra
color_of

Color of an object
as.generic_spct

Coerce to a spectrum
auto_hinges

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

Spectral response of a back-thinned CCD image sensor.
as.matrix-mspct

Coerce a collection of spectra into a matrix
checkMspctVersion

Check that the "mspct.version" attribute is set
ciexyzCMF2.spct

Linear energy CIE xyz colour matching function (CMF) 2 deg data
class_spct

Query which is the class of an spectrum
convertTimeUnit

Convert the "time.unit" attribute of an existing source_spct object
as.response_mspct

Coerce to a collection-of-spectra
clear.spct

Theoretical spectrum of a clear material
clear_body.spct

Theoretical clear body
as.chroma_spct

Coerce to a spectrum
e2q

Convert energy-based quantities into photon-based quantities.
as.response_spct

Coerce to a spectrum
fshift_spct

fshift a spectrum
checkSpctVersion

Check that the "spct.version" attribute is set
as.cps_mspct

Coerce to a collection-of-spectra
e2qmol_multipliers

Calculate energy to quantum (mol) multipliers
eq_ratio

Energy:photon ratio
spread

Expanse
checkTimeUnit

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

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

Collection-of-spectra constructor
as.raw_mspct

Coerce to a collection-of-spectra
getInstrSettings

Get the "instr.settings" attribute
as.raw_spct

Coerce to a spectrum
format.solar_time

Encode in a Common Format
fluence

Fluence
getMspctVersion

Get the "mspct.version" attribute
getWhatMeasured

Get the "what.measured" attribute
head_tail

Return the First and Last Part of an Object
D65.illuminant.spct

CIE D65 illuminant data
green_leaf.spct

Green birch leaf reflectance.
is.generic_spct

Query class of spectrum objects
ciexyzCMF10.spct

Linear energy CIE xyz colour matching function (CMF) 10 deg data
ciexyzCC2.spct

CIE xyz chromaticity coordinates 2 deg data
getWhenMeasured

Get the "when.measured" attribute
getWhereMeasured

Get the "where.measured" attribute
labels

Find labels from "waveband" object
is.old_spct

Query if an object has old class names
log

Logarithms and Exponentials
FEL.BN.9101.165

Data for typical calibration lamps
as_quantum

Convert spectral energy irradiance into spectral photon irradiance
irrad

Irradiance
Ler_leaf_trns_i.spct

Green Arabidopsis leaf spectral transmittance.
interpolate_wl

Map spectra to new wavelength values.
MathFun

Miscellaneous Mathematical Functions
mspct_classes

Names of multi-spectra classes
add_attr2tb

Copy attributes from members of a generic_mspct
is.solar_time

Query class
as.calibration_mspct

Coerce to a collection-of-spectra
is.summary_generic_spct

Query class of spectrum summary objects
na.omit.source_spct

Handle Missing Values in Objects
as.reflector_mspct

Coerce to a collection-of-spectra
clean

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

Solar astronomy using Meeus' algorithm
clean_spct

Clean a spectrum
defunct

Defunct functions and methods
reflectance

Reflectance
l_insert_hinges

Insert wavelength values into spectral data.
as_quantum_mol

Convert spectral energy irradiance into spectral photon irradiance
as.reflector_spct

Coerce to a spectrum
check_w.length

Sanity check of wavelengths (internal function).
reflectance_spct

Calculate reflectance from spectral reflectance
calc_multipliers

Spectral weights
dim.generic_mspct

Dimensions of an Object
ciev10.spct

Linear energy CIE 2008 luminous efficiency function 10 deg data
relative_AM

Relative Air Mass (AM)
calc_source_output

Scaled and/or interpolated light-source spectral output
e2quantum_multipliers

Calculate energy to quantum multipliers
wl_max

Wavelength maximum
e_fluence

Energy fluence
resp_spct

Calculate response from spectral response
e_response

Energy-based photo-response
setInstrDesc

Set the "instr.desc" attribute
normalization

Normalization of an R object
merge2object_spct

Merge into object_spct
energy_as_default

Set spectral-data options
Extract

Extract or replace parts of a spectrum
convolve_each

Convolve function for collections of spectra
copy_attributes

Copy attributes
cps2irrad

Conversion from counts per second to physical quantities
fshift

Shift the scale of a spectrum using a summary function
fscale_spct

fscale a spectrum
day_night

Times for sun positions
energy_irradiance

Calculate (energy) irradiance from spectral irradiance
setInstrSettings

Set the "instr.settings" attribute
energy_ratio

Energy:energy ratio
A.illuminant.spct

CIE A illuminant data
T2T

Convert transmittance type.
A2T

Convert absorbance into transmittance
normalize

Normalize spectral data
findMultipleWl

Find repeated w.length values
getSpctVersion

Get the "spct.version" attribute
split_photon_irradiance

Photon irradiance for split spectrum regions
getTfrType

Get the "Tfr.type" attribute
wl_stepsize

Stepsize
insert_hinges

Insert wavelength values into spectral data.
find_peaks

Find peaks in a spectrum
Extract_mspct

Extract or replace members of a collection of spectra
as.calibration_spct

Coerce to a spectrum
getIdFactor

Get the "idfactor" attribute
as.chroma_mspct

Coerce to a collection-of-spectra
tz_time_diff

Time difference between two time zones
photon_ratio

Photo:photon ratio
as.object_mspct

Coerce to a collection-of-spectra
getInstrDesc

Get the "instr.desc" attribute
photons_energy_ratio

Photon:energy ratio
using_Tfr

Use photobiology options
Trig

Trigonometric Functions
twilight2angle

twilight argument check and conversion
integrate_spct

Integrate spectral data.
upgrade_spectra

Upgrade one or more spectral objects
f_dispatcher_spct

Math function dispatcher for spectra
wb2rect_spct

Create tagged spectrum from wavebands
as.object_spct

Coerce to a spectrum
wb2spct

Create spectrum from wavebands
integrate_xy

Gives irradiance from spectral irradiance.
insert_spct_hinges

Insert new wavelength values into a spectrum
irradiance

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

Query if it is a waveband
filter_cps.mspct

Counts per second from a measurement of a plastic film
is.generic_mspct

Query class of spectrum objects
as.source_spct

Coerce to a spectrum
as_energy

Convert spectral photon irradiance into spectral energy irradiance
isValidInstrDesc

Check the "instr.desc" attribute
is_photon_based

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

Get the "normalized" attribute
is_tagged

Query if it is an spectrum is tagged
getMultipleWl

Get the "multiple.wl" attribute
join_mspct

Join all spectra in a collection
black_body.spct

Theoretical black body
getRfrType

Get the "Rfr.type" attribute
is_scaled

Query whether a generic spectrum has been scaled
getScaled

Get the "scaled" attribute
q_irrad

Photon irradiance
wl_min

Wavelength minimum
minus-.generic_spct

Arithmetic Operators
c.generic_mspct

Combine collections of spectra
isValidInstrSettings

Check the "instr.settings" attribute
q_ratio

Photon:photon ratio
mod-.generic_spct

Arithmetic Operators
setAfrType

Set the "Afr.type" attribute
setBSWFUsed

Set the "bswf.used" attribute
msmsply

Multi-spct transform methods
is_absorbance_based

Query if a spectrum contains absorbance or transmittance data
peaks

Peaks or local maxima
normalize_range_arg

Normalize a range argument into a true numeric range
setGenericSpct

Convert an R object into a spectrum object.
merge_attributes

Merge and copy attributes
setIdFactor

Set the "idfactor" attribute
check_spct

Check validity of spectral objects
wl_midpoint

Midpoint
sign

Sign
normalized_diff_ind

Calculate a normalized index.
photodiode.spct

Spectral response of a GaAsP photodiode
photobiology-package

photobiology: Photobiological Calculations
check_spectrum

Sanity check a spectrum
plus-.generic_spct

Arithmetic Operators
slash-.generic_spct

Arithmetic Operators
photon_irradiance

Photon irradiance
print.waveband

Print a "waveband" object
sun.daily.spct

Daily solar spectral irradiance (simulated)
print.solar_time

Print solar time and solar date objects
clear_photobio.cache

Clear the spectral weights cache
print.summary_generic_spct

Print spectral summary
clip_wl

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

Transmittance spectrum of clear polyester film
trimInstrDesc

Trim the "instr.desc" attribute
sun.data

Solar spectral irradiance (simulated)
div-.generic_spct

Arithmetic Operators
div_spectra

Divide two spectra, even if the wavelengths values differ
q_response

Photon-based photo-response
qe_ratio

Photon:energy ratio
e_irrad

Energy irradiance
formatted_range

Compute range and format it
q2e

Convert photon-based quantities into energy-based quantities
e_ratio

Energy:energy ratio
fscale

Rescale a spectrum using a summary function
getAfrType

Get the "Afr.type" attribute
prod_spectra

Multiply two spectra, even if the wavelengths values differ
trimInstrSettings

Trim the "instr.settings" attribute
waveband

Waveband constructor method
response

Integrated response
q_fluence

Photon fluence
wl_range

Wavelength range
setRfrType

Set the "Rfr.type" attribute
setScaled

Set the "scaled" attribute
getBSWFUsed

Get the "bswf.used" attribute
rbindspct

Row-bind spectra
setWhatMeasured

Set the "what.measured" attribute
rgb_spct

RGB color values
waveband_ratio

Photon or energy ratio
get_attributes

Get the metadata attributes
setWhereMeasured

Set the "where.measured" attribute
get_peaks

Get peaks and valleys in a spectrum
yellow_gel.spct

Transmittance spectrum of yellow theatrical gel.
shared_member_class

Classes common to all collection members.
setWhenMeasured

Set the "when.measured" attribute
split_energy_irradiance

Energy irradiance for split spectrum regions
interpolate_spct

Map a spectrum to new wavelength values.
s_e_irrad2rgb

Spectral irradiance to rgb color conversion
subt_spectra

Subtract two spectra
round

Rounding of Numbers
setMultipleWl

Set the "multiple.wl" attribute
setNormalized

Set the "normalized" attribute
subset2mspct

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

Smooth a spectrum
transmittance

Transmittance
interpolate_spectrum

Calculate spectral values at a different set of wavelengths
is_effective

Is an R object "effective"
transmittance_spct

Calculate transmittance from spectral transmittance.
split_irradiance

Energy or photon irradiance for split spectrum regions
solar_time

Local solar time
is_normalized

Query whether a generic spectrum has been normalized.
sum_spectra

Add two spectra
oper_spectra

Binary operation on two spectra, even if the wavelengths values differ
sun.spct

Solar spectral irradiance (simulated)
opaque.spct

Theoretical spectrum of an opaque material
sun_angles

Solar angles
trim_waveband

Trim (or expand) head and/or tail
summary

Summary of a spectral object
trim_wl

Trim head and/or tail of a spectrum
summary_spct_classes

Function that returns a vector containing the names of spectral summary classes.
water_vp_sat

Water vapour pressure
w_length_range2rgb

Wavelength range to rgb color conversion
trim_spct

Trim (or expand) head and/or tail of a spectrum
sun.daily.data

Daily solar spectral irradiance (simulated)
white_body.spct

Theoretical white body
trim_tails

Trim (or expand) head and/or tail
verbose_as_default

Set error reporting options
w_length2rgb

Wavelength to rgb color conversion
white_led.cps_spct

White led bulb spectrum
untag

Remove tags
^.generic_spct

Arithmetic Operators
rmDerivedSpct

Remove "generic_spct" and derived class attributes.
rmDerivedMspct

Remove "generic_mspct" and derived class attributes.
setTfrType

Set the "Tfr.type" attribute
print

Print a spectral object
upgrade_spct

Upgrade one spectral object
white_led.raw_spct

White led bulb spectrum
source_spct

Spectral-object constructor
setTimeUnit

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

White led bulb spectrum
spct_classes

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

List-of-wavebands constructor
split2mspct

Convert a 'wide' or untidy data frame into a collection of spectra
times-.generic_spct

Arithmetic Operators
tag

Tag a spectrum
v_insert_hinges

Insert wavelength values into spectral data.
valleys

Valleys or local minima
wb2tagged_spct

Create tagged spectrum from wavebands
wb_trim_as_default

Set computation options
T2A

Convert transmittance into absorbance.
D2.UV586

Data for typical calibration lamps