Coverage for tests/test_scarlet.py: 39%

31 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-17 09:41 +0000

1# This file is part of meas_extensions_scarlet. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22import unittest 

23 

24import numpy as np 

25import scarlet 

26from scarlet.initialization import init_source 

27import lsst.utils.tests 

28 

29from utils import numpyToStack, initData 

30 

31 

32class TestLsstSource(lsst.utils.tests.TestCase): 

33 def test_to_heavy(self): 

34 shape = (5, 31, 55) 

35 B, Ny, Nx = shape 

36 coords = [(20, 10), (10, 30), (17, 42)] 

37 result = initData(shape, coords, [3, 2, 1]) 

38 targetPsfImage, psfImages, images, channels, seds, morphs, targetPsf, psfs = result 

39 images = images.astype(np.float32) 

40 seds = seds.astype(np.float32) 

41 

42 frame = scarlet.Frame(shape, psf=targetPsf, channels=np.arange(B)) 

43 observation = scarlet.Observation(images, psf=psfImages, channels=np.arange(B)).match(frame) 

44 foot, peak, bbox = numpyToStack(images, coords[0], (15, 3)) 

45 xmin = bbox.getMinX() 

46 ymin = bbox.getMinY() 

47 center = np.array([peak.getIy()-ymin, peak.getIx()-xmin], dtype=int) 

48 src = init_source(frame=frame, center=center, observations=[observation], thresh=0) 

49 

50 # Convolve the model with the observed PSF 

51 model = src.get_model(frame=src.frame) 

52 model = observation.render(model) 

53 

54 

55class MemoryTester(lsst.utils.tests.MemoryTestCase): 

56 pass 

57 

58 

59def setup_module(module): 

60 lsst.utils.tests.init() 

61 

62 

63if __name__ == "__main__": 63 ↛ 64line 63 didn't jump to line 64, because the condition on line 63 was never true

64 lsst.utils.tests.init() 

65 unittest.main()