# Allen J. Hall

Materials Science & Engineering, Productivity, and Life

## Tag Archives: How To

### Simple Matlab Gui Programs for Crystal Symmetry Calculations

I’ve made a few small gui programs (MATLAB) for finding all unique angles for vectors (or plane normals) in both the cubic and tetragonal crystal spaces. I thought I’d share them here, as I finally worked out a few kinks. Be aware that the little gui’s use the command window to output their results. Some of my other programs would output latex code so that they could be pasted directly into a thesis for tables etc., but this one just uses the standard out (ala the command window in Matlab).

Essentially you enter the vectors for the two planes of interest, then hit calculate, and all the unique angle solutions for the crystal space you chose (one gui for each crystal space right now- no interest in complicating it by combining at this time) gets output in the command window.

I populate some orientation matrices based upon the vectors you give. Then, from matrix calculations, using tetragonal and crystal symmetry operations, we determine all the symmetric orientations. Then, a simple subspace() command gives us the angles of greatest rise (dihedral angle) between the symmetric orientations. The calculations for these operations can be found in my Thesis (if it ever gets published), but can also be found in: V. Randle and O. Engler. Texture Analysis: Macrotexture, Microtexture & Orientation Mapping. CRC Press, 2000.

Please note- it’s your job to check if these are correct, I make no warranties about this stuff. It should work, but feel free to go in and edit everything to your liking. If you use my code, don’t worry too much about citing me (if you do, I appreciate it, but I often leave out others who have contributed also).

These are very simple, but hopefully they’ll help a bit for those working in cubic and tetragonal spaces.

Here’s the cubic symmetry angle calculator:
Vector Angle Calculator Cubic Symmetries

Here’s the tetragonal symmetry angle calculator:
Vector Angle Calculator Tetragonal Symmetries

I hope they work for you- please let me know if you have problems, if I have time I’ll try and help.

### Automatic USB Key Backups Using Rsync

For Christmas, my awesome brother (Donnie) got me a decently sized LaCie Iamakey [Amazon] along with a few other awesome items. He remembered it from a year or two ago on an old list! Total surprise, and a great one. I’ve been eye-ing one for a while since I’m in need of multiple backups of my research work and thesis writing.

I do do manual backups, and in particular have a drive mirrored using rsync in osX so that it’s bootable (old computers and poor grad-students tend to make for older hard-drives). However, I wanted something a bit faster and easier to use. I wanted an automatic (or semiautomatic) backup of critical writings or data.

### Software For Scientists: Awk (& OsX)

For years while Apple had proprietary system software, I was itching to get a Unix system underneath and have the ease of the windowing system. Well, after OsX was released, I was ecstatic. Why? Because of the ease of some tasks in Unix in comparison to other OS’s. This post is only one example of what you can do if you do a bit of research into how to use your Mac. For those who have un*x boxes, this will merely be a place-holder for a few AWK scripts for you.

### Matlab doesn’t open two windows? – Here’s a fix.

After finally installing Leopard (10.5) osX on my Powerbook G4 (Thesis writing computer), I noticed a strange behavior with MATLAB. MATLAB could no longer open more than one instance of itself. As well, it could no longer open a window once it had opened once in any login session. Strange behavior indeed.

Well, here’s the fix… it turns out that Leopard uses launchd to set the display. So, the old method of launching MATLAB was to set the display to 0.0, but this will fail after the first instance, hence the bug. What you can do is simply remove this line from the startup script in matlab (located within the startup application contents).

The line that was:

$SHELL -c 'bin/'$ARCH'/setsid bin/matlab -desktop -display :0.0 &'

should now be:
$SHELL -c 'bin/'$ARCH'/setsid bin/matlab -desktop &'

Once I changed that, everything started up fine!

ps- you will know you have this problem if you look at your console log immediately after launching MATLAB and it says something like:
6/29/10 9:03:34 AM [0x0-0x78078].StartMATLAB[23469] Warning: Unable to open display :0.0, MATLAB is starting without a display.

### iPod Application: LDAPeople Import/Export

