Skip to contents

Form a collection of spectra from separate objects in the parent frame of the call.

Usage

collect2mspct(
  .list = NULL,
  pattern = "*\\.spct$",
  collection.class = NULL,
  ...
)

Arguments

.list

list of R objects

pattern

character an optional regular expression, ignored if .list is not NULL.

collection.class

character vector

...

additional named arguments passed down to the collection constructor.

Value

By default a collection of spectra.

Details

This is a convenience function that simplifies the creation of collections from existing objects of class generic_spct or a derived class. A list of objects con be passed as argument, or a search pattern. If a list is passed, no search is done. If collection.class is NULL, then all objects of class generic_spct or of a class derived from it are added to the collection. If objects of only one derived class are to be collected this class or that of the matching collection should be passed as argument to collection.class. Objects of other R classes are silently discarded, which simplifies the specification of search patterns. By default, i.e., if collection.class is NULL, if all the objects collected belong to the same class then the corresponding collection class will be returned, otherwise a generic_mspct object with heterogeneous members will be returned. To force the return of a generic_mspct even when the collected spectra all belong to the same class, pass generic_mspct as argument to collection.class. If the argument to collection.class is a vector containing two of more class names, only the matching spectra will be collected, and a generic_mspct will be returned. The returned object is created with the constructor for the class, and validated.

See also

Other experimental utility functions: drop_user_cols(), thin_wl(), uncollect2spct()

Examples

collect2mspct() # returns empty generic_mspct object
#> Object: generic_mspct [0 x 1]
#> 
#> --- END ---

sun1.spct <- sun.spct
sun2.spct <- sun.spct
kk.spct <- 10:30 # ignored
collect2mspct()
#> Object: source_mspct [2 x 1]
#> --- Member: sun1.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> --- Member: sun2.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> 
#> --- END ---
collect2mspct(collection.class = "generic_mspct")
#> Object: generic_mspct [2 x 1]
#> --- Member: sun1.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> --- Member: sun2.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> 
#> --- END ---

pet1.spct <- polyester.spct
collect2mspct()
#> Object: generic_mspct [3 x 1]
#> --- Member: pet1.spct ---
#> Object: filter_spct [454 x 2]
#> Wavelength range 240-800 nm, step 1-4 nm 
#> Label: Polyester, clear film, 0.000125 m thick, Autostat CT5 from McDermit Autotype; new 
#> Rfr (/1): 0.074, thickness (mm): 0.125, attenuation mode: absorption.
#> Variables:
#>  w.length: Wavelength [nm]
#>  Tfr: Total spectral transmittance [/1] 
#> --
#> # A tibble: 454 × 2
#>    w.length     Tfr
#>       <int>   <dbl>
#>  1      240 0.00482
#>  2      241 0.00464
#>  3      242 0.00446
#>  4      244 0.00414
#>  5      246 0.004  
#>  6      248 0.004  
#>  7      252 0.00386
#>  8      256 0.00329
#>  9      258 0.003  
#> 10      259 0.003  
#> # ℹ 444 more rows
#> --- Member: sun1.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> --- Member: sun2.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> 
#> --- END ---
collect2mspct(collection.class = "source_mspct")
#> Object: source_mspct [2 x 1]
#> --- Member: sun1.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> --- Member: sun2.spct ---
#> Object: source_spct [522 x 3]
#> Wavelength range 280-800 nm, step 0.9230769-1 nm 
#> Label: sunlight, simulated 
#> Measured on 2010-06-22 09:51:00 UTC 
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI 
#> Variables:
#>  w.length: Wavelength [nm]
#>  s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#>  s.q.irrad: Spectral photon irradiance [mol s-1 m-2 nm-1] 
#> --
#> # A tibble: 522 × 3
#>    w.length s.e.irrad s.q.irrad
#>       <dbl>     <dbl>     <dbl>
#>  1     280          0         0
#>  2     281.         0         0
#>  3     282.         0         0
#>  4     283.         0         0
#>  5     284.         0         0
#>  6     285.         0         0
#>  7     286.         0         0
#>  8     286.         0         0
#>  9     287.         0         0
#> 10     288.         0         0
#> # ℹ 512 more rows
#> 
#> --- END ---
collect2mspct(collection.class = "filter_mspct")
#> Object: filter_mspct [1 x 1]
#> --- Member: pet1.spct ---
#> Object: filter_spct [454 x 2]
#> Wavelength range 240-800 nm, step 1-4 nm 
#> Label: Polyester, clear film, 0.000125 m thick, Autostat CT5 from McDermit Autotype; new 
#> Rfr (/1): 0.074, thickness (mm): 0.125, attenuation mode: absorption.
#> Variables:
#>  w.length: Wavelength [nm]
#>  Tfr: Total spectral transmittance [/1] 
#> --
#> # A tibble: 454 × 2
#>    w.length     Tfr
#>       <int>   <dbl>
#>  1      240 0.00482
#>  2      241 0.00464
#>  3      242 0.00446
#>  4      244 0.00414
#>  5      246 0.004  
#>  6      248 0.004  
#>  7      252 0.00386
#>  8      256 0.00329
#>  9      258 0.003  
#> 10      259 0.003  
#> # ℹ 444 more rows
#> 
#> --- END ---
collect2mspct(collection.class = "response_mspct")
#> Object: response_mspct [0 x 1]
#> 
#> --- END ---