Monitor performance issues & errors in your code

#76: Renewable Python Transcript

Recorded on Monday, Sep 12, 2016.

00:00 Talk Python To Me

00:00 Episode #76: Renewable Python

00:00 Even with solar panels on your roof, it’s possible that your home is still being powered by fossil fuels. Climate innovator and Python developer Anna Schneider is trying to change that. At her company WattTime, consumers can source the cleanest energy available on the grid.

00:00 In this episode of Talk Python To Me, I talk to Anna about how Python powers WattTime, some popular open-source projects focused on renewable energy, and a few other Python based renewable energy startups.

00:00 This is Talk Python To Me, episode 76, recorded Monday, September 12th, 2016.

00:00 [music intro]

00:00 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 am at @mkennedy, keep up with the show and listen to past episodes at talkpython.fm and follow the show on Twitter via @talkpython.

00:00 This episode is brought to you by Hired and Snap CI, thank them for supporting the show on Twitter via @hired_hq and @snap_ci.

01:26 Michael: Anna, welcome to the show.

01:28 Anna: Hi Michael, thanks for having me.

01:30 Michael: I'm really excited to have you on the show today, and to talk about what you've been up to in Python and fighting climate change, and working on renewable energy and all that good stuff, it's going to be great.

01:40 Anna: Yeah I'm excited.

01:42 Michael: Yeah, it's very exciting. But, before we get to that story, let's just start at the beginning- how did you get into programming in the first place?

01:48 Anna: Yeah, so I was a scientist for a long time, that's how I thought of myself; but I used code to do science, so an undergrad, I was working on protein folding and protein structure research. That was my very first exposure to programming, I was doing some really simple bash stuff just to access the data that we were working with, and that progressed from there during grad school.

02:10 Michael: Was that like the folding at home types of data or was that other data?

02:14 Anna: It was data that I collected from this method called AnaMar for figuring out what protein look like.

02:21 Michael: Sure, okay, cool. So, you started programming that way, which I think a lot of people get into programming if they don't just go straight down the computer science track, they get into programming because they needed it to try to do what they were actually doing. And, a lot of times I think people are like, "wait, this is actually really more fun than the actual problem I've tried to solve".

02:44 Anna: Exactly, that was how it worked for me too. I had thought about when I was deciding what to do during grad school and I did my PhD in biophysics, so I was like do I want to work in a laser labs, do I want to work in a protein structure lab, or do I want to study those problems by use code to do it, instead of fancy equipment. And, I ended up realizing that I'm just a lot more creative when I'm writing code then when I'm working with physical objects in the real world, and so that ended up being how I did my PhD.

03:12 Michael: Cool, it makes sense to me. And so, how did you get into Python then?

03:16 Anna: That was during my PhD when I started using Python. So I had been writing these big C++ simulations for how the molecules inside plants do photosynthesis, how they move around. But then I needed something to analyze that data, and Python way nicer for that, so I read a bunch of really crappy C++ code, and then started writing some actually kind of okay Python.

03:37 Michael: That's excellent. So you were studying how plants basically did photosynthesis and things like that?

03:44 Anna: Yeah, so the part of a plant that acts like a solar panel, I was studying the molecules inside that, and how they move around to make plants more or less efficient.

03:52 Michael: Interesting, so how did you go from studying nature photosynthesis to what we're trying to do with solar energy?

03:59 Anna: Yeah, so I got into that project because I knew that I wanted to work on energy software and energy data long-term. At the end of undergrad, all my friends were either like pre-med or going to google or something like that, and neither of those passed out right to me, so I was like what do I care about as much as my friends care about medicine? And energy and sustainability ended up being the answer for me. So I deferred going to grad school and took a year to work at a tiny energy efficiency nonprofit, and then at a place that does climate modeling for renewable energy projects. And so I've sort of been on this trajectory for a long time.

04:38 Michael: Yeah, yeah that's really cool. So did you do programming at those places or what kind of work did you do, like a climate nonprofit?

04:45 Anna: I did the climate modeling for renewable energy place, I was doing programming and data analysis there. And so I worked with a bunch of atmospheric science PhDs, and they would run big climate models when the wind developer would come to us and say like I own this hell, where should I put the turbines, and so we would figure out what the typical wind patterns are in that place, and what's the most efficient way to build new turbines. So I learned Ruby there.

05:09 Michael: Ok, interesting, like optimization problem more or less huh?

05:12 Anna: Yeah, yeah.

05:14 Michael: It's cool, I think a lot of us care about climate change, and we think as programmers and technologists, there must be something we can do. I think certainly as programmers, we are in a better place to help in some way, than a lot of the general public, we could actually write some of the technology that makes these things go, but at the same time it also feels very much like this kind of stuff is the realm of giant companies that have deep-seated interests that are not necessarily good for the world, but are good for them.

05:14 Yeah, and so you shared an article with me that's pretty interesting titled "What can a technologist do about climate change, a personal view", and that's at worrydream.com / climate change?

05:59 Anna: Yeah, so this was something put together by a guy called Bret Victor, and the idea is just exactly where he is going through and saying there's so many places within our global energy system where people who write code for living can make a real contribution. So some of it is- he breaks it down by like funding and how energy is produced, how it is consumed, just the general tooling, and a simulation software. A lot of this is very research heavy and so there's some really cool simulation methods that you can use.

