Пример #1
0
from PyAstronomy.pyaC import ImportCheck

ic = ImportCheck(["numpy", "scipy"], required=["numpy"])

from .XTran import palTrans
from .XTran import forTrans
from .XTran import LimBrightTrans, RmcL, RmcL_Hirano
from .radVel import SinRadVel
from .planetBrightnessPhases import GeomPlanetBrightPhase
from .keplerEllipseModel import KeplerEllipseModel, KeplerRVModel
#from atanProfile import AtanProfile, AtanProfileDamped
from .lineListGaussModel import *
from .voigtAstro import VoigtAstroP
from .LyAProfile import LyaTransmission
from .rotBroadProfile import RotBroadProfile
Пример #2
0
def generalizedESD(x, maxOLs, alpha=0.05, fullOutput=False):
    """
    Carry out a Generalized ESD Test for Outliers.
    
    The Generalized Extreme Studentized Deviate (ESD) test for
    outliers can be used to search for outliers in a univariate
    data set, which approximately follows a normal distribution.
    A description of the algorithm is, e.g., given at
    `Nist <http://www.itl.nist.gov/div898/handbook/eda/section3/eda35h3.htm>`_
    or [Rosner1983]_.
    
    Parameters
    ----------
    maxOLs : int
        Maximum number of outliers in the data set.
    alpha : float, optional
        Significance (default is 0.05).
    fullOutput : boolean, optional
        Determines whether additional return values
        are provided. Default is False.
    
    Returns
    -------
    Number of outliers : int
        The number of data points characterized as
        outliers by the test.
    Indices : list of ints
        The indices of the data points found to
        be outliers.
    R : list of floats, optional
        The values of the "R statistics". Only provided
        if `fullOutput` is set to True.
    L : list of floats, optional
        The lambda values needed to test whether a point
        should be regarded an outlier. Only provided
        if `fullOutput` is set to True.  
    
  """
    ImportCheck(["scipy"], required=["scipy"])
    from scipy.stats import t
    if maxOLs < 1:
        raise(PE.PyAValError("Maximum number of outliers, `maxOLs`, must be > 1.", \
              solution="Specify, e.g., maxOLs = 2"))
    import numpy.ma as ma
    xm = ma.array(x)
    n = len(xm)
    # Compute R-values
    R = []
    L = []
    minds = []
    for i in smo.range(maxOLs + 1):
        # Compute mean and std of x
        xmean = xm.mean()
        xstd = xm.std()
        # Find maximum deviation
        rr = np.abs((xm - xmean) / xstd)
        minds.append(np.argmax(rr))
        R.append(rr[minds[-1]])
        if i >= 1:
            p = 1.0 - alpha / (2.0 * (n - i + 1))
            perPoint = t.ppf(p, n - i - 1)
            L.append((n - i) * perPoint / np.sqrt(
                (n - i - 1 + perPoint**2) * (n - i + 1)))
        # Mask that value and proceed
        xm[minds[-1]] = ma.masked
    # Remove the first entry from R, which is of
    # no meaning for the test
    R.pop(-1)
    # Find the number of outliers
    ofound = False
    for i in smo.range(maxOLs - 1, -1, -1):
        if R[i] > L[i]:
            ofound = True
            break
    # Prepare return value
    if ofound:
        if not fullOutput:
            # There are outliers
            return i + 1, minds[0:i + 1]
        else:
            return i + 1, minds[0:i + 1], R, L, minds
    else:
        # No outliers could be detected
        if not fullOutput:
            # There are outliers
            return 0, []
        else:
            return 0, [], R, L, minds
Пример #3
0
# -*- coding: utf-8 -*-
from __future__ import print_function
from PyAstronomy.pyaC import pyaErrors as PE
from PyAstronomy.pyaC import ImportCheck
import sys

# Check Python version
_majV, _minV = sys.version_info[0:2]
if (_minV < 7) and (_majV == 2):
    PE.warn(
        "funcFit needs 2.7.x or greater. See documentation (Prerequisites) for explanation."
    )

ic = ImportCheck([
    "numpy", "scipy", "pymc", "matplotlib", "matplotlib.pylab", "pyfits",
    "emcee", "progressbar"
])

# Get out if numpy not present
if not ic.check["numpy"]:
    raise(PE.PyARequiredImport("Numpy cannot be imported.", solution="Install numpy (see http://numpy.scipy.org/, you probably should also install SciPy).", \
                               addInfo="The numpy package provides array support for Python and is indispensable in many scientific applications."))

# Check whether fitting modules can be imported
_scoImport = ic.check["scipy"]
_pymcImport = ic.check["pymc"]
_mplImport = ic.check["matplotlib"]

from PyAstronomy.funcFit.utils import *
from .modelRebin import turnIntoRebin, _ModelRebinDocu
from .onedfit import *
Пример #4
0
from PyAstronomy.pyaC import ImportCheck

ic = ImportCheck(["six.moves.tkinter", "matplotlib"], required=["six.moves.tkinter", "matplotlib"])

from .pyaPicker import Picker
from .ffmodelExplorer import FFModelExplorer, FFModelExplorerList, FFModelPlotFit, ffmodelExplorer
from .continuumFinder import ContinuumInteractive
from .interactiveGV import IAGVFit
Пример #5
0
# -*- coding: utf-8 -*-
from __future__ import print_function, division
from PyAstronomy.pyaC import ImportCheck
from PyAstronomy.pyaC import pyaErrors as PE
import six

_ic = ImportCheck([
    "numpy", "quantities", "scipy", "matplotlib", "pyfits", "astropy.io.fits",
    "pandas", "six", "astropy"
],
                  required=["numpy", "scipy"])
_moduleImportStatus = {}

from PyAstronomy.pyasl.asl import *
from PyAstronomy.pyasl.resBased import *


def moduleImportStatus(mode="all"):
    """
    Provide information on model import status.
    
    Parameters
    ----------
    mode : string, {"all", "fail", "success"}, optional
        If 'all' is given, all modules will be shown. If
        'fail' is given, only failures will be shown and
        the opposite in case of 'success'.
  """
    mss = ("all", "fail", "success")
    if not mode in mss:
        raise(PE.PyAValError("Unknown mode: " + str(mode), \
Пример #6
0
from PyAstronomy.pyaC import ImportCheck

ImportCheck(["numpy"], required=["numpy"])

from .pdm import *