Skip to content

Commit

Permalink
update doc from
Browse files Browse the repository at this point in the history
  • Loading branch information
nbren12 committed Sep 16, 2024
1 parent f1300d4 commit d589381
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 72 deletions.
5 changes: 5 additions & 0 deletions _sources/api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ Regridding

.. autofunction:: earth2grid.get_regridder

.. autofunction:: earth2grid.KNNS2Interpolator

.. autofunction:: earth2grid.BilinearInterpolator

Other utilities
---------------

.. autofunction:: earth2grid.healpix.reorder
.. autofunction:: earth2grid.healpix.pad
11 changes: 10 additions & 1 deletion _sources/changelog.md.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v2024.5.2
## latest
- `earth2grid.latlon.BilinearInterpolator` moved to `earth2grid.BilinearInterpolator`

## 2024.8.1

- made visualization dependencies optional
- `healpix.pad` now supports 5d [n, c, f, x, y] shaped arrays.
- Add CUDA implementation of healpix padding (Thorsten Kurth, Mauro Bisson, David Pruitt)

## 2024.5.2

- First publicly available release
28 changes: 5 additions & 23 deletions _sources/installation.md.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
# Installation

## Stable release

To install Earth2 Grid Utilities, run this command in your
terminal:

``` console
$ pip install earth2-grid
```

This is the preferred method to install Earth2 Grid Utilities, as it will always install the most recent stable release.

If you don't have [pip][] installed, this [Python installation guide][]
can guide you through the process.

## From source

The source for Earth2 Grid Utilities can be downloaded from
the [Github repo][].

You can either clone the public repository:

``` console
$ git clone git://github.com/waynerv/earth2-grid
$ git clone git@github.com:NVlabs/earth2grid.git
```

Or download the [tarball][]:

``` console
$ curl -OJL https://github.com/waynerv/earth2-grid/tarball/master
$ curl -OJL https://github.com/NVlabs/earth2-grid/tarball/master
```

Once you have a copy of the source, you can install it with:

``` console
$ pip install .
$ cd earth2grid
$ pip install --no-build-isolation .
```

[pip]: https://pip.pypa.io
[Python installation guide]: http://docs.python-guide.org/en/latest/starting/installation/
[Github repo]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D
[tarball]: https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D/tarball/master
[Github repo]: https://github.com/NVlabs/earth2grid
30 changes: 18 additions & 12 deletions _sources/usage.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
To use Earth2 Grid Utilities in a project

```
import earth2grid
# level is the resolution
level = 6
hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.PixelOrder.XY)
src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64)
z_torch = torch.as_tensor(z)
z_torch = torch.as_tensor(z)
regrid = earth2grid.get_regridder(src, hpx)
z_hpx = regrid(z_torch)
z_hpx.shape
nside = 2**level
reshaped = z_hpx.reshape(12, nside, nside)
>>> import earth2grid
>>> import torch
... # level is the resolution
... level = 6
... hpx = earth2grid.healpix.Grid(level=level, pixel_order=earth2grid.healpix.XY())
... src = earth2grid.latlon.equiangular_lat_lon_grid(32, 64)
... z_torch = torch.cos(torch.deg2rad(torch.tensor(src.lat)))
... z_torch = z_torch.broadcast_to(src.shape)
>>> regrid = earth2grid.get_regridder(src, hpx)
>>> z_hpx = regrid(z_torch)
>>> z_hpx.shape
torch.Size([49152])
>>> nside = 2**level
... reshaped = z_hpx.reshape(12, nside, nside)
... lat_r = hpx.lat.reshape(12, nside, nside)
... lon_r = hpx.lon.reshape(12, nside, nside)
>>> reshaped.shape
torch.Size([12, 64, 64])
```
33 changes: 32 additions & 1 deletion api.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,48 @@ <h2>Regridding<a class="headerlink" href="#regridding" title="Permalink to this
<dd><p>Get a regridder from <cite>src</cite> to <cite>dest</cite></p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="earth2grid.KNNS2Interpolator">
<span class="sig-prename descclassname"><span class="pre">earth2grid.</span></span><span class="sig-name descname"><span class="pre">KNNS2Interpolator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src_lon</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">src_lat</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dest_lon</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dest_lat</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-07</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Regridder</span></span></span><a class="headerlink" href="#earth2grid.KNNS2Interpolator" title="Permalink to this definition"></a></dt>
<dd><p>K-nearest neighbor interpolator with inverse distance weighting</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>src_lon</strong> – (m,) source longitude in degrees E</p></li>
<li><p><strong>src_lat</strong> – (m,) source latitude in degrees N</p></li>
<li><p><strong>dest_lon</strong> – (n,) output longitude in degrees E</p></li>
<li><p><strong>dest_lat</strong> – (n,) output latitude in degrees N</p></li>
<li><p><strong>k</strong> – number of neighbors, default: 1</p></li>
<li><p><strong>eps</strong> – regularization factor for inverse distance weighting. Only used if
k &gt; 1.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="earth2grid.BilinearInterpolator">
<span class="sig-prename descclassname"><span class="pre">earth2grid.</span></span><span class="sig-name descname"><span class="pre">BilinearInterpolator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x_coords</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_coords</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">x_query</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_query</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fill_value</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">nan</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#earth2grid.BilinearInterpolator" title="Permalink to this definition"></a></dt>
<dd><p>Bilinear interpolation for a non-uniform grid</p>
</dd></dl>

