astro.external package

Submodules

astro.external.BDSM module

interface for calling f-BDSM and py-BDSM

astro.external.BDSM.convert_fits_table(filename, epoch=None)

convert the binary fits sources table from bdsm, - add BDSM_ to all column names - check for invalid values (nan) - set RA and DEC

astro.external.BDSM.find_data_file()

look for the data file, in the current directory, if not found then in PATH, if found copy to the working dir, if not return False

astro.external.BDSM.get_beam_from_header(filename)

get the beam from the fits header

astro.external.BDSM.get_version(filename)

get the version of bdsm

astro.external.BDSM.make_parameter_file(bdsm_config)

write parameter file paradefine

astro.external.BDSM.make_shell_script()

write sh script for running bdsm

astro.external.BDSM.run_bdsm(filename, params={})

run BDSM using a shell script on filename, return the filenames of the generated files : - binary fits file with the sources - binary fits file with the gaussians - residual file - parameter file

astro.external.BDSM.run_py_bdsm(filename, sourcelist=None)

interface for calling py-BDSM

astro.external.BDSM.set_mapnaxs(sl_filename, gaul_filename)

set the MAPNAXS1 and MAPNAXS2 headers in the source and gaus fits

astro.external.BPZ module

Interface to the Bayesian Photometric Redshifts code, Benitez 2000

http://www.stsci.edu/~dcoe/BPZ/

Benitez 2000, ApJ, 536, p.571: http://adsabs.harvard.edu/abs/2000ApJ…536..571B

Example:
bpz(‘photz.asc’, ‘output.txt’, config=<specify a BPZConfig object>)
exception astro.external.BPZ.BPZError

Bases: Exception

BPZ Error

astro.external.BPZ.bpz(incatalog, outcatalog, instrument='KiDSVIKING_aibn139', columns='', spectra='CWWSB_capak.list', probs_lite='', prior='', config=None)

Run bpz on a catalog

incatalog : input catalog filename outcatalog : output catalog filename instrument : part of .sed filenames? config : BPZConfig object

astro.external.BPZ.bpz_file(incatalog, outcatalog, instrument='KiDSVIKING_aibn139', columns='', spectra='CWWSB_capak.list', probs_lite='', prior='', config=None)

Run bpz on a catalog

incatalog : input catalog filename outcatalog : output catalog filename instrument : part of .sed filenames? config : BPZConfig object

astro.external.BPZ.bpz_python(incatalog, outcatalog, instrument='KiDSVIKING_aibn139', columns='', spectra='CWWSB_capak.list', probs_lite='', prior='', config=None)

Run bpz on a catalog

incatalog : input catalog filename outcatalog : output catalog filename instrument : part of .sed filenames? config : BPZConfig object

astro.external.CosmicFITS module

exception astro.external.CosmicFITS.CosmicFITSError

Bases: Exception

astro.external.CosmicFITS.cosmicfits(inname, gain)

run cosmicfits

inname – Name of input image gain – ADU conversion factor

astro.external.Dia module

interface to Difference Images Analysis

exception astro.external.Dia.DiaError

Bases: Exception

astro.external.Dia.dia_aga(image_list, config=None)

Run Dia_AGA on a list of images

astro.external.Dia.dia_getpsf(config=None)

Run Dia_GETPSF on a list of images

astro.external.Dia.dia_getvar(image_list, config=None)

Run Dia_getvar on a list of images

astro.external.Dia.dia_makemasks(list)

Create masks for images

astro.external.Dia.dia_mstack(image_list, config=None)

Run Dia_MSTACK on a list of images

astro.external.Dia.dia_phot(image_list, config=None)

Run Dia_phot on a list of images

astro.external.Dia.dia_wcs2pix(image_list)

Run Dia_WCS2PIX on a list of images

astro.external.Dia.run_command(command, suppress_output=1)

A utility function to run Dia

Parameter suppress_output is used to quiet down Dia. (default) Return the value of os.system(command)

astro.external.FITSIO module

interface to the FITSIO tools imcopy and fitscopy imcopy

Usage: imcopy inputImage outputImage[compress]

Copy an input image to an output image, optionally compressing or uncompressing the image in the process. If the [compress] qualifier is appended to the output file name then the input image will be compressed using the tile-compressed format. In this format, the image is divided into rectangular tiles and each tile of pixels is compressed and stored in a variable-length row of a binary table. If the [compress] qualifier is omitted, and the input image is in tile-compressed format, then the output image will be uncompressed.

If an extension name or number is appended to the input file name, enclosed in square brackets, then only that single extension will be copied to the output file. Otherwise, every extension in the input file will be processed in turn and copied to the output file.

Examples:

  1. imcopy image.fit ‘cimage.fit[compress]’

    This compresses the input image using the default parameters, i.e., using the Rice compression algorithm and using row by row tiles.

  2. imcopy cimage.fit image2.fit

    This uncompress the image created in the first example. image2.fit should be identical to image.fit if the image has an integer datatype. There will be small differences in the pixel values if it is a floating point image.

  3. imcopy image.fit ‘cimage.fit[compress GZIP 100,100;4]’

    This compresses the input image using the following parameters:

    GZIP compression algorithm; 100 X 100 pixel compression tiles; noise_bits = 4 (only used with floating point images)

The full syntax of the compression qualifier is:
[compress ALGORITHM TDIM1,TDIM2,…; NOISE_BITS]

where the allowed ALGORITHM values are Rice, GZIP, PLIO, and TDIMn is the size of the compression tile in each dimension, and NOISE_BITS = 1, 2, 3, or 4 and controls the amount of noise suppression when compressing floating point images.

Note that it may be necessary to enclose the file names in single quote characters on the Unix command line.

fitscopy

Usage: fitscopy inputfile outputfile

Copy an input file to an output file, optionally filtering the file in the process. This seemingly simple program can apply powerful filters which transform the input file as it is being copied. Filters may be used to extract a subimage from a larger image, select rows from a table, filter a table with a GTI time extension or a SAO region file, create or delete columns in a table, create an image by binning (histogramming) 2 table columns, and convert IRAF format *.imh or raw binary data files into FITS images. See the CFITSIO User’s Guide for a complete description of the Extended File Name filtering syntax.

Examples:

fitscopy in.fit out.fit (simple file copy) fitscopy - - (stdin to stdout) fitscopy in.fit[11:50,21:60] out.fit (copy a subimage) fitscopy iniraf.imh out.fit (IRAF image to FITS) fitscopy in.dat[i512,512] out.fit (raw array to FITS) fitscopy in.fit[events][pi>35] out.fit (copy rows with pi>35) fitscopy in.fit[events][bin X,Y] out.fit (bin an image) fitscopy in.fit[events][col x=.9*y] out.fit (new x column) fitscopy in.fit[events][gtifilter()] out.fit (time filter) fitscopy in.fit[2][regfilter(“pow.reg”)] out.fit (spatial filter)

Note that it may be necessary to enclose the input file name in single quote characters on the Unix command line.

exception astro.external.FITSIO.FITSIOError

Bases: Exception

astro.external.FITSIO.compress(input_name, output_name='Compress.fits', algo='GZIP', tile=(10, 20), qlevel=16)

Run imcopy FITSIO.

compress(input_name,output_name,algo,tile=(10,20)):

default values output_name = Compress.fits algo = GZIP (allowed ALGORITHM values are Rice, GZIP, PLIO) tile = tilex=10 , tiley=20 qlevel specifies the quantization level when converting a floating point image into integers, prior to compressing the image. The default value = 16, which means the image will be quantized into integer levels that are spaced at intervals of sigma/16., where sigma is the estimated noise level in background areas of the image. If QLEVEL is negative, this means use the absolute value for the quantization spacing (e.g. ‘q -0.005’ means quantize the floating point image such that the scaled integers represent steps of 0.005 in the original image).

astro.external.FITSIO.copy(input_name, output_name)

Run fitscopy FITSIO. fitscopy in.fit out.fit (simple file copy)

astro.external.FITSIO.copy_sub(input_name, output_name, lx, hx, ly, hy)

Run fitscopy FITSIO.

copy_sub(input_name,output_name,lx,hx,ly,hy):

copy_sub(in.fits,out.fits,11,50,21,60) –>

fitscopy in.fits[11:50,21:60] out.fits (copy a subimage)

astro.external.FITSIO.decompress(input_name, output_name='Decompress.fits', extension=0, clobber=False, exception=True)

Run imcopy FITSIO:

decompress(input_name,output_name,extension)
required:
input_name = <any string>
optional values

output_name = ‘Decompress.fits’ extension = 0 # i.e., the primary header clobber = False # overwrite output_name if it exists exception = True # raise an error if output_name exists

# (overridden by clobber)
astro.external.FITSIO.get_imcopy_executable(input_name)
astro.external.FITSIO.is_compressed(filename)

Return True if file <filename> is FITSIO compressed, False if not

astro.external.FitsImageHeader module

This is an interface to the pyfits module which mimics (part of) the qfits interface. Its only purpose is to replace the qfits/eclipse routines which update a fits header of a FITS image.

class astro.external.FitsImageHeader.FitsImageHeader(filename=None)

Bases: object

add(key, value, comment=None)
copy()
default()
dump()
empty()
has_key(item)
items()
save_header()

astro.external.Galfit module

interface to galfit program

astro.external.Galfit.clean_directory()

Galfit appends galfit output to the fit.log file if it exists. This method makes sure that it doesn’t.

astro.external.Galfit.galfit(config_file)

Embarassingly simple interface to galfit. Runs “galfit <config_file>”.

astro.external.Galphot module

interface to the Galphot ellipfit program

The Galphot package is usually run from IRAF. Marijn Franx offers a distribution with a branch of code that must be compiled under IRAF and another branch intended to be run from the Unix command line. Some minor changes were made to that branch to allow it to run under Linux. Normally ellipfit is run in an interactive fashion, and therefore the command to run it is unusual.

