Previous topic

pycrtools.simhelp

Next topic

pycrtools.stokes

This Page

pycrtools.srcfind

GPSplusOffset(startingGPS, offsetXYZ) Convert GPS position + xyz offset -> GPS position
GPStoITRF(gps)
UTMdistance(utm1, utm2)
brute(func, ranges[, args, Ns, full_output, ...]) Minimize a function over a given range by brute force.
directionBruteForcePhases(positions, phases, ...)
directionBruteForceSearch(positions, times) Given N antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave).
directionForHorizontalArray(positions, times) Given N antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave).
directionFromAllTriangles(positions, times) Make all possible N(N-1)(N-2) / 6 triangles from the antenna positions Find the direction of arrival belonging to each triangle; Average over all directions to find the best (?) estimate...
directionFromThreeAntennas(positions, times) Given three antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave).
distanceGPS_ITRF(gps, itrf)
distanceITRF(itrf1, itrf2)
findDirectionBruteAzElStandard(positions, delays) Find direction of plane wave source based on time delays measured at given positions using a brute force grid search.
findDirectionFminAzElStandard(positions, delays) Find direction of plane wave source based on time delays measured at given positions using a downhill simplex algorithm.
fmin(func, x0[, args, xtol, ftol, maxiter, ...]) Minimize a function using the downhill simplex algorithm.
greatCircleDistance(gps1, gps2) Calculate the distance along a great-circle, between 2 GPS points (long, lat) in degrees N, E Distance in meters.
latlongToUTM(lat, long)
mse(az, el, pos, times) Mean-squared error in the times for a given direction on the sky, as used in the brute force search
mseWithDistance(az, el, R, pos, times[, ...]) Mean-squared error in the times for a given direction and distance, as used in brute force or similar searches.
phaseAverage(phases) Calculates the average of an array of phases It uses vector addition, i.e.
phaseError(az, el, pos, phases, freq[, ...])
phaseErrorFromDifference(deltaPhi, freq[, ...])
phaseWrap(phases)
phasesFromDirection(positions, direction, freq)
straightLineDistanceBetweenGPSPoints(gps1, gps2)
testDirectionCalculationForThreeAntennas(...) Given antenna positions, calculate time delays for ‘every’ signal vector on the sky.
testFitMethodsWithTimingNoise(az, el, N_ant, ...) A random set of N_ant antennas is generated, and time differences are calculated for given (az, el) direction.
testForBiasFromNoisyData(n_trials, N_ant, ...) Do a number of trials with random antenna positions and random timing noise.
timeDelayAzElStandard(position, az, el) Calculate arrival time delays at a set of antennas for a signal comming from Azimuth az measured Westwards positive from North and Elevation el measured positive from 0 at the horizon to pi/2 at zenith.
timeDelaysFromDirection(positions, direction) Get time delays for antennas at given position for a given direction.
timeDelaysFromDirectionAndDistance(...) Get time delays for antennas at given position for a given direction and distance.
timeDelaysFromGPSPoint(gps, positions, ...) Get time delays for a radio signal travelling from GPS point gps to antennas at positions.
timeDelaysFromGPSPointUsingITRFConversion(...) Get time delays for a radio signal travelling from GPS point gps to antennas at positions.
timeDelaysFromGPSPointUsingUTMConversion(...) Get time delays for a radio signal travelling from GPS point gps to antennas at positions.

Find a source on the sky based on arrival times and/or phase delays in multiple antennas

Module author: Arthur Corstanje <a.corstanje@astro.ru.nl>

pycrtools.srcfind.GPSplusOffset(startingGPS, offsetXYZ)

Convert GPS position + xyz offset -> GPS position Where (x, y, z) points (east, north, up)

Linearized approximation; accurate to ~ 1 mm for x, y up to 100 m

Warning: approximating the Earth as a sphere, error up to 0.3 % is possible! However, xyz distances are consistent with greatCircleDistance when using the same Earth radius in both functions.

Required arguments:

Parameter Description
startingGPS tuple/array/list (long, lat) in degrees;
offsetXYZ array/list [x, y, z].
pycrtools.srcfind.directionBruteForceSearch(positions, times, azSteps=120, elSteps=30)

Given N antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave).

The direction is found using a ‘brute-force’ search over a grid on the sky. For each direction, the corresponding time delays are calculated using timeDelaysFromDirection(positions, direction). These are compared to the actual (measured) time delays in ‘times’. The mean-squared error (MSE) serves as a fit criterion to be minimized. The global minimum and its MSE are returned. Note that the square-root of the MSE value is useful to determine the average ‘timing noise’, i.e. the timing deviation from the plane-wave solution.

Required arguments:

