Skip to content

Commit

Permalink
made synthetic abundance scene generator method accessible in synth m…
Browse files Browse the repository at this point in the history
…odule
  • Loading branch information
dgeorgiev21 committed Sep 29, 2023
1 parent 6be3aca commit e4065e1
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 16 deletions.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/synth.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: b3e308d8506335cdbde9998bd9328cfb
config: ba262d26c25120d2f9b242da7d115373
tags: 645f666f9bcd5a90fca523b33c5a78b7
16 changes: 11 additions & 5 deletions docs/build/html/_modules/ramanspy/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
<title>ramanspy.core - RamanSPy</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=362ab14a" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?v=135e06be" />
<link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css?v=7f9a90b1" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery.css?v=61a4c737" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-binder.css?v=f4aeca0c" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-dataframe.css?v=2082cf3c" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-rendered-html.css?v=1277b6f3" />
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo-extensions.css?v=36a5483c" />


Expand Down Expand Up @@ -205,7 +209,7 @@
<li class="toctree-l2"><a class="reference internal" href="../../auto_tutorials/vi-analysis/plot_iii_unmixing.html">Built-in unmixing methods</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../auto_tutorials/vi-analysis/plot_iv_integrative_svm.html">Integrative analysis: Support Vector Machine (SVM) classification</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../auto_tutorials/vi-analysis/plot_v_integrative_nn.html">Integrative analysis: Neural Network (NN) classification</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../auto_tutorials/vii%20-%20synth/plot_i_generate_endmembers.html">Generate synthetic endmembers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../auto_tutorials/vii-synth/plot_i_endmembers.html">Generate synthetic spectra</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../../auto_examples/index.html">Examples</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" role="switch" type="checkbox"/><label for="toctree-checkbox-2"><div class="visually-hidden">Toggle navigation of Examples</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul>
Expand Down Expand Up @@ -316,8 +320,8 @@ <h1>Source code for ramanspy.core</h1><div class="highlight"><pre>
<span class="sd"> raman_object = rp.SpectralContainer(spectral_data, spectral_axis)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spectral_data</span><span class="p">,</span> <span class="n">spectral_axis</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">spectral_data</span><span class="p">,</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">spectral_axis</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">spectral_axis</span><span class="p">,</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">spectral_data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">spectral_data</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spectral_axis</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">asarray</span><span class="p">(</span><span class="n">spectral_axis</span><span class="p">)</span>

<span class="c1"># Order data and axis by shift number values</span>
<span class="n">sorted_indices</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spectral_axis</span><span class="o">.</span><span class="n">argsort</span><span class="p">()</span>
Expand Down Expand Up @@ -652,7 +656,9 @@ <h1>Source code for ramanspy.core</h1><div class="highlight"><pre>

</aside>
</div>
</div><script src="../../_static/documentation_options.js?v=5929fcd5"></script>
</div><script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../../_static/doctools.js?v=888ff710"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/scripts/furo.js?v=32e29ea5"></script>
Expand Down
7 changes: 6 additions & 1 deletion docs/build/html/_sources/synth.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ Synthetic spectra
.. autofunction:: generate_spectra


Synthetic fractional abundance scenes
=====================================
.. autofunction:: generate_abundance_scene


Synthetic mixtures
==================
.. autofunction:: mix


Synthetic mixture datasets
==================
==========================
.. autofunction:: generate_mixture_image
4 changes: 3 additions & 1 deletion docs/build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,12 @@ <h2>F</h2>
<h2>G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="synth.html#ramanspy.synth.generate_mixture_image">generate_mixture_image() (in module ramanspy.synth)</a>
<li><a href="synth.html#ramanspy.synth.generate_abundance_scene">generate_abundance_scene() (in module ramanspy.synth)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="synth.html#ramanspy.synth.generate_mixture_image">generate_mixture_image() (in module ramanspy.synth)</a>
</li>
<li><a href="synth.html#ramanspy.synth.generate_spectra">generate_spectra() (in module ramanspy.synth)</a>
</li>
</ul></td>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/loading.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<h1>Data loading<a class="headerlink" href="#data-loading" title="Link to this heading"></a></h1>
<p><cite>RamanSPy</cite> can be used to easily load experimental Raman spectroscopic data from different instruments and manufacturers.
This is enabled through the introduction of custom data loading functions, which can parse and load different data formats
into the appropriate <a class="reference internal" href="auto_tutorials/index.html#data-containers"><span class="std std-ref">Data containers</span></a>.</p>
into the appropriate <a class="reference internal" href="data_classes.html#data-containers"><span class="std std-ref">Data containers</span></a>.</p>
<p>Loading methods are available within the <code class="xref py py-mod docutils literal notranslate"><span class="pre">ramanspy.load</span></code> module.</p>
<section id="witec-suite-witec">
<h2>WITec Suite (WITec)<a class="headerlink" href="#witec-suite-witec" title="Link to this heading"></a></h2>
Expand Down
Binary file modified docs/build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/searchindex.js

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions docs/build/html/synth.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ <h2>Synthetic spectra<a class="headerlink" href="#synthetic-spectra" title="Link
</div>
</dd></dl>

