Commits

casatasks/src/private/task_imbaseline.py

Modified
19 19 from casatasks.private.task_sdsmooth import sdsmooth
20 20 from casatools import image, table, quanta
21 21
22 22 DATACOLUMN = 'DATA'
23 23 OVERWRITE = True
24 24
25 25 IMAGE_STACK_MAX_HEIGHT = 4
26 26 MS_STACK_MAX_HEIGHT = 3
27 27
28 28 qa = quanta()
29 +do_not_erase_temporary_files = True
29 30
30 31
31 32 class AbstractFolder:
32 33 """Abstract class has Image/MeasurementSet file path.
33 34
34 35 This class and child classes are wrapper of CasaImage/MeasurementSet file.
35 36 The wrapped path could be decided to erase by which child classes are implemented.
36 37 """
37 38
38 39 has_file = False
353 354 """Execute image subtraction.
354 355
355 356 The output image is computed as follows:
356 357 - in case any smoothing (along direction and/or frequency) is executed
357 358 output_image = input_image - (smoothed_image - smoothed_and_subtracted_image)
358 359 - in case no smoothing is executed
359 360 output_image = subtracted_image
360 361 """
361 362 if image_stack.height() <= 2: # any smoothing were not executed
362 363 output_image = image_stack.pop().path
364 + eraseable_folder_register.pop(output_image)
363 365 os.rename(output_image, linefile)
364 366 image_stack.push(UnerasableFolder(linefile))
365 367 else:
366 368 smoothed_image = image_stack.subpeak().path
367 369 subtracted_image = image_stack.peak().path
368 370 base_image = image_stack.bottom().path
369 371 __copy_image_file(base_image, linefile)
370 372 __subtract_image(smoothed_image, subtracted_image)
371 373 __subtract_image(linefile, smoothed_image)
372 374
376 378 base_image = image_stack.bottom().path
377 379 output_image = os.path.basename(base_image) + '.cont'
378 380 __copy_image_file(base_image, output_image)
379 381
380 382 subtract_image = image_stack.peak().path
381 383 __subtract_image(output_image, subtract_image)
382 384
383 385
384 386 def do_post_processing(outfile) -> None:
385 387 """Execute some post-processes of imbaseline."""
386 - eraseable_folder_register.clear(dry_run=False)
388 + eraseable_folder_register.clear(dry_run=do_not_erase_temporary_files)
387 389 __write_image_history(outfile)
388 390
389 391
390 392 def __subtract_image(operand_a: str=None, operand_b: str=None) -> None:
391 393 """Subtract image chunk."""
392 394 image_array = None
393 395 with tool_manager(operand_b, image) as ia:
394 396 image_array = ia.getchunk()
395 397
396 398 with tool_manager(operand_a, image) as ia:

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut