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

    •  

      January 2009
      M T W T F S S
      « Dec    
       1234
      567891011
      12131415161718
      19202122232425
      262728293031  

    Archive for the 'Habits' Category


    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 < 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 »

    Updates on welcomed unstability

    Posted by Kris on 3rd March 2008

    Been thinking a lot lately. Exerting myself mentally. Not so much physically. But exercising my mind daily is what I love. If it was this “easy” to exercise physically, well, I would be in well shape. But something drives me to work on projects. Some meaningful, some just practicing and moving my brain cells along the line.

    So, this is nothing other than an updating type of post, a snapshot of where my neurons are firing.

    1) Been actually practicing typing and using Python everyday. Did you know that the language Python was named after Monty Python’s Flying Circus? Neither did I until finally doing the official tutorial. Why am I practicing typing? I have been using computers since I was about 5, and still I cannot proper type. Sort of embarrassing. Not that though. I just want to type about thinking about typing. This post was written without proper typing. I have finally completed the typing tutor deal on my laptop. And now just need the practice part. I can type at 90+ WPM with this improper style, but the memory obstacle is still there.

    That moves me on to Python. Why am I learning yet another language? Well, let me clarify. I am not the master of any one language. Python just seems so sensible to me. Good language to finally master. It comes on every Mac and Linux install. It can do all of my automation tasks that I dearly not need waste time on. Filling out FDS files based on numbers in a CSV file. Searching through PDF files for a server. Or making a post-processor for FDS output files. I love the direct-ness of the language. To print something is “print ‘hello world”. And that’s it. No braces, no output specifiers, no weird containing characters, no declarations, and so on.

    2) Finished the Four-Hour Work Week. Amazing book. It is the first book that I am going to buy ever since giving away a huge percentage of my books about six months ago. I am now tasked with actually making something tangible that the rest of the world can use (and will pay for). The book is not just a business book, but a book about lifestyle, travel, and the philosophy of modern culture.

    I now have to think about what I can provide to benefit masses of people. Perhaps the biggest thinking outside experiment that I have ever done. This can be difficult for my idealistic mind, but is totally possible. Since I retired in the month of August in 2006, this is certainly a key element in keeping myself financially supported - but avoiding the traps of an 80-hour per week self business. I do hope to develop my website with more FDS videos and info. This website or another, I am not sure. Hobby or “business”, I am not yet sure. Time and experiences will tell.

    Rack sprinkler

    3) Travel. Need more travel and exploring. The above points will actually help with this in my abstract mind.

    4) Graduate school politics. My fire science hero has a terrible relationship with my future grad. school advisor, department, and school. Yay. All I want is meaningful work, and I hope that they all understand that. To think that my next two years of work might be thrown away is 1000x times worse than saying I would never be paid for the work. I will do my best, as always. My future advisor posed the question of why should an entity contribute to an open-source worldwide project who did not fund them directly. Why should he post the “results” for free. This violated one of my primary values in life. I immediately thought of Linux, KDE, Google, and tons of other open source projects that were not directly funded by those agencies themselves but have benefited the lives of millions based on contributed work.

    Hell, I have been contributing to the FDS project for “free” for the past three years in whatever way that I can, every single day. I would do it for free - because it is one project of many in the world that is meaningful and benefits the world. It even has the bonus of saving lives through better fire protection design. So, I took that comment with a hard heart and looked back on the past 2 years as I have been earning a McDonald’s salary to teach, research, and contribute to a meaningful project. Priorities.

    AFD warehouse

    To leave on a good note, as I should, I have emailed several contacts around the US and the world about future travel and research opportunities. We will see what happens! Have a fantastic week.

    Posted in Books, Community, FDS, Fire, Goals, Habits, Happiness, Health, Intention, Passion, People, Productivity, Research, School, Teaching | No Comments »

    Walking amidst mind paralysis

    Posted by Kris on 28th January 2008

    I’ve just finished a book entitled The Paradox of Choice by Barry Schwartz. I also copied and highlighted some key parts as I always do with books since I usually borrow them from the library stacks or interlibrary loans. Certain pages of the book spoke right to me and will certainly influence my near and far futures. And I think that from the last chapter mainly, the book will indirectly influence the way that I make decisions, big and small, and with that leave a lasting daily taste in my mouth: a taste of comfort in the overwhelming modern world of information and knowledge.

    Unpaved Dock

    Here is an excerpt from the middle of the book [emphasis mine]:

    “While students at many colleges are happy to discover a subject to study that not only do they enjoy but that will enable them to make a living, many of the students that I teach have multiple interests and capabilities. These students face the task of deciding on the one thing that they want to do more than anything else. Unconstrained by limitations of talent, the world is open to them.
     
    Do they exult this opportunity? Not most of the ones I talk to. Instead, they agonize: Between making money and doing something of lasting social value. Between challenging their intellects and exercising their creative impulses. Between work that demands single-mindedness and work that will enable them to lead balanced lives. Between work they can do in a beautifully pastoral location and work that brings them to a bustling city. Between any work at all and further study.
     
    With a decision as important as this, they struggle to find the reasons that make one choice stand out above all others.”
     
    - The Paradox of Choice - Barry Schwartz

    And well: that resounds into the past college years of my life like no other. I like to think of myself proficient in the modern age of time-wasting devices, loads of information, and deceptive items of value. Yet with all of the opportunity laid out before one’s self, we reach a state of bliss and un-motion. This is evidenced by looking back on this very day, a day for me of photographing in a cemetery with a rudimentary understanding of exposures and composition, having a delicious bowl of seafood Pho and wondering how I can make it, wandering about a craft store glaring at the pastels/fancy paper/technical drafting kits, watching a lecture about high performance computing, and finishing off the day by burning a fire model of a church (for research purposes of course).

    Life Saver

    While I am a big proponent of randomness and a wide range of inputs, I am also a succumber of the pleasures of random input and a productive intake of massive amounts of information. This leaves me feeling adrift in a sea of decisions, which leads to indecision. Luckily, the book that I just mentioned talks of some ideas during the closing chapter. Not solutions, but guides to help you walk across the sea of paralysis. Instead of always looking back and wondering, I just don’t think there is a use in pondering the fourth dimension. Unless, of course, you are also interested in philosophical exercises as one of your too-many hobbies.

    Either tonight or tomorrow, I am going to pursue the action of writing a to learn list (see here). Whether or not this will help with the multitude of choice that has materialized in front of me for the past years; I don’t know. But I have a deep and comforting feeling that while it will not make a difference in happiness, it will certainly grow and satiate my soul; and so I share these thoughts with you.

    Posted in Books, Goals, Habits, Happiness, Intention, Meditation, Passion, Productivity | 1 Comment »

    Ideas and the the paralysis of them in slow-motion

    Posted by Kris on 16th January 2008

    There is something to be said about meaningful work. My first day of school comes, and I am hit with the randomness that my mind yearns for. A random day that involves a balance of valid and worthwhile work. One with action, conversation, exercise, dreaming, and so on. And perhaps not in the traditional sense.

    Berries in Carlos, TX

    For instance: exercise. I am an idealist, and exercise to me means working my brain to death. By meditation or focus. Action to me means working towards something that is meaningful, not just a todo list. However, what is meaningful work? Well, as I find out, I humble myself and think that I do not yet have the wisdom to pick out the meaningful work for myself. This is where mentors come in. Mentors in the damndest sense of the word. Mentors that lead you to greater things in life.

    So I am here today. The first day of my last semester. The end of another chapter. Revelations.

    Today I encountered conversations of natural and synthetic happiness, readings about paralysis and choices from the macro scale to the micro, lectures of sprinkler and fire protection, ideas of numerical analysis and prediction, the dexterity and grace of a game of air hockey, a movie about the modern culture of counter-culture, and so on. The ideas and environment that exist in an academic environment spark the beauty and relationships that exist in nature and bring them to the forefront of my thinking.

    On a more practical level, I am excited about this semester as I have some higher-up duties to perform at school throughout the semester, all the while I plan to keep working away at fulfilling days of creation, writing, and expression. Hence, the artful scientist continues with yet more action-packed days.

    While I am on the topic of everything, there is a feeling in the air that forces me to stop what I am doing and write or read. I seek to take action in non-action and a day full of empty decision scares but amuses me. Here is a list of readings and ideas that I hope to pursue in the next week or two:

    •  The Paradox of Choice - Schwartz: The idea that we are faced with an almost unlimited amount of choices in our modern lifestyles and how this can lead to paralysis of action and thought.
    •  The Great Adventure: Essays and accounts written by former volunteers of the Peace Corps. Excellent range of topics and experiences of worldly cultures and monumental tasks taken on and how it affected and influenced the lives of the volunteers.
    • Against Love - Kipnis: Book about the trappings, routines, mindsets, and rituals that the idea of modern relationships put us humans though by marriage or otherwise. A call for all to love more and resist the urge to “work on ourselves” relentlessly as if we are double-majoring in jobs and relationships for all 16 waking hours of our lives.
    • Breaking away from my todo list for most of the day and filling it instead with reflection, creation, and true action.
    • Contemplating the summer of 2008 and what it may bring. Research at a fire protection firm? Coding mathematics at a Google-like place? Working closely with a fire research firm? Or taking a long term sabbatical on a somewhere mind boggling journey.
    • Considering wrapping my head around the 1.5 - 2 years that I will be (probably) in Maryland studying fire science and mathematics and ensuring that I get everything that I can out of the experience while again maintaining a free, open, and exploratory mind.

    Tree growths

    I ride the night freeways going northbound at 75 mph on the way to my new temporary home. The red jacket keeps the chilling winds at bay by utilizing technology and a thin layer of polymers. My mind wanders to the night sky and sets in a lull, considering the different paths to go on mentally during the ride home. Choices suffocate my deliberation on any subject, and as I arrive at one thought or experience to soak in, my senses quickly jump to the next set of problems or decision to be made.

    Snapshot of paralysis of the mind in real-time from a real human:

    When I get home, should I have a glass of water or a beer? [2 minutes]
    Moving on, should I waste some time with internet games or entertaining forum postings? [1-2 hours]
    Should I write a blog post? [20 minutes]
    Should I read one of the five books that I am currently in? [30 minutes-1 hour]
    Should I write some more Perl code for that project? [1 hour]
    I could always just go to sleep right now and forget all of these decisions. [8 hours]
    Or I could practice my typing. [30 minutes]
    Wait, I could try to edit those three rolls pictures that I took. [1 hour]
    I should attack a few items on my todo list like brainstorming for the semester and writing a few emails. [1 hour]
    Screw it, I should delete half of the items on my todo list that won’t matter in five years anyway. [20 minutes]
    Oh wait, I could write down the top 10 things that I want to do for the next month, then narrow it down to three ideals, then ignore the rest so that I actually progress at something. [30 minutes]
    I should grab a bite to eat. [20 minutes]
    Or just meditate about everything above. [30 minutes]

    Welcome to the modern renaissance life. Thanks for listening. Next time: answers?

    Posted in Fire, Goals, Habits, Happiness, Intention, Meditation, Nomadism, Passion, People, Productivity, School, Travels | 1 Comment »

    Attack of the Colorful Carousel

    Posted by Kris on 5th January 2008

    Plumbing, trees, lighting. Websites, motorcycle rides, freeway traffic. Bills, checks, 30%. It’s like a Google Set generated from my abstract days. School is set to start in a week, and I am ready; or I adapt instantly - the same mindset gets accomplished in a successful way, no? This semester presents me with a weird schedule, open of course to all sorts of things.

    Caroseulambra

    Certainly it is not just me who is addicted to mountains of change over and over? Either way, the idea of a core mind or something to hang onto that changes constantly is intriguing to me and I learn more about it every waking day as my brain connects and reinvents concepts that it thought it had down cold.

    My definition of the purpose of life changes seemingly every week. Not my mission or intention, but my purpose. And five years ago, I didn’t really know or care what the difference between those was. Maybe such an adaptive purpose leads to stronger purpose. Wait, of course it does.

    A world of fire, math, engineering, minds, and so on is useless without shared minds or minds. Are the words of a writer that much valuable without anyone to read it?

    Back to plumbing, bills, and music for now. After you read this blog post from PickTheBrain and start off YOUR new year with death, don’t forget to embrace the randomness in life: not just on an ultimate planned trip in the next 1.5 years, but today, and tomorrow, and the infinite tomorrow.

    Thanks.

    Posted in Community, Fire, Habits, Happiness, Intention, Minimalism, Nomadism, People, School | No Comments »