In [1]:
import pprint, copy
import numpy as NP
import numpy.ma as MA
import matplotlib.pyplot as PLT
from matplotlib.patches import Circle, Wedge, Polygon
import yaml, argparse, warnings
import astropy.units as U
import astropy.cosmology as cosmology
import astropy.constants as FCNST
import astropy.cosmology as cosmology
import scipy.signal as SPS
import astroutils, prisim
from prisim import interferometry as RI
from prisim import bispectrum_phase as BSP
from prisim import delay_spectrum as DS

from IPython.core.debugger import set_trace
%matplotlib inline

In [2]:
print('AstroUtils git # {0}'.format(astroutils.__githash__))
print('PRISim git # {0}'.format(prisim.__githash__))


AstroUtils git # 31a5d333170ef8a8e79fba3f5591a163a17e9416
PRISim git # 1e4267d2e665eb5e2fed30f7b5c374d608298c62

Set up Cosmological parameters


In [3]:
cosmoPlanck15 = cosmology.Planck15 # Planck 2015 cosmology
cosmo100 = cosmoPlanck15.clone(name='Modified Planck 2015 cosmology with h=1.0', H0=100.0) # Modified Planck 2015 cosmology with h=1.0, H= 100 km/s/Mpc

Set up input/output directories


In [4]:
bspdir = '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/bispectrum_phase/'
figdir = bspdir + 'figures/'

In [5]:
freq_window_centers = NP.asarray([150e6])
freq_window_bw = NP.asarray([42e6])
freq_window_shape = 'bhw'
freq_window_fftpow = 2
pad = 7.0

print('freq window centers = ', freq_window_centers)
print('freq window BW eff = ', freq_window_bw)
print('freq window shape = '+freq_window_shape)
print('freq window fftpow = {0:.1f}'.format(freq_window_fftpow))
print('pad = {0:.1f}'.format(pad))


('freq window centers = ', array([1.5e+08]))
('freq window BW eff = ', array([42000000.]))
freq window shape = bhw
freq window fftpow = 2.0
pad = 7.0

Set up cases with Foregrounds and HI


In [6]:
case_with_FG_HI = {'1ps_FG_no_spindex_HI_colocated': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_HI_cosine_colocated/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                      'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_HI_cosine_colocated_achromatic_AiryBeam_noiseless.hdf5'}, 
                   '1ps_FG_spindex_HI_colocated': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_HI_cosine_colocated/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                   'bspfile_sfx': '_HERA19_1ps_FG_spindex_HI_cosine_colocated_achromatic_AiryBeam_noiseless.hdf5'},   
                   '1ps_FG_no_spindex_HI_displaced': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_HI_cosine_displaced/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                      'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_HI_cosine_displaced_achromatic_AiryBeam_noiseless.hdf5'},
                   '1ps_FG_spindex_HI_displaced': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_HI_cosine_displaced/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                   'bspfile_sfx': '_HERA19_1ps_FG_spindex_HI_cosine_displaced_achromatic_AiryBeam_noiseless.hdf5'},
                   'GLEAM_1ps_HI': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_1ps_HI_cosine/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                    'bspfile_sfx': '_HERA19_GLEAM_FG_FoV-30_HI_cosine_on_zenith_achromatic_AiryBeam_noiseless.hdf5'},
                   'GLEAM_HI_21cmfast': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_HI_21cmfast_FaintGalaxies_fiducial_FoV-30/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                         'bspfile_sfx': '_HERA19_GLEAM_FG_FoV-30_HI_21cmfast_FaintGalaxies_fiducial_achromatic_AiryBeam_noiseless.hdf5'},
                   '1ps_FG_no_spindex_HI_21cmfast': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_on_zenith_toy_HI_21cmfast_FaintGalaxies_fiducial/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                     'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_on_zenith_HI_21cmfast_FaintGalaxies_fiducial_achromatic_AiryBeam_noiseless.hdf5'},
                   '1ps_FG_spindex_HI_21cmfast': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_on_zenith_toy_HI_21cmfast_FaintGalaxies_fiducial/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                  'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_on_zenith_HI_21cmfast_FaintGalaxies_fiducial_achromatic_AiryBeam_noiseless.hdf5'}
                  }

In [7]:
key_mapping_FG_HI = {'1ps_FG_no_spindex_HI_colocated': {'FG': '1ps_FG_no_spindex_on_zenith', 
                                                        'HI': '1ps_HI_cosine'}, 
                     '1ps_FG_spindex_HI_colocated': {'FG': '1ps_FG_spindex_on_zenith', 
                                                     'HI': '1ps_HI_cosine'}, 
                     '1ps_FG_no_spindex_HI_displaced': {'FG': '1ps_FG_no_spindex_off_zenith', 
                                                        'HI': '1ps_HI_cosine'}, 
                     '1ps_FG_spindex_HI_displaced': {'FG': '1ps_FG_spindex_off_zenith', 
                                                     'HI': '1ps_HI_cosine'},
                     'GLEAM_1ps_HI': {'FG': 'GLEAM', 
                                      'HI': '1ps_HI_cosine'},
                     'GLEAM_HI_21cmfast': {'FG': 'GLEAM', 
                                           'HI': 'HI_21cmfast_fiducial'},
                     '1ps_FG_no_spindex_HI_21cmfast': {'FG': '1ps_FG_no_spindex_on_zenith', 
                                                       'HI': 'HI_21cmfast_fiducial'},
                     '1ps_FG_spindex_HI_21cmfast': {'FG': '1ps_FG_spindex_on_zenith', 
                                                    'HI': 'HI_21cmfast_fiducial'}
                    }

Set up cases with Foregrounds only


In [8]:
case_with_FG = {'1ps_FG_no_spindex_on_zenith': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_on_zenith_achromatic_AiryBeam_noiseless.hdf5'},
                '1ps_FG_no_spindex_off_zenith': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex/off_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                                 'bspfile_sfx': '_HERA19_1ps_FG_no_spindex_off_zenith_achromatic_AiryBeam_noiseless.hdf5'},
                '1ps_FG_spindex_on_zenith': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                             'bspfile_sfx': '_HERA19_1ps_FG_spindex_on_zenith_achromatic_AiryBeam_noiseless.hdf5'},
                '1ps_FG_spindex_off_zenith': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex/off_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                                              'bspfile_sfx': '_HERA19_1ps_FG_spindex_off_zenith_achromatic_AiryBeam_noiseless.hdf5'},
                'GLEAM': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_FoV-30/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/', 
                          'bspfile_sfx': '_HERA19_GLEAM_FG_FoV-30_achromatic_AiryBeam_noiseless.hdf5'}
               }

Set up cases with HI only


In [9]:
case_with_HI = {'1ps_HI_cosine': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_HI_cosine/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/'},
                'HI_21cmfast_fiducial': {'visdir': '/lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_HI_21cmfast_FaintGalaxies_fiducial/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/'}
               }

Load visibilities of cases with Foregorunds only


In [10]:
for case_id in case_with_FG:
    print('\nLoading visibilities for case: {0}\n\t\t\t from: {1}'.format(case_id, case_with_FG[case_id]['visdir']))
    case_with_FG[case_id]['vis'] = RI.InterferometerArray(None, None, None, init_file=case_with_FG[case_id]['visdir']+'simvis')