06:33 Michael: Ok, nice. Would you say in the end it comes out more on the dream side or more on the worry side?

06:40 Anna: [laugh] I think it's a very optimistic piece, that there's a lot of opportunities for people to get involved right now, and one reason that's the case is that around 2012 there was a sort of flip in economics of renewable energy where wind and solar started being cheaper than coal or natural gas in a lot of parts of the country, and increasingly in lot of parts of the world too; and so it's actually better business to work on renewables right now, and so funnily enough, there's a whole lot more companies working on it now that it's actually a really profitable business.

07:15 Michael: Yeah, surprise, once it's purely a good choice just from a business side then all of the sudden- yeah absolutely.

07:22 Anna: So that's part of why renewables is such an exciting place to be right now; it's not a choice between like, "oh fantasy" and like "oh feeling guilty about it". It's actually good business and good for the world and good for your technology career to move into this field.

07:39 Michael: Yeah, I suspect the next 10 to 15 years are really going to transform a lot of the ways we think about energy and electricity, and all sorts of second-level effects of that as that really kicks into effect. So when you think about like what can you do with the technologies, some people can buy carbon offsets I have, in Portland our electric company has this thing called Green source where you can pay extra for your bill, it will basically guarantee a 100% of your energy comes from renewable energy, that probably offset somebody who wouldn't pay that, and so maybe it's not that great of a deal, so we can make these little changes, or you could do something like you've done like start a whole company, tell us about your company?

08:25 Anna: Yeah, so I am the co-founder and CTO of a cleantech nonprofit called WattTime, it's Watt like energy and Time like times, there's three Ts in that. And so, what we do is we figure out when energy is clean or dirty coming from the grid in real time, so if you think about flipping a light switch, is that turning on a coal plant right now, or windmill, or solar, or natural gas or something else, and that answer actually changes every five minutes as different power plants come on and off the grid; so we figure out that data in real-time and then we use it to control smart devices, so things like smart thermostats, or electric vehicles, or whole building automation systems and so they can turn on when electricity is a little bit cleaner, and off when it's a little bit dirtier, and save carbon from the grid overall.

09:11 Michael: Yeah that's really a great idea. So imagine I have some kind of thermostat and air conditioner at my house, and I want to say I would much prefer to cool my house with renewable energy and that thermostat could subscribe to your service and decide if I were to turn on now what kind of source with this energy come from basically?

09:34 Anna: Exactly.

09:34 Michael: Okay.

09:35 Anna: Yeah, and so our algorithms try to do it so your house will stay more or less the same temperature all the time, but it's like if the air conditioner needs the fire for like 10 minutes out of the hour to keep your house the temperature you want it, it would choose the cleanest 10 minutes.

09:51 Michael: Yeah, that's excellent. And what's the uptake like, are there a lot of companies reaching out to you to work on this, how's it going?

10:00 Anna: We have some pretty good partners in the pipeline right now, it's pretty exciting. Part of the trick is that a lot of smart device companies like IOT Internet of Things is big business, it's really exciting, but it's not very standardized yet. And so a lot of what we're also coming up against it's just the fact like well do we have to write a separate integration for every company and as a non-profit, it takes a lot of funding to get to the point where you have the manpower for that.

10:28 Michael: I bet it does. There's not that many residential places that have that kind of connectivity right, like I have some crummy little twisty thermostat on my wall and I know it doesn't care about any of those sorts of things and it had no capability but, so you're focusing more on large-scale stuff, maybe like electric vehicle charging stations that are super intensive or Hospital air conditioner, things like that?

10:56 Anna: Exactly, although home thermostats is a really good market too, there's a 40 percent of US power demand comes from homes, and a lot of that is from heating and cooling.

11:07 Michael: Sure, absolutely. So could I go buy a thermostat that would integrate with you guys and plug into my house?

11:12 Anna: Yes, you can go to our website and we have a waiting list right now to sign up for our very first smart thermostat from my partner Energate.

11:20 Michael: How exciting. Awesome. So tell us about your company, where to get started?

11:25 Anna: I met my co-founder when we were doing our PhD's at UC Berkeley. So like I said, I was doing biophysics, but I knew I wanted to do energy stuff, and he was doing energy economics and behavioral economics. And so he actually came up with the algorithms that are the foundation of WattTime, to sort of adds an extension of his PhD, and so we just met at a Hackathon just a regular weekend thing, it was like hey you want to work on this thing, this sounds awesome, cool let's do it. And then he's such an amazing like a volunteer organizer that he kept me around for the next few weeks and months and then years.

12:01 Michael: And then for ongoing, very cool. What kind of a Hackathon was it, what was the theme, where was it hosted, things like that?

12:08 Anna: It was called the Berkeley Clean Web Hackathon, so there is a clean web initiative, an international network that hosts energy-focused hackathons.

12:18 Michael: Ok, so it was specifically energy-focused to start with, I see. Very nice. Now, you said it's actually pretty hard to predict whether this energy is going to be clean or not, and there's a lot of data science problems going on there, right?

12:36 Anna: Yeah, yeah, so part of the fundamental challenge with getting to a hundred percent renewables on the grid is that wind and solar are completely dependent on the weather when they're actually produced, and so better prediction of that and better just use of that stochastic information is really interesting for data science.