Parameter Description
positions array (x1, y1, z1, x2, y2, z2, x3, y3, z3), in meters
times array (t1, t2, t3), in seconds.

Input is assumed to be Numpy arrays.

Output: (az, el, mse), in radians, and seconds-squared.

pycrtools.srcfind.directionForHorizontalArray(positions, times, ignoreZCoordinate=False)

Given N antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave).

Here, we find the direction assuming all antennas are placed in the z=0 plane. If all antennas are co-planar, the best-fitting solution can be found using a 2D-linear fit. We find the best-fitting A and B in:

t = A x + B y + C

where t is the array of times; x and y are arrays of coordinates of the antennas. The C is the overall time offset in the data, that has to be subtracted out. The optimal value of C has to be determined in the fit process (it’s not just the average time, nor the time at antenna 0).

This is done using numpy.linalg.lstsq.

The (az, el) follows from:

A = \cos(\mathrm{el}) \cos(\mathrm{az})

B = \cos(\mathrm{el}) \sin(\mathrm{az})

Required arguments:

Parameter Description
positions array (x1, y1, z1, x2, y2, z2, x3, y3, z3), in meters. NB: z_i is simply ignored but still assumed to be there!
times array (t1, t2, t3), in seconds.

Input is assumed to be Numpy arrays.

Output: (az, el), in radians, and seconds-squared.

pycrtools.srcfind.directionFromAllTriangles(positions, times)

Make all possible N(N-1)(N-2) / 6 triangles from the antenna positions Find the direction of arrival belonging to each triangle; Average over all directions to find the best (?) estimate...

pycrtools.srcfind.directionFromThreeAntennas(positions, times)

Given three antenna positions, and (pulse) arrival times for each antenna, get a direction of arrival (az, el) assuming a source at infinity (plane wave). From three antennas we get in general two solutions for the direction, unless the arrival times are out of bounds, i.e. larger than the light-time between two antennas. Usually, when the 3 antennas are in a more or less horizontal plane, one of the solutions will appear to come from below the horizon (el < 0) and can be discarded.

Required arguments:

Parameter Description
positions array (x1, y1, z1, x2, y2, z2, x3, y3, z3);
times array (t1, t2, t3).

Input is assumed to be Numpy arrays.

Output: (az1, el1, az2, el2), in radians, containing the two solutions.

pycrtools.srcfind.findDirectionBruteAzElStandard(positions, delays, Ns=100)

Find direction of plane wave source based on time delays measured at given positions using a brute force grid search.

posision should be a NumPy array of shape (nantennas, 3) where first coordinate is East, second North and third Up in meters.

delays should be a one dimensional NumPy array of length nantennas with the values in seconds.

Returns an array with Azimuth az measured Westwards positive from North and Elevation el measured positive from 0 at the horizon to pi/2 at zenith.

pycrtools.srcfind.findDirectionFminAzElStandard(positions, delays)

Find direction of plane wave source based on time delays measured at given positions using a downhill simplex algorithm.

posision should be a NumPy array of shape (nantennas, 3) where first coordinate is East, second North and third Up in meters.

delays should be a one dimensional NumPy array of length nantennas with the values in seconds.

Returns an array with Azimuth az measured Westwards positive from North and Elevation el measured positive from 0 at the horizon to pi/2 at zenith.

pycrtools.srcfind.greatCircleDistance(gps1, gps2)

Calculate the distance along a great-circle, between 2 GPS points (long, lat) in degrees N, E Distance in meters.

Taken from: http://www.movable-type.co.uk/scripts/latlong.html

pycrtools.srcfind.mse(az, el, pos, times)

Mean-squared error in the times for a given direction on the sky, as used in the brute force search

Required arguments:

Parameter Description
az Azimuth in radians
el Elevation in radians
pos Positions as in the other functions
times Times as in the other functions
pycrtools.srcfind.mseWithDistance(az, el, R, pos, times, outlierThreshold=0, allowOutlierCount=0)

Mean-squared error in the times for a given direction and distance, as used in brute force or similar searches.

Required arguments:

Parameter Description
az Azimuth in radians
el Elevation in radians
R Distance in m; reference is the 0-th element of ‘pos’ and ‘times’.
pos Positions as in the other functions
times Times as in the other functions
pycrtools.srcfind.phaseAverage(phases)

Calculates the average of an array of phases It uses vector addition, i.e. converting to exp(i phi), and summing all the complex exponentials. This corresponds to concatenating vectors in a polar plot. The angle (argument) of the sum vector is the average phase. The length of the sum vector can be used as a measure of the variance in the phases. Here we just output the average.

pycrtools.srcfind.testDirectionCalculationForThreeAntennas(positions)

