Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhilei committed Nov 23, 2022
1 parent 014f7f6 commit 6c4b5bf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/direct_optimal_mapping/dom_pspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ def set_k_space(self, binning='lin', n_perp=None):
self.ky = np.fft.fftfreq(self.ny, d=self.res_y_mpch)*2*np.pi
self.kz = np.fft.fftfreq(self.nz, d=self.res_z_mpch)*2*np.pi

# self.k_xx, self.k_yy, self.k_zz = np.meshgrid(self.kx, self.ky, self.kz, indexing='ij')

self.k_zz, self.k_xx, self.k_yy = np.meshgrid(self.kz, self.kx, self.ky, indexing='ij')

self.k_perp = np.sqrt(np.average(self.k_xx, axis=0)**2 +
Expand Down Expand Up @@ -174,4 +172,4 @@ def calc_ps1d(self, nbin=None, avoid_fg=True):
self.ps1d_nsample = np.array(n_sample)

return


6 changes: 0 additions & 6 deletions src/direct_optimal_mapping/image_cube_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ def image_cube_calc(self):
map_dic_n6 = pickle.load(f_t)

freq_mhz = float(re.search('_(......)MHz', file_n5_t).group(1))
# idx_t = np.where(freq_mhz == self.syn_sa_dic['freq_mhz'])[0]
# syn_sa = self.syn_sa_dic['sa'][idx_t]
syn_sa = self.sa_interp(freq_mhz)
print(i, freq_mhz, 'MHz', end=',')

# normalization d calculation
d_diag = 1/(map_dic_n5['beam_weight_sum'] * map_dic_n5['px_dic']['sa_sr'].flatten()) # vis -> Jy/beam
d_diag = d_diag/syn_sa # Jy/beam -> Jy/sr
# d_diag = d_diag/map_dic_n5['px_dic']['sa_sr'].flatten() # Jy/beam -> Jy/sr
# print(self.syn_sa_dic['sa'][i], map_dic_n5['px_dic']['sa_sr'])
jysr2mk = 1e-26*const.c**2/2/(1e6*freq_mhz)**2/const.k_B*1e3
d_diag = d_diag * jysr2mk # Jy/sr -> mK

Expand All @@ -62,8 +58,6 @@ def image_cube_calc(self):
self.d_diag = np.vstack((self.d_diag, d_diag))
img_cube_n5 = img_cube_n5.squeeze().reshape(((-1, *map_dic_n5['px_dic']['ra_deg'].shape)))
img_cube_n6 = img_cube_n6.squeeze().reshape(((-1, *map_dic_n6['px_dic']['ra_deg'].shape)))
# img_cube_n5 = np.moveaxis(img_cube_n5, 0, -1)
# img_cube_n6 = np.moveaxis(img_cube_n6, 0, -1)

data_dic['data_cube_pol-5'] = img_cube_n5
data_dic['data_cube_pol-6'] = img_cube_n6
Expand Down
10 changes: 1 addition & 9 deletions src/direct_optimal_mapping/optimal_mapping_radec_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def __init__(self, uv, px_dic, epoch='J2000', feed=None,
height=uv.telescope_location_lat_lon_alt_degrees[2]*u.m)

self.uv = uv
# self.nside = nside
# self.npix = hp.nside2npix(nside)
self.hera_dec = self.uv.telescope_location_lat_lon_alt[0]
self.lsts = np.unique(self.uv.lst_array)
self.times = np.unique(uv.time_array)
Expand All @@ -128,9 +126,7 @@ def __init__(self, uv, px_dic, epoch='J2000', feed=None,
self.feed_type = 'vivaldi'
else:
self.feed_type = feed
#print('RA/DEC in the epoch of %s, with %s beam used.'%(self.equinox, self.feed_type))

# theta, phi = hp.pix2ang(nside, range(self.npix))
self.ra = np.radians(px_dic['ra_deg']).flatten()
self.dec = np.radians(px_dic['dec_deg']).flatten()
self.px_sa = px_dic['sa_sr'].flatten()
Expand Down Expand Up @@ -174,8 +170,6 @@ def _radec2azalt(self, ra, dec, time):
aa = AltAz(location=self.hera_site, obstime=obs_time)
if self.equinox == 'J2000':
c = SkyCoord(ra=ra, dec=dec, unit='radian', frame=TETE(obstime=self.equinox))
#c = SkyCoord(ra=ra, dec=dec, unit='radian', frame='icrs')
#print('ICRS')
elif self.equinox == 'Current':
c = SkyCoord(ra=ra, dec=dec, unit='radian', frame=TETE(obstime=obs_time))
else:
Expand Down Expand Up @@ -215,7 +209,6 @@ def set_pyuvbeam(self, beam_model):
pyuvbeam.read_beamfits(beamfits_file)
pyuvbeam.efield_to_power()
pyuvbeam.select(polarizations=self.uv.polarization_array)
#print(pyuvbeam.polarization_array)
pyuvbeam.peak_normalize()
pyuvbeam.interpolation_function = 'az_za_simple'
pyuvbeam.freq_interp_kind = 'cubic'
Expand Down Expand Up @@ -245,8 +238,7 @@ def set_a_mat(self, uvw_sign=1, apply_beam=True):
self.beam_mat = np.zeros(self.phase_mat.shape, dtype='float64')
self.sa_mat = np.zeros(self.phase_mat.shape, dtype='float64')
self.set_pyuvbeam(beam_model=self.feed_type)
# freq_array = np.array([self.frequency,])
freq_array = np.array([169e6,])
freq_array = np.array([self.frequency,])
for time_t in np.unique(self.uv.time_array):
az_t, alt_t = self._radec2azalt(self.ra, self.dec, time_t)
lmn_t = np.array([np.cos(alt_t)*np.sin(az_t),
Expand Down

0 comments on commit 6c4b5bf

Please sign in to comment.