<!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>Download and Cache an amsr File — download.amsr • 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="Download and Cache an amsr File — download.amsr"><meta name="description" content='If the file is already present in destdir, then it is not
downloaded again. The default destdir is the present directory,
but it probably makes more sense to use something like "~/data/amsr"
to make it easy for scripts in other directories to use the cached data.
The file is downloaded with download.file().  Please read the
&amp;#8220;History&amp;#8221; section for important details on how download.amsr()
and also read.amsr() have had be altered over the years, to deal
with changes in the directory structure and file format on the
server from which files are downloaded.'><meta property="og:description" content='If the file is already present in destdir, then it is not
downloaded again. The default destdir is the present directory,
but it probably makes more sense to use something like "~/data/amsr"
to make it easy for scripts in other directories to use the cached data.
The file is downloaded with download.file().  Please read the
&amp;#8220;History&amp;#8221; section for important details on how download.amsr()
and also read.amsr() have had be altered over the years, to deal
with changes in the directory structure and file format on the
server from which files are downloaded.'></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>Download and Cache an amsr File</h1>
      <small class="dont-index">Source: <a href="https://github.com/dankelley/oce/blob/HEAD/R/amsr.R" class="external-link"><code>R/amsr.R</code></a></small>
      <div class="d-none name"><code>download.amsr.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>If the file is already present in <code>destdir</code>, then it is not
downloaded again. The default <code>destdir</code> is the present directory,
but it probably makes more sense to use something like <code>"~/data/amsr"</code>
to make it easy for scripts in other directories to use the cached data.
The file is downloaded with <code><a href="https://rdrr.io/r/utils/download.file.html" class="external-link">download.file()</a></code>.  Please read the
“History” section for important details on how <code>download.amsr()</code>
and also <code><a href="read.amsr.html">read.amsr()</a></code> have had be altered over the years, to deal
with changes in the directory structure and file format on the
server from which files are downloaded.</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">download.amsr</span><span class="op">(</span></span>
<span>  year <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  <span class="va">month</span>,</span>
<span>  <span class="va">day</span>,</span>
<span>  destdir <span class="op">=</span> <span class="st">"."</span>,</span>
<span>  server <span class="op">=</span> <span class="st">"https://data.remss.com/amsr2/ocean/L3/v08.2"</span>,</span>
<span>  type <span class="op">=</span> <span class="st">"3day"</span>,</span>
<span>  debug <span class="op">=</span> <span class="fl">0</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-year-month-day">year, month, day<a class="anchor" aria-label="anchor" href="#arg-year-month-day"></a></dt>
<dd><p>a specification of the desired observation time.
There are 3 choices for this specification.  (a) If <code>year</code> is an object
created by <code><a href="https://rdrr.io/r/base/as.Date.html" class="external-link">as.Date()</a></code>, then that specifies the time, and so <code>month</code>
and <code>day</code> are ignored.  This scheme can be convenient for creating a
sequence of images, starting at a particular date, because adding 1
to an object of class <code>Date</code> increases the time by 1 day, saving
the user from having to know how many days are in any given month.
(b) If <code>year</code> is an integer, then it is taken to be the year, and
the user must also specify <code>month</code> and <code>day</code>, also integers. (c)
If <code>year</code> is NULL (which is the default), then the focus is set to
the most recent date, but this depends on the value of
<code>type</code> (see next).  If <code>type</code> is <code>"3day"</code>, <code>"daily"</code> or <code>"weekly"</code>,
or just the first two of them if <code>type</code> is <code>"monthly"</code>.  If these
things are provided, then they just match exactly the values in the
sought-after file on the remote server.  If <code>year</code> is NULL, then
<code>download.amsr()</code> constructs a URL that ought to be the most recent
available file: 3 days prior to the present date (if <code>type</code> is
<code>"3day"</code> or <code>"daily"</code>), the Saturday two weeks prior to the
present date (if <code>type</code> is <code>"weekly"</code>), or two months in the
past (if <code>type</code> is <code>"monthly"</code>).</p></dd>


