spec.vis
spec.vis
is a mini-database and R data package of receptor absorbance
and ocular transmission spectra with metadata, useful for
visual/colorspace modelling among other things. It currently contains
410 spectra from 119 species.
To download the development version of spec.vis
, you can:
remotes
package:# install.packages("remotes")
remotes::install_github("thomased/spec.vis")
$R CMD INSTALL
or,
from within R:install.packages(path, type = "source", repos = NULL)
The entire database can be loaded into memory by simply calling
data(specvis_spectra)
, along with the metadata data(specvis_meta)
and dictionary data(specvis_dict)
.
Alternately, the specvis_search()
function allows you to query the
available data and return a select subset based on search terms
(e.g. specvis_search(genus == 'bombus')
), with the option of
returning either raw spectra or metadata via the return.spectra
argument.
Finally, if you’re not an R
person, the ‘database’ boils down to a few
text files located in the data.raw/
directory, which you’re free to
download and use as you please.
# Load packages
library(spec.vis)
library(pavo)
# Grab some spectra
apis <- specvis_search(genus == 'apis', species == 'mellifera', return.spectra = TRUE)
canis <- specvis_search(genus == 'canis', species == 'familiaris', return.spectra = TRUE)
bluetit <- specvis_search(genus == 'cyanistes', species == 'caeruleus', return.spectra = TRUE)
# Plot them
par(mfrow=c(1,3))
plot(as.rspec(canis), main = 'Canis familiaris', ylab = 'Absorbance', xlab = '')
plot(as.rspec(apis), ylab = '', main = 'Apis mellifera (f)')
plot(as.rspec(bluetit), ylab = '', main = 'Cyanistes caeruleus', xlab = '')
Contributions of spectra to the package are most welcome. There are a few ways to do so, from most- to least-involved:
spec.vis
package in the usual manner.data-raw/specvis_spectra.csv
file,
and complete all metadata fields in the
data-raw/specvis_meta.csv
file. Spectra should follow the
naming convention <species>_<genus>.<integer>
, where
<integer>
begins at 1 and proceeds from the shortest- to
longest- wavelength sensitive receptor.specvis_rebuild()
to rebuild the database
(i.e. to save the raw data as .rda
files.data(specvis_spectra)
) and metadata (data(specvis_meta)
).If you find the package useful, please cite the original data
source(s)and the spec.vis
package (see citation("spec.vis")
for the
reference).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.