## GPT Cookbook: Collocate

Creates a new file which is a collocated joining of two input source files.

Example 1 Files Which Contain Unique Band Names

This creates a collocated file from two file which contain unique band names. No band names in one input file can match those in the other input file. This is a very simple example of joining two level3 mapped files together.

Command Line Entry

    gpt CollocateGraphEx01.xml -Pifile1=V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc -Pifile2=V20172132017243.L3m_MO_SNPP_KD490_Kd_490_9km.nc -Pofile=CollocateEx01.dim

File = CollocateGraphEx01.xml

    <graph id="CollocateGraphEx01">
        <version>1.0</version>
        <node id="Read">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile1}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Read(2)">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile2}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="CollocateNode">
            <operator>Collocate</operator>
            <sources>
                <sourceProduct refid="Read"/>>
                <sourceProduct.1 refid="Read(2)"/>>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <targetProductType>COLLOCATED</targetProductType>
                <renameMasterComponents>false</renameMasterComponents>
                <renameDependentComponents>false</renameDependentComponents>
                <resamplingType>NEAREST_NEIGHBOUR</resamplingType>
            </parameters>
        </node>
        <node id="Write">
            <operator>Write</operator>
            <sources>
                <sourceProduct refid="Collocate"/>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ofile}</file>
                <formatName>BEAM-DIMAP</formatName>
            </parameters>
        </node>
    </graph>

Here is what example 1 would look like if you use the GUI, in which case there are no variables. The following graph will load into the GUI via the GraphBuilder tool (note: you need to edit the ifile1, ifile2 and ofile paths).

File = CollocateGraphGUIEx01.xml

    <graph id="Graph">
        <version>1.0</version>
        <node id="Read">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>/Users/seadas/GPT_Cookbook/CollocateEx01/V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Read(2)">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>/Users/seadas/GPT_Cookbook/CollocateEx01/V20172132017243.L3m_MO_SNPP_KD490_Kd_490_9km.nc</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="CollocateNode">
            <operator>Collocate</operator>
            <sources>
                <sourceProduct refid="Read"/>>
                <sourceProduct.1 refid="Read(2)"/>>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <sourceProductPaths/>
                <masterProductName>V20172132017243.L3m_MO_SNPP_CHL_chlor_a_9km.nc</masterProductName>
                <targetProductName>_collocated</targetProductName>
                <targetProductType>COLLOCATED</targetProductType>
                <renameMasterComponents>false</renameMasterComponents>
                <renameDependentComponents>false</renameDependentComponents>
                <masterComponentPattern>${ORIGINAL_NAME}_M</masterComponentPattern>
                <dependentComponentPattern>${ORIGINAL_NAME}_S${DEPENDENT_NUMBER_ID}</dependentComponentPattern>
                <resamplingType>NEAREST_NEIGHBOUR</resamplingType>
            </parameters>
        </node>
        <node id="Write">
            <operator>Write</operator>
            <sources>
                <sourceProduct refid="Collocate"/>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>/Users/seadas/GPT_Cookbook/CollocateEx01/Collocate.dim</file>
                <formatName>BEAM-DIMAP</formatName>
            </parameters>
        </node>
        <applicationData id="Presentation">
            <Description/>
            <node id="Read">
                <displayPosition x="37.0" y="134.0"/>
            </node>
            <node id="Read(2)">
                <displayPosition x="59.0" y="198.0"/>
            </node>
            <node id="Collocate">
                <displayPosition x="264.0" y="254.0"/>
            </node>
            <node id="Write">
                <displayPosition x="455.0" y="135.0"/>
            </node>
        </applicationData>
    </graph>

Example 2 Files Which May Contain Identical Band Names

This creates a collocated file from two file which may contain identical band names. To accomplish this, the original band name is preserved with the addition of a suffix relating to which source file the band came from.

Command Line Entry

    gpt CollocateGraphEx02.xml -p CollocateEx02.par -Pifile1=AQUA_MODIS.20020101_20021231.L3m.YR.NSST.sst.9km.nc -Pifile2=AQUA_MODIS.20160101_20161231.L3m.YR.NSST.sst.9km.nc -Pofile=CollocateEx02.dim

