Ejemplo n.º 1
0
 def ssoInFov(self, interpfuncs, simdata, rFov=np.radians(1.75),
              useCamera=True,
              simdataRaCol = 'fieldRA', simdataDecCol='fieldDec'):
     """
     Return the indexes of the simdata observations where the object was inside the fov.
     """
     # See if the object is within 'rFov' of the center of the boresight.
     raSso = np.radians(interpfuncs['ra'](simdata['expMJD']))
     decSso = np.radians(interpfuncs['dec'](simdata['expMJD']))
     sep = haversine(raSso, decSso, simdata[simdataRaCol], simdata[simdataDecCol])
     if not useCamera:
         idxObsRough = np.where(sep<rFov)[0]
         return idxObsRough
     # Or go on and use the camera footprint.
     try:
         self.camera
     except AttributeError:
         self._setupCamera()
     idxObs = []
     idxObsRough = np.where(sep<self.cameraFov)[0]
     for idx in idxObsRough:
         mjd = simdata[idx]['expMJD']
         obs_metadata = ObservationMetaData(unrefractedRA=np.degrees(simdata[idx][simdataRaCol]),
                                            unrefractedDec=np.degrees(simdata[idx][simdataDecCol]),
                                            rotSkyPos=np.degrees(simdata[idx]['rotSkyPos']),
                                            mjd=simdata[idx]['expMJD'])
         raObj = np.radians(np.array([interpfuncs['ra'](simdata[idx]['expMJD'])]))
         decObj = np.radians(np.array([interpfuncs['dec'](simdata[idx]['expMJD'])]))
         raObj, decObj = _observedFromICRS(raObj, decObj, obs_metadata=obs_metadata, epoch=self.epoch)
         chipNames = _chipNameFromRaDec(ra=raObj,dec=decObj, epoch=self.epoch, camera=self.camera, obs_metadata=obs_metadata)
         if chipNames != [None]:
             idxObs.append(idx)
     idxObs = np.array(idxObs)
     return idxObs
Ejemplo n.º 2
0
    def test_chip_name_from_ra_dec_radians(self):
        """
        test that _chipNameFromRaDecLSST agrees with _chipNameFromRaDec
        """

        n_obj = 1000
        raP = 112.1
        decP = -34.1
        obs = ObservationMetaData(pointingRA=raP, pointingDec=decP,
                                  rotSkyPos=45.0, mjd=43000.0)

        rng = np.random.RandomState(8731)
        rr = rng.random_sample(n_obj)*1.75
        theta = rng.random_sample(n_obj)*2.0*np.pi
        ra_list = np.radians(raP + rr*np.cos(theta))
        dec_list = np.radians(decP + rr*np.sin(theta))
        control_name_list = _chipNameFromRaDec(ra_list, dec_list,
                                               obs_metadata=obs,
                                               camera=self.camera)

        test_name_list = _chipNameFromRaDecLSST(ra_list, dec_list,
                                                obs_metadata=obs)

        try:
            np.testing.assert_array_equal(control_name_list.astype(str),
                                          test_name_list.astype(str))
        except AssertionError:
            n_problematic = 0
            for ii, (c_n, t_n) in enumerate(zip(control_name_list.astype(str), test_name_list.astype(str))):
                if c_n != t_n:
                    x_pix, y_pix = pixelCoordsFromRaDecLSST(ra_list[ii], dec_list[ii], obs_metadata=obs)
                    if c_n != 'None':
                        n_problematic += 1
            if n_problematic > 0:
                raise

        self.assertLessEqual(len(np.where(np.char.rfind(test_name_list.astype(str), 'None') >= 0)[0]),
                             n_obj/10)

        # test that exceptions are raised when incomplete ObservationMetaData are used
        obs = ObservationMetaData(pointingRA=raP, pointingDec=decP, mjd=59580.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list, obs_metadata=obs)
        self.assertIn("rotSkyPos", context.exception.args[0])

        obs = ObservationMetaData(pointingRA=raP, pointingDec=decP, rotSkyPos=35.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list, obs_metadata=obs)
        self.assertIn("mjd", context.exception.args[0])

        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list)
        self.assertIn("ObservationMetaData", context.exception.args[0])

        # check that exceptions are raised when ra_list, dec_list are of the wrong shape
        obs = ObservationMetaData(pointingRA=raP, pointingDec=decP, rotSkyPos=24.0, mjd=43000.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list[:5], obs_metadata=obs)
        self.assertIn("chipNameFromRaDecLSST", context.exception.args[0])
