Skip to content

Commit 3ec1951

Browse files
committed
Updated smooth_amps.py to version from master branch.
1 parent de4d8a2 commit 3ec1951

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

factor/scripts/smooth_amps.py

100755100644
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def main(instrument_name, instrument_name_smoothed):
8484
for chan in range(nchans):
8585
real = numpy.copy(parms[gain + ':' + pol + ':Real:'+ antenna]['values'][:, chan])
8686
imag = numpy.copy(parms[gain + ':' + pol + ':Imag:'+ antenna]['values'][:, chan])
87-
88-
phase = numpy.arctan2(imag,real)
87+
phase = numpy.arctan2(imag, real)
8988
amp = numpy.sqrt(imag**2 + real**2)
9089

9190
amp = numpy.log10(amp)
@@ -115,8 +114,17 @@ def main(instrument_name, instrument_name_smoothed):
115114
for antenna in antenna_list:
116115
real = numpy.copy(parms[gain + ':' + pol + ':Real:'+ antenna]['values'][:, chan])
117116
imag = numpy.copy(parms[gain + ':' + pol + ':Imag:'+ antenna]['values'][:, chan])
118-
parms[gain + ':' + pol + ':Real:'+ antenna]['values'][:, chan] = numpy.copy(real*norm_factor)
119-
parms[gain + ':' + pol + ':Imag:'+ antenna]['values'][:, chan] = numpy.copy(imag*norm_factor)
117+
phase = numpy.arctan2(imag, real)
118+
amp = numpy.copy(numpy.sqrt(real**2 + imag**2))
119+
120+
# Clip extremely low amplitude solutions to prevent very high ampllitudes
121+
low_ind = numpy.where(amp < 0.2)
122+
amp[low_ind] = 0.2
123+
124+
parms[gain + ':' + pol + ':Real:'+ antenna]['values'][:, chan] = numpy.copy(amp *
125+
numpy.cos(phase) * norm_factor)
126+
parms[gain + ':' + pol + ':Imag:'+ antenna]['values'][:, chan] = numpy.copy(amp *
127+
numpy.sin(phase) * norm_factor)
120128

121129
if os.path.exists(instrument_name_smoothed):
122130
shutil.rmtree(instrument_name_smoothed)

0 commit comments

Comments
 (0)