Biboroku

Saturday, November 14, 2009

Installing Freemind on Debian Lenny

Filed under: Debian, Lenny, Linux — nomo17k @ 21:15

Download .deb from Freemind’s sourceforge web page, e.g., freemind_0.8.1-2_all.deb. Then

# apt-get install sun-java6-jre
# apt-get install libcommons-codec-java libcommons-lang-java libjcalendar-java
# apt-get install libjgoodies-forms-java librelaxng-datatype-java
# dpkg -i freemind_0.8.1-2_all.deb

Add the following line to ~/.bashrc:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

(Without the environment variable set, I could not get freemind to run at all.) You can then launch it by typing freemind on the shell or choose the program in the menu under office.

Monday, April 20, 2009

Astro Software in Debian Lenny

Filed under: Debian, Lenny, Linux, Research — nomo17k @ 17:44

Here my goal is to build a computing environment where Python is the glue of all the astro-related tools (PyRAF, stsci_python, etc.).

IRAF

In order to use PyRAF, IRAF needs to be installed first.

Python

At the very least, I want the basic Python packages related to science/data analysis:

# apt-get install python ipython python-doc
# apt-get install python-numpy python-scipy python-matplotlib

PyRAF

Install several Python packages:

# apt-get install tk8.4-dev python-tk libf2c2-dev
# apt-get install python-dev python-pmw python-urwid

Test if the required Python modules exists by making sure that no ImportError occurs below:

# python
>>> import readline
>>> import Tkinter
>>> Tkinter._test()
>>> import Pmw
>>> import urwid

If you have an installation of previous version, check the section Cleaning An Old Installation of the installation instruction at the STSci web site to make sure things are clean.

Prepare the source directory:

# mkdir /usr/local/src/python_packages/stsci_python
# cd /usr/local/src/python_packages/stsci_python

Download and extract the source:

# wget http://stsdas.stsci.edu/download/stsci_python_2.7/stsci_python_2.7.tar.gz
# gunzip -c stsci_python_2.7.tar.gz | tar xvf -
# cd stsci_python_2.7/

Normally, using python setup.py install will do the job, but it probably ends in compilation error, complaining the header file cfunc.h not found. In order to force the installation, modify setup.py in the current directory, so that at the very end of the file an additional include directory is defined:

distutils.core.setup(

    # This name is used in various file names to identify this item.
    name="stsci_python",

    # This version is expected to be compared to other version numbers.
    # It will also appear in some file names.
    version="2.7",

    # Apparently, description is not used anywhere.
    description="",

    packages = all_packages,
    package_dir = all_package_dir,
    ext_modules = all_ext_modules,
    scripts = all_scripts,
    data_files = all_data_files,
    include_dirs = ['/usr/lib/python2.5/site-packages/numpy/numarray/numpy']
)

Then we can follow the normal instruction:

# python setup.py install
# cd stscidocs
# python setup.py install

Before running PyRAF for the first time, clear the cache by removing directories under your “pyraf” directory, which is located in where you have your loginuser.cl for IRAF.

That’s it!

Friday, April 17, 2009

IRAF on Debian Lenny

Filed under: Debian, Lenny, Linux, Research — nomo17k @ 15:54

Here is my installation note for IRAF (ver 2.14.1) on Debian Lenny.

Basically, the installation procedure does not differ much from the one outlined in the official IRAF installation guide.

First, create “iraf” user account to the system if it does not exist already. Also, install the C shell (csh) as it appears to be the preferred shell for IRAF (people apparently don’t know when to move on).

$ sudo apt-get install csh ncompress
$ sudo adduser iraf

After user “iraf” has been added to the system, change its home directory and the default shell by modifying /etc/passwd to read:

iraf:x:1002:1002:IRAF Admin,,,:/iraf/iraf/local:/bin/csh

Note that the number 1002 may be different depending on how many users already have the accounts on the system. Only change the last two entries delimited by colon to /iraf/iraf/local and /bin/csh.

