# Making the required images to create figure 2
# Blue Cloud
immoments(
    imagename='M33SNR_35_CO21_cube.image',
    moments=[0],
    chans='5~15',      
    outfile='M33SNR_35_Sano_Blue'
)

# Red Cloud 
immoments(
    imagename='M33SNR_35_CO21_cube.image',
    moments=[0],
    chans='16~24',     
    outfile='M33SNR_35_Sano_Red'
)
#correcting the beam
impbcor(
    imagename='M33SNR_35_Sano_Blue',
    pbimage='M33SNR_35_CO21_cube.pb',
    outfile='M33_Sano_Fig8a_Blue.pbcor'
)
impbcor(
    imagename='M33SNR_35_Sano_Red',
    pbimage='M33SNR_35_CO21_cube.pb',
    outfile='M33_Sano_Fig8a_Red.pbcor'
)


immoments(
    imagename='M33SNR_35_CO21_cube.image.pbcor',
    moments=[0],
    chans='5~15',
    outfile='M33_Sano_Fig8a_Blue.pbcor'
)

immoments(
    imagename='M33SNR_35_CO21_cube.image.pbcor',
    moments=[0],
    chans='16~24',
    outfile='M33_Sano_Fig8a_Red.pbcor'
)

# 1. Open the image tool
ia.open('M33_Sano_Fig8a_Red.pbcor')

# 2. Define your pixel shift (from our 0.1" calculation)
# RA shift ~ -10.3 pixels, Dec shift ~ -11.1 pixels
shift = [-10.3, -11.1]

# 3. Use the 'ia.regrid' approach to shift the data
# We are essentially telling CASA: "Redraw this image, but move everything"
shifted_image = ia.regrid(
    outfile='M33_Sano_Fig8a_Red_SHIFTED_FINAL',
    shape=ia.shape(),
    axes=[0, 1],
    offset=shift,
    overwrite=True
)

# 4. Cleanup
ia.done()
if shifted_image:
    shifted_image.done()

