I love to bring you stories of Python being used in amazing places outside the traditional tech silos of pure web development and data science.
On this episode, you'll meet Robert Kane Repligal, who works on simulation and test software at Richard Childress Racing,
the NASCAR team that just finished number one and two at the Texas Motor Speedway.
You'll hear how Python is allowing them to model car behavior, airflow, and much more, faster than others using outdated tools.
This is Talk Python to Me, episode 281, recorded July 22nd, 2020.
Wait, wait, wait, wait. Normally, I'd play a little guitar riff right here to kick off the episode.
But this episode is about racing and race cars, so let's kick it off with a different kind of instrument and note.
Let's jump into a 2017 Indy Pro Mazda, a furlap around the storied Brands Hatch circuit, and let the engine notes be the music.
This episode is brought to you by the music.
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.
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 Sonar Cube and Linode. Please check out what they're offering during their segments.
This is a really fun episode. You're going to enjoy Kane's story.
And if you're interested, you can find the full five-minute video that Drive Around Brands Hatch at talkpython.fm/hatch.
Kane, welcome to Talk Python to Me.
Thanks. Glad to be here.
Yeah, it's awesome to have you here. I get to bring two of the things that I'm really passionate about together, racing and Python.
All right.
And you've got some really cool stories to tell, I could tell already. So I'm looking forward to having you on the show.
Thanks for having me. I'm excited about it.
Yeah, it's going to be a lot of fun. And I guess, as usual, let's just start at the beginning. How do you get into programming in Python?
Well, it's a pretty long story. But I started off with, do you remember the basic game, Gorillaz? It was like Windows 3.1 and you threw the bananas that blew up.
Yeah.
That's where I started. A friend of mine showed me how to get in there and hack the explosion side so I could never lose to my brother. So that was the intro. It at least got me started on looking at logic and reading code. And then my next project was actually programming my HP calculator. I don't know if you ever used one of those.
You know, I got to admit, I was always a TI sort of person.
Yeah.
I didn't have the HP when I had the TI. Even I had one of those big widescreen TI-93s that had a Cordy keyboard in it. It was crazy.
Oh, yeah.
But yeah, I remember.
No, this one goes back to the reverse Polish notation and everything else that everybody hated. But you were shamed if you had a TI in mechanical engineering. So everybody had HPs.
But yeah, so I did a couple of scripts with that stuff, just mostly playing around. At Auburn, we studied Fortran 77. This was back in 96.
You were in engineering?
Yes.
In mechanical engineering?
I studied mechanical engineering in Auburn.
Yeah. I was in chemical engineering for a year and I wanted to take C++ and they told me, no, no, no, you have to take Fortran. It's going to be the most important language you ever learned.
Yeah. Yeah. And the older generation of mechanical engineers are still diehard Fortran.
Interesting.
One of the teams I worked with a few years ago, their simulation was actually written mostly in Fortran. And I mean, you can't argue with the processing speed of numerical calculations, which is all the sim really is.
So yeah, it smokes.
By the time I was like a sophomore year, I had moved on to MATLAB and most people were using MATLAB for their coursework and projects and things like that. So yeah, I was a big fan of MATLAB for a long time.
And then all my graduate work, I did my master's at Purdue with a focus on vehicle dynamics and all my master's work was done in MATLAB. So got a pretty good amount of experience in that. I really like the scripting languages. I've done some Objective-C stuff and felt out of place, you know, with compiled code and not being able to really dig into it after using MATLAB for so long.
So yeah, you can't just open up those APIs and have a look at them, right? They're binary.
Right, right. Yeah. And so a lot of the problems that we work on in this industry, you have to explore the data a ton before you know what you're even going to do with the project. So the scripting is good for me. My coworkers that are the C-sharp and C++ guys shame me and tell me I'm not a real programmer, you know, so.
But it's all in good fun. And I continued using MATLAB as I started my career. Ford Motor Company had pretty much all their stuff in MATLAB at the time. When I left Ford and went to Hendrick Motorsports to be the race engineer for the 24 car with Jeff Gordon, I was sadly, sadly depressed to not be given a license for MATLAB.
So, I mean, they were doing everything in Excel and they were the ones who SIM runs in Fortran.
Right.
So it was the simulation, they used Excel as a GUI and then had this backend of Fortran piped in to run it. So it was pretty interesting because having the power of Excel where I can just click here and do some calculations was pretty useful.
Yeah. Excel is really powerful like that, right? Except it's hard to follow the logic of it if you've got this formula that leads to that, which is back over there. And then there's a conditional, which jumps here.
Oh, it's impossible. It's impossible.
Yeah.
I cringe when somebody sends me a big Excel sheet with all kinds of formulas all over the place. The logic of the structure of it is what makes sense. And I am not a fan of VBA, so I don't like getting in the backend of that either.
But yet moving into the, you know, racing stuff, we'll spend a million dollars to try to make five horsepower, but we can't spend $2,000 on a MATLAB license to solve analytical problems.
Yeah. I think that's the, I mean, that's the racing take on that story, but you hear and see that story all over the place. Like companies spending millions of dollars or there's millions of dollars of efficiencies to be gained, but like, no, no, no.
You're going to use this crappy old computer that doesn't work that well. It's all locked down or you're going to not get a license to this thing or that thing because for whatever reason, it's right.
It blows my mind how some of these, these sort of organizations can be like Pennywise pound foolish.
Yeah. Yeah. And it's like, I had just finished simplified vehicle simulation optimization program as my masters. So I see the power of not even having to figure out what you want the car to do. You give the simulation, these limits of things that you want for the balance and for the travels and things. And you just say, go. And it finds the setups that will get you those vehicle outputs.
And it's like, wow, that's still not really being done in the same way as what I was doing way back when.
So when you're talking about simulations, is this like tire pressure, ride height, cambers, like the mechanical setup or something else?
No, it's a full model, physical model of a vehicle. So the big modeling package right now is Demola, which is built on Modelica and it handles all the dynamics and vehicle parts, but there's still a lot more to it.
When you want to have a nice GUI interface, you want to be able to output files. There's a whole realm of difficulty in putting this stuff together. It's pretty impressive that a lot of the teams develop their own in-house.
Yeah.
Get out of racing, actually, after I left Hendrick. Didn't really know what I wanted to do. You know, the schedule is just brutal in NASCAR. It's 38 events. And my last year on the road with a 24, we had 22 tests. So I was in town 31 hours a week.
Wow.
And I was in the shop working. And I mean, I was not having a good relationship. We were having problems. And it just got to the point where I got moved into the R&D group where I did only about half as much travel and got to work on some pretty cool projects doing experimental, I guess I should say, exhibition races.
So, like, Dale Jr. Decides he's going to run the three car in Xfinity with his dad's old Wrangler paint scheme.
Right.
And they would work out a deal with Hendrick to make that race happen. And so I'd still get to do some race engineering, but I was mostly doing beta testing and breaking things because I had a reputation for being able to break any sim release.
So they all went through me before it got released to the guys, you know, that were going to the track. So, but I still wasn't programming much. But through that, I got a lot of experience with user experience part of it.
Like, just making suggestions to the simulation group of, hey, can we add this little calculator thing over here? And can we add this would be really useful for the race engineers at the track. And maybe I'm lazy, but I like software to work very easily and fluidly. And I hate doing a lot of clicking. And if it takes 75 clicks for me to get the sim to run, I am not a happy guy, you know?
Yeah, exactly.
But then moving on after that, I kind of did an about face and started doing lighting design for concerts. And I wasn't happy with the software that was available for that. So this is where I delved into the Objective-C part using Xcode with Course Composer and doing some video projection stuff and pretty fun stage lighting, motion lights, had some pretty cool little gimmicks. I always got frustrated at shows where they had lights and video, but the color schemes clashed.
So I programmed mine where the projection mapping would follow the complementary color set of the lighting design.
Oh, that's clever. That's cool.
Yeah. And then I ran into the problem where not, you know, sometimes I would just do the projection stuff and there would be another lighting designer, but they wouldn't have an output that they could give me easily to receive what their color scheme was.
So I started using a digital camera and I had an app that I had built for my iPad where I could pick from the video image and it would decode what that color of those pixels were.
And then I had a little color matching deal that would match it up.
So even if I didn't have that data coming in, really, I was solving problems. That's what I do. Right?
Yeah, that's awesome.
This portion of Talk Python to me is brought to you by SonarCube.
Here's something I get asked a lot.
Once you've mastered the basics of Python, how do you keep building your skill of the language?
Not everyone is lucky enough to have a well-versed mentor who can take the time to look over new commits and guide them in mastering the more subtle aspects of Python.
That's where SonarCube static analysis comes in.
SonarCube finds bugs, vulnerabilities, code smells, and security hotspots in your code.
Every issue is presented in the context of the code with a detailed description of why it's a problem and code examples to guide you in making the fix.
It's powerful, fast, and accurate out of the box.
Oh yeah, and it's free.
So learn more and download SonarCube today at talkpython.fm/sonar.
That's talkpython.fm/sonar, S-O-N-A-R.
Yeah, so I got back into racing.
Obviously, the pay is pretty good compared to normal engineer's pay.
So they drug me back in.
I did a technical director role at a small team and then was still doing the lighting on the side.
But then I moved on to, I got invited while I was still racing, I got invited to be an associate professor at UNC Charlotte, University of North Carolina, Charlotte.
Oh, awesome.
In mechanical engineering?
It was in, they actually have a mechanical engineering motorsports division.
Oh wow, that's pretty specific.
That's awesome.
Yeah.
And so they try to prepare the students for getting out into the actual race industry, which is pretty much centered here in Charlotte, especially for NASCAR.
Yeah, that's sort of the world headquarters for NASCAR, like Indianapolis is for Indy and maybe UK is for Formula One.
Yeah.
And I mean, it helps physically for all the teams to be close together because there's a lot of turnover between different teams and all.
And, you know, as you go, not have to move all over the country to go to different places.
It's just the length of my commute changes for what team I'm working with.
Funny.
Yeah.
But so I started thinking a lot on designing this new vehicle dynamics class and how what I was seeing in other industries with this data science movement and machine learning stuff is that it's going to be the way of the future.
I mean, there is no doubt about it.
The gains that we're able to make by applying machine learning algorithms to this data is just leaps and bounds of what anybody could do in an Excel spreadsheet.
And it's fast and it's fast to develop.
And somebody can have a super great idea, but the three other engineers that are going to be using this tool, they want some small aspects of it changed, like how you break up the track, where you're looking at cornering forces and things.
And so I felt like I wanted to make the class a lot like the vehicle dynamics class I took in my master's program.
And it was heavily numerical based.
It was all MATLAB.
And so I just said, well, it's been a few years since I used MATLAB, but I'm sure it can't be hard to relearn.
So while I was on a full travel schedule again, I was staying up till one and two in the morning, just making toy projects and doing tutorials and trying to get my class together.
Cause I only had two months to have not only skills enough to teach the material, but I had to write the whole course.
I had to write all the homework assignments.
I had to write all the tests.
Wow.
And I think I was getting like four hours of sleep there for that two months period.
And then when I finally had the class done, I slept for like 24 hours straight and it doesn't help.
You still just wake up tired, you know?
Wow.
But I had a lot of great feedback.
You know, they had never even had a MATLAB class.
Any of the students, they don't teach that in the department.
And so they were all learning from scratch.
And one of my TAs, he loved it so much.
He took my class the first semester and then was my TA the second semester.
And he came to me like halfway through his semester.
And he's like, I almost had my whole thesis research work redone in MATLAB because he was trying to use Excel to process engine data that was recording at like a thousand hertz.
You know, 50 channels at a thousand hertz.
He had these spreadsheets that were just massive.
And I mean, Excel can't handle that.
Yeah.
The document too large or whatever.
Like it only does five minutes at a time.
Who knows?
Yeah.
And he redid it and he was just so proud of himself.
And I mean, I was proud for him because that is a big thing to take the semester you're about to graduate and just start at ground zero.
Yeah.
But to have the skill to be able to do that and make it happen is pretty good.
He actually ended up taking a job at Caterpillar designing huge diesel engines for the earth moving equipment.
Okay.
Yeah.
Caterpillar is doing a bunch of stuff with Python.
Oh, yeah.
Yeah.
Actually, Caterpillar is one of our sponsors too.
I don't know if you knew that for our team.
No, I didn't know that.
Yeah.
They were telling us, I met with some of the guys.
We were comparing machine learning notes and he was telling us about their division that does all the reliability testing and things.
So they have all their trucks instrumented.
And as they're going out, they're beaming the data up to a satellite and beaming it back to their data science department and processing it and trying to figure out when these engines are going to fail in a certain way.
Wow.
Yeah.
It's pretty impressive how industry has really latched onto the data science, but racing still lagging behind, I feel.
But we still haven't got to my Python.
Well, you know, one of the things...
That's right.
Bo, just one quick comment.
I think the type of software that you're talking about is really interesting challenges.
I got to work in this for a while as well, where it's event-based, like human event-based.
Yeah.
Right.
We're going to go to the track and on Saturday, the software has to work because we're going to run the simulation in the morning and apply it in the afternoon.
And if it doesn't work, it's not like, well, we'll fix the bug next week or we'll push that to the next sprint.
Like, yeah, that was the Daytona 500 and it didn't work.
So you missed it.
Oh, yeah.
Tell me about it.
I mean, and it's even worse than that.
What I always tell all the young engineers that I've trained is there's really two things you need to do to be successful in the racing industry as an engineer.
The first thing and foremost is you need to remember that the decisions you're making on this car are going to potentially affect somebody's life.
I mean, much less you could crash the car.
You could crash the car and hurt the driver.
You could kill the driver.
You could crash the car so bad that parts go through the catch fence and hurt fans, which has happened before.
And so I always try to make sure that they understand the impact that they could have.
But when it comes to the key talent that you need, it's measuring disappointment because it doesn't matter how hard you try.
You can show up to the racetrack with the fastest car and be the fastest in every practice and qualify on the pole and lead the most laps of the race.
And then by no fault of your own, cut a tire, plow into the fence and your whole weekend.
Now, no matter how good it was to that point, you're a failure now.
You know, and yeah, absolutely.
Yeah.
I see a lot of the young people really have a problem battling with depression.
And I mean, I tell this story as kind of a joke in a way, but it's serious.
And it's easy to get disgruntled and like think of yourself as a failure in this industry.
Yeah.
I can imagine.
I mean, you have to set your expectations right.
Stuff's going to happen.
Things are going to go wrong.
Right.
Sometimes your fault, sometimes not.
Sometimes finishing in the middle is something you've got to be proud of and not like seen as a failure or whatever.
Right.
Like it just I think it does take that mental sort of not necessarily toughness, but just setting the expectations in a real way.
Absolutely.
It seems really frustrating.
Like you spend the whole weekend.
Someone takes you out in the first corner of the race.
It doesn't matter how good your simulation was.
Nope.
You you're packing it up and you're going back home.
Yeah.
And there's a few other aspects of it, too, where I mean, we're a team.
Right.
So if one guy gets down on the team and you're riding back to the hotel in your your minivan and he makes some comments about how bad practice was that day or something that affects everybody around you.
And so having that positive mental attitude is the only way to be successful.
And I mean, I've definitely learned a lot through my career, which is why I try to share that.
But in my earlier days, it was rough.
I was not a good teammate and would say harsh things and I would have harsh things said to me.
Yeah.
But back on the Python track, since we still haven't made it there.
So after I had my son, I couldn't do working on a race team full time and teaching classes.
So I had to quit the UNC Charlotte job and I loved it and love my time with MATLAB.
But then I lost my license because I was on an educational license.
So I had to look at the landscape of like, what do I want to do at Richard Children's Racing?
We had some legacy licenses at the time, but they were so old that going back and relearning what the syntax changes were was not really something that I had any interest in.
And now we've actually upgraded and we have plenty of MATLAB licenses as well.
But I've put so much effort into my Python experience and I just love it.
I mean, it's clean.
Yeah.
My code is beautiful.
I love PEP 8.
I love black.
Oh, yeah.
And just not even having to think about the white space and how I do my continuation lines.
And I mean, just every aspect of it.
I really, the most surprising thing to me is that Python didn't show up on my radar during my entire career up until three years ago.
Yeah, that is pretty interesting.
Yeah.
Because just nobody in my industry used it.
But yeah, so I've kind of gone full tilt on the Python kick, probably done 20 or 25 online courses and everything that's on the Kaggle page.
Been working on the fast AI.
I think you interviewed Jeremy Howard, who is just an amazing teacher, has an amazing teaching style.
You can't not like the guy.
Yeah, awesome.
Yeah, I don't think I have interviewed him.
I should.
But yeah, fast AI is cool.
Yeah.
And clean.
And I was already using PyTorch and it works on top of PyTorch now.
Okay.
So maybe give me a perspective now that you're three years in.
You're not new to the Python world at all anymore.
Some of the stuff we're going to talk about that you've been doing, it's incredible.
But it's still pretty fresh in your mind, I suspect.
Coming from this commercial MATLAB, every little aspect of a library, every toolkit I want to use is like another $1,000 in a negotiation with a purchasing side of my company.
Versus if you can find it on GitHub or on PyPI and it works decent, now that's another thing you can do.
It feels like the world is more open to just doing what you want to solve your problem.
Well, and I think to put that even further, I would say that the competition level is really interesting with open source.
Because as you see some new idea come out, you might see a package start and then another flower pops up somewhere else.
And the contributors look at each other's work and they're like, okay, I'm going to come work on yours now.
Yeah.
You know, and just like abandon that space if somebody comes out with like a better approach to solving some issue.
And I think that that is a powerful thing that these commercial softwares can't compete with.
Right, exactly.
And they definitely can't compete with all the free help that people give.
Yep.
Absolutely.
That's really, really interesting.
So let's talk really quickly just about like some high level stuff in racing.
I want to keep it a little bit focused just so we can spend a lot of time on the Python that you're riding, the simulations you're doing.
But just give us a sense of what type of data you're collecting.
You know, is this during the race you're tracking like tire wear or is it speeds or are you trying to simulate when you should pit?
Like what kind of stuff are you guys doing?
Yeah, pretty much most of that.
We're limited during the race.
NASCAR has, they issue us a data logger and it is nothing that you can really mess with.
And it only has certain channels.
So we're only allowed to have a few channels during the race, you know, GPS location.
So lat, long, elevation type stuff.
A few basic driver things.
So you'll have brake pressure, throttle position, and steering wheel angle.
Everything he's doing, he controls with those three things.
So, I mean, other than shifting gears, but most of the time we don't even shift gears on track because you get to fourth gear.
And that's where you stay for the whole lap.
Unless you're on a road course, yeah.
Yeah.
But during tests, we might have a small test where we just have like 50 instruments where we're actually tracking damper travels for the suspension, all kinds of engine things.
Air flows through the radiators.
Air flows through brake ducts, you know, if we're running out of braking track.
We have these things called wheel force transducers that are like the top of the line.
They're the most expensive sensor.
So you typically actually detune your car when you go test with this because you don't want to risk hitting the wall.
But it measures the three directions of force, three directions of torque, tire pressure, tire temperature.
And so there's quite a few sensors on just that one tire.
You know, we'll use pitot tubes mounted to the roof to track airflow across the top of the roof.
So we can look at the pressure difference there.
There's inside the engine, there's just a hundred things that you could do.
So the data system, the data person job is pretty demanding as well.
Yeah, it sounds like it.
But the system we use for the races is pretty small.
It's pretty lightweight.
So it's not a big deal.
Yeah.
And then, I mean, not to mention we go to the wind tunnel.
I don't know if you've seen the wind shear wind tunnel, which is what we use most of the time, but it's a...
Yeah, I don't think so.
Maybe tell people about it.
Yeah.
It's a 180 mile an hour rolling road wind tunnel.
Like a treadmill, but that goes 180 miles an hour.
It's a treadmill with a $300,000 stainless steel belt.
Oh my goodness.
Okay.
You know, and so there's force pads under the belt to measure the weight on the tires.
And you're also trying to capture the wind speed through the radiator and that kind of test too.
And you don't want to mess with that belt because it's very expensive.
But 180 miles an hour is the...
I believe it's still the fastest wind tunnel in the world.
Wow.
That's pretty awesome.
And I love when we do a wind tunnel test because I only live about three miles from
the wind tunnel and I live 40 miles from the shop.
So it's much nicer commute, but then I don't get to listen to as much podcast.
Yeah, that's true.
That's definitely a drawback.
But yeah, a three mile commute is pretty sweet.
Yeah.
So one of the things that you actually have been spending a lot of time lately is applying
Python and scikit-learn to this wind tunnel data, right?
Oh yeah.
We had an aerodynamicist leave at the end of 2018 who managed the wrangling of all the data
from the raw wind tunnel data into what our sim needs to ingest to do all of its calculations.
And he kind of left all of a sudden.
And so I wasn't that busy.
And so I was just like, hey, pick me.
And so I took it over.
And I have to say that the system that they were using for all this wind tunnel data in
Excel was a nightmare.
And so our manufacturer, General Motors, had been working with a company to develop a new
fitting algorithm to fit this data.
You have to imagine this data is four dimensional.
So you have two travel things on the body that tell you the attitude of your car.
And then you have the yaw angle that your car is to the wind.
And then you have roll.
Right.
Okay.
So it's a 4D fit problem.
So they're kind of struggling with getting the accuracy that we were trying to demand.
And their system, the workflow was pretty hairy and a lot of manual cutting and pasting and
putting it into a form that you needed.
And I got so fed up with it, with this wind tunnel a few months ago that I said, you know
what?
There's another guy who's helping with this now.
Hey, you start with their stuff and try to do it, mash it through.
And I'm just going to write a new script in Python and let's see who finishes and what
the results are.
And so, you know, at first I was really nervous because it was like the first time I was
the first time I had tried to fit a four dimensional surface like that in Python.
And at the end of the second day, I had improved the accuracy of the fit by five times.
Wow.
In some parts of the map.
And just...
500% improvement.
That's insane.
Yeah.
I'm like, you know, but where it missed, it missed really bad.
It wasn't bad everywhere.
Okay.
But where it missed, it was really bad.
So I might've had, we talked wind tunnel terms in terms of counts, which is the coefficient,
but they might have an error at some point of the map of 80 counts.
And I might have an error of one count or two counts at that same point.
And so the support vector regression algorithm inside Git Learn is phenomenal and so easy to
work with.
And it fits super fast for the amount of data that we're using.
But yeah, I think another interesting aspect of that project is the other aerodynamicists
I was working with who kind of went on and got the headaches of the other package.
You take the bumpy road.
Yeah.
When he came back, well, I had been doing it for almost three years at that point,
two and a half years.
So I had suffered enough, but yeah, he came back and I showed him what I was doing.
And he was struggling with his sheet that he uses in the wind tunnel of his Excel sheet locking
up and things like that.
And so we had a few discussions back and forth about MATLAB versus Python and everything else.
And I showed him the code for the aero map fitter that I built.
And he was like, I'm sold.
That looks so easy.
And so he actually jumped on board and has been working on this project to replace his thing.
And he finished it last week and used it for the first time in the wind tunnel last week.
So kudos to him.
That's a pretty good advancement.
Yeah, that's a big achievement.
Yeah.
In a two month span, you know.
Yeah.
Wow.
But he also had a good teacher, I guess, since he calls me up.
But one thing that you talk about on the show a lot is the imposter syndrome.
And I have to say that that hits me right in the heart because every project I do,
I've got to learn something new to finish the project.
And it's like, when will I ever know enough to just sit down and not have to pull up the
documentation on some package or something?
And it kind of gets to you after a while.
You get stuck on some pandas.
I forget what it's called now.
It's like, it's where pandas is trying to make, pandas thinks you're trying to make a copy of data.
But what you're really doing is pointing to the same spot in memory.
Right.
So you're going to run into problems when you change the one thing and now the other thing changes.
And that kind of stuff is hard to get your head around when you come from the MATLAB space.
So he has lots of errors like that.
But, you know, having my coworker come to me and show me what he's struggling with and me let, you know, just have that.
Wow.
I remember struggling with that.
Here's how you fix it.
Yeah.
And that really takes away a lot of the imposter part when you can provide so much help so quickly without any effort.
That's a great point because so often you're pushing the edge of the envelope, trying to do more and more with your current skill set.
So you always are pushing against that edge and always.
Right.
You got to feel that like that struggle.
But then you get a chance to look back and help others.
You're like, oh, actually.
This is easy.
I clearly see what you need to do.
I remember this was hard, but it doesn't feel hard anymore.
Yeah.
Great.
Well, and, you know, in the racing industry, I mean, I have data that I'm processing that comes directly from NASCAR.
I have the track data that's coming from multiple sources.
I have the wind tunnel data that's coming from source.
Your joke about, I think it was you or Brian said the joke about 80% of a data scientist's job is wrangling data and getting it into the right form.
Yeah.
And 20% is them complaining about spending so much time wrangling the data.
I definitely have been accused of that because I will complain.
But again, you have all these different sources that you don't control.
And so when you have a sheet, a data file being delivered to you that changes size in all different aspects, every week, depending on the track, it has different widths and different lengths and all this stuff.
And dealing with that by hand is just a nightmare.
So Python's been a definite blessing with regards to that.
This portion of Talk Python to Me is brought to you by Linode.
Whether you're working on a personal project or managing your enterprise's infrastructure, Linode has the pricing, support, and scale that you need to take your project to the next level.
With 11 data centers worldwide, including their newest data center in Sydney, Australia, enterprise-grade hardware, S3-compatible storage, and the next-generation network, Linode delivers the performance that you expect at a price that you don't.
Get started on Linode today with a $20 credit and you get access to native SSD storage, a 40-gigabit network, industry-leading processors, their revamped cloud manager at cloud.linode.com, root access to your server, along with their newest API and a Python CLI.
Just visit talkpython.fm/Linode when creating a new Linode account and you'll automatically get $20 credit for your next project.
Oh, and one last thing.
They're hiring.
Go to linode.com slash careers to find out more.
Let them know that we sent you.
I can imagine.
And, you know, the version of the software changes or you go to the track the next time.
They're like, oh, we've changed the format of this or we've added a column or taken away a column.
And you're just like, oh, great.
Here we go.
Yeah, constantly.
Oh, and they always would add the column.
They don't add it at the end.
So, in Excel, where you had all your formulas related to that cell, now that cell is not the same data anymore.
And you got to go through and change all your formulas again.
And, oh, man, it's just...
Like halfway through the session, it's changed or something.
Yeah.
Or, you know, it's a data stream.
So, maybe the data is just not coming in anymore.
Like, it just...
You missed a packet.
Yeah.
Like, what do you do then?
And, you know, or there's a big section of blank.
Yeah.
So, dealing with that with pandas is just a dream come true because it has like the drop NAs that just gets rid of all the NAs.
Or, you can replace all the NAs with a zero or whatever kind of makes sense for whatever that entity is.
And especially for the amount of data that we're processing from a race event where the data is all being recorded at 20 hertz.
Right.
For hours?
It's a four-hour event with 10 channels at 20 hertz.
Oh, and NASCAR releases all 40 cars data.
So, everybody had...
So, you don't just have your two cars that are in the race.
You've got the 40 cars that are in the race.
That's interesting.
And do you do a lot of analysis on the competitors' cars?
Yes.
I can imagine.
Yes.
Quite a bit.
We're actually...
Right now, what I'm gearing up to do is do a full suite of dashboards to try to get the hands into...
Or the data in a usable format into the hands of the less technical people.
Or even the technical people who just don't have Python experience.
It's been hard for me to provide them with it.
It's mostly them sending me work orders where it's like, hey, can you run this on these files?
I need this report.
Yeah.
Give me the report.
Yeah.
And so, you had done...
I guess it's been a couple months ago.
You had the guy from Streamlit on.
Yeah.
Adrian on from Streamlit.
Yeah.
Adrian.
Yeah.
And I had been working with Plotly and Dash.
And I think for the end polish product, maybe you can make it look nicer with Dash still.
But you have to do all the CSS programming.
I mean, who really wants to do all that stuff?
So, I actually downloaded Streamlit today for the first time and started working with this afternoon.
And I've already got a dashboard built that is functioning with the lap data.
Oh, that's cool.
Plotting out lap times.
And I mean, it is just...
It is...
Wow.
What a simple thing.
Yeah.
So, for those folks who haven't heard about Streamlit or didn't listen to that episode,
I'll give my take on it.
You can give your take on it.
So, the idea is you take something that would be just a top-to-bottom regular script.
Maybe it has functions.
Maybe it doesn't.
And you want to turn that into an interactive website.
That sounds like a very far bridge to cross.
But the way Streamlit works is it does a bunch of magic to give you stuff that you just put into your script.
And then it turns that into interactive dashboards with sliders and drop-downs and search fields and all kinds of stuff.
And integrates with Plotly and other tools as well.
Yeah.
It's pretty slick, right?
It's really slick.
And one of the things that I'm surprised Adrian didn't really touch on, or maybe he did and I just didn't recall,
it works similar to...
I do a lot of stuff in Jupyter Notebook.
So, I'm always wanting to review my data.
So, I create a data frame and then it's df.head so I can see and make sure that it's in the right form and stuff.
And Streamlit does that and it puts it on your webpage.
So, you don't even have to tell it st.table or whatever.
You just put the data frame, you know, just data frame.
And then, bam, it's on your page.
Nice.
Anything that is a variable that is on a line by itself, it just assumes you want it to put that output to the HTML.
And, I mean, how awesome is that?
I mean, this is like the best, laziest package I've ever seen.
Productivity, productive laziness or something like that.
There's got to be a term for it.
Yeah.
And working with it for the few hours that I did and to already have a dashboard that doesn't look great,
but is functioning, I think is pretty impressive.
Yeah, yeah, it definitely is.
So, this is something you could publish for people to interact with more real-time data or so they don't have to bother you.
They can go do the slider themselves or select the thing themselves and they get the answer, right?
Yeah, exactly.
And sometimes too many opinions is too much, definitely in racing, because everybody's making decisions from partial information.
But I still think getting tools like that into as many hands in front of as many eyeballs as possible has got to be an improvement of somebody noticing something that the other people haven't noticed yet.
And hey, what's with this?
Or hey, look at this correlation.
You know, if you do this output metric versus your finishing position and you see a trend of spring rates and things, having all those people poke around at this stuff, because we do have,
I think our simulation has 634 user inputs right now.
So, and some of those aren't, some of those are not stuff that you touch all the time.
A lot of them aren't.
But there's about 275 things that you set in the model to actually be able to simulate a car.
And it gets worse every day because things keep getting added to it, right?
So-
Right, right.
Different knobs you can turn, different adjustments you can make.
Yeah.
And everything's interactive.
It's a dynamic system.
It's not a dynamic part.
You can't change this spring and change, you can't change one thing and get any benefit.
You have to change a system of parts.
Right.
You change the springs to make them softer, that changes the ride height, which changes the aerodynamics, which changes the wind pressure or whatever, right?
Like it's all-
Exactly.
It's like a whack-a-mole.
You change one thing, it's going to change a bunch of others.
Yeah.
Yep, exactly.
And you'll have crew chiefs that'll come to you, you know, in eight minutes left in practice and want to change these five things and expect you to know how to set the other things to keep your car from crashing into the ground.
So it better run quick.
Yeah.
So how do you run these things?
Is it computationally slow or do you just have a lot of hardware or is it not actually that bad?
Yes.
So it depends.
There's a different aspect.
There's the full dynamic model and that needs to solve at a thousand hertz.
So that's a lot of data.
So that's a lot of data, a lot of decisions being made for how all these parts are moving on the suspension and everything, how the car is sliding with the tires across the pavement.
That I won't say is slow, but it's way slower than a steady state model, which is getting rid of all the dynamics, basically using a set of data inputs that are super simplified and only solving at 10 hertz.
So you don't get the same answer.
Right.
But like in a case where you need to make a decision really quick and like right now, that is a great tool to have as well.
Right.
If you can get an answer that you're 90% sure of in the next 14 seconds, that is way better than getting an answer that you're 95% sure of in 42 minutes.
Yeah.
It's exponentially.
As you get your accuracy, you pay with money, you pay with computational time, you pay with losing the engineer's focus.
The longer he has to sit there twiddling his thumbs, like he's daydreaming about what he's going to do when the track closes or whatever, you know?
Right.
It's easy to lose yourself when you're running 200 sims a week.
Yeah, I can imagine.
Wow.
So one thing I've been thinking about as we're talking is all these different inputs, trying to notice what correlations there might be.
You have access to a lot of the different cars and whatnot.
It seems like there's probably a lot of machine learning stuff that you could potentially apply here.
Like what's the story of machine learning in your world?
I think it is the future.
So when I say we have a lot of data, most of our projects, it's not what most people like big data guys would think is big data.
We don't have a lot of places where we can do like deep learning applications because we just don't have enough of the data that fits in this box.
We're trying to get very specific answers.
And even though you have a race with four hours of data, there's a ton of data in there that's completely worthless because the caution came out.
Right.
You can't feed that to a training system when over two different races where one part you did that stint with no yellow flag.
Obviously, higher pressures and temperatures will change.
The amount of fuel used has changed.
All those things are just like they're not comparable, right?
Yeah.
There's a few places that we've used some deep learning.
Okay.
Some photo stuff.
General Motors provides a photographer to the track.
Well, during the pandemic, they don't always.
But they provide a professional photographer to the track to take pictures of all your other cars, all the cars on track.
So you can say, well, here's their attitude on track and here's our attitude and we're doing it wrong because they're faster than us or whatever.
But over a weekend, you have about 7,000 photos taken and to go.
And of course, it comes in with the file name of whatever the camera is set up to produce, which is pretty much meaningless when you want to find all the pictures of the 18 car.
Right.
And so you have to look at skim through all these thumbnails of these mixed cars because everybody's on track at the same time.
So it's not like they're grouped together in any way.
So one good application is to use NeuralNet to, yeah, I guess I should say convolutional NeuralNet to look at these photos and write new file names and organize them into folders and just take the manual drudgery out of that kind of thing.
All right.
Maybe even create a dashboard that says, I want to look at this car and I need to look at it from the side so that I can understand how much it's like tilting forward or whatever, right?
The rake.
So show me that.
Show me that for this car.
You could probably build that with Streamlight.
That's a great idea.
I think I'll build that next week.
There you go.
What's crazy is like, I mean, you're joking.
It theoretically could be a couple of weeks, whereas like 10 years ago, that was like, we're going to need 50 years and a million dollars of research and like a bunch of PhDs.
And now it's like, maybe we'll do that in this little app.
Yeah.
Our cute little app.
Yeah.
So a lot of the performance stuff, we have enough data during the race to use some deep learning.
But I really think the simpler just regression analysis and classification analysis types of things where you're looking at data.
You take all the metrics of output of these different cars and you split it up around the track.
And then you train a fairly simplified model on what do the fast cars have in common?
What do the slow cars have in common?
And let's not be like the slow cars because there is so much data.
It's hard to say what knob does matter.
What knob is the crucial thing?
So that's the direction we're going.
And I'm excited about it.
Building some new skills and being given the opportunity to apply them in so many different aspects of the job is just huge.
Keep it.
Keep me motivated.
Or ditch that unused subscription for our course bundles, which include all the courses and you pay about the same price as a subscription once.
For details, visit training. talkpython.fm/business or just email sales at talkpython.fm.
Yeah, I can imagine.
And racing is one of those things that's pretty interesting because there's a lot of bespoke engineering that happens.
Like one-off custom engineering.
Yeah.
There's a team of people that are building stuff and adjusting stuff.
It's not like, well, these are the three things I can get from the parts store.
I'm going to stick on here.
Like, you guys are like, well, it would be better if it was like this.
Let's go build that and try it.
Right.
Yeah.
And our hands have been tied quite a bit recently with the rules package.
And we can't do a lot of that anymore.
All the parts have to be submitted to NASCAR ahead of time.
And then they judge whether they like it or not.
And if it's too different from anybody else, they won't approve it.
So it turns into a bit of a cat and mouse game where you're trying to sneak stuff around.
And every once in a while, you'll see somebody get caught with something, some unapproved part, and they get a $100,000 fine and their hands slapped.
Yeah.
You know, but that's a real deal.
Yeah, I can imagine.
Every little bit is an edge.
And, you know, you got to push it to the limit.
Yeah, for sure.
But I think a lot of people take for granted how much tech is in NASCAR because they look at the somewhat antiquated cars with a rear suspension from a 1956 Chevrolet pickup, and they can't understand.
But the science behind trying to make a 3,500-pound car with a truck suspension go fast is actually pretty impressive because, I mean, the Formula One car is absolutely designed to be unbelievable race cars.
But we're not allowed to do that.
So you have to use a lot of weird tricks and things to get these things to go fast and handle well.
And so it's a little bit different.
I think from an engineering standpoint, the jobs in the different series is quite a bit different.
I think NASCAR and IndyCar are pretty similar.
You see people going back and forth between those series.
You don't see a lot of Formula One guys.
Yeah, both of those series have the somewhat spec aspect to it, right?
Like a lot of rules about we're kind of going to agree on this part.
IndyCar goes here or IndyCar is the same chassis as all Dallara chassis or something like that, right?
Right.
Yeah.
But I think the jobs are quite a bit different too.
If a race team has 300 employees, they might only have 25 engineers in NASCAR.
In Formula One, if they have 300 employees, my understanding is that almost 300 of them have an engineering degree.
Exactly.
And they're back there building carbon-carbon adapters or for who knows what, right?
Yeah.
And I think that we had a few Formula One people come in and work at Richard Childress a few years ago.
And the parts that they had worked on, they were incredibly talented at that aspect.
But like in NASCAR, because you have fewer people, you can't just be a tire guy, really.
Like as a race engineer, you need to be over the full spectrum of working on every aspect of this car to even hope the thing is going to go fast.
Yeah.
And if you had 30 or 40 people all working on the little details, it'd be better, but our budgets just aren't there.
Right, right.
I don't know what the NASCAR price is.
Maybe you tell me.
To run an IndyCar, I think, is about $15 million per year.
Run a Formula One car.
You know, Ferrari and Mercedes are spending like $300, $400 million a year.
Yeah.
That's a 10X or 20X difference.
That means a really different constraints if you can operate with those two numbers.
Yeah.
There's nobody spending $100 million that I'm aware of running, you know.
You have to keep in mind, too, that the Formula One cars, they're only running two cars.
Yeah.
Right?
And so they have all that resource and they're still only running two cars.
So they're only paying two drivers.
You look at a Hendrick Motorsports or something and they have four drivers that you're paying.
The driver's the most expensive part, for sure.
Besides maybe that adapter that measures the wheel that you don't want to crash.
Yeah.
No, the driver.
Most drivers are still way more expensive than that.
But when they win, it's worth it, right?
Right.
Yeah.
I haven't looked at much of the budget stuff in a long time.
What I'll say is there's a huge gap in what kind of team you're running.
The guys that are out there running 35th to 40th are doing it pretty cheap.
The cars themselves aren't ridiculously expensive because it's old tech and there's, you know,
we can't do carbon bodies.
I mean, we have some carbon parts, but teams don't have autoclays where they're making a
monocoque, right?
But I think that going on the budget, I think the last number I heard, it was about $150,000
a week, you know, an event.
So if you do, as good as I am at math and science, I'm terrible at basic math.
So whatever 150,000 times 38 is, is a pretty decent number.
Yeah.
5.7 million.
Yeah.
Nice.
Yeah.
So there's a big difference there.
Yeah.
For sure.
You know, but there's a lot of benefits to keeping your costs down too.
Yeah.
Oh yeah.
Because when you're looking at the sponsorship and you're trying to make the sponsor dollar
go as far as possible, you know, being much cheaper is better.
Yeah.
Well, and it means that the sport could be more vibrant, right?
Like if one team drops out, another can come in.
It's not like they have to come up with half a billion dollars.
Right.
Or something insane, right?
And an engineering factory and all that kind of stuff.
So yeah, it's definitely an interesting angle.
So let's maybe just wrap up our show on this, which has been really, really fun.
Just to maybe get your thoughts on this idea of open source and Python, both for ramping
up the capabilities, but also opening up the possibilities, right?
You don't have to buy expensive licenses to custom modeling software and whatnot.
How do you see that affecting the advantage of your team or the industry in general?
Yeah.
I think it's going to be the way of the future.
I mean, I don't see why you would buy a MATLAB license now.
Yeah.
Definitely, if you're having young engineers coming in that haven't ever used MATLAB and
to have that be your standard, I feel like the learning curve of MATLAB is just much more
difficult.
Getting it all right, getting things to work, especially the file input, output aspects that
I always struggle.
I had a ton of experience with MATLAB and I still struggled with, oh, I've got an XML I've
got to get.
Okay, well, how do I even do that?
And, you know, or JSON or something.
And with pandas, you just, it's one line and it interprets what you, what it thinks you
mean it to be.
And it, I think it's going to be the wave of the future.
And for race teams, free is always better.
Cheap is not always good, but free is better.
Right.
And the other angle is you can bring in people who are not potentially trained, you know,
brought up through the engineering side or the math and MATLAB side of things, right?
You could find somebody who was working at a startup, but is passionate about this and they're
really good at Python and data science.
They could maybe make that transition over potentially.
Yeah, absolutely.
I mean, that's what I was saying before, the science of what you do, it doesn't matter if
you're, if you're working at Caterpillar or a race team or, you know, a toilet paper factory,
the way that you're studying the data, all the data science stuff, it applies to every field in the,
in the universe.
So that's absolutely true that you could bring in some excellent programmers.
The one thing I will say, and we have some excellent programmers that are the ones who
actually do our simulation department and everything.
And, but they don't necessarily come from a racing background.
And the one thing I'll say, like I said, I was passionate about UX.
The biggest thing we fight with them is trying to get them to do it the way we want.
Right.
Not the easiest way to code.
Yeah.
Because I need flexible tools.
I need a lot of buttons and things to be able to manipulate this the way I want.
And it's like one of our programmers, he was doing a job for me and he delivered it to me.
And I'm like, what is this?
This is nothing like what we discussed.
Like, where is this part of it?
And where is this part?
How did you not include this?
And he's a Spanish guy.
I won't try to mimic his accent.
He's an ex-Formula 1 guy too.
Brilliant programmer.
But he explained it to me.
He said, well, when we talked about the project, you explained a lot of things and I didn't see why they were needed.
Here's what you need to understand.
If you hand me a banana and tell me to eat it and don't tell me to peel it, I will eat it unpeeled.
But no, he's a great guy.
And we're doing a lot of good work right now.
He's building a data store to be a server-based data store for all these dashboards to be able to work flawlessly across.
We're all over the country, right?
So you need to have a good data system and you need to keep that data synced.
So if somebody does an analysis and posts it up, it needs to change on everybody's computer.
Right.
But the synchronization part is tough problems still with if you have a database and there's 18 people across the company editing the same setup, like how do you merge all that stuff?
And so that has been the bane of my existence for a long time.
Yeah, I'm sure to keep all that data in sync and you're going to run a report and expect an answer out of it.
You want to run it against the same data because otherwise you want to run it on sale data and all that kind of stuff, right?
Oh, yeah.
Yeah, absolutely.
Well, thank you so much for sharing your story about how you're using Python and over at the race team.
That's just fantastic.
Now, before we get out of here, though, I've got to ask you the final two questions.
Oh, yeah.
If you're going to write some Python code, what editor do you use?
If it's an analysis project, I almost always start with Jupyter Notebook.
Okay.
Jupyter or Jupyter Lab.
Which one are you on right now?
Jupyter.
Okay.
And that lets me do my old MATLAB, like searching around where I can print out the data.
And just it's a visual thing for me to understand how the flow of this analysis needs to go.
And then generally what I'll do is once I get done, I'll merge that all into one cell and put it in VS Code for when it's ready to actually be used on a regular basis.
That way I don't have to go through and click all the cells and, well, this thing was out of order and this thing was, you know.
Yeah.
The Jupyter is a gift and also a curse.
Yeah.
It's a little bit like Excel in that regard that it has like these implicit go-tos, not because the control flow, but because you could go back three cells, run that thing and then jump down five cells and run the next one.
And it looks like in order, like they happened in order, but no, you've got to read that little execution number.
Then there's missing numbers that you don't really know what they maybe did, but there's no more evidence of them.
It's very tricky in that regard.
So I think productizing straight Python files makes a lot of sense.
Yeah.
So that's my typical workflow.
Yeah.
That sounds good.
And then notable PyPI package.
I know everybody's heard about Black, but for anybody who uses Jupyter, there's another package called Black Cell Magic that lets you apply Black's formatting inside a Jupyter notebook.
And so.
Oh my goodness.
So that keeps even like my workbook, things that never make it to production, at least formatted right and looking nice.
And then I can't say enough about OpenPixel, which is an Excel, a Python Excel interface.
It provides all the functionality of cell colors and borders.
You could program it all just by typing it out instead of clicking through 8,000 Excel pop-up windows and things.
That's cool.
And this gives you, this is like your bridge to all the people who have legacy Excel stuff laying around or they want to work in Excel and they're like Excel.
And they're like, here you go.
You're like, ah, I'm not doing VBA.
Hold on.
Yeah.
No.
And when a crew chief can only use Excel, you have to pass them an Excel sheet at the end of the day.
Yeah.
So that has been a blessing.
And then the one thing I found out today when I went and downloaded, when I was going through the documentation on Streamlit is they have a new Streamlit for Teams coming out.
I don't know if you've seen that.
Yeah.
That's going to have one click server deployment for your app.
So you can work.
That's going to be sweet.
Work together and everything.
So definitely check that out if you haven't.
All right.
Awesome.
Very good recommendations.
Okay.
Final call to action.
People are excited about this stuff.
Maybe making Python a bigger part of their engineering story.
What do you say?
I like it.
They got to do it.
It's a friendly environment.
Great places to learn all over the internet.
Also mostly free.
And I guess the other thing I'd like to say is just shout out to all my teammates in case anybody listens to this.
They probably hear me talk about Python enough, but we won.
We finished first and second in the race on Sunday.
So shout out to Austin Dillon for.
What event was that?
It was Texas.
Texas Motor Speedway.
Yeah.
Cool.
All right.
Congratulations.
And I guess it's cool to know a little bit of Python was behind the scenes there, huh?
Oh, yeah.
Yeah.
Winning races.
Right on.
And I will mention that there's another race tomorrow night, Thursday, on the NBC Streaming Network.
Cool.
In Kansas.
So definitely check that out.
Right on.
Awesome.
Well, Kane, thanks again for being on the show.
It was really good to hear your story.
And it's inspiring what you're doing.
Yeah.
Thanks so much for having me.
I really enjoyed it and love the show.
Yeah.
See you later.
All right.
Bye.
This has been another episode of Talk Python to Me.
Our guest on this episode was Robert Kane Replical.
And it's been brought to you by SonarCube and Linode.
SonarCube finds bugs, vulnerabilities, code smells, and security hotspots in your code.
Try it out today.
It's free to use.
Just visit talkpython.fm/sonar and click download to get started.
That's S-O-N-A-R.
Or just click the link in your podcast player.
Start your next Python project on Linode's state-of-the-art cloud service.
Just visit talkpython.fm/Linode.
L-I-N-O-D-E.
You'll automatically get a $20 credit when you create a new account.
Want to level up your Python?
If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
Or if you're looking for something more advanced, check out our new async course that digs into
all the different types of async programming you can do in Python.
And of course, if you're interested in more than one of these, be sure to check out our
everything bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
Thank you.