Skip to content

Commit

Permalink
Merge pull request #129 from achael/dev
Browse files Browse the repository at this point in the history
Dev updates May - December 2020
  • Loading branch information
achael authored Dec 10, 2020
2 parents 952a640 + 6ca5320 commit 6b87cdc
Show file tree
Hide file tree
Showing 13 changed files with 1,166 additions and 657 deletions.
10 changes: 5 additions & 5 deletions ehtim/const_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@
'pvis', 'pamp', 'pphase', 'psnr',
'evis', 'eamp', 'ephase', 'esnr',
'bvis', 'bamp', 'bphase', 'bsnr',
'm', 'mamp', 'mphase', 'msnr'
'm', 'mamp', 'mphase', 'msnr',
'rrvis', 'rramp', 'rrphase', 'rrsnr', 'rrsigma', 'rrsigma_phase',
'llvis', 'llamp', 'llphase', 'llsnr', 'llsigma', 'llsigma_phase'
'rlvis', 'rlamp', 'rlphase', 'rlsnr', 'rlsigma', 'rlsigma_phase'
'lrvis', 'lramp', 'lrphase', 'lrsnr', 'lrsigma', 'lrsigma_phase'
'llvis', 'llamp', 'llphase', 'llsnr', 'llsigma', 'llsigma_phase',
'rlvis', 'rlamp', 'rlphase', 'rlsnr', 'rlsigma', 'rlsigma_phase',
'lrvis', 'lramp', 'lrphase', 'lrsnr', 'lrsigma', 'lrsigma_phase',
'rrllvis', 'rrllamp', 'rrllphase', 'rrllsnr', 'rrllsigma', 'rrllsigma_phase']

FIELDS_AMPS = ["amp", "qamp", "uamp", "vamp",
"pamp", "mamp", "rramp", "llamp", "rlamp", "lramp", "rrllamp"]
FIELDS_SIGS = ["sigma", "qsigma", "usigma", "vsigma",
"psigma", "msigma", "rrsigma", "llsigma", "rlsigma", "lrsigma", "rrllsigma"]
FIELDS_PHASE = ["phase", "qphase", "uphase", "vphase", "pphase", "mphase",
"rrphase", "llphase", "lrphase", "rlphase", "rrllphase"]
"rrphase", "llphase", "rlphase", "lrphase", "rrllphase"]
FIELDS_SIGPHASE = ["sigma_phase", "qsigma_phase", "usigma_phase", "vsigma_phase",
"psigma_phase", "msigma_phase", "rrsigma_phase", "llsigma_phase",
"rlsigma_phase", "lrsigma_phase", "rrllsigma_phase"]
Expand Down
227 changes: 138 additions & 89 deletions ehtim/image.py

Large diffs are not rendered by default.

363 changes: 259 additions & 104 deletions ehtim/imager.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions ehtim/imaging/multifreq_imager_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,24 @@ def pack_mftuple(mftuple, mf_solve = (1,1,0)):

return vec

def embed(im, mask, clipfloor=0., randomfloor=False):
"""Embeds a 1d image array into the size of boolean embed mask
"""

out = np.zeros(len(mask))

# Here's a much faster version than before
out[mask.nonzero()] = im

if clipfloor != 0.0:
if randomfloor: # prevent total variation gradient singularities
out[(mask-1).nonzero()] = clipfloor * \
np.abs(np.random.normal(size=len((mask-1).nonzero())))
else:
out[(mask-1).nonzero()] = clipfloor

return out

def embed_mf(imtuple, mask, clipfloor=0., randomfloor=False):
"""Embeds a multifrequency image tuple into the size of boolean embed mask
"""
Expand Down
4 changes: 1 addition & 3 deletions ehtim/imaging/pol_imager_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def pol_imager_func(Obsdata, InitIm, Prior,
ttype (str): The Fourier transform type; options are 'fast' and 'direct'
fft_pad_factor (float): The FFT will pre-pad the image by this factor x the original size
fft_interp (int): Interpolation order for sampling the FFT
grid_conv_func (str): The convolving function for gridding; options are 'gaussian', 'pill', and 'spheroidal'
grid_prad (float): The pixel radius for the convolving function in gridding for FFTs
p_rad (float): The pixel radius for the convolving function in gridding for FFTs
clipfloor (float): The Stokes I Jy/pixel level above which prior image pixels are varied
grads (bool): If True, analytic gradients are used
Expand Down
5 changes: 4 additions & 1 deletion ehtim/io/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ def load_array_txt(filename, ephemdir='ephemeris'):
"""

tdata = np.loadtxt(filename, dtype=bytes, comments='#').astype(str)
if tdata[0][0].lower() == 'site':
tdata = tdata[1:]

path = os.path.dirname(filename)

tdataout = []
Expand Down Expand Up @@ -1290,7 +1293,7 @@ def load_obs_uvfits(filename, polrep='stokes', flipbl=False, allow_singlepol=Tru
endvis = scan['END VIS'] - 1
scantable.append([scan_start - 0.5 * scan_dur,
scan_start + 0.5 * scan_dur])
scantable = np.array(scantable * 24)
scantable = np.array(scantable) * 24

except BaseException:
print("No NX table in uvfits!")
Expand Down
14 changes: 7 additions & 7 deletions ehtim/io/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def save_obs_oifits(obs, fname, flux=1.0):

# create dictionary
union = {}
union = ehtim.io.writeData.arrayUnion(antennaNames, union)
union = ehtim.io.writeoifits.arrayUnion(antennaNames, union)

# extract the integration time
intTime = data['tint'][0]
Expand All @@ -871,8 +871,8 @@ def save_obs_oifits(obs, fname, flux=1.0):
v = data['v']

# convert antenna name strings to number identifiers
ant1 = ehtim.io.writeData.convertStrings(data['t1'], union)
ant2 = ehtim.io.writeData.convertStrings(data['t2'], union)
ant1 = ehtim.io.writeoifits.convertStrings(data['t1'], union)
ant2 = ehtim.io.writeoifits.convertStrings(data['t2'], union)

# convert times to datetime objects
# TODO: these do not correspond to the acutal times
Expand All @@ -896,13 +896,13 @@ def save_obs_oifits(obs, fname, flux=1.0):
for x in timeClosure])

# convert antenna name strings to number identifiers
biarr_ant1 = ehtim.io.writeData.convertStrings(biarr['t1'], union)
biarr_ant2 = ehtim.io.writeData.convertStrings(biarr['t2'], union)
biarr_ant3 = ehtim.io.writeData.convertStrings(biarr['t3'], union)
biarr_ant1 = ehtim.io.writeoifits.convertStrings(biarr['t1'], union)
biarr_ant2 = ehtim.io.writeoifits.convertStrings(biarr['t2'], union)
biarr_ant3 = ehtim.io.writeoifits.convertStrings(biarr['t3'], union)
antOrder = np.transpose(np.array([biarr_ant1, biarr_ant2, biarr_ant3]))

# todo: check that putting the negatives on the phase and t3phi is correct
ehtim.io.writeData.writeOIFITS(fname, obs.ra, obs.dec, obs.rf, obs.bw, intTime,
ehtim.io.writeoifits.writeOIFITS(fname, obs.ra, obs.dec, obs.rf, obs.bw, intTime,
amp, viserror, phase, viserror, u, v, ant1, ant2, dttime,
t3amp, t3amperr, t3phi, t3phierr, uClosure, vClosure, antOrder,
dttimeClosure, antennaNames, antennaDiam,
Expand Down
Loading

0 comments on commit 6b87cdc

Please sign in to comment.