Coverage for tests/test_multiIndex.py : 24%

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
# # LSST Data Management System # Copyright 2008, 2009, 2010 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
ANetBasicAstrometryConfig, ANetBasicAstrometryTask
self.conf = ANetBasicAstrometryConfig()
# Load sample input from disk testDir = os.path.dirname(__file__) self.srcCat = afwTable.SourceCatalog.readFits(os.path.join(testDir, "v695833-e0-c000.xy.fits"))
# The .xy.fits file has sources in the range ~ [0,2000],[0,4500] self.bbox = geom.Box2I(geom.Point2I(0, 0), geom.Extent2I(2048, 4612)) # approximate self.exposure = afwImg.ExposureF(os.path.join(testDir, "v695833-e0-c000-a00.sci.fits"))
# Set up local astrometry_net_data self.an_data_dir = setupAstrometryNetDataDir('photocal')
del self.srcCat del self.conf del self.bbox del self.exposure
astrom = ANetBasicAstrometryTask(self.conf, andConfig=andConfig) astrom.log.setLevel(logLevel) res = astrom.determineWcs(self.srcCat, self.exposure, bbox=self.bbox) del astrom return res
res = self.getAstrometrySolution(logLevel=Log.TRACE, **kwargs) self.assertIsNotNone(res) self.assertGreater(len(res.getMatches()), 50)
# This is the "vanilla" no-multiIndex setup andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig2.py') andConfig.load(fn) self._testGetSolution(andConfig=andConfig)
# This is a multiIndex setup with two indices andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig3.py') andConfig.load(fn) self._testGetSolution(andConfig=andConfig)
# This is a multiIndex setup with two indices, one that has no star kdtree andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig4.py') andConfig.load(fn) self._testGetSolution(andConfig=andConfig)
# This one has a multiIndex and a normal index. andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig5.py') andConfig.load(fn) self._testGetSolution(andConfig=andConfig)
# This one has a multiIndex with stars-only and index-only parts andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig6.py') andConfig.load(fn) self._testGetSolution(andConfig=andConfig)
# This one uses the cache andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig6.py') andConfig.load(fn) andConfig.allowCache = True cacheName = os.path.join(self.an_data_dir, 'andCache.fits') if os.path.exists(cacheName): os.unlink(cacheName) try: generateCache(andConfig) self.assertTrue(os.path.exists(cacheName)) self._testGetSolution(andConfig=andConfig) finally: if os.path.exists(cacheName): os.unlink(cacheName)
# Test that creating an Astrometry object with many index files # does not use up a lot of memory or file descriptors. # FIXME -- there are no tests on memory usage -- not clear exactly # what to enforce. fd0 = ttime.count_file_descriptors() print('Mem0:', end=' ') print(ttime.memusage()) print('FD0:', fd0)
andConfig = AstrometryNetDataConfig() fn = os.path.join(self.an_data_dir, 'andConfig6.py') andConfig.load(fn) andConfig.multiIndexFiles = andConfig.multiIndexFiles * 100 print(len(andConfig.multiIndexFiles), 'multi-index files')
astrom = ANetBasicAstrometryTask(self.conf, andConfig=andConfig)
fd1 = ttime.count_file_descriptors() print() print('Mem1:') print(ttime.memusage()) print('FD1:', fd1)
# Number of used file descriptors should not grow. Magic 10 # is just margin from other things going on in the python process self.assertLess(fd1, fd0 + 10)
res = astrom.determineWcs(self.srcCat, self.exposure, bbox=self.bbox)
fd2 = ttime.count_file_descriptors() print() print('Mem2:') print(ttime.memusage()) print('FD2:', fd2)
# Number of used file descriptors should not grow. Magic 10 # is just margin from other things going on in the python process self.assertLess(fd2, fd0 + 10)
del res del astrom
fd3 = ttime.count_file_descriptors() print() print('Mem3:') print(ttime.memusage()) print('FD3:', fd3)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |