How to use the mc3.stats.time_avg 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 / tests / test_stats.py View on Github external
def test_timeavg_binstep(binstep):
    maxbins = len(data) // 2
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(data, maxbins, binstep)
    assert len(rms) == len(data) // binstep // 2
github pcubillos / mc3 / tests / test_plots.py View on Github external
def test_rms():
    data = np.random.normal(0, 1.0, nsamples)
    rms, lo, hi, stderr, binsz = ms.time_avg(data)
    ax = mp.rms(binsz, rms, stderr, lo, hi)
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_timeavg_values_red():
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(data, len(data)/10, 5)
    np.testing.assert_almost_equal(rms,    expected_red_rms)
    np.testing.assert_almost_equal(rmslo,  expected_red_rmslo)
    np.testing.assert_almost_equal(rmshi,  expected_red_rmshi)
    np.testing.assert_almost_equal(stderr, expected_red_stderr)
    np.testing.assert_almost_equal(binsz,  expected_binsz)
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_timeavg_values_white():
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(white, len(data)/10, 5)
    np.testing.assert_almost_equal(rms,    expected_white_rms)
    np.testing.assert_almost_equal(rmslo,  expected_white_rmslo)
    np.testing.assert_almost_equal(rmshi,  expected_white_rmshi)
    np.testing.assert_almost_equal(stderr, expected_white_stderr)
    np.testing.assert_almost_equal(binsz,  expected_binsz)
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_timeavg_maxbins(maxbins):
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(data, maxbins)
    assert True
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_timeavg_defaults():
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(data)
    assert len(rms)    == 500
    assert len(rmslo)  == 500
    assert len(rmshi)  == 500
    assert len(stderr) == 500
    assert len(binsz)  == 500
github pcubillos / mc3 / tests / test_stats.py View on Github external
def test_timeavg_data_type(dtype):
    rms, rmslo, rmshi, stderr, binsz = ms.time_avg(dtype(data))
    assert True
github pcubillos / mc3 / mc3 / sampler_driver.py View on Github external
mp.trace(output['posterior'], zchain=output['zchain'],
          burnin=output['burnin'], pnames=texnames[ifree],
          savefile=fname+"_trace.png")
      log.msg("'{:s}'".format(fname+"_trace.png"), indent=2)
      # Pairwise posteriors:
      mp.pairwise(posterior, pnames=texnames[ifree], bestp=best_freepars,
          savefile=fname+"_pairwise.png")
      log.msg("'{:s}'".format(fname+"_pairwise.png"), indent=2)
      # Histograms:
      mp.histogram(posterior, pnames=texnames[ifree], bestp=best_freepars,
          savefile=fname+"_posterior.png",
          quantile=0.683, pdf=pdf, xpdf=xpdf)
      log.msg("'{:s}'".format(fname+"_posterior.png"), indent=2)
      # RMS vs bin size:
      if rms:
          RMS, RMSlo, RMShi, stderr, bs = ms.time_avg(output['best_model']-data)
          mp.rms(bs, RMS, stderr, RMSlo, RMShi, binstep=len(bs)//500+1,
                 savefile=fname+"_RMS.png")
          log.msg("'{:s}'".format(fname+"_RMS.png"), indent=2)
      # Sort of guessing that indparams[0] is the X array for data as in y=y(x):
      if (indparams != []
          and isinstance(indparams[0], (list, tuple, np.ndarray))
          and np.size(indparams[0]) == ndata):
          try:
              mp.modelfit(data, uncert, indparams[0], output['best_model'],
                  savefile=fname+"_model.png")
              log.msg("'{:s}'".format(fname+"_model.png"), indent=2)
          except:
              pass

  # Close the log file if necessary:
  if closelog: