[Swift-commit] r3012 - SwiftApps/SEE/trunk

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Wed Jul 15 11:50:43 CDT 2009


Author: aespinosa
Date: 2009-07-15 11:50:43 -0500 (Wed, 15 Jul 2009)
New Revision: 3012

Modified:
   SwiftApps/SEE/trunk/run_ampl
Log:
Incorporated mike's filtering scripts

Modified: SwiftApps/SEE/trunk/run_ampl
===================================================================
--- SwiftApps/SEE/trunk/run_ampl	2009-07-15 14:00:48 UTC (rev 3011)
+++ SwiftApps/SEE/trunk/run_ampl	2009-07-15 16:50:43 UTC (rev 3012)
@@ -11,20 +11,67 @@
 {
   repl=""
   for v in $*; do
-#    echo substituting $v = ${!v}
     val=${!v}
     repl="$repl -e 's,@${v}@,$val,'"
   done
-#  echo Running "sed $repl <$paramtemplate >$paramfile"
   eval sed $repl <$paramtemplate >$paramfile
 }
 
+# Extraction scripts
+
+# Expend
+extract_expend()
+{
+  echo 'YEAR REGION PROD CON1 '
+
+  egrep '\+|^  *ELC|AGF.*OIL' $1 | sed -e 's/AGF.*OIL.*//' | egrep -v 'LND|LAB|CAP|NAT' |
+
+  awk '
+
+  BEGIN { regnum=0; year=2004 }
+
+  NF==1 { region=$1; regnum++; if ( regnum % 16 == 0 ) year++ }
+  NF!=1 { print year, region, $1, $19 }
+
+  '
+}
+
+# Price
+extract_price()
+{
+  grep 'OIL_I' $1 | awk '{ print $2 }'
+}
+
+# Ratio
+extract_ratio()
+{
+  echo -n 'YEAR REGION PRODUCT '
+  head -1 $1 | sed -e 's/^  *USA  *//' -e 's/  *USA.*//'
+
+  egrep '^  *OIL|^  *COL|^  *GAS|^  *ELC|^  *PTL|AGF *OIL' $1 | sed -e 's/     .*//' |
+
+  awk '
+
+  BEGIN { regnum=0; year=2004 }
+
+  NF==1 { region=$1; regnum++; if ( regnum % 16 == 0 ) year++ }
+  # NF!=1 { print year, region, $0 }
+  NF!=1 {
+    printf("%s %s ", year, region);
+    for(f=1;f<=19;f++) { printf(" %s",$(f)); }
+    printf("\n");
+  }
+
+  '
+}
+
+# main loop
+
 paramtemplate=template
 amplapp=ampl
 paramfile=arm_test.cmd
 INSTANCE_ID=$1
 
-
 subval INSTANCE_ID
 $amplapp $paramfile
 
@@ -40,6 +87,11 @@
     mv solve.dat result/${INSTANCE_ID}/solve.dat
     exit 0
 fi
+
+# Filtering
+extract_expend expend.dat > expend.out
+extract_price price.dat > price.out
+extract_ratio ratio.dat > ratio.out
     
 mkdir -p result/${INSTANCE_ID}
 mv expend.dat result/${INSTANCE_ID}/expend.dat
@@ -48,4 +100,8 @@
 mv ratio.dat result/${INSTANCE_ID}/ratio.dat
 mv solve.dat result/${INSTANCE_ID}/solve.dat
 
+mv expend.out result/${INSTANCE_ID}/expend.out
+mv price.out result/${INSTANCE_ID}/price.out 
+mv ratio.out result/${INSTANCE_ID}/ratio.out
+
 exit 0




More information about the Swift-commit mailing list