Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pygmt #203

Closed
wants to merge 15 commits into from
Closed

Pygmt #203

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ LIBNAMEMP = SHTOOLS-mp

F95 = gfortran
PYTHON = python3
JUPYTER = "jupyter nbconvert --ExecutePreprocessor.kernel_name=python3"
JUPYTER = jupyter nbconvert --ExecutePreprocessor.kernel_name=python3
JEKYLL = bundle exec jekyll

PREFIX = /usr/local
SYSLIBPATH = $(PREFIX)/lib

FFTW = "-L$(SYSLIBPATH) -lfftw3 -lm"
FFTW = -L$(SYSLIBPATH) -lfftw3 -lm
LAPACK_UNDERSCORE = 0

SHELL = /bin/sh
Expand Down Expand Up @@ -305,7 +305,7 @@ remove-www:
@-rm -rf $(WWWDEST)

notebooks:
@$(MAKE) -C $(NBDIR) -f Makefile JUPYTER=$(JUPYTER)
@$(MAKE) -C $(NBDIR) -f Makefile JUPYTER="$(JUPYTER)"
@echo "--> Notebook html files created successfully"

remove-notebooks:
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/pages/mydoc/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ If at this point your problem is not resolved, you can

We often make improvements based on user suggestions. Nevertheless, please realize that the developers are very busy and that we are not paid to develop or maintain this archive. We suggest that you open an issue on GitHub describing your suggestion, and we will then flag the issue as a future enhancement.

## How do you pronounce "shtools"?

It is pronounced S-H-Tools.

## I would like to contribute

Please see [this page](how-to-contribute.html).
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/mydoc/implementation-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ For the case of Gauss-Legendre quadrature (`GLQ`), the quadrature is exact when

### Driscoll and Healy [1994]

The second type of grid is for data that are sampled on regular grids. As shown by *Driscoll and Healy* [1994], an exact quadrature exists when the function $$f$$ is sampled at $$N$$ equally spaced nodes in latitude and $$N$$ equally spaced nodes in longitude. For this sampling (`DH`), the grids make use of the longitude band at 90$$^{\circ}$$ N, but not 90$$^{\circ}$$ S, and the number of samples is $$2(L+1)$$, which is always even. Given that the sampling in latitude was imposed a priori, these grids contain almost twice as many samples in latitude as the grids used with Gauss-Legendre quadrature.
The second type of grid is for data that are sampled on regular grids. As shown by *Driscoll and Healy* [1994], an exact quadrature exists when the function $$f$$ is sampled at $$N$$ equally spaced nodes in latitude and $$N$$ equally spaced nodes in longitude. For this sampling (`DH`), the grids make use of the longitude band at 90$$^{\circ}$$ N, but not 90$$^{\circ}$$ S, and the number of samples is $$2(L+1)$$, which is always even. Given that the sampling in latitude was imposed a priori, these grids contain almost twice as many samples in latitude as the grids used with Gauss-Legendre quadrature. It should be noted that for this quadrature, the longitude band at 90$$^{\circ}$$ N is ultimately downweighted to zero, and hence has no influence on the returned spherical harmonic coefficients.

For geographic data, it is common to work with grids that are equally spaced in degrees latitude and longitude. SHTOOLS provides the option of using grids of size $$N\times2N$$, and when performing the Fourier transforms for this case (`DH2`), the coefficients $$c_{lm}$$ and $$s_{lm}$$ with $$m>L$$ are discarded.

Expand Down
11 changes: 5 additions & 6 deletions docs/pages/mydoc/notebooks/Introduction-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -13127,8 +13127,7 @@ <h1 id="Introduction-to-pyshtools">Introduction to pyshtools<a class="anchor-lin
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">print_function</span> <span class="c1"># only necessary if using Python 2.x</span>
<span class="o">%</span><span class="k">matplotlib</span> inline
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">matplotlib</span> inline

<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
Expand All @@ -13143,7 +13142,7 @@ <h1 id="Introduction-to-pyshtools">Introduction to pyshtools<a class="anchor-lin
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>The <em>pyshtools</em> package contains several classes, including <code>SHCoeffs</code>, <code>SHGrid</code>, and <code>SHWindow</code>, a subpackage <code>shtools</code> that contains the Python-wrapped Fortran functions, and a series of subpackages that contain both native python routines and refernces to routines in <code>shtools</code> (<code>constant</code>, <code>legendre</code>, <code>expand</code>, <code>shio</code>, <code>spectralanalysis</code>, <code>rotate</code>, <code>gravmag</code>, and <code>util</code>). The classes <code>SHCoeffs</code>, <code>SHGrid</code>, and <code>SHWindow</code> bundle the vast majority of <em>pyshtools</em> functionality, and in this notebook we will demonstrate how to use the classes related to grids and coefficients.</p>
<p>The <em>pyshtools</em> package contains several classes, including <code>SHCoeffs</code>, <code>SHGrid</code>, and <code>SHWindow</code>, a subpackage <code>shtools</code> that contains the Python-wrapped Fortran functions, and a series of subpackages that contain both native python routines and references to routines in <code>shtools</code> (<code>constant</code>, <code>legendre</code>, <code>expand</code>, <code>shio</code>, <code>spectralanalysis</code>, <code>rotate</code>, <code>gravmag</code>, and <code>util</code>). The classes <code>SHCoeffs</code>, <code>SHGrid</code>, and <code>SHWindow</code> bundle the vast majority of <em>pyshtools</em> functionality, and in this notebook we will demonstrate how to use the classes related to grids and coefficients.</p>

