Skip to contents

Introduction

Extracting output files

It is possible to automatically extract all the output files from one or more SORTIE runs.

The program will look in the directory:
C:/Projects/SORTIE/output/

It will then loop over all the tar files in that directory and extract them to the directory:
C:/Projects/SORTIE/output/extracted

This is a very rudimentary function at this point. It will always open all tarfiles in the output directory, and overwrite all files in the extracted directory.

Further functionality is forthcoming

This function returns a list of all xml files that are in the extracted directory.

Read tree output files

The function ParseXML allows users to read one or more years from one or more xml file.

Inputs to the function include a list of one or more xml files, as well as a list of one or more years to extract.

Put the list of xml files into the variable “ListOfExtractedFile”. Note that this variable can also be filled automatically when using the ExtractFiles function described in the previous section.

Put the list of years to extract into the variable “YearsToExtract”

The code will then run over each set of files and years to read the tree list file and to put the resulting information into an R variable:
trees_#
where # is the loop number. Right now there is no correspondence between the loop number and the file-year combination.

The new variable will have all the columns that Sortie printed to the output file, including one called ID. Note that ID simply represents the place in the output file that tree record contained. While this ID may refer to the same tree for some timesteps, mortality or establishment of that tree record or other trees will change the id. Use the x-y location to track trees instead as they will remain constant for the life of the tree.

Read map output files

The function ParseMap allows users to read all the maps in an output xml file.

In the function, manually assign the name of the output file to read.

The code will scan the file to find all the maps that are present, then will loop over each map in the file, extract the information, and assign it to two different R variables.

The grid and information will be stored in an R variable called:
map_#
where # is the location in the output file.

The type of map is stored in a variable called:
output_type_#
where # is again the location in the output file. The type of the map is read from the output file and could be something like “Dispersed Seeds” or “GLI Map 1”.

Read raster files

There is a stand-alone file “RasterFunctions.r” that will read a raster file and write the information to a text file. This is a simple file whose goal is to allow users to quickly change a raster file into a format that can be pulled into an xml chunk and added to the Sortie file.

Input: raster file name
Output: an text file in xml format. Each cell that has a value greater than 0 will be printed as:
<ha_applyToCell x=”xloc” y=“yloc’/>

Where xloc and yloc are the x-y locations in the raster file.