#     # Perform minor astrometric corrections when the point source foreground is supposed to be at zenith but is not
#     if 'on_zenith' in case_id:
#         print('\tPerforming minor astrometric corrections...')
#         case_with_FG[case_id]['vis'].skyvis_freq[:,:,0].real = NP.abs(case_with_FG[case_id]['vis'].skyvis_freq[:,:,0])
#         case_with_FG[case_id]['vis'].skyvis_freq[:,:,0].imag = NP.zeros_like(case_with_FG[case_id]['vis'].skyvis_freq[:,:,0].real)
#         case_with_FG[case_id]['vis'].vis_freq = case_with_FG[case_id]['vis'].skyvis_freq + case_with_FG[case_id]['vis'].vis_noise_freq
    print('Loaded!\n----------')


Loading visibilities for case: 1ps_FG_no_spindex_off_zenith
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex/off_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_spindex_off_zenith
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex/off_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_no_spindex_on_zenith
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_spindex_on_zenith
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: GLEAM
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_FoV-30/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Load visibilities of cases with HI only


In [11]:
for case_id in case_with_HI:
    print('\nLoading visibilities for case: {0}\n\t\t\t from: {1}'.format(case_id, case_with_HI[case_id]['visdir']))
    case_with_HI[case_id]['vis'] = RI.InterferometerArray(None, None, None, init_file=case_with_HI[case_id]['visdir']+'simvis')
#     # Perform minor astrometric corrections when the point source foreground is supposed to be at zenith but is not
#     if '1ps' in case_id:
#         print('\tPerforming minor astrometric corrections...')
#         case_with_HI[case_id]['vis'].skyvis_freq[:,:,0].real = NP.abs(case_with_HI[case_id]['vis'].skyvis_freq[:,:,0])
#         case_with_HI[case_id]['vis'].skyvis_freq[:,:,0].imag = NP.zeros_like(case_with_HI[case_id]['vis'].skyvis_freq[:,:,0].real)
#         case_with_HI[case_id]['vis'].vis_freq = case_with_HI[case_id]['vis'].skyvis_freq + case_with_HI[case_id]['vis'].vis_noise_freq
    print('Loaded!\n----------')


Loading visibilities for case: 1ps_HI_cosine
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_HI_cosine/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: HI_21cmfast_fiducial
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_HI_21cmfast_FaintGalaxies_fiducial/on_zenith_HERA19/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Load visibilities of cases with Foregorunds and HI


In [12]:
for case_id in case_with_FG_HI:
    print('\nLoading visibilities for case: {0}\n\t\t\t from: {1}'.format(case_id, case_with_FG_HI[case_id]['visdir']))
    case_with_FG_HI[case_id]['vis'] = RI.InterferometerArray(None, None, None, init_file=case_with_FG_HI[case_id]['visdir']+'simvis')
    if ('on_zenith' in key_mapping_FG_HI[case_id]['FG']) or ('1ps' in key_mapping_FG_HI[case_id]['HI']):
        case_with_FG_HI[case_id]['vis'].skyvis_freq = case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq + case_with_HI[key_mapping_FG_HI[case_id]['HI']]['vis'].skyvis_freq
        case_with_FG_HI[case_id]['vis'].vis_freq = case_with_FG_HI[case_id]['vis'].skyvis_freq + case_with_FG_HI[case_id]['vis'].vis_noise_freq
    print('Loaded!\n----------')


Loading visibilities for case: 1ps_FG_no_spindex_HI_colocated
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_HI_cosine_colocated/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_spindex_HI_displaced
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_HI_cosine_displaced/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_spindex_HI_21cmfast
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_on_zenith_toy_HI_21cmfast_FaintGalaxies_fiducial/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_spindex_HI_colocated
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_spindex_HI_cosine_colocated/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: GLEAM_1ps_HI
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_1ps_HI_cosine/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_no_spindex_HI_21cmfast
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_on_zenith_toy_HI_21cmfast_FaintGalaxies_fiducial/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: 1ps_FG_no_spindex_HI_displaced
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/1ps_FG_no_spindex_HI_cosine_displaced/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

Loading visibilities for case: GLEAM_HI_21cmfast
			 from: /lustre/aoc/projects/hera/nthyagar/data/HERA/IDR2.1/ClosurePhase/models/visibilities/toy_GLEAM_HI_21cmfast_FaintGalaxies_fiducial_FoV-30/achromatic_AiryBeam_2x60.0sec_1024x97.7kHz/simdata/
Loaded!
----------

In [13]:
print(case_with_FG['1ps_FG_no_spindex_on_zenith']['vis'].skyvis_freq.shape)
print(case_with_FG['1ps_FG_no_spindex_on_zenith']['vis'].skyvis_freq[[0,1,2],:,0])
print(NP.abs(case_with_FG['1ps_FG_no_spindex_on_zenith']['vis'].skyvis_freq[[0,1,2],:,0].imag).max())

print(case_with_HI['1ps_HI_cosine']['vis'].skyvis_freq.shape)
print(case_with_HI['1ps_HI_cosine']['vis'].skyvis_freq[[0,1,2],:,0])
print(NP.abs(case_with_HI['1ps_HI_cosine']['vis'].skyvis_freq[[0,1,2],:,0].imag).max())


(30, 1024, 2)
[[99.99987385-0.14128888j 99.99987365-0.14142686j 99.99987346-0.14156484j
  ... 99.99957558-0.28216355j 99.99957519-0.28230153j
  99.9995748 -0.28243951j]
 [99.99993483-0.08812329j 99.99993476-0.08820935j 99.99993468-0.08829541j
  ... 99.9998188 -0.17598835j 99.99981865-0.17607441j
  99.9998185 -0.17616046j]
 [99.99995953-0.05316562j 99.9999595 -0.05321754j 99.99995947-0.05326946j
  ... 99.99991729-0.10617547j 99.99991724-0.10622739j
  99.99991718-0.10627931j]]
0.2824395061393335
(30, 1024, 2)
[[ 0.00999999-1.41288883e-05j  0.00817584-1.15628453e-05j
   0.00336889-4.76917573e-06j ... -0.00266712+7.52566191e-06j
   0.00336888-9.51045208e-06j  0.00817581-2.30918251e-05j]
 [ 0.00999999-8.81232950e-06j  0.00817584-7.21186273e-06j
   0.0033689 -2.97458280e-06j ... -0.00266712+4.69383376e-06j
   0.00336889-5.93176808e-06j  0.00817583-1.44026120e-05j]
 [ 0.01      -5.31656207e-06j  0.00817584-4.35098527e-06j
   0.0033689 -1.79459405e-06j ... -0.00266713+2.83183518e-06j
   0.0033689 -3.57869289e-06j  0.00817584-8.68923472e-06j]]
2.8112381179553323e-05

In [14]:
case_id = case_with_HI.keys()[0]

freqs = case_with_HI[case_id]['vis'].channels
antlocs = case_with_HI[case_id]['vis'].layout['positions']
antlabels = case_with_HI[case_id]['vis'].layout['labels']
baselines = case_with_HI[case_id]['vis'].baselines
baseline_labels = case_with_HI[case_id]['vis'].labels

