[Swift-commit] r6791 - in SwiftApps/modis: bin tutorial

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Tue Aug 6 15:03:20 CDT 2013


Author: davidk
Date: 2013-08-06 15:03:20 -0500 (Tue, 06 Aug 2013)
New Revision: 6791

Modified:
   SwiftApps/modis/bin/assemble.sh
   SwiftApps/modis/bin/colormodis.sh
   SwiftApps/modis/bin/montage.pl
   SwiftApps/modis/bin/rgb_adjust_color.pl
   SwiftApps/modis/tutorial/modis01.swift
   SwiftApps/modis/tutorial/modis02.swift
   SwiftApps/modis/tutorial/modis03.swift
   SwiftApps/modis/tutorial/modis04.swift
   SwiftApps/modis/tutorial/modis05.swift
   SwiftApps/modis/tutorial/modis06.swift
Log:
Integrating changes from ATPESC 


Modified: SwiftApps/modis/bin/assemble.sh
===================================================================
--- SwiftApps/modis/bin/assemble.sh	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/bin/assemble.sh	2013-08-06 20:03:20 UTC (rev 6791)
@@ -1,69 +1,25 @@
-#!/bin/bash
+#!/bin/bash -x
 
-output=$(cd $(dirname $1); echo $PWD/$(basename $1))     # Full pathname of output file
-selected=$(cd $(dirname $2); echo $PWD/$(basename $2))   # Full pathname of input text file "selected"
-indir=$(cd $(dirname $3); echo $PWD/$(basename $3))      # Full pathname of image input dir
-webdir=$4
-
-echo output=$output
-echo selected=$selected
-echo indir=$indir
-echo webdir=$webdir
-
-if [ ! -d $webdir ]; then
-   mkdir -p $webdir
-   if [ $? -ne 0 ]; then
-      echo Unable to create $webdir, quitting
-      exit 1
-   fi
-fi
-
+output=shift
+output=$(cd $(dirname $output); echo $PWD/$(basename $output))     # Full pathname of output file
 tmpdir=$( eval mktemp -d $PWD/modis.assemble.XXXX )
 bindir=$(cd $(dirname $0); pwd)
-graytile=$bindir/gray.rgb
 
 # input files are expected to start with hNNvNN. 
 # we reverse this to form the final image
 
