Arxiv:1905.13189V2 [Astro-Ph.IM] 7 Jan 2020 6.1
Total Page:16
File Type:pdf, Size:1020Kb
Version January 8, 2020 Preprint typeset using LATEX style openjournal v. 09/06/15 A BEGINNER'S GUIDE TO WORKING WITH ASTRONOMICAL DATA Markus Possel¨ Haus der Astronomie and Max Planck Institute for Astronomy Contents 8. Basic plotting with Python and Matplotlib 52 8.1. Plotting a function 52 1. Introduction1 8.2. Making a plot look better 52 1.1. Types of data2 8.3. Annotating plots 53 1.2. Types of tools3 8.4. Figure size 54 1.3. Concepts and operations3 8.5. Scatter plots 54 1.4. Software/language choices4 8.6. Fitting data 55 8.7. Histograms 56 2. Data basics: images, spectra, tables5 8.8. Saving figures 57 2.1. Images: Colour, brightness, pixels5 8.9. Glueing data sets 57 2.2. Images: PSF and noise7 2.3. Images: Noise and flatfielding8 9. Importing table data into Python 57 2.4. Images: astronomical information 10 9.1. Opening a FITS table in python 57 2.5. Spectra 11 9.2. Opening an ASCII table in python 58 2.6. Data cubes 14 9.3. Accessing astronomical data bases 59 2.7. High-level data: catalogues and tables 15 10. Astronomical image manipulation with Python 60 3. SAOImage DS9 and astronomical images 18 10.1. FITS files and python 60 3.1. Loading a Hubble image 18 10.2. Displaying (showing) an image 60 3.2. A first look at the Eagle Nebula M16 19 10.3. Pixelwise operations 61 3.3. Coordinates: Navigating the image 20 3.4. Meta-Information: the FITS header 21 11. A simple simulation 63 3.5. Making a colour image 22 11.1. Step-by-step numerical integration: Euler 3.6. Catalogs 23 method 63 3.7. Photometry with regions and statistics 24 11.2. Numerical errors 65 3.8. Profiles 25 11.3. Velocity Verlet algorithm 65 11.4. A simple two-dimensional simulation 66 4. TOPCAT and table data 26 4.1. Opening a table file 27 12. Conclusion 70 4.2. Making a sky plot 28 4.3. Virtual Observatory (VO) services 28 1. INTRODUCTION 4.4. Basic ADQL queries 30 4.5. Selections and subsets 32 Compare professional astronomy today with how it was 4.6. More on plotting 34 50 years ago, and you will recognise some continuity | 4.7. Histograms 37 but also a number of fundamental changes. Perhaps the 4.8. A quick look at a spectrum 37 key change is that astronomy has come to rely almost completely on digital data. Modern telescopes with their 5. Getting started with Python 38 CCD cameras produce digital images and, with the help 5.1. Installing Python 39 of suitable dispersive elements, digital astronomical spec- 5.2. Using Python in Spyder 39 tra. An in-depth analysis of a particularly well-studied 5.3. Modules 41 object will be able to make use of digital images and 6. Basic operations with Python 42 spectra taken at different wavelengths | some taken by arXiv:1905.13189v2 [astro-ph.IM] 7 Jan 2020 6.1. Meet your new versatile calculator 42 ground-based telescopes and some, like extreme ultra- 6.2. Units and constants 42 violet or X rays, which can only be provided by space 6.3. Random numbers 43 telescopes. 6.4. Strings 43 Furthermore, in-depth studies of selected objects are 6.5. Conditions 44 only part of what modern astronomy has to offer. We 6.6. User-defined functions 45 also live in an era of extensive surveys: large-scale under- 6.7. Timing your code 46 takings to photograph, or take spectra of, wider regions of the sky in a systematic way. These surveys not only 7. Taming long data sets: Lists in Python 46 produce many images and spectra, but also extensive cat- 7.1. A list of galaxies 46 alogues 7.2. Doing something element by element 47 of the objects observed, listing various of their 7.3. Operations involving more than one list 48 properties. With such catalogues comes the ability to 7.4. Creating lists simultaneously 49 make statistical deductions about astronomical objects: 7.5. Numpy arrays 50 If you want to know whether, say, elliptical galaxies are, 7.6. Variable types, lists, arrays and speed 50 in general, brighter than spiral galaxies (to pick an ar- 7.7. Strings and base n numbers as lists 51 tificially simple example), you, consult a suitable galaxy 2 catalogue and look up the brightness values for a large 1.1. Types of data number of elliptical and a large number of spiral galaxies. When it comes to data from observational astronomy, Modern surveys produce considerable amounts of data. most data sets we will be dealing with fall into one of the For home use, we have become used to Gigabytes (1 Gi- following categories: gabyte =1000 Megabyte) and Terabytes (TB; 1 Terabyte = 1000 Gigabyte): a DVD holds 4.7 Gigabytes, and hard • Image data | in its simplest form, an image is drives now routinely hold a Terabyte or more. The ESO a two-dimensional array of pixels, where each pixel Survey Telescope VISTA produces about 150 TB worth value denotes a brightness value. In an ordinary of data per year, and the Large Synoptic Survey Tele- color image, each pixel will have three brightness scope (LSST) currently under construction is predicted values, denoting the contribution from red, green, to produce 500 TB worth of image data per month. and blue (RGB). Since astronomers use many spe- Then, there a increasingly large and detailed simula- cialist filters beyond these three colors, astronomi- tions. Take the IllustrisTNG simulation, which follows cal "color" images can have even more color values the evolution of a large portion of the universe from per pixel. Astronomical images usually show a re- shortly after the Big Bang to the present. The small- gion of the night sky. est but most detailed of the TNG runs, TNG50, follows the fate of a cube that, in the present universe, has a • Spectra | simple spectra show us how the en- side-length of 50 Mpc. Within this volume, matter is rep- ergy of the light emitted by an object is distributed resented by 10 billion point particles representing Dark among the different possible wavelengths. Such Matter and 10 billion point particles representing gas. simple spectra are one-dimensional: for each wave- The two simulation runs TNG300 and TNG100 which length value, we know the contribution of light were made available to the public in December 2018 sum from that particular wavelength region. up to more than one Petabyte of data (PB; 1 Petabyte • Data cubes | think of these as an enhanced ver- = 1000 Terabytes). sion of astronomical images. An example is a data Increase the amount of data, and at some point it will cube from what is known as integral field spec- become impractical to download a complete data set onto troscopy (IFS); such a data cube is like a two- your own computer for analysis. This is where data base dimensional image, but now each pixel contains not operations become important: the data is stored in ded- a brightness value, but a whole spectrum received icated data centres, and is accessible online; in order to from the region of the sky within that pixel. Since work with the data, you use the Internet to send specific we have a one-dimensional spectrum for each pixel queries ("Give me the list of all galaxies on the Southern of a two-dimensional image, that gives us in effect hemisphere which are brighter than X"). In this way, the a three-dimensional object: a data cube only data you download is the data you specifically need for your research. The next step is not far off: when even • Catalog data | on a higher level of analysis, as- those pre-selected data sets become too cumbersome to tronomers make catalogues of the properties of dif- handle, researchers can run their analysis programs re- ferent types of astronomical objects. A star cata- motely on the dedicated servers where the data is stored. log, for instance, could list position, proper motion, Infrastructure to allow just this, notably JuPyter note- parallax, brightness (in various wavelength bands), books, are becoming increasingly common. and effective temperature for each of a specific se- All this implies that digital data analysis skills are part lection of stars. of the essential skill sets of modern astronomers. Some This list is not complete | for instance, in interferomet- of the skills needed for a given research project will be ric imaging, when you are trying to reconstruct an image very specific, involving custom software to be used for a by combining coherently the measurements of different very particular kind of analysis, or custom software to telescopes (\aperture synthesis"), your raw data will be be written by the researcher herself. These special skills time-stamped data from the single telescopes, and the must be learned and honed on the job. But there are initial processing will involve cross-correlating the data other skills which are more elementary and more gen- between those telescopes. But while the list is not com- eral. Teaching a selection of those skills is the purpose plete, it should cover the great majority of current astro- of this text. It was originally written for interns at Haus nomical use cases. der Astronomie in Heidelberg, in particular for partici- 1 We will take a first look at examples for each data pants of our International Summer Internship Program type in section2. These different data usually come with aimed at students in the final years of high school, or meta-data, that is, descriptive information about the for students who have just finished high school and are data.