print('Telescope Info:')
pprint.pprint(case_with_HI['1ps_HI_cosine']['vis'].telescope)
print('--------------')
print('Antenna Info:')
pprint.pprint(zip(antlabels, antlocs))
print('--------------')
print('Baseline info:')
pprint.pprint(zip(baseline_labels, baselines))


Telescope Info:
{'groundplane': None,
 'id': 'hera',
 'ocoords': 'altaz',
 'orientation': array([[ 90., 270.]]),
 'shape': 'dish',
 'size': 14.0}
--------------
Antenna Info:
[('0', array([-21.9      ,  12.6439709,   0.       ])),
 ('1', array([-7.3      , 12.6439709,  0.       ])),
 ('2', array([ 7.3      , 12.6439709,  0.       ])),
 ('3', array([21.9      , 12.6439709,  0.       ])),
 ('4', array([-21.9      , -12.6439709,   0.       ])),
 ('5', array([ -7.3      , -12.6439709,   0.       ])),
 ('6', array([  7.3      , -12.6439709,   0.       ])),
 ('7', array([ 21.9      , -12.6439709,   0.       ])),
 ('8', array([-14.6       ,  25.28794179,   0.        ])),
 ('9', array([ 0.        , 25.28794179,  0.        ])),
 ('10', array([14.6       , 25.28794179,  0.        ])),
 ('11', array([-14.6       , -25.28794179,   0.        ])),
 ('12', array([  0.        , -25.28794179,   0.        ])),
 ('13', array([ 14.6       , -25.28794179,   0.        ])),
 ('14', array([-2.92000000e+01, -3.41247498e-16,  0.00000000e+00])),
 ('15', array([-1.46000000e+01, -3.41247498e-16,  0.00000000e+00])),
 ('16', array([ 0.00000000e+00, -3.41247498e-16,  0.00000000e+00])),
 ('17', array([ 1.46000000e+01, -3.41247498e-16,  0.00000000e+00])),
 ('18', array([ 2.92000000e+01, -3.41247498e-16,  0.00000000e+00]))]
--------------
Baseline info:
[(('9', '8'), array([14.6,  0. ,  0. ])),
 (('5', '11'), array([ 7.3      , 12.6439709, -0.       ])),
 (('1', '8'), array([  7.3      , -12.6439709,  -0.       ])),
 (('9', '0'), array([21.9      , 12.6439709,  0.       ])),
 (('0', '4'), array([-0.        , 25.28794179, -0.        ])),
 (('16', '0'), array([ 21.9      , -12.6439709,   0.       ])),
 (('10', '8'), array([29.2,  0. ,  0. ])),
 (('16', '11'), array([14.6       , 25.28794179,  0.        ])),
 (('16', '8'), array([ 14.6       , -25.28794179,   0.        ])),
 (('1', '11'), array([ 7.3       , 37.93191269, -0.        ])),
 (('0', '11'), array([-7.3       , 37.93191269, -0.        ])),
 (('3', '8'), array([ 36.5      , -12.6439709,  -0.       ])),
 (('7', '11'), array([36.5      , 12.6439709, -0.       ])),
 (('2', '4'), array([29.2       , 25.28794179, -0.        ])),
 (('6', '0'), array([ 29.2       , -25.28794179,   0.        ])),
 (('2', '11'), array([21.9       , 37.93191269, -0.        ])),
 (('12', '0'), array([ 21.9       , -37.93191269,   0.        ])),
 (('3', '0'), array([43.8,  0. ,  0. ])),
 (('3', '4'), array([43.8       , 25.28794179, -0.        ])),
 (('8', '11'), array([-0.        , 50.57588358, -0.        ])),
 (('7', '0'), array([ 43.8       , -25.28794179,   0.        ])),
 (('3', '11'), array([36.5       , 37.93191269, -0.        ])),
 (('7', '8'), array([ 36.5       , -37.93191269,  -0.        ])),
 (('9', '11'), array([14.6       , 50.57588358, -0.        ])),
 (('8', '12'), array([-14.6       ,  50.57588358,  -0.        ])),
 (('3', '14'), array([51.1      , 12.6439709, -0.       ])),
 (('18', '0'), array([ 51.1      , -12.6439709,   0.       ])),
 (('18', '14'), array([58.4,  0. ,  0. ])),
 (('10', '11'), array([29.2       , 50.57588358, -0.        ])),
 (('13', '8'), array([ 29.2       , -50.57588358,   0.        ]))]

Plot: Annotated antenna positions


In [93]:
case_id = case_with_HI.keys()[0]

fig, ax = PLT.subplots(1, 1, figsize=(3.5,3.5))
ax.plot(antlocs[:,0], antlocs[:,1], ls='none', marker='o', mec='black', mfc='none', ms=16, color='black')

for antind,antlabel in enumerate(antlabels):
    ax.annotate(antlabel, (antlocs[antind,0], antlocs[antind,1]), xycoords='data', ha='center', va='center', color='black')
    
ax.set_xlim(NP.min(antlocs[:,0])-5, NP.max(antlocs[:,0])+5)
ax.set_ylim(NP.min(antlocs[:,1])-5, NP.max(antlocs[:,1])+5)
ax.set_aspect('equal')
ax.set_xlabel('E [m]', fontsize=11, weight='medium')
ax.set_ylabel('N [m]', fontsize=11, weight='medium')

fig.subplots_adjust(left=0.2, right=0.98, bottom=0.12, top=0.98)



In [94]:
case_id = case_with_HI.keys()[0]

fig, ax = PLT.subplots(1, 1, figsize=(3.5,3.5))

for antind,antlabel in enumerate(antlabels):
    ax.add_patch(Circle((antlocs[antind,0], antlocs[antind,1]), radius=0.5*case_with_HI[case_id]['vis'].telescope['size'], color='none', ec='black', lw=1))
    ax.annotate(antlabel, (antlocs[antind,0], antlocs[antind,1]), xycoords='data', ha='center', va='center', color='black')
    
ax.set_xlim(NP.min(antlocs[:,0])-0.75*case_with_HI[case_id]['vis'].telescope['size'], NP.max(antlocs[:,0])+0.75*case_with_HI[case_id]['vis'].telescope['size'])
ax.set_ylim(NP.min(antlocs[:,1])-0.75*case_with_HI[case_id]['vis'].telescope['size'], NP.max(antlocs[:,1])+0.75*case_with_HI[case_id]['vis'].telescope['size'])
ax.set_aspect('equal')
ax.set_xlabel('E [m]', fontsize=11, weight='medium')
ax.set_ylabel('N [m]', fontsize=11, weight='medium')

fig.subplots_adjust(left=0.2, right=0.98, bottom=0.12, top=0.98)

PLT.savefig(figdir+'HERA-19_antenna_layout.pdf', bbox_inches=0)


Compute closure phases of cases with Foregrounds and HI


In [15]:
cpinfo_case_with_FG_HI = {}
for case_id in case_with_FG_HI:
    print('Computing closure phases on unique triads for {0}...'.format(case_id))
    cpinfo_case_with_FG_HI[case_id] = case_with_FG_HI[case_id]['vis'].getClosurePhase(unique=True)


