<?xml version="1.0"?>
<cd:ProductDefinition xmlns:cd="http://www.stcorp.nl/coda/definition/2008/07" xmlns:ct="http://www.stcorp.nl/coda/test/2008/10" id="ALD_U_N_2A_02_02" format="binary" last-modified="2008-07-01">
  <cd:Record format="binary">
    <cd:Description>Level 2A Product</cd:Description>
    <cd:Field name="mph">
      <cd:NamedType id="MPH_v1"/>
    </cd:Field>
    <cd:Field name="sph">
      <cd:NamedType id="Level_2A_SPH_02_02"/>
    </cd:Field>
    <cd:Field name="dsd">
      <cd:Array format="ascii">
        <cd:Dimension><![CDATA[$num_dsd]]></cd:Dimension>
        <cd:NamedType id="DSD"/>
      </cd:Array>
    </cd:Field>
    <cd:Field name="geolocation">
      <cd:Array>
        <cd:Description>Geolocation and AOCS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[0]]]></cd:Dimension>
        <cd:NamedType id="Level_2A_Geolocation_ADSR_02_02"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[0] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[0]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="product_confidence_data">
      <cd:Array>
        <cd:Description>Product Confidence Data</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[1]]]></cd:Dimension>
        <cd:NamedType id="Level_2A_PCD_ADSR_02_02"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[1] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[1]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="optical">
      <cd:Array>
        <cd:Description>Optical products</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
        <cd:NamedType id="Level_2A_Opt_MDSR_02_02"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[2] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[2]]]></cd:BitOffset>
    </cd:Field>
  </cd:Record>
  <cd:ProductVariable name="num_dsd">
    <cd:Init><![CDATA[$num_dsd = int(/mph/num_dsd)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="num_ds">
    <cd:Init><![CDATA[$num_ds = 3]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="ds_to_dsd_index">
    <cd:Dimension><![CDATA[$num_ds]]></cd:Dimension>
    <cd:Init><![CDATA[$ds_to_dsd_index[0] = index(/dsd, str(./ds_name) == "Geolocation_ADS             "); $ds_to_dsd_index[1] = index(/dsd, str(./ds_name) == "Product_Confidence_Data_ADS "); $ds_to_dsd_index[2] = index(/dsd, str(./ds_name) == "Optical_Properties_MDS      ")]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="ds_available">
    <cd:Dimension><![CDATA[$num_ds]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_ds - 1 do $ds_available[i] = if($ds_to_dsd_index[i] != -1 && int(/dsd[$ds_to_dsd_index[i]]/ds_size) != 0, 1, 0)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="ds_offset">
    <cd:Dimension><![CDATA[$num_ds]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_ds - 1 do $ds_offset[i] = 8 * int(/dsd[$ds_to_dsd_index[i]]/ds_offset)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="num_dsr">
    <cd:Dimension><![CDATA[$num_ds]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_ds - 1 do $num_dsr[i] = int(/dsd[$ds_to_dsd_index[i]]/num_dsr)]]></cd:Init>
  </cd:ProductVariable>
  <!-- MPH Cross File Tests -->
  <ct:NamedCrossFileTest id="MPH_Product"/>
  <ct:NamedCrossFileTest id="MPH_Proc_Stage"/>
  <ct:NamedCrossFileTest id="MPH_Ref_Doc"/>
  <ct:NamedCrossFileTest id="MPH_Acquisition_Station"/>
  <ct:NamedCrossFileTest id="MPH_Proc_Center"/>
  <ct:NamedCrossFileTest id="MPH_Proc_Time"/>
  <ct:NamedCrossFileTest id="MPH_Software_Ver"/>
  <ct:NamedCrossFileTest id="MPH_Sensing_Start"/>
  <ct:NamedCrossFileTest id="MPH_Sensing_Stop"/>
  <ct:NamedCrossFileTest id="MPH_Phase"/>
  <ct:NamedCrossFileTest id="MPH_Cycle"/>
  <ct:NamedCrossFileTest id="MPH_Rel_Orbit"/>
  <ct:NamedCrossFileTest id="MPH_Abs_Orbit"/>
  <ct:NamedCrossFileTest id="MPH_State_Vector_Time"/>
  <ct:NamedCrossFileTest id="MPH_Delta_UT1"/>
  <ct:NamedCrossFileTest id="MPH_X_Position"/>
  <ct:NamedCrossFileTest id="MPH_Y_Position"/>
  <ct:NamedCrossFileTest id="MPH_Z_Position"/>
  <ct:NamedCrossFileTest id="MPH_X_Velocity"/>
  <ct:NamedCrossFileTest id="MPH_Y_Velocity"/>
  <ct:NamedCrossFileTest id="MPH_Z_Velocity"/>
  <ct:NamedCrossFileTest id="MPH_Vector_Source"/>
  <ct:NamedCrossFileTest id="MPH_Utc_Sbt_Time"/>
  <ct:NamedCrossFileTest id="MPH_Sat_Binary_Time"/>
  <ct:NamedCrossFileTest id="MPH_Leap_Utc"/>
  <ct:NamedCrossFileTest id="MPH_Leap_Sign"/>
  <ct:NamedCrossFileTest id="MPH_Leap_Err"/>
  <ct:NamedCrossFileTest id="MPH_Product_Err"/>
  <ct:NamedCrossFileTest id="MPH_Tot_Size"/>
  <ct:NamedCrossFileTest id="MPH_Sph_Size"/>
  <ct:NamedCrossFileTest id="MPH_Num_Dsd"/>
  <ct:NamedCrossFileTest id="MPH_Dsd_Size"/>
  <ct:NamedCrossFileTest id="MPH_Num_Data_Sets"/>
  <!-- SPH Cross File Tests -->
  <ct:NamedCrossFileTest id="SPH_Sph_Descriptor"/>
  <ct:NamedCrossFileTest id="SPH_Num_BRC"/>
  <ct:NamedCrossFileTest id="SPH_Intersect_Start_Lat"/>
  <ct:NamedCrossFileTest id="SPH_Intersect_Start_Long"/>
  <ct:NamedCrossFileTest id="SPH_Intersect_Stop_Lat"/>
  <ct:NamedCrossFileTest id="SPH_Intersect_Stop_Long"/>
  <ct:NamedCrossFileTest id="SPH_Sat_Track"/>
  <ct:NamedCrossFileTest id="SPH_Max_Num_Prof"/>
  <ct:NamedCrossFileTest id="SPH_Num_Valid_Profiles"/>
</cd:ProductDefinition>
