[Swift-commit] r6196 - in SwiftApps/modis: . bin

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Wed Jan 30 21:41:10 CST 2013


Author: davidk
Date: 2013-01-30 21:41:09 -0600 (Wed, 30 Jan 2013)
New Revision: 6196

Added:
   SwiftApps/modis/bin/ppmhist.pl
Modified:
   SwiftApps/modis/bin/assemble2.sh
   SwiftApps/modis/modis.swift
Log:
script to generate ppm histograms


Modified: SwiftApps/modis/bin/assemble2.sh
===================================================================
--- SwiftApps/modis/bin/assemble2.sh	2013-01-31 03:35:58 UTC (rev 6195)
+++ SwiftApps/modis/bin/assemble2.sh	2013-01-31 03:41:09 UTC (rev 6196)
@@ -5,7 +5,7 @@
 indir=$(cd $(dirname $3); pwd)                             # get full pathname of input dir "geos"
 webdir=$4
 
-tmp=$(mktemp -d /tmp/modis.assemble.XXXX)
+tmp=$(mktemp -p . -d modis.assemble.XXXX)
 bindir=$(cd $(dirname $0); pwd)
 graytile=$bindir/gray.png
 

Added: SwiftApps/modis/bin/ppmhist.pl
===================================================================
--- SwiftApps/modis/bin/ppmhist.pl	                        (rev 0)
+++ SwiftApps/modis/bin/ppmhist.pl	2013-01-31 03:41:09 UTC (rev 6196)
@@ -0,0 +1,42 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+# Read file
+my $ppm_filename = shift;
+open(PPMFILE, $ppm_filename) || die "Unable to open $ppm_filename!\n";
+my @ppm_data = <PPMFILE>;
+close(PPMFILE);
+
+my %rgbcount = ();
+my $count=0;
+my $ppmformat="", my $resolution="", my $maxval="";
+
+foreach my $line(@ppm_data) {
+   chomp($line);
+   if ($count == 0){ $ppmformat=$line; $count++; next; }
+   if ($count == 1){ $resolution=$line; $count++; next; }
+   if ($count == 2){ $maxval=$line; $count++; next; }
+
+   my $wordcount=0, my $red="", my $green="", my $blue="";
+   foreach my $rgb(split(/\s+/, $line)) {
+      if($wordcount == 0) { $red=$rgb; $wordcount++; next; }
+      if($wordcount == 1) { $green=$rgb; $wordcount++; next; }
+      if($wordcount == 2) { 
+         $blue=$rgb; 
+         if(!defined($rgbcount{"$red $green $blue"})) { 
+            $rgbcount{"$red $green $blue"}=1;
+         } else {
+            $rgbcount{"$red $green $blue"}++;
+         }
+         $wordcount=0;
+      }
+   }
+   $count++;
+}
+
+while ( my ($key, $value) = each(%rgbcount) ) {
+   (my $red, my $green, my $blue) = split(/ /, $key);
+   my $hex = sprintf("%02x",$red);
+   print "$value $red $hex\n";
+}


Property changes on: SwiftApps/modis/bin/ppmhist.pl
___________________________________________________________________
Added: svn:executable
   + *

Modified: SwiftApps/modis/modis.swift
===================================================================
--- SwiftApps/modis/modis.swift	2013-01-31 03:35:58 UTC (rev 6195)
+++ SwiftApps/modis/modis.swift	2013-01-31 03:41:09 UTC (rev 6196)
@@ -4,9 +4,9 @@
 
 # Define application program interfaces
 
-app (landuse output) getLandUse (imagefile input, int sortfield)
+app (landuse output) getLandUse (imagefile input, int sortfield, string mpath)
 {
-  getlanduse @input sortfield stdout=@output ;
+  getlanduse @input sortfield mpath stdout=@output;
 }
 
 app (file output, file tilelist) analyzeLandUse
@@ -39,12 +39,12 @@
 string MODISdir=  @arg("modisdir");
 string webDir =   @arg("webdir");
 
-string suffix=".tif";
+string suffix=".ppm.gz";
 
 # Input Dataset
 
 imagefile geos[] <ext; exec="../bin/modis.mapper",
-  location=MODISdir, suffix=".tif", n=nFiles >; # site=site
+  location=MODISdir, suffix=".ppm.gz", n=nFiles >; # site=site
 
 
 # Compute the land use summary of each MODIS tile
@@ -53,7 +53,7 @@
   transform=@strcat("landuse/\\1.landuse.byfreq")>;
 
 foreach g,i in geos {
-    land[i] = getLandUse(g,1);
+    land[i] = getLandUse(g,1,MODISdir);
 }
 
 # Find the top N tiles (by total area of selected landuse types)




More information about the Swift-commit mailing list