Skip to content

Commit

Permalink
hotfixes and documentation improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
PageotD committed Jun 5, 2018
1 parent a041c49 commit 7a89c88
Show file tree
Hide file tree
Showing 59 changed files with 3,137 additions and 176 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.

## [0.1.2] - YYYY-MM-DD

### Added
### Added
- *CHANGELOG.md* in docs/
- *Interface with Geopsy-gpdc* in docs/
- *Particle Swarm Optimization: basics* in docs/
- *Read, write and create SU data* tutorial in docs/
- *Windowing SU data* tutorial in docs/
- *Tapering SU data* tutorial in docs/
- **lib** folder for future C/Fortran libraries
- *nessi.modeling.swm references* in docs/
- *nessi.globopt references* in docs
- *MASW from SU data* tutorial in docs/
- *masw* method in *SU/CWP references* chapter in docs/

### Modified
- add __ZENODO__ DOI in the README.md
- interfaces references documentation
- *Seismic modeling example* now in tutorials
- *SU/CWP references* now in *NeSSI API* chapter
- *Getting started* chapter in docs/

### Fixed
- *wind* method of SUdata() can now apply a window in time and space at the same time.
- *pfilter* method of SUdata() can now handle axis 0 and 1
- *masw* method of SUdata() can now return freq and vel arrays as expected
- *masw* method of SUdata() now handles correctly the *scalco* keyword

## Removed
- *2D seismic modeling* part in docs/ (temporary)

