#!/proj/ned/tools/bin/perl $conv = "/proj/ned/tools/bin/conv"; #Before running this script, prepare input data file called "add_new_im.in" (refer to "w3ned.html" in this directory). # and replace in the next line "z.in" by that name # DO NOT FORGET to add soft link to zwicky:/usr1/HttpDev/Docs and zwicky:/usr1/Http/Docs # to where your NEW directory is( if it is new) # Also do not forget to change name of the TABLE you are inserting data !!!! # in this program open (file2, "tbl2"); open (file4, ">cp_fits"); open (file5, ">cp_gif"); open (file6, ">objname"); open (file8, ">fits2gif"); open (file9, ">fits2gif.sv"); open (file10, ">coord1950"); open (file11, ">coord1950c"); open (file12, ">coord2000c"); open (file14, ">coord2000.out"); open (file15, ">isql_name"); open (file18, ">isql_coord"); print file8 "ct 1\n\n"; print file9 "/imaging/config/beta/bin/skyview -n < fits2gif\n"; print file15 ("\n"); print file18 ("#!/proj/ned/tools/bin/perl\n"); #print file18 ("#before running this script, do 'du -sk' for each *.fits file and replace 'X' in 'bytes = X' below with it's file size in kb\n\n"); print file18 ("use DBI\;"); print file18 ("\$database = \"w3ned\\\@rmt_virgo\"\;\n"); print file18 ("\$dbh = DBI->connect(\"dbi:Informix:\$database\",'', '',)\;\n"); $count = 0; while (){ ($name1[$i], $obj[$i], $name2[$i], $ref[$i], $bandpass[$i], $band[$i], $lam[$i], $dlam[$i], $clam[$i], $cdlam[$i], $ra1[$i], $dec1[$i], $pixel[$i], $fwhm[$i], $exp[$i], $tel[$i], $naxis[$i], $naxis1[$i], $fov1[$i], $naxis2[$i], $fov2[$i], $size[$i], $fname[$i],$url[$i], $wcs[$i]) = split(/,/); debug: print ("\$ra1[$i]=$ra1[$i], \\$dec1[$i]=$dec1[$i]\n"); $ra1[$i] =~ s/ +//g; $dec1[$i] =~ s/ +//g; $fov1[$i] =~ s/ +//g; $url[$i] =~ s/ +//g; $url[$i] =~ s/\n//g; $fits_name = $fname[$i]; $fits_gz_name = "$fname[$i]" . ".gz"; $gif_name = $fname[$i]; $gif_name =~ s/\.fits/\.gif/g; $name1[$i] =~ s/ +//g; printf file6 ("%s\n", $name1[$i]); # printf file15 ("fov1 = %s, fov2 = %s, bytes = X where galaxy = '%s'\")\;\n", $fov1[$i], $fov2[$i], $name1[$i]); $ra2 = "$ra1[$i]" . "d"; $dec2 = "$dec1[$i]" . "d"; printf file10 ("$conv -decdeg %s %s equ J2000 equ B1950\n", $ra2, $dec2); printf file11 ("$conv -sexhrs %s %s equ J2000 equ B1950\n", $ra2, $dec2); printf file12 ("$conv -sexhrs %s %s equ J2000 equ J2000\n", $ra2, $dec2); printf file14 ("%s %s\n", $ra1[$i], $dec1[$i]); $data = "data" . "$count"; $count += 1; #Making input for Skyview to dump FITS to GIF # if ($fov1[$i] < 20){ if ($naxis2[$i] < 299){ print file8 "pa $fits_name\n"; print file8 "md $gif_name\n"; print file8 "er\n\n"; } # elsif ($fov1[$i] >= 20 && $fov1[$i] < 40){ else { $koef=1/($naxis2[$i]/200.); print file8 "pa $fits_name\n"; print file8 "zp $koef\n"; print file8 "border 0\n"; print file8 "md $gif_name\n"; print file8 "er\n\n"; } $wcs[$i] =~ s/\n//; printf file18 ("\$rv = \$dbh->do(\"insert into dtimages (galaxy, obj_type, obj_name, refcode, bandpass, band, lambda, clambda, pix_scale, fwhm, exptime, telescope, naxis, naxis1, fov1, naxis2, fov2, bytes, url, wcs, values ('%s', '%s', '%s', '%s', '%s', '%s', %s, '%s', %s, %s, %s, '%s', %s, %s, %s, %s, %s, %s, '%s', %s,\n", $name1[$i], $obj[$i], $name2[$i], $ref[$i], $bandpass[$i], $band[$i], $lam[$i], $clam[$i], $pixel[$i], $fwhm[$i], $exp[$i], $tel[$i], $naxis[$i], $naxis1[$i], $fov1[$i], $naxis2[$i], $fov2[$i], $size[$i], $url[$i], $wcs[$i]); } print file15 ("\n\n"); close (file14); close( file12); close (file11); close (file10); close (file9); close (file8); close (file7); close (file6); close (file5); close (file4); close (file3); close (file2); #print "Done Writing cp_fits that copies all fits.gz file to the corresponding dss1 directory\n\n"; #print "Done Writing cp_gif that copies all gif file to the corresponding dss1 directory\n\n"; print "Done Writing galaxy name into objname\n\n"; print "Done Writing fits2gif that generates gif files using sv\n\n"; print "Now converting J2000 decimal degree coordinates into J2000 sexhrs, B1950 decdeg and sexhrs coordinates \n\n"; system ("chmod 755 coord*"); system ("coord1950 > coord1950.out"); system ("coord1950c > coord1950c.out"); system ("coord2000c > coord2000c.out"); system ("paste coord1950.out coord2000.out > j1; paste j1 coord1950c.out > j2; paste j2 coord2000c.out > coord.out"); open (file17, "coord.out"); while (){ ($ra1950[$i], $dec1950[$i], $ra2000[$i], $dec2000[$i], $cra1950[$i], $cdec1950[$i], $cra2000[$i], $cdec2000[$i]) = split(' '); # CHANGES made by Olga to get rid of letter "d" in dec 1950 coordinates after conversion $ra1950[$i] =~ s/d//g; $dec1950[$i] =~ s/d//g; $cra1950[$i] =~ s/[0-9][0-9][0-9]s/s/g; $cdec1950[$i] =~ s/[0-9][0-9][0-9]s/s/g; $cra2000[$i] =~ s/[0-9][0-9][0-9]s/s/g; $cdec2000[$i] =~ s/[0-9][0-9][0-9]s/s/g; printf file15 ("ra1950, dec1950, ra2000, dec2000, cra1950, cdec1950, cra2000, cdec2000) %s, %s, %s, %s, '%s', '%s', '%s','%s')\"\);\n", $ra1950[$i], $dec1950[$i], $ra2000[$i], $dec2000[$i], $cra1950[$i], $cdec1950[$i], $cra2000[$i], $cdec2000[$i]); } print file18 ("\$dbh->disconnect\;\n"); print file18 ("exit\;\n"); close (file18); close (file17); close (file16); close (file15); system ("paste isql_coord isql_name > add_new_im2.pl"); system ("chmod 755 *.pl;chmod 755 fits2gif.sv"); #Kim was using gzipped FITS #system ("ls -l *.fits.gz > fits.list1;sort +4 -5 fits.list1 > fits.list2;head -1 fits.list2 > fits.list3"); #Make output from 'ls -l', sort it on file size, and check size of #smallest file. #Ex: -rw-rw-rw- 1 daou ned 66240 Jul 27 14:47 UGC_12808:I:H:d1996.fits system ("ls -l *.fits > fits.list1;sort +4 -5 fits.list1 > fits.list2;head -1 fits.list2 > fits.list3"); open (file12, "fits.list3"); while (){ ($data1[$i], $data2[$i], $data3[$i], $data4[$i], $data5[$i], $data6[$i], $data7[$i], $data8[$i], $data9[$i]) = split(' '); if ($data5[$i] < 2500){ #Check the file size. To do this right, check NAXIS1*NAXIS2*BITPIX. print "Exiting since ONE OF THE FITS FILES CONTAINS NULL DATA\n"; close (file12); exit(1); } else{ #print "Ungzipping *.fits.gz\n\n"; #system ("gunzip *.fits.gz"); # print "Generating gif images\n\n"; # system ("fits2gif.sv"); # print "Gzipping *.fits\n\n"; # system ("gzip *.fits"); # We do this manually on spacemouse because we need DBI/DBD.pm # print "Updating dimage data table\n\n"; # system ("add_new_im2.pl"); } close (file12); } # cp add_new_im2.pl to spacemouse /home/daou/ned/"refcode_directory_name" `rm data*`; `rm coord*`; `rm *.list*`; `rm cp*`; `rm j1`; `rm j2`; `rm isql*`; `rm objname`; print ("echo All Done Now run add_new_im2.pl to update database.\n");