12:56 Michael: Yeah, one of the things that maybe not everyone knows is the older energy sources like coal which is especially bad, are very hard to change their capacity right? So the wind my blowhard for 10 minutes and then stop, and that will generate way more energy but you can't just necessarily pour that energy into the grid, right?

13:16 Anna: That's another reason why this is such a hard problem, is exactly what you said, that phenomenon is called curtailment, so the idea that if there is way too much wind being produced right now, maybe the utility would prefer to use that, instead of coal, but it's so expensive to shut down a coal plant for just a few minutes, and so they'll actually call the wind farm and be like, dudes you have to turn off your clean free renewable energy, that has to get wasted right now.

13:42 Michael: Yeah, what I think it's really especially unfortunate about that is that happens at the time when the most energy is being created right?

13:50 Anna: Yeah, it gets punished for doing too well, whereas coal gets rewarded for not doing as well.

13:57 Michael: Wonderful, so you said you actually have-

14:02 Anna: [laugh] Optimistic, really.

14:04 Michael: Well, you know, maybe it's a sign of something like coal, it just doesn't really fit so well into the modern world, where we have so many better answers, right, so in the long-term maybe it's another negative for coal, but still, in the short term it's a problem that is a challenge for you, because you can't just say oh it's windy so it must be good, right, that could have actually been the worst case scenario.

14:04 And you have two kinds of challenges that you're solving with Python, one is right now, what is the energy story for my air conditioner right? If I turn on my air conditioner it comes on immediately, and it does its air conditioning and then it turns back off shortly, but if I had an electric car and I had it plugged in and I just said look I would like to drive to work at seven in the morning, it's 10pm, you get my car charged as you know, efficiently with renewable energy as possible- that's a different kind of problem, it's like a forecasting problem, right?

14:59 Anna: Yeah, so for both of those kinds of problems, how our model works right now is that we get open data about what's going on on the power grid, so there's entities called balancing authorities that make sure that supply and demand are matched in real time, for what's on the power grid, and they actually put a fair bit of open data online which is the foundation of what we're able to do. So we pull in that open data both for what's happening in real time and what they think is going to happen for the next few hours. So, it's interesting their forecasts have some systematic bias which we're working to correct also, but as a start, it's the forecast that the actual power grids are running on themselves, so it's a good starting point for our algorithms.

15:41 Michael: Yeah, sure it's nice that that you have to start with you don't have to completely come up with the forecasting.

15:47 Anna: Exactly, but the open data that we're based on isn't exactly the kind of data that we want to be using, it tells us like overall what's happening on the grid, but it doesn't tell us exactly what your personal effect would be, so if you think about, like if you use a little bit more power right now, what power plant are you affecting most, that's where our sort of special sauce comes in.

16:10 Michael: Yeah, sure. Now you can't talk about your special sauce, but we could talk a little bit about the architecture; so what technology did you use to build your API that these devices integrate with?

16:22 Anna: We are Python top to bottom, and so it's a Django rest framework API that is pulling the data from Postgres database and then serving that so it looks sort of like a weather API just at time series data.

16:36 Michael: Yeah, it's got to be a lot of time series just- all this data of Internet of Things you're collecting and serving. You also use Panda for data analysis, right?

16:48 Anna: Yeah, so on the back ends in order to collect all the open data about what's going on and then analyze it Pandas is really good for that, and then we use Celery for all the periodic task management of scraping the data from the sources, and then sending those on-off control signals to all the smart devices that were working with.

17:08 Michael: You actually outlined this in a talk you gave at Django con this year called Django For IOT From Hackathon To Production, and that was a cool talk, really nicely done.

17:18 Anna: Thank you. It was such a treat to be able to speak at Django con.

17:23 Michael: I'm sure, that's cool. So one of the things you talked about were design patterns and antipatterns for building Internet of Things services.

17:33 Anna: Yeah, so the part of the basic premise of the talk was that you can- normally when we think of a Django like starter project that might be a blog or polls app, or something, but I think that an IOT project can be you just as good a starter project for people to get started on with Django and the Python. So one of the patterns there is that it really is all about time series data, some of your data management you have to take a little bit more carefully about your indices and things like that because your data gets so huge so quickly when you're dealing with Internet of Things data.

18:09 Michael: Yeah, if you have a thousand users they have internet of things data putting time series and that can be millions of records instead of thousands, very interesting.

18:18 Anna: Exactly. Yeah, so even just at a Hackathon scale if you are just doing your weekend project you can still have a lot more data than you know what to do with, which is pretty fun.

18:26 Michael: Sure. So one of the things I thought was interesting you talked about, was you said normal Django apps are built around views and maybe a better way to think about it for APIs that work with Internet of Things devices is to think about tasks instead of views necessarily; because everything is more or less asynchronous, right?

18:46 Anna: Yeah, so that's the other big design pattern with IOT, is that if you think about this is specifically for the use case where say you bought some smart device and the company that made that thing has a server, and they have an API and all you can do is send get or post requests to that API. They won't send you anything unless you ask for it. And so it has to be all about the machine-to-machine communication, and you have to do the work of initiating everything. And so you can't wait for their server to send you a request you have to be able to initiate those. And so that's a big part of what we use Celery for, in those periodic tasks. And so that means the code that really matters can't be living inside your views and it has to be in a similar kind of structure, but for machine-to-machine communication.