Syntax:

ellipfit(filename, xpos, ypos, intable, maskfile, config_dict)

where mandatory: - filename: the FITS file to run galphot on - xpos: the x-position of the galaxy in the FITS file - ypos: the y-position of the galaxy in the FITS file

and optional: - intable: the description of a previous ellipfit run on the same galaxy, to

be used as initial guess. Note that the required ASCII file is produced by the “as_table()” method of an existing GalPhotModel.
  • maskfile: “.del” file. ASCII file containing lines of 3 or 4 values
    describing circles and squares respectively; areas to be masked
  • config_dict: dictionary of configuration options, see ELLIPFIT_CONF_LIST
exception astro.external.Galphot.EllipfitError

Bases: Exception

astro.external.Galphot.check_preconditions()
astro.external.Galphot.ellipfit(filename, xpos, ypos, intable='', maskfile='', config_dict={})

System call to ellipfit

The main reason why symbolic links are created here is to limit the length of the filenames used to ~50 characters. Galphot will not handle very long filenames correctly.

astro.external.Galphot.write_configuration_file(config)

Write the ellipfit configuration file “prof.par” (the name is hardcoded in Galphot(!)). The order of parameters is exactly as in the list ORDER_IN_CONFIG_FILE. Only the values of the parameters are written to the file.

astro.external.Galphot.write_position_file(filename, xpos, ypos)

astro.external.LDAC module

Interface to the LDAC library (catalog manipulation)

This module provides the following classes, methods and functions:

Classes

LDACError – Slightly enhanced exception class LDAC – class containing astrometry and other catalog methods

Methods of Class LDAC

Catalog manipulation methods:

preastrom() – Astrometric pre-solution aplastrom() – Apply astrometric solution associate() – Associate sources in catlogs

make_ssc() – Make a single-source catalog from associated cats
astrom() – Do a full astrometric solution
make_distort() – Compute the astrometric FITS header parameters
concat() – Combine catalogs from different chips
ldacjoinkey() – Add keys from a proto catalog to the input catalog
ldacaddkey() – Add a key to the input catalog ldacdelkey() – Delete a key from the input catalog ldacrenkey() – Rename a key in the input catalog

Catalog creation methods:

asctoldac() – convert a list of parameters to LDAC fits ldactoasc() – convert an LDAC fits table to an ascii file

Utility Functions

Catalog inspection functions:

get_cat_description() – get an overview of the catalog contents get_description() – get an overview of table contents get_records() – get the contents of a table

class astro.external.LDAC.LDAC(prefix=None, verbose=0)

Bases: object

A wrapper for LDAC (Leiden Data Analysis Center) tools.

This class allows all the LDAC tools to share information, primarily shell program output.

add_image_calibs(incatname, inimaname=None, outimaname=None, config=None)

We’re adding astrometry to background subtracted fitsimages

aplastrom(incat, outcat, model='affine', config=None)

Apply astrometry to sourcelist

incat: Input catalog
outcat: Output catalog
model: Which model to use, one of ‘astrom’ (default), ‘affine’ or
‘pv’
asctoldac(input_list, outcat, tab_defs, table, clargs=None, input_file=None, verbose=0)

This procedure creates an LDAC catalog from the input data.

input_list: data in the form of a list of tuples (see NOTE)
outcat: filename of output LDAC catalog (binary FITS table)
tab_defs: table definitions (header and columns) in the form of
a list of tuples (keyword, value), with a set of 3-tuples (HEA_NAME, HEA_TTYPE, HEA_VALUE) or 6-tuples (COL_NAME, COL_TTYPE, COL_HTYPE, COL_COMM, COL_UNIT, COL_DEPTH) forming a single definition (see NOTE) Example for tab_defs: tab_defs = [(‘VERBOSE’, ‘NORMAL’), (‘COL_NAME’, ‘SeqNr’) , (‘COL_TTYPE’, ‘LONG’), (‘COL_HTYPE’, ‘INT’) , (‘COL_COMM’, ‘“Standard star ID”’), (‘COL_UNIT’, ‘”“’) , (‘COL_DEPTH’, ‘1’), (‘COL_NAME’, ‘origin’) , (‘COL_TTYPE’, ‘STRING’), (‘COL_HTYPE’, ‘STRING’) , (‘COL_COMM’, ‘”“’), (‘COL_UNIT’, ‘”“’) , (‘COL_DEPTH’, ‘20’), (‘COL_NAME’, ‘Ra’) , (‘COL_TTYPE’, ‘DOUBLE’), (‘COL_HTYPE’, ‘FLOAT’) , (‘COL_COMM’, ‘“Right Ascension”’), (‘COL_UNIT’, ‘“deg”’) , (‘COL_DEPTH’, ‘1’), (‘COL_NAME’, ‘Dec’) , (‘COL_TTYPE’, ‘DOUBLE’), (‘COL_HTYPE’, ‘FLOAT’) , (‘COL_COMM’, ‘“Declination”’), (‘COL_UNIT’, ‘“deg”’) , (‘COL_DEPTH’, ‘1’)]

