Kosmiczny Python

54
Wstęp AstroPy AUTO Podsumowanie Kosmiczny Python Slawomir Piasecki PyCon PL Ossa/k Rawy Mazowieckiej 15-18 Października 2015 Slawomir Piasecki Kosmiczny Python

Transcript of Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Kosmiczny Python

Sławomir Piasecki

PyCon PLOssa/k Rawy Mazowieckiej15-18 Października 2015

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Outline

1 Wstęp

2 AstroPyQuantityConstantsTableFITSCoordinates

3 AUTO

4 Podsumowanie

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Wstęp

♦ obserwacje gołym okiem♦ greckie modele matematyczne♦ islamski średniowiecze♦ Kopernikowa rewolucja♦ luneta Galileusza♦ fotografia♦ komputery

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Języki programowania w Astronomii

♦ Fortran♦ C/C++♦ IDL♦ Perl

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Języki programowania w Astronomii

♦ Fortran♦ C/C++♦ IDL♦ Perl

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Języki programowania w Astronomii

♦ Fortran♦ C/C++♦ IDL♦ Perl

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Dlaczego Python?

♦ bardzo duża ilość modułów♦ duża społeczność♦ bardzo dobra dokumentacja♦ bardzo prosty w użyciu♦ możliwość wykonywania wykresów

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Do czego wykorzystywany jest Python?

♦ nauki studentów♦ rysowania wykresów♦ jednorazowe skrypty♦ analizy danych z obserwacji♦ sterowania teleskopami♦ codziennego zarządzania komputerem

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Najczęściej używane paczki

♦ NumPy♦ SciPy♦ Math♦ Matplotlib♦ AstroPy

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

AstroPy

♦ jednostki (Quantity)♦ stałe astronomiczne♦ Table♦ FITS♦ współrzędne

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

>>> distance = 15∗u.kilometer

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

>>> distance = 15∗u.kilometer>>> distance

<Quantity 15.0 km>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

>>> distance = 15∗u.kilometer>>> distance

<Quantity 15.0 km>

>>> velocity = 5∗u.meter/u.second>>> result = distance/velocity

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

>>> distance = 15∗u.kilometer>>> distance

<Quantity 15.0 km>

>>> velocity = 5∗u.meter/u.second>>> result = distance/velocity

>>> result

<Quantity 3.0 km s / m>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Quantity w AstroPy

>>> from astropy import units as u

>>> u.meter

Unit(‘‘m’’)

>>> distance = 15∗u.kilometer>>> distance

<Quantity 15.0 km>

>>> velocity = 5∗u.meter/u.second>>> result = distance/velocity

>>> result

<Quantity 3.0 km s / m>

>>> result.decompose()

<Quantity 3000.0 s> <Quantity 50.0 min>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Jednostki długości w Astronomii

>>> 1∗u.km # D y s t a n s d l a s a t e l i t

<Quantity 1 km>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Jednostki długości w Astronomii

>>> 1∗u.km # D y s t a n s d l a s a t e l i t

<Quantity 1 km>

>>> au = 1∗u.au # D y s t a n s w u k l a d a c h p l a n e t a r n y c h

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Jednostki długości w Astronomii

>>> 1∗u.km # D y s t a n s d l a s a t e l i t

<Quantity 1 km>

>>> au = 1∗u.au # D y s t a n s w u k l a d a c h p l a n e t a r n y c h

>>> au.to(’km’)

<Quantity 149597870.7 km>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Jednostki długości w Astronomii

>>> 1∗u.km # D y s t a n s d l a s a t e l i t

<Quantity 1 km>

>>> au = 1∗u.au # D y s t a n s w u k l a d a c h p l a n e t a r n y c h

>>> au.to(’km’)

<Quantity 149597870.7 km>

>>> lyr = 1∗u.lyr # D y s t a n s g a l a k t y c z n y c h

<Quantity 63241.07708426628 AU>

<Quantity 9460730472580.8 km>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Jednostki długości w Astronomii

>>> 1∗u.km # D y s t a n s d l a s a t e l i t

<Quantity 1 km>

>>> au = 1∗u.au # D y s t a n s w u k l a d a c h p l a n e t a r n y c h

>>> au.to(’km’)

<Quantity 149597870.7 km>

>>> lyr = 1∗u.lyr # D y s t a n s g a l a k t y c z n y c h

<Quantity 63241.07708426628 AU>

<Quantity 9460730472580.8 km>

>>> pc = 1∗u.pc<Quantity 3.26156377714188 lyr>

<Quantity 206264.80624548031 AU>

<Quantity 30856775814671.914 km>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Planety w układzie Słonecznym i sąsiedzctwie

Planeta odległość od słońca obiekt odległośćkm AU lyr

Merkury 57 909 107 0.3871 Proxima Centaurii 4.22Wenus 108 208 926 0.7233 Syriusz 8.60Ziemia 149 597 870 1.0000 Luyten 726-8 8.73Mars 227 936 637 1.5237 Ross 9.68Jowisz 778 412 027 5.2034 tau Ceti 11.9Saturn 1 426 725 413 9.5371Uran 2 870 972 220 19.1913Neptun 4 498 252 900 30.0690

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Stałe astronomiczne

>>> from astropy import constants as cons

>>> print cons.G

Name = Gravitational constant

Value = 6.67384e−11Error = 8e−15Units = m3 / (kg s2)

Reference = CODATA 2010

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Stałe astronomiczne

>>> from astropy import constants as cons

>>> print cons.G

Name = Gravitational constant

Value = 6.67384e−11Error = 8e−15Units = m3 / (kg s2)

Reference = CODATA 2010

>>> print cons.M_sun

Name = Solar mass

Value = 1.9891e+30

Error = 5e+25

Units = kg

Reference = Allen’s Astrophysical Quantities 4th Ed.

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> a = [1, 2, 3]

>>> b = [2.0, 4.0, 9.0]

>>> c = [’x’, ’y’, ’z’]

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> a = [1, 2, 3]

>>> b = [2.0, 4.0, 9.0]

>>> c = [’x’, ’y’, ’z’]

>>> t = Table([a, b, c], names=(’a’, ’b’, ’c’),

meta={’name’: ’first table’})

<Table rows=3 names=(’a’,’b’,’c’)>

array([(1, 2.0, ’x’), (4, 4.0, ’y’), (3, 9.0, ’z’)],

dtype=[(’a’, ’<i8’), (’b’, ’<f8’), (’c’, ’S1’)])

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> a = [1, 2, 3]

>>> b = [2.0, 4.0, 9.0]

>>> c = [’x’, ’y’, ’z’]

>>> t = Table([a, b, c], names=(’a’, ’b’, ’c’),

meta={’name’: ’first table’})

<Table rows=3 names=(’a’,’b’,’c’)>

array([(1, 2.0, ’x’), (4, 4.0, ’y’), (3, 9.0, ’z’)],

dtype=[(’a’, ’<i8’), (’b’, ’<f8’), (’c’, ’S1’)])

>>> t[’b’].unit = ’s’

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> a = [1, 2, 3]

>>> b = [2.0, 4.0, 9.0]

>>> c = [’x’, ’y’, ’z’]

>>> t = Table([a, b, c], names=(’a’, ’b’, ’c’),

meta={’name’: ’first table’})

<Table rows=3 names=(’a’,’b’,’c’)>

array([(1, 2.0, ’x’), (4, 4.0, ’y’), (3, 9.0, ’z’)],

dtype=[(’a’, ’<i8’), (’b’, ’<f8’), (’c’, ’S1’)])

>>> t[’b’].unit = ’s’

>>> print(t)

a b c

s

−−−−−−−−−1 2.0 x

2 4.0 y

3 9.0 z

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

FITS

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

FITS

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

FITS

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

FITS

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Współrzędne w układach astronomicznych

>>> from astropy.coordinates import SkyCoord

>>> c = SkyCoord(

ra=10.625∗u.degree, dec=41.2∗u.degree, frame=’icrs’)>>> c = SkyCoord(10.625, 41.2, unit=’deg’)

>>> c = SkyCoord(’00h42m30s’, ’+41d12m00s’)

>>> c = SkyCoord(’00h42.5m’, ’+41d12m’)

>>> c = SkyCoord(’00 42 30 +41 12 00’, unit=(u.hourangle , u.deg))

>>> c = SkyCoord(’00:42.5 +41:12’, unit=(u.hourangle , u.deg))

<SkyCoord (ICRS): (ra, dec) in deg (10.625, 41.2)>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Transformacje współrzędnych

>>> c.cartesian

<CartesianRepresentation

x=0.739514749012, y=0.138730426089, z=0.658689460119>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Transformacje współrzędnych

>>> c.cartesian

<CartesianRepresentation

x=0.739514749012, y=0.138730426089, z=0.658689460119>

>>> c.galactic

<SkyCoord (Galactic): l=121.123343394 deg, b=−21.6403586966 deg>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

Transformacje współrzędnych

>>> c.cartesian

<CartesianRepresentation

x=0.739514749012, y=0.138730426089, z=0.658689460119>

>>> c.galactic

