示例#1
0
    def setUpClass(cls):
        # Load data from a JSON file
        np.seterr(all='raise')
        fname = 'test_data/test_data.json'
        logger.info("Getting Data from file: {}".format(fname))
        with open(fname, 'r') as json_file:
            calib_info = json.load(json_file)

        info = calib_info['info']
        ant_pos = calib_info['ant_pos']
        config = settings.from_api_json(info['info'], ant_pos)

        flag_list = []

        gains_json = calib_info['gains']
        gains = np.asarray(gains_json['gain'])
        phase_offsets = np.asarray(gains_json['phase_offset'])
        config = settings.from_api_json(info['info'], ant_pos)

        measurements = []
        for d in calib_info['data']:
            vis_json, source_json = d
            cv, timestamp = api_imaging.vis_calibrated(vis_json, config, gains,
                                                       phase_offsets,
                                                       flag_list)
            src_list = elaz.from_json(source_json, 0.0)

        cls.disko = DiSkO.from_cal_vis(cv)
        cls.nside = 16
        cls.sphere = HealpixSphere(cls.nside)
        cls.to = TelescopeOperator(cls.disko, cls.sphere)
示例#2
0
    def setUpClass(cls):
        # Load data from a JSON file
        fname = 'test_data/test_data.json'
        logger.info("Getting Data from file: {}".format(fname))
        with open(fname, 'r') as json_file:
            calib_info = json.load(json_file)

        info = calib_info['info']
        cls.ant_pos = np.array(calib_info['ant_pos'])
        config = settings.from_api_json(info['info'], cls.ant_pos)

        flag_list = []

        gains_json = calib_info['gains']
        gains = np.asarray(gains_json['gain'])
        phase_offsets = np.asarray(gains_json['phase_offset'])
        #config = settings.from_api_json(info['info'], cls.ant_pos)

        measurements = []
        for d in calib_info['data']:
            vis_json, source_json = d
            cv, _timestamp = api_imaging.vis_calibrated(
                vis_json, config, gains, phase_offsets, flag_list)

        cls.disko = DiSkO.from_cal_vis(cv)
        cls.nside = 16
        cls.sphere = HealpixSphere(cls.nside)
        res_deg = 4.0
        cls.subsphere = HealpixSubSphere.from_resolution(resolution=res_deg *
                                                         60.0,
                                                         theta=np.radians(0.0),
                                                         phi=0.0,
                                                         radius=np.radians(89))

        cls.adaptive_sphere = AdaptiveMeshSphere.from_resolution(
            res_arcmin=20,
            res_arcmax=res_deg * 60,
            theta=np.radians(0.0),
            phi=0.0,
            radius=np.radians(10))

        cls.gamma = cls.disko.make_gamma(cls.sphere)
        cls.subgamma = cls.disko.make_gamma(cls.subsphere)
示例#3
0
    def test_uv_equal(self):
        shutil.rmtree(TEST_MS, ignore_errors=True)
        ms_from_json(TEST_MS, self.json_data, pol2=False)
        u_arr, v_arr, w_arr, frequency, cv_vis, hdr, timestamp = disko.read_ms(
            TEST_MS, num_vis=276, res_arcmin=120)
        logger.info("U shape: {}".format(u_arr.shape))

        info = self.json_data['info']
        ant_pos = self.json_data['ant_pos']
        config = settings.from_api_json(info['info'], ant_pos)

        gains_json = self.json_data['gains']
        gains = np.asarray(gains_json['gain'])
        phase_offsets = np.asarray(gains_json['phase_offset'])

        cal_vis, timestamp = api_imaging.vis_calibrated(
            self.json_data['data'][0][0], config, gains, phase_offsets, [])
        c = cal_vis.get_config()
        ant_p = np.asarray(c.get_antenna_positions())

        # We need to get the vis array to be correct for the full set of u,v,w points (baselines),
        # including the -u,-v, -w points.

        baselines, u_arr2, v_arr2, w_arr2 = disko.get_all_uvw(ant_p)

        self.assertAlmostEqual(np.max(u_arr, axis=0), np.max(u_arr2, axis=0))

        logger.info("U2 shape {}".format(u_arr2.shape))

        for i in range(u_arr.shape[0]):
            a = u_arr[i]
            b = u_arr2[i]
            self.assertAlmostEqual(a, b)

            a = v_arr[i]
            b = v_arr2[i]
            self.assertAlmostEqual(a, b)
