Slide 1

Slide 1 text

Adrian Price-Whelan ! adrn " adrianprw Kelle Cruz ! kelle " kellecruz

Slide 2

Slide 2 text

Adrian Price-Whelan Postdoctoral fellow Princeton University (visiting CCA this year, Flatiron fellow 2019) ! adrn " adrianprw

Slide 3

Slide 3 text

I’m mostly an astrophysicist (part-time software developer) I use the dynamics of stars throughout the Milky Way to study Dark Matter (see October issue of Science, “Sky Rivers”) I develop specialized software for Galactic dynamics Dominant computational costs: numerical integration + probabilistic inference (sampling)

Slide 4

Slide 4 text

Adrian Price-Whelan Astropy lead developer ! adrn " adrianprw Postdoctoral fellow Princeton University (visiting CCA this year, Flatiron fellow 2019)

Slide 5

Slide 5 text

How do I represent and transform astronomical coordinates in Python? 2011

Slide 6

Slide 6 text

the year 2011

Slide 7

Slide 7 text

the year 2011

Slide 8

Slide 8 text

How do I represent and transform astronomical coordinates in Python? 2011

Slide 9

Slide 9 text

astrolib astropysics coordlib ephempy kapteyn pyastro pyast + more How do I represent and transform astronomical coordinates in Python? 2011

Slide 10

Slide 10 text

source: ADS

Slide 11

Slide 11 text

source: ADS Python IDL Matlab Perl

Slide 12

Slide 12 text

create a Python package with generic functionality that most astronomers need Idea:

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

source: ADS Python IDL Matlab Perl astropy

Slide 15

Slide 15 text

source: ADS Python IDL Matlab Perl astropy

Slide 16

Slide 16 text

Library

Slide 17

Slide 17 text

Library Community Ecosystem

Slide 18

Slide 18 text

= library “The ultimate goal that we seek is a package that would contain much of the core functionality and some common tools required across Astronomy, but not everything Astronomers will ever need.”

Slide 19

Slide 19 text

extending the scientific Python “stack” adapted from Jake Vanderplas

Slide 20

Slide 20 text

extending the scientific Python “stack” adapted from Jake Vanderplas

Slide 21

Slide 21 text

extending the scientific Python “stack” adapted from Jake Vanderplas

Slide 22

Slide 22 text

extending the scientific Python “stack” adapted from Jake Vanderplas

Slide 23

Slide 23 text

extending the scientific Python “stack” adapted from Jake Vanderplas

Slide 24

Slide 24 text

adapted from Jake Vanderplas + many more

Slide 25

Slide 25 text

Why?

Slide 26

Slide 26 text

Why need a library for astronomy?

Slide 27

Slide 27 text

Custom binary file formats (e.g., FITS) Why need a library for astronomy?

Slide 28

Slide 28 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Why need a library for astronomy?

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Why need a library for astronomy?

Slide 36

Slide 36 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Why need a library for astronomy?

Slide 37

Slide 37 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Coordinate systems & transformations Why need a library for astronomy?

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Why need a library for astronomy?

Slide 40

Slide 40 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Coordinate systems & transformations Commonly-used but niche statistics (not in scipy.stats) Why need a library for astronomy?

Slide 41

Slide 41 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Coordinate systems & transformations Commonly-used but niche statistics (not in scipy.stats) OMG ASCII tables Why need a library for astronomy?

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Coordinate systems & transformations Commonly-used but niche statistics (not in scipy.stats) OMG ASCII tables Ultra-precise timing (pulsars!) Why need a library for astronomy?

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

leap seconds

Slide 50

Slide 50 text

Custom binary file formats (e.g., FITS) Represent units & quantities in code Coordinate systems & transformations Commonly-used but niche statistics (not in scipy.stats) OMG ASCII tables Super-precise timing (pulsars!) Plotting images of the sky (a sphere! projections…) Why need a library for astronomy?

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

What?

Slide 53

Slide 53 text

Core functionality and common tools for astronomers

Slide 54

Slide 54 text

Core functionality and common tools for astronomers Focus on user interface design

Slide 55

Slide 55 text

Example: astronomical coordinates (α, δ, D) = (86.7∘, 53.09∘, 27 pc) (α, δ, D) = (05h46m48s, + 53d05m24s, 27 pc) (x, y, z) = (0.9, 16.2, 21.6) pc (l, b, D) = (159.14∘, 12.46∘, 27 pc) J05464800 + 5305240

Slide 56

Slide 56 text

