# -*- 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'))
'-regrid-conv.fits') and not args.force: data, hdr = pyfits.getdata(image.imagefile + '-regrid-conv.fits', 0, header=True) image.img_data = data image.img_hdr = hdr image.set_beam([hdr['BMAJ'], hdr['BMIN'], hdr['BPA']]) else: image.regrid(regrid_hdr) if args.save: image.write(image.imagefile + '-regrid-conv.fits', inflate=True) if args.region is not None: image.apply_region( args.region, invert=True) # after convolution to minimise bad pixels ######################################################### # do curvature and write output curv_data = (all_images[0].img_data - all_images[1].img_data) # not 100% sure if this is correct, probably the two SI errors can be correlated... curv_err_data = (all_errors[0].img_data**2 + all_errors[1].img_data**2)**0.5 # SI data might contain upper limits! Set to nan where error is not defined! curv_data[np.isnan(curv_err_data)] = np.nan curv = pyfits.PrimaryHDU(curv_data, regrid_hdr) curv_err = pyfits.PrimaryHDU(curv_err_data, regrid_hdr) curv.writeto(args.output, overwrite=True) curv_err.writeto(args.output.replace('.fits', '-err.fits'), overwrite=True)
# -*- 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'))