table: name of table to put the data into

clargs: a list of command line arguments

input_file: filename of an input text file (see NOTE)
verbose: verbosity of output
NOTE: The input data can take two forms. The usual form is that of a
list of items to write to LDAC fits. This list has to be a list of tuples, where every tuple represents one row in the output catalog. Every element in the tuple corresponds to one column in the output catalog. Optionally, an ASCII input file containing these items can be provided through the “input_file” parameter. Every line in this file should correspond to one row in the eventual LDAC catalog. The list of table definitions has to be provided by the calling routine.
associate(incats, outcats=None, pairscat=None, table_name='OBJECTS', config=None)
astrom(incats, outcats, icatfile, statfile=None, config=None)
concat(incats, outcat, table='')

Concatenate catalogs into single output catalog

incats: A list of names of input catalogs outcat: The name of an output catalog table: The name of the table in the catalogs

This procedure concatenates the catalogs of the different CCDs within a single exposure of a multi-CCD instrument to a single catalog, where the x and y positions are with respect to a common reference. This can catalog be used by preastrom to find a global offset for the instrument

dump_output(program=None, verbose=0)

Write the program(s) output with multiple verbosity levels.

program: name of program calling for the dump (None dumps all) verbose: verbosity level as an integer (see below)

The output varies with class verbosity level as shown below. The verbosity is set during construction of the class instance, but can be overwritten with the ‘verbose’ option. The verbosity names below are the levels in the LDAC configurations, the verbosity numbers are representations of the names.

NONE/0: no output is shown

NORMAL/1: only basic program information is shown

VERBOSE/2: basic program info, config, warnings, errors, and
unabridged program output is shown.

DEBUG/3: same as VERBOSE/2

filter(incat, outcat, table, sel, verbose=0)
getlist(incat, table, key_list=[])
ldacaddkey(incat, outcat, table, key_list, verbose=0)
ldaccalc(incat, outcat, table, new_column_name, new_column_type, operation)

Perform mathematical operations on a column in an LDAC table.

ldacconv(inname, outname, band_no, channel_name)
ldacdelkey(incat, table, key, verbose=0)
ldacjoinkey(incat, outcat, protocat, table, key_list, verbose=0)
ldacpaste(incats, outcat)

Concatenate several catalogs

ldacrenkey(incat, key_old, key_new, table, switch=0, verbose=0)
ldactoasc(incat, outcat_ascii=None, table_name='OBJECTS', keys=[], opts=[], verbose=0)

Convert an FITS binary table to an ASCII file.

incat: filename of input ldac catalog to convert to ASCII
outcat_ascii: filename of output ASCII file
table_name: table name to extract data from
keys: list of column names within the specified table
(default is [] which gives all columns)

opts: additional options (see below)

verbose: verbosity of output

Options (give a list) are: -b (suppress printing of the banner)

-r (Print the row number) -d (Print comma-delimited lines for DB

loading)
-f (Print fully extended floating point
values and comma-delimited)

-s (Print strings and arrays) -q (Quiet flag: defaulted to verbose!)

make_distort(incats, outcats, config=None)
make_ssc(incats, outcat, table_name='OBJECTS', config=None)
preastrom(incats, outcats, refcats, astrom_ref_cat, distances=None, config=None)
prephotom(incat, outcat, refcat, config=None)
run(command, config=None, program=None, verbose=0)

Run the given command, optionally adding the proper configuration, and update the global program information dictionary with the program’s output. The amount of output is determined by the global verbose variable (see docstring for dump_output), overridden by the local verbose variable if set. Both of these verbosity settings override that in the configuration files.

NOTE: If an error is returned from the command, verbosity level > 1
is used for output regardless of the global settings.
command: command-line to be executed
config: Config object containing configuration
program: name of the program for which the configiration file is to
be written

verbose: custom level to change verbosity to

NOTE: If ‘config’ is specified, the string ‘command’ MUST contain a
‘%s’ placeholder in the proper location to place the derived filename properly. If ‘config’ is None, no such placeholder should exist.

The ‘program’ argument is used as the basis for the key of the program information dictionary and for the configuration filename. The program information dictionary stores all the output of ALL the programs run by one instance of the class in a convenient manner for later perusal. The filename of the configuration file is of the form prefix.program_name.conf, where the prefix is defined by the class.

separate(incat, outcat_prefix)
verbosity_dict = {None: 0, 0: 0, 2: 2, 3: 3, 1: 1, 'VERBOSE': 2, 'NORMAL': 1, 'DEBUG': 3, 'NONE': 0}
verbosity_keywords = {None: 'NONE', 0: 'NONE', 2: 'VERBOSE', 3: 'DEBUG', 1: 'NORMAL'}
exception astro.external.LDAC.LDACError(message='UNEXPECTED ERROR')

