[GRASS-SVN] r68009 - in grass-addons/grass7/raster/r.futures: r.futures.calib r.futures.pga
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 5 18:02:41 PST 2016
Author: annakrat
Date: 2016-03-05 18:02:41 -0800 (Sat, 05 Mar 2016)
New Revision: 68009
Modified:
grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py
grass-addons/grass7/raster/r.futures/r.futures.pga/main.c
grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html
Log:
r.futures: change incentive_table to incentive_power parameter to make scenarios easier to use
Modified: grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py 2016-03-05 22:34:33 UTC (rev 68008)
+++ grass-addons/grass7/raster/r.futures/r.futures.calib/r.futures.calib.py 2016-03-06 02:02:41 UTC (rev 68009)
@@ -101,6 +101,17 @@
#% description: Raster map of development pressure
#% guisection: PGA
#%end
+#%option
+#% key: incentive_power
+#% type: double
+#% required: no
+#% multiple: no
+#% options: 0-10
+#% label: Exponent to transform probability values p to p^x to simulate infill vs. sprawl
+#% description: Values > 1 encourage infill, < 1 urban sprawl
+#% answer: 1
+#% guisection: PGA
+#%end
#%option G_OPT_R_INPUT
#% key: constrain_weight
#% required: no
@@ -130,12 +141,6 @@
#% description: Each line should contain region ID followed by parameters. Values are separated by whitespace (spaces or tabs). First line is ignored, so it can be used for header
#% guisection: PGA
#%end
-#%option G_OPT_F_INPUT
-#% key: incentive_table
-#% required: no
-#% description: File containing incentive lookup table (infill vs. sprawl)
-#% guisection: PGA
-#%end
#%option
#% key: num_neighbors
#% type: integer
@@ -208,7 +213,7 @@
#% guisection: Calibration
#%end
#%rules
-#% collective: demand,scaling_factor,gamma,development_pressure_approach,seed_search,num_neighbors,incentive_table,devpot_params,n_dev_neighbourhood,predictors,development_pressure,calibration_results,discount_factor,compactness_range,compactness_mean,repeat
+#% collective: demand,scaling_factor,gamma,development_pressure_approach,seed_search,num_neighbors,devpot_params,n_dev_neighbourhood,predictors,development_pressure,calibration_results,discount_factor,compactness_range,compactness_mean,repeat
#% exclusive: -l,demand
#% exclusive: -l,num_steps
#% exclusive: -l,scaling_factor
@@ -216,7 +221,7 @@
#% exclusive: -l,development_pressure_approach
#% exclusive: -l,seed_search
#% exclusive: -l,num_neighbors
-#% exclusive: -l,incentive_table
+#% exclusive: -l,incentive_power
#% exclusive: -l,devpot_params
#% exclusive: -l,n_dev_neighbourhood
#% exclusive: -l,predictors
@@ -233,7 +238,6 @@
#% required: -l,development_pressure_approach
#% required: -l,seed_search
#% required: -l,num_neighbors
-#% required: -l,incentive_table
#% required: -l,devpot_params
#% required: -l,n_dev_neighbourhood
#% required: -l,predictors
@@ -332,14 +336,14 @@
developed=development_start)
futures_parameters = dict(development_pressure=fut_options['development_pressure'],
predictors=fut_options['predictors'], n_dev_neighbourhood=fut_options['n_dev_neighbourhood'],
- devpot_params=fut_options['devpot_params'], incentive_table=fut_options['incentive_table'],
+ devpot_params=fut_options['devpot_params'],
num_neighbors=fut_options['num_neighbors'], seed_search=fut_options['seed_search'],
development_pressure_approach=fut_options['development_pressure_approach'], gamma=fut_options['gamma'],
scaling_factor=fut_options['scaling_factor'],
subregions=fut_options['subregions'], demand=fut_options['demand'],
output=development_end)
parameters.update(futures_parameters)
- for not_required in ('constrain_weight', 'num_steps'):
+ for not_required in ('constrain_weight', 'num_steps', 'incentive_power'):
if options[not_required]:
parameters.update({not_required: options[not_required]})
Modified: grass-addons/grass7/raster/r.futures/r.futures.pga/main.c
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.pga/main.c 2016-03-05 22:34:33 UTC (rev 68008)
+++ grass-addons/grass7/raster/r.futures/r.futures.pga/main.c 2016-03-06 02:02:41 UTC (rev 68009)
@@ -1420,7 +1420,7 @@
*consWeightFile, *addVariableFiles, *nDevNeighbourhood,
*devpotParamsFile, *dumpFile, *outputSeries,
*parcelSizeFile, *discountFactor,
- *probLookupFile,
+ /* *probLookupFile,*/ *incentivePower,
*patchMean, *patchRange, *numNeighbors, *seedSearch,
*devPressureApproach, *alpha, *scalingFactor, *num_Regions,
*numSteps, *indexFile, *controlFileAll, *seed;
@@ -1602,6 +1602,7 @@
opt.parcelSizeFile->guisection = _("PGA");
+ /* replaced by incentive power
opt.probLookupFile = G_define_standard_option(G_OPT_F_INPUT);
opt.probLookupFile->key = "incentive_table";
opt.probLookupFile->required = NO;
@@ -1610,7 +1611,20 @@
opt.probLookupFile->description =
_("Format is tightly constrained. See documentation.");
opt.probLookupFile->guisection = _("Scenarios");
+ */
+ opt.incentivePower = G_define_option();
+ opt.incentivePower->key = "incentive_power";
+ opt.incentivePower->required = NO;
+ opt.incentivePower->type = TYPE_DOUBLE;
+ opt.incentivePower->answer = "1";
+ opt.incentivePower->label =
+ _("Exponent to transform probability values p to p^x to simulate infill vs. sprawl");
+ opt.incentivePower->description =
+ _("Values > 1 encourage infill, < 1 urban sprawl");
+ opt.incentivePower->guisection = _("Scenarios");
+ opt.incentivePower->options = "0-10";
+
opt.consWeightFile = G_define_standard_option(G_OPT_R_INPUT);
opt.consWeightFile->key = "constrain_weight";
opt.consWeightFile->required = NO;
@@ -1707,6 +1721,19 @@
sParams.discountFactor = atof(opt.discountFactor->answer);
+ if (opt.incentivePower->answer) {
+ float exponent = atof(opt.incentivePower->answer);
+ sParams.nProbLookup = 1001;
+ sParams.adProbLookup = (double *) G_malloc(sizeof(double) *
+ sParams.nProbLookup);
+ int i = 0;
+ double step = 1. / (sParams.nProbLookup - 1);
+ while (i < sParams.nProbLookup) {
+ sParams.adProbLookup[i] = pow(i * step, exponent);
+ i++;
+ }
+ }
+ /* replaced by incentive power
int parsedOK, i;
FILE *fp;
char inBuff[N_MAXREADINLEN];
@@ -1760,11 +1787,11 @@
sParams.probLookupFile);
}
}
+ */
else {
sParams.nProbLookup = 0;
sParams.adProbLookup = NULL;
}
-
sParams.patchMean = atof(opt.patchMean->answer);
sParams.patchRange = atof(opt.patchRange->answer);
sParams.numNeighbors = atoi(opt.numNeighbors->answer);
Modified: grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html 2016-03-05 22:34:33 UTC (rev 68008)
+++ grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html 2016-03-06 02:02:41 UTC (rev 68009)
@@ -42,21 +42,9 @@
<h3>Scenarios</h3>
Scenarios involving policies that encourage infill versus sprawl
-can be explored using the <b>incentive_table</b> parameter,
+can be explored using the <b>incentive_power</b> parameter,
which uses a power function to transform the probability in POTENTIAL.
-A simple incentive table can be generated using the
-following commands in Python:
-<div class="code"><pre>
-import numpy as np
-power = 2
-length = 1001
-x = np.linspace(0, 1, length)
-np.savetxt(fname="incentive_table.txt", fmt='%1.3f', delimiter=',',
- X=np.column_stack((x, np.power(x, power))),
- header=",{}".format(length), comments='')
-</pre></div>
-
<center>
<img src="incentive.png">
<p>
@@ -107,7 +95,7 @@
compactness_mean=0.4 compactness_range=0.08 num_neighbors=4 seed_search=2 \
patch_sizes=patch_sizes.txt development_pressure=gdp n_dev_neighbourhood=10 \
development_pressure_approach=gravity gamma=2 scaling_factor=1 \
- subregions=subregions incentive_table=probLookup.csv \
+ subregions=subregions incentive_power=2 \
constrain_weight=weight_1 output=final_results output_series=development
</pre></div>
More information about the grass-commit
mailing list