예제 #1
0
    def __init__(self, nside=128, lonCol='fieldRA',
                 latCol='fieldDec', latLonDeg=True, verbose=True, badval=hp.UNSEEN,
                 useCache=True, leafsize=100,
                 useCamera=False, rotSkyPosColName='rotSkyPos',
                 mjdColName='observationStartMJD', chipNames=center_raft_chips, side_length=0.7):
        """
        Parameters
        ----------
        side_length : float (0.7)
            How large is a side of the raft (degrees)
        """
        radius = side_length/2.*np.sqrt(2.)
        super(HealpixComCamSlicer, self).__init__(nside=nside, lonCol=lonCol, latCol=latCol,
                                                  latLonDeg=latLonDeg,
                                                  verbose=verbose, badval=badval, useCache=useCache,
                                                  leafsize=leafsize, radius=radius, useCamera=useCamera,
                                                  rotSkyPosColName=rotSkyPosColName,
                                                  mjdColName=mjdColName, chipNames=chipNames)
        self.side_length = np.radians(side_length)
        self.corners_x = np.array([-self.side_length/2., -self.side_length/2., self.side_length/2.,
                                  self.side_length/2.])
        self.corners_y = np.array([self.side_length/2., -self.side_length/2., -self.side_length/2.,
                                  self.side_length/2.])
        # Need the rotation even if not using the camera
        self.columnsNeeded.append(rotSkyPosColName)
        self.columnsNeeded = list(set(self.columnsNeeded))

        # The 3D search radius for things inside the raft
        self.side_radius = simsUtils.xyz_angular_radius(side_length/2.)
예제 #2
0
    def __init__(self, sat_tle_list, alt_limit=30., fov=3.5, tstep=5., exptime=30.):
        self.sat_list = [ephem.readtle(tle.split('\n')[0], tle.split('\n')[1], tle.split('\n')[2]) for tle in sat_tle_list]
        self.alt_limit_rad = np.radians(alt_limit)
        self.fov_rad = np.radians(fov)
        self._make_observer()
        self._make_fields()
        self.tsteps = np.arange(0, exptime+tstep, tstep)/3600./24.  # to days

        self.radius = xyz_angular_radius(fov)
예제 #3
0
 def __init__(self, nside=None, side_length=0.7):
     """
     Parameters
     ----------
     side_length : float (0.7)
         The length of one side of the square field of view (degrees).
     """
     if nside is None:
         nside = set_default_nside()
     self.nside = nside
     self.tree = hp_kd_tree(nside=nside)
     self.side_length = np.radians(side_length)
     self.inner_radius = xyz_angular_radius(side_length/2.)
     self.outter_radius = xyz_angular_radius(side_length/2.*np.sqrt(2.))
     # The positions of the raft corners, unrotated
     self.corners_x = np.array([-self.side_length/2., -self.side_length/2., self.side_length/2.,
                               self.side_length/2.])
     self.corners_y = np.array([self.side_length/2., -self.side_length/2., -self.side_length/2.,
                               self.side_length/2.])
예제 #4
0
    def _run(self, simData, cols_present=False):
        if cols_present:
            # Column already present in data; assume it is correct and does not need recalculating.
            return simData

        if self.degrees:
            coord_x, coord_y, coord_z = xyz_from_ra_dec(simData[self.raCol],
                                                        simData[self.decCol])
            field_ids = self.tree.query_ball_point(list(zip(coord_x, coord_y, coord_z)),
                                                   xyz_angular_radius())

        else:
            # use _xyz private method (sending radians)
            coord_x, coord_y, coord_z = _xyz_from_ra_dec(simData[self.raCol],
                                                         simData[self.decCol])
            field_ids = self.tree.query_ball_point(list(zip(coord_x, coord_y, coord_z)),
                                                   xyz_angular_radius())

        simData['opsimFieldId'] = np.array([ids[0] for ids in field_ids]) + 1
        return simData
