Latest / Talk Python To Me / #303: Python for Astronomy with Dr. Becky
Transcript
- 0:00If you're involved in science or use computational tools in your work,
- 0:03you should be using code to solve your problems. On this episode, we have Dr. Becky Smethurst,
- 0:08who is an astrophysicist at Oxford University and uses Python to explore galaxies and black holes.
- 0:13Learn how she's using Python to make new discoveries at the cutting edge of research
- 0:17and dive into a couple of her YouTube videos aimed at spreading scientific truth in an
- 0:22entertaining rapper. This is Talk Python To Me, episode 303, recorded February 4th, 2021.
- 0:28Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:46and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy,
- 0:51and keep up with the show and listen to past episodes at talkpython.fm,
- 0:54and follow the show on Twitter via at Talk Python.
- 0:58This episode is brought to you by Linode and Cloud ENV. Please check out what they're offering
- 1:03during their segments. It really helps support the show. Dr. Becky Smethurst, welcome to the podcast.
- 1:08It's so great to have you here. Yeah, it's great to be here. I'm just happy to have a
- 1:12chat about code on a Thursday afternoon for me. One of the things that I like to do is I like to tell
- 1:17stories of people doing amazing stuff with Python, not making Python necessarily their entire world,
- 1:24right? Like it's awesome to talk to the people maybe at Instagram and how they're building Instagram
- 1:28with Python. But I think it's also really neat to shine a light on people doing other things like
- 1:33astronomy or economics or whatever, but also, you know, using Python as a superpower. And it definitely
- 1:40get the sense that that's kind of your world. Yeah. It's fun. Like thinking about not just all the
- 1:44things that you can do with Python, but like humans in general can do the things that I am doing
- 1:50with Python, like that we've figured all of this out, you know, that we can then use a tool like
- 1:55Python to do it. It kind of blows my mind that I get to do that every day. In your world, there's
- 2:00probably a lot of supercomputers and high-end, you know, there's a lot of stuff behind the scenes,
- 2:05behind maybe a simple Jupyter notebook, right? Yeah. Just a little bit like the Oxford physics,
- 2:12like a supercomputer is called Glamdring as well. Like everything's Lord of the Rings references.
- 2:17Okay. Awesome. So these like conversations you have with other physicists in the department being
- 2:21like, Ooh, did you, did you get time on Glamdring? Like how did you get hands on Glamdring? Like it
- 2:26makes it sound like we're passing around this sword between us all like that.
- 2:29That's amazing. And I, you know, we're going to talk a bit about your YouTube channel and some stuff
- 2:35that you're doing there as well to popularize astronomy and whatnot. And one of them, you talked
- 2:39about how at Oxford where you're working, there's actually some of the scenes from Harry Potter
- 2:44shot as well. So there's all sorts of cool fantasy movie tie-ins here, right?
- 2:48Yeah, definitely. So Oxford has them, the colleges and my college Christchurch is the one they used
- 2:53in the first film for the steps up to the hall where like Trevor finds his toad and McGonagall welcomes
- 2:59them and stuff. So the amount of times I've walked up those steps and like quoted parts of the film,
- 3:04because I'm such a Potterhead. But then also I managed to somehow get past the referee on one of my
- 3:09scientific papers to name galaxies after Harry Potter characters.
- 3:12Oh, fantastic.
- 3:14Because like when I was at the telescope taking the data, I was highlighting them like red,
- 3:18blue or green, depending like whether I was observing them on like Tuesday night, Wednesday night or
- 3:23Thursday night. And so I named all the red ones after Gryffindors and all the blue ones after Ravenclaws
- 3:28and all the green ones after Slytherins. So yeah, I ended up with, you know, writing a paper that was
- 3:32like Hermione shows interesting features. It was great.
- 3:37Oh, that's fantastic. I love that. Let's kick off a little bit of background about you with a comment
- 3:41from live stream. Robert says, I like Dr. Smethurst. She reaches for the stars. Fantastic. So maybe tell us
- 3:46a bit about yourself.
- 3:47Yeah, sure. So I am an astrophysicist. I work at the University of Oxford at Christchurch and I research
- 3:54how supermassive black holes affect galaxies. And that's sort of like my day job. And that includes,
- 4:00you know, going to telescopes and taking data, coming back, analyzing that data with Python and then
- 4:06writing it up and publishing it to the world. But then sort of was like a side hustle, I guess you could
- 4:12call it. I have my YouTube channel where I like to just chat to people about space and astrophysics and
- 4:18all the research that's going on in astrophysics right now, because I think there's often a disconnect
- 4:23between the public who are like, I think so many people are interested in space in general, because
- 4:28it is one of those things that there's just an abundance of questions that we don't know the
- 4:32answer to. And that's why we're still doing the research. And so everyone is so curious about it,
- 4:36but they don't have a friendly neighborhood astrophysicist to ask the question too. And that's
- 4:41what I, you know, try and be for people and highlight, you know, what it's actually like
- 4:46to work as an astrophysicist. Because I think a lot of people don't really know that it can feel sort of
- 4:52very opaque, sort of the academic world of research and being a scientist. But then also, you know, being
- 4:57like, oh, there was this new research study published, what does it actually mean? Why do we
- 5:02astrophysicists care? Like, what implications does it have for, you know, our field in general? How does
- 5:07it fit in? All those kind of things and really combating as well, like the rise in the sort of,
- 5:13you know, conspiracy theory science on YouTube as well. I feel like if we just flooded YouTube with like
- 5:17real scientists and real academics actually doing the research, you know, that know their stuff,
- 5:21then I guess we can combat that.
- 5:23Yeah. So that's amazing. Two thoughts. One, I think astronomy is interesting because it's both
- 5:28so close to everyone, right? You go out at night and you just look up and you can't help but go,
- 5:33wow, I can almost see the craters on the moon. Like it's, it's right there. And yet at the same time,
- 5:39it's also super inaccessible, right? Like if we want to study, you know, Newtonian physics,
- 5:43we can throw a rock and watch the parabola, but we, we can't really access the stars in that way,
- 5:49or even the planets other than, you know, they look like stars themselves, right? Basically,
- 5:52unless you get a proper telescope.
- 5:54Yeah, exactly. There's so many steps that go from just using your eyes to observe the night sky to
- 5:59stepping through, you know, buying binoculars, buying telescope, buying a, an adapter that can
- 6:04adapt your camera to a telescope that you've bought to, you know, putting together loads of lenses of
- 6:09cameras to make a telescope or going to then like a professional, you know, telescope that's built
- 6:14with these incredible detectors that let us see the faintest of faintest of features. And with that is,
- 6:20is where we can start doing some science. But, you know, I say even in the 1600s, what, you know,
- 6:26400 years ago or so people were still doing naked eye astronomy and learning things about the stars,
- 6:32or even just with, with binoculars or telescopes, you know, a very small telescope that's maybe less,
- 6:37less than a hundred quid, a hundred dollars. You know, you can see the moons of Jupyter and you could
- 6:42night by night, every time it's clear, go out and sort of show, okay, the four brightest moons of
- 6:47Jupyter are here, here, here, and here around Jupyter. Oh, the next night they've moved. Oh,
- 6:51and the next night they've moved again. And that's a project you can still do at home. And okay, yeah,
- 6:55we might understand that, but that would be one way that you could test gravity or, you know,
- 6:59test the positions of Jupyter's moons. Or even people, a guy called Olber used one of the moons of
- 7:04Jupyter to work out the speed of light 200 years ago. So there are, there is still stuff you can do,
- 7:11but yeah, it can feel like, you know, it's not accessible to the things that we're doing in
- 7:15terms of black holes or dark matter or anything like that. You do need, you know, seven years of
- 7:20education or whatever to be able to grasp that and do research yourself. But I guess that's why I want
- 7:24to be on YouTube. It's kind of saying, okay, you don't have the seven years of maths and physics
- 7:30behind you, but here's the gist of it. You know, here's what they're saying and here's what it means.
- 7:35Amazing. The other thing I wanted to mention or get your thought on is you point out that there's
- 7:40all this misinformation and it just boggles my mind. I just cannot comprehend how we live in a time of
- 7:46so much accessible information. And yet there are people, you know, there's a guy in the United States
- 7:52that was convinced the earth was flat. So he built a rocket, shot himself up in there to disprove it,
- 7:57and then crashed and died, I believe.
- 7:58Yeah.
- 7:59Because he was like, yeah, I got to prove it's flat. All these people keep telling me this,
- 8:02that it's not. And you know, it's so good on you for putting out like interesting,
- 8:07compelling science for people to learn about.
- 8:10Yeah. I think it's also just like really getting out like the process of science. Like
- 8:14you collect evidence, you test an idea you've had, but if the evidence doesn't match that,
- 8:20you have to change your ideas. And I think that's where people get stuck on science is that they have
- 8:25some emotional attachment to an idea like the earth is flat. They can't change their mind when
- 8:30presented with evidence that isn't. But it's the same thing where people are like, oh, I've never
- 8:34really liked the idea of dark matter. So I'm really skeptical of it. You know, like it's the same thing.
- 8:40It's like, well, you know, you have to look at the evidence. And as begrudgingly as astronomers
- 8:45eventually came up with the idea of dark matter after ignoring sort of the evidence 50 years,
- 8:50you know, that was sort of something that is like when you understand the history of all that stuff
- 8:55that's built up, it's very easy to see why we think what we do. And I think that's something I try and
- 9:00focus on to try and combat those sort of like science skeptics or, you know, people who have
- 9:06emotional attachment to stuff like that. And this misinformation is the how we know, not just what
- 9:11we know. Cause I think that's so important.
- 9:13Yeah, absolutely. I know there's a lot of stuff going around this, like this whole coronavirus era of like,
- 9:17well, the scientists said this, and then they changed their mind and they said something else
- 9:22after further research was done. So they must have no idea what they're doing. It's like, no,
- 9:25that's called science ideas. And then you follow up. All right. So let's get into some of the coding
- 9:31topics a little bit here. You know, before we get too far into it, you know, how do you get into
- 9:36programming in Python? Out there on the live stream, I also have a sort of similar question,
- 9:40maybe tie them both together. It's how do you learn Python for astronomy as an intermediate
- 9:44program? I have an intermediate Python program. So any advice for me to get
- 9:47better to apply Python to physics?
- 9:49Yeah, sure. I didn't even come across coding or Python until I was at university. So it must
- 9:55have been my second or third year. There was actually Python courses as part of the physics
- 9:59course, you know, teaching it you from scratch, basically. I never learned it at school because
- 10:04it just never crossed my radar. Like I did what would be the equivalent of sort of like IT
- 10:09computing for what we call our GCSEs up to when we're 16. But that was like Excel spreadsheets
- 10:13and like Word docs. It was right, right. More like computer fluency stuff. Yeah.
- 10:17Yeah. The practical exam was like a three hour practical exam. I think I finished it in an
- 10:20hour and I was just like, oh, it's just an Excel spreadsheet. So I wish we'd done something
- 10:25like that then because I think it would have prepared me better because so much science is
- 10:28ingrained in Python. And it was great. The introduction we had at university because we learned the basics.
- 10:32But then, you know, the next minute you were like, okay, so code up Einstein's theory of
- 10:37general relativity because there's just the laws that you follow and do that around a black hole and
- 10:41look at, you know, the, how the strength of gravity changes as you get closer to it. You know, that was
- 10:46something that was really cool to be set. And that it sounds so complicated to try and code up, but it's,
- 10:51you know, it's like a couple of functions and, and then you don't kind of things. Yeah. I found that so
- 10:56difficult at the time. But looking back now, I'm like, that was so simple.
- 10:59Well, I, you know, thinking back to the code that I've written, I remember being so just thrilled
- 11:05and satisfied of getting some simple little program working. And, but it seemed like a giant achievement
- 11:10at the time. And, you know, it probably fit on one screen or whatnot, but that's how it is when you're
- 11:14learning. Right. Yeah. I mean, even just like being like, what is a terminal, you know, print,
- 11:19hello world. Like, what is this? I remember that being such like a mammoth, like obstacle to get over
- 11:24of just like getting into like the language and everything like that. But that comes from just
- 11:29immersion right in it. And the same thing is true for, for learning how to apply Python to
- 11:33astronomy or to physics. It's immersion in both the language that's used in astronomy and physics,
- 11:39but also then the coding modules that are so useful to you, like Python modules, for example,
- 11:44I'm just going to shout out the AstroPy consortium now, because they're incredible. It's this,
- 11:48this whole open source project that's developing, you know, everything from how to, you know,
- 11:54plan your observations if you're using a telescope. So you give it coordinates of an object and it's like,
- 11:59this is when this is visible in the sky, you know, to, you know, then reducing that data or
- 12:04converting, you know, a redshift to an age of the universe, for example, like something cosmological,
- 12:09like, you know, that people would be writing their own little widget, like HTML widgets for like about
- 12:1410 years ago, but now is so ingrained in the Python and Astro stuff.
- 12:18Yeah, that's fantastic. It's, you know, so much of it seems like it would be very,
- 12:21like a huge challenge, but these days, it may be 20 years ago it was, but these days it's,
- 12:25you know, grab this package, call that function, know what it does, right? And then grab something
- 12:30out of AstroPy or something in Jupyter or Plotly or Altair and off you go.
- 12:34Exactly. So I would definitely, if anyone wants to get into it, definitely recommend starting with
- 12:37the AstroPy project because they have so many tutorials and everything, because it's all open source
- 12:41that they're all probably Jupyter notebooks as well. So it would be a great sort of jumping off
- 12:45point to get involved. Say, you know, want to get into astrophotography maybe,
- 12:49and you want to reduce your images, clean them up with Python. That would be a really fun project to
- 12:53do.
- 12:53Yeah. Fantastic. Quick, maybe a related question from Frey out there is, do you use basic Python
- 12:58or is there a special AstroPy version? I think that's interesting.
- 13:01No, it's the usual Python. You know, there was a big sort of like collective, like,
- 13:06oh, change to Python 3.6 or 3.7, whatever it is during the Astropy community when everyone's
- 13:11stuff broke, but it's the normal basic Python, just complementing,
- 13:15by the Astropy package.
- 13:16Yeah. I think that's one of the powers of Python. And maybe you could speak to this from
- 13:20your slice of science, but I think this is why Python is so popular for computational science
- 13:25in general, is that it's just Python plus, right? And it's so accessible. You can start out with a
- 13:32very simple program, add to it, add to it. And you never think of yourself as a programmer,
- 13:36but all of a sudden you end up with functions and a package. You're like, what am I doing? How
- 13:39did I become a programmer? Right?
- 13:42Exactly. Yeah. I think that's the thing about programming though, is as long as you have a
- 13:45task, you're rolling, right? You know, you're on your way to becoming that. It's almost like not
- 13:50knowing where to begin or not knowing what to do with it that sort of scuppers you. So yeah,
- 13:54it's sort of weird that you can do so much with Python. It's so flexible for, you know,
- 13:59data tables, but I can also pull in an image that I've taken as well. Or I can,
- 14:03the idea of NumPy as well is just an absolute lifesaver. Like the fact that I can,
- 14:08you know, the fact that it's like row and column manipulation, you can do something across the
- 14:12entire array. Like I have images that are arrays, right? So I can do something across the entire
- 14:16image with NumPy like that. Yeah. It's just, it's so easy to use. There are some tools in astrophysics
- 14:23that, you know, we have languages called IDL that were really developed.
- 14:26Right. Specifically for astronomy. Yeah.
- 14:29Yeah. And I find IDL hell, sorry, excuse my language, but like I find you run it and it does
- 14:35a different thing the second time you run it. And I'm like, why?
- 14:38It should not do that.
- 14:39It shouldn't, no. And then like IRAF as well, which is a similar thing that was developed,
- 14:43but they're just, they're not as intuitive and easy readable as Python, I don't think. And so I
- 14:48think that's why Python has really took off in the astronomy community.
- 14:53This portion of Talk Python To Me is sponsored by Linode. Simplify your infrastructure and cut
- 14:58your cloud bills in half with Linode's Linux virtual machines. Develop, deploy, and scale
- 15:02your modern applications faster and easier. Whether you're developing a personal project
- 15:06or managing large workloads, you deserve simple, affordable, and accessible cloud computing solutions.
- 15:12As listeners of Talk Python To Me, you'll get a $100 free credit. You can find all the details
- 15:18at talkpython.fm/Linode. Linode has data centers around the world with the
- 15:23same simple and consistent pricing, regardless of location. Just choose the data center that's
- 15:28nearest to your users. You'll also receive 24-7, 365 human support with no tiers or handoffs,
- 15:34regardless of your plan size. You can choose shared and dedicated compute instances, or you
- 15:39can use your $100 in credit on S3 compatible object storage, managed Kubernetes clusters, and
- 15:45more. If it runs on Linux, it runs on Linode. Visit talkpython.fm/Linode or click the link in your
- 15:52show notes, then click that create free account button to get started.
- 15:57The next question I always ask my guests after introductions, what they do day to day, but I
- 16:01kind of want to anchor our conversation around your YouTube channel on these cool videos you put out
- 16:05there. So not only do you have an answer for that, you have an incredible video you put together.
- 16:11So yeah, an 18-minute video you put together, a day in the life of an Oxford astrophysicist. And
- 16:18basically, it's like a time-lapse with commentary, right? Maybe you want to just talk about,
- 16:24you know, summarize that video for people? Yeah, sure. What do you do day to day?
- 16:27I get, because I just got asked this question so much, like, what do you actually do? And I just
- 16:31figured the easiest way was to show people. So I show people everything from, you know,
- 16:34leaving my house and getting on the train to arriving at the office and lunch and all the
- 16:39things in between kind of thing. So there's a mixture of, you know, me doing everyday things
- 16:44like checking emails. That's almost part of it. Communication between your colleagues to say,
- 16:49oh, I've got this new result. I've got this new plot. Oh, can you read my paper? That's cool.
- 16:53Checking all the new research that's been published.
- 16:55Sorry, you literally have like the time-lapse of, say, you at your desk and you're like,
- 16:59oh, that's on the screen. I must have been doing this right now. Oh, now I'm doing this
- 17:01something in Jupyter. And now I'm off to this.
- 17:03Yeah, exactly. So there's bits of me working with Jupyter and definitely like doing, I was doing a
- 17:08little test of my hypothesis because I had some new data that came in. I then went to a talk that was
- 17:13given by a visitor to the department who was one of the leads in the Event Horizon telescope that made
- 17:19that picture of the black hole, the orange donut, as people call it.
- 17:22That was such huge news. A couple, was that last year?
- 17:24A year before, 2019. That's crazy.
- 17:27Yeah, 2019.
- 17:27But yeah, so that was really cool to show people that, you know, that's part of our day. We,
- 17:32you know, go to talks and listen to people present their science. And then also, you know,
- 17:36I happened to be on the radio that day. I picked a very exciting day.
- 17:39So I was like, oh, keep going on the radio.
- 17:40It seems so glamorous. Like, oh, wow, this person is probably going to win the Nobel Prize. And here
- 17:44I'm on the BBC for a while and back to lunch.
- 17:46There was just lots of bits in my day that were, and then also like we have a big, what we call a
- 17:50journal club where we bring a research paper that's been published that week. And we go through it
- 17:55in our research group and talk about it to find out, you know, how it fits in with our research,
- 17:59that kind of thing and what it means. And I get a lot of my ideas from videos from those kind of
- 18:03journal clubs as well. Cause I'm like, you know, we talked about it as colleagues and then I'll make a
- 18:07video on it to sort of say, well, this is what we found cool this month kind of thing.
- 18:11It just showcases the whole day, but then also a little bit of, it's why it's an Oxford astrophysicist
- 18:15because it's also like, we also took the speaker to college dinner, which is like a very fancy
- 18:21dinner and a nice room. And we all got dressed up and had drinks and stuff like that. It's like
- 18:24very Oxford, but it showcases that side of it because that like, you know, networking side
- 18:29of things. So there's, there's code in there. There's, there's a talk, there's lunch,
- 18:33there's dinner, there's everything. So yeah, it seems fabulous actually. Yeah. Yeah. It
- 18:38seems really great. So, one question, I guess one quick meta question and then one
- 18:43other question. So how did you film this? Like, is it just eight hours or 12 hours of full on high
- 18:49res video or it wasn't the high res cause it was on my old iPhone. So it was like seven 20 P.
- 18:53So it wasn't that high res. I think it was, yeah, I cleaned my phone basically of pretty much
- 18:59every picture and video and backs it up and then literally just carried it around and a little
- 19:05GorillaPod all day, plonked it on the desk and then like took it with me wherever I went. And I would
- 19:10stop it sort of, if I was like leaving the room, I would sort of set a new file going. So it didn't
- 19:15like break or anything. And it was like permanently plugged into like a charging block as well. Cause it
- 19:20was like an old phone running out of battery constantly. I, yeah, I just took it everywhere and I felt
- 19:25stupid doing it just carrying around being like, hi, yeah, sorry. I'm filming. But like, it was,
- 19:33people were always asking me what I was doing everywhere I was going and people like loved the
- 19:36idea of it. So. Yeah. It seemed really interesting. I actually thought you did a great job with it.
- 19:40So the non-meta question is what did you learn about yourself by, did something surprise you?
- 19:47You're like, Oh my gosh, I had no idea. I remember thinking this was quite a full day,
- 19:51but it didn't feel like I was rushing around or doing anything. I just think when you watch
- 19:55something in time-lapse, it feels so busy. So all the comments were like, Oh my God,
- 19:59she does so much in a day. Like she looks so busy. And I was like, I didn't feel that way kind of thing.
- 20:04But like, I felt like I was like, cause there's a part of it where it's, it's filmed like mid November
- 20:08and the Christmas adverts for the, all the big, you know, like department stores had just come out in
- 20:13the UK. And I, there was a part of it where I just caught myself watching one of those.
- 20:18And I was like, stop wasting time in your day on like Twitter or watching videos, you know? So
- 20:23there was bits like that, I guess that I learned that I was kind of like, gosh, that's literally
- 20:28sort of like so much time. One thing I did find though, is that I was very productive because my
- 20:32phone was always recording. I couldn't just pick up my phone and scroll or anything because it was
- 20:37always filming.
- 20:38Instagram or whatever. Yeah. Interesting.
- 20:40So I had quite a productive day because of it.
- 20:42Oh, interesting. All right. Well, let's go ahead and jump into sort of the main topic
- 20:47here is the reason that you caught my attention as maybe a guest for the show is you did this really
- 20:53interesting video, you know, five ways that I use code as an astrophysicist. I think this relates
- 20:58back to that superpower. You know, Python has a superpower, not we should take all the people that are in
- 21:03finance or math and turn them into programmers, but you know, people that have interests, give them some
- 21:08other thing. And you really touched on how programming is so valuable, but it's not necessarily
- 21:13communicated to that when you're in the sciences. I did a math degree and I don't remember really
- 21:18till maybe my senior year in college when they're like, you really need to learn programming. That was
- 21:22just for a research project, right?
- 21:24Yeah. I was the same. Like, I think I was given various different projects that were like graded in
- 21:30my second, third year. And then in my fourth year, I was given a research project on galaxies and it was
- 21:34like, you're going to need code to do this. And that was when I finally became comfortable using it.
- 21:39And you realize, oh, I have, you know, thousands of galaxies. I don't have to do this in an Excel
- 21:45spreadsheet. There's a better way. And, you know, if you have images, you have to analyze, oh, I can do it
- 21:50in the same function. I can do it in the same, you know, you know, piece of code or whatever. And,
- 21:55yeah, I think that's not communicated how much and how many different ways you are going to end up
- 22:01using it and how many ways it just makes your life just generally easier to use it.
- 22:06Right. I mean, there are problems you could solve without writing code.
- 22:08If you know how to do it, there's no way you would spend half an hour doing something by hand. Like,
- 22:14you know, we just write a little program and in three minutes have this done ever and ever,
- 22:18you know, every time over and over. Yeah.
- 22:19Yeah. There are things that I've picked out in my day that I've been like, I do this nearly every
- 22:24day. I should just write a function for this. Yeah. And you just save yourself so much time.
- 22:29I totally agree. There's certain things I have to do at work and my business. And I'd just be like,
- 22:34this is so painful. I can't believe I have to do this. And I, why have I not stopped to just write
- 22:38a program that does this? This can be automated. Why, why have I done this for three months and,
- 22:42you know, suffered over and over. And then, you know, I'm just endlessly happy when I take that.
- 22:48So let's cover the five ways, right? Like you've already set the stage of why
- 22:52people in science in general and astrophysics in particular should care about these things.
- 22:56But what are the five ways?
- 22:58Oh, it reminds me what order I put them in. I can't actually quite remember.
- 23:01I got them here. So the first one you gave was image processing.
- 23:04Yeah. Okay. So this is a big one for astronomy, obviously, is that we, you know,
- 23:07I am an astrophysicist and an astronomer. So I take images of the sky and then use them to do my
- 23:14science. There are some people who are very theoretical. So they'll either run
- 23:17computer simulations or they'll work with sort of the maths. And so they don't really tend to do that.
- 23:21But as an astronomer, I take images of the sky and I have to analyze them. So for one thing,
- 23:27you have to remove all the sources of noise in the image. So that's essentially just,
- 23:31like I said before, it's a numpy array, right? Because all you've recorded when you've taken
- 23:34an image of the sky is how bright each pixel is. And so what you want, say you're observing,
- 23:40like I would be, I would be observing a galaxy. In my image, I would have the light from the galaxy,
- 23:45but I would also have background light from just the sky in general. So like light from the sun
- 23:52that's scattered around the atmosphere and then hits the detector, but also just noise that comes
- 23:58from the detector itself. So the detector thinks it's detected light, but it's actually just that
- 24:02it's a little bit warm, for example, you know? Okay.
- 24:05So the way it does it is light comes in, pings off an electron from in an atom,
- 24:09but that can happen if the atoms are just a little bit warm.
- 24:11Yeah. Yeah. You give an example of even if you close the shutter and have no light at all,
- 24:16it kind of looks like a backlight. We were young, the TV channels, you know,
- 24:21you had like that antenna, not the cable, right? It's just like that fuzz.
- 24:24Yeah, exactly. It looks like fuzz. So you have to remove all those things from your image if you
- 24:28just want the image with galaxy left over at the end. So there's clever ways you can do that. Like
- 24:33you said, you just leave the shutter closed and you get an idea for what the noise looks like
- 24:38for that detector. You can take an image of just like sky and then you'll work out, okay, well,
- 24:43that's the noise I need to remove for that bit and everything. And again, it's just numpy, right?
- 24:47It's just taking them all out. And sometimes you'll also have cosmic rays that come in and hit your
- 24:51detector. So that's really super high energy radiation. And it looks like just a little sort of
- 24:55super bright pixel, maybe three pixels. Like they're just like, and if they're off to the side,
- 25:01it's fine. You just, you just take them out. But if they're right on top of what you want to observe,
- 25:04that's so annoying. That's where the exoplanet transit was supposed to be. What's going on?
- 25:09Yeah, exactly. Similarly with like satellite trails as well, which is obviously becoming a
- 25:13bigger issue with sort of the SpaceX constellations and everything like that as well.
- 25:17Is there going to be some kind of AI type thing that just goes, I now detect SpaceX satellite transit?
- 25:23Stop observing. Yeah. I think that's hopefully the sort of moving forward is that
- 25:27more will be shared between astronomers and sort of the people who are manning those big
- 25:32constellations of satellites. Cause it's great what they want to do. They want to bring internet
- 25:35to the farthest corners of the world, which is always great in my book, moving everything to space
- 25:40in terms of astronomy is just not feasible. Like the money it would cost and everything. And like the
- 25:44fact that you can't fix them if something goes wrong, if they're in space, you know, we still need
- 25:48telescopes on the ground. And so if there's some form of, yeah, like you say, an AI, that's like,
- 25:53warning SpaceX satellite trail coming. Like you just sort of stop your observation and start off
- 25:58again. But yeah, we don't have that at the minute, you know, so you sometimes do get a satellite trail
- 26:03that's snuck in there and you have to remove that. And it, and it, it's so easy to do with Python.
- 26:07Again, AstroPy, there's loads of functions in there that help you out as well with removing so that the
- 26:12detectors aren't always perfect either. So they have a response function, we call it where, you know,
- 26:18they'll have some efficiency of like 95% in the middle, but it will drop off at the edges.
- 26:22And so you'll have to account for that as well in the processing of the image, all those kinds of
- 26:27things you can use Python to do.
- 26:28You've got to somehow adjust what the telescope sees and retrofit that to try to be as close to
- 26:34reality.
- 26:34Yeah.
- 26:35Not just what the picture says, right?
- 26:36Yeah. And there are sometimes as well. So one of the things that can affect your images is just
- 26:40turbulence in the atmosphere. So the same turbulence that you get when you're on a plane and,
- 26:44you know, you pass through like a warm or a cold pocket of air and all of a sudden you feel it
- 26:48shake. If light passes through that, it can get really distorted. And so they actually do some
- 26:53real time adjustment of images on some telescopes. So you might've seen images of telescopes where
- 26:58they're pointing like a giant laser out of the top of them. And that laser, you're essentially
- 27:03recording what happens to the laser as it passes through the atmosphere. And the same, same way that
- 27:07noise cancelling headphones work where they record the noise and then invert it. So you don't hear it.
- 27:13You record what's happening to laser, invert that and put it on the image that you're getting from
- 27:17the telescope and you can get rid of the atmosphere sort of ruining your stuff.
- 27:22Yeah. I've always wondered how they were able to, you know, account for like the waves of heat
- 27:28and all sorts of stuff in the atmosphere and still get these super clear pictures from ground-based
- 27:33telescopes.
- 27:34That's how they do it. Lasers.
- 27:36Awesome. It's like it's in the future, but now. All right. So the next one that you talked about
- 27:41was data analysis and processing large quantities of data. And that's actually what's on the screen
- 27:46here.
- 27:46Yeah.
- 27:47Live share as well, right? You have this really cool example of brightness of 600,000 galaxies.
- 27:53Yeah.
- 27:53Something like that.
- 27:54So one of the biggest surveys that's ever been taken. So, you know, you can do stuff like I do
- 27:59where you sort of spot observe galaxies you're interested in, but then there are some telescopes
- 28:02that's just sole job is to survey the entire sky or the entire like northern sky or entire southern
- 28:08sky. And then you end up with like, here's all the things that's been observed, you know,
- 28:13and you have to write algorithms to pick all those out. That's another side of obviously astronomy as
- 28:17well as like picking out the areas of interest from this huge survey. And you can end up with data
- 28:22tables that are like, here's 600,000 galaxies that have been found with the brightness. So
- 28:26that thing you're showing there. So you've got an ID in the first column and they're like 18 digits
- 28:30because it's all sorts of like, you know, coordinates in there and everything.
- 28:34Yeah.
- 28:34But then U, G, R, I, and Z is five measures of brightness in different what we call wave bands.
- 28:41So U is sort of like the bluest light and then Z is the reddest light. And so you can,
- 28:48if you look in sort of different colors of light, you can see different things. So blue,
- 28:51is lots of new stars, red is lots of old stars. And so that's what you have for like 600,000 galaxies.
- 28:57That's amazing.
- 28:59But then you also have all the other things that you might have measured as well, like their size
- 29:04and their shape and various other different things. You can end up with tables that are
- 29:10just huge essentially. And you'll see that the eagle eyed people might see that the format for the
- 29:15table is .fits, F-I-T-S. And that's a format that was invented by astronomy as well, because it's a format
- 29:22that can both take a table like that, but it can also store an image at the same time. But you can store
- 29:26both a table and an image or many images, you know, so there's all sorts of different things you can do
- 29:31with it. So it's very, very useful. I think it's called a flexible image table system, but don't quote me on that.
- 29:37Yeah, we have full of acronyms in astronomy. So yeah, things like that, where you want to be able
- 29:43to load in the data table, manipulate that data, you know, say, okay, transform this column into
- 29:49something else that I'm interested in, whatever it might be for 600,000 columns, you know, but you
- 29:55don't want to do that on an iterative loop again, like NumPy is great for that. It's just, it's a
- 29:59perfect tool for it.
- 30:01Yeah. And, you know, maybe if you didn't have Python as a skill, you might try to do this in
- 30:05Excel, or maybe even slower would be Google Sheets or something like that.
- 30:09Yeah.
- 30:09But I think those have a limit around 101, you know, 1.05 million rows, and then also
- 30:15your mental well being in terms of how long you gotta wait for stuff to happen, right?
- 30:19Yeah, exactly.
- 30:20Yeah. One thing you do point out in the video when you're talking about this is the mistakes
- 30:25that people have made, especially around the NHS there where-
- 30:31The test and trace.
- 30:32Yeah, the test and trace stuff where they tried to do this with Excel and, you know, missed
- 30:36a ton of COVID cases in the early days.
- 30:38Yeah, exactly. Just because, you know, when you have that many rows, it's so difficult to
- 30:42keep track of in a spreadsheet. You know, with this, you can index it really easily. You can
- 30:47say, give me all the rows that have fulfilled this value or quantity or whatever. And it's just
- 30:53much easier to stay on top of and manipulate. You know, in astronomy, there's lots of people
- 30:57who use, you know, pandas data frames as well to do this kind of stuff. So, you know, it's
- 31:01using all the tools that are available.
- 31:03This portion of Talk Python in Me is brought to you by Cloud ENV. You've heard that you should
- 31:10never commit things like API keys and database connections to source control. Then how do you
- 31:16manage them? Do you email them around? Ask on Slack, hey, what's the new password for our
- 31:20Postgres server? Please don't. What if I told you there was an end-to-end encrypted cloud sync
- 31:26system for environment variables in Python? That setup literally takes just a few seconds. There's
- 31:32no learning curve and you just pip install the sync library. And maybe you could even access
- 31:37control your secrets by adding IP allow or deny lists or even getting notified when a new IP address
- 31:43tries to access one of your secrets like your database connection string. Yeah, that'd be cool if
- 31:48somebody built that, right? Well, they did. And it's called Cloud ENV. You set up your environment
- 31:53on your server with a simple CLI, and then you access your secrets from your Python app using their
- 31:58incredibly simple package. Simple as in two lines of Python. Seriously, it's just load Cloud ENV,
- 32:04os.getenv, and you give it something like database connection string. You just use os.getenv,
- 32:09and it's preloaded all these synchronized and access control secrets. Keep your secrets, well, secret and in sync with Cloud ENV. Get started at talkpython.fm/cloud ENV. That's talkpython.fm/cloud ENV.
- 32:27A couple of listener comments. One is, how long would it take roughly for the code to parse and analyze the data? And what would you do with that? I think that leads well into the next one.
- 32:37Yeah. I mean, loading data tables, even in 600,000 size is so quick in Python. Like by blink and it's done it.
- 32:43Yeah, exactly. I touched on that. Like you would wait in Excel for a while.
- 32:46Yeah. I would wait to just open the spreadsheet, whereas this is just like, yes, I'm done.
- 32:50Yeah. It's almost instant, right? Probably.
- 32:52Yeah. And then again, like, I mean, it depends what you're doing, right? If you're, you know, just transforming one value into another. So for example, people who have a major physics, like flux into luminosity. So for example, flux is what you observe because you're very distant away from something, but luminosity is like the absolute value it would have if you were like right next to it. That's how bright it would be.
- 33:14For example, that's just a simple translation, right? So that on 600,000 rows would probably be quite quick. But if you're doing something a little bit more complex where you're taking each value and perhaps using it in inference or something like that, like optimizing a model based on all these values or something that would obviously take a lot longer. You know, I've had code run from anywhere from a second to a week.
- 33:36Right.
- 33:36So yeah, it just depends what you're doing. And then I think it might, yeah, like you said, lead into the next one is what would I do with the data afterwards? I'd make a plot with matplotlib.
- 33:45And that leads into, yeah, the next thing that you covered, which was model fitting and that sort of thing, right? So Freya asks, how do you search the galaxies and find the ones you need for your research?
- 33:56Yeah. I mean, so for example, I'm really interested in a certain shape of galaxies. So I call them the egg white omelets of the galaxy world.
- 34:05Not the spiral galaxies.
- 34:07No. So if you think about a spiral galaxy, it's a nice flat disk and it has, you know, the spiral arms on the outside, but in the middle, there's usually what we call a bulge, but you can think of like an egg yolk, right? It's like a fried egg, a galaxy. And it has this bulge of stars that instead of, you know, on a nice flat disk where all the stars are orbiting, like in the solar system, like planets in the solar system, you've got stars that look a bit more like a beehive.
- 34:30And then you've got stars that look a bit more like a beehive because they're sort of all doing this, you know, in various different planes around the very, very center. And we think those form when two galaxies merge together and you just, you ruin all the nice rotation and you end up with this big blob in the middle.
- 34:43I'm interested in the things that don't have that blob. So we think they don't, they haven't had a merger, right? And I think, okay, well, what's happened to the black hole in the middle if you haven't merged two things together and shoved a load of stuff into the center?
- 34:55So that's what I'm interested in. So I need two things to do that. First of all, I need to know what shapes the galaxies are. And that kind of stuff comes from literally, well, two ways. First way that we've been doing it for a long time is people eyeballing the images and looking at them and labeling.
- 35:11They have spiral structure. It has a bulge. It doesn't have a bulge. It looks like it's merging, all that kind of stuff. And that's been done individually by people, you know, from Edwin Hubble back in the 1920s to the, you know, poor PhD students that are given 50,000 of them to look at as part of their PhD and label them.
- 35:31But then more recently in the past 10 years, a project called Galaxy Zoo, which is a, what we call a citizen science project online. So galaxyzoo.org still running, you know, gets the public to classify the shapes because it's a fairly simple task for even, you know, like a five-year-old to do is to show them an image and say, is this round and blobby or is this a spiral shape?
- 35:50And that 600,000 images of galaxies that would take one astronomer, you know, years would have terrible statistics. There'd be mistakes all over the place because they hadn't had their morning coffee or something yet before they started.
- 36:00You know, we can get instead 40 people to look at each image and it's fantastic statistics and all that as well. And that's still going because we're still taking pictures of the sky.
- 36:09But there were people out there thinking, well, what about machine learning? Can you train a machine to do this with an algorithm? And yes, you can.
- 36:16So Galaxy Zoo actually held a Kaggle competition for this as well about five or six years ago and found that you can get sort of like 90% sort of like agreement with an expert human.
- 36:28And we're getting to the point now where Galaxy Zoo is running on the website, but we've got a machine in the background, which is deciding what to show to people.
- 36:36The machine's like, I've classified all the simple, easy things, but I'm not sure about these ones. So can you look at this?
- 36:43So it's sort of like a joint effort. And that's going to be really important with the next generation of big survey telescopes we're building. People might have heard of the LSST or it's been recently dubbed the Vera Rubin Observatory.
- 36:53And there's so much data coming out of that thing that is ridiculous now.
- 36:57All right.
- 36:57They're estimating instead of like a, you know, 600,000 to a million, they're estimating like a billion galaxies.
- 37:02Wow.
- 37:02So that's not scalable to get a person or a couple of astronomers to do that. So that's where we need machine, you know, crowd to do it. And yeah, so once you've got those classification labels, either from machine or cloud, then it's just the column in your data table, right?
- 37:18And then you can filter based on, you know, give me all the things with the lowest, you know, vote for having this bulge in the center. And I'll look at those and sort of whittle it down kind of thing.
- 37:28So yeah, it's really how you choose them is just from a data table.
- 37:31Yeah. Once you get the number, then it's super easy, right? It's coming up with it. I did have recently, I had David Armstrong and you have Gamper. They're out of the UK as well.
- 37:39At least David is how they used machine learning to discover 50 exoplanets in some of the Kepler data as well. So yeah, it's super interesting how ML starting to make its way into astronomy.
- 37:51Yeah. And that's another area where ML and citizen science are working together. So there's a, like Galaxy Zoo, there's a project called Planet Hunters, which is using the follow-up to the Kepler space telescope, which is the one that discovered like 5,000 exoplanets.
- 38:04There's now a follow-up called TESS, which is doing the same. And so they're like, we have run our algorithms in the ML on all the data. It's found what we've told it to look for, but then here's all the data. Do you see anything else? Do you see planets? Do you see anything weird? Do you see things unexplained?
- 38:20And that's the thing that you really need people to eyeball.
- 38:23Right, right. The ML is going to find what it knows to find.
- 38:26Yes, exactly.
- 38:27That looks weird, but not, you know.
- 38:30Not what you told me to look for.
- 38:31Yeah, exactly.
- 38:32You know, you can't train a machine to look for stuff that's just interesting because everything will be interesting to it.
- 38:36Yeah, exactly. Yeah, that's the problem with software. You know, you give it input, it gives you a number out the other side and it's easy to trust that number, but that's not always the way to go.
- 38:44Yeah.
- 38:44All right, so the next one you talked about was data visualization and you had some really interesting examples of galaxies colliding that I touched on.
- 38:53And then also your research is around black holes. And so there's a visualization you show of star coming too close to a black hole.
- 39:00Yes.
- 39:01Getting spaghettified.
- 39:03Yeah, it's one of my favorite words ever. Spaghettification is what happens when you get too close to very strong gravity, like around a black hole, where the gravity is stronger at your feet than at your head.
- 39:12So you get stretched out like spaghetti.
- 39:14Never look at spaghetti the same way afterwards.
- 39:17But yeah, so data visualization can be anything from, you know, plotting two columns in a data table against each other in a nice scatter plot and being like, oh, look, there's a correlation there.
- 39:27And then you can fit a line to it with, you know, an optimization, like thinking scipy or something.
- 39:32And that's one side of it of sort of data visualization.
- 39:35Then there's the sort of like, you know, 3D data visualization you can do with like plotly again of like, you know, three columns in a data table.
- 39:42But then there's things you can do like this, where you have simulated what's actually happening around a black hole.
- 39:50And you said, okay, my black hole is here.
- 39:52And I have a star over here that's going to get too close.
- 39:55If I code up all the laws of gravity and Einstein's theory of general relativity and set it running, what happens?
- 40:01And then visualizing what you actually see.
- 40:04And obviously the code behind this is literally like an array telling you where more of the particles that used to be in the star now are on this grid that you've made, where one point on the grid will be a black hole.
- 40:17And every sort of time stamp that you run it at.
- 40:21So maybe you do it for every, say a year or something, I guess, on these timescales.
- 40:25We're talking astrophysics, right?
- 40:27So we're not going to do them every second.
- 40:29So short.
- 40:30I know.
- 40:31So like a year between frames, you recalculate where they all are now based on the laws of physics.
- 40:36And then you obviously want to visualize those arrays as something that, you know, we can actually picture what's going on.
- 40:43And you can play them as a beautiful movie like this as well.
- 40:45And it looks amazing.
- 40:46But you get obviously so much understanding from that as well.
- 40:49It's fun to, you know, you don't, because I don't run a lot of simulations day to day.
- 40:54So it was fun then just to break down what that actually looks like behind the scenes in terms of, yeah, that is just a bunch of numpy arrays basically.
- 41:01Yeah.
- 41:01How interesting.
- 41:02The star is just a bunch of points in a glob in the beginning.
- 41:06Yeah, exactly.
- 41:07Yeah.
- 41:07And that's all to do with like n body simulations they're called.
- 41:10So n being the number of particles you simulate.
- 41:12And obviously the number that you decide to simulate, it goes up as I think is n squared in terms of computing power and stuff.
- 41:18So yeah, it's, it's very difficult.
- 41:21I mean, this is why, you know, I'm like running what we call cosmological simulations where you simulate the entire universe.
- 41:28It's obviously very difficult.
- 41:30They take years to run.
- 41:31You need a lot of RAM for that.
- 41:32Yeah.
- 41:33And then obviously this is what I was talking about before where you have a nice 3D visualization.
- 41:36So this is of something called the Radcliffe wave, which was discovered this time last year.
- 41:41And it was something that was nearby to where the sun is in the Milky Way.
- 41:46So this is sort of like gas card positions, but until they plotted them in, in a 3D way so that you could like drag around the data and overlay.
- 41:54Okay.
- 41:54These are known positions of other things.
- 41:56And these are the shapes of say the spiral arms nearby that, you know, it was then that you could actually see spatially what was going on.
- 42:03They realized that this was actually a feature in the Milky Way.
- 42:07And so that, you know, I can drag it around and everything on plotly.
- 42:09So it's great to see.
- 42:10And there's data visualizations.
- 42:12And so this is just plotly, right?
- 42:13Yeah, exactly.
- 42:14And it's tools like this, though, that like you say, oh, that seems obvious to plot something in 3D to see the spatial scale.
- 42:20But if the tool didn't exist, tool didn't exist, you know?
- 42:22As say somebody who's a scientist or just looking to visualize data, they just need to get it into basically like a numpy array of data, throw it at plotly, give it some colors.
- 42:32And it does all the visualization and the rotation and the zooming and that stuff, right?
- 42:36So it's more accessible than maybe it seems.
- 42:38Yeah.
- 42:38And that's the thing is that it is very accessible.
- 42:40But what I love is that, you know, astronomy is driving forward a lot of these tools as well, because you're saying we need this.
- 42:45You know, people often say, like, why do we bother studying astronomy?
- 42:47Like, you know, shouldn't we put money into other things?
- 42:50But I think one of the sort of indirect benefits is how much astronomy drives forward technology.
- 42:54You know, digital camera detectors are invented because astronomers needed a better way to record stuff.
- 42:59And Wi-Fi was massively improved because astronomers came up with a better way to recombine signals that have been scattered.
- 43:05They go around your house and stuff.
- 43:07And another thing is tools like this.
- 43:09And especially when we look towards a lot of the VR stuff that's coming out soon as well.
- 43:14So I'm thinking about, like, you know, when you can put on a VR headset and you can be immersed in an image or anything like we have now.
- 43:21We like to call them 3D images.
- 43:23So we'll take an image of something at every single wavelength or wavelength steps, right?
- 43:28So from infrared to uv or from red colors to blue colors.
- 43:32And like I said before, there's lots of different features that pop out of those things.
- 43:35So you can imagine actually being able to be immersed in that to actually see it for yourself rather than maybe doing it in something like plotly.
- 43:40Or you could also imagine there's a star called Eta Carinae that we think is very close to supernova and collapse.
- 43:47And people have observed it for years and seen the big 3D structure of it and modeled the 3D structure.
- 43:52People have 3D printed it.
- 43:54But you can imagine being put in a VR environment and being able to fully, you know, move stuff around and get into anything.
- 43:59Just walk around it.
- 44:00Exactly.
- 44:01Yeah.
- 44:02And sort of that kind of a tech is the kind of thing that I can really see a lot of science pushing forward.
- 44:09Like it having a use case, which at first it necessarily didn't in society, but science gave it a use case.
- 44:15And then all of a sudden it became, it was developed.
- 44:17And then all of a sudden society realized another use case for it.
- 44:20And it snorched no balls from there really.
- 44:22So cool.
- 44:22Yeah.
- 44:23Yeah.
- 44:23Super neat.
- 44:24Super neat.
- 44:24So that video covered the five things.
- 44:26And then you interviewed your friend, your colleague who also actually did more simulation work than analyzing and whatnot.
- 44:31So yeah, I recommend people check out that video.
- 44:33Of course, it'll be in the show notes.
- 44:35Are you ready for some quick career advice before we move on?
- 44:38All right.
- 44:39So out here in the comments, would you recommend a computer science for A-level so it'll be easier to use code in university?
- 44:45What subjects would be best for astrophysics?
- 44:47Yeah.
- 44:47Computer science definitely won't hinder you in terms of science.
- 44:51Like I think it's great to sort of know about the ins and outs of computing.
- 44:54And you will do a lot of coding as part of a computer science A-level or whatever is the equivalent in your country.
- 44:59So that's sort of like the 17 to 18 year old that we do in the UK, the exams.
- 45:03Other subjects, obviously physics, obviously maths.
- 45:06For sort of context, so we only do four subjects, maybe only three for our A-levels.
- 45:12We specialize very early in the UK.
- 45:14But I did physics, maths, chemistry, further maths, which is like extra maths.
- 45:18And like that was just because they were my favorite subjects.
- 45:21And I knew that they were the ones that if I had a pile of homework, I'd be picking those off the top, you know, rather than my English homework or whatever.
- 45:27There'd be some essay buried underneath that's going to get written.
- 45:29Exactly.
- 45:30I mean, like I'll do that later.
- 45:31And like future me would hate me because I'd put it off for too long.
- 45:33I'd be doing it the next day right before the class.
- 45:35And so that's why I did those.
- 45:37And that was great because I got to university and the further maths helped because there was some I'd already seen.
- 45:43But like I think when you're at school, it's often quite pressurized to feel like you have to know everything to either get into university or before university.
- 45:50But that's kind of the point of college or university is they're there to teach you these things.
- 45:55They don't expect you to know everything.
- 45:58So just give yourself the best platform to get into whatever subject you care about the most.
- 46:02So if you're considering a certain subject at a certain university, just check what their entry requirements are.
- 46:08If they're like, oh, actually, we would need you to do computer science, then great.
- 46:12Take computer science.
- 46:13But otherwise, you know, just take those subjects that you like the most is what I would say.
- 46:17Yeah, fantastic.
- 46:18And then also another interesting question from Giordia.
- 46:22You know, we have been talking as we're just taking Jupyter for advantage.
- 46:26Like Jupyter is here.
- 46:27So we just use that.
- 46:28But the question is, was the Jupyter ecosystem a game changer for astronomy and training in your opinion?
- 46:32And in what way?
- 46:33I think it was for science.
- 46:34Oh, yeah.
- 46:35I mean, it didn't exist when I was learning.
- 46:37And I think I would have picked it up a lot quicker if it had existed.
- 46:41I think because it's just a more familiar interface than being faced with a terminal or, you know, a blank.
- 46:46I used idle way back in the day, right?
- 46:49Like a blank idle, like empty.
- 46:51What's the word?
- 46:52File.
- 46:53Thank you.
- 46:53Brain.
- 46:54I finally came out.
- 46:55After a long day of work.
- 46:57Yeah, I think it would have been a lot easier.
- 46:58And I do a lot of my tutorials and stuff like that that we share around colleagues.
- 47:03And I also like right now I've got we read a paper the other day.
- 47:06We were like, this is really cool.
- 47:07We could test that.
- 47:09It would be a really quick plot if we just made it.
- 47:11So I've done that in Jupyter notebooks.
- 47:12I've been like, and I've been like, you know, marked down being like, we read this paper.
- 47:15Here's the link of the paper.
- 47:16Like we had this idea.
- 47:17So let's test it.
- 47:18Here's the data.
- 47:19Here's the plot we make.
- 47:20And here's what I think it means.
- 47:21And I'm going to share it to my colleagues.
- 47:22And they'll read it through so much more easily than if I'd sent, you know, an email with an embedded PDF or something.
- 47:28Right.
- 47:28So.
- 47:29Right.
- 47:29A lot of times you send the picture, but obviously you don't necessarily send the code.
- 47:32And people are like, well, what is this?
- 47:33And what does this mean?
- 47:34Like, are you sending the same thing I'm sending?
- 47:36All right.
- 47:37Like, yeah, it really is combined those in interesting ways, I think.
- 47:40Yeah.
- 47:40And I think it really was a game changer, especially for astronomy, just because astronomy is such a visual science that seeing both the code and the images next to each other and what each step physically did to the image.
- 47:52You know, like I was talking about before, like removing all the sources of noise and all that stuff.
- 47:55That is so helpful in Jupyter.
- 47:57Yeah.
- 47:58Fantastic.
- 47:58All right.
- 47:59Well, we're getting a little bit near the end of our time together.
- 48:01So I want to wrap it up with one thing that I think is also worth giving a shout out to.
- 48:05And then you did a nice video of an astrophysicist reacts to funny space meme.
- 48:11Yeah.
- 48:11We'll close it out with that.
- 48:12But you also wrote a cool book that came out pretty recently, right?
- 48:15Called Space, 10 Things You Should Know.
- 48:17You want to tell people about that?
- 48:18Yeah, sure.
- 48:19So it's Space, 10 Things You Should Know is the title in the UK.
- 48:22And Space at the Speed of Light is the title in North America and Canada.
- 48:27Oh, okay.
- 48:28Space, 10 Things You Should Know everywhere else in the world.
- 48:30That's why I'm in the UK.
- 48:31I'm sorry, I pulled it up.
- 48:32Yeah, sure.
- 48:33So it's about, it's sort of like 10 short essays on the things that I feel like you should know if you're wanting to either dip your toe in astronomy or someone who's loved it for a long time but wants to make sure that they're like, you know, do I really know this stuff?
- 48:46If you were going to a dinner party with a bunch of astronomers, like these are the, like you'd want this sort of like base knowledge to be like, oh, I get what they're talking about or whatever.
- 48:54How much differential equations do I need to know?
- 48:56There are none.
- 48:57Absolutely none.
- 48:57It's written, so it's written with my, like I'm talking to my mom basically.
- 49:02So my mom is intelligent but not necessarily educated.
- 49:05So she didn't, she's finished school at 16.
- 49:07So she didn't have the privilege of an education like I did.
- 49:11She just started work straight away.
- 49:13And so she's so curious about space and the universe.
- 49:16Like I think a lot of people are.
- 49:17And so I wrote it with her in mind of being like, okay, what would my mom understand if I said to her, you know, and she loved the book.
- 49:22So I take that as a good thing.
- 49:24So, oh, Freya, thank you.
- 49:26Yeah, Freya says my favorite book as well.
- 49:28So absolutely.
- 49:30But yeah, so it's, it's, I really enjoyed writing it.
- 49:32It's nice and short.
- 49:33So it's not too intimidating if, you know, you don't want to read a big long book about space, but there's everything from like, okay, like, why do we think dark matter exists, for example?
- 49:41But like, could aliens exist?
- 49:43And also like the things we still don't know as well, which I like.
- 49:48So I like thinking about that.
- 49:49Yeah.
- 49:50Yeah.
- 49:50There's, it seems like everything is known.
- 49:52But no.
- 49:53There's so much, but no.
- 49:55No.
- 49:55There's so much more that we don't know.
- 49:57A lot more than it used to be.
- 49:57Yeah.
- 49:58Yeah.
- 49:58Exactly.
- 49:59Fantastic.
- 50:00All right.
- 50:01So I want to do not the same memes, but I want to kind of round this out just as a fun, like, let's do the memes.
- 50:07So let me, I've hidden this on our screen share.
- 50:10So I couldn't see what you were planning.
- 50:13You couldn't jump ahead.
- 50:13I'm excited.
- 50:14All right.
- 50:15So I'll pull up a couple of memes here and I'll try to describe these to the listeners because almost everyone's just listening.
- 50:21Sure.
- 50:22But yeah.
- 50:23So setting the stage here, like on yours, this is kind of a sneaker educational video that you did, right?
- 50:29Like you did the meme, but then you, you talked about the science that would actually.
- 50:33Yeah.
- 50:33People were commenting, like, I clicked for a meme review and now I've come away with more knowledge than any physics class I ever taught.
- 50:39It's like a sneak attack.
- 50:42Exactly.
- 50:44Oh, all right.
- 50:44We go through these pretty quick.
- 50:45I'll try to describe them.
- 50:46All right.
- 50:46So the first one we've got, remember Elon Musk shot at SpaceX, shot his Tesla Roadster and put a camera on his space and was flying along.
- 50:57But actually this is around the same time that Apple Maps came out and was really bad.
- 51:02So the meme is it's this, it's earth in the background with the Tesla flying through the air.
- 51:07It says stupid Apple Maps.
- 51:08I love that.
- 51:11I love it.
- 51:12Because it really, you know, I miss Google Earth.
- 51:14Can we bring, is Google Earth still a thing?
- 51:16I feel like when that came out, we spent so long, like zooming out of the entire earth.
- 51:21And then all we do is just zoom into our house.
- 51:24All the way from the whole earth.
- 51:26I'm like, I wonder where that hiking trail ended.
- 51:29And I like went along it for so far.
- 51:31Yeah.
- 51:31But yeah, I feel like Apple Maps was just so like, I just wasn't intuitive with the zoom and you could end up just like, oh God, I can see the entirety of like Europe right now.
- 51:40Exactly.
- 51:41All right.
- 51:42Next one.
- 51:43There's an otter carrying two little tubes.
- 51:45Shooting along.
- 51:47He says he needs those parts for his spaceship.
- 51:50He's going to otter space.
- 51:51I kind of wish that I studied black holes in otter space now because I feel like they would be cuter for one.
- 51:57It's a very cute picture.
- 52:00Also infinitely cool.
- 52:00Yeah.
- 52:01All right.
- 52:01Next one.
- 52:02You touched on this like this.
- 52:03You talked about the Wi-Fi.
- 52:04So there's, I have no idea why there's a seal here, but it says NASA receives data from over 17.3 billion kilometers away.
- 52:11I lose the Wi-Fi signal in my own bathroom.
- 52:14But that's the thing though, that the techniques that are developed to like recombine all the scattered signals from 17.3 billion kilometers away are the same ones that are used to recombine your Wi-Fi.
- 52:26But apparently brick walls are better at disrupting them than the earth's atmosphere is.
- 52:34Yeah.
- 52:34The magnetic field, 17 billion kilometers, all that.
- 52:38Awesome.
- 52:38Yeah.
- 52:39All right.
- 52:39A couple more.
- 52:40Also, NASA's detectors are much more sensitive than your phone detector.
- 52:42Yeah.
- 52:42That's true.
- 52:43Yeah.
- 52:44You wouldn't want to carry that around.
- 52:45All right.
- 52:46So this one is a different kind of eclipses.
- 52:48So we've got the moon, the earth, and the sun.
- 52:51And it tries to show you what the difference between a lunar and a solar eclipse is.
- 52:55So it has moon, earth, sun.
- 52:57It says lunar eclipse.
- 52:58It has earth, moon, sun, solar eclipse.
- 53:01And then it has earth, sun, moon, apocalypse.
- 53:04Great.
- 53:04It's so, so good.
- 53:06I love it so much.
- 53:07Yeah.
- 53:08That's a good one.
- 53:09Yeah.
- 53:09All right.
- 53:09We never see the moon.
- 53:10That'd be so sad.
- 53:11All right.
- 53:12So here's a picture of a traditional alien like E.T.
- 53:15And it says, here's a creature capable of intergalactic space travel, steals a cow.
- 53:19And the thing is, people justify this as like, well, the cow population is greater than the
- 53:27human population.
- 53:28Therefore, they will have assumed.
- 53:29I was like, if they go by that, they'll be abducted.
- 53:32They'll be abducted loads of chickens.
- 53:33Exactly.
- 53:35So crazy.
- 53:36This one made me laugh really hard.
- 53:38I like this.
- 53:38All right.
- 53:39I mean, I would love aliens, to be real.
- 53:41But I doubt that we'll ever make that kind of contact with them.
- 53:44Exactly.
- 53:44Exactly.
- 53:45I do think they probably are out there, but they're far, far away.
- 53:48All right.
- 53:49So this one is really close to your research.
- 53:50Yeah.
- 53:51It's a black hole and then there's stuff around it, but you can see nothing in the
- 53:54black hole.
- 53:54It says, what happens in the black hole stays in a black hole.
- 53:56Yeah.
- 53:56Kind of like Las Vegas.
- 53:57I mean, that is like the most physics accurate meme we've had so far.
- 54:01Yeah.
- 54:02Yeah.
- 54:03I tried to find a few science-y ones.
- 54:04And then let's see what's the last one here.
- 54:06Oh, yeah.
- 54:06This one, it has the moon, which is just a picture of the moon.
- 54:09And then the dark side of the moon, he's dressed up like the emperor from Star Wars.
- 54:13Palpatine.
- 54:14Yeah.
- 54:14Palpatine.
- 54:15Exactly.
- 54:15So cute.
- 54:17I want like a little, like, do you remember they made, it has to made a load of like little
- 54:21plushy teddy bear things of the planets and like all of their little satellites a while
- 54:26ago.
- 54:26I now want like the dark side of the moon as a little, as a little plushy toy.
- 54:31But people get so confused with like the dark side of the moon and the far side of the moon
- 54:35because the far side of the moon is the moon that we can't see because it's what's called
- 54:39tidely locked.
- 54:40So only one side of the moon ever faces us.
- 54:42So, but that's not the dark side of the moon because when we have a new moon, like
- 54:47or a solar eclipse, the far side of the moon is lit up.
- 54:50Exactly.
- 54:51Because we are seeing the wrong direction.
- 54:52Yeah.
- 54:53Yeah.
- 54:53It is confusing, but still a good meme.
- 54:56All right.
- 54:56Those are fun.
- 54:57Thanks.
- 54:57They're great.
- 54:58All right.
- 54:59So final two questions of the show.
- 55:02If you're going to write some Python code, what editor do you use?
- 55:04VS Code.
- 55:05I love VS Code.
- 55:07VS Code.
- 55:07It only just pipped out Atom.
- 55:09Like I was using Atom and then I saw you.
- 55:11It's good.
- 55:12Command D in VS Code.
- 55:14Basically you can highlight a, like a parameter you've defined and then it picks out all of
- 55:20the other times you've mentioned that parameter in your script.
- 55:22And you'd be like, oh, I want to change the name.
- 55:24And if you start typing, it will just change it everywhere.
- 55:26And like the biggest joy I ever felt was discovering that was a thing.
- 55:31Why is this named?
- 55:33I don't want to change it.
- 55:33Wait, it's so easy to change.
- 55:35Yeah, exactly.
- 55:36It's great.
- 55:37Yeah.
- 55:37And I suspect you probably throw Jupyter in there as well as a lot of work, right?
- 55:41But not proper editor, right?
- 55:42I mean, those are kind of more exploration.
- 55:44Yeah.
- 55:44If I was doing something that I was going to share with colleagues, I'd do it on Jupyter.
- 55:47So the final stage where I would visualize my data in a plot or I'd be able to like write
- 55:52something out as an argument, I'd do it in Jupyter as well.
- 55:55But if I'm doing model fitting or if I'm doing a lot of heavy sort of image analysis, I will
- 56:02do it in a script in like VS Code.
- 56:05Yeah, for sure.
- 56:05I think there are just different ways of working.
- 56:07Are you trying to build something that you can reuse and kind of create a little library
- 56:11out of?
- 56:12Or are you trying to explore and you don't really know where you're going?
- 56:14Exactly.
- 56:14Yeah.
- 56:15I'd use Jupyter for doing that as well.
- 56:16Being like, okay, I have this data table.
- 56:18It's brand new.
- 56:19Let's get to grips with it.
- 56:20I'll do that in Jupyter again because it's just so visual to be able to grab stuff more easily
- 56:24and be like, hmm, let's plot this against this and see if there's something there.
- 56:27Like I'll do that in Jupyter.
- 56:28Rather than like a, I used to do it in an IPython terminal, but it's just so much more
- 56:32visual.
- 56:32Yeah.
- 56:33I have a pop up, a sort of window or whatever.
- 56:35Yeah.
- 56:35Yeah.
- 56:36Well, that's another thing I love about VS Code is that when I then write up my papers,
- 56:40so I use LaTeX, which is another programming language, VS Code can run the LaTeX script
- 56:47for you.
- 56:48Oh, nice.
- 56:48It compiles it to the output.
- 56:50So it can also do the same with Python as well.
- 56:52You can like highlight a little section and get it to run in a terminal as well with like
- 56:56shift enter like you do in a Jupyter notebook.
- 56:59Oh yeah.
- 56:59Okay.
- 57:00So it's just great.
- 57:01It's just great.
- 57:02Fantastic.
- 57:03All right.
- 57:04And then final question.
- 57:05There's almost 300,000 different packages out on PyPI.
- 57:08And that's sort of the part of the beauty of Python, right?
- 57:11Is just, you can go grab these things and bring them in, but you know, what one maybe you've
- 57:16come across you want to recommend?
- 57:17Yeah.
- 57:17So I was trying to think of something that would be applicable to like everyone and not
- 57:21just, you know, someone in astronomy.
- 57:22And my immediate thought, and I can't deny it's been one of the most useful packages just
- 57:26ever to me is MC, E-M-C-E-E by Daniel Foreman-Mackey, who is an astronomer as well.
- 57:34And it's a module that codes up Bayesian analysis, like Monte Carlo, Markov chain Monte Carlo.
- 57:39So MC, MC.
- 57:40Yeah.
- 57:41Yeah.
- 57:41And it's essentially like an optimization package, you know, like a scipy.optimize or something
- 57:45like that, but it uses Bayesian statistics to do it.
- 57:48And the Markov chain Monte Carlo, which is really sophisticated way of optimizing, but also getting
- 57:53sort of like, like, okay, you fitted this model.
- 57:55This is your best fit, but this is how uncertain this model is as well.
- 57:59It's what it gives you.
- 57:59And it's just so like ready and out of the box.
- 58:03It's so well documented.
- 58:04It runs great.
- 58:06And it's just, I just can't fault it.
- 58:08Like, that's the thing.
- 58:09And Dan is just like the coolest person.
- 58:11He's just like, he taught me so much Python when I was a PhD student and he was sort of
- 58:15like a senior PhD student as well.
- 58:17And he has the, he has an accent very similar to yours, actually.
- 58:19He's definitely from, I think he's from the Pacific Northwest, but I don't want to say that
- 58:22in case I got it wrong.
- 58:23And he's like, no, no, I'm from Southern California.
- 58:25Exactly.
- 58:26But like, he's an accent like yours.
- 58:28And so I associate that sort of like really sort of like very sort of like slow, not
- 58:33slow.
- 58:34That sounds bad, but you know what I mean?
- 58:35That, that sort of like cadence to an American accent.
- 58:37Deliver it or whatever.
- 58:38Yeah.
- 58:38Yeah, exactly.
- 58:39Like I associate that with just like, okay, I'm going to teach you this cool thing about
- 58:43Python.
- 58:45Like hold your hand through it.
- 58:46So yeah, it's a great, great package.
- 58:50If you're doing anything to do with like model fitting or Bayesian stats or anything like that,
- 58:53I would like a hundred percent recommend.
- 58:55Awesome.
- 58:55Yeah.
- 58:55That's not something I've tried yet because I haven't had to use that, but it sounds really,
- 58:59really useful.
- 58:59Just as a funny story, since you brought up accents, you know, so for like 10 years or so, I did
- 59:04a professional development, like training.
- 59:07I'd go to a company or somewhere and do like a week long in-person course.
- 59:11And I did this one in Beijing and I think the students were nervous that I would come
- 59:17maybe with like a broad Scottish accent or something.
- 59:20It'd be very hard to understand.
- 59:21And at the end of the course, everyone had to write a little review for the company I was
- 59:27working for.
- 59:27And like, what did you think of Michael as a teacher?
- 59:29And then the company, they would go through and review if there's any weird comments.
- 59:34Like, oh, what happened to this course?
- 59:35Like, why did it go?
- 59:35Like, tell us about why this weird, you know, people are unhappy or they're, you know, what
- 59:40did you do to make them so happy or whatever?
- 59:41And the comment was just this.
- 59:43Michael has a very good tongue.
- 59:45And they're like, you're going to need to explain this.
- 59:48What is going on?
- 59:50Was it mis-translation?
- 59:51Yeah.
- 59:52I was like, he just has a good accent.
- 59:53Like, he speaks clearly and like, whatever.
- 59:55Yeah.
- 59:56But it's just like the way on paper, the way that it ended up with, they contacted me like,
- 1:00:00Michael, you need to tell me what's going on.
- 1:00:03I love that.
- 1:00:04My accent confuses people massively because I was like brought up in the Northwest of England,
- 1:00:10but my mom's family are all from the Northeast of England.
- 1:00:12So it's this odd smush.
- 1:00:14And then most Americans haven't really heard a Northern accent or if they have, it's like
- 1:00:17Sean Bean, you know?
- 1:00:19It's like, let's take the hobbits to my city.
- 1:00:23That's all they've ever heard.
- 1:00:26That's another Lord of the Rings reference.
- 1:00:27God, they're flying today.
- 1:00:28And so, yeah.
- 1:00:29And then I've spent obviously a lot of time in South of England now since I've moved and
- 1:00:33my accents had to soften because academia and science in general is such a global thing.
- 1:00:38You know, so many people with so many different cultures and accents coming together that like,
- 1:00:43if I talked in my normal one, I think a lot of people ask me to repeat things so many times
- 1:00:47that it softens and it gets more.
- 1:00:50I enunciate things more now, which makes me sound posher, which I don't like.
- 1:00:55But nevermind.
- 1:00:56Yeah.
- 1:00:57How funny.
- 1:00:58All right.
- 1:00:59So what a great conversation.
- 1:01:01Thanks for being here, Dr. Becky.
- 1:01:03It's, you know, like I said, you're doing great work.
- 1:01:05People should certainly check out your YouTube channel and what you're doing there.
- 1:01:08You're doing a lot of cool work to popularize science in a super accessible way.
- 1:01:12So final call to action.
- 1:01:13People are interested in what you're doing.
- 1:01:15Maybe they want to get Python into their astronomy or maybe they want to get into astronomy.
- 1:01:19What's your final call to action for listeners?
- 1:01:21Install Astropy.
- 1:01:22I think it's a simple pip install Astropy to get into and check out all their documentation
- 1:01:25as well.
- 1:01:26And, you know, do as much physics and maths as you can and get involved with Galaxy Zoo
- 1:01:32and Planet Hunters online because all those kind of clicks end up in scientific research
- 1:01:36papers and they thank the participants as well.
- 1:01:39So it's a great endeavor to be involved in.
- 1:01:41Yeah.
- 1:01:41And one question on the way out, you know, someone was asking if they can read your,
- 1:01:44can the public read your paper?
- 1:01:46Does you have to be part of a journal subscription?
- 1:01:48No.
- 1:01:48So all astronomy papers get posted on something called the archive.
- 1:01:51A-R-X-I-V.
- 1:01:53Oh, astro-ph on the archive.
- 1:01:55And so they're all free to read.
- 1:01:56So you should be able to find them that way.
- 1:01:58They're all listed from my public website as well, actually.
- 1:02:01So you should be able to find them there.
- 1:02:03Yeah.
- 1:02:03Fantastic.
- 1:02:04All right.
- 1:02:04Well, thank you so much for being here.
- 1:02:06It's been really fun to have you on the show.
- 1:02:08Thanks for having me.
- 1:02:08Have had fun.
- 1:02:09Yeah.
- 1:02:10This has been another episode of Talk Python To Me.
- 1:02:14Our guest on this episode was Dr. Becky Smethurst.
- 1:02:17And it's been brought to you by Linode and Cloud ENV.
- 1:02:19Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 1:02:25Develop, deploy, and scale your modern applications faster and easier.
- 1:02:28Visit talkpython.fm/Linode and click the create free account button to get started.
- 1:02:34Keep your secrets secret and in sync with Cloud ENV.
- 1:02:38Get started with their Python library and CLI at talkpython.fm/cloudenv.
- 1:02:44Want to level up your Python?
- 1:02:46We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:02:50Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:02:55And best of all, there's not a subscription in sight.
- 1:02:58Check it out for yourself at training.talkpython.fm.
- 1:03:01Be sure to subscribe to the show.
- 1:03:03Open your favorite podcast app and search for Python.
- 1:03:05We should be right at the top.
- 1:03:07You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:03:12and the direct RSS feed at /rss on talkpython.fm.
- 1:03:16We're live streaming most of our recordings these days.
- 1:03:20If you want to be part of the show and have your comments featured on the air,
- 1:03:23be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:03:27This is your host, Michael Kennedy.
- 1:03:29Thanks so much for listening.
- 1:03:31I really appreciate it.
- 1:03:32Now get out there and write some Python code.
- 1:03:34Bye.
- 1:03:34Bye.
- 1:03:34Bye.
- 1:03:35Thank you.