 We'll have a talk by Swawomir Piazetsky. I will talk about Python in astronomy. Please welcome Swawomir. Hello everyone. My name is Swawomir Piazetsky and I would like to talk today about the Python in astronomy. Why I chose this topic? Well for almost nine years I was working in the astronomy field in the universities and during that time I was introduced actually to the Python and right now I don't do astronomy that much but I'm working in a company that uses Python every day. So I thought it would be nice to marriage these two topics and my interests and both of the fields and present this speech. So what I would like to talk about today will be like three points, what I would like to just briefly say about astronomy itself, some short history of astronomy with the points that for me are quite important I think in astronomy. I would like briefly describe the package Astrobi which is a package dedicated for astronomers and astrophysics that contains in one place most of the important models and methods using in astronomy and in the area I would like to talk about auto which is a hybrid software, Python and Fortan that I was using during my research in astronomy. Okay so let's start with the beginning. So as you probably know the astronomy is one of the oldest sciences and the first observation was actually taken by the naked eye. So the Asians civilization like Babylon like Maya, Greeks or Egyptians they were using only just eye for just to check what is happening in the night sky and what they are using this information well they were using mostly for navigation for creating simple calendars for agriculture for religion purpose just to manipulate the people of course because once you know where is the solar eclipse for example you can just say the people that yeah you have to pay us more because the gods are very angry on you. So that was like the very beginnings of the astronomy so actually wasn't that much science on it but the first civilization that started to think a bit deeply about astronomy and giving more important questions like what is exactly happening above our heads why it's planets moving this way not the other way and what is our purpose in the universe. So the Greeks start looking for these answers and what they achieved they achieved to estimate the distance between Earth and Moon and they introduced their geocentric system that put Earth in the center of the system and all of the visible objects as planets, sun and even stars were traveling around the Earth. They also started to creating the first astronomical catalogues of the stars and they were able to find with an naked eye just around 1000 of stars they were able to precisely give the coordinates of each of the stars so you could easily find out in some time when you would like to search for these objects. In the middle ages the Europe was not that much into the science because of different things that are happening here but lucky for us the Islamic world was really into the science they really put further the study in astronomy they improved the methods of the observation they were able to discover a few galaxies and some supernova as well they also introduced quite a lot of names and terms that are nowadays using in astronomy but the first revolution in astronomy in my opinion was actually just changing the way of the thinking of the solar system hours so the Copernicus Polish astronomers decided to dethrone the Earth and put in the middle the sun in this case all of the planets would be going circular around the sun and with this model it was much easier to explain why the planets behave like they behave right now but that was just a theory he was not able to prove it in a mathematical way or even observation because at the time there was no instruments he was doing all of the observations still with an naked eye but with the help of that came the Galileo who invited the lunat and one of the first objects he was looking at was Jupiter and he discovered that around the Jupiters are small objects the moons that are circular around it so it was kind of proved that it's possible that around the biggest objects travelling are some smaller objects so that kind of proved that Copernicus had the right and that around the sun it's possible that all of the planets are silkering Newton and Kepler just proved this model in mathematical ways and for the next decades what was happening in astronomy was just improving the telescopes and the method of observation and thanks to this we were able to see deeper and deeper to the universe we were able to discover more objects we were able to create a bigger catalogues of the stars that we know is until the photography was invaded from that point I think astronomy moved very fast in the discovery of new objects because we were not able only to point exactly the position of the objects but we were able also to store some information about it so as for a star that it's quite easy because the star doesn't move that fast but with the photography we were able to detect some near-earth objects that are passing very fast and they are not that bright as a star but we were able to capture them on the photography so when you have several photographs from different nights and you can see that some objects are moving like tweeting then you probably found some asteroids that it's just passing by the earth and the last I think revolution in astronomy came with computers of course today we cannot imagine even any science without computers because we do some nasty complicated computation on it we replace the analog photography by digital photography and we were able to send even the telescope to the space that's why we avoid lots of noises made by atmosphere and earth and we are able to see even deeper and discover very rare objects in the sky so when we have computers we need also some programming languages and in astronomy most important programming languages is Fortran and C++ why those tools? Because they were made actually to do some numerical computation they are very fast, they are very powerful and because they are quite long already in use we have a lot of libraries and a lot of software already is written so many software in astronomy written in Fortran and C++ that there is no even sense to trying to rewrite it into the Python or any other modern languages because it just will take too much time okay so I also ask some astronomers why they choose the Python so I would like just to show you some results of the form that I sent to the astronomers community and one of the first question I ask them is just why they choose Python so I think that it's not really huge surprise that they choose it because it's a huge community they can easily get any answer if they have any problems there is quite a lot of modules that they can use it and they love it because they get tools to create plots before there was some software but right now with Python they can actually customize as they want and as they wish and that's why they really love it but what they are using for the Python so yeah one of the first thing and the most answers were answer was the drawing the plots they really use it for it they using some every single script for backups for maintaining some everyday work they doing for some simple scripts that are using just for the current work of course they using also for data analysis of the observation and I heard also that some of the telescopes are controlled by the software written in Python what are the favorite packages I would be not surprised that it's a non-py, cpy, matpotlib for drawing the plots math and astropy and yeah the next thing I would like to talk about astropy because it's just the package as I mentioned in the beginning concentrating on most of the important metals in astronomy and astrophysics in one place but I would like not to talk about all of them because then I would need much more time I would like just to show you few of them and just slightly describe what for they can be used and why they introduce them to the astropy so first will be the units and physics and astronomy you cannot tell and describe any events without the units you cannot say that someone is walking with a 5 because you don't know if he's walking 5 kilometers or he was walking 5 minutes or with a speed of 5 meters per second or whatever so you need units just to finish the just to fully describe the event so an astropyte if you import the submodular units you can get most of the important unit in astrophysics and astronomy like meters, kilometers, Celsius, kilograms and so on so once you call it units and meters you get the object called unit of course and with the name of meters so I was thinking that it would be nice to show how does it work if we will just have a simple task to solve let's say that we would like to know how much time do you need to cover a distance of 15 kilometers if you are moving 5 meters per second so let's introduce the distance if we call it we will get the object which is quantity and with the quantity we have the information of the value and of course of the units that's what we can do with these objects well we can easily convert this value to meters to any other distance length of course we can multiply and divide it and so on and so on so let's introduce also the velocity the velocity as I say will be 5 meters per second and yeah it's not a rocket science so if you want to know how much time do you need it you have to just divide the distance by velocity and the result of this equation will be 3 kilometers multiplied by second divided by meters it's kind of weird for the time unfortunately AstroPie have a problem with simplify the units so if we have this kind of problems we have to a little bit help him just calling the compose and we will get of course the correct answer which will be 3000 seconds which is 50 minutes ok so if we know how to define the distance I would like to talk about the distance in astronomy right now in the earth we are using kilometers, miles, meters and so on we know how to how far it will be 5 kilometers away from here more or less or 5 miles but in astronomy kilometers are not always that useful I mean we can use it for nearby objects like satellites, like moon even but not much farther I mean the moon is in the nearest point is like 380,000 kilometers away in the farthest way will be around 405,000 kilometers so you can see it's already kind of difficult to repeat this number and this is not that far away in astronomy actually it's just nothing so if we would like to see the distance between earth and sun you can see it's like 150,000,000 kilometers away more or less if I would like to repeat the number I would have some problems with that and because the astronomers like simple things they just introduce a new unit it will be astronomical unit which is from the definition the distance between earth and sun with this value we can very easily describe the distance between planets from the sun or from each other and it's just much easier to say this is like 5 astronomical units instead of huge number of kilometers but this distance it's not good if we would like to travel inside our galaxy because the nearest star are far away from us and we need a new unit which will be light here which could be also kind of confusing because from the very first point if no one knows what is it it could be like a unit of a time but actually it's a distance that a light needs to cover during one year which is around 63,000 astronomical units but the light years are very nice for galaxy inside the galaxy but we know already that there are other galaxies we would like to travel to other galaxies we need another unit of the distance and we came with a parsec which from the definition would be like 3.26 light years and with this unit we can start to talk about distance to galaxies, to quasars, to black holes supernova and so on ok, so I would like to show you why it's so simple using astronomical units as you can see on the left side we have planets in the solar system it is of course with a one and it's just easier to say that Neptune is 30 astronomical units away from the sun than yeah, I know what is it, 4 billions kilometers and on the right side we have few of the nearest stars in the light years so if you can remember one light year is 3.26 no, it's 63.000 astronomical units so yeah, for the proxima centauri we need to travel like 4 years with a speed of the light to get there ok, and astronomy and physics you also need some constants and these constants are also introduced to the astropy and I would like just to briefly show you two of them, one will be quite important gravitational constant so once you call it you get the value you get the error of this value of course you get the units because we are operating with the units and some reference where you can find the actual definition of this constant the second constant that I think it's kind of important in astronomy would be solar mass as you can see the value is very very high and the sun it's not actually really huge one and the universe is actually the average size of the sun so if we discovery any star and we are able to determine the mass of the star we will use the units mass of the sun ok, the next thing will be table it's really nice subclass using for astronomy because we can start to do quite nasty competition with it but to introduce the table we need three equal lists of here will be the integer, float and string so this is the way how we we can introduce the table and we can add the names of each of the list we can add some extra metadata to the objects and if we will call it we will get the information about the length and how does it the table looks like and what we can do with the table well we can from the beginning we can just add the well known units to one of the table so let's set the unit and if we will call it again we will have the information that a second column is with a unit of seconds so now we can start to multiply divide it we can start to do some computation on rows not only on the columns it's kind of a lot of things to do with the table I think it's worth to have five minutes and just check it what probably you could use it for okay and in astronomy you cannot do any observation if you don't have any coordinate system you have to have some points like like in the earth we have in astronomy we have different coordinates depends on the on the telescope it's that was created so we can all of the coordinates are in the spherical representation the only difference between them is the starting point of counting the angles and here you have several ways of introducing the coordinates thanks to the astropy coordinates so we have here one of the coordinate system that we can describe using the time which will be like 42 minutes and 5 and 30 seconds and the second variable will be 41 41 days and 12 minutes and so on so what we can do as I mentioned what we can do with this variable as I mentioned we have different kind of coordinate systems so first of all we can start converting to different representation we can convert it to the Cartesian representation and get a well-known value of x, y and z we can also convert to this spherical representation we can also convert to other coordinate system here what I was using is a galactic galactic coordinates just to describe position of the galaxies and the sky what we can also do we can also add a distance to the objects and then when we call it the Cartesian representation we will get the value and the value of the distance the catalogs the catalogs are made for some specific times one of the most popular time is for the 2000 years so we have to represent the position of the objects at the time that he was visible at the time of 2000 thanks to this we can later transform to other epochs and check what time and we can check that the position of the object is completely different like for example here 50 years ago so if we will just print the coordinates of system one and the epoch of 2000 and the second in 1950 you can see that the position of the object was slightly different okay so the auto this is the part of the work I was doing in the field of astronomy and the software is a hybrid of Fortran and Python Fortran do unfortunately most of the work he's doing the computation and the Python is using just for communicate between the user and the Fortran so with that package we are able to do computation on periodic orbits periodic orbits are the solution of the equation that are repeating in some time which will be easier to say that if we have an orbit and some object is spinning around it the periodic orbit will be the one that after some time of t the object will come exactly to the same position with the same value of velocity and the same direction so thanks to this software we are able to check how the system is changing when we increase for example one of the value in this case let's say the energy so once we add a little bit more energy to the objects the trajectory of that object will change and that software help us to find these changes and put it as a kind of the family of the periodic orbits in some points we can have several solutions for the same for the same starting points and these points are called bifurcation points so that will be looks like if we represent any family orbits as a slide as a line the periodic orbits will be just adding some branches to the light to this line so in my work we choose one of the Hamiltonian which described the energy of the system by giving the position and the speed of the objects on the left side I choose to plot on the Poincare section how could the orbits looks like so each dot represent one periodic orbits and as what actually the plot is showing is that in this field in these places we have orbit periodic that are not stable so after some time they can't lose the stability and there will be no more periodic orbits and in this position where we have some kind of structures and the orbits will be stable and even after a thousand of years there will be still periodic orbits and nothing will change on the right side we have the representation on the coordinates of the value of the energy okay so where is the place for Python over here and Python is used as I mentioned just to communicate with what we have for fun what we have to do first we have to define the function which will be the equation of motion of the Hamiltonian that is described over here so we have to take a derivative of each of variables and return the value to the from the function we also have to describe the orbits this first orbit that we are starting from so we have to give some initial condition and just start to compute to get the whole the whole orbit with the positions and velocities and if we will have this information we can start and do a computation and we get some some results so the results of this computation was getting this this plot which is the which represents the family of the orbits that we are able to find so here also each dot is a one orbit a periodic orbit and as you can see this is kind of evolution of this one orbit here the green is a stable orbits red one are unstable and these plots are just showing like if we would like to slice in this energy how the orbit looks like in the system here we have a chaotic orbits which are unstable here we have a stable one and this is just the Poincare section which show exactly the same here we have a slightly different value of the energy so what I would like to do in my work is like looking for finding the branches but not in the flat in the flat images only to create the free 3D maps of all the branches so we will start to looking on this main branch over here and it's representing over here and we start to check how the orbit looks like this example is just showing all of the symmetrical periodic orbits that can be seen over here we have one symmetry and going from one point to another we can see how the we should see how the orbits might change during the evolution of the orbits so we knew it that in these points from which we will get more solutions so we could follow those solutions and check how the how the new orbits will look like so if we go to the next slide we can see that after the bifurcation points we lose the symmetry it's the first thing that we are noticing and the second thing is that just after bifurcation points the new orbits that are stable and all of them are unstable what was also quite interesting that we have two different points but actually there are kind of common in this family in the evolution of this family and yeah so that what we get it from the auto packages and it will be kind of all from my talk so for the summary what I would like to say is just that Python is start to be more and more popular in astronomy mostly for teaching the students as the first programming languages they really really love it for for drops of the plots and yeah if you are thinking that the Python could be I don't know do some revolution in astronomy it's mostly using the plugins for existing software just to communicate with with already existing software instead of writing a new one because it's not that fast as Fortran or C++ so what would like also thanks to colleagues of mine that have a look on the on my presentation some correction and that will be all okay thank you we have time for a few questions a bit more thank you very much for the presentation and short introduction to astronomy can you please explain what's behind the Pasek I understand the light here is Pasek yeah I can try explain what is the Pasek Pasek is a distance of astronomy units seen as a arc seq value so you have to be you have to be that far away from the earth so you can see the distance from earth and earth as a one arc seq value so this is kind of definition it's kind of difficult to explain it but something like that just the angular so I notice you're wearing an STX next t-shirt are you working with astronomy still at your current employer no no day more I've been one of the friends of mine trying to give us some work but in the end it didn't happen so at the time I'm just working as a developer any more questions well really really nice talk and do you think solutions as Scythe on Numba or these type of things are going to improve or extend the use of Python in astronomy like GPU acceleration I don't know because you said it's used mainly as a wrapper for other Fortran or C++ things have you heard about usage with Scythe on Numba well they use Scythe and Numba for some simple scripts that they can they could use in different languages but in Python it's just generated much faster so as far as I know and what I was doing as well was just like simple computation that I just need for next day or whatever that's all I can say so if there are any more questions thank you very much thank you