Bases: Exception

astro.external.LDAC.convert_values(value)

Convert value to a python type if necessary.

astro.external.LDAC.get_astrom(incat)

Get the astrometry from a catalog

incat: The catalog

Returns a list of dictionaries whose keys are astrometric params. There is once dictionary for each field element The following parameters are included:

CRVAL1, CRVAL2, CRPIX1, CRPIX2, CD1_1, C1_2, CD2_1, CD2_2, PV1_1, PV1_n, PV2_1, PV2_n – non-zero PV elements FITPARMS, STDERRS – the results of the astrom fit

If necessary CDELT*, CROT* are transformed into a CD matrix

astro.external.LDAC.get_cat_description(incat)

Get the a description of the catalog contents

incat: The name of the catalog

Returns a dictionary whose keys are table names and whose values are tuples of (number_of_elements, number_of_data_fields)

astro.external.LDAC.get_ldacimhead(sexcat, key_list=[])

Get a list of records from a table

Return a list of dictionaries, One dictionary per row in the table. Keys in the dictionary correpsond to keys in the table. Values are either ints, strings or float, or tuples of ints or floats.

astro.external.LDAC.get_records(incat, table, key_list=[])

Get a list of records from a table (now using PyFITS to increase precision)

Return a list of dictionaries, One dictionary per row in the table. Keys in the dictionary correpsond to keys in the table. Values are either ints, strings or float, or tuples of ints or floats.

astro.external.LDAC.get_table_description(incat, table)

Get a description of a table

incat: Catalog filename table: Table Name

Returns a dictionary where the keys correspond to the keys in the table, and the values are tuples containing (key_number, key_type, key_dimension)

key_type is one of [int, str, float] key_dimension is 0 for a int or float and length for a sequence

astro.external.LDAC.getastrom_res(rescat, fieldnr, chipnr, kappa=3.0)

Calculate the residuals for individual pointings and chips.

rescat: input residuals catalog from LDAC.astrom
fieldnr: index for a specific pointing
chipnr: index or a specific chip
kappa: Sigma clipping factor to apply to DRA/DDEC data (a value
of 0 disables clipping)

The return is a tuple of:

( ref_ar, ref_ad, ref_str, ref_std, ref_n, ref_rms,
over_ar, over_ad, over_str, over_std, over_n, over_rms)

where the values are the average DRA and DDEC, the sample standard deviation of DRA and DDEC, the number of pairs used in the solution for this fieldnr/chipnr, and the RMS of the hypotenuse of DRA and DDEC, respectively for the reference pairs and overlap pairs, respectively.

astro.external.LDAC.getastrom_stat(incat, rescat, fieldnr, chipnr)

Some overkill here in astrom list, but ready for later use

astro.external.LDAC.list2string(name_list)

astro.external.PhotRed module

exception astro.external.PhotRed.PhotRedError

Bases: Exception

astro.external.PhotRed.run_photred(infile)

run photred

infile photred input file

astro.external.PhotRed.run_sedfilter(infile)

astro.external.PhotoObjAll module

TABLE PhotoObjAll

Contains a record describing the attributes of each photometric object

The table has views:

  • PhotoObj: all primary and secondary objects; essentially this is the view you should use unless you want a specific type of object.
  • PhotoPrimary: all photo objects that are primary (the best version of the object).
    o Star: Primary objects that are classified as stars. o Galaxy: Primary objects that are classified as galaxies. o Sky:Primary objects which are sky samples. o Unknown:Primary objects which are no0ne of the above
  • PhotoSecondary: all photo objects that are secondary (secondary detections)
  • PhotoFamily: all photo objects which are neither primary nor secondary (blended)

The table has indices that cover the popular columns.

name alias type unit ucd description
astro.external.PhotoObjAll.main()

astro.external.Photoz module

TABLE Photoz The photometrically estimated redshifts for all objects in PhotoObjAll.

Please see the Photometric Redshifts entry in Algorithms for more information about the Photoz and Photoz2 tables. NOTE: This table may be empty initially because the photoz values are computed in a separate calculation after the main data release.

name type length unit ucd description

name alias type unit ucd description

astro.external.Photoz2 module

TABLE Photoz2 Alternate computation of photometrically estimated redshifts for objects in the Galaxy view.

Please see the Photometric Redshifts entry in Algorithms for more information about the Photoz and Photoz2 tables. NOTE: This table may be empty initially because the photoz values are computed in a separate calculation after the main data release.

name type length unit ucd description

name alias type unit ucd description

astro.external.Psfex module

Interface to the Psfex PSF extraction program

exception astro.external.Psfex.PsfexError

Bases: Exception

astro.external.Psfex.psfex(catalog_name, config=None, executable='psfex')

Run PSFEx on a catalog

catalog_name : str
filename of a catalog
config : PsfexConfig
configuration object
executable : str
filename of the executable

astro.external.Pullecenella module

Pullecenella masking package

