Numerical Relativity @ Penn State Numerical Relativity @ Penn State
Numerical Relativity @ Penn State

Ken's Computer Tips

Setting the default line colors in gnuplot 25 Nov. 2002
Numerical Relativi
ty @ Penn State

Gnuplot has this nasty default behavior where the first three colors chosen for a line are red, green, and blue (which isn't that bad), but the next colors are magenta, cyan, etc. which are far too faint to be of much use on screen or paper. Here's how to change this.

Create or edit a .Xdefaults file in your home directory. Add to it lines such as those below that tell gnuplot about what colors to use, line styles, and so on. The gnuplot man page offers plenty of options:

       For color displays gnuplot honors the following  resources
       (shown  here with default values). The values may be color
       names in the X11 rgb.txt file on your system,  hexadecimal
       RGB  color  specifications  (see  X11 documentation), or a
       color name followed by a comma and an intensity value from
       0  to 1. For example, blue,.5 means a half intensity blue.

       gnuplot*background: white
       gnuplot*textColor: black
       gnuplot*borderColor: black
       gnuplot*axisColor: black
       gnuplot*line1Color: red
       gnuplot*line2Color: green
       gnuplot*line3Color: blue
       gnuplot*line4Color: magenta
       gnuplot*line5Color: cyan
       gnuplot*line6Color: sienna
       gnuplot*line7Color: orange
       gnuplot*line8Color: coral
There's a good deal more options that one can set there, but for further details, look it up in the gnuplot man page.

Note: The .Xdefault file should exist on the machine which you wish to use to display X windows. In other words, if your desktop machine is machineA and you secure shell into machineB where your data is located, launching gnuplot on machineB will use the parameters defined in .Xdefaults on machineA. Simply put, create your .Xdefaults file on your desktop machine and you won't go wrong.

Using kprinter to print/ create PDF/ create PS 21 Oct. 2002
Numerical Relativi
ty @ Penn State

Regardless of your window manager/ desktop environment of choice, if you have KDE installed on your Linux system (as all of our NR machines do), you can make use of one of the handier KDE programs, namely kprinter.

kprinter is simply a graphical front-end to the printing system of your choice, typically lpr. To use it, simply modify your application's print command to use kprinter instead of lpr, or use kprinter directly from the command line to print a postscript file.

The usefulness of this application comes in that you can:

  • Graphically select which printer to which you'd like your job directly via a pull-down menu
  • Select to print directly to a postscript file
  • Select to print directly to a PDF file (and have it come out looking nice)
  • Choose the pages to print, number of copies, and number of pages you want per side of paper.

To print from gv, acroread, xpdf, xdvi, or the like, change the print command from lpr to kprinter.

To print from Netscape or Mozilla, change the print command to read:
kprinter --stdin

As mentioned above, to choose where to direct the job, or to which type of file you wish to print, use the pull-down menu. To select the pages, number of copies, etc., click on the "Expand" button in the lower left-hand corner, and click on the "Copies" tab. To choose how many pages you want printed per side of paper, click on the "Properties" tab in the upper-right hand corner (essentially equivalent to mpage.

In summary, kprinter is a quick way of performing a lot of common print-related tasks without having to concern yourself with the various commands necessary to get the desired output.

Creating a PDF from scanned images 01 Oct. 2002
Numerical Relativi
ty @ Penn State

From time to time, we would like to create a PDF file from a collection of scanned images. This typically involves a collection of workarounds or having the full (commercial) version of Adobe Acrobat. Here's a fairly straightforward method I've come across for creating reasonably sized PDF's from scanned images.

For the purposes of this tip, I'm going to assume that you already have scanned in your files (in say, .jpg or .tiff formats) and they are named with a common prefix and ascending numbers (although this is not a strict requirement).

First, you're going to convert each image separately into its own PDF. At this time, I'd recommend using the free online service DocMorph. It allows you to upload images one or several at a time, and convert to PDF, convert to a multi-paged TIFF, and even to run an OCR (Optical Character Recognition) engine over it to get a text file or a synthesized voice reproduction. This site is great for a small (say, < 5) number of pages. For a larger number, find a Windows machine and download the companion to DocMorph, MyMorph.

MyMorph will convert individual images to individual PDF's and does a phenomenal job of keeping the file size small! Use this to convert all your images to PDF's. It is unfortunate that only a Windows version is available, but I'd say that its performance outweighs this inconvenience.

Now you have a collection of sequential PDF files. We're going to use Ghostscript to splice these individual files into a single PDF. This can be done on any platform with Ghostscript installed, but for simplicity, I only mention how I did it with Linux - your mileage may vary.

cd to the directory where your individual PDF's currently reside. Type:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf -dBATCH input001.pdf input002.pdf input003.pdf ...

where output.pdf and inputXXX.pdf are tailored to your situation. (You can also use wildcards such as input*.pdf). And that's it! Open the resulting file in xpdf or acroread and see how it looks.

2003 The Pennsylvania State University
NR webmaster(s)