Skip to content

Commit

Permalink
Use taql + mscal instead of virtual columns
Browse files Browse the repository at this point in the history
This fixes #174. Using virtual columns is not advised, since it changes
the measurement set. The taql call with the use of mscal calls exactly
the same functions but without changing the MS.
  • Loading branch information
tammojan committed Oct 16, 2018
1 parent 88d3b2a commit 6629385
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
17 changes: 4 additions & 13 deletions scripts/InitSubtract_deep_sort_and_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,14 @@ def get_image_sizes(self, cellsize_highres_deg=None, cellsize_lowres_deg=None,
self.cellsize_lowres_deg = cellsize_lowres_deg
if not hasattr(self, 'mean_el_rad'):
for MS_id in xrange(self.numMS):
# Add (virtual) elevation column to MS
try:
pt.addDerivedMSCal(self.files[MS_id])
except RuntimeError:
# RuntimeError indicates column already exists
pass

# calculate mean elevation
tab = pt.table(self.files[MS_id], ack=False)
el_values = pt.taql("SELECT mscal.azel1()[1] AS el from "
+ self.files[MS_id] + " limit ::10000").getcol("el")
if MS_id == 0:
global_el_values = tab.getcol('AZEL1', rowincr=10000)[:, 1]
global_el_values = el_values
else:
global_el_values = np.hstack( (global_el_values, tab.getcol('AZEL1', rowincr=10000)[:, 1]) )
tab.close()

# Remove (virtual) elevation column from MS
pt.removeDerivedMSCal(self.files[MS_id])
global_el_values = np.hstack( (global_el_values, el_values ) )
self.mean_el_rad = np.mean(global_el_values)

# Calculate mean FOV
Expand Down
17 changes: 4 additions & 13 deletions scripts/InitSubtract_sort_and_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,14 @@ def get_image_sizes(self, cellsize_highres_deg=None, cellsize_lowres_deg=None,
self.cellsize_lowres_deg = cellsize_lowres_deg
if not hasattr(self, 'mean_el_rad'):
for MS_id in xrange(self.numMS):
# Add (virtual) elevation column to MS
try:
pt.addDerivedMSCal(self.files[MS_id])
except RuntimeError:
# RuntimeError indicates column already exists
pass

# calculate mean elevation
tab = pt.table(self.files[MS_id], ack=False)
el_values = pt.taql("SELECT mscal.azel1()[1] AS el from "
+ self.files[MS_id] + " limit ::10000").getcol("el")
if MS_id == 0:
global_el_values = tab.getcol('AZEL1', rowincr=10000)[:, 1]
global_el_values = el_values
else:
global_el_values = np.hstack( (global_el_values, tab.getcol('AZEL1', rowincr=10000)[:, 1]) )
tab.close()

# Remove (virtual) elevation column from MS
pt.removeDerivedMSCal(self.files[MS_id])
global_el_values = np.hstack( (global_el_values, el_values ) )
self.mean_el_rad = np.mean(global_el_values)

# Calculate mean FOV
Expand Down

0 comments on commit 6629385

Please sign in to comment.