Please send bug reports and suggestions to <joeyfuerimmer@gmail.com> Please send bug reports and suggestions to <zhuoyi.huang@oa-roma.inaf.it>

exception astro.external.Pullecenella.PullecenellaError(message)

Bases: common.log.Error.Error

astro.external.Pullecenella.changekey(filename, key, value=None, comment='')

Pullecenella changekey

append, update, or delete FITS header keywords

filename: name of FITS file to operate on
key: FITS keyword to change

value: value of FITS keyword

comment: associated FITS comment

astro.external.Pullecenella.convreg(regname, maskname, naxis1, naxis2)

Pullecenella convreg

convert region file into fits mask image

regname: name of input region file
maskname: name of output FITS mask file
naxis1: NAXIS1 of output FITS mask file naxis2: NAXIS2 of output FITS mask file
astro.external.Pullecenella.corryc(incatname, segname, outcatname, flag_max)

Pullecenella corryc

update a catalog with a flag limit and SExtractor segmentation image

incatname: filename of input SExtractor catalog (see NOTE)
segname: filename of input SExtractor segmentation image
outcatname: filename of output SExtractor catalog (see NOTE)
flag_max: maximum flag before YWIN_IMAGE is updated
NOTE: The input SExtractor catalog must be of specific form:
NUMBER, XWIN_IMAGE, YWIN_IMAGE, FLAGS, ISOAREA_IMAGE, XMIN_IMAGE, XMAX_IMAGE, YMIN_IMAGE, YMAX_IMAGE

These 9 columns must be in this order! The output catalog will follow this convention.

astro.external.Pullecenella.maskmerge(inmaskname, flagname, flag, outmaskname)

Pullecenella maskmerge

merge (OR) a single value mask image into star mask image

inmaskname: filename of input mask image
flagname: filename of input flag mask image (single value)
flag: flag value of input mask image

outmaskname: filename of output mask image

astro.external.Pullecenella.maskpix(frame, flagname, threshold=50000)

Pullecenella maskpix

mask bad pixels and report empty margin

frame: input frame to be masked

flagname: filename of output flag image

threshold: non-negative saturation threshold [image units]

astro.external.Pullecenella.maskstar(maskname, flagname, naxis1, naxis2)

Pullecenella maskstar

convert region mask file into FITS flag image

maskname: name input mask region file flagname: name of output FITS flag file

naxis1: NAXIS1 of output FITS flag file naxis2: NAXIS2 of output FITS flag file
astro.external.Pullecenella.regstar(catname, regname, rotation, color, config, offset=0)

Pullecenella regstar

generate mask region file from input SExtractor catalog

catname: filename of input SExtractor catalog (see NOTE) regname: name of output region file
rotation: value telescope rotation [deg] (usually ABSROT)
color: color of this region

config: filename of regstar configuration offset: offset of mask [pixel]

NOTE: The input SExtractor catalog must be of specific form:
NUMBER, XWIN_IMAGE, YWIN_IMAGE, FLAGS, ISOAREA_IMAGE, XMIN_IMAGE, XMAX_IMAGE, YMIN_IMAGE, YMAX_IMAGE

These 9 columns must be in this order!

astro.external.Pullecenella.regtofits(regname, flagname, naxis1, naxis2)

Pullecenella regtofits

mask pixels inside regions

regname: name of input region file (supported region format:
circle, box, triangle)
flagname: name of output FITS flag file
naxis1: NAXIS1 of output FITS flag file naxis2: NAXIS2 of output FITS flag file

astro.external.STIFF module

STIFF PYTHON INTERFACE

exception astro.external.STIFF.STIFFError(reason='UNEXPECTED ERROR')

Bases: Exception

astro.external.STIFF.stiff(filename, convert_options='', executable='stiff', **config)

Create a thumbnail from a FITS image

filename : str
filename of FITS image
convert_options : str
string of options to pass to ImageMagick’s convert
executable : str
filename of the executable
config : dictionary
actually keyword arguments containing the STIFF configuration options
astro.external.STIFF.write_stiff_config(config, configname='stiff.conf')

astro.external.Satmask module

Satmask.py

Mask satellite tracks using manually determined endpoints from thumbnails.

Original source:

https://github.com/KiDS-WL/KIDS_cosmic_shear/tree/master/satellitemasking

astro.external.Satmask.create_masks(coadd, trackinexp, allbegs, allends, verbose=False)

Create masks for regrids found to contain satellite tracks.

coadd : CoaddedRegriddedFrame
Coadd object containing links to its source RegriddedFrames.
trackinexp : array
Mask containing information about which exposure contains a given satellite track.
allbegs : array
Beginning coordinates of the regions containing a satellite track to be masked, in world coordinates.
allends : array
Ending coordinates of the regions containing a satellite track to be masked, in world coordinates.
verbose : bool
informational messages switch
list
DARMA bitmask objects for each regrid that needs masking. The filename of the bitmask object contains the basename of the regrid it was derived for.
astro.external.Satmask.filtered_level(line)

This function median filters a line throwing away the top and bottom 10 percentile.

