descwl.output module¶
Configure and handle simulation output.
There is a separate output page with details on what goes into the output and how it is formatted.
-
class
descwl.output.
Reader
(input_name, defer_stamp_loading=True)[source]¶ Bases:
object
Simulation output reader.
The reader loads the file’s contents into memory in the constructor and makes them available via a results data member of type
descwl.analysis.OverlapResults
. Loading of stamp datacubes can be defered until stamps are acutally accessed using the defer_stamp_loading argument below.We use fitsio to read files since it performs significantly faster than
astropy.io.fits
for files with many (~100K) relatively small HDUs (althoughastropy.io.fits
outperforms fitsio for writing these files).Parameters: - input_name (str) – Base name of FITS output files to write. The ”.fits” extension can be omitted.
- defer_stamp_loading (bool) – Defer the loading of stamp datacubes until they are actually
accessed via
descwl.OverlapResults.get_stamp()
of our results data member. This speeds up the constructor substantially and reduces memory requirements when relatively few stamps are actually needed.
Raises: RuntimeError
– Unable to initialize FITS input file.-
static
add_args
(parser)[source]¶ Add command-line arguments for constructing a new
Reader
.The added arguments are our constructor arguments with ‘_’ replaced by ‘-‘ in the names. The defer_stamp_loading constructor argument is not added here.
Parameters: parser (argparse.ArgumentParser) – Arguments will be added to this parser object using its add_argument method.
-
classmethod
from_args
(defer_stamp_loading, args)[source]¶ Create a new
Reader
object from a set of arguments.Parameters: - defer_stamp_loading (bool) – Defer the loading of stamp datacubes until they are actually
accessed via
descwl.OverlapResults.get_stamp()
of our results data member. This speeds up the constructor substantially and reduces memory requirements when relatively few stamps are actually needed. - args (object) – A set of arguments accessed as a
dict
using the built-invars()
function. Any extra arguments beyond those defined inadd_args()
will be silently ignored.
Returns: A newly constructed Reader object.
Return type: - defer_stamp_loading (bool) – Defer the loading of stamp datacubes until they are actually
accessed via
-
class
descwl.output.
Writer
(survey, output_name, no_stamps, no_catalog, output_no_clobber)[source]¶ Bases:
object
Simulation output writer.
See the output page for details on the output contents and formatting.
We use
astropy.io.fits
to write files since it performs significanly faster than fitsio for files with many (~100K) relatively small HDUs (although fitsio outperformsastropy.io.fits
for reading these files). See this issue for details and updates.Parameters: - survey (descwl.survey.Survey) – Simulated survey to describe with FITS header keywords.
- output_name (str) – Base name of FITS output files to write. The ”.fits” extension can be omitted.
- no_catalog (bool) – Do not save the results catalog.
- no_stamps (bool) – Do not save postage stamp datacubes for each source.
- output_no_clobber (bool) – Do not overwrite any existing output file with the same name.
Raises: RuntimeError
– Unable to initialize FITS output file.-
static
add_args
(parser)[source]¶ Add command-line arguments for constructing a new
Writer
.The added arguments are our constructor parameters with ‘_’ replaced by ‘-‘ in the names.
Parameters: parser (argparse.ArgumentParser) – Arguments will be added to this parser object using its add_argument method.
-
description
()[source]¶ Describe our output configuration.
Returns: Description of the the rendering configuration. Return type: str
-
finalize
(results, trace)[source]¶ Save analysis results and close the output file, if any.
This call builds the entire FITS file in memory then writes it to disk.
:param
descwl.analysis.OverlapResults
: Overlap analysis results. :param trace: Function to call for tracing resource usage. Will becalled with a briefstr
description of each checkpoint.
-
classmethod
from_args
(survey, args)[source]¶ Create a new
Writer
object from a set of arguments.Parameters: - survey (descwl.survey.Survey) – Simulated survey to describe with FITS header keywords.
- args (object) – A set of arguments accessed as a
dict
using the built-invars()
function. Any extra arguments beyond those defined inadd_args()
will be silently ignored.
Returns: A newly constructed Reader object.
Return type: