def get_skymodel(self, freq=None): """ """ sky = Table.read(self.skymodel_file) all_coords = radec(sky['ra'], sky['dec']) phase_center = radec(self.ra, self.dec) sep = all_coords.separation(phase_center).deg infield_mask = sep <= self.radius infield_sky = sky[infield_mask] flux = self._extrapol_spec(freq=freq, rflux=infield_sky['flux'], rfreq=infield_sky['rfreq'], index=infield_sky['index']) fluxmask = flux >= self.cutoff infield_sky = infield_sky[fluxmask] flux = flux[fluxmask] names = np.zeros(len(infield_sky), dtype=str) skymodel = np.zeros((len(infield_sky), 3)) for i in range(len(infield_sky)): names[i] = infield_sky['name'][i] skymodel[i, 0] = flux[i] skymodel[i, 1] = infield_sky['ra'][i] skymodel[i, 2] = infield_sky['dec'][i] return skymodel, names
def _ateam_in_fov(self): """ """ at = ateam() infield = {} for key in at.keys(): src_radec = radec(ra=at[key][0], dec=at[key][1]) sep = self.center.separation(src_radec).deg if sep <= self.radius: infield[key] = src_radec return infield
def __init__(self, center, radius, freq, method='gsm', cutoff=100.): self.center = radec(ra=center[0], dec=center[1]) self.radius = radius self.frequency = freq self.cutoff = cutoff # in Jy if method.lower() == 'manual': self.sources = self._ateam_in_fov() self.fluxes = self._ateam_flux() for key in self.sources['key']: if self.fluxes[key] < self.cutoff: del self.sources[key] del self.fluxes[key] elif method.lower() == 'gsm': self.gsmfile = '' self.sources, self.fluxes = self.from_gsm()
def from_gsm(self): """ NEED TO EXTRAPOLATE AT THE RIGHT FREQUENCY CURRENTLY OK FOR 60 MHz """ if not isfile(self.gsmfile): self.save_from_gsm() infield = {} command = [ 'https://lcs165.lofar.eu/cgi-bin/gsmv1.cgi?', 'coord=' + str(self.center.ra.deg), ',' + str(self.center.dec.deg), '&radius=' + str(self.radius), '&cutoff=' + str(self.cutoff), '&unit=deg&deconv=y', ] url = ''.join(command) with urlopen(url) as response: response = response.read().decode('utf8') sources = response.split('\n')[3:] infield = {} fluxes = {} for source in sources: if source == '': continue src_desc = source.split(', ') src_name = src_desc[0] fluxes[src_name] = float(src_desc[4]) src = radec_hd(src_desc[2] + ' ' + src_desc[3].replace('.', ':', 2)) infield[src_name] = radec(ra=src.ra.deg, dec=src.dec.deg) ref_freq = float(src_desc[8]) if src_desc[8] != '' else 60e6 spec_index = float(src_desc[9].replace('[', '').replace(']', '')) return infield, fluxes