Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed Oct 31, 2024
1 parent 313aac0 commit 96d6ccb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 195 deletions.
150 changes: 0 additions & 150 deletions metadetect/lsst/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@


class DetectAndDeblendConfig(Config):
<<<<<<< HEAD
detection = ConfigurableField(
target=SourceDetectionTask,
doc="Detection configuration",
)

deblend = ConfigurableField(
target=SourceDeblendTask,
doc="Deblending configuration",
)

meas = ConfigurableField(
target=SingleFrameMeasurementTask,
doc="Measurement configuration",
=======
meas = ConfigurableField[SingleFrameMeasurementConfig](
doc="Measurement config",
target=SingleFrameMeasurementTask,
Expand All @@ -80,52 +65,12 @@ class DetectAndDeblendConfig(Config):
seed = Field[int](
doc="Random rng seed",
default=42,
>>>>>>> u/im/detect-deblend-refactor-1
)

def setDefaults(self):
super().setDefaults()

<<<<<<< HEAD
# DM does not have config default stability. Set all of them explicitly
self.detection.minPixels = 1
self.detection.isotropicGrow = True
self.detection.combinedGrow = True
self.detection.nSigmaToGrow = 2.4
self.detection.returnOriginalFootprints = False
self.detection.includeThresholdMultiplier = 1.0
self.detection.thresholdPolarity = "positive"
self.detection.adjustBackground = 0.0
self.detection.reEstimateBackground = True
# these are ignored since we are doing reEstimateBackground = False
# self.detection.background
# self.detection.tempLocalBackground
# self.detection.doTempLocalBackground
# self.detection.tempWideBackground
# self.detection.doTempWideBackground

self.detection.nPeaksMaxSimple = 1
self.detection.nSigmaForKernel = 7.0
self.detection.excludeMaskPlanes = util.get_detection_mask()

# the defaults changed from from stdev to pixel_std but
# we don't want that

self.detection.thresholdType = "stdev"
# our changes from defaults
self.detection.reEstimateBackground = False

self.detection.thresholdValue = DEFAULT_THRESH
self.detection.thresholdType = 'stdev'

# these will be ignored when finding the image standard deviation
self.detection.statsMask = util.get_stats_mask()

self.deblend.maxFootprintArea = 0

=======
# defaults for measurement config
>>>>>>> u/im/detect-deblend-refactor-1
self.meas.plugins.names = [
"base_SdssCentroid",
"base_PsfFlux",
Expand All @@ -144,10 +89,6 @@ def setDefaults(self):
# fix odd issue where it things things are near the edge
self.meas.plugins['base_SdssCentroid'].binmax = 1

<<<<<<< HEAD

class DetectAndDeblendTask(Task):
=======
# defaults for detection config
# DM does not have config default stability. Set all of them explicitly
self.detect.minPixels = 1
Expand Down Expand Up @@ -252,7 +193,6 @@ def detect_and_deblend(
show=False,
config=None,
):
>>>>>>> u/im/detect-deblend-refactor-1
"""
run detection and deblending of peaks, as well as basic measurments such as
centroid. The SDSS deblender is run in order to split footprints.
Expand All @@ -277,113 +217,23 @@ def detect_and_deblend(
sources, detexp
The sources and the detection exposure
"""
<<<<<<< HEAD

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.makeSubtask('detection')
self.makeSubtask('deblend')
self.makeSubtask('meas')

def run(self, mbexp):
pass


def detect_and_deblend(
mbexp,
rng,
thresh=DEFAULT_THRESH,
show=False,
):
=======
config_override = config if config is not None else {}
if thresh:
if 'detect' not in config_override:
config_override['detect'] = {}
config_override['detect']['thresholdValue'] = thresh
>>>>>>> u/im/detect-deblend-refactor-1

config = DetectAndDeblendConfig()
config.setDefaults()

util.override_config(config, config_override)

<<<<<<< HEAD
schema = afw_table.SourceTable.makeMinimalSchema()

# Setup algorithms to run
meas_config = SingleFrameMeasurementConfig()
meas_config.plugins.names = [
"base_SdssCentroid",
"base_PsfFlux",
"base_SkyCoord",
]

# set these slots to none because we aren't running these algorithms
meas_config.slots.apFlux = None
meas_config.slots.gaussianFlux = None
meas_config.slots.calibFlux = None
meas_config.slots.modelFlux = None

# goes with SdssShape above
meas_config.slots.shape = None

# fix odd issue where it things things are near the edge
meas_config.plugins['base_SdssCentroid'].binmax = 1

meas_task = SingleFrameMeasurementTask(
config=meas_config,
schema=schema,
)
# avoids a warning spamming for every object
afw_table.CoordKey.addErrorFields(schema)

# these tasks must use the same schema and all be constructed before any
# other tasks using the same schema are run because schema is modified in
# place by tasks, and the constructor does a check that fails if we do this
# afterward
deblend_config = SourceDeblendConfig()
deblend_config.maxFootprintArea = 0
deblend_task = SourceDeblendTask(
config=deblend_config,
schema=schema,
)

table = afw_table.SourceTable.make(schema)

result = self.detection.run(table, detexp)

if result is not None:
sources = result.sources
deblend_task.run(detexp, sources)

with ContextNoiseReplacer(detexp, sources, rng) as replacer:

for source in sources:

if source.get('deblend_nChild') != 0:
continue

source_id = source.getId()

with replacer.sourceInserted(source_id):
meas_task.callMeasure(source, detexp)

else:
sources = []

if show:
vis.show_exp(detexp, use_mpl=True, sources=sources)

return sources, detexp
=======
config.freeze()
config.validate()
task = DetectAndDeblendTask(config=config)
if rng is not None:
task.rng = rng
return task.run(mbexp, show)
>>>>>>> u/im/detect-deblend-refactor-1


def measure(
Expand Down
44 changes: 0 additions & 44 deletions metadetect/lsst/metadetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def run_metadetect(
config_override = config if config is not None else {}
config = MetadetectConfig()
config.setDefaults()
<<<<<<< HEAD
override_config(config, config_override)

Check failure on line 81 in metadetect/lsst/metadetect.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

F821

undefined name 'override_config'
config.freeze()
config.validate()
Expand All @@ -87,34 +86,6 @@ def run_metadetect(
return result


=======
for key, value in config_override.items():
if key == "weight":
for subkey, subvalue in value.items():
setattr(config.weight, subkey, subvalue)
elif key == "psf":
for subkey, subvalue in value.items():
setattr(config.psf, subkey, subvalue)
elif key == "detect":
for subkey, subvalue in value.items():
setattr(config.detect, subkey, subvalue)
elif key == "metacal":
for subkey, subvalue in value.items():
setattr(config.metacal, subkey, subvalue)
else: # not hasattr(config_override[key], "__get__"):
setattr(config, key, value)
# else:
# subconfig = getattr(config, key)
# for subkey, subvalue in value.items():
# setattr(subconfig, subkey, subvalue)

config.validate()
task = MetadetectTask(config=config)
result = task.run(mbexp, noise_mbexp, rng, mfrac_mbexp, ormasks, show=show,)
return result


>>>>>>> u/im/detect-deblend-refactor-1
class WeightConfig(Config):
fwhm = Field[float](
doc="FWHM of the Gaussian weight function (in pixel units)",
Expand Down Expand Up @@ -220,16 +191,8 @@ def setDefaults(self):

# self.stamp_size = DEFAULT_STAMP_SIZES[self.meas_type]

<<<<<<< HEAD
self.weight = WeightConfig()
self.weight.fwhm = DEFAULT_WEIGHT_FWHMS.get(self.meas_type, None)

self.psf = PsfConfig()
self.metacal = MetacalConfig()
=======
self.weight.fwhm = DEFAULT_WEIGHT_FWHMS.get(self.meas_type, None)

>>>>>>> u/im/detect-deblend-refactor-1

def validate(self):

Check failure on line 197 in metadetect/lsst/metadetect.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

E303

too many blank lines (2)
super().validate()
Expand All @@ -242,10 +205,7 @@ def validate(self):
f"for meas_type {self.meas_type}",
)

<<<<<<< HEAD
=======

>>>>>>> u/im/detect-deblend-refactor-1
class MetadetectTask(Task):
ConfigClass = MetadetectConfig
_DefaultName = "metadetect"
Expand All @@ -254,10 +214,6 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.makeSubtask("detect")

<<<<<<< HEAD

=======
>>>>>>> u/im/detect-deblend-refactor-1
def run(
self,
mbexp,
Expand Down
2 changes: 1 addition & 1 deletion metadetect/lsst/skysub.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,4 @@ def __init__(self, *args, **kwargs):
self.makeSubtask("detect_sources")

def run(self, exposure, **kwargs):
return self._sky_sub(exposure, **kwargs)
return self._sky_sub(exposure, **kwargs)

0 comments on commit 96d6ccb

Please sign in to comment.