Coverage for python/lsst/sims/maf/metrics/starDensity.py : 50%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from .baseMetric import BaseMetric
2from scipy.interpolate import interp1d
4__all__ = ['StarDensityMetric']
7class StarDensityMetric(BaseMetric):
8 """Interpolate the stellar luminosity function to return the number of
9 stars per square arcsecond brighter than the rmagLimit. Note that the
10 map is built from CatSim stars in the range 20 < r < 28."""
12 def __init__(self, rmagLimit=25., units='stars/sq arcsec', filtername='r',
13 maps=['StellarDensityMap'], **kwargs):
15 super(StarDensityMetric, self).__init__(col=[],
16 maps=maps, units=units, **kwargs)
17 self.rmagLimit = rmagLimit
18 self.filtername = filtername
20 def run(self, dataSlice, slicePoint=None):
21 # Interpolate the data to the requested mag
22 interp = interp1d(slicePoint['starMapBins_%s' % self.filtername][1:], slicePoint['starLumFunc_%s' % self.filtername])
23 # convert from stars/sq degree to stars/sq arcsec
24 result = interp(self.rmagLimit)/(3600.**2)
25 return result