iPhone/iPod application “LDAPeople” allows your iPod or iPhone to search an LDAP server for contact information, which you can save in your contacts with a single button press. It fills the gap that Apple left in Mail for the iPod with system software os2.x (3.0 includes LDAP support, but not for ssh ldap connections, which LDAPeople supports). LDAPeople has a great, clean, implementation. I highly recommend the application if you’re on the fence about buying it. I use it frequently at my university.

The only barrier to using LDAP people is that, depending on your institution, you have to struggle through proper settings to ensure that you can utilize your organization’s LDAP server to the fullest. The latest update for LDAP people has made a great addition- the import and export of settings files! This is fantastic.

So, without further ado, here’s my settings file for the University of Illinois at Urbana-Champaign’s main LDAP server: UIUC LDAP People Config File. Note that you can search by First name, Last name, and UID/UIN with these settings. The UID is also listed in parentheses after the person’s name to aid in finding the right student or staff-member based upon their e-mail address, etc.

If you make any changes to the settings, I’d love it if you could post below, allowing me to update the file and benefit the rest of the UIUC community. Thank you!

To see other reviews of LDAPeople and/or purchase it, see this app on iTunes:

Related post: iPod Touch Application: LDAPeople

### Latex Hint: Use your computer leverage to output large amounts of data.

After a few weeks of doing cryogenic cathodoluminescence spectroscopy on some of my samples, I have gobs and gobs of spectra to look over, and the task is a bit daunting.  Oh sure, you can do so on the computer in many different ways, but often, I need to see my data on the page (old school) before I can really sort through it.  Sometimes even then there’s just too much of it and playing with the data in MatLab all together is critical.