File = CollocateGraphEx02.xml

    <graph id="CollocateGraphEx02">
        <version>1.0</version>
        <node id="Read">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile1}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Read(2)">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile2}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Collocate">
            <operator>Collocate</operator>
            <sources>
                <sourceProduct refid="Read"/>>
                <sourceProduct.1 refid="Read(2)"/>>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <targetProductType>COLLOCATED</targetProductType>
                <renameMasterComponents>${renameReference}</renameMasterComponents>
                <renameDependentComponents>${renameDependent}</renameDependentComponents>
                <masterComponentPattern>${referenceComponentPattern}</masterComponentPattern>
                <dependentComponentPattern>${dependentComponentPattern}</dependentComponentPattern>
                <resamplingType>${resamplingType}</resamplingType>
            </parameters>
        </node>
        <node id="Write">
            <operator>Write</operator>
            <sources>
                <sourceProduct refid="Collocate"/>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ofile}</file>
                <formatName>BEAM-DIMAP</formatName>
            </parameters>
        </node>
    </graph>

File = CollocateEx02.par

    renameReference=true
    renameDependent=true
    referenceComponentPattern=${ORIGINAL_NAME}_R
    dependentComponentPattern=${ORIGINAL_NAME}_D
    resamplingType=NEAREST_NEIGHBOUR

Example 3 Use of Suffix as Parameter

A slight variant on example 2 where now we pass in band names suffixes related to the actual input file names.

Command Line Entry

    gpt CollocateGraphEx03.xml -p CollocateEx03.par -Pifile1=AQUA_MODIS.20020101_20021231.L3m.YR.NSST.sst.9km.nc -Pifile2=AQUA_MODIS.20160101_20161231.L3m.YR.NSST.sst.9km.nc -PreferenceSuffix=2002 -PdependentSuffix=2016 -Pofile=CollocateEx03.dim

File = CollocateGraphEx03.xml

    <graph id="CollocateGraphEx03">
      <version>1.0</version>
            <node id="Read">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile1}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Read(2)">
            <operator>Read</operator>
            <sources/>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ifile2}</file>
                <formatName>SeaDAS-L3</formatName>
            </parameters>
        </node>
        <node id="Collocate">
            <operator>Collocate</operator>
            <sources>
                <sourceProduct refid="Read"/>>
                <sourceProduct.1 refid="Read(2)"/>>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <targetProductType>COLLOCATED</targetProductType>
                <renameMasterComponents>${renameReference}</renameMasterComponents>
                <renameDependentComponents>${renameDependent}</renameDependentComponents>
                <masterComponentPattern>${ORIGINAL_NAME}_${referenceSuffix}</masterComponentPattern>
                <dependentComponentPattern>${ORIGINAL_NAME}_${dependentSuffix}</dependentComponentPattern>
                <resamplingType>${resamplingType}</resamplingType>
            </parameters>
        </node>
        <node id="Write">
            <operator>Write</operator>
            <sources>
                <sourceProduct refid="Collocate"/>
            </sources>
            <parameters class="com.bc.ceres.binding.dom.XppDomElement">
                <file>${ofile}</file>
                <formatName>BEAM-DIMAP</formatName>
            </parameters>
        </node>
    </graph>

File = CollocateEx03.par

    renameReference=true
    renameDependent=true
    resamplingType=NEAREST_NEIGHBOUR

Notes 1 Resampling Options

Here is a full list of the resampling options and their specific names as used by the Collocate operator. Please be aware that these names differ for the operators Reproject and Mosaic. We will address this in a future SeaDAS release.

    resamplingType=NEAREST_NEIGHBOUR
    resamplingType=BILINEAR_INTERPOLATION
    resamplingType=CUBIC_CONVOLUTION
    resamplingType=BISINC_INTERPOLATION
    resamplingType=BICUBIC_INTERPOLATION