-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
89 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
More Information for JWST Users | ||
=============================== | ||
|
||
The documentation hosted here focuses primarily on calibration software | ||
implementation and use. | ||
|
||
For more user-focused information on JWST instruments and calibration methods, please | ||
see the | ||
`JWST science calibration pipeline <https://jwst-docs.stsci.edu/jwst-science-calibration-pipeline>`__ | ||
pages hosted on `JDox <https://jwst-docs.stsci.edu>`__. | ||
|
||
More information on the | ||
`latest build <https://jwst-docs.stsci.edu/jwst-science-calibration-pipeline/jwst-operations-pipeline-build-information>`__ | ||
in use for data processing operations is also available on JDox. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
from .exp_to_source import ( | ||
exp_to_source, | ||
multislit_to_container, | ||
) | ||
"""Conversion of Stage 2 exposure-based data products to Stage 3 source-based data products.""" | ||
|
||
__all__ = ['exp_to_source', 'multislit_to_container'] | ||
from .exp_to_source import exp_to_source, multislit_to_container | ||
|
||
__all__ = ["exp_to_source", "multislit_to_container"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,74 @@ | ||
import os | ||
import sys | ||
import argparse | ||
from pathlib import Path | ||
|
||
from stdatamodels.jwst.datamodels import MultiSlitModel | ||
|
||
from jwst.exp_to_source import exp_to_source | ||
|
||
|
||
class Main(): | ||
"""Convert exposure-based slits data to source-based data | ||
Docs from the source. | ||
Parameters | ||
---------- | ||
args: str or [str,...] | ||
The command-line arguments. This is passed to | ||
`argparse.parse_args`. If None, `sys.argv` | ||
is used. | ||
class Main: | ||
""" | ||
Convert exposure-based slits data to source-based data. | ||
Attributes | ||
---------- | ||
sources: {source: MultiExposureModel, ...} | ||
A dict keyed on source name whose value is | ||
the corresponding MultiExposureModel. | ||
Command-line interface to the exp_to_source step. For help, use | ||
exp_to_source -h. See also the exp_to_source readthedocs page: | ||
https://jwst-pipeline.readthedocs.io/en/latest/api/jwst.exp_to_source.exp_to_source.html#jwst.exp_to_source.exp_to_source | ||
""" | ||
|
||
def __init__(self, args=None): | ||
""" | ||
Initialize and run the exp_to_source step. | ||
Parameters | ||
---------- | ||
args : str or [str,...] | ||
The command-line arguments. This is passed to | ||
`argparse.parse_args`. If None, `sys.argv` | ||
is used. | ||
""" | ||
if args is None: | ||
args = sys.argv[1:] | ||
if isinstance(args, str): | ||
args = args.split(' ') | ||
args = args.split(" ") | ||
|
||
parser = argparse.ArgumentParser( | ||
description='Convert exposure-based data to source-based data', | ||
usage='python -m jwst.exp_to_source.main files' | ||
description="Convert exposure-based data to source-based data", | ||
usage="python -m jwst.exp_to_source.main files", | ||
) | ||
parser.add_argument( | ||
'files', | ||
type=str, | ||
nargs='+', | ||
help='Files to convert') | ||
parser.add_argument("files", type=str, nargs="+", help="Files to convert") | ||
|
||
parser.add_argument( | ||
'-o', '--output-path', | ||
"-o", | ||
"--output-path", | ||
type=str, | ||
default='.', | ||
help='Folder to save results in. Default: "%(default)s"' | ||
default=".", | ||
help='Folder to save results in. Default: "%(default)s"', | ||
) | ||
|
||
parser.add_argument( | ||
'--dry-run', | ||
action='store_true', dest='dry_run', | ||
help='Execute but do not save results.' | ||
"--dry-run", | ||
action="store_true", | ||
dest="dry_run", | ||
help="Execute but do not save results.", | ||
) | ||
|
||
try: | ||
parsed = parser.parse_args(args=args) | ||
except SystemExit: | ||
return | ||
|
||
# self.sources is a dict keyed on source name whose value is | ||
# the corresponding MultiExposureModel, | ||
# e.g. {source_name: MultiExposureModel, ...} | ||
exposures = [MultiSlitModel(f) for f in parsed.files] | ||
self.sources = exp_to_source(exposures) | ||
if not parsed.dry_run: | ||
for source in self.sources: | ||
out_path = '.'.join([source, 'fits']) | ||
out_path = os.path.join(parsed.output_path, out_path) | ||
out_path = ".".join([source, "fits"]) | ||
out_path = Path(parsed.output_path) / out_path | ||
self.sources[source].save(out_path) | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
Main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
# Testing helpers | ||
from glob import glob | ||
import os | ||
|
||
|
||
INPUT_FILES_GLOB = 'data/jwst_nod?_cal.fits' | ||
from pathlib import Path | ||
|
||
|
||
def t_path(partial_path): | ||
"""Construction the full path for test files""" | ||
test_dir = os.path.dirname(__file__) | ||
return os.path.join(test_dir, partial_path) | ||
"""Construct the full path for test files.""" | ||
test_dir = Path(__file__).parent | ||
return Path(test_dir) / partial_path | ||
|
||
|
||
# Calculate some extra constants | ||
INPUT_FILES_GLOB = t_path(INPUT_FILES_GLOB) | ||
INPUT_FILES = glob(t_path(INPUT_FILES_GLOB)) | ||
INPUT_FILES = list(t_path("data").glob("jwst_nod?_cal.fits")) | ||
INPUT_FILES = [str(infile) for infile in INPUT_FILES] |
This file was deleted.
Oops, something went wrong.