Here’s what I came up with to help output my data very quickly into a printable document that included numerous graphs.  First, the primary goal of this quick method is to be quick- to get tons of graphics (of same proportions) into a doc for printing or perusing.  Second- it should be relatively minimal typing, if possible.  [We all know we can do it by hand 100x; while grad-student pay rate is low, there's gotta be a better way.]

1. Get a directory listing for all the items wanted to be included and dump this in a text file.  (ls *.pdf > filelist.tex)
2. Create a main.tex file which includes the code we’ll need to do this fast.  [You can reuse this file for other directories of graphics needed to be printed.]  My example uses the following:
\documentclass[%
,secnumarabic%
,amssymb, amsmath,nobibnotes, aps, prl,superscriptaddress,letterpaper]{revtex4}
\usepackage[pdftex]{color,graphicx,rotating}
\setkeys{Gin}{width=0.85\columnwidth}

%Simple way to call images and add filenames to captions - for lots of data.
\newcommand{\dataimg}[1]{
\includegraphics[width=3in]{#1}
Filename: #1

}

\begin{document}
\title{CL Results\\
\textit{Internal document not for distribution.}}
\date{\today}
\author{Allen Hall}
\maketitle

\include{filenames}

\printfigures
\end{document}

The important code is the “\include{}” line and also the “\newcommand{\dataimg}…” section. This is what is going to do all the work for us.

3. Now, we need to take your filelist and add at the beginning of each line and end of each line the following:
\dataimg{

and at the end:

}

One way to do this simply is with a command line gawk command:

Terminal Prompt> ls |awk '{ print "\\dataimg{"$0"}" }' 4. So, now each line looks like: \dataimg{filename1.pdf} 5. Once that is done, you can run the LaTeX compile, and you’ll have your file of graphs! That’s a heck of a lot easier than writing each line out by hand. [Use a program like TextMate or Gawk etc. to append and prepend each line with the necessary call.] The benefit of the \newcommand is that it fills in the needed formatting for each graphics file, and attaches the filename for each graphic beside the graphics file itself. You can make it prettier, I’m sure, but this is what I was able to do in a very short time frame. There are many ways to accomplish this little task, you could use Gawk itself to write the latex file for you, I’ve seen some do makefiles to do this type of thing, or perl, or bash shell scripting etc. But, the critical part is to leverage the computer to output a latex file for typsetting and save yourself some time. ### How to backup/save/resurrect your Stanza iPod/iPhone eBook Library A recent Stanza update for the iPod Touch and iPhone left me with a completely blank ebook library! horror!! So, not being content with doing things the most straight forward way, and redownloading every book, I decided to see if you could get all your books back from Stanza somehow. To learn how, join me after the jump… ### Software For Scientists: Engauge Digitizer In the time I’ve been doing my research work at the Univ. of IL, I’ve come across a number of graphs from various past researchers, older papers, stuck on the side of machines (calibration curves), and even hand-drawn or chart-recorder graphs in my numerous projects. The only major problem with those graphs I’ve found is that they aren’t in a digital form for further use with other data (instrument response functions) or to include in your own work as a reference. So, what to do? Well, there’s an easy solution. It’s not the perfect solution, as it’s a bit slow, I’ll get to that in a second, but it’s a great solution to the problem, and has worked for me a number of times now. To top it off, it’s open-source, donation-ware, and cross-platform: Engauge Digitizer (see post at LifeHacker.com). Don’t let the website and lack of recent updates deter you. Tools that can do what Engauge does are few and far between. So, it is definitely worth a try. Here’s an example of how I’ve used it just the other day (prompting this post- I’ve used it for years now, but the recent use reminded me I should share it with others). [click "More" to see an example use and learn more] ### LaTeX Tip: NewCommand For those friends of mine currently attempting to work in LaTeX to code Materials Science and Engineering related tidbits… Here’s a quick tip. Tired of typing all those crazy math commands for your material’s name? Simply use a new command. Here’s are a couple examples… %Simpler way of writing CUINSE2: \newcommand{\cis}{CuInSe$_{2}$} %Simpler way of writing CUINGASE2: \newcommand{\cigs}{CuIn$_{(1-x)}$Ga$_{x}$Se$_{2}$} %Simpler way of writing CUGASE2: \newcommand{\cgs}{CuGaSe$_{2}\$}

To see how this looks in compiled LaTeX output and another example, click “More”…

### Use GeekTool to show S.M.A.R.T. drive status on the desktop (osX)

Well, recently I had a hard-drive corruption occur due to my use of TechTool (as shipped by Apple with their extended coverage- Apple, please ship DiskWarrior with your extended coverage!!!). Since then I’ve been worried about the health of my main os drive, and just learned about S.M.A.R.T. (which is supported by ATA/IDE drives in OsX).

The S.M.A.R.T. status for your drive can be checked in DiskUtil.app (where I’m not sure- couldn’t find it with a cursory check). You can also check it in the command line by typing the following (did you know Disk Util was available in the command line?)…

 diskutil info /dev/disk0 

Of course you may have to check which drive is the drive you hope to check the smart-status on, but disk0 is most likely your boot drive.

To get this as a visual reminder of your disk status, add the following code into GeekTool:
 diskutil info disk0 | grep Verified > /dev/null 
Then turn on GeekTool‘s Icon mode, which uses logical output from the commandline to select an icon to display on the desktop. I used the “default” icons (green or red dot). (This last step comes courtesy of beerguy in the comments area of MacOSXhints.com of this article.)

So, there you have it, a little icon on your desktop which can warn you of impending doom for your hard drive. [See the upper left corner of this blog post.] Very helpful for thesis writers. Of course, impending doom may be too late- so you better have a good backup solution in the works. Oh, and I suggest either adding a title for the icon (try another little mini geektool item) or placing it somewhere (where your drive usually resides) so that in the future you don’t have some odd green or red dot which has no meaning, but which you are sure must be important.

### A Quick Introduction...

I'm a graduate student (PhD Candidate) at the University of Illinois at Urbana-Champaign.

I've studied and researched in two fields of Materials Science and Engineering (Polymers and Semiconductors). My interests are as diverse as my musical tastes and I usually have my hand in some crazy project during my free time.

I'm available for consulting and have access to a world-renown materials research user-facility supported by the D.O.E. If you would like to know more, please contact me.

### Support This Blog

You can support this blog by shopping on Amazon through my Affiliate Store.