LaTex and Inkscape

In about a month and a half I’m going to be presenting a poster at the DCL/DE workshop in Oregon.  Since I don’t currently have a copy of Illustrator, I’m trying to decide what to use instead.  I downloaded Inkscape onto my imac, and started playing around.  The first thing I did was try to make a small annotated sketch.  It was all going fairly smoothly until I tried to add in symbols… and then I remembered how I ran into this problem last time I played with Inkscape.  So it was pretty much the same thing.

Here’s what I did:

1.  Install Inkscape from their website:  inkscape.org.  This part was straightforward.
2.  Download Textext, unzip the folder.  It’s found here: http://pav.iki.fi/software/textext/
3.  Copy the files textext.py and textext.inx to the inkscape extensions folder:

cp *text* ~/.config/inkscape/extensions/

4.  Then get Pstoedit:

fink install pstoedit

5.  In Inkscape, go to Extensions -> Render -> Textext,  and fill the Tex code into the GUI that pops up.

            

There is an error message that comes up saying:

textext.py:55: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import os, sys, tempfile, traceback, glob, re, md5, copy

I recall getting a message something like this last time I installed Textext. It is annoying, but doesn’t seem to be a huge problem, and the extension still works.

Molly Moon’s and more inverse theory

It was a long day, lots of code writing.  But it was fun, because I was working on an interesting inverse problem.  Probably not that interesting to people who know lots about inverse theory, but it’s new to me, so still very cool.  Since I’m not great at writing efficient code, it was a long 6 hours before I could see any results.  But in the end I got a really pretty picture that might tell me something about using earthquake positioning techniques to locate a whale far outside a seismic network.  Well, about 15 km outside a network that covers roughly 5km x 10km of seafloor in 2km water depth.  So pretty far.

And yes.  I am a day behind in my little drawings.  At some point I will surely skip a day.  But I’m trying to keep up for as long as I can.

Oh… what’s that you say?  You want to see the results of yesterday’s work?  Alright!  It might not make sense, and there is always a chance it’s just outright incorrect.  But at the very least, those are some dramatic colors, no?  I had to scale the color values though – basically the colors are in a log scale.  So where it says 10, it actually means 10^{10}, an 8 means 10^{8}, and so on.  So yeah, those position errors way outside the network are huge.  HUGE.

Inverse theory cheat sheet

I made this cheat sheet for simple inverse theory problems.  I did it partially to remember the the basic steps of constructing inverse problems (linear and weakly non-linear), and also to practice using different layouts in LaTeX.  Which, for this example, meant using the multicol package in landscape mode, with some changes to the default geometry.

I grabbed a lot of the formatting bits from the LaTeX cheat sheet.  Here it is:

Inverse theory cheat sheet – PDF

And the jpeg version:

As usual, there is a distinct possibility that I’ve made some mistakes here.  If I find any I’ll correct them.  If *you* find one, please let me know!

LaTex and JASA template

Today Dax and I are figuring out how to use LaTex to put together a JASA paper.  Yay!  So fun – I love figuring out LaTex stuff.  First off, we had to get Dax’s computer all set up to run LaTex.  We went with the MacTex-2010 distribution, it’s pretty much got all you need, and you don’t need to worry about getting the right dependencies or any of that stuff.  It installs all of this stuff:

We haven’t had a chance to investigate much – so far we’re just running TeXShop – it’s pretty straightforward, and does syntax highlighting automatically.  BibDesk for the references is fine too, but I prefer JabRef.  And as it turns out, JabRef was the easiest way to get Dax’s Endnote database converted to BibTex .bib format.

To do the Endnote –> BibTex conversion, we had to follow these steps (after http://wiki.lyx.org/BibTeX/Programs):

  1. In Endnote:  Edit -> Output styles -> Open Style Manager
  2. Check the box marked “Refer Export”
  3. Go to File -> Export.  Save file as type:  “Text only”, Output style: “Refer Export”.
  4. In JabRef:  File -> Import into new database
  5. Choose File Format “Refer/Endnote”, and select exported Endnote .txt file.
  6. In the intermediate viewer window, you can optionally select not to import duplicates, or select which entries you would like to import.  Click OK, and you’re done!

Easy Peasy!

Now for the JASA format.  I found this zip file on the JASA website under For Authors -> JASA.  The second to last option in the first section is Download files for preparation of JASA manuscripts in TeX format. This zip file contains a folder that contains all sorts of JASA/LaTex goodness. I didn’t have a chance to dig in too deep, but I sort of went through and grabbed the bits that I thought relevent, at least to have a first go at it. This meant the template file, the jasatex.cls file, the jasanum.bst file.  There are instructions for installing “JasaTex”, but from what I can tell, it looks like it’s just instructions on getting the style files into the right folders in the Tex system sub-directories.

This was enough to get started, and Dax is filling in his LaTex document with an early draft of his paper – and it looks great! The JASA-LaTex package also includes a handy guide that discusses some LaTex basics and general guidelines.  Very handy.

Multiple sub-figures in Latex

Use the subfig package, so in the preamble, insert this line:

\usepackage{subfig}

Here’s an example of how it’s used (from a Climate Dynamics class assignment):

\begin{figure}[H]
\centering
\subfloat[Zonal Winds - Aquaplanet model]{\includegraphics[width=3in]{pics/P2_1B_zonalwind_image}}
\subfloat[Precipitation - Aquaplanet model]{\includegraphics[width=3in]{pics/P2_1B_precip_image}}\\
\subfloat[Zonal winds - Full geography model]{\includegraphics[width=3in]{pics/P1_2extra_uref_January}}
\subfloat[Precipitation - Full geography model]{\includegraphics[width=3in]{pics/P1_2extra_precip_January}}\\
\caption{Comparison of zonally averaged surface winds and
precipitation fields between the full geography model and the
aquaplanet model.}
\label{fig:p2q1pb}
\end{figure}

And the final result looks like this:

Auto-commenting Latex files in Aquamacs

Yet another reason why I love Aquamacs… I love being able to do this in Matlab (Ctrl-T/Ctrl-R), but it always bugged me that I couldn’t figure out how to do this quickly while editing scripts in Emacs.  I still don’t know how to do it in plain old Bash emacs, but I did find out how to do it in Aquamacs:

ctrl-c ;

This toggles between commenting and uncommenting. I still haven’t checked to see if I can do the same thing in Aquamacs with Python files. I suspect there’s a way. (actually I suspect there’s a way in command line emacs as well, I just haven’t found it).

FFT Review

I haven’t done signal processing of any sort for a while now (that’s not to say I ever did very much of it) – but I occasionally find myself needing to do some filtering or frequency spectrum analysis. And as usual, I always need to look up how I did it before. I should really write myself a little cheat sheet. But since I don’t have time for that now, here’s a quick link: FFT Tutorial. It’s from someone in the EE department at the University of Rhode Island. I had a quick look and I like it because it provides some theory, and also a Matlab example (and it’s pretty clearly written using LaTeX – yeah!). And while I’m on the topic of signal processing, here’s a link to a tutorial by Richard Lyons: “Quadrature Signals, Complex but not Complicated“. I like this one because it has a movie trivia question on page 3. And I totally knew the answer without looking.

LaTeX-ing again

Here I am, sitting indoors during a snowstorm, blundering my way through my raytracing script.  Ah, Snell’s law and optics.  What fun!  Anyhow, I realized that it was the perfect opportunity to practice some LaTeX skills.  I’ll be able to describe the theory of what I’m doing in my script.  Not that it’s anything complicated, but it’s enough for me to be able to practice some TeX-style math notation.  Sweet.

Here’s what I’ve got so far, using Emacs.  Easy!  No math yet though.
[sourcecode language=”latex”]
documentclass[12pt]{article}
title{Raytrace script – how it works}
author{M. Weirathmueller}
date{1 January 2010}
begin{document}
maketitle

section{Indroduction}
This document is meant to accompany the my raytrace.py script, in an attempt to describe the theory behind what it’s doing.

The main idea is to read two sound speed profiles, and to compare depths computed by a multibeam echosounder for these profiles.

section{theory}

end{document}
[/sourcecode]

(incidentally – I just discovered that WordPress source code posting supports LaTeX – fun!)

It was also the first time I’d ever compiled a LaTeX file from the command line. I know, I know, it’s no big deal. But it was new for me!

Created my PDF like this:

[sourcecode]
pdflatex raytrace.tex
[/sourcecode]

Then looked at it in my PDF viewer like this:
[sourcecode]
gnome-open raytrace.pdf
[/sourcecode]

gnome-open just opens the file with the default program for that extension. Also – I added an alias to my .bashrc file so that just typing “g file.pdf” works like “gnome-open file.pdf”.

Learn LaTeX again?

On the drive home, I thought of other things.  Such as how much I missed writing up neat little documents in LaTeX.  They turn out so sharp and professional-looking, much better than I’d generally ever get out of Microsoft Word.  I did my thesis in LaTeX, which still left me quite far from expert status, although I like to think I know a bit more about this typesetting language than the average person on the street (by a tiny margin).

As I drove down the free-way, exhausted from a long day on the water, I actually contemplated writing up some of my longer test procedures in a LaTeX document.  It’s really so much cleaner-looking.  Creating tables, references, embedding scripts, and showing equations would be easy, and look great. When I got home, I dug out my old “LaTeX Companion” book – a 1090 page, dog-eared, coffee covered, cross-referenced LaTex reference bible.  I can’t quite see a truly good reason to actually write anything in LaTex. No one else at work uses it, so if I wrote a test document, no one but me could edit it.  Which is really quite short-sighted.  Still, I can’t help but want to do it.

The LaTex website recommends using Tex Live for Linux operating systems.  I can’t remember what I used for my thesis, it was a full GUI program in Windows (TeXnicCenter, maybe?).  I kind of remember one of my profs doing all of his LaTex stuff on the command line – that seems much more difficult.  But I think it’s always cooler to be able to lightning-type in the terminal to make things happen.  It makes it seem like magic (Arthur C. Clarke did say that “Any significantly advanced technology is indistinguishable from magic).