Help a Python rookie do something slightly out of his league without flying too close to the sun
June 8, 2011 6:55 AM   Subscribe

[PythonFilter] How can I create a location-based web application using Python? Or, what are some good resources to help me get started with this specific task?

I'd like to create a web application using Python (and perhaps Django?) that will calculate the environmental benefits of a residential photovoltaic (PV) system at a user-specified location – details below if interested. I was wondering how I could get started creating such a program. I've made some good headway on a couple of Python tutorials, but I seem to be going at a snail's pace and learning way more than I actually need for this task. Eventually I'd love to be proficient in the language, but for now I'd just like to get my hands dirty with this one project.

I don't have any formal programming experience except for an undergraduate intro course on Matlab, though I'm usually pretty good at figuring out what I need to do for a specific purpose. For example, with my limited knowledge I was able to tool around with Matlab to perform some matrix calculations for another project I was working on (Excel Solver wasn't cutting it). I've also taught myself a great deal of Applescript to automate some of my tasks, mostly working off of existing scripts I found online and modifying them to suit my needs.

Unfortunately, I've been having trouble doing the same with Python. There seems to be so much out there and I don't even know how to get started finding an example that I can use as a rough model. Does anyone have an idea as to how I could get started on this? Maybe some databases that would be helpful? I'm sure there are even better forums to ask this sort of question, so any suggestions on helpful Python-specific message boards would also be greatly appreciated. Thanks in advance.


Details of the program:

The only required input for this program is the location: city from a dropdown list, lat/long, or maybe Google Maps integration. Other parameters regarding the PV system (tilt, shading, size, etc) can also be set; otherwise, default values will be used so it's not too complicated for the casual user – very similar to NREL's PVWatts calculator (e.g. San Francisco). Behind the scenes, the location will be mapped to a database of solar radiation resource, and the environmental impacts of the PV system will also be calculated using life cycle assessment (LCA) techniques. At the end, results will be presented based on the financial concept of "return on investment":
  1. energy return on investment: energy produced per unit energy consumed over the PV system's lifetime
  2. greenhouse gas return on investment: emissions avoided per unit GHG emitted over lifetime
  3. financial return on investment (if I'm feeling ambitious), using price estimates for the system and location data to determine relevant federal and state incentives
Results reported in other forms (payback times, hard numbers, etc.) will also be available if the user is interested. Emphasis will be put on ease-of-use as well as an aesthetically-pleasing GUI, but that's all down the road.
posted by Rickalicioso to Computers & Internet (5 answers total) 9 users marked this as a favorite
Google App Engine -- it's got a ton of tutorials and geographic apis available for it.
posted by empath at 7:06 AM on June 8, 2011

You've picked the right language. Here are some high-level pointers for you.

Want to do matlab-like stuff with Python? NumPy!

Want to do location based stuff with Django? GeoDjango! (may be overkill for your purposes; Google Maps integration may be the path of least resistance)
posted by zsazsa at 7:06 AM on June 8, 2011

Break your problem down into solvable steps. For example:

1. Get a bare-bones site working locally that you can run Python code in.
2. Create a prototype of the forms and whatnot on the site that shows the general user interface, without the underlying logic to actually do anything.
3. Gather all of the data you will need as input for this project, such as any location-based solar data.
4. Write the logic to do any calculations you need to do based on user input and the data you have.
5. Hook everything up together.

For best results, try to do this iteratively. Figure out the minimum amount of work you need to do to get something working end to end, and implement that. Once you are there, then go back and do more work to get more features working. Learn as you go. Especially if this is your first major programming project, you will never be able to learn everything ahead of time, expect to get stuck on things in the middle of the project and be forced to figure them out. StackOverflow is a good resource for both asking questions and just looking up how to do common things. Google App Engine as mentioned above is a good suggestion, since you can easily get started working locally and later easily transition to having a live site.
posted by burnmp3s at 7:14 AM on June 8, 2011 [1 favorite]

Did you do the django tutorial yet?

To have initial basic functionality, you'll need to:

1. make a database model that maps location to related PV data
2. make form where you pick location from a dropdown, choices created from the database in form's __init__ method.
3. make a view that shows PV data based on location id, maybe doing some calculations?

Test data can be entered in django admin.

You don't really need to know much python to do any of this. Just follow django docs. In step 3 you may need to do some calculations using python - I'm not sure I understood from your question how much logic needs to be done there, if any - if you have questions on how to do that part go ahead and ask in this thread.
posted by rainy at 7:24 AM on June 8, 2011

Check out the code at Data Science Toolkit - it's completely open, and you can download the whole thing to run on your own server
posted by estherbester at 10:29 AM on June 8, 2011

« Older Favorite Youtube Covers?   |   Can Kittens be too Big for Cat Mother? Newer »
This thread is closed to new comments.