line : array-like
A 1D array to be median filtered and clipped.
array-like
The median filtered and clipped 1D array.

Consider parameterizing the window, and clipping limit.

astro.external.Satmask.get_image_size(filename)

Determine the image type of input image file and return its size.

filename : str
name of file to introspect
tuple
(width, height) of the input image file

from draco

astro.external.Satmask.get_track_medians(begs, ends, subhdus, dslope=0, width=0, stepslope=1, stepwidth=1)

Derive a filtered median level of counts along lines discovered in the data array of each ccd in subhdus.

begs : array-like
A set of beginning world coordinate pairs, shape = (n, 2).
ends : array-like
A set of ending world coordinate pairs, shape = (n, 2).
subhdus : list
ImageHDU objects potentially containing satellite tracks.
dslope : int
The maximum variation in slope to try (perturb one end by +dslope, the other end by -dslope).
width : int
The half-width of the strip to explore: zero for finding tracks, wider for mapping out best-fit location.
stepslope : int
Parameter to scale the slope for each step.
stepwidth : int
Parameter to scale the width for each step.
array
An array of median levels of shape = (n,) if dslope == 0 and width == 0, or a set of arrays of medians of shape = (n, 2*width+1, 2*dslope+1).
astro.external.Satmask.identify_frames(coadd, coords, verbose=False)

Identify which regrids of each frame contain a satellite track that needs to be masked.

coadd : CoaddedRegriddedFrame
Coadd object containing links to its source RegriddedFrames.
coords : list
Coordinates of corners of the regions containing a satellite track to be masked, in world coordinates.
verbose : bool
informational messages switch
(array, array, array)
Arrays containing track per exposure indication, beginning coordinates, ending coordinates, the last two indicating the tail end points in WCS coordinates.
astro.external.Satmask.mask_tracks(regs, begs, ends, dx1, dx2, width, pkflx, verbose=False)

Create the bitmasks corresponding to the tracks found in each exposure.

regs : list
RegriddedFrame objects containing tracks to mask.
begs : array
Beginning coordinates of the regions containing a satellite track to be masked, in world coordinates.
ends : array
Ending coordinates of the regions containing a satellite track to be masked, in world coordinates.
dx1 : array
Position tweaks in pixels to coordinates in begs.
dx2 : array
Position tweaks in pixels to coordinates in ends.
width : array
The half-width to be masked, in the coordinate direction most orthogonal to the track.
pkflx : array
The peak flux of the track.
verbose : bool
Informational messages switch.
list
DAMRA bitmasks corresponding to the tracks found in this exposure.
astro.external.Satmask.medfilt(x, k)

Apply a length-k median filter to a 1D array x. Boundaries are extended by repeating endpoints.

astro.external.Satmask.sat_txt2reg_split(coadd, endsname='', ends=[], regname='', verbose=False)

Convert endpoints of satellite tracks found in a standard deviation thumbnail of a coadd into track masks, splitting them into manageable chunks. Output the corner coordinates of these new chunks.

coadd : CoaddedRegriddedFrame
coadd object containing the coadd metadata and method to find thumbnail.
endsname : str
name of file containing endpoint coordinates marked from the thumbnail.
regname : str
name of region file to write if specified
verbose : bool
informational messages switch
tuple
two lists of coordinates converted from X,Y in the thumbnail to RA,Dec in the coadd, the second split in parts.
astro.external.Satmask.split_tracks(savedxy, maxseglength=75, verbose=True)

Tracks longer than maxseglength on thumbnail get split (corr. to ~1000 pix = 200”) with overlaps the mask pieces are 2x as long.

astro.external.Satmask.write_coords_as_region_file(coords, regname, verbose=True)

astro.external.Scamp module

interface to the Scamp astrometry and photometry program

Example:
scamp(catalogs=[‘cat1.cat’, ‘cat2.cat’ ],
config=<specify a ScampConfig object>)
exception astro.external.Scamp.ScampError

Bases: Exception

astro.external.Scamp.scamp(catalogs, config=None, executable='scamp-2.0.4')

Run scamp on a list of catalogs.

catalogs : list
filenames of input catalogs
config : ScampConfig
configuration object
executable : str
filename of the executable
NOTE: If the configuration is not given, the default configuration
will be used.

astro.external.Sextractor module

Interface to the SExtractor source extraction program

sex(image1, image2=None, config={}, KEY1=VAL1, KEY2=VAL2, …)

image1 = Detection (and measurement) image image2 = (optional) Measurement image config = An (optional) dictionary of configuration parameters KEY1, KEY2, = (optional) configuration parameters

Returns 1 on succes, 0 otherwise

exception astro.external.Sextractor.SextractorError

Bases: Exception

astro.external.Sextractor.make_filter(filename, fwhm, pixsize, dimension)

Write a custom gaussian filter

filename: name of the filter
fwhm: full-width-half-maximum (arcsec)

pixsize: pixel size (arcsec)

dimension: filter size (pixels)