<SkyCoord (Galactic): l=121.123343394 deg, b=−21.6403586966 deg>>>> c.spherical

<SphericalRepresentation lon=10.625 deg, lat=41.2 deg, distance=1.0>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> from astropy.coordinates import Distance , FK5

>>> c = SkyCoord(

ra=10.625∗u.degree, dec=41.2∗u.degree, distance=500∗u.kpc,frame=FK5, equinox=’J2000’)

>>> c.cartesian.x

<Quantity 369.75737450577776 kpc>

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> from astropy.coordinates import Distance , FK5

>>> c = SkyCoord(

ra=10.625∗u.degree, dec=41.2∗u.degree, distance=500∗u.kpc,frame=FK5, equinox=’J2000’)

>>> c.cartesian.x

<Quantity 369.75737450577776 kpc>

>>> sc = c1.transform_to(FK5(equinox=’J1950’))

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

QuantityConstantsTableFITSCoordinates

>>> from astropy.coordinates import Distance , FK5

>>> c = SkyCoord(

ra=10.625∗u.degree, dec=41.2∗u.degree, distance=500∗u.kpc,frame=FK5, equinox=’J2000’)

>>> c.cartesian.x

<Quantity 369.75737450577776 kpc>

>>> sc = c1.transform_to(FK5(equinox=’J1950’))

>>> sc.to_string()

’9.94122 40.9261’

>>> c.to_string()

’10.625 41.2’

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

AUTO

Pakiet AUTO (Doedel, (1981)) do rozwiązywania bifurykacji wRównaniach Różniczkowych Zwyczajnych.

♦ analiza bifurikacji w systemach algebraicznych

♦ lokalizuje punkt startowy gałęzi, wyszukuje kolejnych orbit wzależności od dwóch lub trzech parametrów, oraz wyliczarozdwojone rodziny orbit

♦ główne algorytmy mają na celu w sposób ciągły rozwiązywać RRZdanego systemu

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

AUTO

The HamiltonianArmbruster, Guckenheimer & Kim (1989)

H =12(X 2+Y 2)+

14(x2+ y2)2−x2−y2− 1

4x2y2

−3 −2 −1 0 1 2 3−3

−2

−1

0

1

2

3

coordinate x

coo

rdin

ate

y

Poincare section x−y E = 6.35

coordinate x

coor

dina

te y

−1.5 −1 −0.5 0 0.5 1 1.5

−1.5

−1

−0.5

0

0.5

1

1.5

−1

−0.5

0

0.5

1

1.5

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Plik auto

from numpy import arange, array

from scipy.integrate import odeint

def fun(u,t):

# D e r i v a t i v e s o f H a m i l t o n i a n .

return(dpx, dpy, dx, dy)

def neworbit(file_name , period, init):

# C o m p u t a t i o n o f n e w o r b i t . U s e s o d e i n t a s O D E I n t e g r a t o r

t = arange(0.0, period, period / 200.0)

t.append(period)

u0 = array([ci[0], ci[1], ci[2], ci[3]]) # i n i t i a l c o n d i t i o n s

u = odeint(fun, u0, t, atol=1.e−12, rtol=1.e−12)

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Special bifurcation rzut x-X

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

3D ewolucja orbit w głównej rodzinie (symmetrycznej)

−1.5−1

−0.50

0.51

1.5

−2

−1

0

1

2

−1

−0.5

0

0.5

1

position xposition y

velo

city

X −1 −0.5 0 0.5 1

0

2

4

6

8

10

position x

ener

gy E

−10

1

−20

2

−2

0

2

position xposition y

velo

city

X−2 −1 0 1 2

−4

−2

0

2

4

position x

posi

tion

y

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

3D ewolucja orbit rodziny rozdwojonej (asymetrycznej)

−1.5−1

−0.50

0.51

1.5

−2

−1

0

1

2

−1

−0.5

0

0.5

1

position xposition y

velo

city

X

−0.50

0.5

−0.050

0.05

0

5

10

BP

position x

BP

position y

ener

gy E

−1.5−1

−0.5

−4−2

02

4−4

−2

0

2

4

position xposition yve

loci

ty X

−1.5 −1 −0.5 0−4

−2

0

2

position x

posi

tion

y

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Podsumowanie

♦ bardzo duży wzrost zainteresowania Python’em♦ proste skrypty♦ nakładki na istniejące oprogramowanie♦ wykreślania wykresów

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Podziękowania

dr Anna Kapińskadr Dagmara Oszkiewiczdr Danka Paraficz

Sławomir Piasecki Kosmiczny Python

WstępAstroPyAUTO

Podsumowanie

Sławomir Piasecki Kosmiczny Python