<dt id="arg-destdir">destdir<a class="anchor" aria-label="anchor" href="#arg-destdir"></a></dt>
<dd><p>A string naming the directory in which to cache the downloaded file.
The default is to store in the present directory, but many users find it more
helpful to use something like <code>"~/data/amsr"</code> for this, to collect all
downloaded amsr files in one place.</p></dd>


<dt id="arg-server">server<a class="anchor" aria-label="anchor" href="#arg-server"></a></dt>
<dd><p>A string naming the server from which data
are to be acquired. See “History”.</p></dd>


<dt id="arg-type">type<a class="anchor" aria-label="anchor" href="#arg-type"></a></dt>
<dd><p>character value indicating where to get the data.  This may be
<code>"3day"</code> (the default), for a composite covering 3 days of observation, which
removes most viewing-path and cloud blanks, <code>"daily"</code> for a daily reading,
<code>"weekly"</code> for a composite covering a week, <code>"monthly"</code> for a composite
covering a month, or <code>"rt"</code> for what seems to be realtime datasets (which
seem to be restricted to the prior few days only).  Note that the <code>"rt"</code>
files store <code>SST</code> and related variables in 3D arrays, as opposed to the
2D arrays used for the other file types.  This is because the ascending
and descending passes are both available; to select a choice for
plotting, use the <code>pass</code> parameter of <code><a href="plot-amsr-method.html">plot,amsr-method()</a></code>.</p></dd>


<dt id="arg-debug">debug<a class="anchor" aria-label="anchor" href="#arg-debug"></a></dt>
<dd><p>an integer specifying whether debugging information is
to be printed during the processing. This is a general parameter that
is used by many <code>oce</code> functions. Generally, setting <code>debug=0</code>
turns off the printing, while higher values suggest that more information
be printed. If one function calls another, it usually reduces the value of
<code>debug</code> first, so that a user can often obtain deeper debugging
by specifying higher <code>debug</code> values.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p><code>download.amsr</code> returns a character value holding the full pathname
of the downloaded file.</p>
    </div>
    <div class="section level2">
    <h2 id="history">History<a class="anchor" aria-label="anchor" href="#history"></a></h2>


<p>Until 25 March 2017, the default server was
<code>"ftp.ssmi.com/amsr2/bmaps_v07.2"</code>, but this was changed when the author
discovered that this FTP site had been changed to require users to create
accounts to register for downloads.  The default was changed to
<code>"http://data.remss.com/amsr2/bmaps_v07.2"</code> on the named date.
This site was found by a web search, but it seems to provide proper data.
It is assumed that users will do some checking on the best source.</p>
<p>On 23 January 2018, it was noticed that the server-url naming convention
had changed, e.g.
<code>http://data.remss.com/amsr2/bmaps_v07.2/y2017/m01/f34_20170114v7.2.gz</code>
becoming
<code>http://data.remss.com/amsr2/bmaps_v08/y2017/m01/f34_20170114v8.gz</code></p>
<p>On 2023-07-26, it was noticed that the server-url naming convention
had changed again, requiring not only the alteration of the default
<code>server</code> value but also the addition of a new parameter named <code>type</code>.
Worse yet the file format had evidently been changed from a gzipped
format to a NetCDF format, which required a complete rewriting
of <code><a href="read.amsr.html">read.amsr()</a></code>.</p>
<p>On 2024-08-17, it was noticed that the server has a directory called <code>rt</code>
which seems to hold realtime data for a few recent days (and a few other
isolated 3-day sequences in the past two years). These files may be
of use in analysis of current events.</p>
    </div>
    <div class="section level2">
    <h2 id="sample-of-usage">Sample of Usage<a class="anchor" aria-label="anchor" href="#sample-of-usage"></a></h2>


