Skip to content

WS-2834: Correct piperestore scripts made with CASA < 5

Daniel Nemergut requested to merge ws2834-edit_piperestore_hif into 2.8.5-DEVELOPMENT

String replacing hif_restoredata with hif(a/v)_restoredata when the calibration was made with CASA < 5.

Tested this by making a custom piperestore that needed both the import and hif fixes:

>> casa_home_major = 6
>>> recipes = "from recipes"
>>> casarecipes = "from casarecipes"
>>> hif = "hif_restoredata"
>>> hifv = "hifv_restoredata"
>>> with open("member.uid___A001_X1296_Xf59.hifa_calimage.casa_piperestorescript.py", "r") as f:
...     content = f.read()
...     content = content.replace(recipes, casarecipes) if casa_home_major > 5 else content.replace(casarecipes, recipes)
...     content = content.replace(hif, hifv) if casa_home_major >= 5 else content.replace(hifv, hif)
>>> with open("test.py", "w") as f:
...     f.write(content)

Contents of member.uid___A001_X1296_Xf59.hifa_calimage.casa_piperestorescript.py:

from recipes.almahelpers import fixsyscaltimes # SACM/JAO - Fixes
__rethrow_casa_exceptions = True
h_init()
try:
    hif_restoredata (vis=['uid___A002_Xc6c0d5_X74ad', 'uid___A002_Xc6d2f9_X170b', 'uid___A002_Xc6d2f9_X2276'], session=['session_1', 'session_2', 'session_2'], ocorr_mode='ca')
finally:
    h_save()

Corrected output in test.py:

from casarecipes.almahelpers import fixsyscaltimes # SACM/JAO - Fixes
__rethrow_casa_exceptions = True
h_init()
try:
    hifv_restoredata (vis=['uid___A002_Xc6c0d5_X74ad', 'uid___A002_Xc6d2f9_X170b', 'uid___A002_Xc6d2f9_X2276'], session=['session_1', 'session_2', 'session_2'], ocorr_mode='ca')
finally:
    h_save()

Merge request reports

Loading