<p><span>Over the past two decades, Python has become the de facto standard language of data science both in industry and astronomy (with the exception of simulations and other extreme scale computing problems). This course text is a full introduction to programming in Python with an explicit focus
Astronomical Python: An introduction to modern scientific programming
โ Scribed by Imad Pasha
- Publisher
- Iop Publishing Ltd
- Year
- 2024
- Tongue
- English
- Leaves
- 400
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
Over the past two decades, Python has become the de facto standard language of data science both in industry and astronomy (with the exception of simulations and other extreme scale computing problems). This course text is a full introduction to programming in Python with an explicit focus on astrophysical applications.
โฆ Table of Contents
PRELIMS.pdf
Acknowledgements
About the Author
Imad Pasha
CH001.pdf
Chapter Introduction
1.1 How to Use This Book?
1.2 Data Availability
References
CH002.pdf
Chapter Essential Unix Skills
2.1 Operating Systems
2.2 Anatomy of the Terminal
2.3 Common UNIX Commands
2.3.1 Printing the Current Directory
2.3.2 Changing Directories
2.3.3 Viewing Files and Directories
2.3.4 Making Directories
2.3.5 Deleting Files and Directories
2.3.6 Moving/Copying Files and Directories
2.3.7 The Wildcard
2.4 Cancelling Commands
2.5 Tab Complete
2.6 Intermediate Shell Commands
2.6.1 Touch/File Creation
2.6.2 Previewing File Contents
2.6.3 Setting Permissions
2.6.4 Piping Outputs
2.6.5 File and Directory Archives
2.7 SSH and Servers
2.7.1 Logging into a Server
2.7.2 Copying Files from a Local Directory to a Server Using SCP
2.7.3 Copying a File from a Server to a Local Directory
2.7.4 Rsync
2.7.5 Screen and Backgrounding Processes
2.8 Profiles
2.8.1 Aliasing
2.8.2 Environment Variables
Exercise 2.2: Easy cd
2.9 Summary
CH003.pdf
Chapter Installing Python and the Astronomy Stack
3.1 Prerequisites
3.1.1 MacOS
3.1.2 Windows
3.2 Python Environments
3.2.1 When to Create an Environment
3.2.2 Creating and Managing Environments
3.2.3 An Environment for this Textbook
3.3 Editors
3.3.1 Terminal Editors
3.3.2 Text Editors
3.3.3 Jupyter Notebooks
3.3.4 IDE (Integrated Development Environment)
3.4 Summary
CH004.pdf
Chapter Introduction to Python
4.1 Variables
4.1.1 Defining Variables
4.1.2 Copies of Variables
4.2 Importing External Libraries
4.3 Comments
4.4 Data Types
4.4.1 Strings
4.4.2 Collections of Data: Lists and Dictionaries
4.5 Indexing
4.6 Slicing
4.7 Operations
4.8 Reserved Words
4.9 Filtering and Masking
4.9.1 Multiple Conditions
4.10 Conditional Statements
4.10.1 Multiple Simultaneous Conditions
4.10.2 Equality versus Identity
4.11 Loops and Iterators
4.11.1 For-Loops
4.11.2 While-Loops
4.11.3 Continuing Through and Breaking Out of Loops
4.11.4 Generators
4.12 Cancelling Code Execution
4.13 Shell and Shell-like Commands in Python
4.14 Interpreting Error Messages
4.15 Handling Exceptions
4.16 Summary
CH005.pdf
Outline placeholder
Introduction
Chapter Visualization with Matplotlib
5.1 Introduction
5.2 A Simple Plot
5.3 Figures and Axes
5.4 Subplots
5.5 Adjusting Marker Properties
5.6 Adjusting Ticks
5.7 Adjusting Fonts and Fontsizes
5.7.1 LaTeX in Labels
5.8 Multiple Subplots
5.9 Subplot Mosaic
5.10 Research Example: Displaying a Best Fit
5.11 Errorbars
5.12 Plotting N-Dimensional Data
5.13 Colorbars
5.14 Summary
References
CH006.pdf
Chapter Numpy
6.1 Introduction
6.2 The Array
6.3 Precision
6.4 Key Library Functions
6.5 Research Example: An Exoplanet Transit
6.6 Summary
References
CH007.pdf
Chapter SciPy
7.1 Introduction
7.2 Numerical Integration
7.3 Optimization
7.4 Statistics
7.4.1 Distributions
7.5 Summary
CH008.pdf
Chapter Astropy and Associated Packages
8.1 Introduction
8.2 Units and Constants
8.3 Cosmological Calculations
8.4 Coordinates
8.5 Astroquery
8.6 Research Example: Automatic Offsets
8.7 Research Example: Handling Astronomical Images
8.7.1 The World Coordinate System
8.7.2 Image Cutouts
8.7.3 Aperture Photometry
8.7.4 Combining Images
8.8 Summary
References
CH009.pdf
Outline placeholder
Introduction
Chapter Functions and Functional Programming
9.1 Introduction
9.2 Defining Functions
9.3 Writing Documentation
9.3.1 Formatting Your Documentation: Best Practices
9.4 Checking Function Inputs
9.5 Local Scope and Global Scope
9.5.1 Debugging with Functions
9.6 Chaining Functions Together
9.7 The Concept of Main()
9.8 Keyword (Optional) Arguments
Exercise 9.1
9.9 Packing and Unpacking Function Arguments
9.10 Testing Function Outputs: Unit Testing
9.11 Type-Hinting
9.12 Summary
CH010.pdf
Chapter Classes and Object Oriented Programming
10.1 Introduction
10.2 Defining Classes
10.3 Setters and Getters
10.4 Representation
10.5 Subclasses (and Superclasses)
10.6 Static Methods
10.7 Abstract Base Classes
10.8 Summary
CH011.pdf
Chapter Data Science with Astronomical Catalogs
11.1 Introduction
11.2 Filetypes and Reading in Data
11.2.1 ASCII (Text Files)
11.2.2 Reading Tabular Data with Astropy
11.2.3 ASDF (Advanced Science Data Format)
11.2.4 HDF5 (Hierarchical Data Format 5)
11.3 Working with Tabular Data in Pandas
11.3.1 Indexing Columns
11.3.2 Indexing Rows with .loc
11.3.3 Filtering Dataframes
11.3.4 Merging Dataframes
Exercise 11.1: Joint Sample
Exercise 11.2: Merging Tables
Exercise 11.3: Initial Cleaning
11.3.5 Saving Dataframes
11.4 Research Example: Analysis with 3DHST
11.4.1 Star-forming Sequence
Exercise 11.5: Redshift dependence
11.4.2 UVJ Diagram
Exercise 11.7: Size-mass relation
11.5 Summary
References
CH012.pdf
Chapter Vectorization and Runtime Improvements
12.1 Introduction
12.2 Identifying Bottlenecks
12.3 Fast Array Operations with Numpy
Exercise 12.1: Distances from Isochrone
Exercise 12.2: Membership Probability
12.4 Jax
12.5 Summary
References
CH013.pdf
Chapter Astronomical Inference
13.1 Introduction
13.2 Fitting a Line to Data
13.3 ฯ2 Fitting
13.4 Bayesian Inference
13.4.1 Bayes Theorem
13.4.2 Why Does This Help with Uncertainties?
13.4.3 Estimating Integrals
13.4.4 Sampling
13.4.5 Simple Monte Carlo
13.4.6 Importance Sampling
Exercise 13.1: The Value of ฯ
13.4.7 Metropolis MCMC
Exercise 13.2: Write a Sampler
13.4.8 Emcee: The Workhorse Astronomy Sampler
13.4.9 Priors
13.4.10 Likelihood
13.4.11 Quoting Parameters and Uncertainties
13.5 Summary
References
CH014.pdf
Chapter Software Development
14.1 Introduction
14.2 Why (and When) to make a Python Package a Python Package
14.3 Organizing Packages: Modules and Submodules
14.4 Custom Exceptions and Warnings
14.5 Installation and Development
14.6 Github and Version Control
14.7 Summary
CH015.pdf
Chapter Conclusions and Next Steps
15.1 Concluding Remarks
References
๐ SIMILAR VOLUMES
<p><span>Over the past two decades, Python has become the de facto standard language of data science both in industry and astronomy (with the exception of simulations and other extreme scale computing problems). This course text is a full introduction to programming in Python with an explicit focus
<p>This open access book offers an initial introduction to programming for scientific and computational applications using the Python programming language. The presentation style is compact and example-based, making it suitable for students and researchers with little or no prior experience in progr
<p><p>This open access book offers an initial introduction to programming for scientific and computational applications using the Python programming language. The presentation style is compact and example-based, making it suitable for students and researchers with little or no prior experience in pr
<span>Python is one of the most popular programming languages, widely used for data analysis and modelling, and is fast becoming the leading choice for scientists and engineers. Unlike other textbooks introducing Python, typically organised by language syntax, this book uses many examples from acros