def process(self, input):

        self.log.info("Starting preprocess flatfield ...")

        # Retrieve the input(s)
        asn = LoadAsLevel2Asn.load(input, basename=self.output_file)

        # Each exposure is a product in the association.
        # Process each exposure.
        results = []
        for product in asn["products"]:
            self.log.info("Processing product {}".format(product["name"]))
            if self.save_results:
                self.output_file = product["name"]
            result = self.process_exposure_product(product, asn["asn_pool"],
                                                   op.basename(asn.filename))

            # Save result
            suffix = "flat"
            result.meta.filename = self.make_output_path(suffix=suffix)
            results.append(result)

        self.log.info("... ending preprocess flatfield")

        self.output_use_model = True
        self.suffix = False
        return results
Ejemplo n.º 2
0
    def process(self, input):

        self.log.info("Starting calwebb_image2 ...")

        # Retrieve the input(s)
        asn = LoadAsLevel2Asn.load(input, basename=self.output_file)

        # Each exposure is a product in the association.
        # Process each exposure.
        results = []
        for product in asn["products"]:
            self.log.info("Processing product {}".format(product["name"]))
            if self.save_results:
                self.output_file = product["name"]
            try:
                getattr(asn, 'filename')
            except AttributeError:
                asn.filename = "singleton"

            result = self.process_exposure_product(product, asn["asn_pool"],
                                                   op.basename(asn.filename))

            # Save result
            suffix = "cal"
            if isinstance(result, datamodels.CubeModel):
                suffix = "calints"
            result.meta.filename = self.make_output_path(suffix=suffix)
            results.append(result)

        self.log.info("... ending calwebb_image2")

        self.output_use_model = True
        self.suffix = False
        return results
Ejemplo n.º 3
0
def test_lv2_obj():
    obj = 'some funny object'
    asn = LoadAsLevel2Asn.load(obj)
    assert asn.filename == DEFAULT_NAME
    assert len(asn['products']) == 1
    assert asn['program'] == DEFAULT_NAME
    assert asn['target'] == DEFAULT_NAME
    assert asn['asn_pool'] == DEFAULT_NAME
Ejemplo n.º 4
0
def test_lv2_datamodel():
    model = ImageModel()
    model.meta.filename = 'modelfile.fits'
    asn = LoadAsLevel2Asn.load(model)
    assert asn.filename == DEFAULT_NAME
    assert asn['program'] == DEFAULT_NAME
    assert asn['target'] == DEFAULT_NAME
    assert asn['asn_pool'] == DEFAULT_NAME
    assert len(asn['products']) == 1
    assert asn['products'][0]['name'] == 'modelfile'
Ejemplo n.º 5
0
def test_lv2_obj_list():
    model = ImageModel()
    model.meta.filename = 'modelfile.fits'
    objs = [
        'some funny object',
        model,
    ]
    asn = LoadAsLevel2Asn.load(objs)
    assert asn.filename == DEFAULT_NAME
    assert len(asn['products']) == 2
    assert asn['program'] == DEFAULT_NAME
    assert asn['target'] == DEFAULT_NAME
    assert asn['asn_pool'] == DEFAULT_NAME
Ejemplo n.º 6
0
def test_lv2_asn():
    asn_file = helpers.t_path('data/asn_level2.json')
    asn = LoadAsLevel2Asn.load(asn_file)
    assert asn.filename == asn_file
    assert len(asn['products']) == 6
Ejemplo n.º 7
0
def test_suffix_removal(test_input, expected):
    """Ensure appropriate suffix removal is occurring"""

    asn = LoadAsLevel2Asn.load([test_input])
    assert asn['products'][0]['name'] == expected