23 August 2013

500. Changing language in Debian (GNOME 3, terminal) to e.g. fr_CH

This is both obvious, and tricky at the same time.

1. Install locales
The first step is to install the languages you need
sudo apt-get install locales
sudo dpkg-reconfigure locales

2. Optional: language packs
If you want e.g. libreoffice to use the new language, you'll need to install the corresponding language pack. Most programmes will NOT need this, but libreoffice and iceweasel do. The same goes for KDE.
sudo apt-get install libreoffice-l10n-fr iceweasel-l10n-fr icedove-l10n-fr

Basically, search for packages with l10n in their names.

3. GNOME
Select the new language in GNOME 3 by gong to Region and Language:
Now, here's the trick: even if the language you want is listed, click on the "+" sign in the bottom left corner, and select it like this:
While you now have two 'French' items, this is necessary or the language will not be correctly set. If you do NOT do this some things will change language, some won't (e.g. Activities won't change to Activités). In that case, if you log out, then back in and go to Languages you'll find that the language is set to "Unspecified [ANSI_X3.4-1968]". See the screenshot at the very  bottom of this post for an example of what it looks like.


Log out of GNOME and log back in again. Et voilà.
And...we have French! French everywhere.


4. Optional: set it in terminal
If you set the language in GNOME as shown above you shouldn't need to do this. However, if you are not using GNOME 3 you may want to set the language explicitly in your terminal by sticking the following in your ~/.profile or ~/.bashrc
export LANG="fr_CH.utf8"

When it's NOT OK:
Note how it says 'Pays et Langue' but still says 'Activities' i.e. the language for some items has been changed, but not all.
See step 3 for an explanation of what's going on.

499. Briefly: Drawing NMR sequences using metapost and Mark White's pulse.mp

Since it's Friday afternoon and I'm not likely to get anything useful done in the hour that remains before going home, I might as well put up another post.

Since posting http://verahill.blogspot.com.au/2013/08/498-briefly-drawing-nmr-pulse-sequences.html I've had a look at this: http://www.celos.net/comp/pulses/

And that actually is (almost -- let's not get carried away here) exactly what I have been looking for. The main issue was that it's meant for metapost -- or rather, the main issue was my unfamiliarity with metapost. Anyway, my life is know complete.

So here's how to get started...

First 'install' the metapost script:
sudo apt-get install texlive-metapost
mkdir ~/texmf/metapost
cd ~/texmf/metapost -p
wget http://www.celos.net/comp/pulses/pulses.mp
sudo texhash

Next, time to test-drive it
mkdir ~/tmp/pulse_test -p
cd ~/tmp/pulse_test
vim test.mp
input pulses.mp beginfig(0); initf; startline(rf,"RF"); xline(1); xpulse(0.5,0.5,"90"); ospan(-0.25,-1.0,1.5,"d1"); xline(0.75); xpulse(1.0,0.5,"180"); ospan(-0.5,-1.0,1.5,"d1"); xline(1.0); ospan(0,-1.0,1.5,"vd"); xline(1.5); xacq(2); endfig;
mpost test.mp mptopdf test.0 pdftops -eps test-0.pdf test-0.eps





Now, I somehow suspect you can embed metapost scripts directly in .tex documents, but from my brief testing I haven't quite managed to make it work.

498. Briefly: Drawing NMR pulse sequences using APSEQ and Mathematica

There are two things that have been bothering me on linux -- one is the difficulty of creating annotated PDF documents, but it seems like things are slowly improving (we still don't have a really good way of creating /editable/ annotations). Another is the issue of creating NMR pulse-sequence drawings. To be fair, it doesn't seem like the situation is much better on Windows or OSX.

Anyway, I still don't have a good way of doing this, but at least I have A way of getting it done: APSEQ. The main drawback is that it requires Mathematica, which I don't like much (I get by with octave and maxima) in addition to being proprietary. But it will do for now.

NOTE: I just needed to 'Get It Done' quickly, so I didn't spend any time looking at the following potential alternatives:
http://www.celos.net/comp/pulses/ (metapost -- which should be tex compatible, right)
https://code.google.com/p/nmrtype/ (python code)
http://nmrwiki.org/wiki/index.php?title=NMRPulse_-_pulse_sequence_drawing_extension_for_MediaWiki (the URL is fairly descriptive)
They all seem to depend on latex in some way or another.

There's also http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9656&rep=rep1&type=pdf but I haven't actually found the sources.

Anyway, here's how to get started with APSEQ:

mkdir ~/tmp/apseq -p
cd ~/tmp/apseq
wget https://www.princeton.edu/~nmr/apseq/apsDistribution.tar.gz
tar xvf apsDistribution.tar.gz
cd zip.feb15/
math
Mathematica 7.0 for Linux x86 (64-bit) Copyright 1988-2009 Wolfram Research, Inc. In[1]:= <<nmr.auto part01 loaded part02 loaded part03 loaded part04 loaded mscp loaded nmr.extra loaded nmr.auto loaded In[2]:= draw[pulseSeq[hahn, echo]={channels[1H],pulse[90],delay[t1],pulse[180],delay[t1],delay[t2],acquire[taq]}] Out[2]= hahn_echo.pdf In[3]:=

which gives you something like this:
Spin echo sequence
The figure is output as a pdf, but it's easy enough to open it in inkscape and converting it to an .eps file.