This file documents the process for generating HAR files from carbon
stock data and aggregating it to the desired regionalization.

The "aggcarbon/country" folder
------------------------------
The original carbon density (Mg C/ha) data for biomass and soil carbon
was compiled by Holly Gibbs et al., and is found in the Excel workbook
./aggcarbon/country/Country_AEZ_carbon_v21.xlsm

A separate Excel workbook reads data from the carbon database (which
must be open simultaneously) and reorganizes the data into matrices
suitable for conversion to a HAR file for use with GTAP. The "Notes"
worksheet in this workbook has an "Export" button which write the
contents of the Matrices worksheet into tab-delimited text file
"Matrices.txt". This file and RegionMap.txt are then processed by the
python script ./aggcarbon/country/AggregateCarbon.py to produce a
GEMPACK text file with the country data aggregated to the 134 GTAP
regions / 18 AEZs used by GTAP 8. This file can be converted to a HAR
file using the "makehar" shell script.

The shell script ./aggcarbon/country/makehar:
    1. converts Mac-format files to standard Unix format by changing
       line-terminators "\r" to "\n",
    2. runs the Python script, and then,
    3. runs the GEMPACK program "modhar" to generate the HAR file
       ./aggcarbon/carbon134.har.  The matrix dimensions used
       reference sets from the file "v87set.har".  (Currently, this is
       runnable only on Linux since the Mac version of "modhar" fails.)

The "aggcarbon" folder
----------------------
The file ./aggcarbon/carbon134.har (described above) is one of the
inputs to the TABLO-based aggregation program, "aggcarbon.tab", which
reads a GTAP user's desired regional aggregation and produces a HAR file
with the carbon density data aggregated accordingly.

The "aggcarbon/bioagg" folder
-----------------------------
This folder holds an example that aggregates the 134-region carbon
data to the 19 regions used by the GTAP-BIO model. The file
aggcarbon/bioagg/aggcarbon.sti provides the names of the files
required by aggcarbon.tab, as shown below:

1	bat  !  This runs the program in "batch" mode
2
3	../carbon134.har
4	../v87set.har
5	bioagg.har
6	carbon19.har

This STI file is generated by the shell script aggcarbon/bioagg/run.
The filenames can be set by modifying the STI file directly or by
modifying the definitions of ASETS and ADATA in the script and
rerunning the script.

The file ../carbon134.har is the output of the procedure run in the
aggcarbon/country folder (described above). The file ../v87sets.har
contains standard GTAP 8 set definitions. The file identified on line
5 must be a HAR file with list of regions to be used in header H1, and
the desired mapping from 134 regions to the regions identified in H1,
in the header DREG. See bioagg.har as an example of this. Finally, the
file given on line 6 (in this case, carbon19.har) is created by the
aggcarbon program with the carbon data regionalized as indicated.

The UNIX shell script aggcarbon/bioagg/run generates the file
bioagg.har from the file bioagg.txt, and then runs aggcarbon using
aggcarbon.sti as a stored input file.