We assume IRAF will be installed under /usr/local/iraf, and a symlink /iraf points to that directory:

# mkdir /usr/local/iraf
# chown iraf /usr/local/iraf
# chgrp iraf /usr/local/iraf
# ln -s /usr/local/iraf /iraf

Login as user “iraf,” and create a bunch of directories:

# su iraf
% cd /usr/local/iraf
% mkdir extern imdirs iraf irafbin x11iraf
% mkdir irafbin/bin.linux
% mkdir irafbin/noao.bin.linux

Install x11iraf. You may use the pre-built binary distribution:

% cd /usr/local/iraf/x11iraf
% wget http://iraf.noao.edu/x11iraf/x11iraf-v2.0BETA-bin.redhat.tar.gz
% gunzip -c x11* | tar xvf -
% su
# ./install
# exit

and select defaults for all the user input upon installation. (Note that if xgterm quits on an error complaining about “ptys,” then you may need to turn on the kernel configurations CONFIG_LEGACY_PTYS and CONFIG_UNIX98_PTYS; yes, you may need to rebuild the kernel…)

Install the source:

% cd /usr/local/iraf/iraf
% wget http://iraf.noao.edu/iraf/ftp/iraf/v214/PCIX/as.pcix.gen.gz
% gunzip -c as.pcix.gen.gz | tar xvf -

Install the binaries:

% cd ../irafbin/bin.linux
% wget http://iraf.noao.edu/iraf/ftp/iraf/v214/PCIX/ib.lnux.x86.gz
% gunzip -c ib.lnux.x86.gz | tar xvf -

% cd ../noao.bin.linux
% wget http://iraf.noao.edu/iraf/ftp/iraf/v214/PCIX/nb.lnux.x86.gz
% gunzip -c nb.lnux.x86.gz | tar xvf -
% exit

Run the install script:

# su iraf
% cd $iraf/unix/hlib
% source irafuser.csh
% su
# ./install

Follow the instruction for the most part, but the following are not necessary: IRAF networking and tapecap device.

# exit
% cd
% source .login
% rehash
% cl

This should start ecl.

For exposing external packages (which must already be installed if not already) within IRAF, the text file extern.pkg can be reused if these packages are already installed. Copy it from a previous installation to /usr/local/iraf/iraf/unix/hlib.

# External (non core-system) packages.  To install a new package, add the
# two statements to define the package root directory and package task,
# then add the package helpdb to the `helpdb' list.

reset	noao		= iraf$noao/
task	noao.pkg	= noao$noao.cl

reset	tables		= /iraf/extern/tables/
task	tables.pkg	= tables$tables.cl

reset	mscred		= /iraf/extern/mscred/
task	mscred.pkg	= mscred$mscred.cl

reset	stsdas		= /iraf/extern/stsdas/
task	stsdas.pkg	= stsdas$stsdas.cl
task	apropos		= stsdas$apropos.cl

reset	rvsao		= /iraf/extern/rvsao/rvsao-2.5.0/
task	rvsao.pkg	= rvsao$rvsao.cl

reset	xdimsum		= /iraf/extern/xdimsum/
task	xdimsum.pkg	= xdimsum$xdimsum.cl

reset	fuzzy		= /iraf/extern/fuzzy/
task	$fuzzy.pkg	= fuzzy$fuzzy.cl

set	crrefer		= "/home/astro_data/stsci_data/"

reset   helpdb          = "lib$helpdb.mip\
                          ,noao$lib/helpdb.mip\
                          ,tables$lib/helpdb.mip\
                          ,stsdas$lib/helpdb.mip\
                          ,mscred$lib/helpdb.mip\
                          ,rvsao$lib/helpdb.mip\
			  ,xdimsum$lib/helpdb.mip\
                          "

keep

You can simply comment out lines with “#” if some packages are not installed.

The packages stsdas and tables should be installed following the official instruction.

