{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from astropy.io import fits" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### READ IN IMAGE, SET UP GRID OF XY COORDINATES" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Download the image from the course website using this link\n", "# http://burro.case.edu/Academics/Astr306/HW/HW3/M84.fits\n", "imname='M84.fits'\n", "imhdr=fits.getheader(imname)\n", "imdata=fits.getdata(imname)\n", "X, Y = np.meshgrid( np.arange(1,imhdr['NAXIS1']+1) ,\n", " np.arange(1,imhdr['NAXIS2']+1) )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### DECIDE ON CENTER PIXEL, CALCULATE DISTANCE (IN PIXELS) OF ALL OTHER PIXELS\n", "Also, flatten the arrays to 1D so that scipy.binned_statistic will understand them." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# first look at the image using ds9 and decide the X,Y coordinate of the pixel defining the center of\n", "# M84. In ds9, this is shown as \"Image X Y\". Note that Xc,Yc pixel coordinate given below\n", "# is NOT the center of M84 -- you need to work that out by looking at the image yourself!\n", "Xc, Yc = 1000.0,1000.0 \n", "R = np.sqrt( (X-Xc)**2 + (Y-Yc)**2 )\n", "R=R.flatten()\n", "pixvals=imdata.flatten()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now you have two arrays to work with: pixvals holds the intensity values in each pixel, R holds the distance of each pixel from the center. That distance is in pixel units, you'll need to convert that to arcseconds using the pixel scale of the image." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" } }, "nbformat": 4, "nbformat_minor": 2 }