Пример #1
0
    def testBasic(self):
        """Test basic operation of PfsConfig"""
        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)

        dirName = os.path.splitext(__file__)[0]
        if not os.path.exists(dirName):
            os.makedirs(dirName)

        filename = os.path.join(dirName, config.filename)
        if os.path.exists(filename):
            os.unlink(filename)

        try:
            config.write(dirName=dirName)
            other = PfsConfig.read(self.pfsDesignId,
                                   self.visit0,
                                   dirName=dirName)
            self.assertPfsConfig(config, other)
        except Exception:
            raise  # Leave file for manual inspection
        else:
            os.unlink(filename)
Пример #2
0
    def testBasic(self):
        """Test basic operation of PfsConfig"""
        config = PfsConfig(self.pfiDesignId, self.expId, self.raBoresight.asDegrees(),
                           self.decBoresight.asDegrees(), self.fiberId, self.tract, self.patch,
                           self.ra, self.dec, self.catId, self.objId, self.targetType,
                           self.fiberMag, self.filterNames, self.pfiCenter, self.pfiNominal)

        dirName = os.path.splitext(__file__)[0]
        if not os.path.exists(dirName):
            os.makedirs(dirName)

        filename = os.path.join(dirName, config.filename)
        if os.path.exists(filename):
            os.unlink(filename)

        try:
            config.write(dirName=dirName)
            other = PfsConfig.read(self.pfiDesignId, self.expId, dirName=dirName)
            self.assertPfsConfig(config, other)
        except Exception:
            raise  # Leave file for manual inspection
        else:
            os.unlink(filename)
def make_pfsConfig(pfsDesignId, visit0, fiberIds, tracts, patches, ras, decs,
                   catIds, objIds, targetTypeIds, fiberMags_g, pfiNominal_x,
                   pfiNominal_y, pfiCenter_x, pfiCenter_y):
    '''
        Description
        -----------
            Make pfsConfig object

        Parameters
        ----------
            pfsDesignId : `int`
            visit0 : `int`
            fiberIds : `numpy.ndarray` of `int`
            tracts : `numpy.ndarray` of `int`
            patches : `numpy.ndarray` of `str`
            ras : `numpy.ndarray` of `float`
            decs : `numpy.ndarray` of `float`
            catIds : `numpy.ndarray` of `int`
            objIds : `numpy.ndarray` of `int`
            targetTypeIds : `numpy.ndarray` of `int`
            fiberMags_g : `numpy.ndarray` of `float`
            pfiNominal_x : `numpy.ndarray` of `float`
            pfiNominal_y : `numpy.ndarray` of `float`
            pfiCenter_x : `numpy.ndarray` of `float`
            pfiCenter_y : `numpy.ndarray` of `float`

        Returns
        -------
            pfsConfig : `object` of `pfsConfig`

        Note
        ----
            You need to have the latest PFS datamodel
    '''
    nFiber = len(fiberIds)
    fiberMag = np.empty((nFiber, 5))
    for i in range(nFiber):
        fiberMag[i] = fiberMags_g[i]
    raBoresight = np.median(ras)
    decBoresight = np.median(decs)
    fiberMags = [[mag] for mag in fiberMag[:, 0]]
    filterNames = [['g'] for i in range(nFiber)]
    pfiNominal = np.array((pfiNominal_x, pfiNominal_y)).transpose()
    pfiCenter = np.array((pfiCenter_x, pfiCenter_y)).transpose()
    pfsConfig = PfsConfig(pfsDesignId=pfsDesignId,
                          visit0=visit0,
                          raBoresight=raBoresight,
                          decBoresight=decBoresight,
                          fiberId=fiberIds,
                          tract=tracts,
                          patch=patches,
                          ra=ras,
                          dec=decs,
                          catId=catIds,
                          objId=objIds,
                          targetType=targetTypeIds,
                          fiberMag=fiberMags,
                          filterNames=filterNames,
                          pfiCenter=pfiCenter,
                          pfiNominal=pfiNominal)
    pfsConfig.write('./out/fits/')
    return pfsConfig