Skip to content

Commit

Permalink
Merge pull request #20 from lsst/bugfix/SIM-1250-camera-equals
Browse files Browse the repository at this point in the history
Bugfix/sim 1250 camera equals
  • Loading branch information
rhiannonlynne committed Jul 10, 2015
2 parents 689fe28 + d1b97ef commit 73dc094
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/lsst/sims/maf/slicers/baseSpatialSlicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _presliceFootprint(self, simData):
self.obs_metadata.unrefractedDec = dec
self.obs_metadata.rotSkyPos = rotSkyPos
self.obs_metadata.mjd = mjd
# Correct ra,dec for
# Correct ra,dec for refraction (because this is automatically done within findChipNames for the boresight)
raCorr, decCorr = observedFromICRS(self.slicePoints['ra'][hpIndices],
self.slicePoints['dec'][hpIndices],
obs_metadata=self.obs_metadata,
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/sims/maf/slicers/healpixSlicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def __eq__(self, otherSlicer):
if otherSlicer.nside == self.nside:
if (otherSlicer.lonCol == self.lonCol and otherSlicer.latCol == self.latCol):
if otherSlicer.radius == self.radius:
result = True
if otherSlicer.useCamera == self.useCamera:
result = True
return result

def _pix2radec(self, islice):
Expand Down
23 changes: 20 additions & 3 deletions python/lsst/sims/maf/slicers/userPointsSlicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,41 @@

class UserPointsSlicer(BaseSpatialSlicer):
"""Use spatial slicer on a user provided point """
def __init__(self, verbose=True, lonCol='fieldRA', latCol='fieldDec',
badval=-666, leafsize=100, radius=1.75, ra=None, dec=None, **kwargs):
def __init__(self, ra, dec, verbose=True, lonCol='fieldRA', latCol='fieldDec',
badval=-666, leafsize=100, radius=1.75,
useCamera=False, rotSkyPosColName='rotSkyPos', mjdColName='expMJD'):
"""
ra = list of ra points to use
dec = list of dec points to use
"""

super(UserPointsSlicer,self).__init__(verbose=verbose,
lonCol=lonCol, latCol=latCol,
badval=badval, radius=radius, leafsize=leafsize, **kwargs)
badval=badval, radius=radius, leafsize=leafsize,
useCamera=useCamera, rotSkyPosColName=rotSkyPosColName,
mjdColName=mjdColName)

# check that ra and dec are iterable, if not, they are probably naked numbers, wrap in list
if not hasattr(ra, '__iter__'):
ra = [ra]
if not hasattr(dec, '__iter__'):
dec = [dec]
if len(ra) != len(dec):
raise ValueError('RA and Dec must be the same length')
self.nslice = np.size(ra)
self.slicePoints['sid'] = np.arange(np.size(ra))
self.slicePoints['ra'] = np.array(ra)
self.slicePoints['dec'] = np.array(dec)
self.plotFuncs = [BaseSkyMap, BaseHistogram]

def __eq__(self, otherSlicer):
"""Evaluate if two slicers are equivalent."""
result = False
if isinstance(otherSlicer, UserPointsSlicer):
if otherSlicer.nslice == self.nslice:
if np.all(otherSlicer.ra == self.ra) and np.all(otherSlicer.dec == self.dec):
if (otherSlicer.lonCol == self.lonCol and otherSlicer.latCol == self.latCol):
if otherSlicer.radius == self.radius:
if otherSlicer.useCamera == self.useCamera:
result = True
return result

0 comments on commit 73dc094

Please sign in to comment.