Fine-tuning (K)ubuntu and installing some astro/math packages
Ubuntu, is one of the best linux distros currently (as of 2009 Feb 11). However the live CD that you can download from the Ubuntu website is pretty minimalistic. Most likely you will need to install additional libraries/software. There are many, many webpages devoted to setting up your desktop so that it looks pretty, flashy and play all kinds of media. As as astronomer/astrophysicist, I have a few additional requirements, viz. installing the astronomical software (e.g. HEASOFT, ISIS, IRAF), mathematics libraries (e.g. GSL), and plotting packages (e.g. gnuplot and pgplot). Some of these (and their pre-requisites) are non-trivial and takes a fair amount of searching the internet. Therefore I am trying to put these things together here, so it can be helpful (mainly to me, but maybe others too) for future reference.
Disclaimer: These settings are what I like (today) … so beware …
0. Random, unorganized notes
2009 Jun 19: The KDE software updater marks the linux kernel upgrades as 'blocked' and wouldn't install them by default. The way to force the kernel upgrade seems to be via 'sudo aptitude full-upgrade'.
1. Setting up Kubuntu
sudo aptitude install vim-gnome vim vim-gtk kubuntu-desktop && \
sudo aptitude update
sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
sudo apt-get --yes install app-install-data-medibuntu apport-hooks-medibuntu
sudo aptitude install libgd2-xpm-dev gfortran g++ \
libncurses5-dev x-dev libx11-dev libxt-dev libreadline5-dev \
gv stellarium autopano-sift enblend hugin libdvdcss2 eog lynx \
w32codecs vlc mencoder mplayer mplayer-fonts mplayer-skins \
startupmanager grub-splashimages kubuntu-grub-splashimages \
gramps gimp doxygen kolourpaint4 vim-gnome vim vim-gtk enscript ncftp \
skype acroread acroread-plugins and mozilla-acroread tree \
mozilla-mplayer gtk2-engines-qtcurve firestarter libgsl0-dev \
nedit gparted csh tcsh mailutils openssh-server subversion \
texlive texmaker kile manpages-dev valgrind povray gwenview tofrodos \
kaffeine gtk-recordmydesktop
sudo aptitude clean
Maybe good to reboot at this point and make sure everything is working properly.
2. Then a few more (optional) fine-tunings that I like (and most others don't)
2.1 Start->System Settings->Notifications->Turn of all sounds.
2.2 Start->System Settings->Window Behavior->Under 'Focus' tab, in Focus box, change 'Policy' to 'Focus follows mouse', check 'Auto Raise' with Delay 500ms. Also make the titlebar expands vertically on double click.
2.3 I hate KDE wallet. Disable it: xterm->kwalletmanager->configure kwallet
2.4 Add logoff/shutdown applet to panel.
2.5 Configure the clock in the panel to show day of the week, and also the seconds. I like when the clock has the same fonts as the rest (Sans Serif 9).
2.6 To solve the problem with check-boxes on Firefox (hope they fix it quickly): Start -> System settings -> Appearance -> GTK Styles and Fonts -> Use another style -> QtCurve
3. Now to the non-standard mathematics/astronomy/astrophysics packages
Note: The version numbers change quite rapidly for these software. These commands assume whatever is the most recent version now (2009 Feb 11). Therefore you may need to edit the commands accordingly. Also, I like to install these in the directory ~/installed/software-name-<version>. Also the sequence of installation is slightly important; particularly you may want to install ISIS after heasoft if you want to link ISIS to heasoft and thus be able to install the XSPEC models.
Update 2009 Sep 25: Maybe I was slow to learn this, but you no longer need to install Pgplot and cfitsio yourself before installing ISIS as long as you have installed heasoft beforehand. You only need to install s-lang. Also VERY, VERY important … use the same set of compilers for compiling s-lang/heasoft/ISIS and preferably the other ISIS modules/accessories like slirp, slgsl etc.
Not needed if you already have it installed, e.g. via the long 'sudo aptitude install …' above. Otherwise
sudo aptitude install libgsl0-dev
To install from source
wget ftp://ftp.gnu.org/gnu/gsl/gsl-1.13.tar.gz
tar -zxf gsl-1.13.tar.gz
cd gsl-1.13
mkdir -p /usr/Gemini1/dmaitra/installed/gsl-1.13
./configure --prefix=/usr/Gemini1/dmaitra/installed/gsl-1.13
make
make check > log 2>&1 # All tests passed
make install
cd ../
rm -rf gsl-1.13*
Download .tar.gz from sourceforge.
Then following the instructions from http://www.miscdebris.net/blog/2007/04/27/install-gnuplot-on-ubuntu/
# Unless libgd2-xpm-dev is already installed e.g. via the
# long 'sudo aptitude install ... command'
sudo aptitude install libgd2-xpm-dev
# Download and install PDFlib Lite
cd ~/src/
wget http://www.pdflib.com/binaries/PDFlib/703/PDFlib-Lite-7.0.3.tar.gz
tar xzf PDFlib-Lite-7.0.3.tar.gz
cd PDFlib-Lite-7.0.3
./configure
make
sudo make install
sudo ldconfig
# Now install gnuplot
# Update 2009 Sep 23: The same instructions also work for v4.2.6
#
cd ~/src
mkdir -p ~/installed/gnuplot-4.2.4
tar -zxf gnuplot-4.2.4.tar.gz
cd gnuplot-4.2.4/
./configure --prefix=/home/dmaitra/installed/gnuplot-4.2.4 \
--with-readline=gnu
make
make install
cd ~/src/
ln -s /home/dmaitra/installed/gnuplot-4.2.6/bin/gnuplot
rm -rf PDFlib-Lite-7.0.3* gnuplot-4.2.4*
## Edit ~/.bashrc and add gnuplot alias:
#alias gnuplot="gnuplot -bg white"
cd src/
wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3130.tar.gz
tar -zxf cfitsio3130.tar.gz
mkdir -p /home/dmaitra/installed/cfitsio3130
cd cfitsio/
./configure CC=gcc --prefix=/home/dmaitra/installed/cfitsio3130
make shared
make install
make testprog
./testprog > testprog.lis
diff testprog.lis testprog.out # Output should be nothing
cmp testprog.fit testprog.std # Output should be nothing
cd /home/dmaitra/src/
rm -rf cfitsio*
## Added in .bashrc For CFITSIO
#C_INCLUDE_PATH=/home/dmaitra/installed/cfitsio3130/include
#LIBRARY_PATH=/home/dmaitra/installed/cfitsio3130/lib
#export C_INCLUDE_PATH LIBRARY_PATH
cd ~/src/
wget ftp://ftp.astro.caltech.edu/pub/pgplot/pgplot5.2.tar.gz
tar -zxf pgplot5.2.tar.gz
mkdir ~/installed/pgplot5.2
cd ~/installed/pgplot5.2
# Edit the drivers.list or (just for me)
scp akash:/home/dmaitra/installed/pgplot5.2/drivers.list .
# or
# wget http://astrokubuntu.wikidot.com/local--files/start/drivers.list
~/src/pgplot/makemake ~/src/pgplot linux g77_gcc
# Edit ~/installed/pgplot/makefile according to the directions in
# http://www.dur.ac.uk/physics.astrolab/ppgplot.html
# Basically:
# Replace "FCOMPL=g77" in line 25
# by "FCOMPL=gfortran"
#
# Replace "FFLAGC=-u -Wall -fPIC -O" in line 26
# by "FFLAGC=-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O"
# Go to ~line 880 and replace
# "pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h"
# by "pndriv.o : "
make
make libpgplot.so # Probably not needed because it said that libpgplot.so
# was already up to date.
make cpg
make clean
rm -rf ~/src/pgplot/
## Edit ~/.bashrc
# PGPLOT_DIR="/home/dmaitra/installed/pgplot5.2"
# export PGPLOT_DIR
#
# Modify LD_LIBRARY_PATH for various softwares
#LD_LIBRARY_PATH=/home/dmaitra/installed/pgplot5.2:$LD_LIBRARY_PATH
#export LD_LIBRARY_PATH
# Make sure to use the same set of compilers used to build heasoft
CXX=g++ ; export CXX
CC=gcc ; export CC
FC=gfortran ; export FC
cd ~/src/slang-2.2.1/
mkdir ~/installed/slang-2.2.1
./configure --prefix=/home/dmaitra/installed/slang-2.2.1
make
make runtests
make install
sudo ldconfig
ln -s ~/installed/slang-2.2.1/bin/slsh ~/bin/
(A) Install the software
Get the gzipped tar source archive from download webpage for all missions.
# (Actually these are already included in the long
# sudo aptitude install command above)
sudo aptitude install gfortran g++ libncurses5-dev \
x-dev libx11-dev libxt-dev
#
# Now to heasoft install
#
CXX=g++ ; export CXX
CC=gcc ; export CC
FC=gfortran ; export FC
cd heasoft-6.7/BUILD_DIR/
mkdir ~/installed/heasoft-6.7
./configure --prefix=/home/dmaitra/installed/heasoft-6.7 > config.out 2>&1 &
grep "\*\*\*" config.out # Check config.out has no problems
make > build.log 2>&1 &
grep "\*\*\*" build.log # Check build.log has no problems
make install > install.log 2>&1 &
grep "\*\*\*" install.log # Check install.log has no problems
# Edit ~/.bashrc to add heasoft initialization lines
HEADAS=/home/dmaitra/installed/heasoft6.6.1/i686-pc-linux-gnu-libc2.8.90
export HEADAS
alias heainit=". $HEADAS/headas-init.sh"
PGPLOT_TYPE=/xw ; export PGPLOT_TYPE
UPDATE on 20090422: I was having some problems running xrtexpomap and decided to upgrade to v6.6.2. I followed the same set of instructions as above, but only with 6.6.1 changed to 6.6.2. The installation went smoothly and the xrtexpomap problem is now gone. I also received an email from Milvia Capalbi and Matteo Perri just around the same time when the latest version was being installed. Milvia and Matteo suggest the following (for Ubuntu OSs)
# BEFORE the initial build of HEASoft.
# for bash
export CFLAGS="-fno-stack-protector"
export CXXFLAGS="-fno-stack-protector"
#or for tcsh:
setenv CFLAGS "-fno-stack-protector"
setenv CXXFLAGS "-fno-stack-protector"
# Following the two above commands, it is possible to launch the usual
./configure
./hmake
./hmake install
Since xrtexpomap is running with the latest version, I haven't tried recompiling with "-fno-stack-protector" flags yet, but if something fails again I'll give this a try!
(B) Install the calibration database
mkdir ~/installed/caldb
cd ~/installed/caldb/
wget http://heasarc.gsfc.nasa.gov/FTP/caldb/software/tools/caldb_setup_files.tar.Z
tar -zxf caldb_setup_files.tar.Z
# Edit the software/tools/caldbinit.sh and .bashrc to point towards the
# right path to caldb directory.
# Open a new terminal window
heainit
cd $CALDB
wget http://heasarc.gsfc.nasa.gov/FTP/caldb/data/xte/pca/goodfiles_xte_pca.tar.Z
wget http://heasarc.gsfc.nasa.gov/FTP/caldb/data/xte/hexte/goodfiles_xte_hexte.tar.Z
wget http://heasarc.gsfc.nasa.gov/FTP/caldb/data/swift/xrt/goodfiles_swift_xrt.tar.Z
tar -zxf goodfiles_xte_pca.tar.Z
caldbinfo INST XTE PCA
tar -zxf goodfiles_xte_hexte.tar.Z
caldbinfo INST XTE HEXTE
tar -zxf goodfiles_swift_xrt.tar.Z
caldbinfo INST SWIFT XRT
rm -i *tar*
# Make sure to use the same set of compilers used to build s-lang and heasoft
CXX=g++ ; export CXX
CC=gcc ; export CC
FC=gfortran ; export FC
cd ~/src/isis-1.5.0-7/
mkdir -p ~/installed/isis-1.5.0-7
unset LD_LIBRARY_PATH
./configure --prefix=/home/dmaitra/installed/isis-1.5.0-7 \
--with-slang=/home/dmaitra/installed/slang-2.2.1 \
--with-headas=$HEADAS
make
make check
make install
ln -s ~/installed/isis-1.5.0-7/isis/1.5.0/bin/* ~/bin/
cd ~/src/
wget http://space.mit.edu/CXC/software/slang/modules/gsl/src/slgsl-0.7.0.tar.gz
tar -zxf slgsl-0.7.0.tar.gz
cd slgsl-0.7.0
./configure --prefix=/home/dmaitra/installed/slang-2.1.4 \
--with-slang=/home/dmaitra/installed/slang-2.1.4
make
make install
cd ~/src/
rm -rf slgsl-0.7.0*
CXX=g++ ; export CXX
CC=gcc ; export CC
FC=gfortran ; export FC
cd ~/src/slirp-1.9.7/
mkdir -p ~/installed/slirp-1.9.7
./configure --prefix=/home/dmaitra/installed/slirp-1.9.7
--with-slang=/home/dmaitra/installed/slang-2.2.1
make
make install
ln -s ~/installed/slirp-1.9.7/bin/* ~/bin/
(works as of 2015 Jan 14)
Download the ISO image from [http://www.astrosen.unam.mx/~favilac/IRAF/14.04/IRAFv216_64BITS.iso]
Then extract files from ISO either using "Archive Manager", or along the following lines:
mkdir ~/iso
sudo mount -o loop path/to/iso/file/YOUR_ISO_FILE.ISO ~/iso
cd ~/iso
Now install IRAF as root
sudo -s # Become root
sh install64.sh # install IRAF
exit # Become normal user
# Don't forget to unmount
cd
sudo umount ~/iso
Before using IRAF for the first time
mkdir ~/iraf/
cd ~/iraf/
mkiraf # choose xgterm
Not only does it install IRAF, but also quite a few other useful stuff. E.g. doing 'ls /iraf/extern/' shows the following:
color fitsutil guiapps pyraf stsdas tables telarchive wcstools x11iraf
To use IRAF, go to the ~/iraf directory and type
According to the installation script another way to start IRAF could be
A script called iraf has been installed in /usr/local/bin/ which executes the xgterm terminal running ecl, and the ds9 viewer
AIPS installation requires libg2c which does not normally come with intrepid (8.10), so
sudo aptitude install libg2c0
The command below will download and install, along with other dependencies,
the 'XShm.h' header file. This is required to build the XAS program which is used
by the AIPS TV. Without this the AIPS TV will not work.
sudo aptitude install xorg-dev ncurses-dev
Then download the AIPS installation files:
cd ~/src
# Keep both the downloaded files (31DEC09.tar.gz and install.pl) in this directory (~/src)
wget ftp://ftp.aoc.nrao.edu/pub/software/aips/31DEC09/31DEC09.tar.gz
wget ftp://ftp.aoc.nrao.edu/pub/software/aips/31DEC09/install.pl
# Create a directory where you wish to install aips
mkdir -p ~/installed/aips/
#Start aips installation
perl install.pl
The perl script install.pl will unpack the tarball 31DEC09.tar.gz and will start installation. Follow the questions asked during the process (and of course answer them for proper installation).
Finally edit the file "/etc/services" to add following lines :
# Local services
sssin 5000/tcp SSSIN # AIPS TV server
ssslock 5002/tcp SSSLOCK # AIPS TV Lock
msgserv 5008/tcp MSGSERV # AIPS Message Server
tekserv 5009/tcp TEKSERV # AIPS TekServer
aipsmt0 5010/tcp AIPSMT0 # AIPS remote FITS disk access
aipsmt1 5011/tcp AIPSMT1 # AIPS remote tape 1
aipsmt2 5012/tcp AIPSMT2 # AIPS remote tape 2
aipsmt3 5013/tcp AIPSMT3
aipsmt4 5014/tcp AIPSMT4
aipsmt5 5015/tcp AIPSMT5
aipsmt6 5016/tcp AIPSMT6
aipsmt7 5017/tcp AIPSMT7
To start aips use command
For binary installation
As of writing (2009-APR-07) the version of sextractor installed automatically by Ubuntu via 'sudo aptitude install sextractor' is buggy. Therefore I had to resort to installing it manually. These are the steps:
cd ~/src/
wget ftp://ftp.iap.fr/pub/from_users/bertin/sextractor/sextractor-2.5.0.tar.gz
tar -zxf sextractor-2.5.0.tar.gz
mkdir -p ~/installed/sextractor-2.5.0
cd sextractor-2.5.0/
./configure --prefix=/home/dmaitra/installed/sextractor-2.5.0
make
make install
cd ~/src
rm -rf sextractor-2.5.0*
# Add to $PATH in .bashrc
# export PATH="$PATH:$HOME/installed/sextractor-2.5.0/bin"
# Get the tarball:
wget http://www.mpeg.org/pub_ftp/mpeg/mssg/mpeg2vidcodec_v12.tar.gz
tar -zxf mpeg2vidcodec_v12.tar.gz
cd mpeg2/
make
cp ./src/mpeg2enc/mpeg2encode ~/bin/
cp ./src/mpeg2dec/mpeg2decode ~/bin/
cd ../
rm -rf mpeg2/ mpeg2vidcodec_v12.tar.gz
mkdir $HOME/src/eqpair
cd $HOME/src/eqpair
tar -zxf /path/to/eqpair.tar.gz
# Edit lmodel.dat to keep only the model parameters for eqpair
# Edit xseqpair.f to point DATADIR (line 838 in my version) to //full path// to
# where $LMODDIR in .bashrc points, e.g. /home/dmaitra/src/eqpair
heainit
xspec
XSPEC12> initpackage eqpair lmodel.dat /home/dmaitra/src/eqpair
XSPEC12> tclexit
# Edit .bashrc to set $LMODDIR pointing to /home/dmaitra/src/eqpair
# LMODDIR=$HOME/src/eqpair ; export LMODDIR
Now eqpair can be loaded from inside XSPEC as follows
XSPEC12>lmod eqpair /home/dmaitra/src/eqpair
# To check that the model was loaded properly type
XSPEC12> model eqpair
# and hit enter to accept all the default parameter values
If $LMODDIR is defined properly, ISIS should load eqpair when you do a " require("xspec"); ". Check for a line like "loading /home/dmaitra/src/eqpair/libeqpair.so" as ISIS starts up.
4. Setting up Panotools (autopano, hugin, enblend etc.)
While most of the pano tools can be installed via aptitude, it may be better to get the bleeding edge. I followed the directions on this webpage http://wiki.panotools.org/Hugin_Compiling_Ubuntu (accessed 2009 Feb 16)
Note added on 2009 Feb 25: At least one of the problems with getting via aptitude is that hugin 0.7 needs enblend 3.2 (which contains 'enfuse') but installs enblend 3.0 (which does not contain enfuse). This could be fixed by replacing enfuse by enblend in preferences (Bug 303222, accessed on 2009 Feb 25).
6. Setting up Heasoft/ISIS on a Mac OS X (v10.5.8)
2009/09/21 : After a few emails with John Houck I found that probably the only uniform compiler set that installs both Heasoft and ISIS in Macs are the gcc/gfortran-4.4 binaries provided by the HPC page. Also thanks to the newly updated ISIS installation page, I realized I could skip installing both Pgplot and cfitsio and use the heasoft installed ones.
Another important thing to keep in mind is the bug in XSPEC gaussian model for 64-bit systems, which Mike Noble found (emailed me on Wed, Mar 12, 2008). Here's what he instructed:
Edit the heasoft-6.7/Xspec/src/XSFunctions/xsgaul.f to change the erf() declaration from
external erf
to
intrinsic erf
So here's what I did, which installs both heasoft, s-lang and isis:
# Installed gcc/gfortran from HPC in /usr/local/bin
CXX=/usr/local/bin/g++ ; export CXX
CC=/usr/local/bin/gcc ; export CC
FC=/usr/local/bin/gfortran ; export FC
#
# Install Heasoft
#
cd ~/Downloads/
tar -xf heasoft6.7src.tar
gvim heasoft-6.7/Xspec/src/XSFunctions/xsgaul.f # Make changes suggested by Mike
cd heasoft-6.7/BUILD_DIR/
./configure --prefix=/Users/dmaitra/installed/heasoft-6.7 >& config.out &
grep "\*\*\*" config.out # No errors found
make >& build.log &
grep "\*\*\*" build.log # No errors found but some warnings!
make install >& install.log &
grep "\*\*\*" install.log # No errors found
gvim ~/.bashrc # Set proper heasoft environment
#
# Install s-lang
#
cd Downloads/slang-2.2.1/
mkdir -p ~/installed/slang-2.2.1
./configure --prefix=/Users/dmaitra/installed/slang-2.2.1
make
make runtests
make install
cd ../
rm -rf slang-2.2.1/
ln -s /Users/dmaitra/installed/slang-2.2.1/bin/slsh ~/bin/
#
# Install ISIS
#
cd Downloads/isis-1.5.0-7/
mkdir -p ~/installed/isis-1.5.0-7
./configure --prefix=/Users/dmaitra/installed/isis-1.5.0-7 \
--with-slang=/Users/dmaitra/installed/slang-2.2.1 \
--with-headas=$HEADAS
make >& build.log &
make check >& make_check.log &
make install >& make_install.log &
cd ../
rm -rf isis-1.5.0-7
ln -s /Users/dmaitra/installed/isis-1.5.0-7/isis/1.5.0/bin/isis \
/Users/dmaitra/bin/
Note that the heasoft build.log will contain many instances of *** as the check with "grep "\*\*\*" build.log" will show. However, according to John Houck "Those warnings aren't important. gcc-4.4 is just unusually strict about how the 'const' qualifier is used."
7. image analysis tips
Create a high quality PNG from PS
convert -density 400 lc.ps -rotate 90 -flatten -resize 25% lc.png
Add a caption/label inside an image
convert ip.JPG -gravity Northeast -stroke white -fill white -pointsize 60 -annotate +50+20 'Label \@ pos' -flatten op.JPG
Extract a linear 16 bit tiff from a raw image using dcraw
dcraw -j -4 -T <RAW_file_name>
8096—8099 are darks, so average them to get a master dark.
convert IMG_8096.JPG.png IMG_8097.JPG.png IMG_8098.JPG.png IMG_8099.JPG.png \
-average master_dark.png
Remove master dark from all frames
convert -compose minus -composite master_dark.png IMG_8094.JPG.png \
ds.IMG_8094.JPG.png
Compose a bunch of images to create a star-trail (based on http://www.wizards-toolkit.org/discourse-server/viewtopic.php?f=1&t=12040#p39496)
convert image1 image2 -compose lighten -composite result
convert result image3 -compose lighten -composite result
etc
To split a JPG (and possibly PNG, TIFF etc. too) into 3 r,g,b FITS files
convert ip.jpg -channel red -fx "u.r" -channel green -fx "u.r" -channel blue -fx "u.r" r.fits
convert ip.jpg -channel red -fx "u.g" -channel green -fx "u.g" -channel blue -fx "u.g" g.fits
convert ip.jpg -channel red -fx "u.b" -channel green -fx "u.b" -channel blue -fx "u.b" b.fits
To create a lossless movie from a bunch of PNGs using mencoder (based on http://lists.mplayerhq.hu/pipermail/mencoder-users/2005-December/002323.html retrieved on 2012 Sep 06)
mencoder "mf://*.png" -mf fps=2.0:type=png:w=900:h=900 -ffourcc MPNG -ovc copy -force-avi-aspect 1.0 -nosound -o result.avi
obviously change the fps value, the w/h (width/height of input PNGs), and the aspect ratio of the output avi!
Insert ProjectionType metadata in an equirectangular image, e.g. from a Ricoh Theta, so that it can be directly uploaded and interpreted by FaceBook.
exiftool -ProjectionType="equirectangular" photo.jpg
(From:
https://facebook360.fb.com/editing-360-photos-injecting-metadata/ accessed on 2017 Sep 26)
8. latex/dvips random stumbles
9. Tips & tricks
This page was created by Dipankar Maitra, in an attempt to learn some of the wiki-lingo.
Comments are welcome. You can reach me at: ddotmaitra AT gmail . com