Repository: PlasmaPy/PlasmaPy
Pull request #218 (2017-12-28 21:56:41)

Fix example in betafrac doc
Just needed an extra line before the 2nd example to parse it as code. Hopefully with the shiny new CircleCi doc viewing you should be able to see this change in all it's glory!


Patch:
diff --git a/docs/diagnostics/index.rst b/docs/diagnostics/index.rst
new file mode 100644
index 00000000..42d88f51
--- /dev/null
+++ b/docs/diagnostics/index.rst
@@ -0,0 +1,5 @@
+.. py:module:: diagnostics
+
+.. _plasmapy-diagnostics:
+
+.. automodapi:: plasmapy.diagnostics
diff --git a/docs/index.rst b/docs/index.rst
index 7aee910f..e4667826 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -38,6 +38,7 @@ Modules
     :maxdepth: 1
 
     atomic/index
+    diagnostics/index
     mathematics/index
     physics/index
 
diff --git a/plasmapy/__init__.py b/plasmapy/__init__.py
index da070773..4495b309 100644
--- a/plasmapy/__init__.py
+++ b/plasmapy/__init__.py
@@ -52,6 +52,7 @@ def _split_version(version):
     from . import atomic
     from . import mathematics
     from . import physics
+    from . import diagnostics
 except ImportError:
     raise ImportError("Unable to load PlasmaPy subpackages.")
 
diff --git a/plasmapy/diagnostics/__init__.py b/plasmapy/diagnostics/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/plasmapy/diagnostics/langmuir.py b/plasmapy/diagnostics/langmuir.py
new file mode 100644
index 00000000..dcfcf30e
--- /dev/null
+++ b/plasmapy/diagnostics/langmuir.py
@@ -0,0 +1,142 @@
+"""
+Defines the Langmuir analysis module as part of the diagnostics package.
+"""
+
+import numpy as np
+import astropy.units as u
+
+
+class Probe():
+    r"""Class containing various Langmuir probe properties. For the moment
+    cylindrical probes are assumed as spherical ones are generally impractical
+    to make.
+
+    Attributes
+    ----------
+    area : Quantity or array
+        Area or array of areas of the probe(s) in units convertible to m^2.
+
+    config : string, optional
+        Electrode configuration. Possible options are 'single' (default),
+        'double', 'double-asym', 'triple', 'tetra', 'penta'. The electrode
+        configuration must correspond to the number of areas provided.
+
+    """
+    def __init__(self, area=u.m**2, config='single'):
+        # Initialize probe properties
+        self.area = area
+        self.config = config
+
+
+def swept_probe_analysis(potential_sweep, 
+                         measured_current, 
+                         probe, 
+                         ion='H',
+                         method='maxwellian', 
+                         smoothing=None, 
+                         polyorder=3):
+    r"""Performs a Langmuir analysis of a given probe V-I profile in order to
+    obtain various plasma parameters.
+
+    Parameters
+    ----------
+    potential_sweep : Quantity
+        The swept electric potential applied to the probe in units convertible to V.
+
+    measured_current : Quantity
+        The corresponding measured current in units convertible to A.
+
+    probe : Probe
+        An instance of the Probe class containing probe properties.
+
+    ion : string, optional
+        Representation of the ion species. Defaults to Hydrogen.
+
+    method : string, optional
+        The preferred analysis method. Options are 'maxwellian' (default) and
+        'OML', which applies Orbital Motion Limit theory.
+
+    smoothing : string, optional
+        The smoothing method applied to the measured current in order to
+        obtain clean derivatives. Options are None (default) and 'savgol',
+        which uses scipy.signal.savgol_filter. When `smoothing` is 'savgol', 
+        the polynomial order is given by polyorder.
+
+    polyorder : int
+        The order of the polynomial used to smooth the measured current and
+        derivatives if `smoothing` is 'savgol'. Default is 3.
+
+    Returns
+    -------
+    T_e : Quantity
+        Best estimate of the electron temperature in units of eV.
+
+    n_e : Quantity
+        Best estimate of the electron density in units of m^-3.
+
+    n_i : Quantity
+        Best estimate of the ion density in units of m^-3. Equal to n_e
+        unless the OML method is used.
+
+    V_F : Quantity
+        Best estimate of the floating potential in units of V.
+
+    V_P : Quantity
+        Best estimate of the plasma potential in units of V.
+
+    Notes
+    -----
+    Due to the use of different methods to obtain n_e and n_i, the ratio
+    between these does not necessarily give an accurate average ionization.
+    """
+    return
+
+
+def obtain_EEDF(potential_sweep, measured_current, probe):
+    r"""Obtains the Electron Energy Distribution Function of the plasma
+    from the second derivative of the measured current response using
+    Druyvestein's equations.
+
+    Parameters
+    ----------
+    potential_sweep : Quantity
+        The swept electric potential applied to the probe in units convertible to V.
+
+    measured_current : Quantity
+        The corresponding measured current in units convertible to A.
+
+    probe : Probe
+        An instance of the Probe class containing probe properties.
+
+    Returns
+    -------
+    EEDF : ndarray
+        Array containing electron energies in units of eV and their
+        corresponding probabilities in units of eV^-1 m^-3.
+    """
+    return
+
+
+def obtain_EEPF(potential_sweep, measured_current, probe):
+    r"""Obtains the Electron Energy Probability Function of the plasma
+    from the second derivative of the measured current response using
+    Druyvestein's equations.
+
+    Parameters
+    ----------
+    potential_sweep : Quantity
+        The swept electric potential applied to the probe in units convertible to V.
+
+    measured_current : Quantity
+        The corresponding measured current in units convertible to A.
+
+    probe : Probe
+        An instance of the Probe class containing probe properties.
+
+    Returns
+    -------
+    EEPF : ndarray
+        Array of shape (2, N) containing electron energies in units of eV and
+        their corresponding probabilities in units of eV^-3/2 m^-3.
+    """
+    return
diff --git a/plasmapy/utils/checks.py b/plasmapy/utils/checks.py
index 44ea008d..322bc30b 100644
--- a/plasmapy/utils/checks.py
+++ b/plasmapy/utils/checks.py
@@ -151,6 +151,7 @@ def check_relativistic(func=None, betafrac=0.1):
     ...     return 1*u.m/u.s
 
     Passing in a custom `betafrac`
