This is a README file for the fits2pg 1.0 program, written by Jure Skvarc. ========================================================================== Fits2pg is a simple program which fills a PostgreSQL 6.3 database with information from astronomical image files, stored in a FITS format. Each record in the database contains several values from the FITS header as well as the FITS file name, the directory, the mount point of the archival medium, the archive name or number, the name (or rather email) of the person who put the image into the database, an arbitrary comment and the time when the images information was inserted into the database. Additionally, if the WCS keywords are present, fits2pg calculates the coordinates or the image center. There are some conditions which have to be fulfilled if you want to use the fits2pg program. First of all, a working postgres 6.3 or later must run on the computer chosen as a server. This does not have to be the local computer because it is possible to specify a remote server address. Before we start using the database, it has to be created. This is done simply by a command from the Unix shell: % createdb images As we see, the database name is assumed to be "images" what is also the default value in the fits2pg program. In principle, it can also be some other name which has to specified when we run fits2pg. Also, is this example (and others) it is assumed the we run the database server locally and that the user is allowed to create databases. Now we need to create the tables used by the fits2ps. This is done from the Unix command line: % psql images -f baza_podatkov.txt or from the psql prompt after we connect to the images database by: images=> \i baza_podatkov.txt As you probably guessed, the file "baza_podatkov.txt" contains the definition of tables used in the "images" database. The main table is also called "images". It contains the following fields: imageID int4, -- Unique image ID mount text, -- name of the mounting point archivename text, -- Archive name path text, -- path relative to the mount point filename text, -- name of the FITS file bitpix int2, -- BITPIX value naxis1 int2, -- image size in x direction naxis2 int2, -- image size in y direction bzero float4, -- bscale float4, -- from the FITS header projection char(4), -- projection type (such as -TAN) crval1 float8, -- Coordinates and reference pixels crpix1 float8, -- . cdelt1 float8, -- . crval2 float8, -- . crpix2 float8, -- . cdelt2 float8, -- . crot float8, -- . radecsys char(5), -- . ra float8, -- right ascension of middle pixel dec float8, -- declination exposure float4, -- exposure time (in seconds) date_mid datetime, -- time of mid-exposure mjd float8, -- modified julian date of observation insert_date datetime, -- date and time when the record was inserted filter text, -- filter used origin text, -- location of the observing site instrument text, -- CCD camera type (most likely) telescope text, observer text, -- Observer name(s) email text, -- contact email comment text -- Comment inserted by a user The value of the date_mid field contains the time of middle of exposure and is calculated from the time related keywords in the FITS header. Since there is no standard which keywords define the time of observation, there is no guerantee the fits2pg will calculate date_mid correctly. It may be necessary to change the fits2pg sources to accomplish this. Fits2pg can take any number of file names in the command line. It will try to read them and insert the information into the database. It is also possible to specify files compressed by gzip, compress and fcompress programs. The command line options are the following: -l filename name of the log file (default stdout) -s server Internet address of the server (default local) -d database database name (default images) -p port port number (default 5432) -a archive archive name (no default) -e email email address (no default, but it is read from FITS header if it exists) -c "comment" comment -v verbose mode In the verbose mode fits2pg writes to stdout everything it reads from header and the SQL command used for the insertion of data. Now let's see some examples, 1. We are in the directory full of FITS files, some of them are compressed with the gzip program. % fits2pg -v -a Asteroids1 -e jure.skvarc@ijs.si -m /cdrom *.fts *.fts.gz Here fits2pg will populate the database images (the default) on the local server with all *.fts and *.fts.gz files. It will also write the value "Asteroids1" into the archivename field and "jure.skvarc@ijs.si" into the email field. The email value specified in the command line overwrites the one that may have been present in the FITS header. 2. We have a CDROM full of FITS files compressed with gzip and stored in different directories and we want to put all of them into the database. The archive name should be "Asteroids2". % find /cdrom/ -name "*.fts" -exec ./fits2pg -v -a Asteroids2 -m /cdrom {} \; 3. Now we want to check how many images do we have in the database. From the psql command line: images=> select count(*) from images; count ----- 5706 (1 row) 4. How many archive CDROMs we have and how many images are on each of them? images=> select archivename, count(*) from images group by archivename; archivename|count -----------+----- ACIT10 | 299 ACIT11 | 363 ACIT12 | 203 ACIT13 | 321 ACIT14 | 382 ACIT15 | 364 ACIT2 | 1852 ACIT3 | 353 ACIT4 | 186 ACIT5 | 337 ACIT6 | 330 ACIT7 | 315 ACIT8 | 202 ACIT9 | 199 (14 rows) 5. How many images without WCS keywords are there in the database? images=> select count(*) from images where projection='none'; count ----- 147 (1 row)