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

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Fri Feb 15 10:51:30 CST 2013


Author: davidk
Date: 2013-02-15 10:51:30 -0600 (Fri, 15 Feb 2013)
New Revision: 6280

Modified:
   SwiftApps/modis/bin/analyzelanduse.sh
   SwiftApps/modis/bin/getlanduse.sh
   SwiftApps/modis/bin/markmap.sh
   SwiftApps/modis/tutorial/modis03.swift
   SwiftApps/modis/tutorial/modis04.swift
Log:
Some updates for ascii maps


Modified: SwiftApps/modis/bin/analyzelanduse.sh
===================================================================
--- SwiftApps/modis/bin/analyzelanduse.sh	2013-02-15 12:10:42 UTC (rev 6279)
+++ SwiftApps/modis/bin/analyzelanduse.sh	2013-02-15 16:51:30 UTC (rev 6280)
@@ -31,33 +31,13 @@
 # Max limit to analyze
 maxnum=$4
 
-# ASCII map name
-asciimap=$6
-
-BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
 # Write topselected.txt
 result=$( grep " $usetype " $( eval echo $5 ) | sed s/':'/' '/g | sort -rnk2 | awk '{print $1 " " $2}' | head -$maxnum )
 echo "$result" > $topselected
    
 # Write selectedtiles.txt
-selected_tiles=""
 for r in $( echo "$result" | awk '{print $1}' )
 do
-   tile=$( basename $r ).ppm.gz |sed s/\.landuse\.byfreq//g 
-   echo $tile >> $selectedtiles
-   selected_tiles="$selected_tiles $tile"
+   echo $( basename $r ).ppm.gz |sed s/\.landuse\.byfreq//g >> $selectedtiles
 done
-
-# Write ASCII map
-for image in $( eval echo $5 )
-do
-   is_land=$( $BINDIR/is_land.pl $image )
-   if [ "$is_land" == "1" ]; then
-      echo $image is land >> $asciimap
-   else
-      echo $image is water >> $asciimap
-   fi
-done
-
 exit 0

Modified: SwiftApps/modis/bin/getlanduse.sh
===================================================================
--- SwiftApps/modis/bin/getlanduse.sh	2013-02-15 12:10:42 UTC (rev 6279)
+++ SwiftApps/modis/bin/getlanduse.sh	2013-02-15 16:51:30 UTC (rev 6280)
@@ -2,3 +2,4 @@
 
 BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 $BINDIR/getlanduse.pl $1 | sort -rn
+$BINDIR/is_land.pl $1 > $2

Modified: SwiftApps/modis/bin/markmap.sh
===================================================================
--- SwiftApps/modis/bin/markmap.sh	2013-02-15 12:10:42 UTC (rev 6279)
+++ SwiftApps/modis/bin/markmap.sh	2013-02-15 16:51:30 UTC (rev 6280)
@@ -5,6 +5,9 @@
 
 tilefile=$1
 outmap=$2
+asciimap=$3
+modisdir=$4
+is_land_files=$5
 
 cp $BINDIR/grid.ppm $outmap
 
@@ -16,4 +19,23 @@
   mv $outmap.tmp $outmap
 done
 
+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}
+      #echo hv is $hv >> $asciimap
+      if [ -f "landuse/$hv.is_land" ]; then
+         is_land=$( cat landuse/$hv.is_land )
+         if [ "$is_land" == 0 ]; then
+            echo -n "X" >> $asciimap
+         else
+            echo -n "_" >> $asciimap
+         fi
+      else
+         echo -n " " >> $asciimap
+      fi
+   done
+   echo "" >> $asciimap
+done
 

Modified: SwiftApps/modis/tutorial/modis03.swift
===================================================================
--- SwiftApps/modis/tutorial/modis03.swift	2013-02-15 12:10:42 UTC (rev 6279)
+++ SwiftApps/modis/tutorial/modis03.swift	2013-02-15 16:51:30 UTC (rev 6280)
@@ -2,14 +2,14 @@
 type imagefile;
 type landuse;
 
-app (landuse output) getLandUse (imagefile input)
+app (landuse output, landuse island) getLandUse (imagefile input)
 {
-  getlanduse @filename(input) stdout=@filename(output);
+  getlanduse @filename(input) @filename(island) stdout=@filename(output);
 }
 
-app (file output, file tilelist, file asciimap) analyzeLandUse (landuse input[], string usetype, int maxnum)
+app (file output, file tilelist) analyzeLandUse (landuse input[], string usetype, int maxnum)
 {
-  analyzelanduse @output @tilelist usetype maxnum @input @filename(asciimap);
+  analyzelanduse @output @tilelist usetype maxnum @input;
 }
 
 # Constants and command line arguments
@@ -23,13 +23,13 @@
 
 # Compute the land use summary of each MODIS tile
 landuse land[] <structured_regexp_mapper; source=geos, match="(h..v..)", transform=@strcat("landuse/\\1.landuse.byfreq")>;
+landuse is_land[] <structured_regexp_mapper; source=geos, match="(h..v..)", transform=@strcat("landuse/\\1.is_land")>;
 
 foreach g,i in geos {
-    land[i] = getLandUse(g);
+    (land[i], is_land[i]) = getLandUse(g);
 }
 
 # Find the top N tiles (by total area of selected landuse types)
 file topSelected <"topselected.txt">;
 file selectedTiles <"selectedtiles.txt">;
-file asciiMap <"map.txt">;
-(topSelected, selectedTiles, asciiMap) = analyzeLandUse(land, landType, nSelect);
+(topSelected, selectedTiles) = analyzeLandUse(land, landType, nSelect);

Modified: SwiftApps/modis/tutorial/modis04.swift
===================================================================
--- SwiftApps/modis/tutorial/modis04.swift	2013-02-15 12:10:42 UTC (rev 6279)
+++ SwiftApps/modis/tutorial/modis04.swift	2013-02-15 16:51:30 UTC (rev 6280)
@@ -2,9 +2,9 @@
 type imagefile;
 type landuse;
 
-app (landuse output) getLandUse (imagefile input)
+app (landuse output, landuse island) getLandUse (imagefile input)
 {
-  getlanduse @filename(input) stdout=@filename(output);
+  getlanduse @filename(input) @filename(island) stdout=@filename(output);
 }
 
 app (file output, file tilelist) analyzeLandUse (landuse input[], string usetype, int maxnum)
@@ -12,9 +12,9 @@
   analyzelanduse @output @tilelist usetype maxnum @input;
 }
 
-app (imagefile grid) markMap (file tilelist) 
+app (imagefile grid, file asciimap) markMap (file tilelist, string mdir, landuse island[]) 
 {
-  markmap @tilelist @grid;
+  markmap @tilelist @grid @filename(asciimap) mdir @island;
 }
 
 # Constants and command line arguments
@@ -27,10 +27,11 @@
 imagefile geos[] <ext; exec="../bin/modis.mapper", location=MODISdir, suffix=".pgm.gz", n=nFiles>;
 
 # Compute the land use summary of each MODIS tile
-landuse land[] <structured_regexp_mapper; source=geos, match="(h..v..)", transform=@strcat("landuse/\\1.landuse.byfreq")>;
+landuse land[]    <structured_regexp_mapper; source=geos, match="(h..v..)", transform=@strcat("landuse/\\1.landuse.byfreq")>;
+landuse is_land[] <structured_regexp_mapper; source=geos, match="(h..v..)", transform=@strcat("landuse/\\1.is_land")>;
 
 foreach g,i in geos {
-    land[i] = getLandUse(g);
+    (land[i], is_land[i]) = getLandUse(g);
 }
 
 # Find the top N tiles (by total area of selected landuse types)
@@ -39,6 +40,6 @@
 (topSelected, selectedTiles) = analyzeLandUse(land, landType, nSelect);
 
 # Mark the top N tiles on a sinusoidal gridded map
-imagefile gridMap<"markedGrid.ppm">;
-gridMap = markMap(topSelected);
-
+imagefile gridMap <"markedGrid.ppm">;
+file asciiMap <"map.txt">;
+(gridMap, asciiMap) = markMap(topSelected, MODISdir, is_land);




More information about the Swift-commit mailing list