
Read File Saved by Ocean Optics' Raspberry Pi software.
Source:R/read-oopi-file.r
read_oo_pidata.RdReads and parses the header of a raw data file as output by the server running on a Raspberry Pi board to extract the whole header remark field. The time field is retrieved and decoded. The company formerly named Ocean Optics is now called Ocean Insight.
Usage
read_oo_pidata(
file,
date = NULL,
geocode = NULL,
label = NULL,
tz = NULL,
locale = readr::default_locale(),
npixels = Inf,
spectrometer.sn = "FLMS00673"
)Arguments
- file
character string
- date
a
POSIXctobject to use to set the"when.measured"attribute. IfNULL, the default, the date is set to the file modification date.- geocode
A data frame with columns
lonandlatused to set attribute"where.measured".- label
character string, but if
NULLthe value offileis used, and ifNAthe "what.measured" attribute is not set.- tz
character Time zone is not saved to the file.
- locale
The locale controls defaults that vary from place to place. The default locale is US-centric (like R), but you can use
localeto create your own locale that controls things like the default time zone, encoding, decimal mark, big mark, and day/month names.- npixels
integer Number of pixels in spectral data.
- spectrometer.sn
character The serial number of the spectrometer needs to be supplied by the user as it is not included in the file header.
Note
The header in these files has very little information.
The file contains a time in milliseconds but as the Raspberry Pi board
contains no real-time clock, it seems to default to number of milliseconds
since the Pi was switched on. The user may wish to supply the date-time as
an argument, but if no argument is passed to date this
attribute is set to the file modification date obtained with file.mtime().
This date-time gives an upper limit to the real time of measurement as in
some operating systems it is reset when the file is copied or even without
any good apparent reason. The user may need to supply the number of pixels
in the array although the default of npixels = Inf usually works
and triggers no warnings.
Examples
file.name <-
system.file("extdata", "spectrum.pi",
package = "photobiologyInOut", mustWork = TRUE)
oopi.spct <- read_oo_pidata(file = file.name)
oopi.spct
#> Object: raw_spct [2,048 x 2]
#> Wavelength range 188.41408-1035.613 nm, step 0.3603105-0.4672823 nm
#> Label: File: spectrum.pi
#> Measured on 2025-10-02 21:42:33.632242 UTC
#> Data acquired with 'OO with Raspberry Pi' s.n. FLMS00673
#> grating 'NA', slit 'NA'
#> diffuser 'unknown'
#> integ. time (s): 0.01
#> total time (s): 0.01
#> counts @ peak (% of max):
#> Variables:
#> w.length: Wavelength [nm]
#> counts: Raw detector counts [number]
#> --
#> # A tibble: 2,048 × 2
#> w.length counts
#> <dbl> <dbl>
#> 1 188. 16.4
#> 2 189. 27476.
#> 3 189. 2064.
#> 4 190. 1994.
#> 5 190. 2001.
#> 6 191. 1954.
#> 7 191. 1950.
#> 8 192. 2083.
#> 9 192. 1980.
#> 10 193. 1980.
#> # ℹ 2,038 more rows
getWhenMeasured(oopi.spct)
#> [1] "2025-10-02 21:42:33 UTC"
getWhatMeasured(oopi.spct)
#> [1] "File: spectrum.pi"
cat(comment(oopi.spct))
#> Ocean Optics Raspeberry Pi raw counts file 'spectrum.pi' imported on 2025-10-02 21:42:55.313734 UTC
#> Saved at time: 612027 milliseconds
#> Integration time: 10000
#> Scans to average: 0
#> Boxcar smoothing: 0