The Artful Scientist

Communicating the greatest possible growth

  • Google Talk

  • Skype Me

    My status
  • Where are you?

    Welcome to theartfulscientist. Enjoy your stay as I talk about my life as a fire protection engineering student and one who studies fire dynamics. These posts range from day to day excitement to my developmental life and provide a window into my world.



    The about page tells more.
  • Photo Albums

  • Want to read what I read?

    Visit my Google Reader shared items page. You can even subscribe to my favorite shared articles.
  • My Music Plays


  • My Visited US States

    Visited US States


    • Subscribe

        RSS Subscribe

      or subscribe to updates by email:

    • Search This Blog

    • Archives

    •  

      November 2008
      M T W T F S S
      « Oct    
       12
      3456789
      10111213141516
      17181920212223
      24252627282930

    Archive for the 'Productivity' Category


    18 minutes with an agile mind - video

    Posted by Kris on 9th April 2008

    Ok, I think I just found a new role model in the teeming world of science. I realize that every day I learn feel closer and closer to the mind of this man that I have just discovered. Watch this 18 minutes of video, and I think you will enjoy it very much. He is an eccentric man, yes, but listen. His words and final thoughts are aligned with the subtitle of my blog, “Communicating the greatest possible growth”.

    Stuff like this gives me a warm feeling of why I am so attracted to the fields of science that I am. Something tells me that this man doesn’t fret too much about the trivial stuff that we sometimes get trapped up in day to day. Click on the picture to watch. Enjoy.

     tedastron.jpg 
    http://www.geeksaresexy.net/2008/04/09/must-watch-18-minutes-with-an-agile-mind/

    By the way, watch out for loose gravel! - I wiped out on my motorcycle gracefully right at this spot near UHD. Everything is okay with me minus a brake pedal that needs to be bent back into shape and a slightly bent handlebar that with bother my OCD.

     
    View Larger Map

    Posted in Community, Fire, Intention, Learning, Math, Motorcycle, Passion, People, Productivity, School, Science, Teaching | No Comments »

    The Golden Resource List for Python Beginners

    Posted by Kris on 17th March 2008

    After years of being a master-of-none with programming languages, I have finally settled on one to delve deeper into: Python. I’ve been learning Python for about a month now, and it has been quite pleasurable. Although the language has been around since 1991, it has been gaining in popularity in the recent years and is used in many underlying projects at Google, Youtube, NASA, Honeywell, and the University of Maryland to name a few. It is an excellent language for a programmer of any level to pick up, and I chose it because of its versatility, clear syntax, and ease of use for transforming my ideas into a a functional and high level language.

    Along the way during the past month, I have sifted through hundreds of websites and quite a few beginner books. So here, I would like to share the links that I found most helpful in my quest for Python knowledge. As far as my past experience, I’ve dabbled in many other languages such as MATLAB, HTML, Fortran, C++, Java, Perl, and so on but never really grew to master a single one or use it in my daily life.

    So, without further delay, on to the list:

    Before You Start With Python

    1. Python.org - I couldn’t make this list without including the main Python site. There is just a great amount of information there. Plus everything I link to can probably be found there, but my list is only those resources that really helped me along in my learning experience.
    2. Teach Yourself Programming in Ten Years - Article by the director of research at Google - A great overview of programming and learning to program, all the while avoiding the ides presented by the “Learn to program in X days” books.

    Excellent Python Tutorials

    1. Dive Into Python - This is one of the first tutorials that I read about Python, and it gave me an excellent overview of the language. It really broke down the code line-by-line, but it still reads like a mix between a reference guide, a cookbook, and a tutorial. It’s a freely available book and should definitely be within quick reach as you learn Python.
    2. How to Think Like a Computer Scientist - This is by far my favorite tutorial in the entire list. I like this (freely available) book because of its plentiful and challenging exercises! I am usually picky when choosing textbooks on a new subject, and I will almost always get the book that has the most examples in it. I spent most of my time creating my own programs at the end of each chapter, and really got a feel for the language (and a nice sense of accomplishment!) at the end of each chapter. Highly recommended.
    3. Python Videos at ShowMeDo - There are over 100 videos at the time of this posting over a wide range of topics. Anything from how to open a Python session to namespaces and more. It was nice when starting out to just sit and watch someone who knew what they were doing do routine tasks, and it helped to ground basic concepts before jumping in on my own. Don’t forget to thank the creators of the videos with a comment!
    4. Learning to Program - This is one that I am going through last, because it gets into a bit more in depth discussion about basic and moderate topics. Very thorough.

    Beginner Exercises and Projects

    1. How to Think Like a Computer Scientist - I just HAD to list this again, because it goes at just the right pace and the exercises are well thought out. I am convinced that I really learned about 80% of my Python basics here when I put them to practice. Learn by doing!
    2. Projects for the Beginner - Python - This is a thread on a forum with over 100 ideas for programs. Use this when you are low on inspiration but high on ambition!
    3. Python Challenge - Neat implementation of puzzles that can be solved with Python scripts. They get harder as you progress levels. You might want to hit up the Python Challenge after getting a good hold on the basics and after you have many of these other links open in other tabs. :)
    4. Useless Python Challenges - This site should be visited after you have finished all of the trivial Python exercises and projects. When you are self-sustaining on the language and eagerly looking for some projects to do, but are hitting a writer’s block for programs, go here.

    Beginner Forums and Lists

    1. Python Forum - Beginners - Not a very high traffic forum, but they have a beginners subforum with 15-30 posts per day, just enough to keep you busy. I find it helpful to attack the problems that other beginners are facing. And if you come up with a good solution, post it and help others while you learn. Everyone wins!
    2. Learning Python Blog - One of the few “learning only” Python blogs. It is always good to see information shared from others while they learn. Sort of like this list. :)
    3. Python Tutor Mailing List - I only recently signed up for this, but I must say that there are some very knowledgeable and helpful people on here and it keeps the Python information coming at you via email. Seems to be quite a few students on here and you will most certainly learn something with each email thread.

    Interesting Python Projects and Libraries

    1. Django Project
    2. TurboGears
    3. Google GData Python API - This is an amazing API from Google that allows you to interact with Google Calendar, Docs, Maps, Youtube, Notebook, and so on. It is very easy to install and use and I look forward to developing with this in the near future.
    4. wxPython - GUI toolkit for interface development. I haven’t gotten to GUIs yet, but everywhere I turn I see references to wxPython.
    5. matplotlib - 2D plotting library that produces very nice looking graphs. Supports many, many types of graphs and is very customizable.
    6. SciPy - A collection of Python tools and modules for use in science, engineering, and mathematics. This is the light at the end of the tunnel for me and I hope to get more involved with this library as I progress with my Python learning.

    Editing Tools and Shells

    1. iPython - An enhanced Python shell that seems geared towards science, engineering, and high performance computing.
    2. TextMate (Mac OS X) - This is such an amazing editor that I must list it here. I didn’t use it at all before I started with Python, and now I simply cannot go without it. I had previously heard it described by programmers as a magical tool, but I had no idea. It does autocompletion based on previous words, syntax highlighting for a ton of languages, has a quick and easy-to-read method to execute Python scripts. It is perhaps the only non-free item in my list, but very much worth it!
    3. TextWrangler (Mac OS X) - This is what I used for a couple of years… until I discovered the greatness of TextMate a few weeks ago. TextWrangler is free though if you wish to use it.

    Other Resources (References, Packages, Hosting)

    1. Python Library Reference - Huge list of explanations about Python’s Standard Library. Made to help you discover the power of Python in your everyday programming.
    2. Python Webhosting - List of webhosts that offer Python solutions on their webhost. Python can be run on most hosts via CGI, but these wiki pages explain exactly how they implement Python usability. Plus I found out about the cool idea of HCoop cooperative web hosting through this list; this is the host on which you are reading this blog. :)
    3. Python Package Index - Directory of Python packages that you can learn about, download, and use in your own programming. Don’t reinvent the wheel!
    4. Python Cookbook Code Samples - This is a directory in the same vein as the previous listing, but the solutions to problems are presented as code with user comments. As of now there are over 2000 recipes.
    5. The Daily Python URL - Just as it sounds. News about Python in compact form.

    Again, while there are many, many other resources for learning Python, this is a list of my personal favorites. These are the specific sites that have been very helpful and impacting on my venture to learn Python. So while I may not have listed a particular item - I probably saw it, but didn’t get much from it at this time.

    Finally, you must forgive me if I got some detail wrong. I am learning, after all! Hopefully this list will help new and moderate Python users to utilize some of the best (and free!) Python resources that others have put up for all to learn from. Thanks to those people who shared their knowledge. And have fun with Python!

    Posted in Computing, Learning, Productivity, Programming, Python, Resources, Teaching | 2 Comments »

    How to install PyObjC, pygame, and gasp on Mac OS X for Python tutorial

    Posted by Kris on 16th March 2008

    I am going through the Python tutorial “How to Think Like a Computer Scientist” right now, and it is an excellent source for beginner/intermediate Python hands-on learning.

    http://openbookproject.net/thinkCSpy/

    However, when I got to chapter 8, my fun stopped right away. The author refers to a Python library called GASP (Graphics API for Students of Python) and gives an example and case study of a small game. The thing is, he doesn’t tell you how to install the module and it abruptly interrupts your lovely Python learning experience.

    http://openbookproject.net/thinkCSpy/ch08.xhtml

    I tried to use easy_install to install most of these, and it always ended up failing for some reason or another.

    As I am using Mac OS X Leopard, I will provide the missing instructions for how to get the gasp module installed (and its dependencies) for anyone else who runs into this situation:

    How to install PyObjC, pygame, and gasp on Mac OS X

    1. I assume that you have already installed some version of Python; I am using Universal Python 2.5 from http://www.pythonmac.org/packages/ which is a nice, easy-to-install package and has other prebuilt packages like numpy, wxPython, matplotlib, etc. ready to be installed. You can see other ways to get Python on your Mac at http://wiki.python.org/moin/MacPython/PythonDistributionsForMac
    2. You will need to install PyObjC, which is also available as a package from http://www.pythonmac.org/packages/ under the 2.5 link.
    3. Now, you will install pygame from a package (pygame-1.8.0rc4-py2.5-macosx10.4.mpkg.zip) available at http://rene.f0o.com/~rene/stuff/macosx/. This is linked from http://www.pygame.org/download.shtml
    4. Finally, we get to the part of installing gasp, which is confusing to find in itself. The FAQ page is at https://answers.launchpad.net/gasp-code/+faq/42 but the link to download is wrong. Get it from https://launchpad.net/gasp-code/+download. You will want to download the Code Release which is currently called python-gasp-0.1.1.tar.bz2.
    5. Extract the bz2 file and there will be a folder inside called gasp. Copy this folder to the /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ directory and you will be in business!

      This is the command that I used: sudo cp -R ~/Desktop/python-gasp-0.1.1/gasp/ /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/gasp

    6. Open a python session and type import pygame and import gasp to make sure that they are installed correctly.
    7. Carry on with the great tutorial linked above!

    I found it odd that the beginners tutorial left out all of this information. Hopefully this will save someone the two days that it took me to find all of these links, packages, and methods.

    Posted in Computing, Productivity, Programming, Python | 4 Comments »

    Mac-Corrected Numerical Analysis Fortran Programs

    Posted by Kris on 10th March 2008

    I am taking a numerical methods course and using the textbook Numerical Analysis 8th edition by Burden and Faires:

    Numerical Analysis

    The book is good and has nice pseudocode examples throughout. It also has a companion website with all of the algorithms programmed in C, FORTRAN, Pascal, Maple, MATLAB, and Mathematica. For our assignments, we can use any program that we want, and I have been using MATLAB, FORTRAN, and Python as those make the most sense to me thus far in my computing experiences and are the most useful for my work.

    However, the FORTRAN 77 programs on the website are programmed in such a way that they only work when using a FORTRAN compiler in Windows. At this time, my primary machine is an Apple Macbook Pro laptop, and I am using the Intel Fortran Compiler version 10.1 on OS X Leopard. When I try to compile the programs from the textbook website, I get errors. So, I went ahead and fixed the files so that they would work on with the Intel compiler on the Mac, and hopefully Linux as well.

    The two problems were that:

    a) The programs were trying to read and write to ‘CON’, which is a Windows specific way of writing to the command window console.

    b) The programs had an extra line at the end and would crash the Intel compiler.

    So, I fixed these errors in all of the programs and you can download the corrected files in .zip format from me and follow the instructions below to compile.

    The original files are freely available from the author’s website here

    Step 1: Download the above linked zip file of the corrected FORTRAN 77 programs

    Step 2: Unzip the FORTRAN files. You will find several files with the .FOR extension.

    Step 3: Run the Intel FORTRAN compiler using the command: ifort -f77rtl -o <outputname> inputfilename.
    For example, to compile example 12.1: ifort -f77rtl -o alg121 ALG121.FOR.

    Step 4: Make the output file executable with: chmod +x alg121

    Step 5: Run the file with ./alg121

    Step 6: Be sure to answer the first Y/N question with the y or n character in quotes, such as “y” or “n”

    Step 7: Have fun learning numerical methods and dissecting the FORTRAN programs!

    Posted in Computing, FORTRAN, Math, Productivity, Programming, School | No Comments »

    The clarity of Python vs. the cloud of Perl

    Posted by Kris on 10th March 2008

    I am learning the Python programming language right now, for many reasons. I need to hone in on a language so that I can write up a script in minutes to do pretty much anything that I need. Things ranging from text file processing, web CGI scripting to generate graphs from data, numerical analysis, and so on. This leaves me with a large number of options such as C++, Java, MATLAB, Python, Perl, and others.

    While I am not a programming newbie, my skill level sits somewhere in the moderate area as I have been exposed to many different programming languages at the beginner level. So when I look for programming tutorials, it leaves me somewhere between the beginner books and websites that assume that you barely know how to “download your camera to your PC” and the other side of the spectrum of which the tutorial looks about as exciting as a book of log tables:

    logTables
    (Flickr user quimby)

    That being said, that leaves us moderate programmers who want to learn - stuck at a good and bad part of our learning experience. The part where you need to practice about every day writing real-world scripts over and over and over. So, after many weeks of lagging through with Python and putting off script writing, I attacked my first real Python program. It seems really trivial and would probably be one of the first few homework problems assigned in a programming course - but I will document my learning process nonetheless for the other moderate programmers that are out there.

    Why Python? I chose Python after dabbling in each language and reading way too much information on each one and finally just trying them out for myself. Which language would be able to match my high-level idealistic mind but still be practical enough to have some power and force behind it? Well, take a look at my example program below. I wanted a program that would take in values from a CSV (comma-separated value) file, loop through a template file, and output new text files with the data from the CSV file’s rows in each output file.

    For the more visually oriented:

    pythonrep.png

    I actually had my roommate last summer help me out with a Perl version of this program, and for comparison, here it is:

    #!/usr/bin/perl
    
    if(@ARGV &lt; 2)
    {
    print "Usage: extractData <csv> <template>\n";
    exit;
    }</template></csv>
    
    my ($file, $templateFile) = @ARGV;
    my $lastTest = "";
    my $templateString = `cat $templateFile`;
    open DF, "&lt; $file";
    
    while(<df>)
    {
    my $line = $_;
    next unless($line =~ m/(^IT)|(^\,)/);
    my ($test, undef, undef, $tray, undef, $cabletype) = split /\,/, $line;
    $test = $lastTest if($test eq "");
    $test =~ s/IT//g;</df>
    
    $lastTest = $test;
    
    print "test: $test; tray: $tray.\n";
    
    $test = sprintf("%02d", $test);
    
    (my $toPrint = $templateString) =~ s/TEST/$test/g;
    $toPrint =~ s/TRAY/$tray/g;
    $toPrint =~ s/CABLETYPE/$cabletype/g;
    
    my $outFile = "CAROLFIRE_IT_" . $test . "_Tray_" . $tray . ".fds";
    
    open OF, "&gt; $outFile";
    print OF $toPrint;
    close OF;
    }
    
    close DF;
    

    Then, here is the version that I wrote last night using Python:

    """Module docstring.
    Usage: python fdscsv.py <csv> <template> <output>
    """</output></template></csv>
    
    import csv, sys, os, re
    
    arguments = sys.argv
    input = csv.reader(open(arguments[1],"r"))
    template = open(arguments[2], "r")
    lines = template.readlines()
    counter = 1
    
    for i, j, k in input:
    output = open(arguments[3] + str(counter) + ".fds", "w")
    for line in lines:
    output.write(line.replace("IREP,JREP,KREP",(str(i) + "," + str(j) + "," + str(k))))
    counter += 1
    output.close()
    

    Now, I realize that the function of the scripts are slightly different while the primary CSV functionality that I illustrated above still remains. I am not going for a line-by-line comparison here. I do want you to just look over the code and see which one makes more sense to your mind. For me, the Python is so easy to read and almost natural to understand while the Perl takes some serious brainpower for me to decode.In conclusion, I just wanted to show where I am at in learning the Python language. It really is enjoyable at this point for me when compared to learning Perl, which was just painful for me. So I hope to add to the resounding praise of Python by posting these examples for other programmers who may be stuck in the intermediate phase of their learning and need a little push of motivation to continue on.

    Finally, if you are interested in what the Python code is actually doing, here is my commented version. Thanks for reading.

    """Module docstring.
    Usage: python fdscsv.py <csv> <template> <output>
    """</output></template></csv>
    
    import csv, sys, os, re
    
    # Reads the arguments into a list
    arguments = sys.argv
    
    # Reads in the input csv file using the module csv
    input = csv.reader(open(arguments[1],"r"))
    
    # Reads in the template file
    template = open(arguments[2], "r")
    
    # Splits the template file into lines
    lines = template.readlines()
    
    counter = 1
    
    # Labels the columns for the data read from the csv and loops through the lines in the csv
    for i, j, k in input:
    
    # Opens a new file with the user-input name plus a counter and an fds extension
    output = open(arguments[3] + str(counter) + ".fds", "w")
    
    # Loops through each line in the template file
    for line in lines:
    
    # Replaces strings in the template file with numbers from the csv file
    output.write(line.replace("IREP,JREP,KREP",(str(i) + "," + str(j) + "," + str(k))))
    
    # Increments the counter for the filename
    counter += 1
    
    output.close()
    

    Posted in FDS, Goals, Habits, Productivity, Programming, Python, School | 2 Comments »