예제 #5
0
    def __init__(self, nside=None, fov_radius=1.75):
        """
        Parameters
        ----------
        fov_radius : float (1.75)
            Radius of the filed of view in degrees
        """
        if nside is None:
            nside = set_default_nside()

        self.tree = hp_kd_tree(nside=nside)
        self.radius = xyz_angular_radius(fov_radius)
예제 #6
0
    def __init__(self, nside=None, fov_radius=1.75, scale=1e5):
        """
        Parameters
        ----------
        fov_radius : float (1.75)
            Radius of the filed of view in degrees
        """
        if nside is None:
            nside = set_default_nside()

        self.tree = hp_kd_tree(nside=nside, scale=scale)
        self.radius = np.round(xyz_angular_radius(fov_radius)*scale).astype(int)
        self.scale = scale
예제 #7
0
    def testKDTreeAPI(self):
        """
        Make sure the API provided by scipy to the kdTree algorithm is functional.
        """
        _ra = np.linspace(0., 2.*np.pi)
        _dec = np.linspace(-np.pi, np.pi)

        Ra, Dec = np.meshgrid(_ra, _dec)
        tree = utils._buildTree(Ra.flatten(), Dec.flatten())

        x, y, z = utils._xyz_from_ra_dec(_ra, _dec)
        indx = tree.query_ball_point(list(zip(x, y, z)), utils.xyz_angular_radius())

        self.assertEqual(indx.shape, _ra.shape)
예제 #8
0
    def __init__(self,
                 nside=128,
                 lonCol='fieldRA',
                 latCol='fieldDec',
                 latLonDeg=True,
                 verbose=True,
                 badval=hp.UNSEEN,
                 useCache=True,
                 leafsize=100,
                 useCamera=False,
                 rotSkyPosColName='rotSkyPos',
                 mjdColName='observationStartMJD',
                 chipNames=center_raft_chips,
                 side_length=0.7):
        """
        Parameters
        ----------
        side_length : float (0.7)
            How large is a side of the raft (degrees)
        """
        radius = side_length / 2. * np.sqrt(2.)
        super(HealpixComCamSlicer,
              self).__init__(nside=nside,
                             lonCol=lonCol,
                             latCol=latCol,
                             latLonDeg=latLonDeg,
                             verbose=verbose,
                             badval=badval,
                             useCache=useCache,
                             leafsize=leafsize,
                             radius=radius,
                             useCamera=useCamera,
                             rotSkyPosColName=rotSkyPosColName,
                             mjdColName=mjdColName,
                             chipNames=chipNames)
        self.side_length = np.radians(side_length)
        self.corners_x = np.array([
            -self.side_length / 2., -self.side_length / 2.,
            self.side_length / 2., self.side_length / 2.
        ])
        self.corners_y = np.array([
            self.side_length / 2., -self.side_length / 2.,
            -self.side_length / 2., self.side_length / 2.
        ])
        # Need the rotation even if not using the camera
        self.columnsNeeded.append(rotSkyPosColName)
        self.columnsNeeded = list(set(self.columnsNeeded))

        # The 3D search radius for things inside the raft
        self.side_radius = simsUtils.xyz_angular_radius(side_length / 2.)
예제 #9
0
    def testKDTreeAPI(self):
        """
        Make sure the API provided by scipy to the kdTree algorithm is functional.
        """
        _ra = np.linspace(0., 2. * np.pi)
        _dec = np.linspace(-np.pi, np.pi)

        Ra, Dec = np.meshgrid(_ra, _dec)
        tree = utils._buildTree(Ra.flatten(), Dec.flatten())

        x, y, z = utils._xyz_from_ra_dec(_ra, _dec)
        indx = tree.query_ball_point(list(zip(x, y, z)),
                                     utils.xyz_angular_radius())

        self.assertEqual(indx.shape, _ra.shape)
예제 #10
0
 def _setRad(self, radius=1.75):
     """Set radius (in degrees) for kdtree search using utility function from mafUtils."""
     self.rad = simsUtils.xyz_angular_radius(radius)
예제 #11
0
 def _setRad(self, radius=1.75):
     """Set radius (in degrees) for kdtree search using utility function from mafUtils."""
     self.rad = simsUtils.xyz_angular_radius(radius)