Given antenna positions, calculate time delays for ‘every’ signal vector on the sky. Then, invert and calculate the signal vector from the given time delays. One out of the 2 possible solutions has to match within some floating point roundoff interval. A two-pi error may occur (and gets written out), but that’s no problem.

Example:

>>> testDirectionCalculationForThreeAntennas(np.array([0, 0, 0, 23, -21, 54, 11, 21, 33]))
Wrong value for az: 0.0 calculated: 195.081863616 or: 360.0
el: 18.0 calculated: 60.2318806131 or: 18.0
Wrong value for az: 0.0 calculated: 196.898077333 or: 360.0
el: 24.0 calculated: 66.1764021336 or: 24.0
Wrong value for az: 0.0 calculated: 285.811432122 or: 360.0
el: 48.0 calculated: 86.4889718066 or: 48.0
Wrong value for az: 0.0 calculated: 358.619827389 or: 360.0
el: 66.0 calculated: 71.2661264901 or: 66.0
Wrong value for az: 0.0 calculated: 360.0 or: 1.33942285143
el: 72.0 calculated: 72.0 or: 65.3494016156
Wrong value for az: 0.0 calculated: 360.0 or: 3.05501838316
el: 78.0 calculated: 78.0 or: 59.4017926229
pycrtools.srcfind.testFitMethodsWithTimingNoise(az, el, N_ant, noiselevel)

A random set of N_ant antennas is generated, and time differences are calculated for given (az, el) direction. Then, for the 3 different fit methods, the result is calculated back. This is done without noise (should return the input), and with noise

Required arguments:

Parameter Description
az Azimuth
el Elevation
N_ant Number of antennae
noiselevel as a fraction of the max time difference across the antennas, e.g. 0.1
pycrtools.srcfind.testForBiasFromNoisyData(n_trials, N_ant, az, el, noiselevel, fitType='LinearFit')

Do a number of trials with random antenna positions and random timing noise. Put in the given (az, el) direction, see what comes out of the fits. By averaging over these trials, we can see if the fit result is biased or not.

Required arguments:

Parameter Description
n_trials  
N_ant  
az  
el  
noiselevel as a fraction of the max time difference across the antennas, e.g. 0.1
fitType [‘LinearFit’ (default)|’BruteForce’|’Triangles’]

Output is printed.

pycrtools.srcfind.timeDelayAzElStandard(position, az, el)

Calculate arrival time delays at a set of antennas for a signal comming from Azimuth az measured Westwards positive from North and Elevation el measured positive from 0 at the horizon to pi/2 at zenith.

posision should be a NumPy array of shape (nantennas, 3) where first coordinate is East, second North and third Up in meters.

Returns time delays in seconds.

pycrtools.srcfind.timeDelaysFromDirection(positions, direction)

Get time delays for antennas at given position for a given direction. Time delays come out as an np-array.

Required arguments:

Parameter Description
positions (np-array x1, y1, z1, x2, y2, z2, ...)
direction (az, el) in radians.

Example:

>>> pos = np.array([0, 0, 0, 23, -21, 54, 11, 21, 33])
>>> dir = (1.2, 0.7)
>>> timeDelaysFromDirection(pos, dir)
array([ -0.00000000e+00,  -8.73671261e-08,  -1.31017019e-07])
pycrtools.srcfind.timeDelaysFromDirectionAndDistance(positions, direction)

Get time delays for antennas at given position for a given direction and distance. Time delays come out as an np-array.

Required arguments:

Parameter Description
positions (np-array x1, y1, z1, x2, y2, z2, ...)
direction (az, el, R) in radians, meters.

Example:

>>> pos = np.array([0, 0, 0, 23, -21, 54, 11, 21, 33])
>>> dir = (1.2, 0.7)
>>> timeDelaysFromDirection(pos, dir)
array([ -0.00000000e+00,  -8.73671261e-08,  -1.31017019e-07])
pycrtools.srcfind.timeDelaysFromGPSPoint(gps, positions, antids, antennaset)

Get time delays for a radio signal travelling from GPS point gps to antennas at positions. The antenna ids are needed for identifying the station it belongs to.

Required arguments:

Parameter Description
gps array / list / tuple (long, lat)
positions (np-array x1, y1, z1, x2, y2, z2, ...)
antids Array or list of antenna ids
antennaset e.g. ‘LBA_OUTER’
pycrtools.srcfind.timeDelaysFromGPSPointUsingITRFConversion(gps, positions_itrf)

Get time delays for a radio signal travelling from GPS point gps to antennas at positions. Returns time delays array per antenna

pycrtools.srcfind.timeDelaysFromGPSPointUsingUTMConversion(gps, positions, antennaset)

Get time delays for a radio signal travelling from GPS point gps to antennas at positions. Returns time delays array per antenna