astromatic API Reference
Wrappers around the astromatic.net software library.
-
class moastro.astromatic.Astromatic(configs=None, workDir='.', defaultsPath=None)[source]
Abstract base class for the Astromatic software wrappers
(SExtractor, SCAMP, Swarp).
-
add_default_param_to_configs(defaultsCommand, name='defaults.txt')[source]
Adds the default parameters filepath to the configs dictionary.
Writes a new defaults file is one is not found/available.
-
add_to_configs(key, value)[source]
Add a key, with a value, to the configs dictionary. Use this to
ensure the configs are initialized.
-
make_command()[source]
Place holder subclass to generate the command line string for
running the Terapix program.
-
make_config_command()[source]
Joins the command line configuration arguments together, returning
a string.
-
run(virtualHost=None)[source]
Runs the command process.
The optional virtualHost is a tuple with format:
-
set_null_config(key, null='""')[source]
Sets the value of the key configuration to the null value, which
is a null string (“”) by default. If null is None, the the key is
deleted altogether.
-
write_defaults_file(defaultsCommand)[source]
Writes the Swarp internal defaults and returns its path.
-
write_input_file_list(inputFITSPaths, name='inputlist')[source]
Writes the path of each FITS file to a file
workDir/inputlist.txt
Run Source Extractor in parallel on multiple processors. ImageLog is
used to store results from each run.
docstring for run
Parameters: | checkKeyDict – dictionary specifying SE check image types, and
the image log keys to store paths to those images under.
Keys are check type (SEGMENTATION, etc), values are image log
keys. |
-
class moastro.astromatic.PSFex(catalogPaths, imageLog=None, imageKeys=None, defaultsPath=None, configs=None, xmlKey=None, workDir='psfex', groupName=None)[source]
Wrapper on the PSFex PSF-modelling software.
-
check_path(checkType)[source]
Returns the path to the specified type of check iamage.
-
classmethod from_db(imageLog, imageKeys, catalogPathKey, configs=None, xmlKey=None, defaultsPath=None, workDir='psfex')[source]
Creates a PSFex run from an image log database.
Parameters: |
- imageLog – a ImageLog-compatible database instance.
- imageKeys – image keys in the imageLog where SE catalogs will be
gathered.
- catalogPathKey – record field where the SE (Source Extractor)
catalogs are found for each image
- xmlKey – key to install XML. If None, then PSFex will
not produce XML output.
- configs – (optional) dictionary of PSFex settings. Keys and
values are standard PSFex command line arguments.
- defaultsPath – path to where a PSFex configuration file can be
found
- workDir – directory where PSFex outputs are saved.
|
-
make_command()[source]
Makes the source extractor command (for CL execution).
Returns a string.
-
psf_paths()[source]
Get the paths to each image, in the same order as the input
catalog paths.
-
save_psf_paths(psfKey)[source]
Files the psf file paths into the image log under psfKey for
all images.
-
save_xml_paths()[source]
Files the xml filepaths into image log under xmlKey for all
images.
-
set_check_images(checkList, prefix, checkDir)[source]
Sets which check images should be made, and where they should be
saved. By default, all checkimages retain the base file name, plus
and appropriate extension.
Parameters: | checkList – sequence of check image types. May include: |
- CHI
- PROTOTYPES
- SAMPLES
- RESIDUALS
- SNAPSHOTS
- MOFFAT
- -MOFFAT
- -SYMMETRICAL
- BASIS
Parameters: |
- prefix – filename prefix for all check images.
- checkDir – directory where the check images should be saved.
|
-
set_check_plots(plotList, prefix, plotDir, plotType='PDF')[source]
Sets which check figures (plplot) should be made, and where they
should be saved.
Parameters: | checkList – sequence of check figure types. May include: |
FWHM - map of PSF FWHM over field
ELLIPTICITY - map of PSF ellipticity over field
COUNTS - map of spatial density of point sources
- COUNT_FRACTION - map of fraction of points accepted for
PSF evaluation
CHI2 - map of average chi^2/d.o.f over field
MOFFAT_RESIDUALS - map of moffat residuals
ASYMMETRY - map of asymmetry indices
-
class moastro.astromatic.Scamp(seCatPaths, imageLog=None, imageKeys=None, defaultsPath=None, configs=None, checks=None, workDir='scamp', useFileRefs=False)[source]
Python wrapper class for Terapix’s SCAMP application for astrometric
and photometric registration of mosaics.
Note
the useFileRefs=True feature seems to be broken b/c SCAMP doesn’t
recognize the files that it downloaded itself. For now, always use False
for this option.
-
classmethod from_db(imageLog, imageKeys, seCatKey, defaultsPath=None, configs=None, checks=None, workDir='scamp', useFileRefs=False)[source]
Construct a SCAMP run from an image log database.
-
make_command()[source]
Writes the command to run scamp, and returns as a string.
-
refcatalog_paths()[source]
Returns the paths to existing reference catalogs.
Insert the SExtractor objects from the self.headDB dictionary to
the given imageLog under the key scampKey. Must have instantiated
Scamp with Scamp.from_db() so that the image keys are known.
-
set_check_plots(checks)[source]
Initializes the scamp checkplot types, and associated file names.
By default, the file names are lower-cased versions of the check type,
and the files are placed in the workDir.
Represents a run of Terapix’s Source Extractor.
Returns the path to the SE catalog.
Returns the path to a check image of type checkType. Returns None
if no such check image exists.
-
make_command()[source]
Makes the source extractor command (for CL execution).
Returns a string.
Sets which check images should be made, and where they should be
saved. By default, all checkimages retain the base file name, plus an
appropriate extension.
Sets a weight image as a FITS at weightPath of SE weight image
type weightType.
-
class moastro.astromatic.Swarp(imagePaths, mosaicName, scampHeadPaths=None, weightPaths=None, defaultsPath=None, configs=None, workDir='mosaic', uniqueExt='')[source]
This class wraps the functionality of Astromatic’s Swarp mosaic
software.
-
copy_mosaic_wcs(headerPath)[source]
Copies the WCS keys in the header of the mosaic image (as produced)
by swarp.run() to an ascii header file at headerPath.
This is useful for creating a .head file for use with a second run of
Swarp with another data set (like a different colour) so that the
pixel-sky projection is the same in both.
TODO DEPRECATED Refactored as a function in Terapix.py. Keep this
method around as a wrapper to Terapix.copyHeaderWCS().
-
classmethod from_db(imageLog, imageKeys, pathKey, mosaicName, scampHeadPathKey=None, weightPathKey=None, defaultsPath=None, configs=None, workDir='mosaic', uniqueExt='')[source]
Construct a Swarp run from database records.
-
make_command()[source]
Produces the command to run Swarp.
-
mosaic_paths()[source]
Returns: | tuple of (mosaic path, mosaic weight path). |
-
set_target_fits(targetFITSPath)[source]
Use the header of targetFITSPath to define output pixel space.
This method links targetFITSPath to mosaicName”.head”, which
Swarp automatically recognizes.
Alternative to set_target_wcs, it creates writes the header
to the appropriate filename and tells swarp to use it as a base WCS
reference.
-
write_input_file_list(paths, name='list')[source]
Override the Terapix class’s method so that lists of imagePaths,
associated with a single image image key can be expanded.
The motivation for this is when doing a combine step on a previous
resampling step. Resampling will break apart multi-extension FITS
files, causing a single image of weight image to now be several
images. When the user applies Swarp on the combine step, the
imagePathKey (and the weightKey) must be lists to that set of FITS
files.