Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
obs2.data['time'] += 0.00001
# concatenate the observations into a single observation object
obs = obs1.copy()
obs.data = np.concatenate([obs1.data,obs2.data])
# Estimate the total flux density from the ALMA(AA) -- APEX(AP) zero baseline
zbl_tot = np.median(obs.unpack_bl('AA','AP','amp')['amp'])
if zbl > zbl_tot:
print('Warning: Specified total compact flux density ' +
'exceeds total flux density measured on AA-AP!')
# Flag out sites in the obs.tarr table with no measurements
allsites = set(obs.unpack(['t1'])['t1'])|set(obs.unpack(['t2'])['t2'])
obs.tarr = obs.tarr[[o in allsites for o in obs.tarr['site']]]
obs = eh.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obs.data, obs.tarr,
source=obs.source, mjd=obs.mjd,
ampcal=obs.ampcal, phasecal=obs.phasecal)
obs_orig = obs.copy() # save obs before any further modifications
# Rescale short baselines to excize contributions from extended flux
if zbl != zbl_tot:
rescale_zerobaseline(obs, zbl, zbl_tot, uv_zblcut)
# Order the stations by SNR.
# This will create a minimal set of closure quantities
# with the highest snr and smallest covariance.
obs.reorder_tarr_snr()
#-------------------------------------------------------------------------------
# Pre-calibrate the data
opacitycal=opacitycal, ampcal=ampcal,
phasecal=phasecal, dcal=dcal, frcal=frcal,
stabilize_scan_phase=stabilize_scan_phase,
stabilize_scan_amp=stabilize_scan_amp,
gainp=gainp, taup=taup, gain_offset=gain_offset,
dtermp=dtermp,dterm_offset=dterm_offset)
obs = ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obsdata, obs.tarr,
source=obs.source, mjd=obs.mjd, polrep=obs_in.polrep,
ampcal=ampcal, phasecal=phasecal, opacitycal=opacitycal, dcal=dcal, frcal=frcal,
timetype=obs.timetype, scantable=obs.scans)
if inv_jones:
obsdata = simobs.apply_jones_inverse(obs, opacitycal=opacitycal, dcal=dcal, frcal=frcal)
obs = ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obsdata, obs.tarr,
source=obs.source, mjd=obs.mjd, polrep=obs_in.polrep,
ampcal=ampcal, phasecal=phasecal,
opacitycal=True, dcal=True, frcal=True,
timetype=obs.timetype, scantable=obs.scans)
#these are always set to True after inverse jones call
# No Jones Matrices, Add noise the old way
# TODO There is an asymmetry here - in the old way, we don't offer the ability to *not* unscale estimated noise.
elif add_th_noise:
obsdata = simobs.add_noise(obs, add_th_noise=add_th_noise,
ampcal=ampcal, phasecal=phasecal, opacitycal=opacitycal,
gainp=gainp, taup=taup, gain_offset=gain_offset)
obs = ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obsdata, obs.tarr,
source=obs.source, mjd=obs.mjd, polrep=obs_in.polrep,
ampcal=ampcal, phasecal=phasecal, opacitycal=True, dcal=True, frcal=True,
def splitObs(obs):
"""Split single observation into multiple observation files, one per scan
"""
print("Splitting Observation File into " + str(len(obs.tlist())) + " scans")
#Note that the tarr of the output includes all sites, even those that don't participate in the scan
obs_List = [ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, tdata, obs.tarr, source=obs.source,
mjd=obs.mjd, ampcal=obs.ampcal, phasecal=obs.phasecal)
for tdata in obs.tlist()
]
return obs_List
print("Producing clean visibilities from movie . . . ")
obs = self.observe_same_nonoise(obs_in, sgrscat=sgrscat, ttype=ttype, fft_pad_factor=fft_pad_factor, repeat=repeat)
# Jones Matrix Corruption & Calibration
if jones:
print("Applying Jones Matrices to data . . . ")
obsdata = simobs.add_jones_and_noise(obs, add_th_noise=add_th_noise,
opacitycal=opacitycal, ampcal=ampcal,
phasecal=phasecal, dcal=dcal, frcal=frcal,
stabilize_scan_phase=stabilize_scan_phase,
stabilize_scan_amp=stabilize_scan_amp,
gainp=gainp, taup=taup, gain_offset=gain_offset,
dtermp=dtermp,dterm_offset=dterm_offset)
obs = ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obsdata, obs.tarr,
source=obs.source, mjd=obs.mjd, polrep=obs_in.polrep,
ampcal=ampcal, phasecal=phasecal, opacitycal=opacitycal, dcal=dcal, frcal=frcal,
timetype=obs.timetype, scantable=obs.scans)
if inv_jones:
obsdata = simobs.apply_jones_inverse(obs, opacitycal=opacitycal, dcal=dcal, frcal=frcal)
obs = ehtim.obsdata.Obsdata(obs.ra, obs.dec, obs.rf, obs.bw, obsdata, obs.tarr,
source=obs.source, mjd=obs.mjd, polrep=obs_in.polrep,
ampcal=ampcal, phasecal=phasecal,
opacitycal=True, dcal=True, frcal=True,
timetype=obs.timetype, scantable=obs.scans)
#these are always set to True after inverse jones call
# No Jones Matrices, Add noise the old way
# TODO There is an asymmetry here - in the old way, we don't offer the ability to *not* unscale estimated noise.
for site in allsites:
try: dat = row[site]
except KeyError: continue
try: caldict[site] = np.append(caldict[site], row[site])
except KeyError: caldict[site] = [dat]
caltable = ehtim.caltable.Caltable(obs.ra, obs.dec, obs.rf, obs.bw, caldict, obs.tarr,
source = obs.source, mjd=obs.mjd, timetype=obs.timetype)
out = caltable
else: # return the calibrated observation
arglist, argdict = obs.obsdata_args()
arglist[4] = np.concatenate(scans_cal)
out = ehtim.obsdata.Obsdata(*arglist, **argdict)
# close multiprocessing jobs
if processes != -1:
pool.close()
return out
def merge(obss):
for i in range(1, len(obss)):
obss[i].data['time'] += i * 1e-6
obss[i].mjd = obss[0].mjd
obss[i].rf = obss[0].rf
obss[i].ra = obss[0].ra
obss[i].dec = obss[0].dec
obss[i].bw = obss[0].bw
return eh.obsdata.merge_obs(obss).copy()