Ejemplo n.º 1
0
    def test_gridding(self):
        """Test building a image from a visibility data set."""

        for filename, type in zip((idiFile, idiAltFile, uvFile),
                                  ('FITS-IDI', 'Alt. FITS-IDI', 'UVFITS')):
            with self.subTest(filetype=type):
                # Open the file
                idi = utils.CorrelatedData(filename)

                # Build the image
                ds = idi.get_data_set(1)
                junk = utils.build_gridded_image(ds, verbose=False)

                # Error checking
                self.assertRaises(RuntimeError,
                                  utils.build_gridded_image,
                                  ds,
                                  pol='XY')

                #
                # VisibilityData test
                #

                ds2 = VisibilityData()
                ds2.append(ds)
                junk = utils.build_gridded_image(ds, verbose=False)

                idi.close()
Ejemplo n.º 2
0
    def __init__(self, ref_time=0.0, verbose=False):
        """
        Initialize a new virtual writer object using a reference time given in
        seconds since the UNIX 1970 ephem, a python datetime object, or a
        string in the format of 'YYYY-MM-DDTHH:MM:SS'.
        """

        WriterBase.__init__(self, '', ref_time=ref_time, verbose=verbose)
        self.visibility_data = VisibilityData()
Ejemplo n.º 3
0
    def test_add_noise(self):
        """Test that we can add baseline noise to a data dictionary without
        error"""

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Add in the noise
        na = vis.add_baseline_noise(out, 15e3, 0.061)

        #
        # Single-channel test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.array([
            30e6,
        ])
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Add in the noise
        na = vis.add_baseline_noise(out, 15e3, 0.061, bandwidth=1e6)

        #
        # VisibilityData test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)
        out2 = VisibilityData()
        out2.append(out)

        # Add in the noise
        na2 = vis.add_baseline_noise(out2, 15e3, 0.061)
Ejemplo n.º 4
0
    def test_shift_data(self):
        """Test that we can shift the uvw coordinates of a data dictionary 
        without error"""

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Shift
        sft = vis.shift_data(out, aa)

        #
        # Single-channel test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.array([
            30e6,
        ])
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Shift
        sft = vis.shift_data(out, aa)

        #
        # VisibilityData test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)
        out2 = VisibilityData()
        out2.append(out)

        # Shift
        sft2 = vis.shift_data(out2, aa)
Ejemplo n.º 5
0
    def get_data_set(self,
                     sets,
                     include_auto=False,
                     sort=True,
                     min_uv=0,
                     max_uv=numpy.inf):
        """
        Return a :class:`lsl.imaging.data.VisibilityDataSet` or 
        :class:`lsl.imaging.data.VisibilityData` object for all 
        baselines for a given set of observations for the specified data set.  
        By default this excludes the autocorrelations.  To include 
        autocorrelations set the value of 'include_auto' to True.  Setting the
        'sort' keyword to False will disable the baseline sorting.  Optionally,
        baselines with lengths between min_uv and max_uv can only be returned.

        .. note::
            min_uv and max_uv should be specified in lambda
        """

        dataSets = VisibilityData()
        try:
            len(sets)
        except TypeError:
            sets = range(sets, sets + 1)
        for set in sets:
            dataSets.append(self.visibility_data[set - 1])

        # Sort
        if sort:
            dataSets.sort()

        # Prune
        if not include_auto and min_uv == 0:
            min_uv = 1e-3
        if min_uv != 0 or max_uv != numpy.inf:
            dataSets = dataSets.get_uv_range(min_uv=min_uv, max_uv=max_uv)

        # Prune a different way
        if len(dataSets) == 1:
            dataSets = dataSets.pop()

        # Return
        return dataSets
Ejemplo n.º 6
0
def build_sim_data(aa,
                   srcs,
                   pols=['xx', 'yy', 'xy', 'yx'],
                   jd=None,
                   chan=None,
                   phase_center='z',
                   baselines=None,
                   mask=None,
                   flat_response=False,
                   resolve_src=False,
                   verbose=False):
    """
    Given an AIPY AntennaArray object and a dictionary of sources from 
    aipy.src.get_catalog, returned a :class:`lsl.imaging.data.VisibilityDataSet` 
    object of simulated data taken at zenith.  Optinally, the data can be 
    masked using some referenced (observed) data set or only a specific sub-set 
    of baselines.
    
    .. versionchanged:: 1.0.1
        * Added a 'flat_response' keyword to make it easy to toggle on and off
          the spectral and spatial response of the array for the simulation
        * Added a 'resolve_src' keyword to turn on source resolution effects
        
    ..versionchanged:: 0.4.0
        Added the 'pols' keyword to only compute certain polarization components
    """

    # Update the JD if necessary
    if jd is None:
        jd = [aa.get_jultime()]
    else:
        try:
            len(jd)
        except TypeError:
            jd = [jd]

    # Build up output dictionary
    freq = aa.get_afreqs() * 1e9
    if len(freq.shape) == 2:
        freq = freq[0, :]
    UVData = VisibilityData()

    # Loop over Julian days to fill in the simulated data set
    jdCounter = 1
    for juldate in jd:
        oBlk = __build_sim_data(aa,
                                srcs,
                                pols=pols,
                                jd=juldate,
                                chan=chan,
                                phase_center=phase_center,
                                baselines=baselines,
                                mask=mask,
                                verbose=verbose,
                                count=jdCounter,
                                max=len(jd),
                                flat_response=flat_response,
                                resolve_src=resolve_src)
        jdCounter = jdCounter + 1
        UVData.append(oBlk)

    # Trim
    if len(UVData) == 1:
        UVData = UVData.pop()

    return UVData
Ejemplo n.º 7
0
    def test_scale_data(self):
        """Test that we can scale a data dictionary without error"""

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Scale
        amp = vis.scale_data(out,
                             numpy.ones(len(antennas)) * 2,
                             numpy.zeros(len(antennas)))
        # Delay
        phs = vis.scale_data(out, numpy.ones(len(antennas)),
                             numpy.ones(len(antennas)))

        #
        # Single-channel test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.array([
            30e6,
        ])
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)

        # Scale
        amp = vis.scale_data(out,
                             numpy.ones(len(antennas)) * 2,
                             numpy.zeros(len(antennas)))
        # Delay
        phs = vis.scale_data(out, numpy.ones(len(antennas)),
                             numpy.ones(len(antennas)))

        #
        # VisibilityData test
        #

        # Setup
        lwa1 = lwa_common.lwa1
        antennas = lwa1.antennas[0:20]
        freqs = numpy.arange(30e6, 50e6, 1e6)
        aa = vis.build_sim_array(lwa1, antennas, freqs)

        # Build the data dictionary
        out = vis.build_sim_data(aa, vis.SOURCES)
        out2 = VisibilityData(out)

        # Scale
        amp2 = vis.scale_data(out2,
                              numpy.ones(len(antennas)) * 2,
                              numpy.zeros(len(antennas)))
        # Delay
        phs2 = vis.scale_data(out2, numpy.ones(len(antennas)),
                              numpy.ones(len(antennas)))