If you are using Microsoft's web browser Internet Explorer on a regular basis, please stop. Seriously.
I've heard a lot of people say they "have to use IE for work." Usually this is not true, it's just the default browser that's on your work computer. If it is true, make sure to file a complaint at your office/work. What should you use instead? Any of the following:
Pass this information along to your friends.
I am a vocal proponent of openness in technology. Today, I was thrilled to read an excellent letter that was written to Google employees by Google Senior VP of Product Management, Jonathan Rosenberg. In this letter, he discusses why openness in technology, as opposed to the old school thought of locking users into a particular company's products/services, is better for companies and users alike. Here's the letter.
EDIT: It's also important to know that Google's main source of revenue, their search ad system, is not open-source. This is an interesting exception/contradiction to the principle's discussed in the letter. If you have any thoughts about this, or anything else in the letter, send me an email at email@example.com.
Engineers often need to draw illustrations and diagrams to include in their writing. Inkscape has recently added some features and bugfixes, and is now an absolutely excellent tool for drawing. You can download it completely free of charge with no limitations at www.inkscape.org.
Inkscape has buit in latex rendering if your system has the appropriate libraries installed. On Ubuntu, you must have "pdf2svg" installed. Once you have the backend rendering programs installed, go to "Extensions -> Render -> LateX Formula" to drop an equation in your illustrations. Even better is the Tex Text plugin, which allows you to edit forumulas after they have been rendered to the illustration.
The new connector tool for drawing diagrams is much improved. Previous versions of Inkscape had an annoying bug that prevented connection lines from displaying properly around circular objects. This is fixed and working perfectly as of Inkscape .47.
Here's a quick little diagram that I created in just a few minutes with Inkscape.
I highly recommend a donation to the Inkscape team so they can continue to improve this amazing tool.
Those of you who read my blog know that I am using Python as an alternative to Matlab. In my experience, python has been an excellent language for scientific programming, but there are some significant differences that make moving from Matlab challenging. I'm writing this article to share with you some of the common "gotchas" that have been a challenge for me, so you don't have to struggle as much.
In Matlab, if you divide integers, it returns a float. For example, 1/2 = .5 in matlab. In python, dividing integers returns integers, so 1/2 = 0. If you want to do this kind of division in python, make sure that you use floats by specifying the decimal places (1.0/2.0 = .5), or use the float typecase (float(1)/2 = .5). This is extremely simple, but it has bitten me many times!
When working with scientific data, it's much better to use the array data type instead of a python list. A python list is not designed to deal with numerical computations, so it does funny things. For example: [1,2] + [3,4] results in [1,2,3,4] with a python list, not [4,6] like you would expect in Matlab. If you're going to do math on your data vectors, use an array to avoid problems: array([1,2]) + array([3,4]) = array([4,6]).
I recently posted an article saying python lists were great for irregular data. In hindsight, that may not have been such a great tip. Using python lists can lead to a lot of tricky problems, so be careful. Here's a link to tips for using scipy arrays.
This one can really mess you up. Whenever you reference an array in python, the computer will provide the memory address for the thing you are accessing, not the actual value. This is called pass-by-reference. This saves memory and makes your programs faster, but it is also harder to keep straight. Consider this example.
>>>a = array([1,2,3])
>>>b = a
b is not a copy of a, it points to the same memory address that a is held. So, if you change b, you will also change a.
>>>b = 9999
a is now equal "9999" because a and b are pointing to the same thing. If you want b to be a separate copy of a, then use b = a.copy().
Sometimes you can create function definition confusion by importing too many libraries. For example, if two libraries have a function called "foo()" and you import them both
>>>from lib1 import *
>>>from lib2 import *
then you will most likely be using the second library's version of foo(). If you want to make sure not to mess up, only use the import statement:
That way, you have to specifically call lib1.foo() and lib2.foo().
Scipy functions generally return array data types, not matrices. Multiplying arrays results in element-by-element multiplication, not matrix multiplication. If you want to do matrix multiplication using array data types, you should use "dot(a,b)" where a and b are arrays. However, if a and b are matrix types, then a*b would do matrix multiplication, and dot(a,b) would be element-by-element. Be careful! See the link below for futher clarification on this issue.
Here's a link that explains some of the key differences in Python for Matlab users: http://www.scipy.org/NumPy_for_Matlab_Users
Scenario: You have your research simulation scripts working, and you're getting some solid results. You read a new paper that describes a method that will work better than what you have, and you decide to implement the method into your simulation. You spend a few hours programming the new method, only to find that you have severely messed up your simulation. You wish you could get back to what you had before.
You should have used a version control system. Most people think that version control is only necessary or useful if you're working on a large project that has multiple individuals contributing to the code. Not true! Version control is helpful for even the projects that you work on by yourself. Bazaar Version Control has become one of my favorite tools. It's free, simple to use, only takes a few minutes to use effectively, and runs on many different operating systems.
Bazaar is great because you can use it locally on your machine without having to set up a version control server. The revision control files will sit nicely right inside the directory of your project (If you need to publish your changes to a server like a traditional VCS, it's simple to do that as well). I use it to keep track of my python code for radio tomographic imaging, and for revision on our publications. I save my papers at each revision so I know what I have changed when a reviewer requests an edit.
Here's how I use it. When I start a new project, I simply navigate to the directory with a command terminal and type:
This starts the control on the directory I am in. Then I tell it that I want it to keep track of certain files by typing:
bzr add myfile1.txt myfile2.dat
and so on. Now, every time I want to take a snapshot of the current state of my files, I simply run:
bzr commit -m 'A short message goes here to describe the state of the code at this checkin time.'
It's as simple as that. Now, when you have your code in a good state and your going to chop it up to add new features, simply run the commit command and you can revert back to that state at any time. Perfect. For a really quick and easy guide to getting started with Bazaar, check out Bazaar in Five Minutes.
Programming and working with multi-dimensional arrays is a common task for engineers. For example, say you have some data from 3 sensors, and you want to sample the data 10 times. That would naturally lead to a 10x3 array that can be indexed as: a[time][sensor].
In my case, I have a number of sensors that sometimes don't report their data. The wireless transmission often gets corrupted, preventing the data from reaching the basestation on my laptop. In this case, I could have 2 sensors that report 10 samples of data, but one that only reports 8. There's an irregularity in the structure now, and using a 10x3 array would require a bunch of overhead checking to make sure I don't count missing data as reported data.
Nested lists to the rescue! In python, a list is a sequence of objects that can be appended. So, to create an empty list:
data = 
Now we have an empty list called "data." Next, let's append three lists inside the list.
We now have a list of empty lists. Kind of like a book with empty chapters in the table of contents. Every time we append a new list, we add a new chapter, but no pages are there yet. Data now looks like this:
data = [,,]
Now, let's say sensor number 0 reports a measurement of 3. Then sensor 1 reports an 8, etc...
Continuing, let's say that sensors 0 and 1 never miss an incoming measurement, but sensor 2 is spotty. In this case, data and data are longer in length than data, but the nested list has no problem with this. If you want the average of sensor 0's measurements, you could do something like:
mu = mean(data)
Easy! Way better than trying to keep track of missing data. The only downside is that dynamic data structures are slower than pre-allocated length arrays. If you need your program to be screaming fast, appending to lists may not be your best choice.
FOLLOW UP: If you want to create a list of empty lists, you can use the following convenient code:
emptyLists = map(list,[]*100)
This will create a list of 100 empty lists.
I often get asked why I am pursuing a PhD in electrical engineering. "Do you want to be a professor?" they usually ask. Frankly, the answer is no. Although I have one of the best advisors around, and I enjoy, appreciate, and understand the value of academic research, my aspirations are different. My dream is to come up with creative new ideas, then deliver them to everyday people in the form of products or services. I believe that our work as engineers is advanced only when we are taken for granted. Our users push the button, it works, and they usually don't know or care how.
We as engineers often view the commercialization of our work as something that should be left to others. We come up with the ideas, show that they work, then leave it to someone else to implement in product. We like to tell ourselves that "engineers are not technicians," and think we have more creative/interesting work to do. We usually believe that the most interesting and rewarding part of science is in the research, not the development.
As scientists and engineers, I believe we need to do a better job at understanding the importance of the implementation and development. I recently teamed up with a friend of mine who has a Master's in Business Administration (MBA) to write a business plan. We are developing a company to commercialize some of the technologies that I am working on as a PhD student, and a business plan is an important first step in making sure the company has a viable offering. As an engineer, I was tempted with thoughts like, "I should just let the business people take care of our plan. I'm an engineer, and I should focus on the technology itself, not the petty financial and marketing aspects."
To my surprise, I found that thinking and writing about the marketing of our proposed product amplified my technical abilities as an engineer. Suddenly, the problems with the current state of my technology were obvious, and problems that I thought were important to solve became worthless. New ideas and opportunities for the future of the technology were poured in to my thoughts, all of which could easily be the topic of research publications. I gained confidence that my research mattered to everyday people, and my motivation in my research work skyrocketed. I knew that solving the right problems would be extremely valuable.
If you're an engineer, don't blow off the applications and viability of your research to others. If you take some time to understand the business aspects of your research, you'll be much more sucessful as a scientist. You'll know what's important to solve, and what can be ignored. People will listen to you because they know that you see the big picture. Your job opportunities and skill sets will be amplified and expanded.
The University of Utah is a phenomenal school when it comes to commercialization of the new technologies developed by professors and students. Here are some links:
If you're at Utah, check these programs out, and watch for classes that relate. If you're not at Utah, find out what commercialization programs and classes your school has to offer. It's worth your time.
I am a big fan of open source software, as you can probably tell by reading my previous posts. I use Linux, OpenOffice, Inkscape, Drupal, and a ton of other open source applications on a regular basis. I love the fact that an entire community dispersed across the world can work on open source projects. Mark my words, 10 years from now, open source applications will be ubiquitous and preferred.
I'm excited for this year's Utah Open Source Conference coming up on October 8-10, 2009. It's a great time to meet other users of open source software and talk about how to make it better. Check it out, and if you live in Utah, sign up!
A few weeks ago, I posted about my attempt to replace Matlab with Python as my preferred scientific/numerical/engineering/plotting software. This is simply a follow-up to share my thoughts after a few weeks of using Python exclusively.
I now prefer Python over Matlab, and will continue to use it for my engineering research, publications, and other work. Python is different from Matlab, so the change has slowed me down a bit while I learn some of the details, but I have really enjoyed the process. Python is elegant and powerful, and I have found that I can do almost everything that I used to do in Matlab. Some things I can do in Python that I can't in Matlab.
My main complaint is that the matplotlib (python plotting library) windows are not as interactive and flexible as Matlab's. The end-result plots are just as high-quality as matlab, it's just that the plot viewing tool is not as rich. This is a small price to pay, however, for such a powerful and friendly scientific computing tool. I'm sold.
I encourage all of you engineers out there to give Python, Scipy, and matplotlib a fair try. It's worth your time, and you won't regret it.