Ejemplo n.º 3
0
    def _presliceFootprint(self, simData):
        """Loop over each pointing and find which sky points are observed """
        # Now to make a list of lists for looking up the relevant observations at each slicepoint
        self.sliceLookup = [[] for dummy in range(self.nslice)]
        self.chipNames = [[] for dummy in range(self.nslice)]
        # Make a kdtree for the _slicepoints_
        # Using scipy 0.16 or later
        self._buildTree(self.slicePoints['ra'],
                        self.slicePoints['dec'],
                        leafsize=self.leafsize)

        # Loop over each unique pointing position
        if self.latLonDeg:
            lat = np.radians(simData[self.latCol])
            lon = np.radians(simData[self.lonCol])
        else:
            lat = simData[self.latCol]
            lon = simData[self.lonCol]
        for ind, ra, dec, rotSkyPos, mjd in zip(np.arange(simData.size), lon,
                                                lat,
                                                simData[self.rotSkyPosColName],
                                                simData[self.mjdColName]):
            dx, dy, dz = self._treexyz(ra, dec)
            # Find healpixels inside the FoV
            hpIndices = np.array(
                self.opsimtree.query_ball_point((dx, dy, dz), self.rad))
            if hpIndices.size > 0:
                obs_metadata = ObservationMetaData(
                    pointingRA=np.degrees(ra),
                    pointingDec=np.degrees(dec),
                    rotSkyPos=np.degrees(rotSkyPos),
                    mjd=mjd)

                chipNames = _chipNameFromRaDec(
                    self.slicePoints['ra'][hpIndices],
                    self.slicePoints['dec'][hpIndices],
                    epoch=self.epoch,
                    camera=self.camera,
                    obs_metadata=obs_metadata)
                # If we are using only a subset of chips
                if self.chipsToUse != 'all':
                    checkedChipNames = [
                        chipName in self.chipsToUse for chipName in chipNames
                    ]
                    good = np.where(checkedChipNames)[0]
                    chipNames = chipNames[good]
                    hpIndices = hpIndices[good]
                # Find the healpixels that fell on a chip for this pointing
                good = np.where(chipNames != [None])[0]
                hpOnChip = hpIndices[good]
                for i, chipName in zip(hpOnChip, chipNames[good]):
                    self.sliceLookup[i].append(ind)
                    self.chipNames[i].append(chipName)

        if self.verbose:
            "Created lookup table after checking for chip gaps."
Ejemplo n.º 4
0
 def ssoInFov(self,
              interpfuncs,
              simdata,
              rFov=np.radians(1.75),
              useCamera=True,
              simdataRaCol='fieldRA',
              simdataDecCol='fieldDec'):
     """
     Return the indexes of the simdata observations where the object was inside the fov.
     """
     # See if the object is within 'rFov' of the center of the boresight.
     raSso = np.radians(interpfuncs['ra'](simdata['expMJD']))
     decSso = np.radians(interpfuncs['dec'](simdata['expMJD']))
     sep = haversine(raSso, decSso, simdata[simdataRaCol],
                     simdata[simdataDecCol])
     if not useCamera:
         idxObsRough = np.where(sep < rFov)[0]
         return idxObsRough
     # Or go on and use the camera footprint.
     try:
         self.camera
     except AttributeError:
         self._setupCamera()
     idxObs = []
     idxObsRough = np.where(sep < self.cameraFov)[0]
     for idx in idxObsRough:
         mjd = simdata[idx]['expMJD']
         obs_metadata = ObservationMetaData(
             unrefractedRA=np.degrees(simdata[idx][simdataRaCol]),
             unrefractedDec=np.degrees(simdata[idx][simdataDecCol]),
             rotSkyPos=np.degrees(simdata[idx]['rotSkyPos']),
             mjd=simdata[idx]['expMJD'])
         raObj = np.radians(
             np.array([interpfuncs['ra'](simdata[idx]['expMJD'])]))
         decObj = np.radians(
             np.array([interpfuncs['dec'](simdata[idx]['expMJD'])]))
         raObj, decObj = _observedFromICRS(raObj,
                                           decObj,
                                           obs_metadata=obs_metadata,
                                           epoch=self.epoch)
         chipNames = _chipNameFromRaDec(ra=raObj,
                                        dec=decObj,
                                        epoch=self.epoch,
                                        camera=self.camera,
                                        obs_metadata=obs_metadata)
         if chipNames != [None]:
             idxObs.append(idx)
     idxObs = np.array(idxObs)
     return idxObs
