Upgrade to Pro — share decks privately, control downloads, hide ads and more …

astropy

 astropy

Adrian Price-Whelan

December 15, 2012
Tweet

More Decks by Adrian Price-Whelan

Other Decks in Science

Transcript

  1. Project Coordinators • Perry Greenfield, STScI • Thomas Robitaille, MPIA

    • Erik Tollerud, Yale Core package maintainers • Tom Aldcroft, CfA • Erik Bray, STScI • Matt Davis, STScI • Michael Droettboom, STScI Affiliated package maintainers • Tom Aldcroft, CfA (pyidlastro) • Rene Breton, University of Southampton (photutils) • Wolfgang Kerzendorf, ANU (specutils) • Taro Sato (kcorrect) Contributors • Demitri Muna, NYU • Adrian Price-Whelan, Columbia U • Steve Crawford, SALT • Adam Ginsburg, U Colorado • Frederic Grollier • Prasanth Nair • Neil Crighton, MPIA • Christoph Deil, MPIK • Kyle Barbary, LBNL Monday, March 4, 13
  2. The Problem • astLib • astrolib • astropysics • pyephem

    • ephempy • pyast • pyastro • apwlib • chiantipy • pymidas • pandora • pyspec • pyraf • atpy • aplpy • pynovas • cosmopy • cosmolopy • kapteyn • cosmics.py • pyguide • astrogui • pyastronomy • pywcs • pyfits • sunpy • ...more? Monday, March 4, 13
  3. astropy Documentation: docs.astropy.org Code: github.com/astropy/astropy (soon) Tutorials & Recipes: github.com/astropy/astropy-tutorials

    Mailing lists: Get help and discuss with users: astropy Discuss technicalities with developers: astropy-dev Report bugs (not installation problems!): issue tracker github.com/astropy/astropy/issues Monday, March 4, 13
  4. astropy.units A system for defining and converting between units, and

    performing arithmetic with physical quantities. >>> import astropy.units as u >>> q = (1.125*u.pc).to(u.km) >>> q <Quantity 3.47138727915e+13 km> >>> q.value 34713872791505.906 >>> q.unit Unit("km") Monday, March 4, 13
  5. astropy.coordinates >>> import astropy.coordinates as coord >>> import astropy.units as

    u >>> coord.ICRSCoordinates('00h42m44.3s +41d16m9s') <ICRSCoordinates RA=10.68458 deg, Dec=41.26917 deg> >>> coord.ICRSCoordinates(10.68458, 41.26917, unit=(u.degree, u.degree)) <ICRSCoordinates RA=10.68458 deg, Dec=41.26917 deg> If units are unambiguous to humans, you don’t need to specify -> Otherwise, you have to tell the constructor degrees / hours / radians Monday, March 4, 13
  6. astropy.coordinates >>> c = coord.ICRSCoordinates('00h42m44.3s +41d16m9s') >>> c.ra <RA 10.68458

    deg> >>> c.ra.hours 0.7123053333333333 >>> c.ra.format(u.hour, sep=”hms”) '0h42m44.30000s' >>> c.ra.format(u.degree, sep=”:”) '10:41:04.50000' Angle objects (e.g. RA, Dec) can be formatted into strings. Monday, March 4, 13
  7. astropy.coordinates >>> c = coord.ICRSCoordinates('00h42m44.3s +41d16m9s') >>> c.galactic <GalacticCoordinates l=121.17431

    deg, b=-21.57280 deg> >>> c.transform_to(coord.GalacticCoordinates) <GalacticCoordinates l=121.17431 deg, b=-21.57280 deg> >>> c.galactic.l, c.galactic.b (<Angle 121.17431 deg>, <Angle -21.57280 deg>) Transformations are computed based on a registry of available conversions. Monday, March 4, 13
  8. astropy.coordinates Why do you care? If you define a new

    coordinate system, you only have to specify the transformation to and from one other, but can then transform to any system: SgrCoordinates `sgr` >>> c = coord.ICRSCoordinates('00h42m44.3s +41d16m9s') >>> c.transform_to(SgrCoordinates) <SgrCoordinates Lambda=113.81238 deg, Beta=-45.82266 deg> Monday, March 4, 13
  9. astropy.time Functionality for manipulating times and dates. Supports UTC, TA,

    UT1. Adds JD, MJD, ISO 8601, etc. Monday, March 4, 13
  10. astropy.time >>> from astropy.time import Time >>> t = Time(55672.5134,

    format=‘mjd’, scale=’utc’) >>> t.jd 2455673.0134 >>> t.iso '2011-04-21 12:19:17.760' >>> import datetime >>> t = Time(datetime.datetime.utcnow().isoformat(), scale='utc') >>> t.mjd Monday, March 4, 13
  11. astropy.table - Store and manipulate heterogeneous tables of data -

    Modify rows, columns; swap columns; add new rows, columns - Create tables, write to many formats (ASCII, Latex, DAOPhot, etc.) Monday, March 4, 13
  12. astropy.io.fits >>> from astropy.io import fits >>> hdulist = fits.open(“some_file.fits”)

    >>> hdulist.info() Filename: test1.fits No. Name Type Cards Dimensions Format 0 PRIMARY PrimaryHDU 220 () int16 1 SCI ImageHDU 61 (800, 800) float32 2 SCI ImageHDU 61 (800, 800) float32 3 SCI ImageHDU 61 (800, 800) float32 4 SCI ImageHDU 61 (800, 800) float32 >>> hdulist[0].data ... etc. Monday, March 4, 13
  13. astropy.wcs pywcs --> astropy.wcs Same syntax, just merged into Astropy

    API overhaul coming in v0.3 Monday, March 4, 13
  14. astropy.wcs >>> from astropy.io import fits >>> from astropy import

    wcs >>> hdulist = fits.open(“some_file.fits”) >>> wcs.WCS(hdulist[0].header) ... etc. Monday, March 4, 13
  15. astropy.cosmology Classes for representing cosmologies Utility functions for calculating commonly

    used quantities that depend on a cosmological model Monday, March 4, 13
  16. astropy.cosmology >>> from astropy.cosmology import LambdaCDM >>> cosmo = LambdaCDM(H0=85.,

    Om0=0.3, Ode0=0.5) >>> cosmo.lookback_time(0.612) 4.57737249034 >>> from astropy.cosmology import WMAP9 >>> WMAP9.lookback_time(0.612) 5.87117768853 >>> WMAP9.luminosity_distance(z=0.612) # (in Mpc) 3671.859892514587 Note: currently doesn’t use Units...coming very soon! Monday, March 4, 13
  17. worked example: - Read in and plot a list of

    SDSS coordinates - Color code points by u-r color Monday, March 4, 13