How to use the mc3.utils function in mc3

To help you get started, we’ve selected a few mc3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pcubillos / mc3 / mc3 / stats / stats.py View on Github external
'cred_region',
    'ppf_uniform',
    'ppf_gaussian',
    'dwt_daub4',
    'Loglike',
    'Prior_transform',
    ]

import sys

import numpy as np
import scipy.stats       as ss
import scipy.interpolate as si

from .. import utils as mu
sys.path.append(mu.ROOT + 'mc3/lib/')
import _binarray as ba
import _chisq    as cs
import _dwt      as dwt


def bin_array(data, binsize, uncert=None):
    """
    Compute the binned weighted mean and standard deviation of an array
    using 1/uncert**2 as weights.
    Eq. (4.31) of Data Reduction and Error Analysis for the Physical
    Sciences by Bevington & Robinson).

    Parameters
    ----------
    data: 1D ndarray
        A time-series dataset.
github pcubillos / mc3 / mc3 / sampler_driver.py View on Github external
if ninfo == 7:         # The priors
          prior    = params[4]
          priorlow = params[5]
          priorup  = params[6]
      if ninfo >= 4:         # The stepsize
          pstep    = params[3]
      if ninfo >= 3:         # The boundaries
          pmin     = params[1]
          pmax     = params[2]
      else:
          log.error('Invalid format/shape for params input file.')
      params = params[0]     # The initial guess
  params = np.array(params)

  # Process data and uncertainties:
  data = mu.isfile(data, 'data', log, 'bin', False, not_none=True)
  if np.ndim(data) > 1:
      data, uncert = data
  # Make local 'uncert' a copy, to avoid overwriting:
  if uncert is None:
      log.error("'uncert' is a required argument.")
  uncert = np.copy(uncert)

  # Process the independent parameters:
  if indparams != []:
      indparams = mu.isfile(indparams, 'indparams', log, 'bin', unpack=False)

  if ioff:
      plt.ioff()

  if resume:
      log.msg("\n\n{:s}\n{:s}  Resuming previous MCMC run.\n\n".