[Music]
now we've heard about the Australian
syron so now we're going to hear about
iic which is the International Center
for radio astronomy research is that
right yes that's where I work but that's
not talking
about I'll move away so we're going to
hear about python for astronomers from
Andrew
Williams Andrew is an optical astronomer
who moved from Research into software
for telescope and instrumentation Auto
automation he's been working on the
merchants and Widefield array and
relocated and related instrumentation
since 2007 he works for C uni in Perth
Australia thank you Andrew
hi I'd like to start by acknowledging
the N Nation where I work and the uh uh
B the sorry the IM Nation where this
photo is taken and the cooland nation
here I normally work on this guide this
is a merch and wide field array radio
telescope out um in the middle of
nowhere uh but I'm not going to be
talking about that I'm going to be
talking about how you can use Python to
do astronomy astronomy
calculations uh for non-
astronomers so glossing over all of the
scary mats as Lizzie put it started my
career here uh I actually did a um
honors and then a PhD building a digital
camera for this telescope uh it was a
liquid nitrogen cooled camera to set up
an automatic search for Supernova uh and
I was going to hand this around but I
didn't realize it was going to be in the
big room this is $10,000 in 1989 money
of uh CCD chip and analog to digital
converter for that camera this is the
actual chip in the camera that I built
so if you want to geek out about
obsolete Electronics find me at lunch
time so that was the first digital photo
taken in W by digital photo there's some
caveats like I mean taken by digital
camera not digitized and not of
something in the sky through telescope
that's a 5 and 1/4 in floppy and a
cardboard box taken using a pinhole
camera I put a pin in a piece of
aluminum foil that was the first picture
out of the to out of the
camera but first of all I'm going to
talk about coordinates
um when we talk about the position of
things in the sky we usually don't know
distances so for coordinates we use
angles from The
Observer so those angles are the
direction that need we need to look to
see that object so we represent a
position of the Sky by two angles
describing a point on the inside of an
imaginary sphere around the
Observer it's equivalent to latitude and
longitude we measure positions on Earth
uh with angles from the center of the
Earth around uh what's not an imaginary
sphere well it's not a sphere but around
the the sphere of the earth coordinate
frames we need to work out what
references we're using when we're
talking about a coordinate called a
coordinate
frame so the frame we use for both
astronomy and for latitude and longitude
is based on the rotation of the Earth on
its axis so for longitude the zero point
is what we call a grenwich Meridian it's
just an agreed upon point on the earth
that we call Zero
longitude and uh that agreed upon point
was agreed upon fairly late the French
had a zero longitude line go through
Paris Observatory and it just happened
that the the English one out the
references for latitude of the equator
in the pole so 0 degrees latitude is on
the equator minus 90 is a South Pole and
Plus 90 is a North Pole and we use
exactly the same system for coordinates
in the sky so we can refer to what do we
call Al azth coordinates where azth is
the compass bearing that you need to
face in order to look towards the object
North is 0° uh East is 90° and so on and
altitude is the angle above the Horizon
it has a couple of different names
sometimes altitude is called um
elevation the elevation angle and
sometimes to be really different uh
people talk about the Zenith angle which
instead of being the angle above the
Horizon it's the angle from straight
overhead so you can find coordinates uh
that are sort of altitude or elevation
or 90° that which is a zeni angle the
problem is the Earth is turning and
moving so if you work out what the
altitude and ath is for the moon or
alpha centur or anything else
it's only true for that location on
Earth at that instant in time not really
useful for telling uh putting in a
catalog to say this is where AA Sor is
compared to other
stars so we Define a new coordinate
system uh using uh Celestial equator
which is the line in the sky above the
equator of the earth and the celestial
poles which is the points in sky above
the poles of the earth so you can only
see one of the celestial poles at a time
unless you're exactly in the equator in
which case you can see two but they're
just on the equator in the northern
hemisphere the north Celestial pole is
always due north and it's an angle above
the Horizon roughly equal to a Latitude
um it would be exactly equal if the
Earth wasn't a sphere and things weren't
more
complicated I said the Earth was a
sphere rather in Perth the South Cal
pole is always due south it's at roughly
32 de above the Horizon and if you look
at the stars at night all of the stars
rotate in a circle around that pole so
if the South cesal Poles over there a
star might go in a circle like that
taking 24 hours to go around further
away they go up and down and above and
below the Horizon but close to the pole
they go in
circles so equatorial coordinates uh
need a reference frame and just like uh
longitude we pick an arbitrary point in
the sky and we call that zero R
Ascension ra is the equivalent of of
longitude in the sky uh don't ask me why
it's called R Ascension historically
Reasons from hundreds of years
ago and also for historical reasons it's
often measured in hours minutes and
seconds counting around like time zones
only to the microsc if you want an
accurate
coordinate zero point for ra is this
arbitrary fix point on the sky called
the first point of Aries it's the point
where the ecliptic crosses the um the
celestial
Equator the declination of a star is the
angle above or below the celestial
equator from Plus 90 the north Celestial
pole the point in the sky right above
the nor nor pole all the way through to
minus 90 at the South Cal pole so we've
got right Ascension which is like
longitude measured around the clock
around the the equator and declination
which is like latitude from- 90 to Plus
90 the Earth is tilted relative to the
rest of the solar system relative to the
sun and the other planets so that
inclination line is how much the earth
axis is tilted we've got the north
Celestial pole directly above the North
Pole of the earth South Celestial pole
directly above the South Pole and we
measure uh R Ascension is one of that
those thick red arrows and declination
is the other thick red arrow uh right
Ascension being the equivalent to
longitude and declination being
equivalent to
Latitude there are some caveats um the
earth axis is actually drifting on the
sky uh the Earth imagine a top slowing
down it kind of does that so the Earth's
axis is doing that sort of motion that's
called procession well the procession is
this motion the mutation is is the
bouncing up and down as it rotates and
that happens over thousands of years but
because the earth axis is actually
moving in a different direction in the
sky every year we need to give the
position as a right attention and a
declination and some kind of idea of
where the Earth Anis is pointing at the
time usually we we talk about j2000
meaning a coordinate frame using the
positions on the sky relative to where
the Earth's axis is pointing at the
start of the year 2000 in the 1980s they
often use uh 1950 as a reference instead
of
2000 so it's a little bit like measuring
latitude and longitude if you wanted to
use the magnetic pole of the earth
instead of the the true um the
rotational pole you know the magnetic
poles are drifting so if you wanted to
measure longitude and latitude using the
magnetic poles of the earth you'd have
to specify where the magnetic pole was
when you uh defined those
coordinates modern positions and a
modern catalog usually What's called the
icrs frame which uses 2,000 as an
equinox to refer to where the axis is
pointing but they Define coordinates as
seen from the center of the solar system
not from the earth which makes a
difference for nearby objects but not so
much for Far Away objects an alternative
is the gcrs frame which is also used the
the 2000 Equinox where the axis was in
the year 2000 but refers to coordinates
as seen from the center of the Earth or
there are modifications uh where you can
can use coordinates as seen from your
particular Observatory and that's
important if you're looking at things
close in like if you want to look at um
Mercury it's more useful to define the
coordinate as seen from the earth and
not as seen from the center of the solar
system because your telescopes are on
earth if you want to represent time this
is the first real code here uh I'm going
to talk about the astropy library
because it's um the most General
astronomy Library you can find it is
incredibly accurate incredibly detailed
and if you read the documentation it
will dive you straight into curly
horrible scary maths that you don't need
to
know the basic idea is you import a Time
class you can either ask for the time
now or you can pass it a Constructor uh
in a whole range of different formats uh
it understands a bunch of them without
you're needing to explain like if you
just give it a year month day hour
minute second it'll understand that if
you give it uh a big number and tell it
the format is UNIX that's your the Unix
Tim stamp if you give it a date time
object it'll also work it out and just
tell you I put scale equals UTC there
because there are a bunch of different
time scales they're all slightly
different um they all have different uh
features like some of them are um
relative to what's called atomic time
some of them are locked to the rotation
of the earth if you don't know what a
time scale is you want UTC if you do
know what a time scale is you
99.99% of the the time want UTC but the
time class sometimes gives you a
different one if you pass it on usual um
signing value so I'd always say scale
equals UTC there just to be
sure for output there are a whole bunch
of attributes you can ask for the iso
representation if you want a string the
Unix representation if you want a a
Epoch timestamp the mjd if you want the
modified Julian day there's a whole
bunch of different attributes if you
want in different
formats the other cool thing about asrai
is almost all of the constructors of
these objects accept iterables as a
value so if you create a Time object
that has an array of values then you get
a single time object that internally
stores that as a numpy array of all of
the values you passed to it and you can
then use that one time object in
calculations and you'll get back an
array of values one for each item in the
input array that's useful because all of
the hairy calculations are done on the
nump as a whole and all of the hairy
parameters about exactly how that time
is defined stored on the object as a
whole and all it stores is a num
values so if you wanted to represent a
position you ask for a Skyward object
Sky cord is a generic astropy uh class
that represents the coordinates of
things in the sky and just like time
there are a whole bunch of different
ways to specify them uh you can ask for
uh a simple
passing two values and if you just pass
two values it recognizes the first one
is right Ascension and the second one is
declination you uh specify the unit with
this unit argument so here both of those
values the first one and the second one
they're in degrees if you want to pass
an a r Ascension in hours then instead
of passing um degrees as a unit you pass
a tupal and the tupal represents the the
units for the first parameter and the
units for the second parameter so that
is 1.234 hours andus 2634 de for R
ension
declaration for uh C we're specifying
the right exension as what's called a SE
admal value that's just hours minutes
and seconds just like you'd specify time
123456 and you can specify either hours
minute seconds uh or degrees minute
seconds you can specify the degrees
value Asus 32 uh degrees 3 minutes and 4
seconds and by the units we've specified
exactly that it's 12 hours and 34
minutes and not 12° and 34
minutes uh if you pass a third argument
uh without a um a parameter name then
it's the distance and again we've
specified the units for that distance as
light years there's a whole bunch of
different units you can use if you ask
for the attributes you can ask for the
value of uh the RA in degrees if you'd
said a. ra. hour you'd get the value
back in hours as you can see on the
second line they're also internally um
storing this as a cartisian
representation so uh you can ask for the
cartisian value and you'll get your x y
and Zed in light years uh and because
these are ICS coordinates it's inight is
from the center of the solar system if
you don't have a distance for that
coordinate then what you get are an XYZ
value in dimensionless um unit one
radius sphere so it's not as useful
you can also look up objects by name
internally that uses what's called a
sesame website run by research
organization in France uh so you can ask
for the name of a whole bunch of
different objects um in from you know
random catalog names in catalogs of
pulsars through to things like alphas
and T once you created it it behaves
like any other Sky coordinate object so
you're going to ask for the hour or the
the RA in hours or the the declination
degrees or the cartisian representation
uh it does not supply distances if you
ask for the distance of alpha centor you
won't get it you'll need to look it up
in a in a catalog and I'll talk about
that
later so uh for objects inside the solar
system we have get sun to tell you the
position of sun get moon tell you where
the Moon is or get body to tell you
where Jupiter or Europa or uh whatever
other solar system body you want and
these things need time as an argument
because all of these things move around
the position of m42 doesn't move it's a
it's a a Galaxy um well not in human
time scales position of the Moon and Sun
and Europa do move so you create a time
and you ask for the position of the Sun
or the moon or what else you want they
return Sky coed instances but um because
they're almost all used to well all of
these functions are used to return the
position of things inside the solar
system they return the positions
relative to the Center of the Earth not
relative to the center of the sun you
can convert it if you want to convert
gcrs uh coordinate to an ICS then you
can do it just the same way you do for
an Al asth conversion and I'll talk
about that later and that's useful
because if you want to get the cartisian
representation back you can ask for the
coordinates of the Sun Moon Europa any
solar system bodies you want convert
them to ICS and then you the cartisian
coordinates Define where these bodies
are in the solar system if you to you
know plot them in a a game or whatever
else you want to
do you can also get uh the location in
cartisian
with velocity so the um OBS do
geolocation um will tell you that the
distance
uh sorry I was talking about the next
slide so this is the cartisian
coordinates of the Sun as seen from the
earth you can see the distance is 99 358
astronomical units not light
years if you want to do alth conversion
to work at things where appear to be uh
for a particular Observer
you need to create what's called an
earth location uh you can do that either
with a from geodetic call where you give
it a latitude and longitude and a height
above the ground or if it's an
observatory you can just ask a location
of parks for example or
mwa internally they're stor as Earth
centered gcrs coordinates in meters uh
but not including the rotation of the
earth so if you ask for the location of
the mwa you'll get back a fixed set of
numbers in meters um defining where the
m W is and that uses the the computed
geode of the earth not assuming it's a
sphere so you're can ask for the Y value
or the cartisian representation in X Y
and Z
uh you can also ask for the um position
and velocity if you pass it a time that
get gcrs posel uh function um Returns
the position of the the mwa telescope
now and the Velocity in x y and Zed in
m/s
uh which is kind of Handy if you want to
plot the Earth turning or how the Earth
is moving in in time and that's used for
a whole bunch of internal calculations
as
well if you want to transform a
coordinate from where it is in the sky
to where it looks like on the ground uh
you create uh Earth location where
you're observing from you create a time
using the same uh Creator we saw before
you create a position for example a
Galaxy called NGC 2997 that's my
favorite Galaxy um you create a
reference frame called alt as um and
that's in the astropod coordinates um
Library so Al as has two parameters an
observing time which is when you're uh
looking at this object and a location
which is where you're looking at it from
and that coordinate frame encodes all of
the scary MTH to transform positions to
um as seen from mwa at that time and
again your observing time can be an
array of values it can be one time
object with 500 times in it uh your
location can have uh a numpy array of
locations in it uh your Sky coordinate
object can have a numpy array of
positions they don't broadcast well uh
you you could generally have one scaler
and a bunch of arrays if you want to
broadcast that one scaler over all the
array values or you need to make sure
all the array values are of the same
dimensions um so if you have 100 times
on 100 positions you get 100 locations
of that each one position at the
corresponding
time your new object after you've used
this transform two function is also a
sky coed object it represents the same
position on the sky but it has a couple
of extra attributes called alt and as
and those Alton as uh are the altitude
above the Horizon and the the aamus the
compass bearing
now all of these attributes of raas and
decks uh and positions and distances
they're all ASI um dimensioned objects
called Unit objects and that's good if
you want to um make sure you're
extracting the right value if you just
ask for the value of the ra you won't
know immediately whether it's in degrees
or hours if you ask for the value of the
distance you won't know it's whether
it's in meters or astronomical units or
light years so you generally need to ask
for the specific unit that you want so
uh al. deg means you're asking for the
value and degrees of the altitude if you
asked for alt dot um hours you could in
theory convert the altitude hours um you
can use these units objects in your own
calculations if you want to create a
value in um kilograms and another value
in meters and divide one U of these
variables by the other youd need to ask
for the result in um kilog per meter uh
and that makes you sure that your
dimensions are correct when you're doing
your
calculations in other words NGC 2997 as
viewed from the mwa at that time on that
date was 60.7 de above the Horizon and a
little bit south of G
West you can also use Astro query Astro
query is a library it's part of asai
that um lets you import
classes that let you interrogate
websites Vier for example is a website
run again by the same guys that do uh
Sesame uh in France and it has many
hundreds of catalogs and each of those
cataloges has many thousands or
sometimes millions or billions of
objects Vier is just one website the
Astro query Library supports dozens of
websites each one of them has its own um
subl Library as
curvier creates a Vier class to um
explore the Vier website as query.
simbad might have a different CL a
different uh class that explores a
simbad website each of these websites is
run by different organizations they'll
have different types of librar some of
these uh cataloges and libraries return
positions and brightnesses and other
parameters for objects some of them
return images so there's an astro cury
Library that that's you return James web
Space Telescope images of whatever field
you want each of them has a slightly
different interface because each of them
is specific to that website there are
some things that they have in common uh
an SQL like search Syntax for finding
things called um
Astro I can't remember what it's called
anyway SQL like so for visier in
particular we can uh do things like
search for catalogs that might be of
interest you can either do that by going
to the viia website and looking or
there's a a query called find catalogs
let you specify some Search terms and
get a catalog list and that catalog list
if you ask for the catalog name of the
description gives you a string which is
the name and the description which is
just a on line summary of what the
description is now when you actually do
that it returns 10 or 12 different
catalogs one of them is called ja a67
a19 that's the the code for that catalog
called the fifth catalog of nearby stars
and that's got about 6,000 nearby stars
in it it's relatively recent it's got
lots of data it looks like it might be
useful so first of all we say the row
limits are minus one by default viio
will return just a few rows to minimize
um load on their server we ask for um
that particular catalog we get a list of
cataloges with that one entry in it uh
and we can ask for element zero of that
list NSC is now what's called an astropy
table astropy tables are pretty cool
first of all they've got a nice um uh
representation uh we can see that we're
pretty printing it we're skipping over
all of the um col columns that we can't
fit across the width we're summarizing
the
rows uh and it's got a bunch of stuff in
it you usually don't need to lose the
whole catalog many catalogs have
billions of entries
well many catalogs have thousands most
have millions and some have billions so
you use um attribute you use methods on
that visier object uh to filter however
you want you can ask for uh the area of
all records in a given area of sky for
example query region you're asking for
the records in a small region of sky in
this case around m81 you know 10 art
minutes around m81 uh you can also
filter by brightness or any other
parameter want dist um any parameter you
want you can specify in this uh filters
column and you get what a list of table
objects table objects are kind of cool
you can ask for the keys and and
represent it as a dictionary uh so in
this case you've got 31 keys with things
like Parallax and uh ra and deck you can
also index by a row number so the
catalog at entry 5 at r aj200
is exactly the same as the catalog at
r2000 entry number five both of them are
the same you can Google that catalog uh
name or you can search for it on the VIS
site you can see that ra2000 and deck
2000 are the coordinates and plx is the
parallx uh pmra PMD and RV are the the
proper motion how fast it's moving in
the sky and the radio velocity which is
how fast is moving towards us so they
represent
velocities Parallax is the difference in
position of that object as seen from
when the earth is in one side of its
orbit and when it's in the other side of
its orbit if it's nearby the angle
appears to move by a lot if it's far
away the angle doesn't move much at all
one Parc has a parallax of one Arc so we
can create a new aray called distances
which is um
32656 that's the uh light year to par to
paret conversion divided by The Parallax
and then we just create a sky coordinate
object that has an RA value which is a
numpy array of all of the raas in the
table a deck value which is a numpy
array of all the declinations in the
table and a distance value which is all
the distances in the
table and then that Sky coordinate
object you can do whatever you want you
can ask for the cartisian uh attribute
to get those X Y and Z values in uh in
um coordinates in in light years or you
can use transform to Al as to get the
altitude and asouth of them or whatever
else you want if you want to go further
give me an email there's a lot of stuff
I glossed over uh astropy documentation
is very cool but very complicated uh I'd
highly recommend skyfield if you're
using anything inside the solar system
skyfield is written by Brandon rhods
who's been out and done Keynotes here at
as Pon a couple of times astrop plan is
good for planning observations um if
you're actually uh planning a telescope
use so I'd highly recommend those guys
and that's it
awesome thank you very much I really
enjoyed it and I really like astronomy
so that was quite
nice just as a quick thank you we've got
a mug for you y thank you little p on
our you mug so cool yeah thanks a lot
thanks very
much now we're going to have a quick
10minute break and then we've got our
next talk on napari