How to use the pyuvdata.utils function in pyuvdata

To help you get started, we’ve selected a few pyuvdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / parameter.py View on Github external
def lat_lon_alt(self):
        """Get value in (latitude, longitude, altitude) tuple in radians."""
        if self.value is None:
            return None
        else:
            # check defaults to False b/c exposed check kwarg exists in UVData
            return utils.LatLonAlt_from_XYZ(self.value, check_acceptability=False)
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / uvbeam.py View on Github external
efield_data = beam_object.data_array
        _sh = beam_object.data_array.shape
        Nfreqs = beam_object.Nfreqs

        if self.pixel_coordinate_system != 'healpix':
            Naxes2, Naxes1 = beam_object.Naxes2, beam_object.Naxes1
            npix = Naxes1 * Naxes2
            efield_data = efield_data.reshape(efield_data.shape[:-2] + (npix,))
            _sh = efield_data.shape

        # construct jones matrix containing the electric field

        pol_strings = ['pI', 'pQ', 'pU', 'pV']
        power_data = np.zeros((1, 1, len(pol_strings), _sh[-2], _sh[-1]), dtype=np.complex)
        beam_object.polarization_array = np.array(
            [uvutils.polstr2num(ps.upper(), x_orientation=self.x_orientation) for ps in pol_strings])

        for fq_i in range(Nfreqs):
            jones = np.zeros((_sh[-1], 2, 2), dtype=np.complex)
            pol_strings = ['pI', 'pQ', 'pU', 'pV']
            jones[:, 0, 0] = efield_data[0, 0, 0, fq_i, :]
            jones[:, 0, 1] = efield_data[0, 0, 1, fq_i, :]
            jones[:, 1, 0] = efield_data[1, 0, 0, fq_i, :]
            jones[:, 1, 1] = efield_data[1, 0, 1, fq_i, :]

            for pol_i in range(len(pol_strings)):
                power_data[:, :, pol_i, fq_i, :] = self._construct_mueller(jones, pol_i, pol_i)

        if self.pixel_coordinate_system != 'healpix':
            power_data = power_data.reshape(power_data.shape[:-1] + (Naxes2, Naxes1))
        beam_object.data_array = power_data
        beam_object.polarization_array = np.array(
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / uvbeam / beamfits.py View on Github external
----------
        filename : str
            The beamfits file to read from.
        run_check : bool
            Option to check for the existence and proper shapes of
            required parameters after reading in the file.
        check_extra : bool
            Option to check optional parameters as well as required ones.
        run_check_acceptabilit : bool
            Option to check acceptable range of the values of
            required parameters after reading in the file.
        """
        with fits.open(filename) as fname:
            primary_hdu = fname[0]
            primary_header = primary_hdu.header.copy()
            hdunames = uvutils._fits_indexhdus(fname)  # find the rest of the tables

            data = primary_hdu.data

            # only support simple antenna_types for now.
            # support for phased arrays should be added
            self._set_simple()

            self.beam_type = primary_header.pop("BTYPE", None)
            if self.beam_type is not None:
                self.beam_type = self.beam_type.lower()
            else:
                bunit = primary_header.pop("BUNIT", None)
                if bunit is not None and bunit.lower().strip() == "jy/beam":
                    self.beam_type = "power"

            if self.beam_type == "intensity":
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / uvflag / uvflag.py View on Github external
def baseline_to_antnums(self, baseline):
        """Get the antenna numbers corresponding to a given baseline number.

        Parameters
        ----------
        baseline : int
            baseline number

        Returns
        -------
        tuple
            Antenna numbers corresponding to baseline.

        """
        assert self.type == "baseline", 'Must be "baseline" type UVFlag object.'
        return uvutils.baseline_to_antnums(baseline, self.Nants_telescope)
github RadioAstronomySoftwareGroup / pyuvsim / scripts / file_series_from_config.py View on Github external
def set_other_required_params(input_uv, nonzero_uvw=False):
    input_uv.Nblts = input_uv.Nbls * input_uv.Ntimes
    enu = uvutils.ENU_from_ECEF((input_uv.antenna_positions + input_uv.telescope_location).T, *input_uv.telescope_location_lat_lon_alt).T
    uvws = []
    ant_1_arr = []
    ant_2_arr = []
    for i in range(input_uv.Nants_data):
        for j in range(i,input_uv.Nants_data):
            uvws.append(enu[j,:] - enu[i,:])
            ant_2_arr.append(i)
            ant_1_arr.append(j)
    uvws = np.array(uvws)
    if nonzero_uvw:
        inds = uvws == 0.0
        uvws[inds] = np.finfo(float).eps/2.    # set to less than machine precision, but nonzero
        print np.finfo(float).eps/2.
    input_uv.ant_1_array = np.tile(ant_1_arr, input_uv.Ntimes).T
    input_uv.ant_2_array = np.tile(ant_2_arr, input_uv.Ntimes).T
    input_uv.uvw_array = np.tile(uvws.T, input_uv.Ntimes).T
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / uvflag / uvflag.py View on Github external
Returns
        -------
        ant_pairs_nums : list of tuples of int or None
            List of tuples containing the parsed pairs of antenna numbers, or
            None if ant_str is 'all' or a pseudo-Stokes polarizations.
        polarizations : list of int or None
            List of desired polarizations or None if ant_str does not contain a
            polarization specification.

        """
        if self.type != "baseline":
            raise ValueError(
                "UVFlag objects can only call 'parse_ants' function "
                "if type is 'baseline'."
            )
        return uvutils.parse_ants(
            self,
            ant_str=ant_str,
            print_toggle=print_toggle,
            x_orientation=self.x_orientation,
        )