Esempio n. 1
0
                     c.antloc[int(c.ublindex[u][~mask, 0][0])]).tolist()
            bindex = bindex + [[a, int(c.ublindex[u][~mask, 2][0])]
                               for a in c.ublindex[u][~mask, 2].astype(int)
                               ]  #inside crossindex
A = np.array(A)[:, :2]
A = np.concatenate((A, -A), axis=0)
bindex = c.subsetbl[c.crossindex[np.array(bindex).astype(int)]]  #inside all bl

b = np.empty((len(A), rawdata.shape[1], rawdata.shape[2]), dtype='float32')
for p, pol in enumerate(crosspols.keys()):
    b[p * len(bindex):(p + 1) *
      len(bindex)] = (np.angle(rawdata[p][..., bindex[:, 0]]) -
                      np.angle(rawdata[p][..., bindex[:, 1]])).transpose(
                          (2, 0, 1))

crosstimer = omni.Timer()
print "Solving cross calibration....",
sys.stdout.flush()
sol = omni.solve_slope(A, b, 1)
sol[:, flags['xx']] = np.nan
sol[:, flags['yy']] = np.nan
median_sol = np.array([nanmedian(sol[i]) for i in range(len(sol))])
print "Done.",
sys.stdout.flush()
crosstimer.tick()
if make_plots:
    for i in range(len(sol)):
        plt.subplot('21%i' % (i + 1))
        min_period = TPI / min(abs(A[:, i][abs(A[:, i]) > 1]))
        plt.imshow((sol[i] + min_period / 2.) % min_period - min_period / 2.)
        plt.colorbar()
Esempio n. 2
0
####calibrate################
##print FILENAME + " MSG: starting calibration."
for p, calibrator in zip(range(len(wantpols)), calibrators):
	data = np.concatenate([data[p] for i in range(1)], axis = 0)
	calibrator.removeDegeneracy = removedegen
	calibrator.removeAdditive = removeadditive
	calibrator.keepData = keep_binary_data
	calibrator.keepCalpar = keep_binary_calpar
	calibrator.convergePercent = converge_percent
	calibrator.maxIteration = max_iter
	calibrator.stepSize = step_size
	calibrator.computeUBLFit = False
	#print data[0,120:132,0]
	times = []
	nthreads = range(1, 26) + range(30,60,10)
	for nthread in nthreads:
		timer = omni.Timer()
		calibrator.logcal(data, np.zeros_like(data), nthread = nthread, verbose=False)
		#timer.tick()
		calibrator.lincal(data, np.zeros_like(data), nthread = nthread, verbose=False)
		times += [list((nthread,) + timer.tick(nthread))]
		if nthread == 1:
			correct_calpar = np.copy(calibrator.rawCalpar)
		else:
			np.testing.assert_array_equal(correct_calpar, calibrator.rawCalpar)
times = np.array(times)
plt.plot(nthreads, times[:, 1])
plt.plot(nthreads, times[1, 1] * 2/np.array(nthreads))
plt.show()
Esempio n. 3
0
#!/usr/bin/env python

import aipy as ap
import numpy as np
import commands, os, time, math, ephem, optparse, sys, warnings
import omnical.calibration_omni as omni
import cPickle as pickle
import scipy.signal as ss
import scipy.ndimage.filters as sfil
from scipy import interpolate
FILENAME = "omnical_PSA128.py"
print "#Omnical Version %s#" % omni.__version__
PI = np.pi
TPI = 2 * np.pi
TIMER = omni.Timer()
######################################################################
##############Config parameters###################################
######################################################################
o = optparse.OptionParser()

#ap.scripting.add_standard_options(o, cal=True, pol=True)
o.add_option('-t',
             '--tag',
             action='store',
             default='PSA128',
             help='tag name of this calibration')
o.add_option('-C',
             '--cal',
             action='store',
             default=None,
             help='calfile for processing uv files')