<!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, shrink-to-fit=no"><title>Read a rsk File — read.rsk • oce</title><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Read a rsk File — read.rsk"><meta name="description" content="Read an RBR rsk or txt file, e.g. as produced by an RBR logger, producing an
object of class rsk."><meta property="og:description" content="Read an RBR rsk or txt file, e.g. as produced by an RBR logger, producing an
object of class rsk."></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">oce</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">1.8-4</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><a class="dropdown-item" href="../articles/A_oce.html">1. Introduction to Oce</a></li>
    <li><a class="dropdown-item" href="../articles/B_ctd.html">2. Analysis of CTD data</a></li>
    <li><a class="dropdown-item" href="../articles/C_adp.html">3. Analysis of acoustic-Doppler data</a></li>
    <li><a class="dropdown-item" href="../articles/D_map_projections.html">4. Using map projections</a></li>
    <li><a class="dropdown-item" href="../articles/E_flags.html">5. Dealing with data-quality flags</a></li>
    <li><a class="dropdown-item" href="../articles/F_subclassing.html">6. Subclassing oce objects</a></li>
    <li><a class="dropdown-item" href="../articles/G_altering_defaults.html">7. Altering oce Defaults</a></li>
    <li><a class="dropdown-item" href="../articles/H_tides.html">8. Tidal Analysis</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/dankelley/oce/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">

      <h1>Read a rsk File</h1>
      <small class="dont-index">Source: <a href="https://github.com/dankelley/oce/blob/HEAD/R/rsk.R" class="external-link"><code>R/rsk.R</code></a></small>
      <div class="d-none name"><code>read.rsk.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Read an RBR rsk or txt file, e.g. as produced by an RBR logger, producing an
object of class <code>rsk</code>.</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">read.rsk</span><span class="op">(</span></span>
<span>  <span class="va">file</span>,</span>
<span>  from <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  <span class="va">to</span>,</span>
<span>  by <span class="op">=</span> <span class="fl">1</span>,</span>
<span>  <span class="va">type</span>,</span>
<span>  encoding <span class="op">=</span> <span class="cn">NA</span>,</span>
<span>  tz <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/options.html" class="external-link">getOption</a></span><span class="op">(</span><span class="st">"oceTz"</span>, default <span class="op">=</span> <span class="st">"UTC"</span><span class="op">)</span>,</span>
<span>  <span class="va">tzOffsetLocation</span>,</span>
<span>  patm <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  allTables <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  <span class="va">processingLog</span>,</span>
<span>  debug <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/options.html" class="external-link">getOption</a></span><span class="op">(</span><span class="st">"oceDebug"</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-file">file<a class="anchor" aria-label="anchor" href="#arg-file"></a></dt>
<dd><p>a connection or a character string giving the name of the RSK file to
load. Note that <code>file</code> must be a character string, because connections are
not used in that case, which is instead handled with database calls.</p></dd>


<dt id="arg-from">from<a class="anchor" aria-label="anchor" href="#arg-from"></a></dt>
<dd><p>indication of the first datum to read.  This can a positive integer
to indicate sequence number, the POSIX time of the first datum, or a character
string that can be converted to a POSIX time.  (For POSIX times, be careful
about the <code>tz</code> argument.)</p></dd>


<dt id="arg-to">to<a class="anchor" aria-label="anchor" href="#arg-to"></a></dt>
<dd><p>an indication of the last datum to be read, in the same format as
<code>from</code>.  If <code>to</code> is missing, data will be read to the end of the file.</p></dd>


<dt id="arg-by">by<a class="anchor" aria-label="anchor" href="#arg-by"></a></dt>
<dd><p>an indication of the stride length to use while walking through the
file.  If this is an integer, then <code>by-1</code> samples are skipped between each
pair of samples that is read.  If this is a string representing a time interval,
in colon-separated format (HH:MM:SS or MM:SS), then this interval is divided by
the sampling interval, to get the stride length.</p></dd>


<dt id="arg-type">type<a class="anchor" aria-label="anchor" href="#arg-type"></a></dt>
<dd><p>optional file type, presently can be <code>rsk</code> or <code>txt</code> (for a
text export of an RBR rsk or hex file). If this argument is not provided, an
attempt will be made to infer the type from the file name and contents.</p></dd>


