Streamlining spectral data processing and modeling for spectroscopy applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
12 KiB

<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Resample spectra in list-column to new x-axis interval — resample_spc • simplerspec</title><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"><script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"><script src="../pkgdown.js"></script><meta property="og:title" content="Resample spectra in list-column to new x-axis interval — resample_spc"><meta property="og:description" content="Resamples (interpolates) different spectra types with
corresponding x-axis values that are both stored in list-columns of a spectra
tibble. A spectra tibble hosts spectra, x-axis vectors, metadata, and
further linked data with standardized naming conventions. Data input for
resampling can for example be generated with simplerspec::gather_spc().
Resampling is a key harmonizing step to process and later model spectra
measured at different resolutions and spectral ranges (i.e., different
spectrometer devices and/or measurement settings)."><meta name="robots" content="noindex"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><body data-spy="scroll" data-target="#toc">
<div class="container template-reference-topic">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">simplerspec</a>
<span class="version label label-danger" data-toggle="tooltip" data-placement="bottom" title="In-development version">0.1.0.9001</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"><li>
<a href="../reference/index.html">Reference</a>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul><ul class="nav navbar-nav navbar-right"><li>
<a href="https://github.com/philipp-baumann/simplerspec/" class="external-link">
<span class="fab fa-github fa-lg"></span>
</a>
</li>
</ul></div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Resample spectra in list-column to new x-axis interval</h1>
<small class="dont-index">Source: <a href="https://github.com/philipp-baumann/simplerspec/blob/HEAD/R/resample-spc.R" class="external-link"><code>R/resample-spc.R</code></a></small>
<div class="hidden name"><code>resample_spc.Rd</code></div>
</div>
<div class="ref-description">
<p>Resamples (interpolates) different spectra types with
corresponding x-axis values that are both stored in list-columns of a spectra
tibble. A spectra tibble hosts spectra, x-axis vectors, metadata, and
further linked data with standardized naming conventions. Data input for
resampling can for example be generated with <code><a href="gather_spc.html">simplerspec::gather_spc()</a></code>.
Resampling is a key harmonizing step to process and later model spectra
measured at different resolutions and spectral ranges (i.e., different
spectrometer devices and/or measurement settings).</p>
</div>
<div id="ref-usage">
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">resample_spc</span><span class="op">(</span></span>
<span> <span class="va">spc_tbl</span>,</span>
<span> column_in <span class="op">=</span> <span class="st">"spc"</span>,</span>
<span> x_unit <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"wavenumber"</span>, <span class="st">"wavelength"</span><span class="op">)</span>,</span>
<span> wn_lower <span class="op">=</span> <span class="fl">500</span>,</span>
<span> wn_upper <span class="op">=</span> <span class="fl">4000</span>,</span>
<span> wn_interval <span class="op">=</span> <span class="fl">2</span>,</span>
<span> wl_lower <span class="op">=</span> <span class="fl">350</span>,</span>
<span> wl_upper <span class="op">=</span> <span class="fl">2500</span>,</span>
<span> wl_interval <span class="op">=</span> <span class="fl">1</span>,</span>
<span> interpol_method <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"linear"</span>, <span class="st">"spline"</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
</div>
<div id="arguments">
<h2>Arguments</h2>
<dl><dt>spc_tbl</dt>
<dd><p>Spectra data embedded in a tibble object (classes
<code>"tbl_df", "tbl", "data.frame"</code>). The spectra tibble needs to contain at
least of one of the the spectra columns <code>spc</code>, <code>spc_rs</code>, <code>spc_mean</code>,
<code>spc_nocomp</code>, <code>sc_sm</code>, <code>sc_rf</code>, or <code>spc_pre</code> (list-columns with spectral
<code>data.table</code>s), and <code>wavenumbers</code> or <code>wavelengths</code> (list-column with vectors
of x-axis values corresponding to each spectrum). The help section <em>"Matching
spectrum type and corresponding x-axis type"</em> describes the spectra types
and corresponding x-axis types.</p></dd>
<dt>column_in</dt>
<dd><p>Character vector of length 1L or symbol/name
specifying the name of list-column that contains the spectra to be resampled.</p></dd>
<dt>x_unit</dt>
<dd><p>Character vector of length 1L specifying the measurement unit
of the x-axis values (list-column) of the input spectra in <code>spc_tbl</code>.
Possible values are <code>"wavenumber"</code> (default) or <code>"wavelength"</code>. Wavenumber
is a convenient unit of frequency in the mid-infrared spectral range,
where wavelength is often used as spatial period for the visible and
near-infrared range.</p></dd>
<dt>wn_lower</dt>
<dd><p>Numeric value of lowest wavenumber. This argument will only
be used if <code>x_unit = "wavenumber"</code>. The value serves as starting value for
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 500 (i.e., in reciprocal centimeters).</p></dd>
<dt>wn_upper</dt>
<dd><p>Numeric value of highest wavenumber. This argument will only
be used if <code>x_unit = "wavenumber</code>. The value will be used as last value of
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 4000 (i.e., in reciprocal centimeters).</p></dd>
<dt>wn_interval</dt>
<dd><p>Numeric value of the wavenumber increment for the new
wavenumber sequence that the spectra will be resampled upon. Default value
is 2 (i.e., in reciprocal centimeters).</p></dd>
<dt>wl_lower</dt>
<dd><p>Numeric value of lowest wavelength. This argument will only
be used if <code>x_unit = "wavelength"</code>. The value serves as starting value of
the new wavenumber sequence that the spectra will be resampled upon.
Default value is 350 (i.e. in nanometers).</p></dd>
<dt>wl_upper</dt>
<dd><p>Numeric value of highest wavelength. This argument will only
be used if <code>x_unit = "wavelength"</code>. The value will be used as last value of
the new wavenumber sequence that the spectra will be resampled upon. Default
value is 2500 (i.e., in nanometers).</p></dd>
<dt>wl_interval</dt>
<dd><p>Numeric value of the wavelength increment for the new
wavenumber sequence that the spectra will be resampled upon. This argument
will only be used if <code>x_unit = "wavelength"</code>. Default value is 1 (i.e., in
nanometers).</p></dd>
<dt>interpol_method</dt>
<dd><p>Character of <code>"linear"</code> (default) or <code>"spline"</code> with
the interpolation method. <code>"spline"</code> uses a cubic spline to interpolate the
input spectra at given x-axis values to new equispaced x-axis intervals.</p></dd>
</dl></div>
<div id="value">
<h2>Value</h2>
<p>A spectra tibble (<code>spc_tbl</code>) containing two added list-columns:</p><ul><li><p><code>spc_rs:</code> Resampled spectra as list of <code>data.table</code>s</p></li>
<li><p><code>wavenumbers_rs</code> or <code>wavelengths_rs</code>: Resampled x-axis values as list of
numeric vectors</p></li>
</ul></div>
<div id="matching-spectrum-type-and-corresponding-x-axis-type">
<h2>Matching spectrum type and corresponding x-axis type</h2>
<p>The combinations of input spectrum types (<code>column_in</code>) and
corresponding x-axis types are generated from a simple lookup list. The
following key-value(s) pairs can be matched at given key, which is the column
name from <code>column_in</code> containing the spectra.</p><ul><li><p><code>"spc"</code> : <code>"wavenumbers"</code> or <code>"wavelengths"</code> (raw spectra)</p></li>
<li><p><code>"spc_rs"</code> : <code>"wavenumbers_rs"</code> or <code>"wavelengths_rs"</code>) (resampled spectra)</p></li>
<li><p><code>"spc_mean"</code> : <code>"wavenumbers_rs"</code> or <code>"wavelengths_rs"</code> (mean spectra)</p></li>
<li><p><code>"spc_nocomp"</code> <code>"wavenumbers"</code> or <code>"wavelengths"</code> (spectra prior
atmospheric compensation)</p></li>
<li><p><code>"sc_sm" : c("wavenumbers_sc_sm", "wavelengths_sc_sm")</code> (single channel
sample spectra)</p></li>
<li><p><code>"sc_rf" : c("wavenumbers_sc_rf", "wavelengths_sc_rf")</code> (single channel
reference spectra)</p></li>
<li><p><code>"spc_pre" : "xvalues_pre"</code> (preprocessed spectra)</p></li>
</ul></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
</nav></div>
</div>
<footer><div class="copyright">
<p></p><p>Developed by Philipp Baumann.</p>
</div>
<div class="pkgdown">
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
</div>
</footer></div>
</body></html>