Skip to content

Commit

Permalink
Modified Antenna Positions object initialisation
Browse files Browse the repository at this point in the history
AntennaPositions previously required either an position file or shape
Now it can also be initialised as an empty object for testing
  • Loading branch information
ronniyjoseph committed Oct 16, 2019
1 parent d7140a1 commit b56bc6e
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions radiotelescope.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ def __init__(self, load=True, path=None, shape=None, frequency_channels=None, ve


class AntennaPositions:
def __init__(self, load=True, path=None, shape='linear', verbose=False):
def __init__(self, load=True, path=None, shape=None, verbose=False):
if load:
if path == None:
raise ValueError("Specificy the antenna position path if loading position data")
else:

antenna_data = xyz_position_loader(path)
else:

if shape is not None:
antenna_data = xyz_position_creator(shape, verbose=verbose)

self.antenna_ids = antenna_data[:, 0]
self.x_coordinates = antenna_data[:, 1]
self.y_coordinates = antenna_data[:, 2]
self.z_coordinates = antenna_data[:, 3]
if load or shape is not None:
self.antenna_ids = antenna_data[:, 0]
self.x_coordinates = antenna_data[:, 1]
self.y_coordinates = antenna_data[:, 2]
self.z_coordinates = antenna_data[:, 3]
else:
self.antenna_ids = None
self.x_coordinates = None
self.y_coordinates = None
self.z_coordinates = None
return

def number_antennas(self):
Expand Down Expand Up @@ -327,29 +333,28 @@ def xyz_position_loader(path):


def xyz_position_creator(shape, verbose=False):
# type: (object) -> object
"""
Generates an array lay-out defined by input parameters, returns
x,y,z coordinates of each antenna in the array
Generates an array lay-out defined by input parameters, returns
x,y,z coordinates of each antenna in the array
shape : list of array parameters
shape[0] : string value 'square', 'hex', 'doublehex', 'linear'
shape : list of array parameters
shape[0] : string value 'square', 'hex', 'doublehex', 'linear'
'square': produces a square array
shape[1]: 1/2 side of the square in meters
shape[2]: number of antennas along 1 side
shape[3]: x position of square
shape[4]: y position of square
'square': produces a square array
shape[1]: 1/2 side of the square in meters
shape[2]: number of antennas along 1 side
shape[3]: x position of square
shape[4]: y position of square
'hex': produces a hex array
'hex': produces a hex array
'doublehex': produces a double hex array
'doublehex': produces a double hex array
'linear': produces a linear array
shape[1]: x-outeredges of the array
shape[2]: number of elements in the EW-linear array
'linear': produces a linear array
shape[1]: x-outeredges of the array
shape[2]: number of elements in the EW-linear array
"""
"""

if shape[0] == "square" or shape[0] == 'doublesquare':
if verbose:
Expand Down Expand Up @@ -455,7 +460,7 @@ def xyz_position_creator(shape, verbose=False):
return xyz_coordinates


def redundant_baseline_finder(uv_positions, baseline_direction,verbose=False):
def redundant_baseline_finder(uv_positions, baseline_direction, verbose=False):
"""
"""

Expand Down Expand Up @@ -537,4 +542,4 @@ def redundant_baseline_finder(uv_positions, baseline_direction,verbose=False):
else:
sys.exit("The given redundant baseline direction is invalid:" + \
" please use 'EW', 'ALL'")
return sorted_baselines
return sorted_baselines

0 comments on commit b56bc6e

Please sign in to comment.