Example #1
0
def blank_uvcal_from_uvdata(uvdata):
    """initialize UVCal object with same times, antennas, and frequencies as uvdata.

    Parameters
    ----------
    uvdata: UVData object
        UVData object that you wish to generate a blanck UVCal object from.

    Returns
    -------
    uvcal: UVCal object
        UVCal object with all flags set to False
        and all gains set to unity with same antennas, freqs, jones, and times
        as uvdata.
    """
    uvcal = UVCal()
    uvcal.Nfreqs = uvdata.Nfreqs
    uvcal.Njones = uvdata.Npols
    uvcal.Ntimes = uvdata.Ntimes
    uvcal.Nspws = uvdata.Nspws
    uvcal.history = ""
    uvcal.Nspws = uvdata.Nspws
    uvcal.telescope_name = uvdata.telescope_name
    uvcal.telescope_location = uvdata.telescope_location
    uvcal.Nants_data = uvdata.Nants_data
    uvcal.Nants_telescope = uvdata.Nants_telescope
    uvcal.ant_array = np.asarray(list(set(uvdata.ant_1_array).union(set(uvdata.ant_2_array))))
    uvcal.antenna_names = uvdata.antenna_names
    uvcal.antenna_numbers = uvdata.antenna_numbers
    uvcal.antenna_positions = uvdata.antenna_positions
    uvcal.spw_array = uvdata.spw_array
    uvcal.freq_array = uvdata.freq_array
    uvcal.jones_array = uvdata.polarization_array
    uvcal.time_array = np.unique(uvdata.time_array)
    uvcal.integration_time = np.mean(uvdata.integration_time)
    uvcal.lst_array = np.unique(uvdata.lst_array)
    uvcal.gain_convention = "divide"  # always use divide for this package.
    uvcal.flag_array = np.zeros(
        (uvcal.Nants_data, uvcal.Nspws, uvcal.Nfreqs, uvcal.Ntimes, uvcal.Njones),
        dtype=np.bool,
    )
    uvcal.quality_array = np.zeros_like(uvcal.flag_array, dtype=np.float64)
    uvcal.x_orientation = uvdata.x_orientation
    uvcal.gain_array = np.ones_like(uvcal.flag_array, dtype=np.complex128)
    uvcal.cal_style = "redundant"
    uvcal.cal_type = "gain"
    uvcal.time_range = (
        uvcal.time_array.min() - uvcal.integration_time / 2.0,
        uvcal.time_array.max() + uvcal.integration_time / 2.0,
    )
    uvcal.channel_width = np.median(np.diff(uvcal.freq_array))

    return uvcal
Example #2
0
 def uvcal_from_data(self):
     """
     Generate an empty uvcal object from visibility parameters
     """
     uvc = UVCal()
     uvc.Njones = self.measured_vis.Npols
     uvc.Nfreqs = self.measured_vis.Nfreqs
     uvc.Ntimes = self.measured_vis.Ntimes
     uvc.Nspws = self.measured_vis.Nspws
     uvc.time_range = (self.measured_vis.time_array.min(),
                       self.measured_vis.time_array.max())
     uvc.telescope_name = self.measured_vis.telescope_name
     uvc.Nants_data = self.measured_vis.Nants_data
     uvc.Nants_telescope = self.measured_vis.Nants_telescope
     uvc.ant_array = np.unique(self.measured_vis.ant_1_array)
     uvc.antenna_names = self.measured_vis.antenna_names
     uvc.antenna_numbers = self.measured_vis.antenna_numbers
     uvc.freq_array = self.measured_vis.freq_array
     uvc.channel_width = self.measured_vis.channel_width
     uvc.jones_array = self.measured_vis.polarization_array
     uvc.time_array = np.unique(self.measured_vis.time_array)
     uvc.integration_time = self.measured_vis.integration_time
     uvc.x_orientation = 'east'  #always
     uvc.cal_type = 'gain'
     uvc.quality_array = np.zeros(
         (self.measured_vis.Nants_data, 1, self.measured_vis.Nfreqs,
          self.measured_vis.Ntimes, self.measured_vis.Npols))
     uvc.git_origin_cal='calibrated with stefcal_uvdata version %s with run id %s'\
                         %(self.meta_params.stefcal_version_str,self.meta_params.id)
     uvc.gain_array = np.ones(
         (self.meta_params.Nants_data, 1, self.model_vis.Nfreqs,
          self.model_vis.Ntimes, self.model_vis.Npols),
         dtype=complex)
     uvc.flag_array = np.empty(
         (self.meta_params.Nants_data, 1, self.model_vis.Nfreqs,
          self.model_vis.Ntimes, self.model_vis.Npols),
         dtype=bool)
     uvc.flag_array[:] = False
     return uvc
Example #3
0
uvc.cal_style = 'redundant'
uvc.cal_type = 'gain'
uvc.gain_convention = 'multiply'

command_given = sys.argv[1:]
command_given = ["'" + x + "'" if ' ' in x else x for x in command_given]
command_given = ' '.join(command_given)
script_path = os.path.dirname(os.path.abspath(__file__))
git_hash = sub.check_output(['git', '-C', script_path, 'rev-parse',
                             'HEAD']).strip().decode('UTF-8')
uvc.history = 'Created using mkgains.py\nCommand run: mkgains.py %s\nmkgains.py Git Hash: %s' % (
    command_given, git_hash)

uvc.Njones = uvd.Npols
uvc.jones_array = uvd.polarization_array
uvc.ant_array = np.arange(uvc.Nants_data)
uvc.time_range = [
    uvc.time_array[0] - (uvc.integration_time / 172800.),
    uvc.time_array[-1] + (uvc.integration_time / 172800.)
]
uvc.quality_array = np.zeros(
    (uvc.Nants_data, uvc.Nspws, uvc.Nfreqs, uvc.Ntimes, uvc.Njones),
    dtype='float64')
uvc.flag_array = np.zeros(
    (uvc.Nants_data, uvc.Nspws, uvc.Nfreqs, uvc.Ntimes, uvc.Njones),
    dtype='bool')
uvc.time_array = np.unique(uvd.time_array)
if uvc.x_orientation == None:
    uvc.x_orientation = 'East'

# Create random gains
#
# Pointing integration time
#
cal.integration_time = 1800.
#
cal.gain_convention = 'divide'  # Use this operation to apply gain solution.
cal.x_orientation = 'east'  # orientation of 1st jones parameter.
#
# JD's this can applied to. Below is Season 1
#
cal.time_range = [2456528., 2456626.]
#
cal.telescope_name = 'MWA'
cal.Nants_data = Nants_data
cal.Nants_telescope = Nants_data  # have solutions for all antennas in array.
cal.ant_array = ant_array
cal.antenna_names = antenna_names
cal.antenna_numbers = ant_array
cal.flag_array = flags
cal.gain_array = gains
cal.quality_array = chisq
#
# Put your name in as creator
#
cal.observer = '<YOUR NAME HERE>'
#
# Put in the git url of the code that generated the cals
#
cal.git_origin_cal = 'https://github.com/EoRImaging/FHD'
#
# And if you know the git hash, put that in as well