19:39 Michael: You can't really just make a call to some server that's going to go out to a thermostat and wait for the thermostat to respond, right, your system would just lock up, so a lot of it is begin sending this message asynchronously, throw it onto a queue of some sort, and then say the message was sent and just wait for some kind of response later, right?

19:59 Anna: Exactly, yes so there's the whole other part of the architecture where the devices have to communicate with their maker server and then their server has to communicate with yours and everything sort setup in its own very special way. Every device that you play with is going to have a slightly different setup.

20:18 Michael: Yeah, they may be responsive, they may be high latency, they may be flaky right, you never know with these cheap little devices, interesting. The other thing you talked about was that you maybe don't build just one application but you might have a family of applications around some kind of project, so you might have one that talks to devices, one that receives observations, one for like a vendor portal, things like that, right? It might be a suite of web apps, if you will.

20:48 Anna: Yeah, so every kind of application that you're doing, since there are so many users at an app like this, there is the human in their home doing whatever, there is the company that you're working with, there is the physical devices, and each of these needs its own kind of user interface, so it's kind of fun thinking of thermostat as the user of your application. And what is the user experience for the thermostat.

21:15 Michael: Yeah, that is a funky visualization to think of the thermostats as your user but yeah.

21:19 Anna: That's the UX problem I spent a lot of my time solving.

21:23 Michael: The thermostats are much happier if we implemented this... [laugh]

21:27 Anna: [laugh] It's kind of true.

21:29 Michael: Funny. The other thing you said is one of the challenges you can run into is you might have a- if you're trying to spin up a quick prototype like at a Hackathon for your example, or just some quick proof-of-concept you might have one way of implementing things, especially like the background tasks and stuff, and then if you're doing in production it probably needs a lot more careful attention.

21:53 Anna: I'm a big fan of Heroku, and especially for Hackathons and so Heroku has one really nice feature called the Heroku scheduler, and that allows you to for free run periodic tasks every ten minutes or every hour or one today, so that can be a really good first pass option, and if you want to do something really quick and easy at Hackathon where like you've written the code to say okay I want to hit the thermostat API every 10 minutes that's a free way to do it, where you don't get all the pain and serve extra structure of setting up Celery; but as soon as you need more reliability or more flexibility in terms of when you're running the tasks, then Celery is definitely the right option there.

21:53 So if people aren't familiar with Celery, this is a distributed message queue framework for Python, so it's great for either running asynchronous tasks so something like if someone signs up for your service and you want to send them user sign up email, you can send the email in the background while you return a few to them, to them but you can also use it for scheduling periodic tasks, so something like every five or ten minutes.

23:03 Michael: Sure, yeah I think it's thought of more often for long running things, I'm going to do some kind of report and it's going to take too long for the request, so we'll initiate it as a task and then poll for the response or something like this. But the scheduling aspect of it is cool too.

23:21 Anna: Yeah, so it's like if you would normally do something with crone on your laptop, this is the way that you can use a similar kind of way of thinking about things. But in a distributed environment where you're actually running your apps.

23:21 [music]

23:21 This portion of Talk Python To Me is brought to you by Hired. Hired is the platform for top

23:21 Python developer jobs. Create your profile and instantly get access to 3500 companies who will work to compete with you.

23:21 Take it from one of Hired users who recently got a job and said, "I had my first offer on Thursday, after going live on Monday and I ended up getting eight offers in total. I've worked with recruiters in the past but they've always been pretty hit and miss, I've tried LinkedIn but I found Hired to be the best. I really like knowing the salary upfront, privacy was also a huge seller for me."

23:21 Sounds awesome, doesn't it? Wait until you hear about the signing bonus- everyone who accepts a job from Hired gets a $1000 signing bonus, and as Talk Python listeners it gets way sweeter. Use the link hired.com/talkpythontome and hired will double the signing bonus to $2000. Opportunity is knocking, visit hired.com/talkpythontome and answer the door.

23:21 [music]

24:45 Michael: So, one of the things that you talked about a lot is IOT and your, service your company is more focused around providing data for other people's things on the internet, but you said you end up building some- every now and then as proof of concept yourself because someone's got to show that this works before someone also will buy into it, right?

25:07 Anna: Exactly, yeah so starting as just one step above a student project, when we were just getting started; one of our first partnerships was university of California at Merced, it has all of these electric golf carts that the maintenance people used to drive around; this is like the simplest thing that's approximation of an electric vehicle charging system we could use; and so we got these smart plugs so it's like something you plug into the wall and then you can plug anything else into that, and then we had all of the electric golf carts plug into those, and then we would manage the charging from there. There's a brand called Think Eco that has an API that you can use to control these smart plugs. So we got those and we're able to write an app that does like the full end to end integrations or everything from figuring out the best times to be charging, forecasting that for the next few hours and then sending signals all the way down to the charging system to say like ok, turn on now, ok turn off now.

26:10 Michael: How interesting. So, talk to me about the architecture a little bit, like did you have like a Linux server on the same network as the smart plugs and something like this, and they just kind of watch that or how did you put it together?

26:23 Anna: Yeah, so for that part of the communication and there's a couple of different models so the one that we used for that project, there was a hub, so sort of like a local gateway so there is a protocol called Zigbee, that's pretty common for Internet of Things communication between the device and some central hub, and then you plug the hub into ethernet, and that's able to talk back out to real server.

