Scientific Programming Study Group

Notes from Jan 21 and 27, 2010 Scientific Programming Study Group

Jim Emery is a member of Kansas City’s STEM2 society. He has started a Scientific Programming Study Group recently at the CCCKC hackerspace. STEM2 is a group that promotes Science, Technology, Engineering and Mathematics. The topic is based on his document titled “Scientific Calculating, Programming and Writing” which can be found at the Stem2 web site.

Using Python

Jim chose the Python language for these sessions. It is a powerful language with many features that make scientific computing easier.

Finding documentation on Python:

Getting Started in Linux

Since I’m using Ubuntu Linux, Python is already installed. To work through Jim’s examples I need to create the following new directories in my home folder “/vthompson“.

  • /bin
  • /tmp
  • /src

The next step is to open a command window and adjust the $PATH variable so any programs placed in the /bin folder can be found. First, keyin the command echo $PATH to see how this environment variable is already defined.

PATH Environment Variable

PATH Environment Variable

From the picture above, we see the /bin directory shows up in in several places. Surprisingly, the directory I just created in my home directory already shows up. How did this happen? The answer can be found in the hidden shell script also found in my home directory,  vthompson/.profile. It contains the following code segment that automatically places a home directory’s /bin path as the first one in the PATH list.

# set PATH so it includes user’s private bin if it exists
if [ -d “$HOME/bin” ] ; then

A good place to find more information is the Ubuntu Documentation page on Environment Variables. Also, for more information about shell scripts check out the Beginners Bash Scripting page. Another helpful document if you’re just starting to work with the command line is this CategoryCommandLine document.

Purpose of the /bin Directory

Linux is designed as a multi user operating system. While your desktop or laptop computer may not be used by other people logging into different accounts, using the home directory’s /bin folder prevents our special programs from interfering with someone else’s computer usage habits.

Now, its time to populate the /bin directory with files from the STEM2 software listing. The files we need are and Download and unzip the contents into /bin.

Trying a Sample Program

From Jim’s book, Chapter 6 on Graphing and Programmable Calculators, I’m trying the square root sample. I’ve created a /src directory to place my program source code into. Here is the sample program written using the gedit editor:

Squareroot Source Code

Squareroot Source Code

And the resulting screen shot of the program:

Squareroot Example Python Program

Squareroot Example Python Program

Other Python Notes:

About SomeoneKnows
(c) 2010 Vince Thompson


Adventures in Linux Documentation

In the Linux world, there are multiple paths toward providing a solution. There are various “brands” of Linux distributions (“distros”) that seem to have a little different way of doing things. Likewise, when you download programs written for Linux there are often multiple programs providing similar capabilities (some better than others). Documentation with configuration details can lead in different directions based on who wrote them. Sometimes the Linux world gives you enough rope to hang yourself.

I’ve been setting up a test environment to get web server functionality that I’ll use to create web sites offline as I described in X-AMPP Based Web Sites. Since then I’ve downloaded Drupal 6 from the Drupal download site and prepared to install in my test server environment.

A couple of weeks earlier I set up my first Drupal environment with the online Internet service provider that will be hosting my live web sites. This ISP provides a button to launch the Drupal setup process and everything went smoothly.

The X-AMP configuration created a web hosting area under /opt/lampp/htdocs directory. Since I’m wanting to set up multiple virtual domains I added a “www” folder named htdocs/www under that directory as a placeholder for each virtual domain. For example I have set up htdocs/www/mystudysource.dom for that particular web site. My first instinct was to download and extract Dripal into this domain’s directory. I realized this was wrong and placed the extracted files onto my desktop area instead. Then I created a “drupal6” folder and proceeded to copy the extracted contents into my mystudysource.dom/drupal6 directory using an ftp program.

XAMPP Control Panel

XAMPP Control Panel

I started the XAMPP control panel, pushing the Start XAMPP button and was up and running as far as having a web server but I still needed to copy the files into my domain’s area. Since one of the components started is ProFTPD (an ftp server program) I’m able to use a program like Mozilla’s FileZilla to transfer these files. With the drupal files in the mystudygroup.dom/drupal6 directory I’m ready to start configuration.

Setting up Drupal on my development environment didn’t go as smoothly. I got a list of warnings and errors but not the configuration screen I expected. Doing the same thing over and over produced similar results with some slight variations. I suspect I have some kind of mis-configuration causing access errors so, its back to reading the documentation to see what I missed.

Over the last few days I’ve been reading a lot more documentation, both online and from books I already have. It’s interesting how a variety of sources can take you off in different directions. Reading the documentation is similar to looking at an old weathered stone that has many cracks running in different directions. I’ve seen a wide range of documentation from topics that are well formated and easy to follow to the extreme opposite with a pathetic mashup of email comments appearing as a solid block of text characters with no formatting at all. I’m sure one of these documentation fissures will lead me in the right direction.

About SomeoneKnows
(c) 2010 Vince Thompson

X-AMP Based Web Sites

I’ve been developing web sites since 1996 and was the architect of Paul Mueller’s plate heat exchanger design program brought online in 2000. So far the web sites I’ve built have used Microsoft’s Internet Information Server (IIS).

I’m working on some new web sites running on Linux and using the Apache web server. In particular they are using Apache, MySql database and PHP which refer to using the “AMP” designation. There’s WAMP for a Windows version, LAMP versions for Linux applications, and XAMPP. I ended up using the XAMPP project from ApacheFriends as described in this Ubuntu Forums thread. I went to the XAMPP area on SourceForge to download the latest version. This placed the LAMP applications in my /opt/lampp directory.

