Esempio n. 1
0
    def buildRecipeInput(self, obsres):

        if self.sky_image is None:
            print('obtaining SKY image')
            sky_cal_result = self.dal.getLastRecipeResult(
                "EMIR", "EMIR", "IMAGE_SKY")
            self.sky_image = sky_cal_result['elements']['skyframe']

        obsres['master_sky'] = self.sky_image
        newOR = ObservationResult()
        newOR.frames = obsres['frames']
        obsres['obresult'] = newOR
        newRI = StareImageRecipeInput(**obsres)

        return newRI
Esempio n. 2
0
    def run_single(self, rinput):
        self.logger.info('starting spectroscopy ABBA reduction')

        flow = self.init_filters(rinput)
        nimages = len(rinput.obresult.frames)
        self.logger.info('we receive %d images', nimages)
        if nimages != 4:
            msg = 'Recipe expects 4 images, received %d' % nimages
            raise numina.exceptions.RecipeError(msg)

        procesed_hdulists = basic_processing(rinput, flow)

        # INPUTS are ABBA, so
        #
        hdulist = self.process_abba(procesed_hdulists)
        grism = hdulist[0].header.get('GRISM', 'unknown')
        if grism.lower() == 'open':
            # perform TEST10 in addition
            import emirdrp.recipes.acquisition.maskcheck as mk
            from numina.core import ObservationResult, DataFrame
            import numpy
            try:
                import StringIO as S
            except ImportError:
                import io as S

            self.logger.info('GRISM is OPEN, doing a RECIPE10')
            sub = mk.MaskCheckRecipe()
            sub.configure(instrument='EMIR', mode='TEST10')
            o = ObservationResult()
            o.__dict__ = rinput.obresult.__dict__
            o.frames = [DataFrame(frame=hdulist)]
            subd = {}
            subd['obresult'] = o
            ss = S.StringIO(_NOMINALPOS)
            subd['bars_nominal_positions'] = numpy.loadtxt(ss)

            subinput = mk.MaskCheckRecipe.RecipeInput(**subd)

            sub.run(subinput)

        result = self.create_result(reduced_mos_abba=hdulist)
        self.logger.info('end spectroscopy ABBA reduction')
        return result
Esempio n. 3
0
    def build_recipe_input_gtc(self, obsres, dal, pipeline='default'):
        newOR = ObservationResult()
        # FIXME: this method will work only in GTC
        # stareImagesIds = obsres['stareImagesIds']._v
        stareImagesIds = obsres.stareImagesIds
        obsres.children = stareImagesIds
        self.logger.info('Submode result IDs: %s', obsres.children)
        stareImages = []
        # Field to query the results
        key_field = 'frame'
        for subresId in obsres.children:
            subres = dal.getRecipeResult(subresId)
            # This 'frame' is the name of the product in RecipeResult
            # there is also a 'sky' field
            elements = subres['elements']
            stareImages.append(elements[key_field])
        newOR.frames = stareImages

        naccum = obsres.naccum
        self.logger.info('naccum: %d', naccum)
        mode_field = "DITHERED_IMAGE"
        key_field = 'accum'
        if naccum != 1:  # if it is not the first dithering loop
            self.logger.info("SEARCHING LATEST RESULT of %s", mode_field)
            latest_result = dal.getLastRecipeResult("EMIR", "EMIR", mode_field)
            elements = latest_result['elements']
            accum_dither = elements[key_field]
            self.logger.info("FOUND")
        else:
            self.logger.info("NO ACCUMULATION")
            accum_dither = stareImages[0]

        newOR.naccum = naccum
        newOR.accum = accum_dither

        # obsres['obresult'] = newOR
        # print('Adding RI parameters ', obsres)
        # newRI = DitheredImageARecipeInput(**obsres)
        newRI = self.create_input(obresult=newOR)
        return newRI