<div class="sourceCode"><pre><code><span></span>
<span><span class="co"># The download may take up to about a minute.</span></span>
<span><span class="va">f</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/download.amsr.html">download.amsr</a></span><span class="op">(</span><span class="fl">2023</span>, <span class="fl">7</span>, <span class="fl">27</span>, destdir<span class="op">=</span><span class="st">"~/data/amsr"</span><span class="op">)</span></span>
<span><span class="va">d</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/read.amsr.html">read.amsr</a></span><span class="op">(</span><span class="va">f</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">d</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/mtext.html" class="external-link">mtext</a></span><span class="op">(</span><span class="va">d</span><span class="op">[[</span><span class="st">"filename"</span><span class="op">]</span><span class="op">]</span>, side<span class="op">=</span><span class="fl">3</span>, line<span class="op">=</span><span class="fl">0</span>, adj<span class="op">=</span><span class="fl">0</span><span class="op">)</span></span></code></pre></div>

    </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>Other functions that download files:
<code><a href="download.coastline.html">download.coastline</a>()</code>,
<code><a href="download.met.html">download.met</a>()</code>,
<code><a href="download.topo.html">download.topo</a>()</code></p>
<p>Other functions that plot oce data:
<code><a href="plot-adp-method.html">plot,adp-method</a></code>,
<code><a href="plot-adv-method.html">plot,adv-method</a></code>,
<code><a href="plot-amsr-method.html">plot,amsr-method</a></code>,
<code><a href="plot-argo-method.html">plot,argo-method</a></code>,
<code><a href="plot-bremen-method.html">plot,bremen-method</a></code>,
<code><a href="plot-cm-method.html">plot,cm-method</a></code>,
<code><a href="plot-coastline-method.html">plot,coastline-method</a></code>,
<code><a href="plot-ctd-method.html">plot,ctd-method</a></code>,
<code><a href="plot-gps-method.html">plot,gps-method</a></code>,
<code><a href="plot-ladp-method.html">plot,ladp-method</a></code>,
<code><a href="plot-landsat-method.html">plot,landsat-method</a></code>,
<code><a href="plot-lisst-method.html">plot,lisst-method</a></code>,
<code><a href="plot-lobo-method.html">plot,lobo-method</a></code>,
<code><a href="plot-met-method.html">plot,met-method</a></code>,
<code><a href="plot-odf-method.html">plot,odf-method</a></code>,
<code><a href="plot-rsk-method.html">plot,rsk-method</a></code>,
<code><a href="plot-satellite-method.html">plot,satellite-method</a></code>,
<code><a href="plot-sealevel-method.html">plot,sealevel-method</a></code>,
<code><a href="plot-section-method.html">plot,section-method</a></code>,
<code><a href="plot-tidem-method.html">plot,tidem-method</a></code>,
<code><a href="plot-topo-method.html">plot,topo-method</a></code>,
<code><a href="plot-windrose-method.html">plot,windrose-method</a></code>,
<code><a href="plot-xbt-method.html">plot,xbt-method</a></code>,
<code><a href="plotProfile.html">plotProfile</a>()</code>,
<code><a href="plotScan.html">plotScan</a>()</code>,
<code><a href="plotTS.html">plotTS</a>()</code>,
<code><a href="tidem-class.html">tidem-class</a></code></p>
<p>Other things related to amsr data:
<code><a href="sub-sub-amsr-method.html">[[,amsr-method</a></code>,
<code>[[&lt;-,amsr-method</code>,
<code><a href="amsr.html">amsr</a></code>,
<code><a href="amsr-class.html">amsr-class</a></code>,
<code><a href="composite-amsr-method.html">composite,amsr-method</a></code>,
<code><a href="plot-amsr-method.html">plot,amsr-method</a></code>,
<code><a href="read.amsr.html">read.amsr</a>()</code>,
<code><a href="subset-amsr-method.html">subset,amsr-method</a></code>,
<code><a href="summary-amsr-method.html">summary,amsr-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</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>

