Exemplo n.º 1
0
    def run_qa(self, qatype, inputs, clobber=True):
        """Run QA tests of a given type
        Over-writes previous QA of this type, unless otherwise specified

        qatype: str  
          Type of QA to be performed (e.g. SKYSUB)
        inputs: tuple
          Set of inputs for the tests
        clobber: bool, optional [True]
          Over-write previous QA 
        """
        from desispec.sky import qa_skysub
        from desispec.fiberflat import qa_fiberflat
        from desispec.fluxcalibration import qa_fluxcalib

        # Check for previous QA if clobber==False
        if not clobber:
            # QA previously performed?
            if 'METRICS' in self.qa_data[qatype]:
                return
        # Run
        if qatype == 'SKYSUB':
            # Expecting: frame, skymodel
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_skysub()
            # Run
            qadict = qa_skysub(self.qa_data[qatype]['PARAMS'], inputs[0],
                               inputs[1])
        elif qatype == 'FIBERFLAT':
            # Expecting: frame, fiberflat
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fiberflat()
            # Run
            qadict = qa_fiberflat(self.qa_data[qatype]['PARAMS'], inputs[0],
                                  inputs[1])
        elif qatype == 'FLUXCALIB':
            # Expecting: frame, fluxcalib
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fluxcalib()
            # Run
            qadict = qa_fluxcalib(self.qa_data[qatype]['PARAMS'], inputs[0],
                                  inputs[1])
        else:
            raise ValueError('Not ready to perform {:s} QA'.format(qatype))
        # Update
        self.qa_data[qatype]['METRICS'] = qadict
Exemplo n.º 2
0
    def run_qa(self, qatype, inputs, clobber=True):
        """Run QA tests of a given type
        Over-writes previous QA of this type, unless otherwise specified

        qatype: str  
          Type of QA to be performed (e.g. SKYSUB)
        inputs: tuple
          Set of inputs for the tests
        clobber: bool, optional [True]
          Over-write previous QA 
        """
        from desispec.sky import qa_skysub
        from desispec.fiberflat import qa_fiberflat
        from desispec.fluxcalibration import qa_fluxcalib

        # Check for previous QA if clobber==False
        if not clobber:
            # QA previously performed?
            if 'QA' in self.qa_data[qatype].keys():
                return
        # Run
        if qatype == 'SKYSUB':
            # Expecting: frame, skymodel
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_skysub()
            # Run
            qadict = qa_skysub(self.qa_data[qatype]['PARAM'],
                inputs[0], inputs[1])
        elif qatype == 'FIBERFLAT':
            # Expecting: frame, fiberflat
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fiberflat()
            # Run
            qadict = qa_fiberflat(self.qa_data[qatype]['PARAM'], inputs[0], inputs[1])
        elif qatype == 'FLUXCALIB':
            # Expecting: frame, fluxcalib
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fluxcalib()
            # Run
            qadict = qa_fluxcalib(self.qa_data[qatype]['PARAM'], inputs[0], inputs[1])
        else:
            raise ValueError('Not ready to perform {:s} QA'.format(qatype))
        # Update
        self.qa_data[qatype]['QA'] = qadict
Exemplo n.º 3
0
    def run_qa(self, qatype, inputs, clobber=True):
        """Run QA tests of a given type
        Over-writes previous QA of this type, unless otherwise specified

        qatype: str
          Type of QA to be performed (e.g. SKYSUB)
        inputs: tuple
          Set of inputs for the tests
        clobber: bool, optional [True]
          Over-write previous QA

        Returns:
            bool
              True = Calculation performed
              False = Calculation not performed
        """
        from desispec.sky import qa_skysub
        from desispec.fiberflat import qa_fiberflat
        from desispec.fluxcalibration import qa_fluxcalib
        from desispec.qa.qalib import SNRFit

        # Check for previous QA if clobber==False
        if (not clobber) and (qatype in self.qa_data.keys()):
            # QA previously performed?
            if 'METRICS' in self.qa_data[qatype]:
                return False
        # Run
        if qatype == 'SKYSUB':
            # Expecting: frame, skymodel
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_skysub()
            # Run
            qadict = qa_skysub(self.qa_data[qatype]['PARAMS'], inputs[0],
                               inputs[1])
        elif qatype == 'FIBERFLAT':
            # Expecting: frame, fiberflat
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fiberflat()
            # Run
            qadict = qa_fiberflat(self.qa_data[qatype]['PARAMS'], inputs[0],
                                  inputs[1])
        elif qatype == 'FLUXCALIB':
            # Expecting: frame, fluxcalib
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fluxcalib()
            # Run
            qadict = qa_fluxcalib(self.qa_data[qatype]['PARAMS'], inputs[0],
                                  inputs[1])
        elif qatype == 'S2N':
            # Expecting only a frame
            assert len(inputs) == 1
            # Init parameters (as necessary)
            self.init_s2n()
            # Run
            qadict, fitsnr = SNRFit(inputs[0],
                                    self.night,
                                    self.camera,
                                    self.expid,
                                    self.qa_data[qatype]['PARAMS'],
                                    fidboundary=None,
                                    offline=True)
            # Remove undesired
            for key in ['RA', 'DEC']:
                qadict.pop(key)
        else:
            raise ValueError('Not ready to perform {:s} QA'.format(qatype))
        # Update
        self.qa_data[qatype]['METRICS'] = qadict
        # Return
        return True
Exemplo n.º 4
0
    def run_qa(self, qatype, inputs, clobber=True):
        """Run QA tests of a given type
        Over-writes previous QA of this type, unless otherwise specified

        qatype: str
          Type of QA to be performed (e.g. SKYSUB)
        inputs: tuple
          Set of inputs for the tests
        clobber: bool, optional [True]
          Over-write previous QA

        Returns:
            bool
              True = Calculation performed
              False = Calculation not performed
        """
        from desispec.sky import qa_skysub
        from desispec.fiberflat import qa_fiberflat
        from desispec.fluxcalibration import qa_fluxcalib
        from desispec.qa.qalib import SNRFit

        # Check for previous QA if clobber==False
        if (not clobber) and (qatype in self.qa_data.keys()):
            # QA previously performed?
            if 'METRICS' in self.qa_data[qatype]:
                return False
        # Run
        if qatype == 'SKYSUB':
            # Expecting: frame, skymodel
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_skysub()
            # Run
            qadict = qa_skysub(self.qa_data[qatype]['PARAMS'],
                inputs[0], inputs[1])
        elif qatype == 'FIBERFLAT':
            # Expecting: frame, fiberflat
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fiberflat()
            # Run
            qadict = qa_fiberflat(self.qa_data[qatype]['PARAMS'], inputs[0], inputs[1])
        elif qatype == 'FLUXCALIB':
            # Expecting: frame, fluxcalib
            assert len(inputs) == 2
            # Init parameters (as necessary)
            self.init_fluxcalib()
            # Run
            qadict = qa_fluxcalib(self.qa_data[qatype]['PARAMS'], inputs[0], inputs[1])
        elif qatype == 'S2N':
            # Expecting only a frame
            assert len(inputs) == 1
            # Init parameters (as necessary)
            self.init_s2n()
            # Run
            qadict,fitsnr = SNRFit(inputs[0], self.night, self.camera, self.expid,
                                   self.qa_data[qatype]['PARAMS'], fidboundary=None,
                                   offline=True)
            # Remove undesired
            for key in ['RA', 'DEC']:
                qadict.pop(key)
        else:
            raise ValueError('Not ready to perform {:s} QA'.format(qatype))
        # Update
        self.qa_data[qatype]['METRICS'] = qadict
        # Return
        return True