diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e3958..f99f7d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactored logging, and added tests (#338). - Updated bespoke sdintimaging task, to align with latest CASA version (#347). +- If we don't have any model flux, then overwrite minimum number of major cycles (#359). ### Fixed diff --git a/phangsPipeline/casaImagingRoutines.py b/phangsPipeline/casaImagingRoutines.py index 64662f9..00cafda 100644 --- a/phangsPipeline/casaImagingRoutines.py +++ b/phangsPipeline/casaImagingRoutines.py @@ -957,6 +957,10 @@ def clean_loop( previous_flux = current_flux current_flux = model_stats['sum'][0] + # In some cases, we may want to overwrite forcing a + # minimum number of loops + force_overwrite_min_loops = False + delta_flux = (current_flux - previous_flux) if use_absolute_delta: delta_flux = abs(delta_flux) @@ -968,6 +972,9 @@ def clean_loop( if np.isnan(frac_delta_flux) and loop > 0: frac_delta_flux = 0 + # At this point, doing more loops won't change anything + force_overwrite_min_loops = True + # Check whether the model flux convergence criteria is met if convergence_fracflux is not None: @@ -986,6 +993,12 @@ def clean_loop( if cumulative_niter >= max_total_niter: proceed = False + # If there's no change in the flux, then running for more loops + # won't do anything + if delta_flux == 0: + proceed = False + force_overwrite_min_loops = True + # If requested, stop if the integrated model flux becomes # negative. @@ -1034,12 +1047,15 @@ def clean_loop( noise_conv = None # Enforce minimum and maximum limits on number of loops. These - # override other convergence criteria. + # override other convergence criteria in most cases. if loop >= max_loops: proceed = False if loop < min_loops: - proceed = True + if force_overwrite_min_loops: + proceed = False + else: + proceed = True # Generate a record line and print the current status to the screen