def __init__(self, imagefile): """ imagefile: name of the fits file """ Image.__init__(self, imagefile) self.region = None self.region_noise = None self.hdu = fits.PrimaryHDU(self.img_data, self.img_hdr) # calculate beam area in pixels cd1 = abs(self.img_hdr['CDELT1']) cd2 = abs(self.img_hdr['CDELT2']) bmaj = self.img_hdr['BMAJ'] bmin = self.img_hdr['BMAJ'] if ((cd1 - cd2) / cd1) > 1.0001 and ((bmaj - bmin) / bmin) > 1.0001: raise RadioError( 'Pixels are not square (%g, %g) and beam is elliptical' % (cd1, cd2)) gfactor = 2.0 * np.sqrt(2.0 * np.log(2.0)) self.barea = 2.0 * np.pi * (bmaj / cd1 * bmin / cd2) / ( gfactor * gfactor) # in pixels logging.info('Beam area is', self.barea, 'pixels') self.masks = []
def __init__(self, imagefile): logging.debug('Create direction for %s' % imagefile) Image.__init__(self, imagefile) self.scale = 1. self.shift = 0. self.beamfile = None self.noise = 1. self.imagefile = imagefile
sys.exit(1) if args.radec is not None and len(args.radec) != 2: logging.error('--radec must be in the form of "RA DEC" (2 floats).') sys.exit(1) from lib_fits import Image, find_freq if __name__ == '__main__': ######################################################## # prepare images and make catalogues if necessary all_images = [] all_errors = [] all_beams = [] for imagefile in args.images: image = Image(imagefile) all_beams.append(image.get_beam()) all_images.append(image) si_err_image = imagefile.replace('.fits', '-err.fits') if os.path.isfile(si_err_image): err_image = Image(si_err_image) assert err_image.get_beam() == image.get_beam() all_errors.append(err_image) else: raise FileNotFoundError( f'SI error image {si_err_image} does not exist.') ##################################################### # find the smallest common beam if args.beam is None: if args.circbeam: maxmaj = np.max([b[0] for b in all_beams])
def __init__(self, imagefile): Image.__init__(self, imagefile)
# -*- coding: utf-8 -*- # # Copyright (C) 2019 - Francesco de Gasperin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # reg2fits.py reg img.fits from lib_fits import Image import os, sys im = Image(sys.argv[2]) regionfile = sys.argv[1] im.apply_region(regionfile, blankvalue=1, invert=False) im.apply_region(regionfile, blankvalue=0, invert=True) im.write(sys.argv[1].replace('reg', 'fits'))
# -*- coding: utf-8 -*- # # Copyright (C) 2019 - Francesco de Gasperin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # reg2fits.py reg img.fits from lib_fits import Image import os, sys im = Image(sys.argv[2]) regionfile = sys.argv[1] im.apply_region(regionfile, blankvalue=1, invert=False) im.apply_region(regionfile, blankvalue=0, invert=True) im.write(sys.argv[1].replace('reg','fits'))