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