Convert a data frame with data imported with read_yocto_spctlog()
into a collection of raw_spct objects.
Arguments
- df
data.frame With only one of average, minimum or maximum sensor counts for each spectral channels.
- channels
character vector of length one or longer. In addition to a vector of spectral sensor channel names as used in the AS7343 documentation, the nicknames
"all","wide","narrow"and"xyz"as vectors of length one are accepted.- ...
Arguments passed on to
photobiology::subset2mspctdrop.idxlogical Flag indicating whether to drop or keep idx.var in the collection members.
ncolinteger Number of 'virtual' columns in data.
byrowlogical If
ncol > 1how to read in the data.
Details
The data frame, possibly after subsetting data columns, is pivoted into long form, and subsequently split by time stamp. The readings at each time point are converted into short spectra with at most 13 wavelength values, one from each channel.
Note
Currently, function subset2mspct() used
in the conversion into a raw_mspct object can be slow in the case of
10000's of spectra.
Examples
nrow(yocto_spectral.df)
#> [1] 199
comment(yocto_spectral.df)
#> [1] "Data logged by a YoctoPuce USB module.\nData file \"yocto-spectral-LED.csv\" created on 2026-01-25 23:48:09.\nMetadata file \"SPECTRL1-2CF3B6.json\" created on 2026-01-25 23:48:09.\nImported on 2026-01-25 23:50:24 using TZ = \"UTC\" with 'rYoctoPuceInOut' (== 0.0.1.1).\n"
yocto_spectral.mspct <- yocto_spectral2mspct(yocto_spectral.df)
#> Creating a 'source_mspct' containing 199 'source_spct' objects.
summary(yocto_spectral.mspct)
#> Summary of raw_mspct [199 x 1] object: yocto_spectral.mspct
#> # A tibble: 199 × 7
#> spct.idx class dim w.length.min w.length.max colnames multiple.wl
#> <chr> <chr> <chr> <dbl> <dbl> <list> <dbl>
#> 1 2025-12-03 19:54:… raw_… [13 … 402. 852. <chr> 1
#> 2 2025-12-03 19:55:… raw_… [13 … 402. 852. <chr> 1
#> 3 2025-12-03 19:56:… raw_… [13 … 402. 852. <chr> 1
#> 4 2025-12-03 19:57:… raw_… [13 … 402. 852. <chr> 1
#> 5 2025-12-03 19:58:… raw_… [13 … 402. 852. <chr> 1
#> 6 2025-12-03 19:59:… raw_… [13 … 402. 852. <chr> 1
#> 7 2025-12-03 20:00:… raw_… [13 … 402. 852. <chr> 1
#> 8 2025-12-03 20:01:… raw_… [13 … 402. 852. <chr> 1
#> 9 2025-12-03 20:02:… raw_… [13 … 402. 852. <chr> 1
#> 10 2025-12-03 20:03:… raw_… [13 … 402. 852. <chr> 1
#> # ℹ 189 more rows
yocto_spectral.mspct[[1]]
#> Object: raw_spct [13 x 3]
#> Wavelength range 402.3-852.2 nm, step 13.3-109.4 nm
#> Variables:
#> w.length: Wavelength [nm]
#> counts: Raw detector counts [number]
#> --
#> # A tibble: 13 × 3
#> channel counts w.length
#> <chr> <dbl> <dbl>
#> 1 F1 0 402.
#> 2 F2 0 426.
#> 3 FZ 0.0192 452.
#> 4 F3 0 476.
#> 5 F4 0.0189 514.
#> 6 F5 0 546.
#> 7 FY 0.0854 560.
#> 8 FXL 0.0967 597.
#> 9 F6 0.0824 642.
#> 10 F7 0.0682 687
#> 11 VIS 0.0814 723.
#> 12 F8 0 743.
#> 13 NIR 0 852.