astro.external.Sextractor.sex(image1, image2=None, params=None, config=None, executable='sex')

Set SExtractor parameters and configuration and run.

image1 : str
Detection (and measurement) image
image2 : str
(optional) Measurement image
params : str
(optional) extra output parameters (Parameters object)
config : SexConfig
(optional) configuration options (Config object)
executable : str
filename of the executable
NOTE: If either params or config is not specified, the defaults will
be used.

astro.external.SextractorParametersList module

astro.external.SpecObjAll module

TABLE SpecObjAll

Contains the measured parameters for a spectrum.

This is a base table containing ALL the spectroscopic information, including a lot of duplicate and bad data. Use the SpecObj view instead, which has the data properly filtered for cleanliness.

name alias type unit ucd description
astro.external.SpecObjAll.main()

astro.external.Swarp module

interface to the Swarp image regridding program

Example:
swarp(images=[‘image1.fits’, ‘image2.fits’],
weights=[‘weight1.fits’, ‘weight2.fits’], config=<specify a SwarpConfig object>)
exception astro.external.Swarp.SwarpError

Bases: Exception

Symbolic links are used to keep filenames and also the total command line length limited. SWarp has certain maxima in this regard. Goal is to use WEIGHT_SUFFIX, so all weights have symbolic link name equal to the symbolic link name of the images with the suffix ‘weight’ inserted.

A tuple of a list of the symbolic links for the images and the symbolic links for the weights is returned.

astro.external.Swarp.swarp(images, weights=[], config=None, executable='swarp')

Run swarp on a list of images.

images : list
image filenames
weights : list
weight filenames belonging to the images (in the same order)
config : SwarpConfig
configuration object
executable : str
filename of the executable
NOTE: If the filename containing the configuration is not given, the
default configuration will be used.

astro.external.TWOMASS module

TABLE 2MASS

astro.external.TWOMASS.get_htmrange_2mass_psc()
astro.external.TWOMASS.get_htmrange_2mass_xsc()
astro.external.TWOMASS.get_ranges_from_file(item, filename)
astro.external.TWOMASS.stod(arg)

astro.external.TinyTim module

This is a simple interface to run TinyTim (v6.3) on ACS data

Example command:

>>> tinytim(paramfile='tiny.conf', instrument=15, chip=1, x=10, y=10,
            filter='f555w', spectrum=2, coeff=2000, diameter=3,
            filename='psf_image')
astro.external.TinyTim.check_chip(chip)
astro.external.TinyTim.check_extinction(ebmv, Av)
astro.external.TinyTim.check_filter(filter)
astro.external.TinyTim.check_gaussian(major, minor, angle)

Check that all three parameters major, minor, angle are set. Actually we can’t do much to check the angle, just that major and minor exist.

astro.external.TinyTim.check_instrument(instrument)
astro.external.TinyTim.check_position(x, y)
astro.external.TinyTim.check_spectrum(spectrum, coeff)
astro.external.TinyTim.check_star(spectral_type)
astro.external.TinyTim.make_options_string(major=0.0, minor=0.0, angle=0.0, jitter=0.0, ebmv=0.0, Av=0.0, wmag=0.0)
astro.external.TinyTim.tiny1(paramfile, instrument, chip, x, y, filter, spectrum, coeff, diameter, filename, major=0.0, minor=0.0, angle=0.0, jitter=0.0, ebmv=0.0, Av=0.0, wmag=0.0)

tiny1 (the C program) is used to interactively create the configuration file which is used by tiny2 and optionally tiny3. This interface takes all the commands, normally given interactively, as its arguments, and sends them to the tiny1 program.

astro.external.TinyTim.tiny2(paramfile)

Interface to tiny2. Simply runs “tiny2 <paramfile>”.

astro.external.TinyTim.tiny3(paramfile)

Interface to tiny3. Simply runs “tiny3 <paramfile>”.

astro.external.TinyTim.tinytim(paramfile, instrument, chip, x, y, filter, spectrum, coeff, diameter, filename, major=0.0, minor=0.0, angle=0.0, jitter=0.0, ebmv=0.0, Av=0.0, wmag=0.0)

astro.external.USNOB module

TABLE USNO-B1.0

astro.external.USNOB.ab(arg)

astro.external.aweimports module

astro.external.lasSource module

TABLE WSA_lasSource

Contains LAS merged sources from LAS detections in lasDetection.

Name Alias Type Unit UCD Description Default Value

Module contents

Python wrappers for software packages

Some software packages contain useful routines, but are not available as Python extension modules. Modules are defined for those external packages which hide the (command-line) programs from the Python user. Hence a Python interface and syntax is available to use the routines in the software packages. Note that the routines in these modules are used in other places and their particular names remain invisible. This is done to ensure easy replacement of the package by (or comparison with) another package that provides the same functionality.

Package | Purpose

LDAC | Perform astrometry and association on FITS tables SExtractor | Extract source positions and other parameters from a FITS image Swarp | Reproject and co-add FITS images