Example #1
0
def test_ccdmask_empty_mask():
    flat1 = numpy.ones((2000, 2000))
    flat1[0:100, 0] = 0
    flat2 = flat1
    mask = numpy.zeros((2000, 2000), dtype="int")
    bpm2 = ccdmask(flat1, flat2, mask, mode="full")
    assert bpm2[1].sum() == 100
Example #2
0
    def run(self, rinput):
        self.logger.info('start BPM recipe')
        N = len(rinput.obresult.frames)

        self.logger.debug('we have %d images', N)
        half = N // 2
        flow = self.init_filters(rinput, rinput.obresult.configuration)
        self.logger.debug('we have %d images', N)
        reduced1 = basic_processing_with_combination_frames(
            rinput.obresult.frames[:half],
            flow,
            method=combine.median
        )

        self.save_intermediate_img(reduced1, 'reduced1.fits')

        reduced2 = basic_processing_with_combination_frames(
            rinput.obresult.frames[half:],
            flow,
            method=combine.median
        )

        self.save_intermediate_img(reduced2, 'reduced2.fits')

        ratio, mask, sigma = ccdmask(reduced1[0].data, reduced2[0].data, mode='full')

        hdu = fits.PrimaryHDU(mask, header=reduced1[0].header)
        hdu.header['UUID'] = uuid.uuid1().hex
        hdu.header['OBJECT'] = 'MASTER BPM'
        hdu.header['IMAGETYP'] = 'BPM'
        self.set_base_headers(hdu.header)

        hdu.header['history'] = 'BPM creation time {}'.format(
            datetime.datetime.utcnow().isoformat()
        )

        for frame in rinput.obresult.frames:
            hdu.header['history'] = "With image {}".format(
                self.datamodel.get_imgid(frame.open())
            )

        reduced = fits.HDUList([hdu])
        self.logger.info('end BPM recipe')
        return self.create_result(master_bpm=reduced)
Example #3
0
def test_ccdmask_no_mask():
    flat1 = numpy.ones((2000, 2000))
    flat1[0:100, 0] = 0
    flat2 = flat1
    bpm2 = ccdmask(flat1, flat2, mode="full")
    assert bpm2[1].sum() == 100
Example #4
0
def test_ccdmask_flat2_None():
    flat1 = numpy.ones((20, 20))
    bpm2 = ccdmask(flat1)
    assert bpm2[1].all() == False