Search is not available for this dataset
text
stringlengths
75
104k
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...
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...
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...
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...
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...
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...
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 ...
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...
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() ...
def bootstrap_falsealarmprob(lspinfo, times, mags, errs, nbootstrap=250, magsarefluxes=False, sigclip=10.0, npeaks=No...
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...
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...
def traptransit_fit_magseries(times, mags, errs, transitparams, sigclip=10.0, plotfit=False, magsarefluxes=False, verbose=True): '''This fits a trapezoid transit mode...
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...
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...
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...
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...
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. ...
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...
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....
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, ...
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...
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...
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, ...
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, ...
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...
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...
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...
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 ...
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...
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...
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...
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 ...
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: ...
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 -----...
def initialize(self, executor, secret): ''' This handles initial setup of the `RequestHandler`. ''' self.executor = executor self.secret = secret
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...
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...
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. ...
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. ...
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....
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): ...
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...
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
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,...
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...
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...
def rfepd_magseries(times, mags, errs, externalparam_arrs, magsarefluxes=False, epdsmooth=True, epdsmooth_sigclip=3.0, epdsmooth_windowsize=21, epdsmooth_func=smooth_magseries_savgol, ...
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), ...
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, ...
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...
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...
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] = ...
def stellingwerf_pdm(times, mags, errs, magsarefluxes=False, startp=None, endp=None, stepsize=1.0e-4, autofreq=True, normalize=False, ...
def analytic_false_alarm_probability(lspinfo, times, conservative_nfreq_eff=True, peakvals=None, inplace=True): '''This returns the analytic false alarm probabilities f...
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...
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...
def consolidate_kepler_fitslc(keplerid, lcfitsdir, normalize=True, headerkeys=LCHEADERKEYS, datakeys=LCDATAKEYS, sapkeys=LCSAPKEYS, pdckeys=...
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 --...
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 ...
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...
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...
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...
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...
def epd_kepler_lightcurve(lcdict, xccol='mom_centr1', yccol='mom_centr2', timestoignore=None, filterflags=True, writetodict=True, epdsmooth=5): '''This runs EPD...
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...
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...
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...
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, ...
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...
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...
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...
def parallel_timebin(lclist, binsizesec, maxobjects=None, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, magcols=None, errcols=None, ...
def parallel_timebin_lcdir(lcdir, binsizesec, maxobjects=None, outdir=None, lcformat='hat-sql', lcformatdir=None, timecols=None, ma...
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...
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...
def serial_varfeatures(lclist, outdir, maxobjects=None, timecols=None, magcols=None, errcols=None, mindet=1000, lcformat='hat-sql', lcfo...
def parallel_varfeatures(lclist, outdir, maxobjects=None, timecols=None, magcols=None, errcols=None, mindet=1000, lcformat='hat-sql', ...
def parallel_varfeatures_lcdir(lcdir, outdir, fileglob=None, maxobjects=None, timecols=None, magcols=None, errcols=None, ...
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...
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 ...
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:: ...
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...
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...
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...
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_...
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...
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...
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...
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...
def spline_fit_magseries(times, mags, errs, period, knotfraction=0.01, maxknots=30, sigclip=30.0, plotfit=False, ignoreinitfail=False, magsarefluxes=False, ...
def savgol_fit_magseries(times, mags, errs, period, windowlength=None, polydeg=2, sigclip=30.0, plotfit=False, magsarefluxes=False, verbose=True): '''Fit a Savitzky-...
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...
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...
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...
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. ''' ...
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, ...
def parallel_cp_pfdir(pfpickledir, outdir, lcbasedir, pfpickleglob='periodfinding-*.pkl*', lclistpkl=None, cprenorm=False, nbrradiusarcsec=60.0, maxnumneighbors=5, ...
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...
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, ...