View source: R/read-wasatch-csv.r
read_wasatch_csv | R Documentation |
Read wavelength and spectral data from the data section of a file as
output by Enlighten importing them into R. Parse the header of a file to
extract the acquisition time, instrument name and serial number, as well
additional metadata related to the instrument and its settings. Function
read_wasatch_csv()
only accepts "column oriented" CSV files.
read_wasatch_csv(
file,
date = NULL,
geocode = NULL,
label = NULL,
tz = NULL,
locale = readr::default_locale(),
s.qty = NULL,
extra.cols = "keep",
scale.factor = 1,
simplify = TRUE,
...
)
file |
character |
date |
a |
geocode |
A data frame with columns |
label |
character string, but if |
tz |
character Time zone is by default that of the machine's locale. |
locale |
The locale controls defaults that vary from place to place. The
default locale is US-centric (like R), but you can use
|
s.qty |
character, possibly named. The name of the quantity using the conventions accepted used in package 'photobiology' that is to be imported from column "Processed" from the file. |
extra.cols |
character What to do non-processed data columns if present
in file. One of |
scale.factor |
numeric vector of length 1, or length equal to the number of rows (= detector pixels). Numeric multiplier applied to returned spectral values. |
simplify |
logical If TRUE, single spectra are returned as individual spectra instead of collections of length one. |
... |
additional arguments passed to the constructor of the spectrum object. |
Enlighten's column-wise CSV files contain at least two columns,
Wavelength and Processed. In the header the Technique used is recorded.
Additional data columns can be present. Column Pixel contains the pixel
index in the array as integers. Columns Raw, Dark and Reference contain
detector counts data. Technique is used to guess the type of spectrum
stored in the column named Processed, which can be detector counts or
derived values. By default the data are read into a single spectrum object
and all columns retained, but only the data in Processed are interpreted as
spectral data corresponding to the class of the object. If passed
extra.cols = "drop"
, only Wavelength and Processed are copied to the
returned object, while if passed extra.cols = "drop.pixel"
only the
contents of column Pixel are discarded. If passed extra.cols =
"split"
all columns containing spectral data are each read into a separate
spectrum, these are collected and a "generic_mspct" object containing them
returned. extra.cols
can be a named vector of mappings, of length at
least one but possibly longer. If longer a "generic_mspct" is returned,
otherwise a spectrum object as inferred from the name each column is mapped
to.
An object of a class derived from generic_spct
such as
raw_spct
or filter_spct
. generic_spct
is derived from
tibble and data frame.
We thank Ruud Niesen from Photon Mission (https://photonmission.com/) for organizing the loan of the spectrometer used to produce the various files needed for the development of this function.
Enlighten, the free software from Wasatch Photonics can save spectra in
a variety of additional formats: different types of CSV files, plain text
and JSON. Plain text files contain no metadata or even column headers and
if the need arises can be read with R function read.table()
. JSON
files contain the most detailed metadata.
https://wasatchphotonics.com/ https://wasatchphotonics.com/product-category/software/
file.name <-
system.file("extdata", "enlighten-wasatch-scope.csv",
package = "photobiologyInOut", mustWork = TRUE)
wasatch.raw.spct <-
read_wasatch_csv(file = file.name)
summary(wasatch.raw.spct)
wasatch.raw.spct <-
read_wasatch_csv(file = file.name, s.qty = "counts")
summary(wasatch.raw.spct)
wasatch.raw.spct <-
read_wasatch_csv(file = file.name, s.qty = c(Processed = "counts"))
summary(wasatch.raw.spct)
wasatch.raw.spct <-
read_wasatch_csv(file = file.name, extra.cols = "drop")
summary(wasatch.raw.spct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.