#!/bin/tcsh #+ # Purpose: # Does a few tests of the version of AST installed in $INSTALL. # Usage: # ast_tester <-nd> # Description: # Build and run various tests of an AST installation. # # Some tests produce graphical output. Postscript plots of the FITS # headers in the current directory are produced for visual comparison # with previous versions. For each file matching "*.head" in the current # directory, a file is created called "*-new.ps". This file should be # compared visually with the file "*.ps". The new files are displayed # automatically unless the -nd option is supplied on the command line # # This script assumes the gfortran compiler is available. If this is not # the case, do a global edit of gfortran to whatever fortran 77 compiler # you have available (you will probably also need to change the compiler # flags). # Options: # -nd : Suppresses display of test plots. # Prior Requirements: # - Unless the "-nd" option is specified, it requires the gv command (a # frontend for ghostscript) to be on your PATH. # - The following environment variables are used: # STARLINK_DIR - should be set to the root of the tree in which the SSC is # installed. A default of /star is used if not set. # AST - should be set to the root of the tree in which the version of # AST to be tested is installed. A default of $STARLINK_DIR is used # if not set. # Author: # DSB: David Berry (JAC, Hawaii) #- if( ! $?STARLINK_DIR ) then setenv STARLINK_DIR /star endif if( ! $?AST ) then setenv AST $STARLINK_DIR endif if( ! $?LDFLAGS ) then setenv LDFLAGS "" endif setenv PATH $AST/bin\:$STARLINK_DIR/bin\:$PATH # Build the progs #gfortran -fno-second-underscore -o regression regression.f -fno-range-check $LDFLAGS -I$AST/include -I$STARLINK_DIR/include -L$AST/lib -L$STARLINK_DIR/lib `ast_link -ems` `chr_link` gfortran -fno-second-underscore -o plotter plotter.f -fno-range-check $LDFLAGS -I$AST/include -I$STARLINK_DIR/include -L$AST/lib -L$STARLINK_DIR/lib `ast_link -pgp -ems` `pgplot_link` gfortran -fno-second-underscore -o wcsconverter wcsconverter.f -fno-range-check $LDFLAGS -I$AST/include -I$STARLINK_DIR/include -L$AST/lib -L$STARLINK_DIR/lib `ast_link -ems` `chr_link` `err_link` gfortran -fno-second-underscore -o simplify simplify.f -fno-range-check $LDFLAGS -I$AST/include -I$STARLINK_DIR/include -L$AST/lib -L$STARLINK_DIR/lib `ast_link -ems` `chr_link` `err_link` # Run the other test progs echo "" foreach prog (testmapping testchebymap testunitnormmap testskyframe testframeset testchannel testpolymap testcmpmap testlutmap testfitstable testtable teststcschan teststc testspecframe testfitschan testswitchmap testrebin testrebinseq testtrangrid testnormmap testtime testrate testflux testratemap testspecflux testxmlchan testregions testkeymap ) gfortran -fno-second-underscore -w -g -o $prog -g $prog.f -fno-range-check $LDFLAGS -I$AST/include \ -I$STARLINK_DIR/include -L$AST/lib -L$STARLINK_DIR/lib `ast_link -ems` \ `psx_link` `prm_link` `chr_link` `err_link` ./$prog \rm $prog end foreach prog (testobject testconvert testerror) gcc -o $prog $prog.c -I.. -DHAVE_CONFIG_H $LDFLAGS -L$STARLINK_DIR/lib `ast_link` ./$prog \rm $prog end # Make new plots. echo "" echo "Generating new plots..." echo "" if( $1 == "-nd" ) then echo " (but not displaying them because the -nd option was supplied)" echo "" endif \rm *-new.ps >& /dev/null foreach n (*.head) set bn = `basename $n .head` set atfile = "${bn}.attr" if( -e $atfile ) then set attr1 = `cat $atfile` else set attr1 = ' ' endif set atfile = "${bn}.fattr" if( -e $atfile ) then set attr2 = `cat $atfile` else set attr2 = ' ' endif set boxfile = "${bn}.box" if( -e $boxfile ) then set box = `cat $boxfile` else set box = ' ' endif set psfile = "${bn}-new.ps" ./plotter $n "$attr1" "$attr2" a.ps $box if( -e $STARLINK_DIR/bin/psmerge ) then $STARLINK_DIR/bin/psmerge -t300x300 -r90 a.ps > $psfile else cp a.ps $psfile endif if( $1 != "-nd" ) then gv $psfile -orientation=landscape endif end \rm -f a.ps # Make new fits headers echo "" echo "Doing WCS conversion tests..." echo "" set ok = 1 foreach n ( "timj ast fits-wcs cdmatrix=1" \ "timj ast fits-iraf" \ "timj ast fits-aips" \ "timj ast fits-pc" \ "timj ast native" \ "timj ast native" \ "a20070718_00010_02_cube ast fits-wcs" \ "dss fits-dss ast" \ "dss ast dss" \ "dss ast fits-wcs cdmatrix=1" \ "degen1 ast fits-wcs cdmatrix=1" \ "degen1 ast fits-wcs cdmatrix=1" \ "sip head fits-wcs cdmatrix=1,sipreplace=0" \ "longslit fits-pc fits-wcs cdmatrix=1" ) set a = `echo $n` set base = $a[1] set in_suffix = $a[2] set encoding = $a[3] if( $#a > 3 ) then set attrs = $a[4] else set attrs = "" endif set in_file = "$base.$in_suffix" set old_file = "$base.$encoding" set new_file = "$base-new.$encoding" ./wcsconverter $in_file $encoding $new_file "$attrs,FitsDigits=8" diff -c $old_file $new_file > ! $old_file.diff if( $status == 0 ) then \rm -f $old_file.diff $new_file else echo " $old_file and $new_file differ\!\! (see $old_file.diff)" echo " Command was:" echo " wcsconverter $in_file $encoding $new_file $attrs,FitsDigits=8" set ok = 0 endif end if( $ok == 1 ) then echo " All WCS conversion tests passed" echo "" endif echo "" echo "Doing Simplification tests..." echo "" set ok = 1 foreach n ( *.map ) set a = `basename $n .map` ./simplify $n $a.out diff -c $a.simp $a.out > ! $a.diff if( $status == 0 ) then \rm -f $a.out $a.diff else echo " $a.simp and $a.out differ\!\! (see $a.diff)" set ok = 0 endif end if( $ok == 1 ) then echo " All simplification tests passed" echo "" echo "" endif \rm -f plotter wcsconverter simplify testxmlchan