Computing closure phases on unique triads for 1ps_FG_no_spindex_HI_colocated...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_spindex_HI_displaced...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_spindex_HI_21cmfast...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_spindex_HI_colocated...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for GLEAM_1ps_HI...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_no_spindex_HI_21cmfast...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_no_spindex_HI_displaced...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for GLEAM_HI_21cmfast...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00

Compute closure phases of cases with Foregrounds only


In [16]:
cpinfo_case_with_FG = {}
for case_id in case_with_FG:
    print('Computing closure phases on unique triads for {0}...'.format(case_id))
    cpinfo_case_with_FG[case_id] = case_with_FG[case_id]['vis'].getClosurePhase(unique=True)


Computing closure phases on unique triads for 1ps_FG_no_spindex_off_zenith...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_spindex_off_zenith...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_no_spindex_on_zenith...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for 1ps_FG_spindex_on_zenith...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for GLEAM...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00

Compute closure phases of cases with HI only


In [17]:
cpinfo_case_with_HI = {}
for case_id in case_with_HI:
    print('Computing closure phases on unique triads for {0}...'.format(case_id))
    cpinfo_case_with_HI[case_id] = case_with_HI[case_id]['vis'].getClosurePhase(unique=True)


Computing closure phases on unique triads for 1ps_HI_cosine...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00
Computing closure phases on unique triads for HI_21cmfast_fiducial...
100% |-----------------------------------------| 162/162 Triplets Time: 0:00:00

Predict values for closure phases


In [18]:
predicted_cpinfo_with_FG_HI = {}
for case_id in case_with_FG_HI:
    imag_ratio_triad = (cpinfo_case_with_HI[key_mapping_FG_HI[case_id]['HI']]['skyvis'] / cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['skyvis']).imag
    predicted_cpinfo_with_FG_HI[case_id] = {'imag_ratio_triad': imag_ratio_triad, 'sum_imag_ratio_triad': NP.sum(imag_ratio_triad, axis=1)}
    print('Predicted closure phases on unique triads for {0}...'.format(case_id))


Predicted closure phases on unique triads for 1ps_FG_no_spindex_HI_colocated...
Predicted closure phases on unique triads for 1ps_FG_spindex_HI_displaced...
Predicted closure phases on unique triads for 1ps_FG_spindex_HI_21cmfast...
Predicted closure phases on unique triads for 1ps_FG_spindex_HI_colocated...
Predicted closure phases on unique triads for GLEAM_1ps_HI...
Predicted closure phases on unique triads for 1ps_FG_no_spindex_HI_21cmfast...
Predicted closure phases on unique triads for 1ps_FG_no_spindex_HI_displaced...
Predicted closure phases on unique triads for GLEAM_HI_21cmfast...

In [19]:
print(imag_ratio_triad.shape)
print(NP.sum(imag_ratio_triad, axis=1).shape)
pprint.pprint(cpinfo_case_with_HI[key_mapping_FG_HI[case_id]['HI']]['antenna_triplets'])
pprint.pprint(cpinfo_case_with_HI[key_mapping_FG_HI[case_id]['HI']]['baseline_triplets'])


(162, 3, 1024, 2)
(162, 1024, 2)
[('0', '1', '2'),
 ('0', '1', '3'),
 ('0', '1', '4'),
 ('0', '1', '5'),
 ('0', '1', '6'),
 ('0', '1', '7'),
 ('0', '1', '8'),
 ('0', '1', '9'),
 ('0', '1', '10'),
 ('0', '1', '11'),
 ('0', '1', '12'),
 ('0', '1', '13'),
 ('0', '1', '16'),
 ('0', '1', '17'),
 ('0', '1', '18'),
 ('0', '2', '4'),
 ('0', '2', '5'),
 ('0', '2', '6'),
 ('0', '2', '7'),
 ('0', '2', '8'),
 ('0', '2', '9'),
 ('0', '2', '10'),
 ('0', '2', '11'),
 ('0', '2', '12'),
 ('0', '2', '13'),
 ('0', '2', '17'),
 ('0', '2', '18'),
 ('0', '3', '4'),
 ('0', '3', '5'),
 ('0', '3', '6'),
 ('0', '3', '7'),
 ('0', '3', '8'),
 ('0', '3', '9'),
 ('0', '3', '10'),
 ('0', '3', '11'),
 ('0', '3', '12'),
 ('0', '3', '13'),
 ('0', '3', '14'),
 ('0', '3', '18'),
 ('0', '4', '8'),
 ('0', '4', '9'),
 ('0', '4', '10'),
 ('0', '4', '11'),
 ('0', '4', '12'),
 ('0', '4', '13'),
 ('0', '4', '14'),
 ('0', '4', '16'),
 ('0', '4', '17'),
 ('0', '4', '18'),
 ('0', '5', '8'),
 ('0', '5', '9'),
 ('0', '5', '10'),
 ('0', '5', '12'),
 ('0', '5', '13'),
 ('0', '5', '14'),
 ('0', '5', '17'),
 ('0', '5', '18'),
 ('0', '6', '8'),
 ('0', '6', '9'),
 ('0', '6', '10'),
 ('0', '6', '13'),
 ('0', '6', '14'),
 ('0', '6', '15'),
 ('0', '6', '18'),
 ('0', '7', '8'),
 ('0', '7', '9'),
 ('0', '7', '10'),
 ('0', '7', '14'),
 ('0', '7', '15'),
 ('0', '7', '16'),
 ('0', '8', '11'),
 ('0', '8', '12'),
 ('0', '8', '13'),
 ('0', '8', '14'),
 ('0', '9', '11'),
 ('0', '9', '12'),
 ('0', '9', '13'),
 ('0', '9', '14'),
 ('0', '9', '15'),
 ('0', '10', '11'),
 ('0', '10', '12'),
 ('0', '10', '13'),
 ('0', '10', '14'),
 ('0', '10', '15'),
 ('0', '10', '16'),
 ('0', '11', '16'),
 ('0', '11', '17'),
 ('0', '11', '18'),
 ('0', '12', '17'),
 ('0', '12', '18'),
 ('0', '13', '18'),
 ('0', '14', '18'),
 ('1', '2', '4'),
 ('1', '2', '11'),
 ('1', '3', '4'),
 ('1', '3', '11'),
 ('1', '3', '14'),
 ('1', '4', '8'),
 ('1', '4', '9'),
 ('1', '4', '10'),
 ('1', '4', '18'),
 ('1', '8', '11'),
 ('1', '8', '12'),
 ('1', '8', '13'),
 ('1', '9', '11'),
 ('1', '10', '11'),
 ('1', '10', '14'),
 ('1', '11', '17'),
 ('1', '11', '18'),
 ('1', '14', '18'),
 ('2', '3', '4'),
 ('2', '3', '11'),
 ('2', '3', '14'),
 ('2', '4', '9'),
 ('2', '4', '10'),
 ('2', '4', '18'),
 ('2', '8', '11'),
 ('2', '8', '12'),
 ('2', '8', '13'),
 ('2', '9', '11'),
 ('2', '10', '11'),
 ('2', '11', '18'),
 ('2', '14', '18'),
 ('3', '4', '10'),
 ('3', '4', '14'),
 ('3', '8', '11'),
 ('3', '8', '12'),
 ('3', '8', '13'),
 ('3', '9', '11'),
 ('3', '10', '11'),
 ('3', '11', '14'),
 ('3', '12', '14'),
 ('3', '13', '14'),
 ('3', '14', '18'),
 ('8', '9', '11'),
 ('8', '9', '12'),
 ('8', '9', '13'),
 ('8', '10', '11'),
 ('8', '10', '12'),
 ('8', '10', '13'),
 ('8', '11', '14'),
 ('8', '11', '15'),
 ('8', '11', '17'),
 ('8', '11', '18'),
 ('8', '12', '14'),
 ('8', '12', '15'),
 ('8', '12', '18'),
 ('8', '13', '14'),
 ('8', '13', '15'),
 ('8', '13', '16'),
 ('8', '14', '18'),
 ('9', '10', '11'),
 ('9', '11', '14'),
 ('9', '11', '15'),
 ('9', '11', '18'),
 ('9', '14', '18'),
 ('10', '11', '14'),
 ('10', '11', '15'),
 ('10', '11', '16'),
 ('10', '14', '18'),
 ('14', '15', '18'),
 ('14', '16', '18')]