Ejemplo n.º 5
0
    def _presliceFootprint(self, simData):
        """Loop over each pointing and find which sky points are observed """
        # Now to make a list of lists for looking up the relevant observations at each slicepoint
        self.sliceLookup = [[] for dummy in range(self.nslice)]
        self.chipNames = [[] for dummy in range(self.nslice)]
        # Make a kdtree for the _slicepoints_
        # Using scipy 0.16 or later
        self._buildTree(self.slicePoints['ra'], self.slicePoints['dec'], leafsize=self.leafsize)

        # Loop over each unique pointing position
        if self.latLonDeg:
            lat = np.radians(simData[self.latCol])
            lon = np.radians(simData[self.lonCol])
        else:
            lat = simData[self.latCol]
            lon = simData[self.lonCol]
        for ind, ra, dec, rotSkyPos, mjd in zip(np.arange(simData.size), lon, lat,
                                                simData[self.rotSkyPosColName], simData[self.mjdColName]):
            dx, dy, dz = simsUtils._xyz_from_ra_dec(ra, dec)
            # Find healpixels inside the FoV
            hpIndices = np.array(self.opsimtree.query_ball_point((dx, dy, dz), self.rad))
            if hpIndices.size > 0:
                obs_metadata = simsUtils.ObservationMetaData(pointingRA=np.degrees(ra),
                                                             pointingDec=np.degrees(dec),
                                                             rotSkyPos=np.degrees(rotSkyPos),
                                                             mjd=mjd)

                chipNames = _chipNameFromRaDec(self.slicePoints['ra'][hpIndices],
                                               self.slicePoints['dec'][hpIndices],
                                               epoch=self.epoch,
                                               camera=self.camera, obs_metadata=obs_metadata)
                # If we are using only a subset of chips
                if self.chipsToUse != 'all':
                    checkedChipNames = [chipName in self.chipsToUse for chipName in chipNames]
                    good = np.where(checkedChipNames)[0]
                    chipNames = chipNames[good]
                    hpIndices = hpIndices[good]
                # Find the healpixels that fell on a chip for this pointing
                good = np.where(chipNames != [None])[0]
                hpOnChip = hpIndices[good]
                for i, chipName in zip(hpOnChip, chipNames[good]):
                    self.sliceLookup[i].append(ind)
                    self.chipNames[i].append(chipName)

        if self.verbose:
            "Created lookup table after checking for chip gaps."
