Storing Configuration Values
00:00
Using my crystal ball. I’m looking into the future. I can see that I’m going to need some constants that I want to use again, and as such, I’ve created a shared configuration file called config.py
.
00:12 There’s some stuff in here you’re not going to use until the next lesson, so I’ll be ignoring some of it for now.
00:19
The Astropy get_body()
call fetches coordinate information about an object in our solar system, and it needs to know where on Earth you are as positioning information is relative to you.
00:31 More on this in a future lesson, but for now, you need to know that you need an Earth location object. So I’m importing that here when dealing with astronomical data.
00:40
In fact, most science data, you’re going to have both values and units that go with them to help track and manage this. AstroPy
has a module that allows you to attach unit information to your data.
00:53 Here I’m importing it and using it to you. This allows you to do things like translate between degrees and radians and helps prevent you from sending in one when a function expects the other.
01:06 To create an Earth location object, you need some positional information. I’ve created three constants here, one for latitude, one for longitude, and one for elevation.
01:17 The magic numbers are my home in Toronto, Canada. Using these three constants, I create a new Earth location object. Note how I multiply latitude and longitude by degrees and elevation by meters, making sure the correct unit information is associated with the values.
01:36 Everything else in this file is actually for the next lesson, so let’s go look at.
Become a Member to join the conversation.