
Delivered-To: rgroman@globec.whoi.edu
Date: Mon, 14 Jun 1999 15:45:27 -0400
From: JGOFS Data System <jgofs@chips1.gso.uri.edu>

#!/bin/csh -f
#
# dsp2gif script
# 7/7/95 RCG
#
# 5/30/98 KWS
# Adds lat-lon grid and 200 meter bathymmetry on the fly, then
# it converts DSP formatted image file into gif image file as before

# Assumes QUERY_STRING is the file to be converted
# mia2gifpath is set to the directory of where the mia2gif program resides
# tmppath is set to the directory where temporary gif files will be stored
# palfile is set to the full path/file name of the pallette data file
# 
echo " from dsdp2gif QUERY_STRING = $QUERY_STRING"
set dspin=$QUERY_STRING

#set mia2gifpath=/usr/dsp/bin
set mia2gifpath=/pathfdr1/jgofs/htmlbin/bin
set tmppath=/pathfdr1/jgofs/httpd/htdocs/temp-dir
set imagepath=/pathfdr1/jgofs/httpd/htdocs/images
set palfile=/pathfdr1/jgofs/htmlbin/bin/petes.pal
set dspbinpath=/pathfdr3/dsp/bin

set tmp=`date '+%H%M%S'`
if ($REMOTE_HOST == "") then
	setenv REMOTE_HOST "tmp.host"
endif

set gifout=$tmppath/$tmp.$REMOTE_HOST.gif
#echo " gifout = $gifout"

set ext=$dspin:e

set zcatout = "no"
if ($ext == "Z") then
	set zcatout=$tmppath/$tmp.$REMOTE_HOST.zcat
	zcat $dspin > $zcatout
	chmod o+w $tmppath/*.$REMOTE_HOST.zcat
	set dspin=$zcatout
endif
########################################################################
#  		more preliminaries
########################################################################
set add_name = add
set diff_name = diff
set standard_out = "$tmppath/$tmp.$REMOTE_HOST."
#########################################################################
#		"diff" section for grid
#########################################################################
# set specified_in_1 = "$imagepath/gom_grid_image"
set specified_in_1 = "$imagepath/gom_all3_image"  # grid+bath+land
set standard_in_1 = "$dspin"
set standard_out_1 = "${standard_out}temp_1"
set tdiff_1 = "$dspbinpath/$diff_name $specified_in_1,0,245,0.0,2.0,0.,1.,0.0,1.0" 
set fdiff_1="$tdiff_1 in=$standard_in_1 out=$standard_out_1"
##########################
$fdiff_1                    # this is the entire command string
################################################################################
##################################################################################

set tempin = "$standard_out_1"	# grid in black, no bath
$mia2gifpath/mia2gif in=$tempin out=$gifout pal=\($palfile,24\)
########works but b/w only, no color /$mia2gifpath/mia2gif in=$dspin out=$gifout

chmod o+w $tmppath/*.$REMOTE_HOST.gif

if (-e $zcatout) rm $zcatout

if (-e $gifout) then

#	echo "Content-type: text/html"
#	echo ""
#	echo "Here is the satellite image requested"
#	echo "\<p\>\<img src=\"$gifout\"\>\</p\>"
#	echo " gifout file = $gifout created" ; ls -l $gifout

	echo "Content-type: image/gif"
	echo ""
	cat $gifout
 	rm $gifout

else

	echo " Content-type: text/plain"
	echo ""
	echo " Could not convert the satellite image from the file "
	echo "  $dspin " 
	echo " Please contact the U.S. GLOBEC Georges Bank"
	echo " Data Mangement Office."
	echo " "
	echo " The following information may be useful for debugging the problem."
	echo " QUERY_STRING = $QUERY_STRING"
	echo " mia2gifpath = $mia2gifpath"
	echo " tmppath = $tmppath"
	echo " palfile = $palfile"
	echo " dspin = $dspin"
	echo " ext = $ext"
	echo " zcatout = $zcatout"
	echo " gifout = $gifout"
	
	echo "specified_in_1 = $specified_in_1"
	echo "standard_in_1 = $standard_in_1"
	echo "standard_out_1 = $standard_out_1"
	echo "tdiff_1 = $tdiff_1"
	echo "fdiff_1 = $fdiff_1"

	echo "tempin = $tempin"
endif