Thursday, April 9, 2009

Updating Flash BIOS off a Bootable CD

Filed under: Linux — nomo17k @ 17:34

Note: These days, computers ship without floppy drives by default, so there may exist a better generic procedure for updating flash BIOS. This instruction is just kept for a historical reason.

Flashing BIOS can be dangerous. A typical disclaimer of the process applies.

First, download a DOS bootdisk image (win98-boot.img — missing for now while I find a semipermanent online disk space — can be useful) and the BIOS update program, e.g., BIOSUPDT.EXT, from the BIOS vendor to a directory (say ~/tmp for an illustration).

Mount the DOS image and copy the BIOS update program as follows:

# cd ~/tmp
# mkdir mnt
# mount -o loop -t vfat win98-boot.img mnt
# cp BIOSUPDT.EXE mnt
# umount mnt

Make a CD ISO image:

# mkisofs -o image.iso -b win98-boot.img win98-boot.img

Burn the ISO image to a blank CD. Boot from the CD and you should simply run the BIOS update program from DOS.

Search for Files Containing a Text

Filed under: Linux — nomo17k @ 17:14

Here is a little BASH script (which I name findstr) to search for the files containing a specified string:

#!/usr/bin/env bash
##############################################################################
# findstr
#
# Search for files containing a specified string.  Show the file path,
# line number, and the line itself containing a specified string.
#
# EXAMPLE:
#
# To search for all the files with the file extension .html containing
# a string "body" under the current directory and all its
# subdirectories, do:
#
#   $ findstr . "*.html" "body"
#

find $1 -name \*$2 -exec grep -nH "$3" {} \;

IRAF Tips

Filed under: Linux, Research — nomo17k @ 16:59

Printing Out Help

When printing out a help for an IRAF task name iraftask, you may want to save papers by multicolumn printing using a2ps.

cl> help iraftask | type dev=text > iraftask.txt
cl> !a2ps iraftask.txt -2 --medium=letter -o iraftask.ps

The generated .ps file should be printed out.  Note that this doesn’t appear to work well on PyRAF, in which escape sequences do not appear to be parsed.

Changing Page Size of a PostScript Document

Filed under: Linux — nomo17k @ 16:55

For scaling a postscript page size, do:

$ psresize -Pa4 -pletter src.ps > dst.ps

To generate a letter-sized output as a PDF document, do:

$ dvips -t letter doc.dvi -o doc.ps
$ ps2pdf14 -sPAPERSIZE=letter doc.ps

Reducing the Number of Pages of a PostScript Document

Filed under: Linux — nomo17k @ 16:53

To save papers, sometimes it is desired to to collect multiple pages into a page on printing a postscript file. Use mpage command to generate a new postscript file:

$ mpage -2 -c paper.ps > paper_2pg.ps
$ lpr -Pprinter paper_2pg.ps

Merging Two Text Files Line by Line

Filed under: Linux — nomo17k @ 16:48

Say you have two text files (text1.txt and text2.txt) with data:

# x     y
1.0   1.0
2.0   4.0
3.0   9.0
# x     z
1.0   1.0
2.0   8.0
3.0  27.0

If you wish to merge these files line by line, use paste:

$ paste text1.txt text2.txt > merged.txt

This will create a text file like this one:

# x     y   # x     z
1.0   1.0   1.0   1.0
2.0   4.0   2.0   8.0
3.0   9.0   3.0  27.0

Mirror a Website using wget

Filed under: Linux, Web — nomo17k @ 16:44

To mirror a website below a certain directory level, use wget. For example, let’s say you want to mirror everything below some directory in a web site: http://site/a/b/. Then the directory “b” is two levels below the top most level, so you need to specify “2″ for –cut-dirs option. Hence

$ wget -m -E -nH -np --cut-dirs=2 http://site/a/b/

should download all the downloadable contents under the current local directory.

Next Page »

Blog at WordPress.com.