<%doc>
This Mako template is intended to create a variable comparison report page for
Glance's report generation.

Created by Eva Schiffer Nov 2011.
Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved.
</%doc>

<%!
    import glance.report    as report
    import glance.constants as constants
%>

<%inherit file="basereport.txt"/>

<%block name="title">
    <%
        variableName = runInfo[constants.VARIABLE_TECH_NAME_KEY]
        variableDisplayName = variableName
        if constants.DISPLAY_NAME_KEY in runInfo:
            variableDisplayName = runInfo[constants.DISPLAY_NAME_KEY]
    %>
    ${variableDisplayName} Variable Comparison
</%block>

## this version of the config file path is escaped to be down in the variable report directory
<%block name="configFileLink">
    Please see <a href="${runInfo[constants.CONFIG_FILE_PATH_KEY]}">this copy of the configuration file</a>
</%block>

## additional filtering information specific to the variable being analyzed
<%block name="additionalFilterInfo">
    ## display info about the basic data filters if the data was filtered
    % if (constants.FILTER_FUNCTION_A_KEY in runInfo) and (not (runInfo[constants.FILTER_FUNCTION_A_KEY] is None)) :
        Note: The data for this variable from file A was filtered.<br>
        <% wasFiltered = True %>
    % endif
    % if (constants.FILTER_FUNCTION_B_KEY in runInfo) and (not (runInfo[constants.FILTER_FUNCTION_B_KEY] is None)) :
        Note: The data for this variable from file B was filtered.<br>
        <% wasFiltered = True %>
    % endif
</%block>

## these need to be linked out further to allow for variable directories; TODO, this won't work with deeper directories :(
<%block name="lonlatInvalidImages">
    <a href="../LonLatMismatch.A.png">
        View mismatching points in A's lon/lat system
    </a><br>
    <a href="../LonLatMismatch.B.png">
        View mismatching points in B's lon/lat system
    </a>
</%block>

## this is the main body block that includes most of the comparison info
<%block name="comparedData">
    
    ## show the original data images if we have any
    <%block name="originalImages">
    
    % if (len(imageNames[constants.ORIGINAL_IMAGES_KEY]) > 0) :
        <h3>Original Data</h3>
        <p>
            % for image in sorted(imageNames[constants.ORIGINAL_IMAGES_KEY]):
                <a href="./${image}"><img src="small.${image}"></a>
            % endfor
        </p>
    % endif
    
    </%block>
    
    ## this is the summary of how the data was compared
    <%block name="comparisonSummary">
    
    <h3>Comparison Information</h3>
    
    ## comparison parameters
    <p>
        ## display the variable names
        % if constants.VARIABLE_B_TECH_NAME_KEY in runInfo :
            variable name in A: ${runInfo[constants.VARIABLE_TECH_NAME_KEY]} <br>
            variable name in B: ${runInfo[constants.VARIABLE_B_TECH_NAME_KEY]} <br>
        % else :
            variable name: ${runInfo[constants.VARIABLE_TECH_NAME_KEY]} <br>
        % endif
        
        ## display the epsilon
        epsilon value: ${runInfo[constants.EPSILON_KEY]} <br>
        
        ## if there is an epsilon percent, also show that
        % if (constants.EPSILON_PERCENT_KEY in runInfo) and (runInfo[constants.EPSILON_PERCENT_KEY] is not None) :
            epsilon percent: ${runInfo[constants.EPSILON_PERCENT_KEY]}% <br>
        % endif
        
        ## display the missing value
        % if (constants.FILL_VALUE_ALT_IN_B_KEY in runInfo) and (not (runInfo[constants.FILL_VALUE_ALT_IN_B_KEY] is runInfo[constants.FILL_VALUE_KEY])) :
            "missing" data value in A: ${str(runInfo[constants.FILL_VALUE_KEY])}<br>
            "missing" data value in B: ${str(runInfo[constants.FILL_VALUE_ALT_IN_B_KEY])}<br>
        % else :
            "missing" data value: ${str(runInfo[constants.FILL_VALUE_KEY])}<br>
        % endif
        
        ## if there are units available, display those
        % if (constants.VAR_UNITS_A_KEY in runInfo) and (runInfo[constants.VAR_UNITS_A_KEY] is not None) :
            units in A: ${str(runInfo[constants.VAR_UNITS_A_KEY])}<br>
        % endif
        % if (constants.VAR_UNITS_B_KEY in runInfo) and (runInfo[constants.VAR_UNITS_B_KEY] is not None) :
            units in B: ${str(runInfo[constants.VAR_UNITS_B_KEY])}<br>
        % endif
    </p>
    
    </%block>
    
    ## show the comparison statistics
    <%block name="stats">
    
    <h3>Statistical Summary</h3>
    
    ## list out all of the statistics groups we have
    <dl>
    % for setName in sorted(list(statGroups)) :
        <% dataSet = statGroups[setName] %>
            <dt>
                ${setName}
            </dt>
            <dd>
                % for statName, statValue in sorted(list(dataSet.items())) :
                    ${statName}<%block name="statDocLink"><a href="${runInfo[constants.DOCUMENTATION_PATH_KEY]}">*</a></%block>: ${report.make_formatted_display_string(statValue)} <br>
                % endfor
                <br>
            <dd>
    % endfor
    </dl>
    
    </%block>
    
    ## display any comparison images we have, if appropriate
    <%block name="comparisonImages">
    
    <%
    hideComparisonImages = (constants.SHORT_CIRCUIT_DIFFS_KEY in runInfo) and runInfo[constants.SHORT_CIRCUIT_DIFFS_KEY]
    %>
    % if (len(imageNames[constants.COMPARED_IMAGES_KEY]) > 0) and (not hideComparisonImages) :
        <p>
            <% inSubSet = False %>
            % for image in sorted(imageNames[constants.COMPARED_IMAGES_KEY]) :
                ## if we have a plain image, display it
                % if (type(image) is str) :
                    % if inSubSet :
                        <hr>
                        <% inSubSet = False %>
                    % endif
                    <a href="./${image}"><img src="./small.${image}"></a>

                ## if we have a subset of images, separate it from the rest
                % elif (type(image) is list) :
                    <% inSubSet = True %>
                    <hr>
                    <blockquote>
                        % for subImage in image :
                            <a href="./${subImage}"><img src="./small.${subImage}"></a>
                        % endfor
                    </blockquote>
                % endif
                
            % endfor
        </p>
    % endif
    
    </%block>
    
</%block>

<%block name="attrsTitle">
<h3>Variable Attributes</h3>
</%block>