Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alkc/apogeereader
An R package for reading Spectrawiz and Spectrovision spectral data files
https://github.com/alkc/apogeereader
apogee ps-100 r spectral-data spectrawiz spectrawiz-files spectrovision spectrovision-files ss-110 ss-120
Last synced: 19 days ago
JSON representation
An R package for reading Spectrawiz and Spectrovision spectral data files
- Host: GitHub
- URL: https://github.com/alkc/apogeereader
- Owner: alkc
- Created: 2017-05-18T08:03:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T07:59:37.000Z (over 3 years ago)
- Last Synced: 2023-10-20T16:31:35.077Z (about 1 year ago)
- Topics: apogee, ps-100, r, spectral-data, spectrawiz, spectrawiz-files, spectrovision, spectrovision-files, ss-110, ss-120
- Language: R
- Homepage:
- Size: 65.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# apogreereader
## Early development!
This package is still in early development. Function names and such _might_ be
subject to change!The first stable version of this package will (hopefully) be available via CRAN.
Until then, follow the instructions below to install the development version.## Hello world!
apogeereader is a package for reading files containing spectral measurements
made using the Stellarnet SpectraWiz® Spectroscopy Software and Apogee Instruments, Inc.
Spectrovision Spectroradiometer software. It is inspired by the [asdreader](https://github.com/cran/asdreader) package
(for ASD Fieldspec data) in its basic functionality.## Installation
To install this development version of spectrawizreader, please use the
`install_github()` function from the
[devtools package](https://github.com/r-lib/devtools/), like so:```{r}
devtools::install_github("alkc/apogeereader")
```## Usage
### Spectrawiz
#### Basic file input
```{r}
# Get path to demo file included in the package:
path_to_spectrawiz_file <- trm_file()# Read the file into a data.frame
spectral_data <- read_spectrawiz(file)# Print first five columns:
print(spectral_data[,1:5])
```The first column in the `data.frame` returned by `read_spectrawiz` is always
the filename associated with the input file. To remove it, just subset away
the first column:```{r}
spectral_data <- spectral_data[,-1]
```#### Getting the wavelengths
The wavelengths are stored in the column names of the `data.frame` returned by
`read_spectrawiz()`.Use the base function `colnames()` to extract the wavelengths, followed by
`as.numeric()` to convert the wavelength vector from characters to numbers.Here is an example:
```{r}
path_to_spectrawiz_file <- trm_file()
spectral_data <- read_spectrawiz(path_to_spectrawiz_file)# The first column in spectral_data contains file paths, so we remove it
# before we extract the colnames
wavelengths <- colnames(spectral_data[,-1])# The wavelengths are stored as characters in the column names. To convert them
# back to numeric format, use as.numeric():
wavelengths <- as.numeric(wavelengths)# Done!
# Preview the first six values:
head(wavelengths)
# [1] 339.0 339.5 340.0 340.5 341.0 341.5
```### Spectrovision
#### Basic file input
```{r}
spectrovision_file <- spectrovision_file()
spectral_data <- read_spectrovision(spectrovision_file)
```
The first column of the resulting `data.frame` is the timestamp
associated with each measurement. If you wish to split the timestamp into
separate `Date`, `Time` and `Sensor` for each row them set the `split_timestamp`
argument to `TRUE` in `read_spectrovision`:```{r}
spectrovision_file <- spectrovision_file()
spectral_data <- read_spectrovision(spectrovision_file, split_timestamp = TRUE)
```#### Merging multiple spectrovision files into a single `data.frame`
```{r}
library(purrr)spectrovision_files <- c(path_to_spectrovision_1, path_to_spectrovision_2,
path_to_spectrovision_3)spectral_data <- map_dfr(spectrovision_files, read_spectrovision)
```