#!/bin/csh -f #++++++++++++++++ #.IDENTIFICATION Vgraph #.LANGUAGE C-shell #.AUTHOR Francois Ochsenbein [CDS] #.ENVIRONMENT VizieR #.KEYWORDS #.VERSION 1.0 02-Jun-2001 #.VERSION 1.1 14-Jul-2001: Accept thePro #.VERSION 1.2 20-Oct-2004: Requires LD_LIBRARY_PATH #.VERSION 1.3 11-Feb-2007: Accept theCat=. to call link/elodie #.VERSION 1.4 18-Jan-2010: -notitle (don't issue the title) #.VERSION 1.41 15-Jul-2011: Wpop added when pop-up window #.VERSION 1.42 09-Oct-2011: better plot without .graph file #.VERSION 1.43 28-Apr-2012: Addition colors photometry #.VERSION 1.44 16-Jul-2014: Remove /tmp/Vgraph.arg when too large (1M) #.PURPOSE Generate Graphs / Plots #.COMMENTS This program is meant for the execution of plots in VizieR. # It is called from vizExec or vizPlot. # Therefore, when this program is called, I'm in the catalogue # directory, and the following variables are defined: # - theCat = name of catalog (. for an external link) # - theTab = name of table (eventually) # - thePro = name of Prgram to execute to generate ascii table eg fits2a # - SCRIPT_NAME PATH_INFO etc.. (HTTPD variables) # Also defines the variables # HTTP_PLOT = name of the plotting program (to call via ) # GRAPH_ARG = default definitions for the plots. # This program calls the .graph file in the catalogue directory, # and executes or source's it # On input, PATH_INFO is always set to /Vgraph[/gif|ps|...] # Also defines ADAPTED when was called after adaptform #---------------- setenv HTTP_PLOT /viz-bin/nph-Plot setenv GRAPH_ARG \ "-C -f 0.04 -h 0.85 -w 0.75 -u 0.125 -r 0.175 --title-font-size 0.05" if (! $?SCRIPT_NAME) setenv SCRIPT_NAME $0 if (! $?CATS) setenv CATS /ftp/cats if (! $?PATH_INFO) setenv PATH_INFO "/Vgraph" if (! $?Vroot) setenv Vroot /usr/httpd # Or ~cds/httpd... if (! $?local) then set local = 0 if ($SCRIPT_NAME =~ /local/* ) then set local = 1 endif endif if ($?theTab) then echo2 "#---Vgraph($theCat /./ $theTab) SCRIPT_NAME=$SCRIPT_NAME" #echo2 "#---Vgraph: theTab=$theTab" else echo2 "#---Vgraph($theCat) SCRIPT_NAME=$SCRIPT_NAME" endif if ($SCRIPT_NAME =~ */Vbin/*) then #echo2 $SCRIPT_NAME setenv HTTP_PLOT /Vbin/nph-Plot setenv METADB "metaviz@VIZIR asu asu4VizieR" #set verbose endif if ($local) then setenv Vaccess '*' setenv HTTP_PLOT /local$HTTP_PLOT if (-w /tmp/Vgraph.arg ) then set s = `ls -l /tmp/Vgraph.arg | awk '{print $5}'` if ($s > 1048576) then echo2 "#+++Large file /tmp/Vgraph.arg ($s bytes) -- removing" rm -f /tmp/Vgraph.arg; touch /tmp/Vgraph.arg endif else touch /tmp/Vgraph.arg endif (echo ""; echo "----Arguments to Vgraph `date`") >> /tmp/Vgraph.arg echo PATH_INFO=$PATH_INFO >> /tmp/Vgraph.arg #ls -l `which cgigraph` >> /tmp/Vgraph.arg #printenv|sort >> /tmp/Vgraph.arg endif @ i = 1 while ($i <= $#argv) echo "arg#$i=$argv[$i]" >> /tmp/Vgraph.arg @ i += 1 end endif ### Add for Graph if (-x $Vroot/bin/libplot.so) then if ($?LD_LIBRARY_PATH) then setenv LD_LIBRARY_PATH $Vroot/bin:$LD_LIBRARY_PATH else setenv LD_LIBRARY_PATH $Vroot/bin endif endif #echo2 $PATH_INFO set tmp = `echo $PATH_INFO | sed 's%/*V*g*r*a*p*h*[^/]*/*%%'` setenv Vgraph $tmp # Definition of VizieR url setenv PATH_VIZ `echo $SCRIPT_NAME | sed 's%/vizExec.*$%%'` # Colors are defined in graph_color #set verbose ################################################################## # The first step: no PATH_INFO -- was called from vizExec # The output from .graph is HTX # Macros: # \graph{HTML-arguments}{graph arguments} # \Agraph{graph arguments}{text of link} ################################################################## if ("$Vgraph" == "") then unsetenv Vgraph if ($?Wpop) then setenv PATH_INFO "$Wpop/$PATH_INFO" # Added V1.41 if (! $?BITMAPSIZE) then setenv BITMAPSIZE 600x400 endif endif #if ("$1" =~ -graph*) then # setenv ADATPED 1 # eval "`cgigraph -csh $argv:q`" #endif #echo "\def\adaptGraph{" #cgigraph -htx $argv:q #echo "}" #### PROBLEM on LINUX, echo interprets sequences... cat <<====Vdef \def\graph#1#2{\tag{IMG #1 SRC='$HTTP_PLOT/Vgraph/gif?\htarg{#2}'}} \def\Agraph#1#2{\A{$HTTP_PLOT/Vgraph/#1}{#2}} \def\vFile#1#2{\A{/viz-bin/getCatFile?#1}{#2}} \def\aFile#1#2{\A{/viz-bin/nph-Cat?-plus=-+\}{#2}} \def\vizier#1#2{\W{_blank}{$PATH_VIZ/VizieR?#1}{#2}} \def\section#1{\subsection{\quad #1}} % Otherwise takes too much space ====Vdef #echo '\def\graph#1#2{\tag{IMG #1 SRC='$HTTP_PLOT/Vgraph/gif?\htarg{#2}'}}" #echo "\def\Agraph#1#2{\A{$HTTP_PLOT/Vgraph/#1}{#2}}" #echo "\def\vFile#1#2{\A{/viz-bin/getCatFile?#1}{#2}}" # EXternal linkS if ("$theCat" == .) then echo2 "#---Vgraph: theCat=$theCat, theTab=$theTab, args=($*)" set prog = `echo $theTab | acut -d/ -f1-2` set arg1 = "`echo $theTab | acut -d/ -f3-`" exec $Vroot/cgi/$prog -Vgraph $argv:q endif if (-x .graph) exec .graph $argv:q if (-r .graph) then source .graph exit $status endif # How to do is not explained... # Accept when a Table is specified AND -graph is specified if ($?theTab) then if ("$*" !~ *-gra*) set argv = (-graph $argv:q) goto defGraph endif echo "Plot Generation ($#argv arguments: $*)" echo "****Problems with .graph file in $cwd" ls -la .graph |& cat exit 1 endif ################################################################## # Second call (normally initiated by nph-Plot) ################################################################## switch("$Vgraph") case "gif": echo "Content-type:image/gif"; echo "" breaksw case "ps": echo "Content-type:application/postscript" echo "Content-Disposition: inline; filename='$*.ps'" echo "" breaksw case "htm*": echo "Content-type:text/html"; echo "" breaksw case "htx": echo "Content-type:text/htx"; echo "" breaksw case "txt/*" case "txt": echo "Content-type:text/plain"; echo "" #set verbose breaksw default: set error_title = "'$Vgraph' option" set error_text = "Related to $cwd" goto vizError endsw # EXternal linkS if ("$theCat" == .) then echo2 "#---Vgraph: theCat=$theCat, theTabl=$theTab args=($*)" set prog = `echo $theTab | acut -d/ -f1-2` set arg1 = "`echo $theTab | acut -d/ -f3-`" if ($local) echo2 "#==>exec $Vroot/cgi/$prog -Vgraph $argv:q" exec $Vroot/cgi/$prog -Vgraph $argv:q endif if (-x .graph) exec .graph $argv:q if (-r .graph) then source .graph exit $status endif goto defGraph defGraph: ################################################################### # Default Graph -- -graph specified. theTab is defined. ################################################################### fcat -f "$theTab" if ($status) then set error_title = "Missing file?" set error_text = "The file {\bf $theTab} is unreadable" goto vizError endif if ("$*" =~ *-graph*) then #echo2 "Executing cgigraph -csh $argv:q" #set verbose cgigraph -csh $argv:q > /tmp/s$$; if ($local) then echo "" >> /tmp/Vgraph.arg echo "----Result of cgigraph -csh:" >> /tmp/Vgraph.arg cat /tmp/s$$ >> /tmp/Vgraph.arg endif source /tmp/s$$; rm /tmp/s$$ #eval "`cgigraph -csh $argv:q`" # Gives a problem endif if (! $?Vgraph) then if ($local) echo1 "{\fg{red4}There are $#argv arguments: $*}" if ($#argv>0) then if ("$1" =~ "-notit"*) then shift else if ($?Wpop) then echo1 "\centerline{\large\bf{File {\fg{red3}$theTab}}}" else echo1 "\centerline{\subsection*{File {\fg{red3}$theTab}}}" endif endif if ($local) then echo "" >> /tmp/Vgraph.arg echo "----Arguments to cgigraph -form -htx -graph" >> /tmp/Vgraph.arg @ i = 1 while ($i <= $#argv) echo "$argv[$i]" >> /tmp/Vgraph.arg @ i += 1 end endif #echo cgigraph -form -htx -graph $argv:q > /tmp/Vgraph.arg cgigraph -img -ps:"Postscript Plot" -txt:"Data as an ascii table" \ -cap:"<&getCatFile.w $theCat/$theTab|Original file>" \ -form -htx -graph $argv:q exit $status endif #set verbose if (! $?thePro) then setenv thePro cat if ($theTab =~ *.fit*) setenv thePro fits2a endif set plotarg = \ "-C -f 0.0375 -h 0.85 -w 0.75 -u 0.125 -r 0.20 --font-name Arial --font-size 0.05" #eval `cgigraph -csh $argv:q` # This generates an error with * cgigraph -csh $argv:q > /tmp/s$$ ; source /tmp/s$$ if ($local) then echo2 "#---Vgraph: sourcing /tmp/s$$ :" cat2 /tmp/s$$ echo2 "#---Vgraph: sourcing /tmp/s$$ (end)" endif rm /tmp/s$$ if ($#argv>0) then if ("$1" == "-notitle") shift endif #echo2 "fcat '$theTab' | $thePro | graph -T $Vgraph $plotarg $argv:q" fcat "$theTab" | $thePro | graph -T $Vgraph $plotarg $argv:q exit $status vizError: ################################################################### # Error Messages -- in case something went wrong... ################################################################### #echo "Content-type: text/html" #echo "" set tt = /tmp/v-e.$$ if ("$error_title" == "") then set error_title = "(Unspecified Error)" endif if (! $?error_text) then set error_text = "" else set error_text = "\par{\fg{Red}\bf $error_text}" endif #set verbose touch $tt cat <<====vizError >> $tt \title{VizieR Error} \tag{BODY bgcolor="\#ffe0e0"} %\large \centerline{{ \Large\bf Dedicated Vgraph link error }} {\large\em The following unexpected problem occured in {\bf VizieR}}:\thickrule $error_title:q $error_text:q {\em \Aglutag{question "Vgraph/$PATH_INFO?theCat" "francois@simbad.u-strasbg.fr"} {Problem report:} Please insert in your message the input detailed below:} \par {\tt PATH_INFO=$PATH_INFO \break cwd=$cwd \break ====vizError if ($#argv < 1) then echo "(empty string) \\" >> $tt endif while ($#argv > 0) echo "'$1' \\" >> $tt shift end if ($local) then ( echo "\begin{verbatim}"; printenv | sort -d ; echo "\end{verbatim}" ) \ >> $tt endif echo "}\par\CDStail{Vgraph}" >> $tt if (! $?cat1) then set cat1 = cat endif #which cgiprint ; which glufilter #echo "----Contents of $tt" ; echo "
"; cat $tt ; echo "
" #$cat1 $tt | cgiprint -tex -glu | glufilter -D "CDS'/usr/local/glu/vizier.dic" $cat1 $tt #echo $tt rm -f $tt exit 1