</section>
<section id="synthetic-fractional-abundance-scenes">
<h2>Synthetic fractional abundance scenes<a class="headerlink" href="#synthetic-fractional-abundance-scenes" title="Link to this heading"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="ramanspy.synth.generate_abundance_scene">
<span class="sig-prename descclassname"><span class="pre">ramanspy.synth.</span></span><span class="sig-name descname"><span class="pre">generate_abundance_scene</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_endmembers</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scene_type</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/ramanspy/synth/synth.html#generate_abundance_scene"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#ramanspy.synth.generate_abundance_scene" title="Link to this definition"></a></dt>
<dd><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>size</strong> (<em>int</em>) – The size of the abundance scene. Assumes a square scene (i.e. size x size).</p></li>
<li><p><strong>num_endmembers</strong> (<em>int</em>) – The number of endmembers to use.</p></li>
<li><p><strong>scene_type</strong> (<em>{'chessboard'</em><em>, </em><em>'gaussian'</em><em>, </em><em>'dirichlet'}</em>) – The type of scene to generate.</p></li>
<li><p><strong>seed</strong> (<em>int</em><em>, </em><em>optional</em>) – The seed to use for the random number generator.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>image</strong> – The generated abundance image.</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>array_like, shape (size, size, num_endmembers)</p>
</dd>
</dl>
</dd></dl>

</section>
<section id="synthetic-mixtures">
<h2>Synthetic mixtures<a class="headerlink" href="#synthetic-mixtures" title="Link to this heading"></a></h2>
Expand Down Expand Up @@ -436,6 +460,10 @@ <h2>Synthetic mixture datasets<a class="headerlink" href="#synthetic-mixture-dat
<li><a class="reference internal" href="#ramanspy.synth.generate_spectra"><code class="docutils literal notranslate"><span class="pre">generate_spectra()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#synthetic-fractional-abundance-scenes">Synthetic fractional abundance scenes</a><ul>
<li><a class="reference internal" href="#ramanspy.synth.generate_abundance_scene"><code class="docutils literal notranslate"><span class="pre">generate_abundance_scene()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#synthetic-mixtures">Synthetic mixtures</a><ul>
<li><a class="reference internal" href="#ramanspy.synth.mix"><code class="docutils literal notranslate"><span class="pre">mix()</span></code></a></li>
</ul>
Expand Down
7 changes: 6 additions & 1 deletion docs/source/synth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ Synthetic spectra
.. autofunction:: generate_spectra


Synthetic fractional abundance scenes
=====================================
.. autofunction:: generate_abundance_scene


Synthetic mixtures
==================
.. autofunction:: mix


Synthetic mixture datasets
==================
==========================
.. autofunction:: generate_mixture_image
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ramanspy"
version = "0.2.3"
version = "0.2.4"
description = "RamanSPy: An open-source Python package for integrative Raman spectroscopy data analysis"
readme = "README.md"
authors = [{ name = "Dimitar Georgiev", email = "[email protected]" }]
Expand Down
3 changes: 2 additions & 1 deletion src/ramanspy/synth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .synth import generate_spectra, mix, generate_mixture_image
from .synth import generate_spectra, mix, generate_abundance_scene, generate_mixture_image

__all__ = [
"generate_spectra",
"mix",
"generate_abundance_scene",
"generate_mixture_image",
]
6 changes: 3 additions & 3 deletions src/ramanspy/synth/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ def mix(
return mixtures


def _generate_abundance_image(size, num_endmembers, scene_type, *, seed=None):
def generate_abundance_scene(size, num_endmembers, scene_type, *, seed=None):
"""
Parameters
----------
size : int
The size of the abundance image. Assumes a square image.
The size of the abundance scene. Assumes a square scene (i.e. size x size).
num_endmembers : int
The number of endmembers to use.
scene_type : {'chessboard', 'gaussian', 'dirichlet'}
Expand Down Expand Up @@ -326,7 +326,7 @@ def generate_mixture_image(
"""

endmebers = generate_spectra(num_endmembers, num_spectral_bands, realistic=realistic_endmembers, seed=seed)
abundance_image = _generate_abundance_image(image_size, num_endmembers, image_type, seed=seed)
abundance_image = generate_abundance_scene(image_size, num_endmembers, image_type, seed=seed)

mixture = mix(endmebers, abundance_image, mixture_mode=mixture_mode, noise=noise, noise_amplitude=noise_amplitude,
baseline=baseline, baseline_amplitude=baseline_amplitude, baseline_probability=baseline_probability,
Expand Down

0 comments on commit e4065e1

Please sign in to comment.