Search is not available for this dataset
text
stringlengths
75
104k
def parallel_pf(lclist, outdir, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=None, pfmethods=('gls','pdm','mav','win'), pfkwargs=({},{},{},{}), si...
def parallel_pf_lcdir(lcdir, outdir, fileglob=None, recursive=True, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=N...
def collect_nonperiodic_features( featuresdir, magcol, outfile, pklglob='varfeatures-*.pkl', featurestouse=NONPERIODIC_FEATURES_TO_COLLECT, maxobjects=None, labeldict=None, labeltype='binary', ): '''This collects variability features into arrays for us...
def train_rf_classifier( collected_features, test_fraction=0.25, n_crossval_iterations=20, n_kfolds=5, crossval_scoring_metric='f1', classifier_to_pickle=None, nworkers=-1, ): '''This gets the best RF classifier after running cross-validation. - splits t...
def apply_rf_classifier(classifier, varfeaturesdir, outpickle, maxobjects=None): '''This applys an RF classifier trained using `train_rf_classifier` to varfeatures pickles in `varfeaturesdir`. Parameters ---------- classifier ...
def plot_training_results(classifier, classlabels, outfile): '''This plots the training results from the classifier run on the training set. - plots the confusion matrix - plots the feature importances - FIXME: plot the learning curves too, see:...
def _fourier_func(fourierparams, phase, mags): '''This returns a summed Fourier cosine series. Parameters ---------- fourierparams : list This MUST be a list of the following form like so:: [period, epoch, [amplitude_1, amplitude_2, amplitude_3, ..., ampl...
def _fourier_chisq(fourierparams, phase, mags, errs): '''This is the chisq objective function to be minimized by `scipy.minimize`. The parameters are the same as `_fourier_func` above. `errs` is used to calculate the chisq value. ''' f = _f...
def _fourier_residual(fourierparams, phase, mags): ''' This is the residual objective function to be minimized by `scipy.leastsq`. The parameters are the same as `_fourier_func` above. ''' f = _fourier_func(fourierparams, phase, mags) residual = mag...
def fourier_fit_magseries(times, mags, errs, period, fourierorder=None, fourierparams=None, sigclip=3.0, magsarefluxes=False, plotfit=False, ignoreinitfail=True, ...
def plot_magseries(times, mags, magsarefluxes=False, errs=None, out=None, sigclip=30.0, normto='globalmedian', normmingap=4.0, timebin=None, yrange=N...
def plot_phased_magseries(times, mags, period, epoch='min', fitknotfrac=0.01, errs=None, magsarefluxes=False, normto='globalmedian', ...
def skyview_stamp(ra, decl, survey='DSS2 Red', scaling='Linear', flip=True, convolvewith=None, forcefetch=False, cachedir='~/.astrobase/stamp-cache', timeout=10.0, retry_failed...
def fits_finder_chart( fitsfile, outfile, fitsext=0, wcsfrom=None, scale=ZScaleInterval(), stretch=LinearStretch(), colormap=plt.cm.gray_r, findersize=None, finder_coordlimits=None, overlay_ra=None, overlay_decl=None, overla...
def plot_periodbase_lsp(lspinfo, outfile=None, plotdpi=100): '''Makes a plot of periodograms obtained from `periodbase` functions. This takes the output dict produced by any `astrobase.periodbase` period-finder function or a pickle filename containing such a dict and makes a periodogram plot. Par...
def read_hatpi_textlc(lcfile): ''' This reads in a textlc that is complete up to the TFA stage. ''' if 'TF1' in lcfile: thiscoldefs = COLDEFS + [('itf1',float)] elif 'TF2' in lcfile: thiscoldefs = COLDEFS + [('itf2',float)] elif 'TF3' in lcfile: thiscoldefs = COLDEFS + ...
def lcdict_to_pickle(lcdict, outfile=None): '''This just writes the lcdict to a pickle. If outfile is None, then will try to get the name from the lcdict['objectid'] and write to <objectid>-hptxtlc.pkl. If that fails, will write to a file named hptxtlc.pkl'. ''' if not outfile and lcdict['obj...
def read_hatpi_pklc(lcfile): ''' This just reads a pickle LC. Returns an lcdict. ''' try: if lcfile.endswith('.gz'): infd = gzip.open(lcfile,'rb') else: infd = open(lcfile,'rb') lcdict = pickle.load(infd) infd.close() return lcdict ...
def concatenate_textlcs(lclist, sortby='rjd', normalize=True): '''This concatenates a list of light curves. Does not care about overlaps or duplicates. The light curves must all be from the same aperture. The intended use is to concatenate light curves a...
def concatenate_textlcs_for_objectid(lcbasedir, objectid, aperture='TF1', postfix='.gz', sortby='rjd', normalize=True, ...
def concat_write_pklc(lcbasedir, objectid, aperture='TF1', postfix='.gz', sortby='rjd', normalize=True, outdir=None, recursive=True): '''This concatenates all tex...
def parallel_concat_worker(task): ''' This is a worker for the function below. task[0] = lcbasedir task[1] = objectid task[2] = {'aperture','postfix','sortby','normalize','outdir','recursive'} ''' lcbasedir, objectid, kwargs = task try: return concat_write_pklc(lcbasedir, obj...
def parallel_concat_lcdir(lcbasedir, objectidlist, aperture='TF1', postfix='.gz', sortby='rjd', normalize=True, outdir=None, recursive=Tru...
def merge_hatpi_textlc_apertures(lclist): '''This merges all TFA text LCs with separate apertures for a single object. The framekey column will be used as the join column across all light curves in lclist. Missing values will be filled in with nans. This function assumes all light curves are in the for...
def read_hatpi_binnedlc(binnedpklf, textlcf, timebinsec): '''This reads a binnedlc pickle produced by the HATPI prototype pipeline. Converts it into a standard lcdict as produced by the read_hatpi_textlc function above by using the information in unbinnedtextlc for the same object. Adds a 'binned'...
def generate_hatpi_binnedlc_pkl(binnedpklf, textlcf, timebinsec, outfile=None): ''' This reads the binned LC and writes it out to a pickle. ''' binlcdict = read_hatpi_binnedlc(binnedpklf, textlcf, timebinsec) if binlcdict: if outfile is None: ou...
def parallel_gen_binnedlc_pkls(binnedpkldir, textlcdir, timebinsec, binnedpklglob='*binned*sec*.pkl', textlcglob='*.tfalc.TF1*'): ''' This generates the binnedlc pkls for a directory of su...
def pklc_fovcatalog_objectinfo( pklcdir, fovcatalog, fovcatalog_columns=[0,1,2, 6,7, 8,9, 10,11, 13,14,15,16, 17,18,19, 20,21], ...
def _base64_to_file(b64str, outfpath, writetostrio=False): '''This converts the base64 encoded string to a file. Parameters ---------- b64str : str A base64 encoded strin that is the output of `base64.b64encode`. outfpath : str The path to where the file will be written. This shou...
def _read_checkplot_picklefile(checkplotpickle): '''This reads a checkplot gzipped pickle file back into a dict. NOTE: the try-except is for Python 2 pickles that have numpy arrays in them. Apparently, these aren't compatible with Python 3. See here: http://stackoverflow.com/q/11305790 The workar...
def _write_checkplot_picklefile(checkplotdict, outfile=None, protocol=None, outgzip=False): '''This writes the checkplotdict to a (gzipped) pickle file. Parameters ---------- checkplotdict : dict T...
def get_phased_quantities(stimes, smags, serrs, period): '''Does phase-folding for the mag/flux time-series given a period. Given finite and sigma-clipped times, magnitudes, and errors, along with the period at which to phase-fold the data, perform the phase-folding and return the phase-folded values. ...
def make_fit_plot(phase, pmags, perrs, fitmags, period, mintime, magseriesepoch, plotfit, magsarefluxes=False, wrap=False, model_over_lc=False): '''This makes a plot of the LC model fit. Parameters ---------- pha...
def objectlist_conesearch(racenter, declcenter, searchradiusarcsec, gaia_mirror=None, columns=('source_id', 'ra','dec', 'phot_g_mean_mag', ...
def objectlist_radeclbox(radeclbox, gaia_mirror=None, columns=('source_id', 'ra','dec', 'phot_g_mean_mag', 'l','b', 'parallax, paralla...
def objectid_search(gaiaid, gaia_mirror=None, columns=('source_id', 'ra','dec', 'phot_g_mean_mag', 'phot_bp_mean_mag', 'phot_rp_mean_mag', ...
def generalized_lsp_value(times, mags, errs, omega): '''Generalized LSP value for a single omega. The relations used are:: P(w) = (1/YY) * (YC*YC/CC + YS*YS/SS) where: YC, YS, CC, and SS are all calculated at T and where: tan 2omegaT = 2*CS/(CC - SS) and where: Y = ...
def generalized_lsp_value_withtau(times, mags, errs, omega): '''Generalized LSP value for a single omega. This uses tau to provide an arbitrary time-reference point. The relations used are:: P(w) = (1/YY) * (YC*YC/CC + YS*YS/SS) where: YC, YS, CC, and SS are all calculated at T ...
def generalized_lsp_value_notau(times, mags, errs, omega): ''' This is the simplified version not using tau. The relations used are:: W = sum (1.0/(errs*errs) ) w_i = (1/W)*(1/(errs*errs)) Y = sum( w_i*y_i ) C = sum( w_i*cos(wt_i) ) S = sum( w_i*sin(wt_i) ) ...
def specwindow_lsp_value(times, mags, errs, omega): '''This calculates the peak associated with the spectral window function for times and at the specified omega. NOTE: this is classical Lomb-Scargle, not the Generalized Lomb-Scargle. `mags` and `errs` are silently ignored since we're calculating t...
def pgen_lsp( times, mags, errs, magsarefluxes=False, startp=None, endp=None, stepsize=1.0e-4, autofreq=True, nbestpeaks=5, periodepsilon=0.1, sigclip=10.0, nworkers=None, workchunksize=None, glspfunc=_glsp_w...
def specwindow_lsp( times, mags, errs, magsarefluxes=False, startp=None, endp=None, stepsize=1.0e-4, autofreq=True, nbestpeaks=5, periodepsilon=0.1, sigclip=10.0, nworkers=None, glspfunc=_glsp_worker_specwindow, ...
def analytic_false_alarm_probability(lspinfo, times, conservative_nfreq_eff=True, peakvals=None, inplace=True): '''This returns the analytic false alarm probabilities ...
def check_existing_apikey(lcc_server): '''This validates if an API key for the specified LCC-Server is available. API keys are stored using the following file scheme:: ~/.astrobase/lccs/apikey-domain.of.lccserver.org e.g. for the HAT LCC-Server at https://data.hatsurveys.org:: ~/.astroba...
def get_new_apikey(lcc_server): '''This gets a new API key from the specified LCC-Server. NOTE: this only gets an anonymous API key. To get an API key tied to a user account (and associated privilege level), see the `import_apikey` function below. Parameters ---------- lcc_server : str ...
def import_apikey(lcc_server, apikey_text_json): '''This imports an API key from text and writes it to the cache dir. Use this with the JSON text copied from the API key text box on your LCC-Server user home page. The API key will thus be tied to the privileges of that user account and can then access ...
def submit_post_searchquery(url, data, apikey): '''This submits a POST query to an LCC-Server search API endpoint. Handles streaming of the results, and returns the final JSON stream. Also handles results that time out. Parameters ---------- url : str The URL of the search API endpoin...
def retrieve_dataset_files(searchresult, getpickle=False, outdir=None, apikey=None): '''This retrieves a search result dataset's CSV and any LC zip files. Takes the output from the `submit_post_searchquery` function above or a ...
def cone_search(lcc_server, center_ra, center_decl, radiusarcmin=5.0, result_visibility='unlisted', email_when_done=False, collections=None, columns=None, filters=None, sortspe...
def xmatch_search(lcc_server, file_to_upload, xmatch_dist_arcsec=3.0, result_visibility='unlisted', email_when_done=False, collections=None, columns=None, filters=None, sortspe...
def get_dataset(lcc_server, dataset_id, strformat=False, page=1): '''This downloads a JSON form of a dataset from the specified lcc_server. If the dataset contains more than 1000 rows, it will be paginated, so you must use the `page` kwarg to get the page you...
def object_info(lcc_server, objectid, db_collection_id): '''This gets information on a single object from the LCC-Server. Returns a dict with all of the available information on an object, including finding charts, comments, object type and variability tags, and period-search results (if available). ...
def list_recent_datasets(lcc_server, nrecent=25): '''This lists recent publicly visible datasets available on the LCC-Server. If you have an LCC-Server API key present in `~/.astrobase/lccs/` that is associated with an LCC-Server user account, datasets that belong to this user will be returned as well,...
def list_lc_collections(lcc_server): '''This lists all light curve collections made available on the LCC-Server. If you have an LCC-Server API key present in `~/.astrobase/lccs/` that is associated with an LCC-Server user account, light curve collections visible to this user will be returned as well, e...
def stetson_jindex(ftimes, fmags, ferrs, weightbytimediff=False): '''This calculates the Stetson index for the magseries, based on consecutive pairs of observations. Based on Nicole Loncke's work for her Planets and Life certificate at Princeton in 2014. Parameters ---------- ftimes,fmags...
def stetson_kindex(fmags, ferrs): '''This calculates the Stetson K index (a robust measure of the kurtosis). Parameters ---------- fmags,ferrs : np.array The input mag/flux time-series to process. Must have no non-finite elems. Returns ------- float The Stetson K ...
def lightcurve_moments(ftimes, fmags, ferrs): '''This calculates the weighted mean, stdev, median, MAD, percentiles, skew, kurtosis, fraction of LC beyond 1-stdev, and IQR. Parameters ---------- ftimes,fmags,ferrs : np.array The input mag/flux time-series with all non-finite elements remov...
def lightcurve_flux_measures(ftimes, fmags, ferrs, magsarefluxes=False): '''This calculates percentiles and percentile ratios of the flux. Parameters ---------- ftimes,fmags,ferrs : np.array The input mag/flux time-series with all non-finite elements removed. magsarefluxes : bool ...
def lightcurve_ptp_measures(ftimes, fmags, ferrs): '''This calculates various point-to-point measures (`eta` in Kim+ 2014). Parameters ---------- ftimes,fmags,ferrs : np.array The input mag/flux time-series with all non-finite elements removed. Returns ------- dict A dict...
def nonperiodic_lightcurve_features(times, mags, errs, magsarefluxes=False): '''This calculates the following nonperiodic features of the light curve, listed in Richards, et al. 2011): - amplitude - beyond1std - flux_percentile_ratio_mid20 - flux_percentile_ratio_mid35 - flux_percentile_rat...
def gilliland_cdpp(times, mags, errs, windowlength=97, polyorder=2, binsize=23400, # in seconds: 6.5 hours for classic CDPP sigclip=5.0, magsarefluxes=False, **kwargs): '''This calculates the CDPP of a...
def all_nonperiodic_features(times, mags, errs, magsarefluxes=False, stetson_weightbytimediff=True): '''This rolls up the feature functions above and returns a single dict. NOTE: this doesn't calculate the CDPP to save time since binning and smoothi...
def _bls_runner(times, mags, nfreq, freqmin, stepsize, nbins, minduration, maxduration): '''This runs the pyeebls.eebls function using the given inputs. Parameters ---------- times,mags : np...
def _parallel_bls_worker(task): ''' This wraps the BLS function for the parallel driver below. Parameters ---------- tasks : tuple This is of the form:: task[0] = times task[1] = mags task[2] = nfreq task[3] = freqmin task[4] = s...
def bls_serial_pfind( times, mags, errs, magsarefluxes=False, startp=0.1, # search from 0.1 d to... endp=100.0, # ... 100.0 d -- don't search full timebase stepsize=5.0e-4, mintransitduration=0.01, # minimum transit length in phase maxtransitduration=0.4, # m...
def bls_parallel_pfind( times, mags, errs, magsarefluxes=False, startp=0.1, # by default, search from 0.1 d to... endp=100.0, # ... 100.0 d -- don't search full timebase stepsize=1.0e-4, mintransitduration=0.01, # minimum transit length in phase maxtransitdurat...
def _get_bls_stats(stimes, smags, serrs, thistransdepth, thistransduration, ingressdurationfraction, nphasebins, thistransingressbin, thistransegressbin, ...
def bls_stats_singleperiod(times, mags, errs, period, magsarefluxes=False, sigclip=10.0, perioddeltapercent=10, nphasebins=200, mintransitduration=0.01, maxtr...
def bls_snr(blsdict, times, mags, errs, assumeserialbls=False, magsarefluxes=False, sigclip=10.0, npeaks=None, perioddeltapercent=10, ingressdurationfraction=0.1, verbose=True): '''Calculates the ...
def massradius(age, planetdist, coremass, mass='massjupiter', radius='radiusjupiter'): '''This function gets the Fortney mass-radius relation for planets. Parameters ---------- age : float This should be one of: 0.3, 1.0, 4.5 [in Gyr]. planetdist : float ...
def _collect_tfa_stats(task): ''' This is a parallel worker to gather LC stats. task[0] = lcfile task[1] = lcformat task[2] = lcformatdir task[3] = timecols task[4] = magcols task[5] = errcols task[6] = custom_bandpasses ''' try: (lcfile, lcformat, lcformatdir, ...
def _reform_templatelc_for_tfa(task): ''' This is a parallel worker that reforms light curves for TFA. task[0] = lcfile task[1] = lcformat task[2] = lcformatdir task[3] = timecol task[4] = magcol task[5] = errcol task[6] = timebase task[7] = interpolate_type task[8] = sigcli...
def tfa_templates_lclist( lclist, lcinfo_pkl=None, outfile=None, target_template_frac=0.1, max_target_frac_obs=0.25, min_template_number=10, max_template_number=1000, max_rms=0.15, max_mult_above_magmad=1.5, max_mult_above_mageta=1.5, ...
def apply_tfa_magseries(lcfile, timecol, magcol, errcol, templateinfo, mintemplatedist_arcmin=10.0, lcformat='hat-sql', lcformatdir=None, ...
def _parallel_tfa_worker(task): ''' This is a parallel worker for the function below. task[0] = lcfile task[1] = timecol task[2] = magcol task[3] = errcol task[4] = templateinfo task[5] = lcformat task[6] = lcformatdir task[6] = interp task[7] = sigclip ''' (lcfile...
def parallel_tfa_lclist(lclist, templateinfo, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=None, interp='nearest', ...
def parallel_tfa_lcdir(lcdir, templateinfo, lcfileglob=None, timecols=None, magcols=None, errcols=None, lcformat='hat-sql', lcformatdir=None, ...
def update_checkplot_objectinfo(cpf, fast_mode=False, findercmap='gray_r', finderconvolve=None, deredden_object=True, custom_bandpasses=None, ...
def _read_pklc(lcfile): ''' This just reads a light curve pickle file. Parameters ---------- lcfile : str The file name of the pickle to open. Returns ------- dict This returns an lcdict. ''' if lcfile.endswith('.gz'): try: with gzip.ope...
def _check_extmodule(module, formatkey): '''This imports the module specified. Used to dynamically import Python modules that are needed to support LC formats not natively supported by astrobase. Parameters ---------- module : str This is either: - a Python module import path...
def register_lcformat(formatkey, fileglob, timecols, magcols, errcols, readerfunc_module, readerfunc, readerfunc_kwargs=None, normfunc_module=No...
def get_lcformat(formatkey, use_lcformat_dir=None): '''This loads an LC format description from a previously-saved JSON file. Parameters ---------- formatkey : str The key used to refer to the LC format. This is part of the JSON file's name, e.g. the format key 'hat-csv' maps to the fo...
def ec2_ssh(ip_address, keypem_file, username='ec2-user', raiseonfail=False): """This opens an SSH connection to the EC2 instance at `ip_address`. Parameters ---------- ip_address : str IP address of the AWS EC2 instance to connect to. keypem_file : str...
def s3_get_file(bucket, filename, local_file, altexts=None, client=None, raiseonfail=False): """This gets a file from an S3 bucket. Parameters ---------- bucket : str The AWS S3 bucket name. filename : str ...
def s3_get_url(url, altexts=None, client=None, raiseonfail=False): """This gets a file from an S3 bucket based on its s3:// URL. Parameters ---------- url : str S3 URL to download. This should begin with 's3://'. altexts : None or list of str ...
def s3_put_file(local_file, bucket, client=None, raiseonfail=False): """This uploads a file to S3. Parameters ---------- local_file : str Path to the file to upload to S3. bucket : str The AWS S3 bucket to upload the file to. client : boto3.Client or None If None, thi...
def s3_delete_file(bucket, filename, client=None, raiseonfail=False): """This deletes a file from S3. Parameters ---------- bucket : str The AWS S3 bucket to delete the file from. filename : str The full file name of the file to delete, including any prefixes. client : boto3....
def sqs_create_queue(queue_name, options=None, client=None): """ This creates an SQS queue. Parameters ---------- queue_name : str The name of the queue to create. options : dict or None A dict of options indicate extra attributes the queue should have. See the SQS doc...
def sqs_delete_queue(queue_url, client=None): """This deletes an SQS queue given its URL Parameters ---------- queue_url : str The SQS URL of the queue to delete. client : boto3.Client or None If None, this function will instantiate a new `boto3.Client` object to use in it...
def sqs_put_item(queue_url, item, delay_seconds=0, client=None, raiseonfail=False): """This pushes a dict serialized to JSON to the specified SQS queue. Parameters ---------- queue_url : str The SQS URL of the queue to push th...
def sqs_get_item(queue_url, max_items=1, wait_time_seconds=5, client=None, raiseonfail=False): """This gets a single item from the SQS queue. The `queue_url` is composed of some internal SQS junk plus a `queue_name`. For our purposes (`lcp...
def sqs_delete_item(queue_url, receipt_handle, client=None, raiseonfail=False): """This deletes a message from the queue, effectively acknowledging its receipt. Call this only when all messages retrieved from the queue have been processed, sin...
def make_ec2_nodes( security_groupid, subnet_id, keypair_name, iam_instance_profile_arn, launch_instances=1, ami='ami-04681a1dbd79675a5', instance='t3.micro', ebs_optimized=True, user_data=None, wait_until_up=True, client=None, ...
def delete_ec2_nodes( instance_id_list, client=None ): """This deletes EC2 nodes and terminates the instances. Parameters ---------- instance_id_list : list of str A list of EC2 instance IDs to terminate. client : boto3.Client or None If None, this function will in...
def make_spot_fleet_cluster( security_groupid, subnet_id, keypair_name, iam_instance_profile_arn, spot_fleet_iam_role, target_capacity=20, spot_price=0.4, expires_days=7, allocation_strategy='lowestPrice', instance_types=SPOT_INSTANCE_TYPES...
def delete_spot_fleet_cluster( spot_fleet_reqid, client=None, ): """ This deletes a spot-fleet cluster. Parameters ---------- spot_fleet_reqid : str The fleet request ID returned by `make_spot_fleet_cluster`. client : boto3.Client or None If None, this function...
def gcs_get_file(bucketname, filename, local_file, altexts=None, client=None, service_account_json=None, raiseonfail=False): """This gets a single file from a Google Cloud Storage bucket. Parameters ------...
def gcs_get_url(url, altexts=None, client=None, service_account_json=None, raiseonfail=False): """This gets a single file from a Google Cloud Storage bucket. This uses the gs:// URL instead of a bucket name and key. Parameters ---------- ...
def gcs_put_file(local_file, bucketname, service_account_json=None, client=None, raiseonfail=False): """This puts a single file into a Google Cloud Storage bucket. Parameters ---------- local_file : str Path to the file to upl...
def read_hatlc(hatlc): ''' This reads a consolidated HAT LC written by the functions above. Returns a dict. ''' lcfname = os.path.basename(hatlc) # unzip the files first if '.gz' in lcfname: lcf = gzip.open(hatlc,'rb') elif '.bz2' in lcfname: lcf = bz2.BZ2File(hatlc, ...