</section>
<section id="other-utilities">
<h2>Other utilities<a class="headerlink" href="#other-utilities" title="Permalink to this heading"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="earth2grid.healpix.reorder">
<span class="sig-prename descclassname"><span class="pre">earth2grid.healpix.</span></span><span class="sig-name descname"><span class="pre">reorder</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">src_pixel_order</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">PixelOrder</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">XY</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dest_pixel_order</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">PixelOrder</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">XY</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#earth2grid.healpix.reorder" title="Permalink to this definition"></a></dt>
<dd><p>Reorder x from one pixel order to another</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="earth2grid.healpix.pad">
<span class="sig-prename descclassname"><span class="pre">earth2grid.healpix.</span></span><span class="sig-name descname"><span class="pre">pad</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tensor</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Tensor</span></span></span><a class="headerlink" href="#earth2grid.healpix.pad" title="Permalink to this definition"></a></dt>
<dd><p>Pad each face consistently with its according neighbors in the HEALPix</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x</strong> – The input tensor of shape [N, F, H, W]</p></li>
<li><p><strong>x</strong> – The input tensor of shape [N, F, H, W] or [N, F, C, H, W]</p></li>
<li><p><strong>padding</strong> – the amount of padding</p></li>
</ul>
</dd>
Expand Down
18 changes: 16 additions & 2 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,22 @@

<section id="changelog">
<h1>Changelog<a class="headerlink" href="#changelog" title="Permalink to this heading"></a></h1>
<section id="v2024-5-2">
<h2>v2024.5.2<a class="headerlink" href="#v2024-5-2" title="Permalink to this heading"></a></h2>
<section id="latest">
<h2>latest<a class="headerlink" href="#latest" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">earth2grid.latlon.BilinearInterpolator</span></code> moved to <code class="docutils literal notranslate"><span class="pre">earth2grid.BilinearInterpolator</span></code></p></li>
</ul>
</section>
<section id="id1">
<h2>2024.8.1<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p>made visualization dependencies optional</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">healpix.pad</span></code> now supports 5d [n, c, f, x, y] shaped arrays.</p></li>
<li><p>Add CUDA implementation of healpix padding (Thorsten Kurth, Mauro Bisson, David Pruitt)</p></li>
</ul>
</section>
<section id="id2">
<h2>2024.5.2<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p>First publicly available release</p></li>
</ul>
Expand Down
24 changes: 23 additions & 1 deletion genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,24 @@
<h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#E"><strong>E</strong></a>
<a href="#B"><strong>B</strong></a>
| <a href="#E"><strong>E</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#K"><strong>K</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#T"><strong>T</strong></a>

</div>
<h2 id="B">B</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api.html#earth2grid.BilinearInterpolator">BilinearInterpolator() (in module earth2grid)</a>
</li>
</ul></td>
</tr></table>

<h2 id="E">E</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -71,6 +81,14 @@ <h2 id="G">G</h2>
</ul></td>
</tr></table>

<h2 id="K">K</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api.html#earth2grid.KNNS2Interpolator">KNNS2Interpolator() (in module earth2grid)</a>
</li>
</ul></td>
</tr></table>

<h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand All @@ -91,7 +109,11 @@ <h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api.html#earth2grid.healpix.Grid.reorder">reorder() (earth2grid.healpix.Grid method)</a>

<ul>
<li><a href="api.html#earth2grid.healpix.reorder">(in module earth2grid.healpix)</a>
</li>
</ul></li>
</ul></td>
</tr></table>

Expand Down
25 changes: 6 additions & 19 deletions installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,21 @@

<section id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h1>
<section id="stable-release">
<h2>Stable release<a class="headerlink" href="#stable-release" title="Permalink to this heading"></a></h2>
<p>To install Earth2 Grid Utilities, run this command in your
terminal:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>pip<span class="w"> </span>install<span class="w"> </span>earth2-grid
</pre></div>
</div>
<p>This is the preferred method to install Earth2 Grid Utilities, as it will always install the most recent stable release.</p>
<p>If you don’t have <a class="reference external" href="https://pip.pypa.io">pip</a> installed, this <a class="reference external" href="http://docs.python-guide.org/en/latest/starting/installation/">Python installation guide</a>
can guide you through the process.</p>
</section>
<section id="from-source">
<h2>From source<a class="headerlink" href="#from-source" title="Permalink to this heading"></a></h2>
<p>The source for Earth2 Grid Utilities can be downloaded from
the <a class="reference external" href="https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D">Github repo</a>.</p>
the <a class="reference external" href="https://github.com/NVlabs/earth2grid">Github repo</a>.</p>
<p>You can either clone the public repository:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>clone<span class="w"> </span>git://github.com/waynerv/earth2-grid
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>git<span class="w"> </span>clone<span class="w"> </span>git@github.com:NVlabs/earth2grid.git
</pre></div>
</div>
<p>Or download the <a class="reference external" href="https://github.com/%7B%7B%20cookiecutter.github_username%20%7D%7D/%7B%7B%20cookiecutter.project_slug%20%7D%7D/tarball/master">tarball</a>:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>curl<span class="w"> </span>-OJL<span class="w"> </span>https://github.com/waynerv/earth2-grid/tarball/master
<p>Or download the [tarball][]:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>curl<span class="w"> </span>-OJL<span class="w"> </span>https://github.com/NVlabs/earth2-grid/tarball/master
</pre></div>
</div>
<p>Once you have a copy of the source, you can install it with:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>pip<span class="w"> </span>install<span class="w"> </span>.
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span>earth2grid
<span class="gp">$ </span>pip<span class="w"> </span>install<span class="w"> </span>--no-build-isolation<span class="w"> </span>.
</pre></div>
</div>
</section>
</section>


Expand Down
Binary file modified objects.inv
Binary file not shown.
Loading

0 comments on commit d589381

Please sign in to comment.