Ejemplo n.º 6
0
    def testUtilityMethods(self):
        """
        Generate a catalog using the methods from AstrometryUtils.py and CameraUtils.py.
        Read that data in, and then recalculate the values 'by hand' to make sure
        that they are consistent.
        """

        catName = os.path.join(getPackageDir('sims_catUtils'), 'tests', 'scratchSpace',
                               'AstrometryUtilityCatalog.txt')

        if os.path.exists(catName):
            os.unlink(catName)

        self.cat.write_catalog(catName)

        dtype = [('id', int),
                 ('raICRS', float), ('decICRS', float),
                 ('parallax', float), ('radial_velocity', float),
                 ('x_pupil', float), ('y_pupil', float), ('chipName', str, 11),
                 ('xPix', float), ('yPix', float),
                 ('xFocalPlane', float), ('yFocalPlane', float)]

        baselineData = np.genfromtxt(catName, dtype=dtype, delimiter=';')

        self.assertGreater(len(baselineData), 0)

        pupilTest = _pupilCoordsFromRaDec(baselineData['raICRS'],
                                          baselineData['decICRS'],
                                          parallax=baselineData['parallax'],
                                          v_rad=baselineData['radial_velocity'],
                                          obs_metadata=self.obs_metadata,
                                          epoch=2000.0)

        for (xxtest, yytest, xx, yy) in \
                zip(pupilTest[0], pupilTest[1], baselineData['x_pupil'], baselineData['y_pupil']):
            self.assertAlmostEqual(xxtest, xx, 6)
            self.assertAlmostEqual(yytest, yy, 6)

        focalTest = focalPlaneCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        focalRa = _focalPlaneCoordsFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                             parallax=baselineData['parallax'],
                                             v_rad=baselineData['radial_velocity'],
                                             epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(focalTest[0], focalTest[1], focalRa[0], focalRa[1],
                    baselineData['xFocalPlane'], baselineData['yFocalPlane']):

            self.assertAlmostEqual(xxtest, xx, 6)
            self.assertAlmostEqual(yytest, yy, 6)
            self.assertAlmostEqual(xxra, xx, 6)
            self.assertAlmostEqual(yyra, yy, 6)

        pixTest = pixelCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        pixTestRaDec = _pixelCoordsFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                             parallax=baselineData['parallax'],
                                             v_rad=baselineData['radial_velocity'],
                                             epoch=self.cat.db_obj.epoch,
                                             obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(pixTest[0], pixTest[1], pixTestRaDec[0], pixTestRaDec[1],
                    baselineData['xPix'], baselineData['yPix']):

            if not np.isnan(xx) and not np.isnan(yy):
                self.assertAlmostEqual(xxtest, xx, 5)
                self.assertAlmostEqual(yytest, yy, 5)
                self.assertAlmostEqual(xxra, xx, 5)
                self.assertAlmostEqual(yyra, yy, 5)
            else:
                np.testing.assert_equal(xx, np.NaN)
                np.testing.assert_equal(yy, np.NaN)
                np.testing.assert_equal(xxra, np.NaN)
                np.testing.assert_equal(yyra, np.NaN)
                np.testing.assert_equal(xxtest, np.NaN)
                np.testing.assert_equal(yytest, np.NaN)

        nameTest = chipNameFromPupilCoords(pupilTest[0], pupilTest[1],
                                           camera=self.cat.camera)

        nameRA = _chipNameFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                    epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                    camera=self.cat.camera)

        is_none = 0
        for (ntest, nra, ncontrol) in zip(nameTest, nameRA, baselineData['chipName']):
            if ncontrol != 'None':
                self.assertEqual(ntest, ncontrol)
                self.assertEqual(nra, ncontrol)
            else:
                is_none += 1
                self.assertIsNone(ntest)
                self.assertIsNone(nra)

        self.assertGreater(is_none, 0)
        self.assertLess(is_none, len(baselineData))

        if os.path.exists(catName):
            os.unlink(catName)
    def test_chip_name_from_ra_dec_radians(self):
        """
        test that _chipNameFromRaDecLSST agrees with _chipNameFromRaDec
        """

        n_obj = 1000
        raP = 112.1
        decP = -34.1
        obs = ObservationMetaData(pointingRA=raP,
                                  pointingDec=decP,
                                  rotSkyPos=45.0,
                                  mjd=43000.0)

        rng = np.random.RandomState(8731)
        rr = rng.random_sample(n_obj) * 1.75
        theta = rng.random_sample(n_obj) * 2.0 * np.pi
        ra_list = np.radians(raP + rr * np.cos(theta))
        dec_list = np.radians(decP + rr * np.sin(theta))
        control_name_list = _chipNameFromRaDec(ra_list,
                                               dec_list,
                                               obs_metadata=obs,
                                               camera=self.camera)

        test_name_list = _chipNameFromRaDecLSST(ra_list,
                                                dec_list,
                                                obs_metadata=obs)

        np.testing.assert_array_equal(control_name_list.astype(str),
                                      test_name_list.astype(str))
        self.assertLessEqual(
            len(
                np.where(
                    np.char.rfind(test_name_list.astype(str), 'None') >= 0)
                [0]), n_obj / 10)

        # test that exceptions are raised when incomplete ObservationMetaData are used
        obs = ObservationMetaData(pointingRA=raP,
                                  pointingDec=decP,
                                  mjd=59580.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list, obs_metadata=obs)
        self.assertIn("rotSkyPos", context.exception.args[0])

        obs = ObservationMetaData(pointingRA=raP,
                                  pointingDec=decP,
                                  rotSkyPos=35.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list, obs_metadata=obs)
        self.assertIn("mjd", context.exception.args[0])

        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list)
        self.assertIn("ObservationMetaData", context.exception.args[0])

        # check that exceptions are raised when ra_list, dec_list are of the wrong shape
        obs = ObservationMetaData(pointingRA=raP,
                                  pointingDec=decP,
                                  rotSkyPos=24.0,
                                  mjd=43000.0)
        with self.assertRaises(RuntimeError) as context:
            _chipNameFromRaDecLSST(ra_list, dec_list[:5], obs_metadata=obs)
        self.assertIn("chipNameFromRaDecLSST", context.exception.args[0])
    def testUtilityMethods(self):
        """
        Generate a catalog using the methods from AstrometryUtils.py and CameraUtils.py.
        Read that data in, and then recalculate the values 'by hand' to make sure
        that they are consistent.
        """

        self.cat.write_catalog("AstrometryTestCatalog.txt")

        dtype = [('id',int),
                 ('raPhoSim',float), ('decPhoSim',float),
                 ('raObserved',float), ('decObserved',float),
                 ('x_pupil',float), ('y_pupil',float), ('chipName',str,11),
                 ('xPix',float), ('yPix',float),
                 ('xFocalPlane',float), ('yFocalPlane',float)]

        baselineData = numpy.loadtxt('AstrometryTestCatalog.txt', dtype=dtype, delimiter=';')

        pupilTest = _pupilCoordsFromRaDec(baselineData['raObserved'],
                                              baselineData['decObserved'],
                                              obs_metadata=self.obs_metadata,
                                              epoch=2000.0)

        for (xxtest, yytest, xx, yy) in \
                zip(pupilTest[0], pupilTest[1], baselineData['x_pupil'], baselineData['y_pupil']):
            self.assertAlmostEqual(xxtest,xx,6)
            self.assertAlmostEqual(yytest,yy,6)

        focalTest = focalPlaneCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        focalRa = _focalPlaneCoordsFromRaDec(baselineData['raObserved'], baselineData['decObserved'],
                                             epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(focalTest[0], focalTest[1], focalRa[0], focalRa[1],
                        baselineData['xFocalPlane'], baselineData['yFocalPlane']):

            self.assertAlmostEqual(xxtest,xx,6)
            self.assertAlmostEqual(yytest,yy,6)
            self.assertAlmostEqual(xxra,xx,6)
            self.assertAlmostEqual(yyra,yy,6)

        pixTest = pixelCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        pixTestRaDec = _pixelCoordsFromRaDec(baselineData['raObserved'], baselineData['decObserved'],
                                             epoch=self.cat.db_obj.epoch,
                                             obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(pixTest[0], pixTest[1], pixTestRaDec[0], pixTestRaDec[1],
                           baselineData['xPix'], baselineData['yPix']):

            if not numpy.isnan(xx) and not numpy.isnan(yy):
                self.assertAlmostEqual(xxtest,xx,5)
                self.assertAlmostEqual(yytest,yy,5)
                self.assertAlmostEqual(xxra,xx,5)
                self.assertAlmostEqual(yyra,yy,5)
            else:
                self.assertTrue(numpy.isnan(xx))
                self.assertTrue(numpy.isnan(yy))
                self.assertTrue(numpy.isnan(xxra))
                self.assertTrue(numpy.isnan(yyra))
                self.assertTrue(numpy.isnan(xxtest))
                self.assertTrue(numpy.isnan(yytest))


        nameTest = chipNameFromPupilCoords(pupilTest[0], pupilTest[1],
                                           camera=self.cat.camera)

        nameRA = _chipNameFromRaDec(baselineData['raObserved'], baselineData['decObserved'],
                                    epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                    camera=self.cat.camera)

        for (ntest, nra, ncontrol) in zip(nameTest, nameRA, baselineData['chipName']):
            if ncontrol != 'None':
                self.assertEqual(ntest,ncontrol)
                self.assertEqual(nra,ncontrol)
            else:
                self.assertTrue(ntest is None)
                self.assertTrue(nra is None)

        if os.path.exists("AstrometryTestCatalog.txt"):
            os.unlink("AstrometryTestCatalog.txt")
Ejemplo n.º 9
0
    def testUtilityMethods(self):
        """
        Generate a catalog using the methods from AstrometryUtils.py and CameraUtils.py.
        Read that data in, and then recalculate the values 'by hand' to make sure
        that they are consistent.
        """

        with lsst.utils.tests.getTempFilePath('.txt') as catName:
            self.cat.write_catalog(catName)

            dtype = [('id', int),
                     ('raICRS', float), ('decICRS', float),
                     ('parallax', float), ('radial_velocity', float),
                     ('x_pupil', float), ('y_pupil', float), ('chipName', str, 11),
                     ('xPix', float), ('yPix', float),
                     ('xFocalPlane', float), ('yFocalPlane', float)]

            baselineData = np.genfromtxt(catName, dtype=dtype, delimiter=';')

        self.assertGreater(len(baselineData), 0)

        pupilTest = _pupilCoordsFromRaDec(baselineData['raICRS'],
                                          baselineData['decICRS'],
                                          parallax=baselineData['parallax'],
                                          v_rad=baselineData['radial_velocity'],
                                          obs_metadata=self.obs_metadata,
                                          epoch=2000.0)

        for (xxtest, yytest, xx, yy) in \
                zip(pupilTest[0], pupilTest[1], baselineData['x_pupil'], baselineData['y_pupil']):
            self.assertAlmostEqual(xxtest, xx, 6)
            self.assertAlmostEqual(yytest, yy, 6)

        focalTest = focalPlaneCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        focalRa = _focalPlaneCoordsFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                             parallax=baselineData['parallax'],
                                             v_rad=baselineData['radial_velocity'],
                                             epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(focalTest[0], focalTest[1], focalRa[0], focalRa[1],
                    baselineData['xFocalPlane'], baselineData['yFocalPlane']):

            self.assertAlmostEqual(xxtest, xx, 6)
            self.assertAlmostEqual(yytest, yy, 6)
            self.assertAlmostEqual(xxra, xx, 6)
            self.assertAlmostEqual(yyra, yy, 6)

        pixTest = pixelCoordsFromPupilCoords(pupilTest[0], pupilTest[1], camera=self.cat.camera)

        pixTestRaDec = _pixelCoordsFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                             parallax=baselineData['parallax'],
                                             v_rad=baselineData['radial_velocity'],
                                             epoch=self.cat.db_obj.epoch,
                                             obs_metadata=self.cat.obs_metadata,
                                             camera=self.cat.camera)

        for (xxtest, yytest, xxra, yyra, xx, yy) in \
                zip(pixTest[0], pixTest[1], pixTestRaDec[0], pixTestRaDec[1],
                    baselineData['xPix'], baselineData['yPix']):

            if not np.isnan(xx) and not np.isnan(yy):
                self.assertAlmostEqual(xxtest, xx, 5)
                self.assertAlmostEqual(yytest, yy, 5)
                self.assertAlmostEqual(xxra, xx, 5)
                self.assertAlmostEqual(yyra, yy, 5)
            else:
                np.testing.assert_equal(xx, np.NaN)
                np.testing.assert_equal(yy, np.NaN)
                np.testing.assert_equal(xxra, np.NaN)
                np.testing.assert_equal(yyra, np.NaN)
                np.testing.assert_equal(xxtest, np.NaN)
                np.testing.assert_equal(yytest, np.NaN)

        nameTest = chipNameFromPupilCoords(pupilTest[0], pupilTest[1],
                                           camera=self.cat.camera)

        nameRA = _chipNameFromRaDec(baselineData['raICRS'], baselineData['decICRS'],
                                    epoch=self.cat.db_obj.epoch, obs_metadata=self.cat.obs_metadata,
                                    camera=self.cat.camera)

        is_none = 0
        for (ntest, nra, ncontrol) in zip(nameTest, nameRA, baselineData['chipName']):
            if ncontrol != 'None':
                self.assertEqual(ntest, ncontrol)
                self.assertEqual(nra, ncontrol)
            else:
                is_none += 1
                self.assertIsNone(ntest)
                self.assertIsNone(nra)

        self.assertGreater(is_none, 0)
        self.assertLess(is_none, len(baselineData))