hCoordinateConvert(source, sourceCoordinate, target, targetCoordinate, anglesInDegrees)
Converts a 3D spatial vector into a different Coordinate type (e.g. Spherical to Cartesian).
Parameters
source Coordinates of the source to be converted - vector of length 3 sourceCoordinate Type of the coordinates for the source target Coordinates of the source to be converted - vector of length 3 targetCoordinate Type of the coordinates for the target (output vector) anglesInDegrees True if the angles are in degree, otherwise in radians
Description
Available Coordinate Types are:
AzElHeight Azimuth-Elevation-Height AzElRadius Azimuth-Elevation-Radius Cartesian Cartesian coordinates Cylindrical Cylindrical coordinates Direction Direction on the sky DirectionRadius Direction on the sky with radial distance Frquency Frequency LongLatRadius Longitude-Latitude-Radius NorthEastHeight North-East-Height Spherical Spherical coordinates Time Time Precede the Coordinate Types by CoordinateTypes., i.e., CoordinateTypes.AzElRadius.
Example
hCoordinateConvert(meandirection,CoordinateTypes.AzElRadius,azelr,CoordinateTypes.Cartesian,False)
hCImageFromCCM(image, ccm, weights, nofAntennas, nfreq)
Calculates a single complex pixel or a pixel vector (i.e., an image), from an cross correlation matrix and complex geometrical weights for each antenna by multiplying ccm and weights and summing over all baselines.
Parameters
image Image vector containing N_freq frequency bins in the order [power(pix0,bin0), power(pix0,bin1), ..., power(pix1,bin0), ...]. Size of vector is N_pixel * N_bins ccm Upper half of the cross-correlation matrix (input) containing complex visibilities as a function of frequency. The ordering is ant0 * ant1, ant0 * ant2, ..., ant1 * ant2, ... - where each antN contains nfreq frequency bins. weights Vector containing the weights to be applied for each pixel, antenna, and frequency bin (in that order, i.e. frequency index runs fastest). nofAntennas Number of antennas used for weights and ccm nfreq Number of frequency bins used for weights and ccm
Description
The image contains the power as a function of pixel and frequency bins. Each value is the sum over all baselines of the norm of the complex visibilities times complex weights for that pixel and frequency bin.
The results will be added to the image, hence for a new image the image must be initialized to 0! Otherwise an old image can be provided and the new data will simply be added to it.
The length of the ccm vector is (N-1)/2*N_freq, where N is the number of antennas and N_freq the number of frequency bins per antenna. The length of the weights vector is N_pixel*N_ant*N_freq.
Usage
hCrossCorrelationMatrix(ccm,fftdata,nfreq) -> ccm = ccm(old) + ccm(fftdata)
Example
>>> ccm=Vector(complex,file['nofSelectedAntennas']*(file['nofSelectedAntennas']-1)/2*file['fftLength'])
>>> cimage=Vector(complex,n_pixels*nbins,fill=0)
>>> image=hArray(float,[n_pixels,file['fftLength']])
>>> hCrossCorrelationMatrix(ccm,file_fft.vec(),file['fftLength'])
>>> hCImageFromCCM(cimage,ccm,weights.vec(),file['nofSelectedAntennas'],file['fftLength'])
>>> cimage.norm(image.vec())
>>> intimage=np.array(image[...].sum()) # convert to numpy array
>>> immax=intimage.max()
>>> intimage /= immax
>>> intimage.resize([n_az,n_el])
>>> plt.imshow(intimage,cmap=plt.cm.hot)
hDelayToPhase(vec, frequencies, delays)
Coverts a vector of time delays and a vector of frequencies to a corresponding vector of phases (of a complex number).
Parameters
vec Output vector returning real phases of complex numbers frequencies Input vector with real delays in units of time [second] delays Input vector with real delays in units of time [second]
Description
The frequencies always run fastest in the output vector. If input vectors are shorter they will be wrapped until the output vector is full.
Usage
hDelayToPhase(vec,frequencies,delays) -> vec = [phase(frequencies_0,delays_0),phase(frequencies_1,delays_0),...,phase(frequencies_n,delays_0),phase(frequencies_1,delays_1),...]
hDelayToWeight(vec, frequencies, delays)
Coverts a vector of time delays and a vector of frequencies to a corresponding vector of weights.
Parameters
vec Output vector returning real phases of complex numbers frequencies Input vector with real delays in units of time [second] delays Input vector with real delays in units of time [second]
Description
The frequencies always run fastest in the output vector. If input vectors are shorter they will be wrapped until the output vector is full.
Usage
hDelayToWeight(vec,frequencies,delays) -> vec = [phase(frequencies_0,delays_0),phase(frequencies_1,delays_0),...,phase(frequencies_n,delays_0),phase(frequencies_1,delays_1),...]
hGeometricDelayFarField(antPosition, skyDirection, length)
Calculates the time delay in seconds for a signal received at an antenna position relative to a phase center from a source located in a certain direction in farfield (based on L. Bahren).
Parameters
antPosition Cartesian antenna positions (Meters) relative to a reference location (phase center) - vector of length 3 skyDirection Vector in Cartesian coordinates pointing towards a sky position from the antenna - vector of length 3 length Length of the skyDirection vector, used for normalization - provided to speed up calculation
hGeometricDelayNearField(antPosition, skyPosition, distance)
Calculates the time delay in seconds for a signal received at an antenna position relative to a phase center from a source located at a certain 3D space coordinate in nearfield (based on L. Bahren).
Parameters
antPosition Cartesian antenna positions [meter]) relative to a reference location (phase center) - vector of length 3 skyPosition Vector in Cartesian coordinates [meter] pointing towards a sky location, relative to phase center - vector of length 3 distance Distance of source, i.e. the length of skyPosition - provided to speed up calculation
hGeometricDelays(delays, antPositions, skyPositions, farfield)
Calculates the time delay in seconds for signals received at various antenna positions relative to a phase center from sources located at certain 3D space coordinates in near or far field.
Parameters
delays Output vector containing the delays in seconds for all antennas and positions [antenna index runs fastest: (ant1, pos1), (ant2,pos1), ...] - length of vector has to be number of antennas times positions antPositions Cartesian antenna positions [meter] relative to a reference location (phase center) - vector of length number of antennas times three skyPositions Vector in Cartesian coordinates [meter] pointing towards a sky location, relative to phase center - vector of length number of skypositions times three farfield Calculate in farfield approximation if true, otherwise do near field calculation
Example
>>> result=[]
>>> plt.clf()
>>> for j in range(29,30):
>>> x=[]
>>> y=[]
>>> for i in range(177,178):
>>> azel[0]=float(i)
>>> azel[1]=float(j)
>>> hCoordinateConvert(azel,CoordinateTypes.AzElRadius,cartesian,CoordinateTypes.Cartesian,True)
>>> hGeometricDelays(delays,antenna_positions,hArray(cartesian),True)
>>> delays *= 10^6
>>> deviations=delays-obsdelays
>>> deviations.abs()
>>> sum=deviations.vec().sum()
>>> x.append(i)
>>> y.append(sum)
>>> result.append(y)
>>> plt.plot(x,y)
hGeometricPhases(phases, frequencies, antPositions, skyPositions, farfield)
Calculates the phase gradients for signals received at various antenna positions relative to a phase center from sources located at certain 3D space coordinates in near or far field and for different frequencies.
Parameters
phases Output vector containing the phases in radians for all frequencies, antennas and positions [frequency index, runs fastest, then antenna index: (nu1, ant1, pos1), (nu2, ant1, pos1), ...] - length of vector has to be number of antennas times positions time frequency bins frequencies Vector of frequencies [Hz] to calculate phases for antPositions Cartesian antenna positions [meter] relative to a reference location (phase center) - vector of length number of antennas times three skyPositions Vector in Cartesian coordinates [meter] pointing towards a sky location, relative to phase center - vector of length number of skypositions times three farfield Calculate in farfield approximation if true, otherwise do near field calculation
hGeometricWeights(weights, frequencies, antPositions, skyPositions, farfield)
Calculates the phase gradients as complex weights for signals received at various antenna positions relative to a phase center from sources located at certain 3D space coordinates in near or far field and for different frequencies.
Parameters
weights Output vector containing the phases in radians for all frequencies, antennas and positions [frequency index, runs fastest, then antenna index: (nu1, ant1, pos1), (nu2, ant1, pos1), ...] - length of vector has to be number of antennas times positions time frequency bins frequencies Vector of frequencies [Hz] to calculate phases for antPositions Cartesian antenna positions [meter] relative to a reference location (phase center) - vector of length number of antennas times three skyPositions Vector in Cartesian coordinates [meter] pointing towards a sky location, relative to phase center - vector of length number of skypositions times three farfield Calculate in farfield approximation if true, otherwise do near field calculation
hWorld2Pixel(pixel, world, refcode, projection, refLong, refLat, incLon, incLat, refX, refY)
Get pixel coordinates for given vector of world coordinates
Parameters
pixel Pixel coordinates world World coordinates refcode reference code for coordinate system e.g. AZEL,``J2000``, ... projection the projection used e.g. SIN`, ``STG, ... refLong reference value for longtitude (CRVAL) refLat reference value for latitude (CRVAL) incLon incLon increment value for longtitude (CDELT) incLat incLon increment value for latitude (CDELT) refX refX reference -pixel (CRPIX)
refY refY reference -pixel (CRPIX)
hPixel2World(world, pixel, refcode, projection, refLong, refLat, incLon, incLat, refX, refY, lonPole, latPole)
Get world coordinates for given vector of pixel coordinates.
Parameters
world World coordinates pixel Pixel coordinates refcode reference code for coordinate system e.g. AZEL, J2000, ... projection the projection used e.g. SIN, STG, ... refLong reference value for longtitude (CRVAL) refLat reference value for latitude (CRVAL) incLon incLon increment value for longtitude (CDELT) incLat incLon increment value for latitude (CDELT) refX refX reference - pixel (CRPIX)
refY refY reference -pixel (CRPIX)
lonPole (LONPOLE) latPole (LATPOLE)
hEquatorial2Horizontal(hc, ec, utc, ut1_utc, L, phi)
Convert array of equatorial J2000 coordinates to horizontal, AZEL coordinates.
Parameters
hc array with horizontal coordiates [radians] (alt, az, alt, az, ...) altitude positive eastwards from north. ec array with equatorial coordinates [radians] (ra, dec, ra, dec, ...). utc UTC as Julian Day. ut1_utc difference UT1-UTC (as obtained from IERS bulletin A) if 0 a maximum error of 0.9 seconds is made. L longitude of telescope [radians]. L is observer’s longitude (positive east, negative west of Greenwhich). phi latitude of telescope [radians].
hBeamformImage(image, fftdata, frequencies, antpos, skypos)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y.
hBeamformImage(image, fftdata, frequencies, delays)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)], e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. delays Array containing the delays [s] for all antennas and positions (antenna index runs fastest: (ant1, pos1), (ant2, pos1), ...) - length of vector has to be number of antennas times positions as calculated by hGeometricDelays().
hBeamformImage(image, fftdata, frequencies, antpos, skypos, step)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y. step Array with steps to take for stepping though the frequency channels (used to efficiently skip bad channels).
hBeamformImage(image, fftdata, frequencies, antpos, skypos)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y.
hBeamformImage(image, fftdata, frequencies, delays)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)], e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. delays Array containing the delays [s] for all antennas and positions (antenna index runs fastest: (ant1, pos1), (ant2, pos1), ...) - length of vector has to be number of antennas times positions as calculated by hGeometricDelays().
hBeamformImage(image, fftdata, frequencies, antpos, skypos, step)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y. step Array with steps to take for stepping though the frequency channels (used to efficiently skip bad channels).
hBeamformImage(image, fftdata, frequencies, antpos, skypos)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y.
hBeamformImage(image, fftdata, frequencies, delays)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)], e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. delays Array containing the delays [s] for all antennas and positions (antenna index runs fastest: (ant1, pos1), (ant2, pos1), ...) - length of vector has to be number of antennas times positions as calculated by hGeometricDelays().
hBeamformImage(image, fftdata, frequencies, antpos, skypos, step)
Beamform image
Parameters
image Array to store resulting image. Stored as [I(x_0, y_0, f_0), I(x_0, y_0, f_1), ... I(x_nx, y_ny, f_nf)] e.g. the rightmost (frequency) index runs fastest. This array may contain an existing image. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky positions in the local cartesian frame [Hz]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_np, y_np, z_np] where np is the number of pixels in the image. Storage order for the pixels is the same as for the image e.g. runs faster in y. step Array with steps to take for stepping though the frequency channels (used to efficiently skip bad channels).
hDedispersionShifts(shifts, frequencies, reference, dm, dt)
Generate shifts for dedispersion
Parameters
shifts Shifts. frequencies Frequencies in Hz. reference Reference frequency in Hz. dm Dispersion Measure. dt Time sampling step in seconds.
hBeamformBlock(out, fftdata, frequencies, antpos, skypos)
Beamform block
Parameters
out Beamformer output. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky position in the local cartesian frame [Hz]. Stored as [x, y, z].
hBeamformBlock(out, fftdata, frequencies, delays)
Beamform block
Parameters
out Beamformer output. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. delays Array containing the delays [s] for all antennas
hBeamformBlock(out, fftdata, frequencies, antpos, skypos)
Beamform block
Parameters
out Beamformer output. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. antpos Array with antenna positions in the local Cartesian frame [meter]. Stored as [x_0, y_0, z_0, x_1, y_1, z_1, ... x_na, y_na, z_na] where na is the number of antennas. skypos Array with sky position in the local cartesian frame [Hz]. Stored as [x, y, z].
hBeamformBlock(out, fftdata, frequencies, delays)
Beamform block
Parameters
out Beamformer output. fftdata Array with FFT data of each antenna. Expects data to be stored as [f(0,0), f(0,1), ..., f(0,nf), f(1,0), f(1,1), ..., f(1,nf), ..., f(na, 0), f(na,1), ..., f(na,nf)] e.g. f(i,j) where i is the antenna number and j is the frequency. frequencies Array with frequencies [Hz] stored as [f_0, f_1, ..., f_n]. delays Array containing the delays [s] for all antennas
hFrequencyIntegratedImage(out, in)
Calculates the square of the absolute value and add it to output vector.
Parameters
out Numpy vector in Input vector