示例#1
0
    def ingestPfsConfig(self, dirName, fileInfo, args):
        """Ingest a PfsConfig file

        Parameters
        ----------
        dirName : `str`
            Directory in which the file resides.
        fileInfo : `dict`
            Key-value pairs defining the file.
        args : `argparse.Namespace`
            Parsed command-line arguments.
        """
        outfile = args.butler.get("pfsConfig_filename", fileInfo)[0]
        if os.path.exists(outfile):
            # Don't clobber one that got put there when we ingested a different spectrograph,arm
            return

        pfsDesignId = fileInfo["pfsDesignId"]
        visit = fileInfo["visit"]
        fileName = PfsConfig.fileNameFormat % (pfsDesignId, visit)
        infile = os.path.join(dirName, fileName)
        if os.path.exists(infile):
            self.ingest(infile, outfile, mode=args.mode, dryrun=args.dryrun)
            return

        # Check for a PfsDesign, and use that instead
        designName = os.path.join(dirName,
                                  PfsDesign.fileNameFormat % (pfsDesignId, ))
        if not os.path.exists(designName):
            raise RuntimeError(
                "Unable to find PfsConfig or PfsDesign for pfsDesignId=0x%016x"
                % (pfsDesignId, ))
        design = PfsDesign.read(pfsDesignId, dirName)
        PfsConfig.fromPfsDesign(design, visit,
                                design.pfiNominal).write(dirName)
        self.ingest(infile, outfile, mode=args.mode, dryrun=args.dryrun)
示例#2
0
 def testFromPfsDesign(self):
     """Test PfsConfig.fromPfsDesign"""
     design = PfsDesign(self.pfsDesignId, self.raBoresight.asDegrees(),
                        self.decBoresight.asDegrees(), self.fiberId,
                        self.tract, self.patch, self.ra, self.dec,
                        self.catId, self.objId, self.targetType,
                        self.fiberStatus, self.fiberMag, self.filterNames,
                        self.pfiNominal)
     config = PfsConfig(self.pfsDesignId, self.visit0,
                        self.raBoresight.asDegrees(),
                        self.decBoresight.asDegrees(), self.fiberId,
                        self.tract, self.patch, self.ra, self.dec,
                        self.catId, self.objId, self.targetType,
                        self.fiberStatus, self.fiberMag, self.filterNames,
                        self.pfiCenter, self.pfiNominal)
     self.assertPfsConfig(
         PfsConfig.fromPfsDesign(design, self.visit0, self.pfiCenter),
         config)