Skip to content

(nested subsector) queries fail using rgcam #91

Description

@mbins

rgcam often fails when running queries from GCAM's Main_queries.xml with (nested subsector) in the query name. The issue appears to stem from the fact that these queries use variable depth of subsector nesting in a single query (indicated by the the // between subsector & technology, as in the example below).

            <emissionsQueryBuilder title="CO2 emissions by tech (nested subsector) (excluding resource production)">
                <axis1 name="technology">technology</axis1>
                <axis2 name="Year">emissions</axis2>
                <xPath buildList="true" dataName="emissions" group="false" sumAll="false">*[@type = 'sector' ]/*[@type='subsector']//*[@type='technology']//
            CO2/emissions/node()</xPath>
                <comments/>
            </emissionsQueryBuilder>

A workaround is to split the query in two - one with standard sector/subsector/technology structure, and another that specifies the depth of subsector nesting (note that this requires knowing the number of nesting subsectors in the sectors the query is targeting) - in order to extract the info for nested and non-nested subsectors, which can then be recombined.
example of query for standard sector/subsector/technology structure (note that the structure is *[@type='subsector']/ instead of *[@type='subsector']//:

            <emissionsQueryBuilder title="CO2 emissions by tech (excluding resource production)">
                <axis1 name="technology">technology</axis1>
                <axis2 name="Year">emissions</axis2>
                <xPath buildList="true" dataName="emissions" group="false" sumAll="false">*[@type = 'sector' ]/*[@type='subsector']/*[@type='technology']//
            CO2/emissions/node()</xPath>
                <comments/>
            </emissionsQueryBuilder>

example of query for one nested subsector (2 subsectors in total; note that *[@type='subsector']/ is repeated twice):

        <queryGroup name="CO2 emissions">
            <emissionsQueryBuilder title="CO2 emissions by tech (nested subsector) (excluding resource production)">
                <axis1 name="technology">technology</axis1>
                <axis2 name="Year">emissions</axis2>
                <xPath buildList="true" dataName="emissions" group="false" sumAll="false">*[@type = 'sector' ]/*[@type='subsector']/*[@type='subsector']/*[@type='technology']//
            CO2/emissions/node()</xPath>
                <comments/>
            </emissionsQueryBuilder>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions