def __init__(self, args=None): if args is None: args = sys.argv[1:] if isinstance(args, str): args = args.split(' ') parser = argparse.ArgumentParser( 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( '-o', '--output-path', type=str, 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.' ) try: parsed = parser.parse_args(args=args) except SystemExit: return 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) self.sources[source].save(out_path)
def __init__(self, args=None): if args is None: args = sys.argv[1:] if isinstance(args, str): args = args.split(' ') parser = argparse.ArgumentParser( 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( '-o', '--output-path', type=str, 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.') try: parsed = parser.parse_args(args=args) except SystemExit: return 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) self.sources[source].save(out_path)
def run_exp_to_source(): inputs = [MultiSlitModel(f) for f in helpers.INPUT_FILES] outputs = exp_to_source(inputs) return inputs, outputs
def run_exp_to_source(): inputs = [MultiSlitModel(f) for f in helpers.INPUT_FILES] outputs = exp_to_source(inputs) yield inputs, outputs for model in inputs: model.close()