Created
February 22, 2011 22:24
-
-
Save astrofrog/839560 to your computer and use it in GitHub Desktop.
Convert 2MASS ALTAS images into MJy/sr (and subtract background)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert 2MASS ATLAS images into MJy/sr, and subtract background value | |
# estimated by 2MASS pipeline. | |
# | |
# Example: | |
# | |
# >>> atlas_to_MJysr('glimpse_k_test.fits', 'glimpse_k_cal.fits') | |
# | |
import pyfits | |
import pywcs | |
import numpy as np | |
zeromag = {'j': 1594., 'h': 1024., 'k': 666.7} | |
def arcperpix(wcs): | |
return degperpix(wcs) * 3600. | |
def degperpix(wcs): | |
try: | |
pscale = np.sqrt(wcs.wcs.cd[0, 0] ** 2 + wcs.wcs.cd[1, 0] ** 2) | |
except AttributeError: | |
pscale = np.abs(wcs.wcs.cdelt[0]) | |
return pscale | |
def atlas_to_MJysr(input_file, output_file): | |
# Read in ATLAS image | |
hdu = pyfits.open(input_file)[0] | |
# Extract required values from header | |
magzp = hdu.header['MAGZP'] | |
filter = hdu.header['FILTER'] | |
skyval = hdu.header['SKYVAL'] | |
# Convert to Jy | |
image = zeromag[filter] * (hdu.data - skyval) * 10. ** (-0.4 * magzp) | |
# Convert to MJy | |
image /= 1.e6 | |
# Find pixel area | |
wcs = pywcs.WCS(hdu.header) | |
pixel_scale = arcperpix(wcs) | |
pixel_area = (pixel_scale / 206265.) ** 2. | |
# Convert to MJy/sr | |
image /= pixel_area | |
# Write out file in MJy/sr | |
pyfits.writeto(output_file, image, hdu.header, clobber=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please I want to understand something about your work. First of all, which software did you use ? is it CASA or directly terminal and this steps or from this steps can I calculate bulge's magnitude or this steps just for all galaxy?