Virtual Domains

I am creating multiple web sites and want a separate development environment on my laptop for each web domain. Next I edit the /etc/hosts file to define local ip addresses for each of my web sites. Localhost is already defined at, then I’m adding the name of my computer, gtdev1, so it points to also. I will be working on the following web sites:,,,,, and

I’m hard coding IP locations mapped to my computer. If I were to use the “.com” designation it would hijack any attempts to go to the live Internet web sites from my computer. To prevent confusion I’m changing the names slightly using a “.dom” designation instead. I use .dom to represent domain. I edit the /etc/hosts file adding the lines mapped to IP addresses    localhost    gtdev1    GeometricTechnology.dom    MyStudySource.dom    DIYRoboticsLab.dom    UnBiasedSewing.dom    labywiinth.dom    MakeKC.dom

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now, for instance, when I type http://MyStudySource.dom into the web browser it serves up the default page from my laptop. This lets me work with each unique local web domain. The next thing I need to do is provide a separate folder for each domain instead of the default localhost location.

I created a folder called under /opt/lampp/htdocs/ called www with folders inside for each of the domains, for instance /opt/lampp/htdocs/www/geometrictechnology.dom.

Next I edit the /opt/lampp/etc/extra/httpd-vhosts.conf file to identify folders for each of the local domains.

# Virtual Hosts
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn’t need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at
# <URL:;
# for further details before you try to setup virtual hosts.
# You may use the command line option ‘-S’ to verify your virtual host
# configuration.

# Use name-based virtual hosting.
NameVirtualHost *:80

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
DocumentRoot htdocs/xampp
ServerName localhost
ErrorLog logs/localhost-error_log
CustomLog logs/localhost-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@geometrictechnology.dom
DocumentRoot htdocs/www/geometrictechnology.dom
ServerName geometrictechnology.dom
ErrorLog logs/geometrictechnology.dom-error_log
CustomLog logs/geometrictechnology.dom-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@mystudysource.dom
DocumentRoot htdocs/www/mystudysource.dom
ServerName mystudysource.dom
ErrorLog logs/mystudysource.dom-error_log
CustomLog logs/mystudysource.dom-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@diyroboticslab.dom
DocumentRoot htdocs/www/diyroboticslab.dom
ServerName diyroboticslab.dom
ErrorLog logs/diyroboticslab.dom-error_log
CustomLog logs/diyroboticslab.dom-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@labywiinth.dom
DocumentRoot htdocs/www/labywiinth.dom
ServerName labywiinth.dom
ErrorLog logs/labywiinth.dom-error_log
CustomLog logs/labywiinth.dom-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@unbiasedsewing.dom
DocumentRoot htdocs/www/unbiasedsewing.dom
ServerName unbiasedsewing.dom
ErrorLog logs/unbiasedsewing.dom-error_log
CustomLog logs/unbiasedsewing.dom-access_log common

<VirtualHost *:80>
ServerAdmin webmaster@makekc.dom
DocumentRoot htdocs/www/makekc.dom
ServerName makekc.dom
ErrorLog logs/makekc.dom-error_log
CustomLog logs/makekc.dom-access_log common

To enable the http-vhosts.config settings check the httpd.config again to verify the following Include statements are un commented.

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

Include etc/extra/httpd-xampp.conf

# Various default settings
Include etc/extra/httpd-default.conf

After making these changes stop and restart Apache so it will find the changes.

Under the /opt/lampp/htdocs/www/ folder I have a folder for each of the domains I want to use. Inside each of the domain folders I have a file named index.html. This file simply has the paragraph tag

<p> Hello World </p>

Actually, I customized the message in each to know which folder the web page was served from. Now when I type my local domain name into a browser is serves up my Hello World or equivalent example from each domain’s directory.

About SomeoneKnows

(c) 2010 Vince Thompson

Laptop Rebuild

I got a new 500 GB hard drive over the Christmas season and have installed it in my laptop computer. I considered going with Linux only but finally gave in and set aside a portion for Windows. I’m hoping some of the mythical stimulus money finally lands on a project I’m in line to work on that requires using a Windows only program.

Before installing the new drive I spent a few days archiving files to DVD. I’m getting ready to rebuild a server too so getting files from both computers took extra time.

Hard Drive Partitions

Hard Drive Partitions

This is how I partitioned my disk drive:

When I installed Windows Vista from the restore CD, this put two partitions on the disk.

  • /dev/sda1 – Toshiba System Volume with 1.6 GB NTFS
  • /dev/sda2 – SQ0046… Reduced to 60 GB NTFS Area for Windows OS and other programs

After getting Window installed I placed the Ubuntu 9.10 in the CD drive and rebooted. The installation procedure needs to know about how the disk drive will be used. I added the following partitions:

/dev/sda3 Remaining 439 GB partitioned as follows

  • /dev/sda5 – 32 GB Filesystem formatted as FAT32 mounted as /shared (I’m using this when my project files are supported by both Win and Linux OS)
  • /dev/sda6 – 4GB set up as Linux swap space
  • /dev/sda7 – Remaining 403 GB as Linux Ext4 file system mounted as /

About SomeoneKnows

(c) 2010 Vince Thompson