Preparation of Data

Before starting the line fit we need to prepare the data. As an example, if different lines need to be combined later in the analysis, then my suggestion is to first prepare all the cubes to a common beam and grid.

File regridding

I will add a sample file showing how to modify a cube to match angular resolution and pixel grid to that of a second line.

Unit conversion and primary beam correction

The convertion of interferometric data into Kelvin units and including the primary beam conversion can be performed with the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from spectral_cube import SpectralCube
import numpy as np
import astropy.units as u

# file without the primary beam corrected
# then primary beam response, and primary beam corrected one
file_in = 'cube_no_PBcorr.fits'
file_in_PB = 'cube_PB_response.fits'
file_in_K = 'cube_ready.fits'

cube = SpectralCube.read(file_in)
PB = fits.getdata(file_in_PB)
kcube = cube.to(u.K) / np.squeeze(PB)
kcube.write(file_in_K, overwrite=True)