[array([[ 14.6,   0. ,   0. ],
       [ 14.6,   0. ,   0. ],
       [-29.2,  -0. ,  -0. ]]),
 array([[ 14.6,   0. ,   0. ],
       [ 29.2,   0. ,   0. ],
       [-43.8,  -0. ,  -0. ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [  0.        , -25.28794179,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [ 14.6       , -25.28794179,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [ 29.2       , -25.28794179,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [ -7.3      ,  12.6439709,   0.       ],
       [ -7.3      , -12.6439709,   0.       ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [  7.3      ,  12.6439709,  -0.       ],
       [-21.9      , -12.6439709,  -0.       ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [ 21.9      ,  12.6439709,   0.       ],
       [-36.5      , -12.6439709,   0.       ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [ -7.3       , -37.93191269,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [  7.3       , -37.93191269,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [ 21.9       , -37.93191269,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [  7.3      , -12.6439709,  -0.       ],
       [-21.9      ,  12.6439709,  -0.       ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [ 21.9      , -12.6439709,   0.       ],
       [-36.5      ,  12.6439709,   0.       ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [ 36.5      , -12.6439709,  -0.       ],
       [-51.1      ,  12.6439709,  -0.       ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-29.2       , -25.28794179,   0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [-14.6       ,  25.28794179,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [  0.        , -25.28794179,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [ 14.6       , -25.28794179,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [-21.9      ,  12.6439709,  -0.       ],
       [ -7.3      , -12.6439709,   0.       ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [ -7.3      ,  12.6439709,   0.       ],
       [-21.9      , -12.6439709,  -0.       ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [  7.3      ,  12.6439709,  -0.       ],
       [-36.5      , -12.6439709,   0.       ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-21.9       , -37.93191269,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [ -7.3       , -37.93191269,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [  7.3       , -37.93191269,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [  7.3      , -12.6439709,  -0.       ],
       [-36.5      ,  12.6439709,   0.       ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [ 21.9      , -12.6439709,   0.       ],
       [-51.1      ,  12.6439709,  -0.       ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [-43.8       , -25.28794179,   0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [-29.2       , -25.28794179,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [  0.        , -25.28794179,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 43.8      ,   0.       ,   0.       ],
       [-36.5      ,  12.6439709,   0.       ],
       [ -7.3      , -12.6439709,   0.       ]]),
 array([[ 43.8      ,   0.       ,   0.       ],
       [-21.9      ,  12.6439709,  -0.       ],
       [-21.9      , -12.6439709,  -0.       ]]),
 array([[ 43.8      ,   0.       ,   0.       ],
       [ -7.3      ,  12.6439709,   0.       ],
       [-36.5      , -12.6439709,   0.       ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [-36.5       , -37.93191269,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [-21.9       , -37.93191269,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 43.8       ,   0.        ,   0.        ],
       [ -7.3       , -37.93191269,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 43.8      ,   0.       ,   0.       ],
       [-51.1      , -12.6439709,   0.       ],
       [  7.3      ,  12.6439709,  -0.       ]]),
 array([[ 43.8      ,   0.       ,   0.       ],
       [  7.3      , -12.6439709,  -0.       ],
       [-51.1      ,  12.6439709,  -0.       ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ],
       [-21.9       , -12.6439709 ,  -0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ],
       [-36.5       , -12.6439709 ,   0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [  7.3       , -12.6439709 ,  -0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 21.9       , -12.6439709 ,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 36.5       , -12.6439709 ,  -0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 21.9       ,  12.6439709 ,   0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 36.5       ,  12.6439709 ,  -0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[  0.        , -25.28794179,   0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ],
       [-21.9       , -12.6439709 ,  -0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ],
       [-36.5       , -12.6439709 ,   0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [  7.3       , -12.6439709 ,  -0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [ 21.9       , -12.6439709 ,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [ 21.9       ,  12.6439709 ,   0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[ 14.6       , -25.28794179,   0.        ],
       [ 36.5       ,  12.6439709 ,  -0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ],
       [-21.9       , -12.6439709 ,  -0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ],
       [-36.5       , -12.6439709 ,   0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [  7.3       , -12.6439709 ,  -0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [-36.5       ,  12.6439709 ,   0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ]]),
 array([[ 29.2       , -25.28794179,   0.        ],
       [ 21.9       ,  12.6439709 ,   0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [-36.5       ,  37.93191269,   0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ],
       [-21.9       , -12.6439709 ,  -0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ],
       [-36.5       , -12.6439709 ,   0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [-36.5       ,  12.6439709 ,   0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ]]),
 array([[ 43.8       , -25.28794179,   0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [  0.        , -50.57588358,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [ 29.2       , -50.57588358,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [  0.        , -50.57588358,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [-29.2       , -25.28794179,   0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [  0.        , -50.57588358,   0.        ],
       [-36.5       ,  37.93191269,   0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [-43.8       , -25.28794179,   0.        ],
       [  7.3       ,  12.6439709 ,  -0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [-29.2       , -25.28794179,   0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ]]),
 array([[ 36.5       ,  12.6439709 ,  -0.        ],
       [-14.6       , -25.28794179,  -0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[  7.3       , -37.93191269,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[  7.3       , -37.93191269,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[  7.3       , -37.93191269,   0.        ],
       [ 43.8       ,  25.28794179,  -0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ 21.9       , -37.93191269,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[ 21.9       , -37.93191269,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ 36.5       , -37.93191269,  -0.        ],
       [ 14.6       ,  25.28794179,   0.        ],
       [-51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ -7.3      , -12.6439709,   0.       ],
       [ 58.4      ,   0.       ,   0.       ],
       [-51.1      ,  12.6439709,  -0.       ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-29.2       , -25.28794179,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-21.9       , -37.93191269,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-43.8       , -25.28794179,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-36.5       , -37.93191269,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[ 29.2      ,   0.       ,   0.       ],
       [-51.1      , -12.6439709,   0.       ],
       [ 21.9      ,  12.6439709,   0.       ]]),
 array([[-14.6       , -25.28794179,  -0.        ],
       [  7.3       ,  37.93191269,  -0.        ],
       [  7.3       , -12.6439709 ,  -0.        ]]),
 array([[-14.6       , -25.28794179,  -0.        ],
       [ 21.9       ,  37.93191269,  -0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[-14.6       , -25.28794179,  -0.        ],
       [ 36.5       ,  37.93191269,  -0.        ],
       [-21.9       , -12.6439709 ,  -0.        ]]),
 array([[-14.6       , -25.28794179,  -0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[ -7.3       ,  12.6439709 ,   0.        ],
       [  0.        , -50.57588358,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[ -7.3       ,  12.6439709 ,   0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ -7.3       ,  12.6439709 ,   0.        ],
       [ 29.2       , -50.57588358,   0.        ],
       [-21.9       ,  37.93191269,  -0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[ 21.9       ,  12.6439709 ,   0.        ],
       [-43.8       , -25.28794179,   0.        ],
       [ 21.9       ,  12.6439709 ,   0.        ]]),
 array([[ -7.3       , -37.93191269,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[ -7.3       , -37.93191269,   0.        ],
       [ 43.8       ,  25.28794179,  -0.        ],
       [-36.5       ,  12.6439709 ,   0.        ]]),
 array([[-21.9      , -12.6439709,  -0.       ],
       [ 58.4      ,   0.       ,   0.       ],
       [-36.5      ,  12.6439709,   0.       ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-43.8       , -25.28794179,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-36.5       , -37.93191269,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ]]),
 array([[ 14.6      ,   0.       ,   0.       ],
       [-51.1      , -12.6439709,   0.       ],
       [ 36.5      ,  12.6439709,  -0.       ]]),
 array([[-29.2       , -25.28794179,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ],
       [  7.3       , -12.6439709 ,  -0.        ]]),
 array([[-29.2       , -25.28794179,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ],
       [ -7.3       , -12.6439709 ,   0.        ]]),
 array([[-29.2       , -25.28794179,   0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[-21.9       ,  12.6439709 ,  -0.        ],
       [  0.        , -50.57588358,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ]]),
 array([[-21.9       ,  12.6439709 ,  -0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[-21.9       ,  12.6439709 ,  -0.        ],
       [ 29.2       , -50.57588358,   0.        ],
       [ -7.3       ,  37.93191269,  -0.        ]]),
 array([[ -7.3       ,  12.6439709 ,   0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ]]),
 array([[  7.3       ,  12.6439709 ,  -0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ]]),
 array([[-21.9       , -37.93191269,   0.        ],
       [ 43.8       ,  25.28794179,  -0.        ],
       [-21.9       ,  12.6439709 ,  -0.        ]]),
 array([[-36.5      , -12.6439709,   0.       ],
       [ 58.4      ,   0.       ,   0.       ],
       [-21.9      ,  12.6439709,  -0.       ]]),
 array([[-43.8       , -25.28794179,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ],
       [  7.3       , -12.6439709 ,  -0.        ]]),
 array([[-43.8       , -25.28794179,   0.        ],
       [ -7.3       ,  12.6439709 ,   0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ]]),
 array([[-36.5       ,  12.6439709 ,   0.        ],
       [  0.        , -50.57588358,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ]]),
 array([[-36.5       ,  12.6439709 ,   0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [ 21.9       ,  37.93191269,  -0.        ]]),
 array([[-36.5       ,  12.6439709 ,   0.        ],
       [ 29.2       , -50.57588358,   0.        ],
       [  7.3       ,  37.93191269,  -0.        ]]),
 array([[-21.9       ,  12.6439709 ,  -0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ]]),
 array([[ -7.3       ,  12.6439709 ,   0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [ 36.5       ,  37.93191269,  -0.        ]]),
 array([[-36.5       , -37.93191269,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ]]),
 array([[-21.9       , -37.93191269,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ]]),
 array([[ -7.3       , -37.93191269,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ],
       [ 51.1       ,  12.6439709 ,  -0.        ]]),
 array([[-51.1      , -12.6439709,   0.       ],
       [ 58.4      ,   0.       ,   0.       ],
       [ -7.3      ,  12.6439709,   0.       ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [ -0.        ,  50.57588358,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [  0.        , -50.57588358,   0.        ],
       [-14.6       ,  50.57588358,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [ 14.6       , -50.57588358,   0.        ],
       [-29.2       ,  50.57588358,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [ -0.        ,  50.57588358,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [-14.6       , -50.57588358,   0.        ],
       [-14.6       ,  50.57588358,  -0.        ]]),
 array([[ 29.2       ,   0.        ,   0.        ],
       [  0.        , -50.57588358,   0.        ],
       [-29.2       ,  50.57588358,  -0.        ]]),
 array([[  0.        , -50.57588358,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[  0.        , -50.57588358,   0.        ],
       [ -0.        ,  25.28794179,  -0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[  0.        , -50.57588358,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[  0.        , -50.57588358,   0.        ],
       [ 43.8       ,  25.28794179,  -0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 14.6       , -50.57588358,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[ 14.6       , -50.57588358,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[ 14.6       , -50.57588358,   0.        ],
       [ 29.2       ,  25.28794179,  -0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 29.2       , -50.57588358,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[ 29.2       , -50.57588358,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ],
       [ -0.        ,  25.28794179,  -0.        ]]),
 array([[ 29.2       , -50.57588358,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [-14.6       ,  25.28794179,  -0.        ]]),
 array([[-14.6       , -25.28794179,  -0.        ],
       [ 58.4       ,   0.        ,   0.        ],
       [-43.8       ,  25.28794179,  -0.        ]]),
 array([[ 14.6       ,   0.        ,   0.        ],
       [-29.2       , -50.57588358,   0.        ],
       [ 14.6       ,  50.57588358,  -0.        ]]),
 array([[-14.6       , -50.57588358,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [ 29.2       ,  25.28794179,  -0.        ]]),
 array([[-14.6       , -50.57588358,   0.        ],
       [ -0.        ,  25.28794179,  -0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[-14.6       , -50.57588358,   0.        ],
       [ 43.8       ,  25.28794179,  -0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[-29.2       , -25.28794179,   0.        ],
       [ 58.4       ,   0.        ,   0.        ],
       [-29.2       ,  25.28794179,  -0.        ]]),
 array([[-29.2       , -50.57588358,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ],
       [ 43.8       ,  25.28794179,  -0.        ]]),
 array([[-29.2       , -50.57588358,   0.        ],
       [ -0.        ,  25.28794179,  -0.        ],
       [ 29.2       ,  25.28794179,  -0.        ]]),
 array([[-29.2       , -50.57588358,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ],
       [ 14.6       ,  25.28794179,   0.        ]]),
 array([[-43.8       , -25.28794179,   0.        ],
       [ 58.4       ,   0.        ,   0.        ],
       [-14.6       ,  25.28794179,  -0.        ]]),
 array([[ 14.6,   0. ,   0. ],
       [ 43.8,   0. ,   0. ],
       [-58.4,  -0. ,  -0. ]]),
 array([[ 29.2,   0. ,   0. ],
       [ 29.2,   0. ,   0. ],
       [-58.4,  -0. ,  -0. ]])]

In [20]:
print(cpinfo_case_with_HI.keys())


['1ps_HI_cosine', 'HI_21cmfast_fiducial']

In [21]:
triad1_label = 'EQ14'
triad1 = ('0', '1', '8')
triad1_ind = cpinfo_case_with_HI[cpinfo_case_with_HI.keys()[0]]['antenna_triplets'].index(triad1)
triad1_baselines = cpinfo_case_with_HI[cpinfo_case_with_HI.keys()[0]]['baseline_triplets'][triad1_ind]
blind1 = []
for i in range(3):
    blind = NP.where(NP.sum(NP.abs(baselines - triad1_baselines[[i]]), axis=1) <= 0.1)[0]
    if blind.size == 1:
        blind1 += [blind[0]]
    if blind.size == 0:
        blind = NP.where(NP.sum(NP.abs(baselines + triad1_baselines[[i]]), axis=1) <= 0.1)[0]
        if blind.size == 1:
            blind1 += [blind[0]]
        else:
            raise ValueError('Baseline [{0[0]:.1f}, {0[1]:.1f}, {0[2]:.1f}] nor its conjugate found'.format(triad1_baselines[i]))
bltriplet1_in_sim = NP.asarray([baselines[blind1[i]] for i in range(3)])
print(triad1_ind)
print(triad1_baselines)
print(blind1)
print(bltriplet1_in_sim)


6
[[ 14.6         0.          0.       ]
 [ -7.3        12.6439709   0.       ]
 [ -7.3       -12.6439709   0.       ]]
[0, 2, 1]
[[ 14.6         0.          0.       ]
 [  7.3       -12.6439709  -0.       ]
 [  7.3        12.6439709  -0.       ]]

In [22]:
triad2_label = 'EQ50'
triad2 = ('8', '11', '18')
triad2_ind = cpinfo_case_with_HI[cpinfo_case_with_HI.keys()[0]]['antenna_triplets'].index(triad2)
triad2_baselines = cpinfo_case_with_HI[cpinfo_case_with_HI.keys()[0]]['baseline_triplets'][triad2_ind]
blind2 = []
for i in range(3):
    blind = NP.where(NP.sum(NP.abs(baselines - triad2_baselines[[i]]), axis=1) <= 0.1)[0]
    if blind.size == 1:
        blind2 += [blind[0]]
    if blind.size == 0:
        blind = NP.where(NP.sum(NP.abs(baselines + triad2_baselines[[i]]), axis=1) <= 0.1)[0]
        if blind.size == 1:
            blind2 += [blind[0]]
        else:
            raise ValueError('Baseline [{0[0]:.1f}, {0[1]:.1f}, {0[2]:.1f}] nor its conjugate found'.format(triad2_baselines[i]))
bltriplet2_in_sim = NP.asarray([baselines[blind2[i]] for i in range(3)])
print(triad2_ind)
print(triad2_baselines)
print(blind2)
print(bltriplet2_in_sim)


143
[[  0.         -50.57588358   0.        ]
 [ 43.8         25.28794179  -0.        ]
 [-43.8         25.28794179  -0.        ]]
[19, 18, 20]
[[ -0.          50.57588358  -0.        ]
 [ 43.8         25.28794179  -0.        ]
 [ 43.8        -25.28794179   0.        ]]

In [23]:
print(triad1_ind)
print(triad1)
print(freqs.shape)
print(predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'].shape)
print(cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'].shape)
print(cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'].shape)
print(predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'].shape)
print((cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'] - cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'] - predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad']).shape)


6
('0', '1', '8')
(1024,)
(162, 3, 1024, 2)
(162, 1024, 2)
(162, 1024, 2)
(162, 1024, 2)
(162, 1024, 2)

Plot HI visibility amplitudes


In [26]:
colrs = ['red', 'blue', 'black']
for case_id in case_with_HI:
    for blind, triad_ind, triad, triad_label in zip([blind1, blind2], [triad1_ind, triad2_ind], [triad1, triad2], [triad1_label, triad2_label]):
        print('\tPlotting Triad:({0[0]},{0[1]},{0[2]})'.format(triad))
        
        fig = PLT.figure(figsize=(3.5,2))
        ax = fig.add_subplot(111)
        for i in range(3):
            ax.plot(freqs/1e6, NP.abs(case_with_HI[case_id]['vis'].skyvis_freq[blind[i],:,0]), color=colrs[i], ls='-', lw=2, alpha=0.5)


	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)

Plot: Plot Foreground and fluctuations in amplitude due to HI


In [38]:
colrs = ['red', 'blue', 'black']
for case_id in case_with_FG_HI:
    if (('GLEAM' in case_id) or ('21cmfast' in case_id)) and ('cosine' not in key_mapping_FG_HI[case_id]['HI']):
        lwidth = 1
        plot_envelope = False
    else:
        lwidth = 0.5
        plot_envelope = True
    print('Plotting {0}:'.format(case_id))
    
    for blind, triad_ind, triad, triad_label in zip([blind1, blind2], [triad1_ind, triad2_ind], [triad1, triad2], [triad1_label, triad2_label]):
        print('\tPlotting Triad:({0[0]},{0[1]},{0[2]})'.format(triad))
        
        fig, axs = PLT.subplots(nrows=2, sharex=True, squeeze=True, figsize=(3,4))
        
        for i in range(3):
            axs[0].plot(freqs/1e6, NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind[i],:,0]), color=colrs[i], ls='-', lw=2, alpha=0.5)
            axs[1].plot(freqs/1e6, 1e3 * (NP.abs(case_with_FG_HI[case_id]['vis'].skyvis_freq[blind[i],:,0]) - NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind[i],:,0])), color=colrs[i], ls='-', lw=lwidth, alpha=0.5)
            if plot_envelope:
                axs[1].plot(freqs/1e6, 1e3 * (NP.abs(SPS.hilbert(NP.abs(case_with_FG_HI[case_id]['vis'].skyvis_freq[blind[i],:,0]) - NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind[i],:,0])))), color=colrs[i], ls='-', lw=1)
                axs[1].plot(freqs/1e6, -1e3 * (NP.abs(SPS.hilbert(NP.abs(case_with_FG_HI[case_id]['vis'].skyvis_freq[blind[i],:,0]) - NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind[i],:,0])))), color=colrs[i], ls='-', lw=1)            
            
        axs[0].text(0.98, 0.95, r'$\nabla$'+' ({0[0]},{0[1]},{0[2]})'.format(triad), transform=axs[0].transAxes, ha='right', va='center')
        axs[0].set_ylabel(r'$|V_p^\mathrm{F}(f)|$ [Jy]', fontsize=11, weight='medium')
        axs[1].set_ylabel(r'$\delta\,|V_p(f)|$ [mJy]', fontsize=11, weight='medium')
        
        if ('FG_spindex' in case_id) and ('colocated' in case_id):
            axs[0].set_xlim(126, 174)
            axs[1].set_xlim(126, 174)            
        else:
            axs[0].set_xlim(105, 195)
            axs[1].set_xlim(105, 195)

        ax0_ymin = NP.min(NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind,:,0]))
        ax0_ymax = NP.max(NP.abs(case_with_FG[key_mapping_FG_HI[case_id]['FG']]['vis'].skyvis_freq[blind,:,0]))
        axs[0].set_ylim(max([0, ax0_ymin-5]), ax0_ymax+5)
        
        fig.subplots_adjust(hspace=0, wspace=0)
        fig.subplots_adjust(left=0.22, right=0.98, bottom=0.12, top=0.98)
        
        big_ax = fig.add_subplot(111)
        big_ax.set_facecolor('none')
        big_ax.set_xticks([])
        big_ax.set_yticks([])
        big_ax.set_xlabel(r'$f$ [MHz]', weight='medium', fontsize=11, labelpad=20)
        
        PLT.savefig(figdir + '{0}_visibility_models_{1}_HERA-19_achromatic_AiryBeam.pdf'.format(triad_label, case_id), bbox_inches=0)


Plotting 1ps_FG_no_spindex_HI_colocated:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting 1ps_FG_spindex_HI_displaced:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting 1ps_FG_spindex_HI_21cmfast:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting 1ps_FG_spindex_HI_colocated:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting GLEAM_1ps_HI:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting 1ps_FG_no_spindex_HI_21cmfast:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting 1ps_FG_no_spindex_HI_displaced:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
Plotting GLEAM_HI_21cmfast:
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)

Plot: Compare computed and predicted values for closure phases


In [28]:
for case_id in case_with_FG_HI:
    print('------------------------\nPlotting {0}'.format(case_id))
    if ('GLEAM' in case_id) or ('21cmfast' in case_id):
        lwidth = 1
        plot_envelope = False
    else:
        lwidth = 0.5
        plot_envelope = True
    
    for triad_ind, triad, triad_label in zip([triad1_ind, triad2_ind], [triad1, triad2], [triad1_label, triad2_label]):
        print('\tPlotting Triad:({0[0]},{0[1]},{0[2]})'.format(triad))
        
        fig, axs = PLT.subplots(nrows=3, sharex=True, squeeze=True, figsize=(3,6))

        colrs = ['red', 'blue', 'black']
        for i in range(3):
            axs[0].plot(freqs/1e6, 1e3 * predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'][triad_ind,i,:,0], ls='-', lw=lwidth, color=colrs[i], alpha=0.5)
            if plot_envelope:
                axs[0].plot(freqs/1e6, 1e3 * NP.abs(SPS.hilbert(predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'][triad_ind,i,:,0])), ls='-', lw=1, color=colrs[i])
                axs[0].plot(freqs/1e6, -1e3 * NP.abs(SPS.hilbert(predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'][triad_ind,i,:,0])), ls='-', lw=1, color=colrs[i])

        axs[0].text(0.98, 0.95, r'$\nabla$'+' ({0[0]},{0[1]},{0[2]})'.format(triad), transform=axs[0].transAxes, ha='right', va='center')
        axs[0].set_ylabel(r'$\delta\phi_p^\mathrm{L}(f)$ [milli-radian]', fontsize=11, weight='medium')
        axs[0].set_xlim(105, 195)
        ax0_ymin = 1e3 * NP.abs(NP.min(predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'][triad_ind,:,:,0]))
        ax0_ymax = 1e3 * NP.abs(NP.max(predicted_cpinfo_with_FG_HI[case_id]['imag_ratio_triad'][triad_ind,:,:,0]))
        axs[0].set_ylim(min([-0.0125, -1.1*ax0_ymin]), max([0.0125, 1.1*ax0_ymax]))

        axs[1].plot(freqs/1e6, 1e3 * (cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'][triad_ind,:,0] - cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'][triad_ind,:,0]), ls='-', lw=lwidth, color='black', alpha=0.5)
        axs[1].plot(freqs/1e6, 1e3 * predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0], ls='-', lw=lwidth, color='gray', alpha=0.5)
        if plot_envelope:
            axs[1].plot(freqs/1e6, 1e3 * NP.abs(SPS.hilbert(predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0])), ls='-', lw=1, color='gray')
            axs[1].plot(freqs/1e6, -1e3 * NP.abs(SPS.hilbert(predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0])), ls='-', lw=1, color='gray')
        axs[1].set_ylabel(r'$\delta\phi_\nabla^\mathrm{L}(f)$ [milli-radian]', fontsize=11, weight='medium')
        axs[1].set_xlim(105, 195)
        ax1_ymin = 1e3 * NP.abs(NP.min(predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0]))
        ax1_ymax = 1e3 * NP.abs(NP.max(predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0]))
        axs[1].set_ylim(min([-0.0125, -1.1*ax1_ymin]), max([0.0125, 1.1*ax1_ymax]))

        axs[2].plot(freqs/1e6, 1e9 * (cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'][triad_ind,:,0] - cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'][triad_ind,:,0] - predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0]), ls='-', lw=lwidth, color='gray')
        axs[2].set_ylabel(r'err$\left(\delta\phi_\nabla^\mathrm{L}(f)\right)$ [nano-radian]', fontsize=11, weight='medium')
        axs[2].set_xlim(105, 195)
        ax2_ymin = 1e9 * NP.abs(NP.min(cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'][triad_ind,:,0] - cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'][triad_ind,:,0] - predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0]))
        ax2_ymax = 1e9 * NP.abs(NP.max(cpinfo_case_with_FG_HI[case_id]['closure_phase_skyvis'][triad_ind,:,0] - cpinfo_case_with_FG[key_mapping_FG_HI[case_id]['FG']]['closure_phase_skyvis'][triad_ind,:,0] - predicted_cpinfo_with_FG_HI[case_id]['sum_imag_ratio_triad'][triad_ind,:,0]))
        axs[2].set_ylim(min([-0.0125, -1.1*ax2_ymin]), max([0.0125, 1.1*ax2_ymax]))

        fig.subplots_adjust(hspace=0, wspace=0)
        fig.subplots_adjust(left=0.24, right=0.98, bottom=0.07, top=0.98)

        big_ax = fig.add_subplot(111)
        big_ax.set_facecolor('none')
        big_ax.set_xticks([])
        big_ax.set_yticks([])
        big_ax.set_xlabel(r'$f$ [MHz]', fontsize=11, weight='medium', labelpad=20)

        PLT.savefig(figdir + '{0}_closure_phase_comparison_actual_vs_prediction_{1}_HERA-19_achromatic_AiryBeam.pdf'.format(triad_label, case_id), bbox_inches=0)


------------------------
Plotting 1ps_FG_no_spindex_HI_colocated
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting 1ps_FG_spindex_HI_displaced
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting 1ps_FG_spindex_HI_21cmfast
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting 1ps_FG_spindex_HI_colocated
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting GLEAM_1ps_HI
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting 1ps_FG_no_spindex_HI_21cmfast
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting 1ps_FG_no_spindex_HI_displaced
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)
------------------------
Plotting GLEAM_HI_21cmfast
	Plotting Triad:(0,1,8)
	Plotting Triad:(8,11,18)