</div>
</div>
Expand Down Expand Up @@ -13218,7 +13217,7 @@ <h2 id="Grid-and-Coefficient-classes">Grid and Coefficient classes<a class="anch
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>This creates a new class instance of <code>SHCoeffs</code> that contains several attributes and methods. For reproducibility, the optional parameter <code>seed</code> specifies the seed of the <em>numpy</em> random number generator. By default, <em>pyshtools</em> assumes that the coefficients are real and that they are normalized using the <code>'4pi'</code> convention exlcuding the Condon-Shortley phase factor. This is the standard normalization in Geodesy and many fields of geophysics and spectral analysis. Other normalizations can be specified explicitly by specifying the optional parameter <code>normalization</code>, which can be <code>'4pi'</code>, <code>'ortho'</code>, <code>'schmidt'</code>, or <code>'unnorm'</code>. The Condon-Shortley phase can be included by setting the optional parameter <code>csphase</code> to <code>-1</code>, and if you wanted complex coefficients, you could set <code>kind='complex'</code>.</p>
<p><code>from_random()</code> is just one way to create a set of spherical harmonic coefficients. The other constructor methods are <code>from_file()</code> to read the coefficients from an <code>shtools</code> or <code>npy</code> formatted file, <code>from_zeros()</code> if you just want all the coefficients to be set to zero, and <code>from_array()</code> if you already have a <em>numpy</em> array of the coefficients.</p>
<p><code>from_random()</code> is just one way to create a set of spherical harmonic coefficients. The other constructor methods are <code>from_file()</code> to read the coefficients from an <code>shtools</code> or <code>npy</code> formatted file, <code>from_zeros()</code> if you just want all the coefficients to be set to zero, <code>from_array()</code> if you already have a <em>numpy</em> array of the coefficients, and <code>from_cap()</code> if you want to return the coefficients of a spherical cap. When reading from a file, if a URL is specified, the data will be downloaded directly from the web site.</p>
<p>Next, let's calculate the power spectrum and plot it. <em>pyshtools</em> provides a built in plotting function to do this, and as we will see below, the power spectrum can also be returned as a <em>numpy</em> array using the <code>spectrum()</code> method.</p>

</div>
Expand Down Expand Up @@ -13616,7 +13615,7 @@ <h2 id="Grid-and-Coefficient-classes">Grid and Coefficient classes<a class="anch
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">clm</span><span class="o">.</span><span class="n">set_coeffs</span><span class="p">(</span><span class="n">values</span><span class="o">=</span><span class="mf">0.</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">ms</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">grid_dh2</span> <span class="o">=</span> <span class="n">clm</span><span class="o">.</span><span class="n">expand</span><span class="p">(</span><span class="n">grid</span><span class="o">=</span><span class="s1">&#39;DH2&#39;</span><span class="p">)</span>
<span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">grid_dh2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">colorbar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">cb_orientation</span><span class="o">=</span><span class="s1">&#39;vertical&#39;</span><span class="p">,</span> <span class="n">cb_label</span><span class="o">=</span><span class="s1">&#39;My data&#39;</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">grid_dh2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">colorbar</span><span class="o">=</span><span class="s1">&#39;vertical&#39;</span><span class="p">,</span> <span class="n">cb_label</span><span class="o">=</span><span class="s1">&#39;My data&#39;</span><span class="p">,</span> <span class="n">show</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">grid_dh2</span><span class="o">.</span><span class="n">info</span><span class="p">()</span>
</pre></div>

Expand Down Expand Up @@ -13668,7 +13667,7 @@ <h2 id="Grid-and-Coefficient-classes">Grid and Coefficient classes<a class="anch
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>If you want to save either the raw spherical harmonic coefficients to a file, or save the raw gridded data to a file, this can be done using the <code>to_file()</code> methods. If you want to extract the grid or coefficients as a <em>numpy</em> array, this can be done using the <code>to_array()</code> methods. Here, we will just extract the first few degrees of the spherical harmonic coefficients and verify that the coefficient was indeed set to zero:</p>
<p>If you want to save either the raw spherical harmonic coefficients to a file, or save the raw gridded data to a file, this can be done using the <code>to_file()</code> methods. If you want to extract the grid or coefficients as a <em>numpy</em> or <em>xarray</em> array, this can be done using the <code>to_array()</code> and <code>to_xarray()</code> methods. If you want to extract the gridded data as a netcdf file that can be used directly with the Generic Mapping Tools (GMT), use <code>to_netcdf()</code>. Here, we will just extract the first few degrees of the spherical harmonic coefficients and verify that the coefficient was indeed set to zero:</p>

</div>
</div>
Expand Down
38 changes: 31 additions & 7 deletions docs/pages/mydoc/notebooks/Introduction-2.html

Large diffs are not rendered by default.

Loading