Module
StarbugBase
- class starbug2.starbug.StarbugBase(fname, pfile=None, options={})
StarbugBase is the overall container for the photometry package. It holds the active image, the parameter file and the output images/tables. It is self contained enough to simply run “photometry” and everything should just take care of itself from there on.
- bgd_estimate()
Estimate the background of the active image Saves the result as an ImageHDU self.background
- bgd_subtraction()
Internally subtract a background array from an image array
- calculate_psf()
- detect()
Full source detection routine Saves the result as a table self.detections
- property header
Construct relevant base header information for routine products
- Returns:
`fits.Header`
- Return type:
Header file containing a series of relevvant information
- property image
automagically find the main image array to use Order of importance is: > self._nHDU (if set) > param[ HDUNAME ] > SCI, BGD, RES > first ImageHDU > image[0]
- property info
Get some useful information from the image header file
- load_apfile(fname=None)
Load a AP_FILE to be used during photometry
- Parameters:
fname (str) – Filename for fits table containg source coordinates. These coorindates can be xcentroid/ycentroid, x_init/y_init, x_0,y_0 or RA/DEC. The latter is used if starbug gets “USE_WCS=1” in the parameter file.
- load_bgdfile(fname=None)
Load a BGD_FILE to be used during photometry
- Parameters:
fname (str) – Filename of fits image the same dimensions as the main image
- load_image(fname)
Given fname, load the image into starbug to be worked on.
- Parameters:
fname (str) – Filename of fits image (with any number of extensions. If using a non standard HDU index, set the name or index of the extension with “HDUNAME=XXX” in the parameter file
- load_psf(fname=None)
Load a PSF_FILE to be used during photometry
- Parameters:
fname (str) – Filename of a PSF fits image
- photometry()
Full photometry routine Saves the result as a table self.psfcatalogue // Additionally it appends a residual Image onto the self.residuals HDUList
- prepare_image_arrays()
Make a copy of the original image, and prepare the other image arrays
- Returns:
image – A copy of the image array, scale into Jy if appropriate
error (np.array) – An error array in the same unit as image
bgd (np.array or None) – A copy of the loaded background image in the same units as the image
mask (?)
- static sort_output_names(fname, param_output=None)
This is a useful function that looks at both an input file and a set output and figures out how to name output files. If param_output looks like a directory then the output will be set to that directory with the basename of fname. If param_output looks like a file, then the output basename will take that form
- Parameters:
fname (str) – Filename to use as the core of the output
param_output (str) – This is the OUTPUT parameter in the parameter file. It can be an output directory or output filename. If None (default) then it will be ignored
- Returns:
outdir (str) – The output directory
bname (str) – The output file basename (e.g. path/to/output.txt -> “output”)
extension (str) – The file extension split from the inputs
- source_geometry()
Calculate source geometry stats for a given image and source list
- verify()
This simple function verifies that everything necessary has been loaded properly
- Returns:
0 (on success)
1 (on fail)
- starbug2.starbug.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.starbug.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
Starbug2 Routines
Core routines for StarbugII.
- class starbug2.routines.APPhot_Routine(radius, sky_in, sky_out, verbose=0)
Aperture photometry called by starbug
- Parameters:
radius (float) – Pixel radius of photometric aperture.
sky_in (float) – Pixel radius of inner sky annuli.
sky_out (float) – Pixel radius of outer sky annuli.
verbose (bool) – Set whether to print verbose output information
- static apcorr_from_encenergy(filter, encircled_energy, table_fname=None, verbose=0)
Rather than fitting radius to the APCORR CRDS, use the closes Encircled energy value
- static calc_apcorr(filter, radius, table_fname=None, verbose=0)
Using CRDS apcorr table, fit a curve to the radius vs apcorr columns and then return aporr to respective input radius
- log(msg)
log message if in verbose mode
- radius_from_encenrgy(eefrac, table_fname)
- run(image, detections, error=None, dqflags=None, apcorr=1.0, sig_sky=3)
Forced aperture photometry on a list of detections detections are a astropy.table.Table with columns xcentroid ycentroid or x_0 y_0 This will add extra columns into this table ap_flux ap_sky
- Parameters:
detections (astropy.table.Table) – Table with source poisitions containing xcentroid,ycentroid columns
image (numpy.ndarray) – 2D Image data to run photometry on
error (numpy.ndarray) – 2D Image array containing photometric error per pixel
dqflags (numpy.ndarray) – 2D Image array containing JWST data quality flags per pixel
apcorr (float) – Aperture correction to be applied to the flux
sig_sky (float) – Sigma threshold above the median to clip from sky apertures
- Return type:
Photometry catalogue
- class starbug2.routines.ArtificialStar_Routine(detector, psffitter, psf)
docstring
- run(image, ntests=1000, subimage_size=500, sources=None, fwhm=1, flux_range=(0, 100000.0), separation_thresh=2, save_progress=1)
run artificial star testing on an image :param ntests - number of tests to conduct: :param subimage_size - size of the cropped subimage: :param sources - precalculated positions to test stars: astropy table with x_0 y_0 flux columns :param fwhm - FWHM of the stars to be added: this is used to ensure the source isnt too close to the border :param : this is used to ensure the source isnt too close to the border :param flux_range - range of fluxes to test: :param separation_thresh - number pixels above which the separation is too high and the artificial star failed: :param save_progress - periodically save the catalogue:
for each star, plaxe it into a copy of the base image. however, the base image should be cropped in and around that new star
- class starbug2.routines.BackGround_Estimate_Routine(sourcelist, boxsize=2, fwhm=2, sigsky=2, bgd_r=-1, profile_scale=1, profile_slope=0.5, verbose=0, bgd=None)
Diffuse background emission estimator run by starbug.
- Parameters:
sourcelist (astropy.table.Table) – List of sources in the image in a table containing “xcentroid” “ycentroid”.
boxsize (int) – Size of the kernel to pass over the image in unsharp masking.
fwhm (float) – Source full width hald maximum in the image.
sigsky (float) –
.
bgd_r (float) –
.
profile_scale (float) –
.
profile_slope (float) –
.
verbose (bool) –
.
- calc_background(data, axis=None, masked=None)
Calculate the background value.
- Parameters:
data (array_like or ~numpy.ma.MaskedArray) – The array for which to calculate the background value.
axis (int or None, optional) – The array axis along which the background is calculated. If None, then the entire array is used.
masked (bool, optional) – If True, then a ~numpy.ma.MaskedArray is returned. If False, then a ~numpy.ndarray is returned, where masked values have a value of NaN. The default is False.
- Returns:
result – The calculated background value. If
maskedis False, then a ~numpy.ndarray is returned, otherwise a ~numpy.ma.MaskedArray is returned. A scalar result is always returned as a float.- Return type:
float, ~numpy.ndarray, or ~numpy.ma.MaskedArray
- calc_peaks(im)
Determine peak pixel value for each source in xy
- class starbug2.routines.Detection_Routine(sig_src=5, sig_sky=3, fwhm=2, sharplo=0.2, sharphi=1, round1hi=1, round2hi=1, smoothlo=-inf, smoothhi=inf, ricker_r=1.0, verbose=0, cleansrc=1, dobgd2d=1, boxsize=2, doconvl=1)
Detection routine
A standalone detection that runs on a 2D image. It uses DAOStarFinder as the base for peak detection but run several times on a series of background subtracted images. Each run the background subtraction is differemt, bringing out a different set of sources
- Parameters:
sig_src (float) – The detection flux threshold, this sets the number of sigma above the image median flux that a source must be brighter than. Default: sig_src=5 is a “solid” detection.
sig_sky (float) – The number of sigma above the image median flux that is still considered “sky”. Pixels below this will be cut out during the detection steps.
fwhm (float) – Full width half maximum of a standard source in the image.
sharplo (float) – Lowest bound for a source “sharpness”.
sharphi (float) – Upper bound for a source “sharpness”.
round1hi (float) – Upper bound for a source “roundness1”, this distribution is symmetric and the lower bound is taken as negative round1hi.
round2hi (float) – Upper bound for a source “roundness2”, this distribution is symmetric and the lower bound is taken as negative round2hi.
smoothlo (float) – Lower bound for source “smoothness”.
smoothhi (float) – Upper bound for source “smoothness”.
ricker_r (float) – Pixel radius for the wavelet used in the CONVL detection step.
cleansrc (bool) – Set whether to “clean” the catalogue after detection based on the above source geometric properties.
dobgd2d (bool) – Set whether to run the BGD2D detection step.
doconvl (bool) – Set whether to run the CONVL detection step.
boxsize (int) – Set kernel size for BGD2D background measuring step.
verbose (bool) – Set whether to print verbose output information.
- detect(data, bkg_estimator=None, xycoords=None, method=None)
The core detection step (DAOStarFinder)
- Parameters:
data (numpy.ndarray) – Image array to detect on
bkg_estimator (callable function) – Function to call to generate the background array the same shape as data array
xycorrds (astropy.table.Table) – Table of initial guesses (xcentroid,ycentroid)
method (str) – Detection method “findpeaks” - use the photutils findpeaks method None - Use the DAOStarFinder method
- Returns:
detections – Sourcelist Table
- Return type:
astropy.Table
- find_stars(data, mask=None)
This routine runs source detection several times, but on a different form of the data array each time. Each form has been “skewed” somehow to brighten the most faint sources and flatten the differential background.
1:Plain detections 2:Subtract Background estimation 3:RickerWave convolution
- Parameters:
data (numpy.ndarray) – 2D image array to detect on
mask (numpy.ndarray) – Pixels to mask out on the data array
- match(base, cat)
Internal function to class Used to match detenctoins from separate background subtracted images into the main catalogue. This will append a source if its matched separation is above the threshold = self.fwhm
- Parameters:
base (astropy.table.Table) – Base catalogue to match to
cat (astropy.table.Table) – Catalogue to be matched
- Returns:
matched – The matched catalogue
- Return type:
astropy.Table
- class starbug2.routines.PSFPhot_Routine(psf_model, fitshape, apphot_r=3, min_separation=8, force_fit=False, background=None, verbose=1)
PSF Photometry routine called by starbug
- Parameters:
psf_model (FittableImageModel) – Model PSF to be used in the fitting
fitshape (int or tuple) – Size of PSF to use in pixels. Must be less than or equal to the size of psf_model
min_separation (float) – Minimum source separation for source grouper (pixels)
apphot_r (float) – Aperture radius to be used in initial guess photometry
force_fit (bool) – Conduct forced centroid PSF fitting
background (image) – 2D array with the same dimensions as the data used in fitting
verbose (bool, int) – Show verbose outputs
- do_photometry(image, init_params=None, error=None, mask=None, progress_bar=False)
- starbug2.routines.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.routines.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
Artificial Star Testing
- class starbug2.artificialstars.Artificial_StarsIII(starbug, index=-1)
ast
- auto_run(ntests, stars_per_test=1, subimage_size=-1, mag_range=(18, 27), loading_buffer=None, autosave=-1, skip_phot=0, skip_background=0)
The main entry point into the artificial star test This handles everything except the results compilation at the end,
- Parameters:
ntests (int) – Number of tests to run
stars_per_test (int) – Number of stars to inject per test
subimage_size (int) – in prep.
mag_range (tuple,list) – Length two list or tuple containing the magnitude range of injected stars. These will be uniformly sampled from within this range.
loading_buffer (numpy.ndarray) – Length 3 array of shared memory to increment a loading bar between multiple subprocesses..
autosave (int) – Auto quick saving output frequency
skip_phot (int) – If true then ignore the PSF phot step and use aperture fluxes instead
skip_background (int) – If true then ignore the background substraction step
- Returns:
test_result – Full raw test results. Injected initial properties with measured values
- Return type:
astropy.Table
- create_subimage(image, size, position=(0, 0), hdu=1, buffer=0)
probably to be deprecated
- single_test(image, contains, skip_phot=0, skip_background=0)
Conduct a single test on an image with a set of initial source properties
- Parameters:
image (numpy.ndarray) – 2D image array to conduct test on
contains (table) – Table of initial source properties to be injected into the image. This table must contain the columns (“x_0”,”y_0”,”flux”)
skip_phot (int) – Skip the PSF phot routine
skip_background (int) – Skip the background estimation and subtraction step
- Returns:
result – Table hoizontally stacked with the initial inputs and the detection and photometric results. Plus column named “status”, an integer flag as to whether the source was detected or not.
- Return type:
Table
- starbug2.artificialstars.compile_results(raw, image=None, plotast=None, fltr='m')
Compile all the raw data into usable results
- starbug2.artificialstars.estim_completeness_mag(ast)
Estimate the completenss level of the artificial star test
- Parameters:
ast (astropy Table) – Output of Artificial_Stars.get_completeness, table must contain columns (mag, rec)
- Returns:
fit (list) – The fitting parameters to the logistic curve f(x)=l/(1+exp(-k(x-xo))) fit=[l,xo,k]
complete (list) – Magnitude of 70% and 50% completeness
- starbug2.artificialstars.get_completeness(test_result)
Compile the results into magnitude binned values of recovery fraction and flux error
- Parameters:
test_result (table) – The output from auto_run
- Returns:
result – Table containing percent completeness as a function of magnitude
- Return type:
astropy Table
- starbug2.artificialstars.get_spatialcompleteness(test_result, image, res=10)
Produce an image array showing the spatially dependant recovery fraction
- Parameters:
test_result (table) – The output from auto_run
image (numpy.ndarry) – 2D image array to take the shape from
res (int) – The resolution of the spatial bins
- Returns:
percs – A 2D array the same shape as the image input, pixel values show the fraction of injected sources recovered in this bin
- Return type:
numpy.ndarray
- starbug2.artificialstars.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.artificialstars.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.artificialstars.scurve(x, l, k, xo)
S-curve function to fit completeness results to
f(x)=l/(1+exp(-k(x-xo)))
- Parameters:
x (list) – Magnitude range to input into function
l (float) – Function parameters
xo (float) – Function parameters
k (float) – Function parameters
- Returns:
f(x)
- Return type:
float
Utils
- starbug2.utils.collapse_header(header)
Convert a dictionary to a Header. Parameters in PARAMFILES have keys longer than 8 chars which can cause issues in the fits format. This function turns those to comment cards.
- Parameters:
header (dict , fits.Header) – Header or dictionary to convert to collapse header
- Returns:
result – Collapsed Header
- Return type:
fits.Header
- starbug2.utils.colour_index(table, keys)
Allow table indexing with A-B
- starbug2.utils.combine_fnames(fnames, ntrys=10)
when matching catalogues, combines the file names into an appropriate combination of all the inputs
- Parameters:
fnames (list of file names)
ntrys (int) – The number of mismatched characters it will allow
- Returns:
fname – Combined filenames
- Return type:
str
- starbug2.utils.cropHDU(hdu, xlim=None, ylim=None)
Crop an image with multiple extensions. Retaining the extensions
- Parameters:
hdu (fits.HDUList) – A multi frame fits HDUList
xlim (list) – Pixel X bounds to crop image between
ylim (list) – Pixel Y bounds to crop image between
- Returns:
hdu – The full HDUList that has been spatially cropped
- Return type:
fits.HDUList
- starbug2.utils.export_region(tab, colour='green', scale_radius=1, region_radius=3, xcol='RA', ycol='DEC', wcs=1, fname='/tmp/out.reg')
A handy function to convert the detections in a DS9 region file
- Parameters:
tab (table) – Source list table with some kind of positional columns
colour (str) – Region colour
scale_region (int) – Scale region radius with flux ? true/false
region_radius (int) – Otherwise, use this region radius in pixels
xcol/ycol (str) – XY column names to use
wcs (int) – Boolean if the xycols use WCS system
fname (str) – Filename to output to
- starbug2.utils.export_table(table, fname=None, header=None)
Export table with correct dtypes
- Parameters:
table – Table to export
fname (str) – Filename to export to
header (dict,Header) – Optional header file to include in fits table
- starbug2.utils.extnames(hdulist)
Return list of HDU extension names
- Parameters:
hdulist (HDUList) – fits hdulist to operate on
- Returns:
result – List of extension names
- Return type:
list
- starbug2.utils.fill_nan(table)
Fill empty values in table with nans This is useful for tables that have columns that dont support nans (e.g. starbug flag). These will be set to zero instead
- Parameters:
table – table to operate on
- Returns:
Input table will masked vales filled in as nan
- Return type:
table
- starbug2.utils.find_colnames(tab, basename)
Find substring (basename) within the table colnames. Searches for substring at the beginning of the word I.E search for “flux” in (“flux_out”,”flux_err”,”dflux”) returns as (“flux_out”,”flux_err”)
- Parameters:
tab (table) – Table to operate on
basename (str) – String basename to search
- Returns:
result – List of all matching column names
- Return type:
list
- starbug2.utils.find_filter(table)
Attempt to identify filter for a table from the meta data or column names
- Parameters:
table (astropy.table.Table) – Table to work on
- Returns:
filter – Identified filter value, otherwise None
- Return type:
str
- starbug2.utils.flux2ABmag(flux, fluxerr=None)
Convert flux to AB magnitudes
- Parameters:
flux (float) – Source flux values
fluxerr (float) – Soure flux error values if known
- Returns:
result – Magnitude in AB system
- Return type:
float
- starbug2.utils.flux2mag(flux, fluxerr=None, zp=1)
Convert flux to magnitude in an arbitrary system
- Parameters:
flux (list (float)) – List of source flux values
fluxerr (list (flost)) – List of known flux uncertainties
zp (float) – Zero point flux value
- Returns:
mag (float) – Source magnitudes
magerr (float) – Magnitude errors
- starbug2.utils.get_MJysr2Jy_scalefactor(ext)
Find the unit scale factor to convert an image from MJy/sr to Jy Header file must contain the keyword “PIXAR_SR”
- Parameters:
ext (PrimaryHDU,ImageHDU,BinaryTableHDU) – Fits extension with header file
- Returns:
scalefactor – Value of scaling factor from the header
- Return type:
float
- starbug2.utils.get_version()
Try to determine the installed starbug version on the system
- Returns:
version – Starbug2 installed version
- Return type:
str
- starbug2.utils.hcascade(tables, colnames=None)
Similar use as hstack Except rather than adding a full new column, the inserted value is placed into the leftmost empty column
- Parameters:
tables (list of Tables) – Table to hcascade
colnames (list of str) – List of column names to include in the stacking. If colnames=None, use all possible columns
- Returns:
result – Single combined table
- Return type:
table
- starbug2.utils.import_table(fname, verbose=0)
Slight tweak to astropy.table.Table.read. This makes sure that the proper column dtypes are maintained
- Parameters:
fname (str) – Path to binary fits table file
verbose (bool) – Display verbose information
- Returns:
Loading table
- Return type:
table
- starbug2.utils.parse_unit(raw)
Take a value with the ability to be cast into several units and parse it i.e. 123p -> 123 ‘pixels’
Recognised units are: p : pixels s : arcsec m : arcmin d : degree
- Parameters:
raw (str) – Raw input string to operate on
- Returns:
value (float) – Numerical value of unit
unit (int) – Unit type (p,s,m,d)
- starbug2.utils.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.utils.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.utils.reindex(table)
Add indexes into a table
- starbug2.utils.rmduplicates(seq)
Take a sequence and rm its duplicates while preserving the order of the input
- Parameters:
seq (list) – Input list to work on
- Returns:
result – A copy of the list with the duplicate elements removed
- Return type:
list
- starbug2.utils.tab2array(tab, colnames=None)
Returns the contents of the table as a notmal 2D numpy array NB: this is different from Table.asarray(), which returns an array of numpy.voids
if colnames not None, return the subset of the table corresponding to this list
- Parameters:
tab (table) – Table to operate on
colnames (list) – Column names in table to include in the array
- Returns:
array – Array from the table
- Return type:
numpy.ndarray
- starbug2.utils.tabppend(base, tab)
Is this the same as vstack?
- starbug2.utils.wget(address, fname=None)
A really simple “implementation” of wget
- Parameters:
address (str) – URL to download
fname (str) – Filename to save output to
- Returns:
status – 0 on success, 1 on failure
- Return type:
int
Param
- starbug2.param.load_params(fname)
Convert a parameter file into a dictionary of options INPUT: fname=path/to/file.param RETURN: dictionary of options
- starbug2.param.parse_param(line)
Parse a parameter line
- starbug2.param.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.param.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.param.update_paramfile(fname)
When the local parameter file is from an older version, add or remove the new or obselete keys INPUT: fname=local file to update
Matching
Starbug matching functions Primarily this is the main routines for dither/band/generic matching which are at the core of starbug2 and starbug2-match
- class starbug2.matching.BandMatch(**kwargs)
- match(catalogues, method='first', **kwargs)
Given a list of catalogues, it will reorder them into increasing wavelength or to match the fltr= keyword in the initialiser. The matching then uses the shortest wavelegnth availables position. I.e If F115W, F444W, F770W are input, the F115W centroid positions will be taken as “correct”. If a source is not resolved in this band, the next most astrometrically accurate position is taken, i.e. F444W
- Parameters:
catalogues (list) – List of astropy.table.Table objects containing the meta item “FILTER=XXX”
method (str) – Centroid method “first” - Use the position corresponding to the earliest appearance of the source “last” - Use the position corresponding to the latest appearance of the source “bootsrap”- .. “average” - ..
- Returns:
base – Matched catalogue
- Return type:
astropy.Table
- order_catalogues(catalogues)
Reorder catalogue list into increasing wavelength size This only works for JWST bands. Unrecognised filters will be left unchanged. The function should also set the self.filter variable if possible
Parameter
- catalogueslist
List of astropy.table.Table with meta keys “FILTER”
- returns:
catalogues – The same list reordered
- rtype:
list
- class starbug2.matching.CascadeMatch(**kwargs)
A simple advancement on “Generic Matching” where the number of columns are not preserved. At the end of each sub match, the table is left justified, to reduce the total number of columns needed.
- Parameters:
GenericMatch (See)
- match(catalogues, **kwargs)
Match a list of catalogues with RA and DEC columns
- Parameters:
GenericMatch.match (See)
- Returns:
output – A left aligned catalogue of all the matched values
- Return type:
astropy.table.Table
- class starbug2.matching.DitherMatch(catalogues, pfile=None)
The same as Generic Matching
- match(**kwargs)
- class starbug2.matching.ExactValueMatch(value='Catalogue_Number', **kwargs)
Match catalogues based on a single value in one of their columns The normal use case is matching sources based on their Catalogue_Number value.
- Parameters:
value (str) – Column name to take exact values from
- match(catalogues, **kwargs)
Core matching function
- Parameters:
catalogues (list) – List of astropy Tables to match together
- Returns:
base – Full matched catalogue
- Return type:
astropy.Table
- class starbug2.matching.GenericMatch(threshold=None, colnames=None, fltr=None, verbose=None, pfile=None)
Base matching class
- Parameters:
threshold (float) – Separation threshold in arcseconds
colnames (list) – List of str column names to include in the matching. Everything else will be discarded
fltr (str) – Specifically set the filter of the catalogues
verbose (int) – Include verbose outputs
pfile (str) – Parameter filename
- build_meta(catalogues)
Not happy with this yet
- finish_matching(tab, error_column='eflux', num_thresh=-1, discard_outliers=False, zpmag=0, colnames=None)
Averaging all the values. Combining source flags and building a NUM column
- Parameters:
tab (astropy.table.Table) – Table to work on
error_column (str) – Column containing resultant photometric errors to be used to calculate the magnitude error “eflux” - use the eflux column (the normal photometric error column) “stdflux” - use “stdflux” column as error on flux
num_thresh (int) – Minimum number of matches a source must have. NUM values smaller than this will be removed from the table. If num_thresh<=0, no cropping will happen
discard_outliers (bool) – Choose whether to remove outling values from the averaging. This may be usful if some flux values are wildly different from others in the set
zpmag (float) – Zero point (Magnitude) to be applied to the magnitude after it is calculated
colnames (list) – List of colnames to include in the averaging. If None, use self.colnames instead
- Returns:
av – An averaged version of the input table
- Return type:
astropy.Table
- init_catalogues(catalogues)
This function is a bit of a “do everything” function
It takes the input catalogues and removes any columns that arent included in the self.colnames list. If this is None, then all columns are kept. Additionally it initialises the loading bar with the summed length of all the input catalogues. Finally it attempts to set the photometric filter that is being used
- Parameters:
catalogues (list (astropy.Tables)) – The input catalouges to work on
- Returns:
out – The cleaned list of input catalogues
- Return type:
list (astropy.Table)
- mask_catalogues(catalogues, mask)
- match(catalogues, join_type='or', mask=None, cartesian=False, **kwargs)
This matching works as a basic match. Everything is included and the column names have _N appended to the end.
- Parameters:
join_type (str) – Joing method “or” include sources in any catalogue “and” only include sources in all catalogues
mask (list) – in prep.
- Returns:
base – Matched catalogue.
- Return type:
astropy.Table
- starbug2.matching.band_match(catalogues, colnames=('RA', 'DEC'))
Given a list of catalogues (with filter names in the meta data), match them in order of decreasing astrometric accuracy. If F115W, F444W, F770W are input, the F115W centroid positions will be taken as “correct”. If a source is not resolved in this band, the next most astrometrically accurate position is taken, i.e. F444W
- starbug2.matching.parse_mask(string, table)
Parse an commandline mask string to be passed into a matching routine Example: –mask=F444W!=nan
- Parameters:
string (str) – Raw mask sting to be parsed
table (?) – Table to work on
- Returns:
mask – Boolean mask array to index into a table or array
- Return type:
np.ndarray
- starbug2.matching.perror(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.matching.printf(text, /)
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- starbug2.matching.sort_exposures(catalogues)
Given a list of catalogue files, this will return the fitsHDULists as a series of nested dictionaries sorted by: > BAND > OBSERVATION ID > VISIT ID > DETECTOR – These two have been switched > DITHER (EXPOSURE) – These two have been switched