Example: astronomical coordinates Reference frame Coordinate system Coordinate representation Component formatting (α, δ, D) = (86.7∘, 53.09∘, 27 pc) (α, δ, D) = (05h46m48s, + 53d05m24s, 27 pc) (x, y, z) = (0.9, 16.2, 21.6) pc (l, b, D) = (159.14∘, 12.46∘, 27 pc) J05464800 + 5305240

Slide 57

Slide 57 text

Example: astronomical coordinates (α, δ, D) = (86.7∘, 53.09∘, 27 pc) (α, δ, D) = (05h46m48s, + 53d05m24s, 27 pc) (x, y, z) = (0.9, 16.2, 21.6) pc (l, b, D) = (159.14∘, 12.46∘, 27 pc) J05464800 + 5305240

Slide 58

Slide 58 text

Example: astronomical coordinates high-level interface reference frame coordinate representation

Slide 59

Slide 59 text

Example: astronomical coordinates high-level interface reference frame coordinate representation

Slide 60

Slide 60 text

Example: astronomical coordinates high-level interface reference frame coordinate representation

Slide 61

Slide 61 text

Python + C/Cython extensions Python >= 3.5 165,595 lines of Python + 87,957 lines of tests + 48,734 lines of documentation >1,000 users ~100 downloads/day astropy — v3.0.5

Slide 62

Slide 62 text

astropy docs.astropy.org

Slide 63

Slide 63 text

How?

Slide 64

Slide 64 text

How? Community driven development

Slide 65

Slide 65 text

Making community-driven development work

Slide 66

Slide 66 text

Making community-driven development work 1. Use GitHub to host code, track issues, contributions - Code review - Feature requests - Feature planning - Manage releases

Slide 67

Slide 67 text

Making community-driven development work 1. Use GitHub to host code, track issues, contributions - Code review - Feature requests - Feature planning - Manage releases 2. Use continuous integration to run tests - Travis CI, CircleCI, AppVeyor - Enforce good test coverage in new code - Test on multiple architectures, dependency versions

Slide 68

Slide 68 text

Making community-driven development work 1. Use GitHub to host code, track issues, contributions - Code review - Feature requests - Feature planning - Manage releases 2. Use continuous integration to run tests - Travis CI, CircleCI, AppVeyor - Enforce good test coverage in new code - Test on multiple architectures, dependency versions 3. Use readthedocs to serve documentation - Documentation generated from code with Sphinx - New contributions require documentation

Slide 69

Slide 69 text

Guiding principles Open source, open development

Slide 70

Slide 70 text

Open source github.com/astropy/astropy

Slide 71

Slide 71 text

Open development

Slide 72

Slide 72 text

Open development

Slide 73

Slide 73 text

Open development

Slide 74

Slide 74 text

Guiding principles Open source, open development Provide tested, documented code to users

Slide 75

Slide 75 text

Software testing & continuous integration

Slide 76

Slide 76 text

Software testing & continuous integration

Slide 77

Slide 77 text

Documentation

Slide 78

Slide 78 text

Documentation

Slide 79

Slide 79 text

Documentation

Slide 80

Slide 80 text

Guiding principles

Slide 81

Slide 81 text

Guiding principles Open source, open development Provide tested, documented code to users

Slide 82

Slide 82 text

Guiding principles Open source, open development Provide tested, documented code to users Encourage contributions from users

Slide 83

Slide 83 text

Guiding principles Open source, open development Provide tested, documented code to users Encourage contributions from users Don’t re-invent tools, but minimize dependencies

Slide 84

Slide 84 text

Guiding principles Open source, open development Provide tested, documented code to users Encourage contributions from users Don’t re-invent tools, but minimize dependencies Feed features and functionality back upstream

Slide 85

Slide 85 text

Guiding principles Open source, open development Provide tested, documented code to users Encourage contributions from users Don’t re-invent tools, but minimize dependencies Feed features and functionality back upstream Allow & encourage extending core functionality

Slide 86

Slide 86 text

Who?

Slide 87

Slide 87 text

Astronomers! ~270 contributors ~20 package leads & maintainers but… Who develops the Astropy library?

Slide 88

Slide 88 text

Astronomers! ~270 contributors ~20 package leads & maintainers but… Who develops the Astropy library?

Slide 89

Slide 89 text

Astronomers! ~270 contributors ~20 package leads & maintainers but… Who develops the Astropy library?

Slide 90

Slide 90 text

Maintainers Deputies

Slide 91

Slide 91 text

Maintainers Deputies • Evaluating & merging new pull requests by sub-package • Feature development & issue tracking

