pygcam.landProtection
¶
This module supports implementation of the protect sub-command of GCAM tool (gt). It is provided in library form so that it can be used from within setup programs (or other programs) without having to execute the GCAM tool (gt) script.
See the documentation for landProtection.xml, the input file used by this subcommand.
API¶
-
class
pygcam.landProtection.
LandProtection
(node)¶ Stores the application’s representation of the parsed XML file describing land protection scenarios.
Parameters: node – an lxml.etree.Element
representing the top-level<landProtection>
node-
protectLand
(infile, outfile, scenarioName, backup=True)¶ Generate a copy of infile with land protected according to scenarioName, writing the output to outfile.
Parameters: - infile – input file (should be one of the GCAM aglu-xml land files)
- outfile – the file to create which represents the desired land protection
- scenarioName – a scenario in the landProtection.xml file
- backup – if True, create a backup outfile, with a ‘~’ appended to the name, before writing a new file.
Returns: none
-
-
pygcam.landProtection.
createProtected
(tree, fraction, landClasses=None, otherArable=False, regions=None, unprotectFirst=False)¶ Modify an lxml tree representing a GCAM input file to protect a fraction of landClasses in regions.
Parameters: - tree – a tree representing a parsed GCAM land_input XML file
- fraction – the fraction of land in the given land classes to protect
- landClasses – a string or a list of strings, or None. If None, all standard unmanaged land classes are modified.
- otherArable – (bool) if True, land class ‘OtherArableLand’ is included in default land classes.
- regions – a string or a list of strings, or None. If None, all regions are modified.
Returns: None
-
pygcam.landProtection.
protectLand
(infile, outfile, fraction, landClasses=None, otherArable=False, regions=None, unprotectFirst=False)¶ Create a copy of infile that protects a fraction of landClasses in regions.
Parameters: - infile – the path of a GCAM land_input XML file
- outfile – the path of the XML file to create by modifying data from infile
- fraction – the fraction of land in the given land classes to protect
- landClasses – a string or a list of strings, or None. If None, all “standard” unmanaged land classes are modified.
- otherArable – (bool) if True, land class ‘OtherArableLand’ is included in default land classes.
- regions – a string or a list of strings, or None. If None, all regions are modified.
Returns: None
-
pygcam.landProtection.
unProtectLand
(tree, landClasses=None, otherArable=False, regions=None)¶ Restore the file to 0% land protection by adding the protected land back into its unprotected counterpart and deleting the protected elements.
Parameters: - tree – a tree representing a parsed GCAM land_input XML file
- landClasses – a string or a list of strings, or None. If None, all standard unmanaged land classes are modified.
- otherArable – (bool) if True, land class ‘OtherArableLand’ is included in default land classes.
- regions – a string or a list of strings, or None. If None, all regions are modified.
Returns: None