26:48 Michael: Ok, yeah so the smart plugs could get out and check on what they're supposed to do.

26:53 Anna: Exactly.

26:53 Michael: Ok, very cool. How much do one of those little plugs cost, if like listeners are like I'm going to build one of those, is it a cheap thing that you can put in your house or is it kind of pricey?

27:03 Anna: Different brands are anywhere between like 30 bucks and a 100 bucks.

27:06 Michael: Okay.

27:07 Anna: There's a range of prices and there is some pretty cool things you can do with them, so one called Belkin Wemo is on if this then that, so that's something where you barely have to write any code at all to start hacking your route with it.

27:22 Michael: That is pretty cool that it's built on that, interesting. So you guys are writing a lot of Python code around renewable energy and whatnot; you've got some open source projects at github.com / watttime and your most, I guess generally applicable one, you have your API code there and stuff like that, but one of them that's kind of general purpose is the thing called PyIso, do you want to tell us about that?

27:54 Anna: PyIso is a set of Python client libraries that we use for scraping data from different online sources about what's happening at the power grid. So one thing that we think is really cool and that other people like playing with too, is what is the mix of generation sources that's on the grid at any given time, so maybe in California we have some number of megawatts of natural wind, some number of coal, some number of solars, some number of winds, and that's going to be different in five minutes, and it's going to be different in the mid west, and it's going to be different in New York. And so PyIso is a set of libraries that anyone can use to start scraping some of that data and playing around with it yourselves, so that you can understand where your power comes from.

28:42 Michael: So, if you wanted to build a business like yours this is some of the foundational data that you might need?

28:48 Anna: Exactly, and it's been really fun to get open-source requests from people at solar companies or people doing research on these systems, so there's a lot of users out there and very open to contributors.

29:01 Michael: Yeah, excellent, so if you want to help check it out. I'll be sure to link to it in the show notes.

29:07 Anna: Cool, one specific thing that would be really cool to get help with is we have coverage for a lot of the United States right now, but there's also a similar open data available in Canada and in Europe and Australia, and other parts of the world, so if you're listening to the show and you're like oh everything she's talking about is in the US, like there's opportunities in the rest of the world chip in to.

29:28 Michael: Ok, so you're taking this from some kind of governmental source in the US or regulatory place that gets this data, what are the data sources of this library?

29:39 Anna: So that's the annoying part, that's why they need the whole library for it, is that I mentioned the balancing authorities a few minutes ago, so that's where we get the data from, but each balancing authority publishes data in a totally different format, so some are like zip CSVs, some are xml, some is Json API, so that's a big part of the point of PyIso is to hide all that ugly stuff in the background and make it easy for you to just write one little Python line and have everything else get taken care of, so that's a lot of pandas and beautiful soup in the background of that. And requests.

30:16 Michael: Oh yeah, that's a good combination. Pandas, Beautiful Soup and Request. Yeah, so I've heard of a lot of variation in APIs, you know maybe this is an HTP Json service maybe that's a Soap web service but I've never heard of it being so broad as we've got zipped csv, with like some probably the beautiful soup is for like some kind of web scraping, not some other service? And then you've got like an actual API right?

30:49 Anna: Yeah, so different balancing authorities in different parts of the US have just put their data online in different formats, so there hasn't been any real reason for them to standardize it, and a lot of them don't employ nice fancy Python developers to write a good service, so it's just people have been able to throw together.

31:10 Michael: I think that one of the challenges of getting renewable energy really working has to do with having a better power grid, that is obviously like an important physics problem, but I think maybe it sounds like there's even more fundamental things like if there's not some kind of standard API for even discussing what kind of energy is being used and so on, if it's down to a zip csv that's probably not a system that in its mind is about real-time.

31:43 Anna: No. I completely agree and that's something that there's a lot of rhetoric in the community that are like, "we're moving towards real-time and everything is going to be real-time and the future is going to be amazing". But we're still pretty early in the process of building the future, so it's lot of opportunities.

32:01 Michael: Sure but it's cool at least that you have a library that means people don't have to live in that past they can work in the future and if that bouncing authority comes up and said, "alright we actually have a real API now", they won't have to change their code right you guys just fix that open source library to use the new format and it's good to go.

32:19 Anna: That's the idea, yeah, and so keeping it up-to-date has been another fun challenge at every daylight savings time transition I have to wake up early on a Sunday and fix whatever bugs came up because there's also no standardized way of handling the daylight savings time of these datasets.

32:36 Michael: So, you said that there were actually quite a number of other open source projects and startups that were either open source projects focused on renewable energy or maybe they're even written in Python as well as a number of renewable energy startups using Django and other Python web frameworks?

32:56 Anna: Yeah, I sort of like to break down the fields of what's happening in renewables, into a few different categories, so sort of that the lowest of all is to just build the renewals, it doesn't matter what we build we just want as much as possible. The next layer is to build the right renewables that produce energy at the right times- so like we were talking about before if there is like too much winds, when there's also too much other kinds of energy being produced it can't be useful, so getting that next level of optimization matters. And then sort of their highest level is ok we have the constraint of what energy has been produced, how can we use it in the best way.

33:32 Michael: Right, that's kind of where you live a little bit.

