From 96d6ccbb77e4bbe3f99592bc0d21302d2c1b19a8 Mon Sep 17 00:00:00 2001 From: Arun Kannawadi Date: Thu, 31 Oct 2024 09:55:14 -0700 Subject: [PATCH] Resolve conflicts --- metadetect/lsst/measure.py | 150 ---------------------------------- metadetect/lsst/metadetect.py | 44 ---------- metadetect/lsst/skysub.py | 2 +- 3 files changed, 1 insertion(+), 195 deletions(-) diff --git a/metadetect/lsst/measure.py b/metadetect/lsst/measure.py index 8b62857d..bc1477a4 100644 --- a/metadetect/lsst/measure.py +++ b/metadetect/lsst/measure.py @@ -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, @@ -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", @@ -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 @@ -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. @@ -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( diff --git a/metadetect/lsst/metadetect.py b/metadetect/lsst/metadetect.py index 392214f1..00a5e125 100644 --- a/metadetect/lsst/metadetect.py +++ b/metadetect/lsst/metadetect.py @@ -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) config.freeze() config.validate() @@ -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)", @@ -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): super().validate() @@ -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" @@ -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, diff --git a/metadetect/lsst/skysub.py b/metadetect/lsst/skysub.py index 57542989..eb738b70 100644 --- a/metadetect/lsst/skysub.py +++ b/metadetect/lsst/skysub.py @@ -214,4 +214,4 @@ def __init__(self, *args, **kwargs): self.makeSubtask("detect_sources") def run(self, exposure, **kwargs): - return self._sky_sub(exposure, **kwargs) \ No newline at end of file + return self._sky_sub(exposure, **kwargs)