INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Converts given J H Ks mags to an SDSS g magnitude value.
def jhk_to_sdssg(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an SDSS g magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted SDSS g band magnitude. ''' return convert_constant...
Converts given J H Ks mags to an SDSS r magnitude value.
def jhk_to_sdssr(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an SDSS r magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted SDSS r band magnitude. ''' return convert_constant...
Converts given J H Ks mags to an SDSS i magnitude value.
def jhk_to_sdssi(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an SDSS i magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted SDSS i band magnitude. ''' return convert_constant...
Converts given J H Ks mags to an SDSS z magnitude value.
def jhk_to_sdssz(jmag,hmag,kmag): '''Converts given J, H, Ks mags to an SDSS z magnitude value. Parameters ---------- jmag,hmag,kmag : float 2MASS J, H, Ks mags of the object. Returns ------- float The converted SDSS z band magnitude. ''' return convert_constant...
Calculates the GAIA absolute magnitude for object ( or array of objects ).
def absolute_gaia_magnitude(gaia_mag, gaia_parallax_mas, gaia_mag_err=None, gaia_parallax_err_mas=None): '''Calculates the GAIA absolute magnitude for object (or array of objects). Given a G mag and the parallax measured by GAI...
Calculates the Schwarzenberg - Czerny AoV statistic at a test frequency.
def aov_theta(times, mags, errs, frequency, binsize=0.05, minbin=9): '''Calculates the Schwarzenberg-Czerny AoV statistic at a test frequency. Parameters ---------- times,mags,errs : np.array The input time-series and associated errors. frequency : float The test fre...
This is a parallel worker for the function below.
def _aov_worker(task): '''This is a parallel worker for the function below. Parameters ---------- task : tuple This is of the form below:: task[0] = times task[1] = mags task[2] = errs task[3] = frequency task[4] = binsize ...
This calculates a frequency grid for the period finding functions in this module.
def get_frequency_grid(times, samplesperpeak=5, nyquistfactor=5, minfreq=None, maxfreq=None, returnf0dfnf=False): '''This calculates a frequency grid for the period finding functions in this module...
This estimates M: the number of independent frequencies in the periodogram.
def independent_freq_count(frequencies, times, conservative=True): '''This estimates M: the number of independent frequencies in the periodogram. This follows the terminology on page 3 of Zechmeister & Kurster (2009):: M = DELTA_f / delta_f where:: DELTA_f = freq.max() - freq.min() ...
Calculates the false alarm probabilities of periodogram peaks using bootstrap resampling of the magnitude time series.
def bootstrap_falsealarmprob(lspinfo, times, mags, errs, nbootstrap=250, magsarefluxes=False, sigclip=10.0, npeaks=No...
This just puts all of the period - finders on a single periodogram.
def make_combined_periodogram(pflist, outfile, addmethods=False): '''This just puts all of the period-finders on a single periodogram. This will renormalize all of the periodograms so their values lie between 0 and 1, with values lying closer to 1 being more significant. Periodograms that give the same...
Read. epdlc and. tfalc light curves and return a corresponding labelled dict ( if LC from <2012 ) or astropy table ( if > = 2012 ). Each has different keys that can be accessed via. keys ()
def read_original_textlc(lcpath): ''' Read .epdlc, and .tfalc light curves and return a corresponding labelled dict (if LC from <2012) or astropy table (if >=2012). Each has different keys that can be accessed via .keys() Input: lcpath: path (string) to light curve data, which is a textfile wit...
This fits a trapezoid transit model to a magnitude time series.
def traptransit_fit_magseries(times, mags, errs, transitparams, sigclip=10.0, plotfit=False, magsarefluxes=False, verbose=True): '''This fits a trapezoid transit mode...
This decides if a value is to be fit for or is fixed in a model fit.
def _get_value(quantitystr, fitparams, fixedparams): """This decides if a value is to be fit for or is fixed in a model fit. When you want to get the value of some parameter, but you're not sure if it's being fit or if it is fixed. then, e.g. for `period`:: period_value = _get_value('period', fitp...
This returns a BATMAN planetary transit model.
def _transit_model(times, t0, per, rp, a, inc, ecc, w, u, limb_dark, exp_time_minutes=2, supersample_factor=7): '''This returns a BATMAN planetary transit model. Parameters ---------- times : np.array The times at which the model will be evaluated. t0 : float Th...
Assume priors on all parameters have uniform probability.
def _log_prior_transit(theta, priorbounds): ''' Assume priors on all parameters have uniform probability. ''' # priorbounds contains the input priors, and because of how we previously # sorted theta, its sorted keys tell us which parts of theta correspond to # which physical quantities. all...
Given a batman TransitModel and its proposed parameters ( theta ) update the batman params object with the proposed parameters and evaluate the gaussian likelihood.
def _log_likelihood_transit(theta, params, model, t, flux, err_flux, priorbounds): ''' Given a batman TransitModel and its proposed parameters (theta), update the batman params object with the proposed parameters and evaluate the gaussian likelihood. Note: the priorbound...
Given a batman TransitModel and its proposed parameters ( theta ) update the batman params object with the proposed parameters and evaluate the gaussian likelihood.
def _log_likelihood_transit_plus_line(theta, params, model, t, data_flux, err_flux, priorbounds): ''' Given a batman TransitModel and its proposed parameters (theta), update the batman params object with the proposed parameters and evaluate the gaussian likelihood. ...
Evaluate posterior probability given proposed model parameters and the observed flux timeseries.
def log_posterior_transit(theta, params, model, t, flux, err_flux, priorbounds): ''' Evaluate posterior probability given proposed model parameters and the observed flux timeseries. ''' lp = _log_prior_transit(theta, priorbounds) if not np.isfinite(lp): return -np.inf else: r...
Evaluate posterior probability given proposed model parameters and the observed flux timeseries.
def log_posterior_transit_plus_line(theta, params, model, t, flux, err_flux, priorbounds): ''' Evaluate posterior probability given proposed model parameters and the observed flux timeseries. ''' lp = _log_prior_transit_plus_line(theta, priorbounds) if not np....
This fits a Mandel & Agol ( 2002 ) planetary transit model to a flux time series. You can fit and fix whatever parameters you want.
def mandelagol_fit_magseries( times, mags, errs, fitparams, priorbounds, fixedparams, trueparams=None, burninpercent=0.3, plotcorner=False, samplesavpath=False, n_walkers=50, n_mcmc_steps=400, eps=1e-4, skipsampling=False, ...
The model fit by this function is: a Mandel & Agol ( 2002 ) transit PLUS a line. You can fit and fix whatever parameters you want.
def mandelagol_and_line_fit_magseries( times, mags, errs, fitparams, priorbounds, fixedparams, trueparams=None, burninpercent=0.3, plotcorner=False, timeoffset=0, samplesavpath=False, n_walkers=50, n_mcmc_steps=400, eps=1e-4...
This just lists all the filter systems available for TRILEGAL.
def list_trilegal_filtersystems(): ''' This just lists all the filter systems available for TRILEGAL. ''' print('%-40s %s' % ('FILTER SYSTEM NAME','DESCRIPTION')) print('%-40s %s' % ('------------------','-----------')) for key in sorted(TRILEGAL_FILTER_SYSTEMS.keys()): print('%-40s %s...
This queries the TRILEGAL model form downloads results and parses them.
def query_galcoords(gal_lon, gal_lat, filtersystem='sloan_2mass', field_deg2=1.0, usebinaries=True, extinction_sigma=0.1, magnitude_limit=26.0, maglim_filtercol=4, ...
This runs the TRILEGAL query for decimal equatorial coordinates.
def query_radecl(ra, decl, filtersystem='sloan_2mass', field_deg2=1.0, usebinaries=True, extinction_sigma=0.1, magnitude_limit=26.0, maglim_filtercol=4, trilegal_version=1.6, ...
This reads a downloaded TRILEGAL model file.
def read_model_table(modelfile): ''' This reads a downloaded TRILEGAL model file. Parameters ---------- modelfile : str Path to the downloaded model file to read. Returns ------- np.recarray Returns the model table as a Numpy record array. ''' infd = gzip.op...
This compares two values in constant time.
def _time_independent_equals(a, b): ''' This compares two values in constant time. Taken from tornado: https://github.com/tornadoweb/tornado/blob/ d4eb8eb4eb5cc9a6677e9116ef84ded8efba8859/tornado/web.py#L3060 ''' if len(a) != len(b): return False result = 0 if isinstance(a...
Overrides the default serializer for JSONEncoder.
def default(self, obj): '''Overrides the default serializer for `JSONEncoder`. This can serialize the following objects in addition to what `JSONEncoder` can already do. - `np.array` - `bytes` - `complex` - `np.float64` and other `np.dtype` objects Para...
handles initial setup.
def initialize(self, currentdir, assetpath, cplist, cplistfile, executor, readonly, baseurl): ''' handles initial setup. ''' self.currentdir = currentdir self.assetpath = assetpath self.currentproject = cplist self.cplistfile = cplistfile ...
This handles GET requests to the index page.
def get(self): '''This handles GET requests to the index page. TODO: provide the correct baseurl from the checkplotserver options dict, so the frontend JS can just read that off immediately. ''' # generate the project's list of checkplots project_checkplots = self.curr...
This handles GET requests to serve a specific checkplot pickle.
def get(self, checkplotfname): '''This handles GET requests to serve a specific checkplot pickle. This is an AJAX endpoint; returns JSON that gets converted by the frontend into things to render. ''' if checkplotfname: # do the usual safing self.checkp...
This handles POST requests.
def post(self, cpfile): '''This handles POST requests. Also an AJAX endpoint. Updates the persistent checkplot dict using the changes from the UI, and then saves it back to disk. This could definitely be faster by just loading the checkplot into a server-wide shared dict or some...
This handles GET requests for the current checkplot - list. json file.
def get(self): ''' This handles GET requests for the current checkplot-list.json file. Used with AJAX from frontend. ''' # add the reviewed key to the current dict if it doesn't exist # this will hold all the reviewed objects for the frontend if 'reviewed' not ...
This handles POST requests.
def post(self): '''This handles POST requests. Saves the changes made by the user on the frontend back to the current checkplot-list.json file. ''' # if self.readonly is set, then don't accept any changes # return immediately with a 400 if self.readonly: ...
This handles a GET request to run a specified LC tool.
def get(self, cpfile): '''This handles a GET request to run a specified LC tool. Parameters ---------- cpfile : str This is the checkplot file to run the tool on. Returns ------- str Returns a JSON response. Notes -----...
This handles initial setup of the RequestHandler.
def initialize(self, executor, secret): ''' This handles initial setup of the `RequestHandler`. ''' self.executor = executor self.secret = secret
This handles GET requests.
def get(self): '''This handles GET requests. Returns the requested checkplot pickle's information as JSON. Requires a pre-shared secret `key` argument for the operation to complete successfully. This is obtained from a command-line argument. ''' provided_key = self.ge...
This queries the 2MASS DUST service to find the extinction parameters for the given lon lat.
def extinction_query(lon, lat, coordtype='equatorial', sizedeg=5.0, forcefetch=False, cachedir='~/.astrobase/dust-cache', verbose=True, timeout=10.0, jitter=5.0): '''Thi...
This smooths the magseries with a Gaussian kernel.
def smooth_magseries_gaussfilt(mags, windowsize, windowfwhm=7): '''This smooths the magseries with a Gaussian kernel. Parameters ---------- mags : np.array The input mags/flux time-series to smooth. windowsize : int This is a odd integer containing the smoothing window size. ...
This smooths the magseries with a Savitsky - Golay filter.
def smooth_magseries_savgol(mags, windowsize, polyorder=2): '''This smooths the magseries with a Savitsky-Golay filter. Parameters ---------- mags : np.array The input mags/flux time-series to smooth. windowsize : int This is a odd integer containing the smoothing window size. ...
This calculates the difference in mags after EPD coefficients are calculated.
def _old_epd_diffmags(coeff, fsv, fdv, fkv, xcc, ycc, bgv, bge, mag): ''' This calculates the difference in mags after EPD coefficients are calculated. final EPD mags = median(magseries) + epd_diffmags() ''' return -(coeff[0]*fsv**2. + coeff[1]*fsv + coeff[2]*fdv**2....
Detrends a magnitude series given in mag using accompanying values of S in fsv D in fdv K in fkv x coords in xcc y coords in ycc background in bgv and background error in bge. smooth is used to set a smoothing parameter for the fit function. Does EPD voodoo.
def _old_epd_magseries(times, mags, errs, fsv, fdv, fkv, xcc, ycc, bgv, bge, epdsmooth_windowsize=21, epdsmooth_sigclip=3.0, epdsmooth_func=smooth_magseries_signal_medfilt, epdsmooth_extraparams=None): ...
This is the EPD function to fit using a smoothed mag - series.
def _epd_function(coeffs, fsv, fdv, fkv, xcc, ycc, bgv, bge, iha, izd): ''' This is the EPD function to fit using a smoothed mag-series. ''' return (coeffs[0]*fsv*fsv + coeffs[1]*fsv + coeffs[2]*fdv*fdv + coeffs[3]*fdv + coeffs[4]*fkv*fkv + c...
This is the residual function to minimize using scipy. optimize. leastsq.
def _epd_residual(coeffs, mags, fsv, fdv, fkv, xcc, ycc, bgv, bge, iha, izd): ''' This is the residual function to minimize using scipy.optimize.leastsq. ''' f = _epd_function(coeffs, fsv, fdv, fkv, xcc, ycc, bgv, bge, iha, izd) residual = mags - f return residual
This is the residual function to minimize using scipy. optimize. least_squares.
def _epd_residual2(coeffs, times, mags, errs, fsv, fdv, fkv, xcc, ycc, bgv, bge, iha, izd): '''This is the residual function to minimize using scipy.optimize.least_squares. This variant is for :py:func:`.epd_magseries_extparams`. ''' f = _epd_function(coeffs,...
Detrends a magnitude series using External Parameter Decorrelation.
def epd_magseries(times, mags, errs, fsv, fdv, fkv, xcc, ycc, bgv, bge, iha, izd, magsarefluxes=False, epdsmooth_sigclip=3.0, epdsmooth_windowsize=21, epdsmooth_func=smooth_magseries_savgol, epdsmooth_extraparams...
This does EPD on a mag - series with arbitrary external parameters.
def epd_magseries_extparams( times, mags, errs, externalparam_arrs, initial_coeff_guess, magsarefluxes=False, epdsmooth_sigclip=3.0, epdsmooth_windowsize=21, epdsmooth_func=smooth_magseries_savgol, epdsmooth_extraparams=None, object...
This uses a RandomForestRegressor to de - correlate the given magseries.
def rfepd_magseries(times, mags, errs, externalparam_arrs, magsarefluxes=False, epdsmooth=True, epdsmooth_sigclip=3.0, epdsmooth_windowsize=21, epdsmooth_func=smooth_magseries_savgol, ...
This calculates various features related to fitting models to light curves.
def lcfit_features(times, mags, errs, period, fourierorder=5, # these are depth, duration, ingress duration transitparams=(-0.01,0.1,0.1), # these are depth, duration, depth ratio, secphase ebparams=(-0.2,0.3,0.7,0.5), ...
This calculates various periodogram features ( for each periodogram ).
def periodogram_features(pgramlist, times, mags, errs, sigclip=10.0, pdiff_threshold=1.0e-4, sidereal_threshold=1.0e-4, sampling_peak_multiplier=5.0, sampling_startp=None, ...
This calculates various phased LC features for the object.
def phasedlc_features(times, mags, errs, period, nbrtimes=None, nbrmags=None, nbrerrs=None): '''This calculates various phased LC features for the object. Some of the features cal...
This calculates the Stellingwerf PDM theta value at a test frequency.
def stellingwerf_pdm_theta(times, mags, errs, frequency, binsize=0.05, minbin=9): ''' This calculates the Stellingwerf PDM theta value at a test frequency. Parameters ---------- times,mags,errs : np.array The input time-series and associated errors. frequenc...
This is a parallel worker for the function below.
def _stellingwerf_pdm_worker(task): ''' This is a parallel worker for the function below. Parameters ---------- task : tuple This is of the form below:: task[0] = times task[1] = mags task[2] = errs task[3] = frequency task[4] = ...
This runs a parallelized Stellingwerf phase - dispersion minimization ( PDM ) period search.
def stellingwerf_pdm(times, mags, errs, magsarefluxes=False, startp=None, endp=None, stepsize=1.0e-4, autofreq=True, normalize=False, ...
This returns the analytic false alarm probabilities for periodogram peak values.
def analytic_false_alarm_probability(lspinfo, times, conservative_nfreq_eff=True, peakvals=None, inplace=True): '''This returns the analytic false alarm probabilities f...
Converts magnitude measurements in Kepler band to SDSS r band.
def keplermag_to_sdssr(keplermag, kic_sdssg, kic_sdssr): '''Converts magnitude measurements in Kepler band to SDSS r band. Parameters ---------- keplermag : float or array-like The Kepler magnitude value(s) to convert to fluxes. kic_sdssg,kic_sdssr : float or array-like The SDSS g...
This extracts the light curve from a single Kepler or K2 LC FITS file.
def read_kepler_fitslc( lcfits, headerkeys=LCHEADERKEYS, datakeys=LCDATAKEYS, sapkeys=LCSAPKEYS, pdckeys=LCPDCKEYS, topkeys=LCTOPKEYS, apkeys=LCAPERTUREKEYS, appendto=None, normalize=False, ): '''This extracts the light curve from a single Kepl...
This gets all Kepler/ K2 light curves for the given keplerid in lcfitsdir.
def consolidate_kepler_fitslc(keplerid, lcfitsdir, normalize=True, headerkeys=LCHEADERKEYS, datakeys=LCDATAKEYS, sapkeys=LCSAPKEYS, pdckeys=...
This reads a K2 SFF ( Vandenberg + 2014 ) light curve into an lcdict.
def read_k2sff_lightcurve(lcfits): '''This reads a K2 SFF (Vandenberg+ 2014) light curve into an `lcdict`. Use this with the light curves from the K2 SFF project at MAST. Parameters ---------- lcfits : str The filename of the FITS light curve file downloaded from MAST. Returns --...
This writes the lcdict to a Python pickle.
def kepler_lcdict_to_pkl(lcdict, outfile=None): '''This writes the `lcdict` to a Python pickle. Parameters ---------- lcdict : lcdict This is the input `lcdict` to write to a pickle. outfile : str or None If this is None, the object's Kepler ID/EPIC ID will determined from the ...
This turns the pickled lightcurve file back into an lcdict.
def read_kepler_pklc(picklefile): '''This turns the pickled lightcurve file back into an `lcdict`. Parameters ---------- picklefile : str The path to a previously written Kepler LC picklefile generated by `kepler_lcdict_to_pkl` above. Returns ------- lcdict Return...
This filters the Kepler lcdict removing nans and bad observations.
def filter_kepler_lcdict(lcdict, filterflags=True, nanfilter='sap,pdc', timestoignore=None): '''This filters the Kepler `lcdict`, removing nans and bad observations. By default, this function removes points in the Kepler LC that hav...
This is the EPD function to fit.
def _epd_function(coeffs, fluxes, xcc, ycc, bgv, bge): '''This is the EPD function to fit. Parameters ---------- coeffs : array-like of floats Contains the EPD coefficients that will be used to generate the EPD fit function. fluxes : array-like The flux measurement array b...
This is the residual function to minimize using scipy. optimize. leastsq.
def _epd_residual(coeffs, fluxes, xcc, ycc, bgv, bge): '''This is the residual function to minimize using scipy.optimize.leastsq. Parameters ---------- coeffs : array-like of floats Contains the EPD coefficients that will be used to generate the EPD fit function. fluxes : array-li...
This runs EPD on the Kepler light curve.
def epd_kepler_lightcurve(lcdict, xccol='mom_centr1', yccol='mom_centr2', timestoignore=None, filterflags=True, writetodict=True, epdsmooth=5): '''This runs EPD...
This uses a RandomForestRegressor to fit and decorrelate Kepler light curves.
def rfepd_kepler_lightcurve( lcdict, xccol='mom_centr1', yccol='mom_centr2', timestoignore=None, filterflags=True, writetodict=True, epdsmooth=23, decorr='xcc,ycc', nrftrees=200 ): '''This uses a `RandomForestRegressor` to fit and decorrelate K...
Detrends the x and y coordinate centroids for a Kepler light curve.
def detrend_centroid(lcd, detrend='legendre', sigclip=None, mingap=0.5): '''Detrends the x and y coordinate centroids for a Kepler light curve. Given an `lcdict` for a single quarter of Kepler data, returned by `read_kepler_fitslc`, this function returns this same dictionary, appending detrended centro...
After running detrend_centroid this gets positions of centroids during transits and outside of transits.
def get_centroid_offsets(lcd, t_ing_egr, oot_buffer_time=0.1, sample_factor=3): '''After running `detrend_centroid`, this gets positions of centroids during transits, and outside of transits. These positions can then be used in a false positive analysis. This routine requires knowing the ingress and e...
This is a helper function for centroid detrending.
def _get_legendre_deg_ctd(npts): '''This is a helper function for centroid detrending. ''' from scipy.interpolate import interp1d degs = nparray([4,5,6,10,15]) pts = nparray([1e2,3e2,5e2,1e3,3e3]) fn = interp1d(pts, degs, kind='linear', bounds_error=False, ...
This calculates the residual and chi - sq values for a Legendre function fit.
def _legendre_dtr(x, y, y_err, legendredeg=10): '''This calculates the residual and chi-sq values for a Legendre function fit. Parameters ---------- x : np.array Array of the independent variable. y : np.array Array of the dependent variable. y_err : np.array Arra...
This bins the given light curve file in time using the specified bin size.
def timebinlc(lcfile, binsizesec, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, magcols=None, errcols=None, minbinelems=7): '''This bins the given light curve file in time using the s...
This is a parallel worker for the function below.
def timebinlc_worker(task): ''' This is a parallel worker for the function below. Parameters ---------- task : tuple This is of the form:: task[0] = lcfile task[1] = binsizesec task[3] = {'outdir','lcformat','lcformatdir', 'timeco...
This time - bins all the LCs in the list using the specified bin size.
def parallel_timebin(lclist, binsizesec, maxobjects=None, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, magcols=None, errcols=None, ...
This time bins all the light curves in the specified directory.
def parallel_timebin_lcdir(lcdir, binsizesec, maxobjects=None, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, ma...
This runs: py: func: astrobase. varclass. varfeatures. all_nonperiodic_features on a single LC file.
def get_varfeatures(lcfile, outdir, timecols=None, magcols=None, errcols=None, mindet=1000, lcformat='hat-sql', lcformatdir=None): '''This runs :py:func:`astrobase.varclass.var...
This wraps varfeatures.
def _varfeatures_worker(task): ''' This wraps varfeatures. ''' try: (lcfile, outdir, timecols, magcols, errcols, mindet, lcformat, lcformatdir) = task return get_varfeatures(lcfile, outdir, timecols=timecols, magcol...
This runs variability feature extraction for a list of LCs.
def serial_varfeatures(lclist, outdir, maxobjects=None, timecols=None, magcols=None, errcols=None, mindet=1000, lcformat='hat-sql', lcfo...
This runs variable feature extraction in parallel for all LCs in lclist.
def parallel_varfeatures(lclist, outdir, maxobjects=None, timecols=None, magcols=None, errcols=None, mindet=1000, lcformat='hat-sql', ...
This runs parallel variable feature extraction for a directory of LCs.
def parallel_varfeatures_lcdir(lcdir, outdir, fileglob=None, maxobjects=None, timecols=None, magcols=None, errcols=None, ...
This reads the checkplot pickle or dict provided and writes out a PNG.
def checkplot_pickle_to_png( checkplotin, outfile, extrarows=None ): '''This reads the checkplot pickle or dict provided, and writes out a PNG. The output PNG contains most of the information in the input checkplot pickle/dict, and can be used to quickly glance through the highlight...
This is just a shortened form of the function above for convenience.
def cp2png(checkplotin, extrarows=None): '''This is just a shortened form of the function above for convenience. This only handles pickle files as input. Parameters ---------- checkplotin : str File name of a checkplot pickle file to convert to a PNG. extrarows : list of tuples ...
This is a flare model function similar to Kowalski + 2011.
def flare_model(flareparams, times, mags, errs): '''This is a flare model function, similar to Kowalski+ 2011. From the paper by Pitkin+ 2014: http://adsabs.harvard.edu/abs/2014MNRAS.445.2268P Parameters ---------- flareparams : list of float This defines the flare model:: ...
This returns the residual between model mags and the actual mags.
def flare_model_residual(flareparams, times, mags, errs): ''' This returns the residual between model mags and the actual mags. Parameters ---------- flareparams : list of float This defines the flare model:: [amplitude, flare_peak_time, rise_gaussian...
This periodically cleans up the ~/. astrobase cache to save us from disk - space doom.
def cache_clean_handler(min_age_hours=1): """This periodically cleans up the ~/.astrobase cache to save us from disk-space doom. Parameters ---------- min_age_hours : int Files older than this number of hours from the current time will be deleted. Returns ------- Noth...
This checks the AWS instance data URL to see if there s a pending shutdown for the instance.
def shutdown_check_handler(): """This checks the AWS instance data URL to see if there's a pending shutdown for the instance. This is useful for AWS spot instances. If there is a pending shutdown posted to the instance data URL, we'll use the result of this function break out of the processing loop...
This sends checkplot making tasks to the input queue and monitors the result queue for task completion.
def runcp_producer_loop( lightcurve_list, input_queue, input_bucket, result_queue, result_bucket, pfresult_list=None, runcp_kwargs=None, process_list_slice=None, purge_queues_when_done=False, delete_queues_when_done=False, download_...
This wraps the function above to allow for loading previous state from a file.
def runcp_producer_loop_savedstate( use_saved_state=None, lightcurve_list=None, input_queue=None, input_bucket=None, result_queue=None, result_bucket=None, pfresult_list=None, runcp_kwargs=None, process_list_slice=None, download_when_done=T...
This runs checkplot pickle making in a loop until interrupted.
def runcp_consumer_loop( in_queue_url, workdir, lclist_pkl_s3url, lc_altexts=('',), wait_time_seconds=5, cache_clean_timer_seconds=3600.0, shutdown_check_timer_seconds=60.0, sqs_client=None, s3_client=None ): """This runs checkplot pickle maki...
This runs period - finding in a loop until interrupted.
def runpf_consumer_loop( in_queue_url, workdir, lc_altexts=('',), wait_time_seconds=5, shutdown_check_timer_seconds=60.0, sqs_client=None, s3_client=None ): """This runs period-finding in a loop until interrupted. Consumes work task items from an input qu...
This fits a double inverted gaussian EB model to a magnitude time series.
def gaussianeb_fit_magseries(times, mags, errs, ebparams, sigclip=10.0, plotfit=False, magsarefluxes=False, verbose=True): '''This fits a double inverted gaussian EB model...
This fits a univariate cubic spline to the phased light curve.
def spline_fit_magseries(times, mags, errs, period, knotfraction=0.01, maxknots=30, sigclip=30.0, plotfit=False, ignoreinitfail=False, magsarefluxes=False, ...
Fit a Savitzky - Golay filter to the magnitude/ flux time series.
def savgol_fit_magseries(times, mags, errs, period, windowlength=None, polydeg=2, sigclip=30.0, plotfit=False, magsarefluxes=False, verbose=True): '''Fit a Savitzky-...
Fit an arbitrary - order Legendre series via least squares to the magnitude/ flux time series.
def legendre_fit_magseries(times, mags, errs, period, legendredeg=10, sigclip=30.0, plotfit=False, magsarefluxes=False, verbose=True): '''Fit an arbitrary-order Legendre series, vi...
For all neighbors in a checkplotdict make LCs and phased LCs.
def update_checkplotdict_nbrlcs( checkplotdict, timecol, magcol, errcol, lcformat='hat-sql', lcformatdir=None, verbose=True, ): '''For all neighbors in a checkplotdict, make LCs and phased LCs. Parameters ---------- checkplotdict : dict This is the chec...
This makes a checkplot pickle for the given period - finding result pickle produced by lcproc. periodfinding. runpf.
def runcp( pfpickle, outdir, lcbasedir, lcfname=None, cprenorm=False, lclistpkl=None, nbrradiusarcsec=60.0, maxnumneighbors=5, makeneighborlcs=True, fast_mode=False, gaia_max_timeout=60.0, gaia_mirror=None, xmatchinf...
This is the worker for running checkplots.
def runcp_worker(task): ''' This is the worker for running checkplots. Parameters ---------- task : tuple This is of the form: (pfpickle, outdir, lcbasedir, kwargs). Returns ------- list of str The list of checkplot pickles returned by the `runcp` function. ''' ...
This drives the parallel execution of runcp for a list of periodfinding result pickles.
def parallel_cp( pfpicklelist, outdir, lcbasedir, fast_mode=False, lcfnamelist=None, cprenorm=False, lclistpkl=None, gaia_max_timeout=60.0, gaia_mirror=None, nbrradiusarcsec=60.0, maxnumneighbors=5, makeneighborlcs=True, ...
This drives the parallel execution of runcp for a directory of periodfinding pickles.
def parallel_cp_pfdir(pfpickledir, outdir, lcbasedir, pfpickleglob='periodfinding-*.pkl*', lclistpkl=None, cprenorm=False, nbrradiusarcsec=60.0, maxnumneighbors=5, ...
This runs the period - finding for a single LC.
def runpf(lcfile, outdir, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=None, pfmethods=('gls','pdm','mav','win'), pfkwargs=({},{},{},{}), sigclip=10.0, getblssnr=False, nworkers=NC...
This runs the runpf function.
def _runpf_worker(task): ''' This runs the runpf function. ''' (lcfile, outdir, timecols, magcols, errcols, lcformat, lcformatdir, pfmethods, pfkwargs, getblssnr, sigclip, nworkers, minobservations, excludeprocessed) = task if os.path.exists(lcfile): pfresult = runpf(lcfile, ...