33:33 Anna: Exactly, but there is really cool work happening at all three of those levels.

33:38 Michael: And there's also efficiency right, just like do build more efficient buildings and use less energy right, use less?

33:45 Anna: Yeah, so efficiency is sort of like step 0. It's not as fun to talk about but it matter is at least as much as anything else, so turn off your lights-

33:56 Michael: Yeah, I talk to my kids all the time, I'll go into their bathroom, my daughters' and we have like this I don't know this lighting thing for their mirror that's like six lights and they're all on whether they're at school, I'm like kids do you know how many lights you just left on when you left, so yeah that definitely makes it, and there's actually an open source project for that, that you pointed out right, called energy plus?

34:17 Anna: Yeah, so energy plus is a simulation program that's used by architects and engineers for building new energy-efficient buildings, so doing some of that design work so there's a lot of cool simulation work that's a part of that for like thermo modeling and energy flow and how like sunlight is hitting a building to make sure that part's efficient. That project is mostly in C++ and Fortran actually, I'm not sure if there's Python bindings for it, but that's a very active open source project maintained by the National Renewable Energy Lab in Colorado.

34:52 Michael: Sure, so let's talk about some of the build more ones, some of the Python startups are in that area right?

35:00 Anna: Yeah, yeah that's an area where there's a lot of startups right now, and because the biggest challenge for building more renewables right now, and especially in solar, is not the cost of the equipment itself which is amazing that that's so cheap now, but so the bigger part of the cost that people are trying to work on is sort of the soft costs, so things like marketing and we customer acquisition and making it easy to design systems quickly and get them installed quickly. So there's a whole bunch of Python startups that are working in the sector.

35:35 Michael: Sure so, one of them is utility API, another one is sighten, folsom labs, and energysage? So what are those guys doing with Python, what's their business model each one of them?

35:48 Anna: Yes, so utility API is one of our friends in Oakland there's a lot of this in California and, they do is they do sort of the flip side of what PyIso does that for utility built data, so they say like utility build 36:04 [indiscernible] like it'll be a PDF or some sort of like horrible unscrapable format and so they've written scrapers for all bunch of different utilities that either individuals can use but really other solar companies can use to say okay this is what someone's power bill has looked like in the past, maybe they're going to be a good solar customer maybe they're not going to be a good solar customer. And so simply opening up that data access is a really foundational part of the pipeline.

36:30 Michael: Right, because our API is zipped csv file, the data, right so-

36:39 Anna: Pdfs in this case [laugh] so they have a pretty hard problem.

36:45 Michael: Yes they do, wow, so if like for example if I want to add solar energy to my house or some kind of renewable energy, and I went to some solar energy company and I said, hey what could you guys do for me- they have this huge problem of like well go and download the last year of your data and zip it up and send it to us or something crazy like that and this utility API basically reverses that and it and makes it possible to go have a look at what my actual data is in an API form?

37:16 Anna: Exactly, yeah, so they've been growing really quickly.

37:21 Michael: Nice are they using Django as well?

37:22 Anna: Yes, so they have Django and they're more Python the back, lots of regular expressions and very scraping packages.

37:29 Michael: Yeah I can imagine, cool and then sighten.IO?

37:32 Anna: Sighten and Folsom labs are two of the Python base energy startups that focus on designing at the systems for actually getting the solar panels on roofs. So, another challenge that solar developers want to be solving quickly is what's the angle of your rooftop what is the right number of panels to put on your roof, and what's the best way to hook all the modules up together. Sighten and Folsom labs but with handle different parts of that problem.

38:07 Michael: Yeah, because otherwise you're using something like autocad and you are just starting entirely from scratch and there's nothing about solar energy or any of these types of things right, so this is a much quicker like a rad design tool for your physical deployment of solar? Interesting.

38:23 Anna: Exactly, yeah, and so those are kind of fun because there is both the physics modeling to make sure that the electrons are flowing in all the right places, and also some of the financial modeling to see like is this going to produce the right cash flow both for the customer and for the company who is actually installing the panels.

38:41 Michael: Sure. And then energy sage is about getting quotes, it's like Expedia for renewable energy, right?

38:49 Anna: Yeah, so there is several of these different services where you can go and say like there's so many tiny solar companies in different parts of the country and just small pop shops; and so it can be really hard as like if you're just a regular person and you want to put solar on the roof you don't know who to call, and so Energy Sage is one of the startups that is trying to make it easy for companies to find you but for you to find companies. So there's people going both ways.

38:49 [music]

38:49 We all want to ship our software faster, respond to user request quicker and build an edge on the competition. But the faster you go, the more likely a bug or issue will slip by and cause your users' grief. I have the same trade-offs with my Talk Python websites and infrastructure. That's why I use Snap CI. Every time I check into github, Snap CI springs into action. A clean copy of code at github, a Python 3 virtual environment is created all the packages and dependencies are installed, the unittests are run. Finally, I am notified in Slack and in many bar on my Mac about the outcome. That how I know it's safe to ship a shiny new version of my web app. Ship your software faster with the 30 days free trial at snap.ci/talkpython.

38:49 [music]

40:20 Michael: Let's talk about building the right renewables, so right amount of energy right time, that kind of thing. In this space there's this problem called the Duck curve what's the duck curve?

