<?xml version="1.0"?>
<cd:ProductDefinition id="MIP_NLE_2P_v3" format="binary" last-modified="2011-04-28" xmlns:cd="http://www.stcorp.nl/coda/definition/2008/07">
  <cd:Record format="binary">
    <cd:Field name="mph">
      <cd:NamedType id="MPH"/>
    </cd:Field>
    <cd:Field name="sph">
      <cd:NamedType id="MIP_NL__2P_SPH_v1"/>
    </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="summary_quality_ads">
      <cd:Array>
        <cd:Description>Summary Quality ADS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[0]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_ADSR_summary_quality"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[0] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[0]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="scan_geolocation_ads">
      <cd:Array>
        <cd:Description>Scan Geolocation ADS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[1]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_ADSR_geolocation_v1"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[1] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[1]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="dataset_structure_ads">
      <cd:Array>
        <cd:Description>Structure ADS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_ADSR_structure_v2"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[2] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[2]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="scan_information_mds">
      <cd:Array>
        <cd:Description>Scan information MDS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[3]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_MDSR_info_v2"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[3] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[3]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="pt_retrieval_mds">
      <cd:Array>
        <cd:Description>p,T and Height Correction Profiles MDS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[4]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_MDSR_corr_v2"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[4] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[4]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="o3_retrieval_mds">
      <cd:Array>
        <cd:Dimension><![CDATA[$num_dsr[5]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_MDSR_vmr1_v2"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[5] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[5]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="h2o_retrieval_mds">
      <cd:Array>
        <cd:Dimension><![CDATA[$num_dsr[6]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_MDSR_vmr2_v2"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[6] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[6]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="microwindow_occupation_ads">
      <cd:Array>
        <cd:Description>Microwindows occupation matrices for p,T and trace-gas retrievals</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[7]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_ADSR_mw_v1"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[7] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[7]]]></cd:BitOffset>
    </cd:Field>
    <cd:Field name="processing_parameters_ads">
      <cd:Array>
        <cd:Description>Instrument and Processing Parameters ADS</cd:Description>
        <cd:Dimension><![CDATA[$num_dsr[8]]]></cd:Dimension>
        <cd:NamedType id="MIP_NL__2P_ADSR_params"/>
      </cd:Array>
      <cd:Available><![CDATA[$ds_available[8] != 0]]></cd:Available>
      <cd:BitOffset><![CDATA[$ds_offset[8]]]></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 = 9]]></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) == "SUMMARY QUALITY ADS         "); $ds_to_dsd_index[1] = index(/dsd, str(./ds_name) == "SCAN GEOLOCATION ADS        "); $ds_to_dsd_index[2] = index(/dsd, str(./ds_name) == "DATASET STRUCTURE ADS       "); $ds_to_dsd_index[3] = index(/dsd, str(./ds_name) == "SCAN INFORMATION MDS        "); $ds_to_dsd_index[4] = index(/dsd, str(./ds_name) == "PT RETRIEVAL MDS            "); $ds_to_dsd_index[5] = index(/dsd, str(./ds_name) == "O3 RETRIEVAL MDS            "); $ds_to_dsd_index[6] = index(/dsd, str(./ds_name) == "H2O RETRIEVAL MDS           "); $ds_to_dsd_index[7] = index(/dsd, str(./ds_name) == "MICROWINDOW OCCUPATION ADS  "); $ds_to_dsd_index[8] = index(/dsd, str(./ds_name) == "PROCESSING PARAMETERS ADS   ")]]></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 && !(bytes(/dsd[$ds_to_dsd_index[i]]/filename, 8) == "NOT USED"), 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>
  <cd:ProductVariable name="species_count">
    <cd:Init><![CDATA[$species_count = 2]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_info_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_info_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_info_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[0]/dsr_offset) != -1, i + 1, $structure_info_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_info_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_info_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[0]/dsr_offset) == -1, if(i > 0, $structure_info_cum_num_dsr[i - 1], 0), if($structure_info_next_index[i] == -1, $num_dsr[3], if(i > 0, $structure_info_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_info_next_index[i]]/ds_pointer[0]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[0]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[0]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="info_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[3]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[3] - 1 do $info_structure_index[i] = index($structure_info_cum_num_dsr, $structure_info_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_pt_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_pt_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_pt_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[1]/dsr_offset) != -1, i + 1, $structure_pt_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_pt_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_pt_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[1]/dsr_offset) == -1, if(i > 0, $structure_pt_cum_num_dsr[i - 1], 0), if($structure_pt_next_index[i] == -1, $num_dsr[4], if(i > 0, $structure_pt_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_pt_next_index[i]]/ds_pointer[1]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[1]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[1]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="pt_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[4]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[4] - 1 do $pt_structure_index[i] = index($structure_pt_cum_num_dsr, $structure_pt_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_vmr1_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_vmr1_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_vmr1_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[2]/dsr_offset) != -1, i + 1, $structure_vmr1_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_vmr1_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_vmr1_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[2]/dsr_offset) == -1, if(i > 0, $structure_vmr1_cum_num_dsr[i - 1], 0), if($structure_vmr1_next_index[i] == -1, $num_dsr[5], if(i > 0, $structure_vmr1_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_vmr1_next_index[i]]/ds_pointer[2]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[2]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[2]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="vmr1_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[5]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[5] - 1 do $vmr1_structure_index[i] = index($structure_vmr1_cum_num_dsr, $structure_vmr1_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_vmr2_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_vmr2_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_vmr2_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[3]/dsr_offset) != -1, i + 1, $structure_vmr2_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_vmr2_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_vmr2_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[3]/dsr_offset) == -1, if(i > 0, $structure_vmr2_cum_num_dsr[i - 1], 0), if($structure_vmr2_next_index[i] == -1, $num_dsr[6], if(i > 0, $structure_vmr2_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_vmr2_next_index[i]]/ds_pointer[3]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[3]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[3]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="vmr2_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[6]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[6] - 1 do $vmr2_structure_index[i] = index($structure_vmr2_cum_num_dsr, $structure_vmr2_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_mw_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_mw_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_mw_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[14]/dsr_offset) != -1, i + 1, $structure_mw_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_mw_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_mw_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[14]/dsr_offset) == -1, if(i > 0, $structure_mw_cum_num_dsr[i - 1], 0), if($structure_mw_next_index[i] == -1, $num_dsr[7], if(i > 0, $structure_mw_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_mw_next_index[i]]/ds_pointer[14]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[14]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[14]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="mw_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[7]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[7] - 1 do $mw_structure_index[i] = index($structure_mw_cum_num_dsr, $structure_mw_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_param_next_index">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[$structure_param_next_index[$num_dsr[2] - 1] = -1; for i = $num_dsr[2] - 2 to 0 step -1  do $structure_param_next_index[i] = if(int(/dataset_structure_ads[i + 1]/ds_pointer[16]/dsr_offset) != -1, i + 1, $structure_param_next_index[i + 1])]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="structure_param_cum_num_dsr">
    <cd:Dimension><![CDATA[$num_dsr[2]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[2] - 1 do $structure_param_cum_num_dsr[i] = if(int(/dataset_structure_ads[i]/ds_pointer[16]/dsr_offset) == -1, if(i > 0, $structure_param_cum_num_dsr[i - 1], 0), if($structure_param_next_index[i] == -1, $num_dsr[8], if(i > 0, $structure_param_cum_num_dsr[i - 1], 0) + (int(/dataset_structure_ads[$structure_param_next_index[i]]/ds_pointer[16]/dsr_offset) - int(/dataset_structure_ads[i]/ds_pointer[16]/dsr_offset)) / int(/dataset_structure_ads[i]/ds_pointer[16]/dsr_length)))]]></cd:Init>
  </cd:ProductVariable>
  <cd:ProductVariable name="param_structure_index">
    <cd:Dimension><![CDATA[$num_dsr[8]]]></cd:Dimension>
    <cd:Init><![CDATA[for i = 0 to $num_dsr[8] - 1 do $param_structure_index[i] = index($structure_param_cum_num_dsr, $structure_param_cum_num_dsr > i)]]></cd:Init>
  </cd:ProductVariable>
</cd:ProductDefinition>
