Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

# 

# LSST Data Management System 

# Copyright 2008-2017 LSST/AURA. 

# 

# 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/>. 

# 

 

# The Plugin classes here are accessed via registries, not direct imports. 

__all__ = ("CModelStageConfig", "CModelConfig") 

 

from .cmodel import CModelStageControl, CModelControl, CModelAlgorithm 

 

from lsst.pex.config import makeConfigClass 

import lsst.meas.base 

 

 

CModelStageConfig = makeConfigClass(CModelStageControl) 

CModelConfig = makeConfigClass(CModelControl) 

 

apCorrList = ("modelfit_CModel", "modelfit_CModel_initial", "modelfit_CModel_exp", "modelfit_CModel_dev") 

 

 

class CModelSingleFrameConfig(lsst.meas.base.SingleFramePluginConfig, CModelConfig): 

 

def setDefaults(self): 

lsst.meas.base.SingleFramePluginConfig.setDefaults(self) 

CModelConfig.setDefaults(self) 

 

 

@lsst.meas.base.register("modelfit_CModel", apCorrList=apCorrList) 

class CModelSingleFramePlugin(lsst.meas.base.SingleFramePlugin): 

"""Single-frame measurement interface for CModelAlgorithm. 

 

This class simply provides __init__ and measure methods that matched the SingleFramePlugin signatures 

and delegate to the CModelAlgorithm's methods. 

""" 

ConfigClass = CModelSingleFrameConfig 

 

@staticmethod 

def getExecutionOrder(): 

return 3.0 

 

def __init__(self, config, name, schema, metadata): 

lsst.meas.base.SingleFramePlugin.__init__(self, config, name, schema, metadata) 

self.algorithm = CModelAlgorithm(name, config.makeControl(), schema) 

 

def measure(self, measRecord, exposure): 

self.algorithm.measure(measRecord, exposure) 

 

def fail(self, measRecord, error=None): 

self.algorithm.fail(measRecord, error.cpp if error is not None else None) 

 

 

class CModelForcedConfig(lsst.meas.base.ForcedPluginConfig, CModelConfig): 

 

def setDefaults(self): 

lsst.meas.base.ForcedPluginConfig.setDefaults(self) 

CModelConfig.setDefaults(self) 

 

 

@lsst.meas.base.register("modelfit_CModel", apCorrList=apCorrList) 

class CModelForcedPlugin(lsst.meas.base.ForcedPlugin): 

"""Forced measurement interface for CModelAlgorithm 

 

This class simply provides __init__ and measure methods that matched the ForcedPlugin signatures 

and delegate to CModelAlgorithm implementations. 

 

The CModel algorithm currently cannot be run in forced mode when the measurement WCS is different 

from the reference WCS (as is the case in CCD forced photometry). This is a temporary limitation 

that will be addressed on DM-5405. 

 

CModel forced measurement when the measurement image is the same as the reference image should be 

almost -- but not quite -- identical to unforced measurement. The primary difference is that 

the final fit region from the reference measurement will be used for the initial fit in forced mode 

as well as the exp, dev, and combined exp+dev fits 

""" 

ConfigClass = CModelForcedConfig 

 

@staticmethod 

def getExecutionOrder(): 

return 3.0 

 

def __init__(self, config, name, schemaMapper, metadata): 

lsst.meas.base.ForcedPlugin.__init__(self, config, name, schemaMapper, metadata) 

self.algorithm = CModelAlgorithm(name, config.makeControl(), schemaMapper) 

 

def measure(self, measRecord, exposure, refRecord, refWcs): 

if refWcs != exposure.getWcs(): 

raise lsst.meas.base.FatalAlgorithmError( 

"CModel forced measurement currently requires the measurement image to have the same" 

" Wcs as the reference catalog (this is a temporary limitation)." 

) 

self.algorithm.measure(measRecord, exposure, refRecord) 

 

def fail(self, measRecord, error=None): 

self.algorithm.fail(measRecord, error.cpp if error is not None else None)