40:30 Anna: It's kind of weird name for a kind of cool graph, so if you Google duck curve you will find that these graphs that show- right now in some parts of the world the amount of renewables that's being put on the grid is sort of balancing the other things that's being produced, so there is not really a problem but as more and more solar in particular is put on the grid, that will mean that sometimes there can actually be more solar production in the middle of the day, than there is demands. So this is a huge problem because that means that if we're just spending money on building new solar panels willy-nilly, that's not actually solving real problem.

41:18 Michael: Right because like the coal plants have to stay on line so you just have to dump that energy anyway.

41:25 Anna: Exactly, or like even if we were able to turn off the coal plants there might be still be too much solar which is kind of fun problems to have, but that really is a future that we're moving towards, so building the right mix of energy in the right places is something that is mostly a sort of research and policy problem at this point, so there's a lot of cool work going on at research labs including some of the National dle labs.

41:55 Michael: Excellent, yeah, and that was kind of your first job, right?

41:58 Anna: Yeah, so there's also some work going on at like consulting companies like what I was at and also the big solar companies will have in-house grids that do some of this work to be like okay, we need to get this project permitted to put on the grid, how can we simulate exactly how much energy our wind farms or solar farms are going to be producing in 10 years.

42:19 Michael: Ok, yeah, so there's a lot of interesting open-source- there's a couple of popular open-source Python related projects trying to help answer this question right?

42:30 Anna: Yeah, so there's one for wind called wind ml, ml like machine learning, and there is a similar one that called pv live and that has a Python binding, so both of these are Python projects that for the first one it can help you collect data about what your wind farm might do, and analyze that data, and for the second it does the same thing for calculating solar pv output, so if you have sort of like photovoltaic panels what kind of power are they going to be producing, so you can plan around that.

43:05 Michael: And if you wanted to treat this like a data science problem are there cool datasets and stuff that you can use?

43:13 Anna: Yeah, so both of those will give you access to data sets and then the National Renewable Energy Lab also hosts assembly data set called PB watts, so that's something that like there's been a lot of effort put into developing these data sets, but that one is kind of interesting is that I wasn't able to find good Python bindings for it, or a good Python client so that's an opportunity for someone to start it a new open source project.

43:38 Michael: And then, the last part, the third category he said was using the right energy when it's available and that's what WatTtime works on that's what PyIso your project works on, what else is going on around there?

43:52 Anna: Part of why this is so hard is that this isn't something that the grid operators can really just do by themselves, you can't just plan it forward and then have it work, because it's at the end of the day it's a behavioral problem is happening at the user side of the equation, so almost every energy Hackathon that I've been at like someone is like super excited, like if people could just see where their energy is coming from, then they'll take all the right actions, and like you can make some really fun graphs that way but unfortunately none of them have ever really caught on like Google and Apple and like Microsoft they all try these two and unfortunately it's just like a really hard behavioral problem to get people to pay attention to where their energy comes from.

44:36 Michael: Yeah, they don't really seem to catch on. You put an interesting fact up here that says people spend less than 10 minutes a year thinking about their power bill.

44:43 Anna: Yeah. So it's true, like people don't really care even though they think they do and even though they want to and so that's why technology can be so impactful and as part of the problem is because it's all about automation and smart devices and internet of things, in order to like really solve the problem in a way that sticks.

45:02 Michael: Yeah, you almost have to take the person out of the loop, right if the thing that controls the house is connected back to another place that cares about how this works and the person still spends maybe 12 minutes now because they have some blinky lights to look at, thinking about this per year it's still like if it does the right thing that's way better.

45:19 Anna: Yeah, exactly. So what we do at Watt Time as part of that, another project that is- the sort of category of ways of dealing with the energy problem is called demand response, making it the power demand be responsive to what's happening on the power grid. And so, one open source project is there is something called open edr which is open automated demand response and this is a standard, like a protocol for developing implementations for smart devices that will actually turn on and off at the right times.

45:55 Michael: That's pretty neat.

45:55 Anna: Yeah, so there's a few different open source implementations of this protocol and those are something that are a real opportunity for people to get involved and develop those more fully because it's sort of a pain if that the first thing you have to do in order to be able to work with a bunch of different devices is to re-implement the standard every time. So that's a really impactful place where people could jump in.

46:20 Michael: And then, another area around here seems to me is if you know there's excess energy if you could somehow store it, and there's a lot of interesting ways that I learned that you can store energy like you could pump water uphill and then put them back out and get almost as like water power when there's a less energy and things like that but probably the most, the biggest one that's affecting residential areas at least I would say it's probably the tesla powerwall right?

46:48 Anna: Yeah so that's definitely the sort of the sexiest option out the right now.

46:53 Michael: For sure and maybe not everyone knows what it is maybe you could just tell us what is the power wall?

46:57 Anna: Yeah, so that is battery it that you can stick on the wall in your garage and you can buy it from Tesla and you can feel fancy because you've bought the thing from Tesla, even though you can't afford a car. And it can talk to test those servers and turn on and off at different times that you can be I'm not sure exactly what features they've built out so far in terms of what different kinds of grid events it can respond to.

47:25 Michael: Right, maybe it is paying attention to price or maybe it's paying attention to renewable energy or not something like that who knows. I don't have one either; but there's a lot of possibilities that could trigger on.