## [0.1.1] - 2018-06-01

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
![Powered by PYTHON](https://www.python.org/static/community_logos/python-powered-w-100x40.png)
![LGPL3 logo](https://www.gnu.org/graphics/lgplv3-88x31.png)

![ZENODO](https://zenodo.org/badge/doi/10.5281/zenodo.1256630.svg)

NeSSI (Near-Surface Seismic Imaging) aims to provide python modules for the rapid development of seismic inversion codes based on the particle swarm optimization method.

NeSSI is an open-source project licensed under the [LGPLv3](https://www.gnu.org/licenses/lgpl-3.0-standalone.html).
Expand Down
48 changes: 48 additions & 0 deletions docs/filtering_SU_data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Filtering SU data
=================

The ``pfilter`` method of ``SUdata()`` allows to apply a zero-phase,
sine-squared tapered filter to the data.

Sine-squared taper
------------------

.. code:: ipython3
# Import numpy and matplotlib
import numpy as np
import matplotlib.pyplot as plt
# Import the SUdata class from nessi.io module
from nessi.io import SUdata
# Declare
dobs = SUdata()
# Read the SU file
dobs.read('data/musc_F50_01.su')
# Create frequency and amplitude arrays for filtering
freq = np.zeros(4, dtype=np.float32)
amps = np.zeros(4, dtype=np.float32)
freq[0] = 10.; freq[1] = 100.; freq[2] = 250.; freq[3] = 300.;
amps[0] = 0.; amps[1] = 1.0; amps[2] = 1.0; amps[3] = 0.0;
# Filtering
dobsf = dobs.pfilter(freq, amps)
.. code:: ipython3
# Plot original and filtered data
fig = plt.figure(figsize=(12,5))
plt.subplot(121)
dobs.image(clip=0.05, label2='trace number', label1='time [s]', title='Original SU data', legend=1)
plt.subplot(122)
dobsf.image(clip=0.05, label2='trace number', label1='time [s]', title='Filtered data', legend=1)
plt.show()
.. image:: images/filtering_SU_data_01.png
6 changes: 5 additions & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ Installation

The installation of NeSSI is not automatized yet (with a setup.py for example) but it is quite simple.

In a terminal, go to the nessi/nessi folder and type: ``make`` .
In a terminal, in the nessi folder, type to compile C and Fortran libraries: ``make`` .

Then, you have to add the path of the nessi package to ``PYTHONPATH``. In your ``.bashrc`` file, add:

``export PYTHONPATH=$PYTHONPATH:/path/to/the/nessi/package``

Regenerate all pathes: ``source ~/.bashrc``.

NeSSI package is now available from python.
Binary file added docs/html/_images/filtering_SU_data_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/masw_SU_data_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/masw_SU_data_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/tapering_SU_data_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/tapering_SU_data_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/tapering_SU_data_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/windowing_SU_data_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/windowing_SU_data_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/html/_images/windowing_SU_data_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions docs/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,21 @@
<li class="toctree-l1"><a class="reference internal" href="../getting_started.html">Getting started</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../seismic_modeling.html">2D elastic seismic modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../seismic_modeling_examples.html">Seismic modeling examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../sucwp_references.html">SU/CWP references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../particle_swarm.html">Particle Swarm Optimization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../interfaces.html">Interfaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nessi_globopt.html">NeSSI global optimization module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nessi_modeling_interfaces.html">nessi.modeling.interfaces references</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../read_write_and_create_SU_data.html">Read, write and create SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../windowing_SU_data.html">Windowing SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../filtering_SU_data.html">Filtering SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tapering_SU_data.html">Tapering SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../masw_SU_data.html">&nbsp;MASW from SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../masw_SU_data.html#normalize-the-dispersion-diagram">Normalize the dispersion diagram</a></li>
<li class="toctree-l1"><a class="reference internal" href="../gpdc_interface.html">Interface with Geopsy-gpdc</a></li>
<li class="toctree-l1"><a class="reference internal" href="../PSO_basics.html">Particle Swarm Optimization: basics</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../nessi_modeling_swm.html">nessi.modeling.swm references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../sucwp_references.html">SU/CWP references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nessi_modeling_interfaces.html">nessi.modeling.interfaces references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nessi_globopt_references.html">nessi.globopt references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../changelog.html">Changelog</a></li>
</ul>

Expand Down
29 changes: 15 additions & 14 deletions docs/html/_modules/nessi/globopt/pso/swarm.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,21 @@
<li class="toctree-l1"><a class="reference internal" href="../../../../getting_started.html">Getting started</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../seismic_modeling.html">2D elastic seismic modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../seismic_modeling_examples.html">Seismic modeling examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../sucwp_references.html">SU/CWP references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../particle_swarm.html">Particle Swarm Optimization</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../interfaces.html">Interfaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../nessi_globopt.html">NeSSI global optimization module</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../nessi_modeling_interfaces.html">nessi.modeling.interfaces references</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../read_write_and_create_SU_data.html">Read, write and create SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../windowing_SU_data.html">Windowing SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../filtering_SU_data.html">Filtering SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../tapering_SU_data.html">Tapering SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../masw_SU_data.html">&nbsp;MASW from SU data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../masw_SU_data.html#normalize-the-dispersion-diagram">Normalize the dispersion diagram</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../gpdc_interface.html">Interface with Geopsy-gpdc</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../PSO_basics.html">Particle Swarm Optimization: basics</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../nessi_modeling_swm.html">nessi.modeling.swm references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../sucwp_references.html">SU/CWP references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../nessi_modeling_interfaces.html">nessi.modeling.interfaces references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../nessi_globopt_references.html">nessi.globopt references</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../changelog.html">Changelog</a></li>
</ul>

Expand Down Expand Up @@ -187,7 +188,7 @@ <h1>Source code for nessi.globopt.pso.swarm</h1><div class="highlight"><pre>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<div class="viewcode-block" id="Swarm"><a class="viewcode-back" href="../../../../nessi_globopt.html#nessi.globopt.Swarm">[docs]</a><span class="k">class</span> <span class="nc">Swarm</span><span class="p">():</span>
<div class="viewcode-block" id="Swarm"><a class="viewcode-back" href="../../../../nessi_globopt_references.html#nessi.globopt.Swarm">[docs]</a><span class="k">class</span> <span class="nc">Swarm</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Swarm</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand All @@ -202,7 +203,7 @@ <h1>Source code for nessi.globopt.pso.swarm</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">misfit</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pspace</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>

<div class="viewcode-block" id="Swarm.init_pspace"><a class="viewcode-back" href="../../../../nessi_globopt.html#nessi.globopt.Swarm.init_pspace">[docs]</a> <span class="k">def</span> <span class="nf">init_pspace</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fmod</span><span class="p">):</span>
<div class="viewcode-block" id="Swarm.init_pspace"><a class="viewcode-back" href="../../../../nessi_globopt_references.html#nessi.globopt.Swarm.init_pspace">[docs]</a> <span class="k">def</span> <span class="nf">init_pspace</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fmod</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Initialiaze parameter space from file</span>

Expand All @@ -225,7 +226,7 @@ <h1>Source code for nessi.globopt.pso.swarm</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">pspace</span><span class="p">[:,</span> <span class="n">ipar</span><span class="p">,</span> <span class="p">:]</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">[:,</span> <span class="n">i</span><span class="p">:</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span>
<span class="n">i</span> <span class="o">+=</span> <span class="mi">3</span></div>

<div class="viewcode-block" id="Swarm.init_particles"><a class="viewcode-back" href="../../../../nessi_globopt.html#nessi.globopt.Swarm.init_particles">[docs]</a> <span class="k">def</span> <span class="nf">init_particles</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nindv</span><span class="p">):</span>
<div class="viewcode-block" id="Swarm.init_particles"><a class="viewcode-back" href="../../../../nessi_globopt_references.html#nessi.globopt.Swarm.init_particles">[docs]</a> <span class="k">def</span> <span class="nf">init_particles</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nindv</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Initialize all the particles of the swarm.</span>

Expand Down Expand Up @@ -285,7 +286,7 @@ <h1>Source code for nessi.globopt.pso.swarm</h1><div class="highlight"><pre>

<span class="k">return</span> <span class="n">vngrid</span>

<span class="k">def</span> <span class="nf">get_gbest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">topology</span><span class="p">,</span> <span class="n">indv</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">ndim</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<div class="viewcode-block" id="Swarm.get_gbest"><a class="viewcode-back" href="../../../../nessi_globopt_references.html#nessi.globopt.Swarm.get_gbest">[docs]</a> <span class="k">def</span> <span class="nf">get_gbest</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">topology</span><span class="p">,</span> <span class="n">indv</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">ndim</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Get gbest particle of the whole swarm or in the neighborhood of</span>
<span class="sd"> a given particle.</span>
Expand Down Expand Up @@ -323,9 +324,9 @@ <h1>Source code for nessi.globopt.pso.swarm</h1><div class="highlight"><pre>
<span class="n">ibest</span> <span class="o">=</span> <span class="n">grid</span><span class="p">[</span><span class="n">indv</span><span class="p">,</span> <span class="n">i</span><span class="p">]</span>
<span class="n">vbest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">misfit</span><span class="p">[</span><span class="n">grid</span><span class="p">[</span><span class="n">indv</span><span class="p">,</span> <span class="n">i</span><span class="p">]]</span>

<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">[</span><span class="n">ibest</span><span class="p">,</span> <span class="p">:,</span> <span class="p">:]</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">history</span><span class="p">[</span><span class="n">ibest</span><span class="p">,</span> <span class="p">:,</span> <span class="p">:]</span></div>

<div class="viewcode-block" id="Swarm.update"><a class="viewcode-back" href="../../../../nessi_globopt.html#nessi.globopt.Swarm.update">[docs]</a> <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<div class="viewcode-block" id="Swarm.update"><a class="viewcode-back" href="../../../../nessi_globopt_references.html#nessi.globopt.Swarm.update">[docs]</a> <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Standard PSO update.</span>

Expand Down
Loading

0 comments on commit 7a89c88

Please sign in to comment.