Example #1
0
 def getCalibration(self,
                    adinputs=None,
                    caltype=None,
                    refresh=True,
                    howmany=None):
     """
     Uses the calibration manager to population the Calibrations dict for
     all frames, updating any existing entries
     
     Parameters
     ----------
     adinputs: list of ADs
         files for which calibrations are needed
     caltype: str
         type of calibration required (e.g., "processed_bias")
     refresh: bool
         if False, only seek calibrations for ADs without them; otherwise
         request calibrations for all ADs
     howmany: None/int
         maximum number of calibrations to return per AD (None means return
         the filename of one, rather than a list of filenames)
     """
     log = self.log
     ad_rq = adinputs if refresh else [
         ad for ad in adinputs if not self._get_cal(ad, caltype)
     ]
     cal_requests = get_cal_requests(ad_rq, caltype)
     calibration_records = process_cal_requests(cal_requests,
                                                howmany=howmany)
     for ad, calfile in calibration_records.items():
         self.calibrations[ad, caltype] = calfile
     return adinputs
Example #2
0
 def getCalibration(self, adinputs=None, caltype=None, refresh=True,
                    howmany=None):
     """
     Uses the calibration manager to population the Calibrations dict for
     all frames, updating any existing entries
     
     Parameters
     ----------
     adinputs: list of ADs
         files for which calibrations are needed
     caltype: str
         type of calibration required (e.g., "processed_bias")
     refresh: bool
         if False, only seek calibrations for ADs without them; otherwise
         request calibrations for all ADs
     howmany: None/int
         maximum number of calibrations to return per AD (None means return
         the filename of one, rather than a list of filenames)
     """
     log = self.log
     ad_rq = adinputs if refresh else [ad for ad in adinputs
                                       if not self._get_cal(ad, caltype)]
     cal_requests = get_cal_requests(ad_rq, caltype)
     calibration_records = process_cal_requests(cal_requests, howmany=howmany)
     for ad, calfile in calibration_records.items():
         self.calibrations[ad, caltype] = calfile
     return adinputs
Example #3
0
    def getMDF(self, adinputs=None):
        caltype = "mask"
        log = self.log
        inst_lookups = self.inst_lookups
        try:
            masks = import_module('.maskdb', inst_lookups)
            mdf_dict = getattr(masks, 'mdf_dict')
        except (ImportError, AttributeError):
            mdf_dict = None

        rqs_actual = [
            ad for ad in adinputs if self._get_cal(ad, caltype) is None
        ]
        for ad in rqs_actual:
            if 'SPECT' in ad.tags:
                mask_name = ad.focal_plane_mask()
                key = '{}_{}'.format(ad.instrument(), mask_name)
                if mdf_dict is not None:
                    try:
                        mdf = os.path.join(os.path.dirname(masks.__file__),
                                           'MDF', mdf_dict[key])
                    except KeyError:
                        log.warning("MDF not found in {}".format(inst_lookups))
                    else:
                        self.calibrations[ad, caltype] = mdf
                        continue
                log.stdinfo("Requesting MDF from fitsstore ...")
                mdf_requests = get_cal_requests([ad], caltype)
                mdf_records = process_cal_requests(mdf_requests)
                for ad, calfile in mdf_records.items():
                    self.calibrations[ad, caltype] = calfile

        return adinputs
Example #4
0
    def getMDF(self, adinputs=None):
        caltype = "mask"
        log = self.log
        inst_lookups = self.inst_lookups
        try:
            masks = import_module('.maskdb', inst_lookups)
            mdf_dict = getattr(masks, 'mdf_dict')
        except (ImportError, AttributeError):
            mdf_dict = None

        rqs_actual = [ad for ad in adinputs if self._get_cal(ad, caltype) is None]
        for ad in rqs_actual:
            if 'SPECT' in ad.tags:
                mask_name = ad.focal_plane_mask()
                key = '{}_{}'.format(ad.instrument(), mask_name)
                if mdf_dict is not None:
                    try:
                        mdf = os.path.join(os.path.dirname(masks.__file__),
                                           'MDF', mdf_dict[key])
                    except KeyError:
                        log.warning("MDF not found in {}".format(inst_lookups))
                    else:
                        self.calibrations[ad, caltype] = mdf
                        continue
                log.stdinfo("Requesting MDF from fitsstore ...")
                mdf_requests = get_cal_requests([ad], caltype)
                mdf_records = process_cal_requests(mdf_requests)
                for ad, calfile in mdf_records.items():
                    self.calibrations[ad, caltype] = calfile

        return adinputs
Example #5
0
    def getCalibration(self, adinputs=None, caltype=None, procmode=None,
                       refresh=True, howmany=None):
        """
        Uses the calibration manager to population the Calibrations dict for
        all frames, updating any existing entries

        Parameters
        ----------
        adinputs: <list>
            List of ADs of files for which calibrations are needed

        caltype: <str>
            type of calibration required (e.g., "processed_bias")

        refresh: <bool>
            if False, only seek calibrations for ADs without them; otherwise
            request calibrations for all ADs. Default is True.

        howmany: <int> or <None>
            Maximum number of calibrations to return per AD (None means return
            the filename of one, rather than a list of filenames)

        """
        log = self.log
        ad_rq = adinputs if refresh else [ad for ad in adinputs
                                          if not self._get_cal(ad, caltype)]

        # TODO refactor Calibrations out if we stick with this
        # If refresh, clear out the cache so we don't use it
        if refresh:
            for ad in ad_rq:
                del self.calibrations[ad, caltype]

        cal_requests = get_cal_requests(ad_rq, caltype, procmode)
        calibration_records = process_cal_requests(cal_requests, howmany=howmany)
        for ad, calfile in calibration_records.items():
            self.calibrations[ad, caltype] = calfile
        return adinputs