<dt id="arg-encoding">encoding<a class="anchor" aria-label="anchor" href="#arg-encoding"></a></dt>
<dd><p>ignored.</p></dd>


<dt id="arg-tz">tz<a class="anchor" aria-label="anchor" href="#arg-tz"></a></dt>
<dd><p>the timezone assumed for the time values stored in the
data file.  Unless the user has set an alternative value in the
<code>~/.Rprofile</code> file, the default will be <code>"UTC"</code>; see the
“Altering oce Defaults” vignette for more on the use
of the <code>~/.Rprofile</code> file.</p></dd>


<dt id="arg-tzoffsetlocation">tzOffsetLocation<a class="anchor" aria-label="anchor" href="#arg-tzoffsetlocation"></a></dt>
<dd><p>offset, in hours, between the CTD clock and
the clock in the controlling computer/tablet/phone (if one was used during
the sampling). This offset is required to relate location information from the
controller to hydrographic information from the CTD, using timestamps as an
index (see "A note on location information" in “Details”).
If the user supplies a value for <code>tzOffsetLocation</code>, then that is used.
If not, an attempt is made to infer it from an item named <code>UTCdelta</code>
that might be present within a table named <code>epochs</code> in the file. If no
value can be inferred from either of these two methods, then
<code>tzOffsetLocation</code> is set to zero.</p></dd>


<dt id="arg-patm">patm<a class="anchor" aria-label="anchor" href="#arg-patm"></a></dt>
<dd><p>controls the handling of atmospheric pressure, an important issue
for RBR instruments that record absolute pressure; see “Details”.</p></dd>


<dt id="arg-alltables">allTables<a class="anchor" aria-label="anchor" href="#arg-alltables"></a></dt>
<dd><p>logical value, TRUE by default, indicating whether to save
all the non-empty tables in the database (pruned of <code>blob</code> columns) in the
<code>metadata</code> slot of the returned object. This may be useful for detailed
analysis.</p></dd>


<dt id="arg-processinglog">processingLog<a class="anchor" aria-label="anchor" href="#arg-processinglog"></a></dt>
<dd><p>if provided, the action item to be stored in the log.
This is typically only provided for internal calls; the default that it provides
is better for normal calls by a user.</p></dd>


