from __future__ import absolute_import
from numpy import cos, sin, sqrt
import scipy.optimize as optimize
import scipy.special as spspec
from casatasks import casalog
from casatools import quanta
The class to derive the theoretical beam size of an image.
bu = sdbeamutil.TheoreticalBeam()
# set imaging, antenna, and pointing informations
bu.set_antenna('12m',blockage='0.75m',taper=10)
bu.set_sampling(['12arcsec','12arcsec'])
bu.set_image_param('5arcsec', '115GHz','SF', 6, -1, -1, -1)
# print summary of setup to logger
# get theoretical beam size of an image.
beam = bu.get_beamsize_image()
self.is_antenna_set = False
self.is_kernel_set = False
self.is_sampling_set = False
self.antenna_diam_m = -1.
self.antenna_block_m = 0.0
self.sampling_arcsec = []
def __to_arcsec_list(self, angle):
"""Return a list of angles in arcsec (value only without unit)."""
if type(angle) not in [list, tuple, np.ndarray]:
return [self.__to_arcsec(val) for val in angle]
def __to_arcsec(self, angle):
"""Convert angle to arcsec and return the value without unit."""
return my_qa.getvalue(my_qa.convert(angle, "arcsec"))[0]
elif my_qa.getunit(angle) == '':
raise ValueError("Invalid angle: %s" % (str(angle)))
def __parse_width(self, val, cell_size_arcsec):
"""Convert value in unit of arcsec.
If val is angle, returns a float value in unit of arcsec.
else the unit is assumed to be pixel and multiplied by cell_size_arcsec
return self.__to_arcsec(val)
elif my_qa.getunit(val) in ('', 'pixel'):
return my_qa.getvalue(val) * cell_size_arcsec
raise ValueError("Invalid width %s" % str(val))
def set_antenna(self, diam, blockage="0.0m", taper=10):
"""Set parameters to construct antenna beam.
antenna diameter and blockage
taper: the illumination taper in dB
self.antenna_diam_m = my_qa.getvalue(my_qa.convert(diam, "m"))[0]
self.antenna_block_m = my_qa.getvalue(my_qa.convert(blockage, "m"))[0]
self.is_antenna_set = True
def set_sampling(self, intervals, pa="0deg"):
"""Set sampling interval of observation.