Slide 92

Slide 92 text

The Astropy Coordination Committee Erik Tollerud Kelle Cruz Tom Aldcroft Tom Robitaille • Overall coordination and management of the Astropy project • Evaluating new affiliated packages • Arbitrating disagreements in the core package • Managing finances for the project

Slide 93

Slide 93 text

numfocus.org “…promote sustainable high-level programming languages, open code development, and reproducible scientific research”

Slide 94

Slide 94 text

numfocus.org “…promote sustainable high-level programming languages, open code development, and reproducible scientific research”

Slide 95

Slide 95 text

How to contribute Important to guide users to and through their first few PRs Explain expectations: code + tests + docs Coding guidelines Follow PEP8 and general style of subpackage you’re working in Avoid multiple inheritance When to include C code etc. Engaging and supporting developers docs.astropy.org/en/latest/development/codeguide.html

Slide 96

Slide 96 text

Documentation guidelines Docstring styles and content (for users) Comments within code (for developers) Testing guidelines Practical issues: where to put tests, how to name them, etc. Explain concepts and expectations: unit, regression, functional (i.e. unit tests not enough, even if 100% coverage) Engaging and supporting developers docs.astropy.org/en/latest/development/docguide.html docs.astropy.org/en/latest/development/testguide.html

Slide 97

Slide 97 text

Coordination meetings (Astropy project developers) Developer sprints (usually during or around other meetings) Regular telecons (deadlines are good!) Google Summer of Code (2014—present, ~30 students so far) Python in Astronomy Engaging and supporting developers

Slide 98

Slide 98 text

hacking the scientific attribution system Engaging and supporting developers

Slide 99

Slide 99 text

Who uses the Astropy library? LIGO (detection of gravitational waves) LIGO (neutron star merger follow-up) ALMA (first observations) + many large observatories, surveys, and regular astronomers!

Slide 100

Slide 100 text

= ecosystem “A common package should not preclude any other Astronomy package from existing, because there will always be more complex and/or specialized tools required.”

Slide 101

Slide 101 text

Astropy affiliated packages Domain-specific astronomy Python packages that request to be part of the Astropy community Commit to Astropy goals: improving reuse, interoperability, interface standards http://affiliated.astropy.org/

Slide 102

Slide 102 text

Astropy affiliated packages Core library: General tools, long-term stable, longer release schedule Affiliated packages: Specialized tools, faster development and release cycle ~40 exist to date http://affiliated.astropy.org/

Slide 103

Slide 103 text

Custom tools we use, develop, and release 4 pytest plugins (all publicly released, see here https://github.com/astropy/pytest-astropy) Sphinx extensions (see https://github.com/astropy/sphinx-automodapi) Python package template (see https://github.com/astropy/package-template) Benchmarking tool: airspeed velocity (see https://asv.readthedocs.io/en/stable/)

Slide 104

Slide 104 text

Goal: simplify startup and maintenance of packaged, released Python software Sets up: documentation template (Sphinx) testing infrastructure (py.test) CI configuration setup.py script (support for Cython exts.) (Uses cookiecutter) Astropy package template https://github.com/astropy/package-template

Slide 105

Slide 105 text

Custom benchmarking www.astropy.org/astropy-benchmarks

Slide 106

Slide 106 text

= community “Our goal is to keep ours a positive, inclusive, successful, and growing community”

Slide 107

Slide 107 text

Superset of users & developers Many entry points: - Mailing lists: users, developers - Slack - Regular telecons - New: Astropy event calendar Conferences: - Workshops - Python in Astronomy - .Astronomy What is the Astropy community?

Slide 108

Slide 108 text

Engaging and supporting users

Slide 109

Slide 109 text

Engaging and supporting users Documentation is not enough

Slide 110

Slide 110 text

Engaging and supporting users

Slide 111

Slide 111 text

Tutorials colab.research.google.com Jupyter notebooks Rendered to static HTML OR Open as live notebook with Google Colaboratory

Slide 112

Slide 112 text

Many lead / maintainer roles unfilled How do we prevent burnout and support devs? User -> Contributor -> Maintainer? A significant development bottleneck is code review How can we incentivize this effort? Our goal is to enable all astronomy, not solve specific science questions How do we fund “infrastructure” software like Astropy? Challenges & the future

Slide 113

Slide 113 text

Tradeoff between API stability & betterizing / updating (example: astropy.units is very general and used outside of astronomy, but is it worth the headache [to users & devs] of splitting it out?) Incentivize performance enhancements Improve educational materials Challenges & the future