+
     >>> @check_relativistic(betafrac=0.01)
     ... def speed():
     ...     return 1*u.m/u.s


Test patch:
diff --git a/plasmapy/diagnostics/tests/test_langmuir.py b/plasmapy/diagnostics/tests/test_langmuir.py
new file mode 100644
index 00000000..0ff8881e
--- /dev/null
+++ b/plasmapy/diagnostics/tests/test_langmuir.py
@@ -0,0 +1,37 @@
+"""Tests for functions that use Langmuir analysis functions."""
+
+import numpy as np
+
+from plasmapy.diagnostics.langmuir import (swept_probe_analysis,
+                               obtain_EEDF,
+                               obtain_EEPF)
+
+class Test_swept_probe_analysis():
+    def test_no_signal(self):
+        """
+        Checks whether an error is raised when zero signal is passed to the
+        function.
+        """
+        errStr = ("Performing a swept probe analysis should return an error "
+                  "when zero signal is passed, but doesn't.")
+        assert True, errStr
+
+class Test_obtain_EEDF():
+    def test_no_signal(self):
+        """
+        Checks whether an error is raised when zero signal is passed to the
+        function.
+        """
+        errStr = ("Attempting to obtain the EEDF should return an error when "
+                  "zero signal is passed, but doesn't.")
+        assert True, errStr
+
+class Test_obtain_EEPF():
+    def test_no_signal(self):
+        """
+        Checks whether an error is raised when zero signal is passed to the
+        function.
+        """
+        errStr = ("Attempting to obtain the EEPF should return an error when "
+                  "zero signal is passed, but doesn't.")
+        assert True, errStr