<commit_before>
'''
Find the amount of emission recovered in a high-resolution map, based on a low-resolution map
'''

from spectral_cube import SpectralCube
import numpy as np
from radio_beam import Beam
from astropy.convolution import convolve
from astropy import units as u
from astropy import wcs


class MultiResObs(object):
    """
    Object to hold observations of the same object at different resolutions.
    This is intended for matching and analyzing high-res (interferometric)
    and low-res (single dish) observations.
    """
    def __init__(self, highres, lowres):
        super(MultiResObs, self).__init__()
        self.highres = SpectralCube.read(highres)
        self.lowres = SpectralCube.read(lowres)

        self.lowbeam = Beam.from_fits_header(self.lowres.header)
        self.highbeam = Beam.from_fits_header(self.highres.header)

        self.combined_beam = self.lowbeam.convolve(self.highbeam)

    def match_coords(self):
        '''
        Match the spatial and spectral coordinates of the cubes.
        '''

        # Are either of the cubes in the correct frame?
        if self.highres.header['CTYPE1'] != self.lowres.header['CTYPE1']:
            raise TypeError("ctypes do not match. Are observations in the "
                            "same projection? Highres: " +
                            self.highres.header['CTYPE1'] +
                            " Lowres: " + self.lowres.header['CTYPE1'])
        elif self.highres.header['CTYPE2'] != self.lowres.header['CTYPE2']:
            raise TypeError("ctypes do not match. Are observations in the "
                            "same projection? Highres: " +
                            self.highres.header['CTYPE2'] +
                            " Lowres: " + self.lowres.header['CTYPE2'])

        # Determine which cube should be slice down so both have the same
        # spatial coverage.

        all_extrema = []

        long_slice = self.lowres.longitude_extrema > self.highres.longitude_extrema

        if long_slice[0]:<commit_msg>Beam already in SpectralCube<commit_after>
'''
Find the amount of emission recovered in a high-resolution map, based on a low-resolution map
'''

from spectral_cube import SpectralCube
import numpy as np
from radio_beam import Beam
from astropy.convolution import convolve
from astropy import units as u
from astropy import wcs


class MultiResObs(object):
    """
    Object to hold observations of the same object at different resolutions.
    This is intended for matching and analyzing high-res (interferometric)
    and low-res (single dish) observations.
    """
    def __init__(self, highres, lowres):
        super(MultiResObs, self).__init__()
        self.highres = SpectralCube.read(highres)
        self.lowres = SpectralCube.read(lowres)

        self.lowbeam = self.lowres.beam
        self.highbeam = self.highres.beam

        self.combined_beam = self.lowbeam.convolve(self.highbeam)

    def match_coords(self):
        '''
        Match the spatial and spectral coordinates of the cubes.
        '''

        # Are either of the cubes in the correct frame?
        if self.highres.header['CTYPE1'] != self.lowres.header['CTYPE1']:
            raise TypeError("ctypes do not match. Are observations in the "
                            "same projection? Highres: " +
                            self.highres.header['CTYPE1'] +
                            " Lowres: " + self.lowres.header['CTYPE1'])
        elif self.highres.header['CTYPE2'] != self.lowres.header['CTYPE2']:
            raise TypeError("ctypes do not match. Are observations in the "
                            "same projection? Highres: " +
                            self.highres.header['CTYPE2'] +
                            " Lowres: " + self.lowres.header['CTYPE2'])

        # Determine which cube should be slice down so both have the same
        # spatial coverage.

        all_extrema = []

        long_slice = self.lowres.longitude_extrema > self.highres.longitude_extrema

        if long_slice[0]:
{'fraction_non_alphanumeric': 0.08917513004706465, 'fraction_numerical': 0.004458756502353232, 'mean_word_length': 2.3098360655737706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '461574', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1099, 'n_words': 324}