[Swift-commit] r6269 - in SwiftApps/modis: . bin
davidk at ci.uchicago.edu
davidk at ci.uchicago.edu
Thu Feb 14 13:55:10 CST 2013
Author: davidk
Date: 2013-02-14 13:55:10 -0600 (Thu, 14 Feb 2013)
New Revision: 6269
Added:
SwiftApps/modis/bin/grid.ppm
Removed:
SwiftApps/modis/bin/grid.ppm.gz
Modified:
SwiftApps/modis/bin/colormodis.sh
SwiftApps/modis/bin/draw_rectangle.pl
SwiftApps/modis/bin/markmap.sh
SwiftApps/modis/demo
Log:
Make the demo script a little more interactive
Start splitting up modis script into simpler examples for future tutorial use
Modified: SwiftApps/modis/bin/colormodis.sh
===================================================================
--- SwiftApps/modis/bin/colormodis.sh 2013-02-13 19:34:43 UTC (rev 6268)
+++ SwiftApps/modis/bin/colormodis.sh 2013-02-14 19:55:10 UTC (rev 6269)
@@ -7,49 +7,27 @@
infile=$1
outfile=$2
+BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-# Create temp files in current directory since /tmp may not be available
-tmp=`mktemp modis.$USER.XXXXXX.ppn.gz`
-map=`mktemp colormap.$USER.XXXXXX`
-
-# Create color set
-
-(
- cat |
- sed -e 's/ c.=/ /g' -e 's/[^0-9 ]//g' |
- awk '{printf("#%02x%02x%02x #%02x%02x%02x\n", NR-1, NR-1, NR-1, $1, $2, $3)}') >$map <<EOF
- <Entry c1="32" c2="65" c3="179" c4="255"/>
- <Entry c1="0" c2="106" c3="15" c4="255"/>
- <Entry c1="0" c2="124" c3="37" c4="255"/>
- <Entry c1="0" c2="162" c3="91" c4="255"/>
- <Entry c1="0" c2="161" c3="37" c4="255"/>
- <Entry c1="6" c2="146" c3="40" c4="255"/>
- <Entry c1="158" c2="150" c3="104" c4="255"/>
- <Entry c1="193" c2="196" c3="143" c4="255"/>
- <Entry c1="133" c2="170" c3="91" c4="255"/>
- <Entry c1="177" c2="183" c3="65" c4="255"/>
- <Entry c1="164" c2="208" c3="126" c4="255"/>
- <Entry c1="115" c2="171" c3="174" c4="255"/>
- <Entry c1="204" c2="210" c3="83" c4="255"/>
- <Entry c1="217" c2="0" c3="0" c4="255"/>
- <Entry c1="157" c2="227" c3="110" c4="255"/>
- <Entry c1="182" c2="181" c3="194" c4="255"/>
- <Entry c1="148" c2="148" c3="148" c4="255"/>
+# Translation table - edit colors here
+cat > translate.txt <<EOF
+#000000 #2041b3
+#010101 #006a0f
+#020202 #007c25
+#030303 #00a25b
+#040404 #00a125
+#050505 #069228
+#060606 #9e9668
+#070707 #c1c48f
+#080808 #85aa5b
+#090909 #b1b741
+#0a0a0a #a4d07e
+#0b0b0b #73abae
+#0c0c0c #ccd253
+#0d0d0d #d90000
+#0e0e0e #9de36e
+#0f0f0f #b6b5c2
+#101010 #949494
EOF
-cp $infile $tmp
-gunzip $tmp
-tmp=$( basename $tmp .gz )
-
-# output logged to stdout/error is ignored by swift for this app()
-
-while read mval color ; do
- echo color $mval is $color
- echo convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
- convert $tmp "-fill" "$color" "-opaque" "$mval" $tmp
-done <$map
-
-#cp $tmp $outfile
-convert -thumbnail 300x300 $tmp $outfile
-
-rm $tmp $map
+$BINDIR/adjust_color.pl $infile translate.txt $outfile
Modified: SwiftApps/modis/bin/draw_rectangle.pl
===================================================================
--- SwiftApps/modis/bin/draw_rectangle.pl 2013-02-13 19:34:43 UTC (rev 6268)
+++ SwiftApps/modis/bin/draw_rectangle.pl 2013-02-14 19:55:10 UTC (rev 6269)
@@ -1,11 +1,11 @@
#!/usr/bin/perl
-# Draw a rectangle on a gzipped PPM
-# Usage: draw_rectangle.pl infile.ppm.gz xmin ymin xmax ymax outfile.ppm.gz
+# Draw a rectangle on a PPM
+# Usage: draw_rectangle.pl infile.ppm xmin ymin xmax ymax outfile.ppm
my ($pgm_input_filename, $xmin, $ymin, $xmax, $ymax, $pgm_output_filename) = @ARGV;
-open(PGMFILE_INPUT, "gunzip -c $pgm_input_filename |") || die "Unable to open $pgm_input_filename!";
-open(PGMFILE_OUTPUT, "| gzip -c > $pgm_output_filename") || die "Unable to create $pgm_output_filename";
+open(PGMFILE_INPUT, "$pgm_input_filename") || die "Unable to open $pgm_input_filename!";
+open(PGMFILE_OUTPUT, ">$pgm_output_filename") || die "Unable to create $pgm_output_filename";
# Read header
my $magic = <PGMFILE_INPUT>;
Added: SwiftApps/modis/bin/grid.ppm
===================================================================
(Binary files differ)
Property changes on: SwiftApps/modis/bin/grid.ppm
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: SwiftApps/modis/bin/grid.ppm.gz
===================================================================
(Binary files differ)
Modified: SwiftApps/modis/bin/markmap.sh
===================================================================
--- SwiftApps/modis/bin/markmap.sh 2013-02-13 19:34:43 UTC (rev 6268)
+++ SwiftApps/modis/bin/markmap.sh 2013-02-14 19:55:10 UTC (rev 6269)
@@ -6,7 +6,7 @@
tilefile=$1
outmap=$2
-cp $BINDIR/grid.ppm.gz $outmap
+cp $BINDIR/grid.ppm $outmap
cat $tilefile | while read f ; do
hv=$(echo $f | sed -e 's,^.*/,,' -e 's/\..*//')
Modified: SwiftApps/modis/demo
===================================================================
--- SwiftApps/modis/demo 2013-02-13 19:34:43 UTC (rev 6268)
+++ SwiftApps/modis/demo 2013-02-14 19:55:10 UTC (rev 6269)
@@ -20,6 +20,16 @@
fi
}
+run()
+{
+ echo
+ cp $1 .
+ eval swiftrun -site $SITE $( basename $1 ) -landtype=$LANDTYPE -nfiles=$NFILES \
+ -nselect=$NSELECT -modisdir=$MODISDIR -webdir=$WEBDIR
+ rm $( basename $1 )
+}
+
+
# Parse command line arguments
while [ $# -gt 0 ]
do
@@ -35,10 +45,39 @@
shift
done
-echo landtype=$LANDTYPE
-echo nfiles=$NFILES
-echo nselect=$NSELECT
-echo webdir=$WEBDIR
+# Select site
+echo
+echo "Available sites"
+prompt="Pick an option: "
+options=("local" "midway")
+PS3=$prompt
+select opt in "${options[@]}" "Quit"; do
+ case "$REPLY" in
+ 1) SITE="local"; break;;
+ 2) SITE="midway"; break;;
+ $(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
+ *) echo "Invalid option. Try another one.";continue;;
+ esac
+done
-eval swiftrun -site $SITE modis.swift -landtype=$LANDTYPE -nfiles=$NFILES \
- -nselect=$NSELECT -modisdir=$MODISDIR -webdir=$WEBDIR
+# Select script
+echo
+prompt="Pick an option:"
+options=("Tutorial 1" "Tutorial 2" "Tutorial 3" "Tutorial 4")
+
+echo "Select script"
+PS3="$prompt "
+select opt in "${options[@]}" "Quit"; do
+
+ case "$REPLY" in
+
+ 1 ) run tutorial/modis01.swift; break;;
+ 2 ) run tutorial/modis02.swift; break;;
+ 3 ) run tutorial/modis03.swift; break;;
+ 4 ) run tutorial/modis04.swift; break;;
+ $(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
+ *) echo "Invalid option. Try another one.";continue;;
+
+ esac
+done
+
More information about the Swift-commit
mailing list