| io_spec | R Documentation |
Functions for reading and writing spectral data to and from OpenSpecy format.
OpenSpecy objects are lists with components wavenumber, spectra,
and metadata; their supported formats are .json, .csv, and .rds.
A file-backed FileSpecs method writes a new ENVI pair.
## S3 method for class 'FileSpecs'
write_spec(x, file, method = NULL, ...)
write_spec(x, ...)
## Default S3 method:
write_spec(x, ...)
## S3 method for class 'OpenSpecy'
write_spec(x, file, method = NULL, digits = getOption("digits"), ...)
read_spec(file, method = NULL, ...)
as_hyperSpec(x)
x |
an object of class |
file |
file path to be read from or written to. |
method |
optional custom reader or |
digits |
number of significant digits to use when formatting numeric
values; defaults to |
... |
further arguments passed to the submethods. |
Due to floating point number errors there may be some differences in the
precision of the numbers returned if using multiple devices for .json and
.csv files but the numbers should be nearly identical.
readRDS() should return the exact same object every time.
write_spec.FileSpecs() streams one complete rectangular region to a new
ENVI BIP pair using float64 spectra and a round-trip-safe wavelength axis.
It refuses custom writers, source-member targets, existing outputs, and
multi-region or incomplete views.
read_spec() reads data formatted as an OpenSpecy object and
returns a list object of class OpenSpecy containing spectral
data.
write_spec() writes spectral data. For FileSpecs, it invisibly
returns the new ENVI header and binary paths; other methods are called for
their file-writing side effect.
as_hyperspec() converts an OpenSpecy object to a
hyperSpec-class object.
Zacharias Steinmetz, Win Cowger
OpenSpecy();
read_text(), read_asp(), read_spa(),
read_spc(), and read_jdx() for text files, .asp,
.spa, .spa, .spc, and .jdx formats, respectively;
read_zip() and read_any() for wrapper functions;
saveRDS(); readRDS();
write_json(); read_json();
read_extdata("raman_hdpe.json") |> read_spec()
read_extdata("raman_hdpe.rds") |> read_spec()
read_extdata("raman_hdpe.csv") |> read_spec()
## Not run:
data(raman_hdpe)
write_spec(raman_hdpe, "raman_hdpe.json")
write_spec(raman_hdpe, "raman_hdpe.rds")
write_spec(raman_hdpe, "raman_hdpe.csv")
# Convert an OpenSpecy object to a hyperSpec object
hyper <- as_hyperSpec(raman_hdpe)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.