 Catherine Maroney comes to us from Pasadena, where she works at NASA's Jet Propulsion Laboratory. And she's been working there for the last 23 years, which I think, if it had been all Python back then, would be somewhere around Python 1.3 on the Terra Earth observation satellite. When she's not busy implementing climate observation algorithms, she enjoys more photography, which presumably of this time thinks that you can see without being in a polar orbit, and traveling. Catherine's here to tell us about how we can combine multiple languages, this case Python C and Fortran, to get both fast development iteration and fast code execution. Which sounds very much to me like having your cake and eating it too, so I'm really excited to hear about this. Please give her a warm welcome. Yes, well, well, yeah, as well. First off, I would like to say that I'm sorry to the people who are doing the live captioning because my stutter is going to play holy hell with it. And I'm also hoping that all of the tributes that I've been paying to the gods of fermented grains pay off. So, my talk today is basically doing massive large scale umber crunching, where I use both Fortran and C in order to fill in the gaps where Python itself simply cannot handle things. If you have to do lots of nested loops in Python, you should be streaming some very good television shows at the same time. Because it's going to be very, very slow. And some of the big scientific libraries out there happen to have C interfaces only. What we do for my satellite is that the top layer and middle layers are all in Python. And we breakly compiled all the stuff down into the smallest possible boxes. And then into the Fortran as needed. Run just that very small subroutine and then pop back up to really Python. And what makes it work is that you can pass. No, I'm pie. Pass it down into the Fortran and do all of the necessary calculations and then bounce back straight up to Python. Python is a fabulous language. It will be very slow. And even though C is still the gold standard, trying to do Malik and then work is multi-dimensional. And when I'm talking about Fortran, this is not the old school Fortran 77. This is Fortran 95. This is Fortran 2003. Fortran has the dynamic memory and the data structures. So what you do is that you write as much as the top layer and middle layer stuff using pure Python as much as you possibly can. And then break the Fortran and C stuff down into the smallest possible boxes. That way, most of the code is Python. So I get the advantages of the compact code and the beautiful in text as I can. So what I've done is to make it work. To make a pure Python wrapper around the very low level C interface to the HDF libraries. And you declare the function signatures in your PXD file. It's basically the standard C. And then you write a higher level function call. That wraps all of the individual C functions. And you put that in your PYX file. And then there's the function signature. These are the individual function calls and so on and so forth. And then you create the final class in pure Python. And the final, all of the top level functions and the end result. Happens to be pure Python just like this. And then you create the file. And then pass that straight down to the lowest level C. And writing the same code in straight C would be a good maybe 50 lines of code. But with the high level wrapper, instead of being 50 lines of code, it's now a very compact very, very easy to read five lines. And you can put it into the setup file or compile it from the mandoline. And the second example, like, for example, doing a weighted median filtering in Python on, if you did the, it's in straight Python on, you'd better be streaming Game of Thrones. Because this would be achingly slow. So what you do is that you take that smallest possible box, write a pure, pure, pure four trans subroutine, and then create an object file using F2Py. Then import hot, hot, hot, into your Python code. And then the calling process in between the C and Fortran happens to be absolutely transparent. So the trickiest part is that the Python and Fortran function signatures need to match up exactly. So what I always do is to get the function signature coded up. And test it piece by piece. And unsatzz working in the actual function coding itself, it happens to be absolutely straightforward. So what you do here is that you, as in the various arrays, using the following method, the shape of the out array comes first. And then the input arrays in order. And then the shapes of those arrays in order. And this little unit test passes. So I know that my function signature is now working. And then adding the actual Fortran guts happens to be very straightforward. So if Fortran and function signature happens to be here, the guts of the Fortran happens to be here. And then what you do is that you compile it from the command line using F2Py, and namely the shared object file Fortran. And then in your Python, all you do happens to be the... be a standard import statement. And then you just say, my result happens to be Fortran. And the name of the function is test4. And this then passes the... passes the NumPy arrays into Fortran, reads them, writes to them. And from the point of the top level Python, it is completely transparent. And you can include this into your setup file also. And that's it. Thank you. Thank you very much, Catherine.