<dt id="arg-debug">debug<a class="anchor" aria-label="anchor" href="#arg-debug"></a></dt>
<dd><p>a flag that can be set to <code>TRUE</code> to turn on debugging.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p>An <a href="rsk-class.html">rsk</a> object.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>This can read files produced by several RBR instruments.  At the moment, five
styles are understood: (1) text file produced as an export of an RBR <code>hex</code>
or <code>rsk</code> file; (2) text file with columns for temperature and pressure
(with sampling times indicated in the header); (3) text file with four columns,
in which the date the time of day are given in the first two columns, followed
by the temperature, and pressure; (4) text file with five columns, in which
depth in the water column is given after the pressure; (5) an SQLite-based
database format. The first four options are provided mainly for historical
reasons, since RBR instruments at the date of writing commonly use the SQLite
format, though the first option is common for all instruments that produce a
<code>hex</code> file that can be read using Ruskin.
Options 2-4 are mostly obsolete, and will be removed from future versions.</p>
<p><strong>A note on location information.</strong>
It is possible to couple RBR CTD devices with smart phones or tablets
(see RBR-global, 2020), with the location data from the latter being stored
in the output <code>.rsk</code> file. The format does not seem to be documented by RBR,
but <code>read.rsk()</code> attempts to infer location nevertheless.
The procedure involves comparing the <code>tstamp</code> (time-stamp)
field from the hydrographic part of the dataset (which is in a database
table named <code>data</code>) with the <code>tstamp</code> field in the geographical part of the
dataset (in a table named <code>geodata</code>). (The <code>geodata</code> entries are filtered to
those for which the <code>origin</code> field equals <code>"auto"</code>. This seems to align
with times shown for "LOCATION" data in RBR-provided viewing software.)
The connection between the two fields is done with <code><a href="https://rdrr.io/r/stats/approxfun.html" class="external-link">approx()</a></code>, after
adding <code>tzOffsetLocation</code> (with units converted appropriately) to the
time inferred from <code>geodata$tstamp</code> field, to account for the fact that phones and tablets
may be set to local time. If the procedure succeeds, then <code>longitude</code> and
<code>latitude</code> are inserted into the <code>metadata</code> slot of the return value, in the
form of vectors with the same length as <code>pressure</code> in the <code>data</code> slot.</p>
<p><strong>A note on conductivity.</strong>
RBR devices record conductivity in mS/cm, and it
is this value that is stored in the object returned by <code>read.rsk</code>. This can
be converted to conductivity ratio (which is what many other instruments report)
by dividing by 42.914 (see Culkin and Smith, 1980) which will be necessary in
any seawater-related function that takes conductivity ratio as an argument (see
“Examples”).</p>
<p><strong>A note on pressure.</strong>
RBR devices tend to record absolute pressure (i.e.
sea pressure plus atmospheric pressure), unlike most oceanographic instruments
that record sea pressure (or an estimate thereof).  The handling of pressure
is controlled with the <code>patm</code> argument, for which there are three
possibilities.  (1) If <code>patm</code> is <code>FALSE</code> (the default), then
pressure read from the data file is stored in the <code>data</code> slot of return
value, and the <code>metadata</code> item <code>pressureType</code> is set to the string
<code>"absolute"</code>.  (2) If <code>patm</code> is <code>TRUE</code>, then an estimate of
atmospheric pressure is subtracted from the raw data. For data files in the
SQLite format (i.e.  <code>*.rsk</code> files), this estimate will be the value read
from the file, or the “standard atmosphere” value 10.1325 dbar, if the file
lacks this information.  (3) If <code>patm</code> is a numerical value (or list of
values, one for each sampling time), then `patm` is subtracted from the
raw data.  In cases 2 and 3, an additional column named
`pressureOriginal` is added to the `data` slot to store the value
contained in the data file, and `pressureType` is set to a string
starting with `"sea"`.  See <code><a href="as.ctd.html">as.ctd()</a></code> for details of how this
setup facilitates the conversion of <a href="rsk-class.html">rsk</a> objects to
<a href="ctd-class.html">ctd</a> objects.</p>
    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p>Culkin, F., and Norman D. Smith, 1980. Determination of the concentration of
potassium chloride solution having the same electrical conductivity, at 15 C and
infinite frequency, as standard seawater of salinity 35.0000 ppt (Chlorinity
19.37394 ppt). <em>IEEE Journal of Oceanic Engineering</em>, <strong>5</strong>, pp 22-23.</p>
<p>RBR-global.com, 2020. "Ruskin User Guide." RBR, August 18, 2020.
Revision RBR#0006105revH.</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p>The documentation for <a href="rsk-class.html">rsk</a> explains the structure of
<code>rsk</code> objects, and also outlines other functions dealing with them.  Since
RBR has a wide variety of instruments, <code>rsk</code> datasets can be quite general,
and it is common to coerce <code>rsk</code> objects to other forms for specialized
work, e.g. <code><a href="as.ctd.html">as.ctd()</a></code> can be used to create CTD object, so that the
generic plot obeys the CTD format.</p>
<p>Other things related to rsk data:
<code><a href="sub-sub-rsk-method.html">[[,rsk-method</a></code>,
<code>[[&lt;-,rsk-method</code>,
<code><a href="as.rsk.html">as.rsk</a>()</code>,
<code><a href="ctdFindProfilesRBR.html">ctdFindProfilesRBR</a>()</code>,
<code><a href="plot-rsk-method.html">plot,rsk-method</a></code>,
<code><a href="rsk.html">rsk</a></code>,
<code><a href="rsk-class.html">rsk-class</a></code>,
<code><a href="rskPatm.html">rskPatm</a>()</code>,
<code><a href="rskToc.html">rskToc</a>()</code>,
<code><a href="subset-rsk-method.html">subset,rsk-method</a></code>,
<code><a href="summary-rsk-method.html">summary,rsk-method</a></code></p></div>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Dan Kelley and Clark Richards</p>
    </div>

  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>Developed by Dan Kelley, Clark Richards.</p>
</div>

<div class="pkgdown-footer-right">
  <p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.0.9000.</p>
</div>

    </footer></div>





  </body></html>