47:38 Anna: Yeah and so there is also other similar things where like you can get used electric vehicle batteries and use those for the same thing so it doesn't it's like recycling electric vehicle battery there's a secondary market where you can stick them in your garage and have them be useful.

47:55 Michael: That's really interesting that I had not heard of. Cool, you have to give us some links to something like that so I can put on the show notes. You know, maybe some people out there listening are getting excited about like hey maybe I could participate in this- there actually are a bunch of energy focused startup incubators kind of like YC but for energy right?

48:16 Anna: Yeah, so these are great places to start if you have your own idea for an energy project, or you just want to meet people who are involved and maybe get hired at an existing start up. There is a bunch of these in different cities one, two blocks from my office in Oakland California is called powerhouse and there's another called Acre in New York City Greentown labs in Boston, Energy foundry in Chicago, 1776 in DC, there are some all over the US and I'm sure some in some of the other countries too.

48:47 Michael: Is the process pretty similar to go into y combinator you come in with an idea they help you grow it, turn it into a company, but it's really just cut this mission around energy?

48:56 Anna: Exactly each one has a slightly different model but a lot of them also have meet up so even if you aren't ready to make this your full-time job yet, you can still go to some of their public like community events and learn more about what's going on.

49:11 Michael: Okay that's great. Too bad there's not a Portland one maybe someday.

49:15 Anna: Someone could start one.

49:17 Michael: That's true. Alright well this has been a really interesting conversation and before we wrap it up let me ask you two questions I always ask all my guests; one is if you are going to write some code, Python code in particular, what editor do open up?

49:33 Anna: I like Sublime these days.

49:36 Michael: Sublime, very nice.

49:37 Anna: Yep, although in grad school I had something called Spyder, and that sort of like an R 49:44 studio or a matlab clone for Python.

49:45 Michael: Yeah that one comes with the Anaconda distribution, right I think from from the continuum guys so you can get it that way, that's cool.

49:53 Anna: Yeah, but if I'm writing Django I like sublime.

49:55 Michael: Right, if you're doing data science maybe spyder it is pretty awesome, but if you are doing Django, Sublime, ok, cool. I saw the other day there's 88,000 plus packages on pypi.io, it's crazy that's why it's so great to work in Python, right, just mostly what you need is already out there. What one is your favorite these days?

50:15 Anna: What I heard about recently is called Retrying so since a lot of what we've talked about this like all these different IOT data sources and great data sources are really flaky so retrying is something that makes it a lot easier to be like okay this 50:30 this HTTP request failed but let's try it again. So there's a nice little decorator that just Retry.

50:36 Michael: Can you see like Retrying like 10 times with some kind of like backup level or like what does it look like? If people want to get involved what can they do how do they work with watt time or what other advice or call to action can you give them?

50:52 Anna: Yeah so if you want to get involved in helping with PyIsl it's P-Y-I-S-L and you can check out our github page or just email me or chat me up on Twitter and we can find a way to start working together. My personal twitter is windupanna and WattTime is on twitter at that wattime.

51:12 Michael: Excellent, yeah and I'll put those in the links of course.

51:15 Anna: Great, and if you want to get on the waiting list for some of our smart devices there's smart thermostat that you can sign up for, or an electric vehicle charging station or if you have like if you actually manage commercial building we have a lot of other services that we can hook you up with also.

51:34 Michael: That's awesome and it won't be just renewable energy doing good but you have the warm feeling the Python is it back, right exactly?

51:39 Anna: Exactly, the real positive motivation, not saving the world, just saving Python.

51:44 Michael: That's right, saving the world with Python. Let's leave it at that. Anna, thanks so much for being on the show and sharing the story about what you're doing around renewable energy, it's inspiring.

51:55 Anna: Thank you. This is really fun.

51:57 Michael: Yep you bet, talk to you later.

51:59 Anna: Talk to you, bye.

51:59 This has been another episode of Talk Python To Me.

51:59 Today's guest has been Anna Schneider and this episode has been sponsored by Hired and Snap CI. Thank you both for supporting the show!

51:59 Rollbar takes the pain out of errors. They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complained. As Talk Python To Me listeners, track a ridiculous number of errors for free at rollbar.com/talkpythontome

51:59 Snap CI is modern continuous integration and delivery. Build, test, and deploy your code directly from github, all in your browser with debugging, docker, and parallelism included. Try them for free at snap.ci/talkpython

51:59 Are you or a colleague trying to learn Python? Have you tried books and videos that left you bored by just covering topics point-by-point? Check out my online course Python Jumpstart by Building 10 Apps at talkpython.fm/course to experience a more engaging way to learn Python. If you're looking for something a little more advanced, try my write pythonic code course at talkpython.fm/pythonic.

51:59 You can find the links from the show at talkpython.fm/episodes/show/76

51:59 Be sure to subscribe to the show. Open your favorite podcatcher and search for Python. We should be right at the top. You can also find the iTunes feed at /itunes, Google Play feed at /play and direct RSS feed at /rss on talkpython.fm.

51:59 Our theme music is Developers Developers Developers by Cory Smith, who goes by Smixx. Cory just recently started selling his music on iTunes so I recommend you check it out at talkpython.fm/music. You can browse his music there and listen to the full-length version of Developers Developers Developers.

51:59 This is your host, Michael Kennedy. Thanks for listening!

51:59 Smixx, take us out of here.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon