Usage

Start by making sure that you have AsteroGaP installed.

import asterogap

If nothing yells at you, then you’re good and can proceed. If something does seem upset, go back and reinstall.

Reading in Data

The code runs primarily on the command line, where all you really need is a file with columns of time, fluxes (or magnitudes), and flux errors (or magnitude errors). This documentation will go into how you can fully customize your input and how it will effect the run.

By default, the code will assume that the first 3 columns correspond to time, flux, and flux errors respectively and that there is no header. If your file does have a header, you need to specify the columns by including a -c or --columns and listing the names of the columns afterwards (again, in the order of time, flux, and flux error respectively). You do not need to put the names in quotations.

$ python run_gp -f [filename] -d [datadir] -c [time] [flux] [flux error]

In order to read in the data file correctly, the code needs to know that the delimeter of your data is (e.i. is your data separated by whitespace ” ” or by commas “,”). The code will assume commas by default but if your data is seperated by whitespace, then you can indicate that on the command line with a -ws or --whitespace.

$ python run_gp -f [filename] -d [datadir] -ws

Prepping MCMC

The code utilizes MCMC methods to generate results. For more information on MCMC and the package used here, check out Dan Foreman-Mackey’s emcee paper.

There are a couple different parameters that will greatly effect how your MCMC code will run.

  • Walkers/chains (default: 100)

  • Burn-in iterations (default: 2000): the number of steps the MCMC should run through in order to ensure that the chains have converged properly (or the number of iterations to remove from the head of the MCMC chains).

  • Iterations (default: 1000)

$ python run_gp -f [filename] -d [datadir] -w [nwalkers] -b [burn_in] -i [niter]

All of these effect how long it will take for your code to run, with more steps or walkers taking more time.

If you want to multithread the run, you can set the number of threads for the emcee code to use. The default is 1. This is great if you have access to high-performance resources, but if you’re working on a personal computer, just make sure not to set the thread number to more than what your machine can handle.

$ python run_gp -f [filename] -d [datadir] -w [nwalkers] -b [burn_in] -i [niter] -t [threads]

Setting the kernel

For the Gaussian Process kernel, the priors are pre-encoded, but there is the option of setting up a long-term lightcurve profile adjustment kernel. This additional kernel is supposed to account for the gradual change in the lightcurve profile that is naturally seen in most asteroids. Without it, the kernel remains strictly periodic with no fine adjustments to the amplitudes.

This kernel is by default included in the setup, but you can omit it by indicating it on the command line with -k or --kernel.

$ python run_gp -f [filename] -d [datadir] -k

asterogap.run_gp.read_data(filename, datadir='./', cols=None, whitespace=False)[source]

Read in light curve data from asteroid.

asterogap.run_gp.write_data(filename, sampler, asteroid, nwalkers, niter, burn_in)[source]

Write the sampler results as an HDF5 file, with all the other info you might want.

The main powerhouse for this code is the Gaussian Process (GP) class, called GP Fit. With this class, we store all the information regarding the input data, the parameters, the kernel settings, and the results from the MCMC runs.

class asterogap.GP.GPFit(time_stamps, flux, flux_error, kernel_long)[source]
run_emcee(nwalkers, niter, threads, burn_in)[source]

Runs emcee’s mcmc code.

set_gp_kernel()[source]

Sets up the Gaussian Process Kernel that is needed for george.

set_params()[source]

Calculates initial gp parameter values based on data.

set_walker_param_matrix(nwalkers, seed=None)[source]

Creates a matrix of starting parameters for every walker.

asterogap.GP.prior(params, kde)[source]

Calculated the log of the prior values, given parameter values.

Parameters
paramslist

List of all kernel parameters

param[0]float

mean (between 0 and 2)

param[1]float

k1 log constant

param[2]float

k1 log metric

param[3]float

k2 log amplitude (between -10 and 10)

param[4]float

log gamma (log gamma between ####0.1 and 40)

param[5]float

log period (period between ####1h and 24hrs)

Returns
sum_log_priorint

sum of all log priors (-inf if a parameter is out of range)

asterogap.GP.post_lnlikelihood(params, gp, tsample, fsample, flux_err, kde)[source]

Calculates the posterior likelihood from the log prior and log likelihood.

Parameters
paramslist

List of all kernel parameters

Returns
ln_likelihoodfloat

The posterior, unless the posterior is infinite, in which case, -1e25 will be returned instead.