-cd $indir
-
-for h in {0..35}; do
-   h=$( printf %02d $h );
-   
-   for v in {0..17}; do
-      v=$( printf %02d $v );
-      hv=h${h}v${v}
-      vh=v${v}h${h}
-
-      # Use graytile if the expected section is not found
-      if [ ! -f $indir/$hv.color.rgb ]; then
-         echo $indir/$hv.color.rgb does not exist
-         cp $graytile $tmpdir
-         mv $tmpdir/gray.rgb $tmpdir/$vh.rgb 
-
-      # Otherwise, downscale input images
-      #elif grep $hv $selected >&/dev/null; then
-      #   convert $hv.png -resize 290x290 $tmpdir/t.png
-      #   convert $tmp/t.png -bordercolor red -border 5x5 $tmpdir/$vh.png
-      else
-         # $bindir/rgb_downscale.pl $indir/$hv.color.rgb 2400 2400 8 $tmpdir/$vh.rgb
-         mv $indir/$hv.color.rgb $tmpdir/$vh.rgb
-      fi
-  done
+while [ $# -gt 0 ]
+do
+   file=$1
+   shift
+   h=$( basename $file | cut -c2-3 )
+   v=$( basename $file | cut -c5-6 )
+   vh=v"$v"h"$h"
+   cp $file $tmpdir/$vh.rgb
 done
 
-#montage -tile 36x18 -geometry +0+0 $tmpdir/v*png $tmpdir/bigmap.png
-#cp $tmp/bigmap.png $output
+cd $tmpdir
+$bindir/montage.pl 5 5 200 200 v*
+$bindir/rgb_to_png.py map.rgb 1000 1000 ../map.png
 
-###########
-
 exit 0
-
-inputs=$(ls -1 $*)
-labels=""
-for f in $inputs; do
-  labels="$labels -label $(echo $f | sed -e 's/^.*\(h..v..\).*/\1/') $f"
-done
-
-montage $labels -font Courier-Regular $output
-

Modified: SwiftApps/modis/bin/colormodis.sh
===================================================================
--- SwiftApps/modis/bin/colormodis.sh	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/bin/colormodis.sh	2013-08-06 20:03:20 UTC (rev 6791)
@@ -7,8 +7,10 @@
 
 infile=$1
 outfile=$2
-xres=2400
-yres=2400
+scale=${3-12}
+xres=${4-2400}
+yres=${5-2400}
+
 BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 # Translation table - edit colors here
@@ -30,10 +32,7 @@
 #0e0e0e #9de36e
 #0f0f0f #b6b5c2
 #101010 #949494
-#ffffff #000000
 EOF
 
-$BINDIR/rgb_adjust_color.pl $infile translate.txt $outfile
-mv $outfile $outfile.tmp
-$BINDIR/rgb_downscale.pl $outfile.tmp 2400 2400 8 $outfile
-
+$BINDIR/rgb_adjust_color.pl $infile translate.txt $outfile.tmp
+$BINDIR/rgb_downscale.pl $outfile.tmp $xres $yres $scale $outfile

Modified: SwiftApps/modis/bin/montage.pl
===================================================================
--- SwiftApps/modis/bin/montage.pl	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/bin/montage.pl	2013-08-06 20:03:20 UTC (rev 6791)
@@ -11,7 +11,7 @@
 my $xres=shift;
 my $yres=shift;
 
-open(OUTFILE, ">output.rgb") || die "Unable to open output.rgb";
+open(OUTFILE, ">map.rgb") || die "Unable to open output.rgb";
 
 while(@ARGV) {
 

Modified: SwiftApps/modis/bin/rgb_adjust_color.pl
===================================================================
--- SwiftApps/modis/bin/rgb_adjust_color.pl	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/bin/rgb_adjust_color.pl	2013-08-06 20:03:20 UTC (rev 6791)
@@ -11,13 +11,13 @@
 open(TRANSLATION_TABLE, "$translation_table") || die "Unable to open $translation_table";
 while(<TRANSLATION_TABLE>) {
    my ($from, $to) = split;
-   $tr_table{$from} = $to;
+   $tr_table{lc($from)} = lc($to);
 }
 
 # Read data
 $/ = \3;
 while(<FILE_INPUT>) {
-   my $hex = sprintf ("#%2.2X%2.2X%2.2X", unpack('C3', $_));
+   my $hex = lc(sprintf ("#%2.2X%2.2X%2.2X", unpack('C3', $_)));
 
    if(defined($tr_table{$hex})) { 
       my $new_value = $tr_table{$hex};

Modified: SwiftApps/modis/tutorial/modis01.swift
===================================================================
--- SwiftApps/modis/tutorial/modis01.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis01.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -6,6 +6,6 @@
   getlanduse @filename(input) stdout=@filename(output);
 }
 
-imagefile modisImage <"../data/modis/2002/h00v09.rgb">;
-landuse result <"landuse/h00v09.landuse.byfreq">;
+imagefile modisImage <"data/europe/h18v05.rgb">;
+landuse result <"landuse/h18v05.landuse.byfreq">;
 result = getLandUse(modisImage);

Modified: SwiftApps/modis/tutorial/modis02.swift
===================================================================
--- SwiftApps/modis/tutorial/modis02.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis02.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -8,7 +8,7 @@
 
 # Constants and command line arguments
 int nFiles       = @toInt(@arg("nfiles", "1000"));
-string MODISdir  = @arg("modisdir", "../data/modis/2002");
+string MODISdir  = @arg("modisdir", "data/europe");
 
 # Input Dataset
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".rgb", n=nFiles>;

Modified: SwiftApps/modis/tutorial/modis03.swift
===================================================================
--- SwiftApps/modis/tutorial/modis03.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis03.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -16,7 +16,7 @@
 int nFiles       = @toInt(@arg("nfiles", "1000"));
 int nSelect      = @toInt(@arg("nselect", "10"));
 string landType  = @arg("landtype", "urban");
-string MODISdir  = @arg("modisdir", "../data/modis/2002");
+string MODISdir  = @arg("modisdir", "data/europe");
 
 # Input Dataset
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".rgb", n=nFiles>;

Modified: SwiftApps/modis/tutorial/modis04.swift
===================================================================
--- SwiftApps/modis/tutorial/modis04.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis04.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -21,7 +21,7 @@
 int nFiles       = @toInt(@arg("nfiles", "1000"));
 int nSelect      = @toInt(@arg("nselect", "10"));
 string landType  = @arg("landtype", "urban");
-string MODISdir  = @arg("modisdir", "../data/modis/2002");
+string MODISdir  = @arg("modisdir", "data/europe");
 
 # Input Dataset
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".rgb", n=nFiles>;

Modified: SwiftApps/modis/tutorial/modis05.swift
===================================================================
--- SwiftApps/modis/tutorial/modis05.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis05.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -26,7 +26,7 @@
 int nFiles       = @toInt(@arg("nfiles", "1000"));
 int nSelect      = @toInt(@arg("nselect", "10"));
 string landType  = @arg("landtype", "urban");
-string MODISdir  = @arg("modisdir", "data/modis/2002");
+string MODISdir  = @arg("modisdir", "data/europe");
 
 # Input Dataset
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".rgb", n=nFiles>;
@@ -53,10 +53,3 @@
 foreach g, i in geos {
   colorImage[i] = colorModis(g);
 }
-
-# Assemble a montage of the top selected areas
-#imagefile montage<"map.png">; # @arg
-#file assemble_olog <"logs/assemble.o.log">;
-#file assemble_elog <"logs/assemble.e.log">;
-#tracef("Calling assemble %s %s %s %s\n", @montage, @selectedTiles, @colorImage[0], webDir);
-#(montage, assemble_olog, assemble_elog) = assemble(selectedTiles,colorImage,webDir);

Modified: SwiftApps/modis/tutorial/modis06.swift
===================================================================
--- SwiftApps/modis/tutorial/modis06.swift	2013-08-06 19:55:25 UTC (rev 6790)
+++ SwiftApps/modis/tutorial/modis06.swift	2013-08-06 20:03:20 UTC (rev 6791)
@@ -22,16 +22,16 @@
   colormodis @input @output;
 }
 
-app (imagefile mon, file o, file e) assemble (file tiles, imagefile images[], string data_dir)
+app (imagefile mon) assemble (imagefile images[])
 {
-   assemble @filename(o) @filename(tiles) data_dir stdout=@filename(o) stderr=@filename(e);
+   assemble @filename(mon) @filenames(images);
 }
 
 # Constants and command line arguments
 int nFiles       = @toInt(@arg("nfiles", "1000"));
 int nSelect      = @toInt(@arg("nselect", "10"));
 string landType  = @arg("landtype", "urban");
-string MODISdir  = @arg("modisdir", "data/modis/2002");
+string MODISdir  = @arg("modisdir", "data/europe");
 
 # Input Dataset
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".rgb", n=nFiles>;
@@ -61,8 +61,5 @@
 
 # Assemble a montage of the top selected areas
 imagefile montage<"map.png">; # @arg
-file assemble_olog <"logs/assemble.o.log">;
-file assemble_elog <"logs/assemble.e.log">;
-tracef("Calling assemble %s %s %s\n", @montage, @selectedTiles, @colorImage[0]);
-(montage, assemble_olog, assemble_elog) = assemble(selectedTiles, colorImage, "colorImages");
+montage = assemble(colorImage);
 




More information about the Swift-commit mailing list