示例#4
0
def ms_from_json(ms_name, json_data, pol2):
    info = json_data['info']
    ant_pos = json_data['ant_pos']
    config = settings.from_api_json(info['info'], ant_pos)
    gains = json_data['gains']['gain']
    phases = json_data['gains']['phase_offset']

    for d in json_data['data']: # TODO deal with multiple observations in the JSON file later.
        vis_json, source_json = d
        cal_vis, timestamp = api_imaging.vis_calibrated(vis_json, config, gains, phases, [])
        src_list = source_json

    if pol2:
        pol_feeds = [ 'RR', 'LL' ]
    else:
        pol_feeds = [ 'RR' ]

    vis_data, baselines = cal_vis.get_all_visibility()
    vis_array = np.array(vis_data, dtype=np.complex64)

    ms_create(ms_table_name=ms_name, info = info['info'],
              ant_pos = ant_pos,
              vis_array = vis_array, baselines=baselines, timestamps=timestamp,
              pol_feeds=pol_feeds, sources=src_list)
示例#5
0
config = api_handler.get_config(api)
mode = api.get('mode/current')

if mode['mode'] != 'vis':
    print("ERROR: Telescope must be in visibility mode to allow imaging. Set via the web API")

gains = api.get('calibration/gain')
visibility_data = api.get('imaging/vis')


'''
    STEP 2: Apply Calibration to the visiblilties
'''
print("Apply Calibration Data")
cv, timestamp = api_imaging.vis_calibrated(visibility_data, config, gains['gain'], gains['phase_offset'], flag_list=[])


'''
    STEP 3: Perform the imaging
'''
print("Generate Dirty Image")
n_bin = 2**9  # Image resolution
cal_ift, cal_extent, n_fft, bin_width = api_imaging.image_from_calibrated_vis(cv, nw=n_bin/4, num_bin=n_bin)

# Take the absolute value 
img = np.abs(cal_ift)

# Scale it to multiples of the image standard deviation
sd = np.std(img)
scaled_image = img/sd
示例#6
0
            'info': info,
            'ant_pos': ant_pos,
            'gains': gains_json,
            'data': [[vis_json, src_json]]
        }

    info = json_data['info']
    ant_pos = json_data['ant_pos']
    config = settings.from_api_json(info['info'], ant_pos)
    gains = json_data['gains']['gain']
    phases = json_data['gains']['phase_offset']

    for d in json_data[
            'data']:  # TODO deal with multiple observations in the JSON file later.
        vis_json, source_json = d
        cv, timestamp = api_imaging.vis_calibrated(vis_json, config, gains,
                                                   phases, [])
        src_list = source_json

    # FIXME. These appear to be weird polarization codes (or ID's). WHY oh WHY are they called corr?
    # We use RR antennas, so this should be either RR or I?. I'm using FITS code 1 for this 'I'
    corr_types = [[MS_STOKES_ENUMS['I']]]

    ms_create(ms_table_name=ARGS.ms,
              info=info['info'],
              ant_pos=ant_pos,
              cal_vis=cv,
              timestamps=timestamp,
              corr_types=corr_types,
              sources=src_list)
示例#7
0
config = api_handler.get_config(api)
mode = api.get('mode/current')

if mode['mode'] != 'vis':
    print("ERROR: Telescope must be in visibility mode to allow imaging. Set via the web API")

gains = api.get('calibration/gain')
visibility_data = api.get('imaging/vis')


'''
    STEP 2: Apply Calibration to the visiblilties
'''
print("Apply Calibration Data")
cv, timestamp = api_imaging.vis_calibrated(visibility_data, config, gains['gain'], gains['phase_offset'], flag_list=[])


'''
    STEP 3: Perform the imaging
'''
print("Generate Dirty Image")
n_bin = 2**9  # Image resolution
cal_ift, cal_extent, n_fft, bin_width = api_imaging.image_from_calibrated_vis(cv, nw=n_bin/4, num_bin=n_bin)

# Take the absolute value 
img = np.abs(cal_ift)

# Scale it to multiples of the image standard deviation
sd = np.std(img)
scaled_image = img/sd