<commit_before>
from spectral_cube import SpectralCube
from spectral_cube.cube_utils import largest_beam

from paths import iram_co21_data_path, fourteenB_HI_data_path
from constants import cube_name, regridco_cube_name

'''
Regrid the HI data to match the CO.
'''

cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.fits"))
del cube._header[""]

hi_cube = SpectralCube.read(fourteenB_HI_data_path(cube_name))

# Find the largest HI beam
hi_beam = largest_beam(hi_cube.beams)

hi_conv_cube = hi_cube.convolve_to(hi_beam)

hi_conv_cube = hi_conv_cube.spectral_interpolate(cube.spectral_axis)

hi_conv_cube = hi_conv_cube.regrid(cube.header)

hi_conv_cube.write(fourteenB_HI_data_path(regridco_cube_name, no_check=True))<commit_msg>Velocity axis needs flipping??<commit_after>
from spectral_cube import SpectralCube
from spectral_cube.cube_utils import largest_beam

from paths import iram_co21_data_path, fourteenB_HI_data_path
from constants import cube_name, regridco_cube_name

'''
Regrid the HI data to match the CO.
'''

cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.fits"))
del cube._header[""]

hi_cube = SpectralCube.read(fourteenB_HI_data_path(cube_name))

# Find the largest HI beam
hi_beam = largest_beam(hi_cube.beams)

hi_conv_cube = hi_cube.convolve_to(hi_beam)

hi_conv_cube = hi_conv_cube.spectral_interpolate(cube.spectral_axis)

hi_conv_cube = hi_conv_cube.reproject(cube.header)

# For some reason, the velocity axis in the data needs to be flipped.
# Look into where this is happening in spectral_cube
hi_hdu = hi_conv_cube.hdu.copy()
hi_hdu.data = hi_hdu.data[::-1]

new_hi_conv_cube = SpectralCube.read(hi_hdu)

new_hi_conv_cube.write(fourteenB_HI_data_path(regridco_cube_name, no_check=True))
{'fraction_non_alphanumeric': 0.08232584916522741, 'fraction_numerical': 0.00978698906160046, 'mean_word_length': 7.561576354679803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490094', 'n_tokens_mistral': 723, 'n_tokens_neox': 692, 'n_words': 125}