Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Determining Local Midnight in UTC

00:00 All right. I’ve got the time stuff out of the way. Now, for the core math, again, this is a snippet that I’ll combine into the bigger picture in a few minutes.

00:09 I wanted to just set it aside for a moment and concentrate just on this chunk. The first step is to ask the user for the name of a target to view. In the previous lesson, you used the Astropy get_body() call.

00:21 That only works on planets in our solar system. The .from_name() method of the SkyCoord class casts a much wider net. It uses a database to look up the given name and return the corresponding coordinates.

00:34 Remember, SkyCoord contains a right ascension and declination. With the target coordinates in hand, I need to translate them, and I want to do that for every viewing time in my array.

00:47 First, I call the get_viewing_times() function I just showed you, getting the array of times, and then I construct an AltAz object, giving it the range of viewing hours and the current location.

00:59 This actually results in a translation frame. Technically, it’s an array of translation frames, one for each viewing time. Astropy, like NumPy, is a little fast and loose with the types, with the context determining whether something coming back is a single value or an array.

01:15 This can be a little confusing until you’re used to it. These calls might look like they’re using a single value, but they’re actually operating on a spectrum of values.

01:24 You then use the frame to get a set of translations to the local position. Over the range of times, this final step takes the target and performs the translation, transforming it from SkyCoord to AltAz.

01:37 This is the core of what needs to be done. Everything else is just setup and making the pretty pictures. Let’s put it all together now.

Become a Member to join the conversation.