Ejemplo n.º 1
0
    def create(self, **kwargs):

        win_ranges = self.window_ranges()
        bad_sample_mask = self.bad_sample_mask()

        if bad_sample_mask is not None:
            return rf.SpectralWindowRange(win_ranges, bad_sample_mask)
        else:
            return rf.SpectralWindowRange(win_ranges)
Ejemplo n.º 2
0
def rtr_comparison_base_config(**kwargs):
    """Make modifications to configuration so that ReFRACtor code matches the behavior of the
       OCO-2 software.
    """

    l1b_file = os.path.join(test_in_dir, "oco2_L1bScTG_06779a_151010_B8000r_170717081341-selected_ids.h5")
    met_file = os.path.join(test_in_dir, "oco2_ECMWFTG_06779a_151010_B8000r_170703073334-selected_ids.h5")
     

    config_def = retrieval_config_definition(l1b_file, met_file, sounding_id, **kwargs)

    # Reduce stopping point of window ranges by one to account for differences in behavior with old code
    mw = config_def['spec_win']['window_ranges']['value']
    for chan_idx in range(mw.shape[0]):
        mw[chan_idx, 0, 1] -= 1
    config_def['spec_win']['window_ranges']['value'] = mw

    # Use BRDF sufrace type
    config_def['atmosphere']['ground']['child'] = 'brdf'

    # Set to 1.0 to avoid difference where ReFRACtor has fixed the bug where table scale in
    # OCO code only applies itself within the low res, not high res spectral bounds
    config_def['atmosphere']['absorber']['CO2']['absorption']['table_scale'] = 1.0

    # Set z_matrix interpolation wavenumber ranges to what is used in expected daa
    rt_interp_wn = np.array([[[12962.5, 13172.1]],
                             [[6181.26, 6257.9]],
                             [[4808.22, 4883.57]]])
    rt_interp_win = rf.SpectralWindowRange(rf.ArrayWithUnit(rt_interp_wn, "cm^-1"))

    config_def['radiative_transfer']['spec_win'] = rt_interp_win

    return config_def
Ejemplo n.º 3
0
    def create(self, **kwargs):

        full_ranges = self.full_ranges()
        micro_windows = self.micro_windows()
        num_channels = full_ranges.rows

        # If micro_windows are not supplied use the full_ranges as the
        # window values.
        if micro_windows is None:
            micro_windows = full_ranges

        # Convert microwindows to the units
        mw_conv = micro_windows.convert_wave(full_ranges.units)

        # Map microwindows to spectral channels
        mapping = {chan_idx: [] for chan_idx in range(num_channels)}
        max_num_mw = 0
        for mw_range in mw_conv.value:
            # convert_wave may have reversed order
            mw_beg, mw_end = sorted(mw_range)

            match_found = False
            for chan_idx, (full_beg, full_end) in enumerate(full_ranges.value):
                if mw_beg >= full_beg and mw_end <= full_end:
                    mapping[chan_idx].append((mw_beg, mw_end))
                    match_found = True
                    max_num_mw = max(max_num_mw, len(mapping[chan_idx]))
                    break

            if not match_found:
                raise Exception(
                    'Could not find channel bounding microwindow: ({}, {})'.
                    format(mw_beg, mw_end))

        # Create microwindow ranges
        win_ranges = np.zeros((num_channels, max_num_mw, 2))
        for chan_idx in range(num_channels):
            for mw_idx, mw_range in enumerate(mapping[chan_idx]):
                win_ranges[chan_idx, mw_idx, :] = mw_range

        # Assign to configuration
        return rf.SpectralWindowRange(
            rf.ArrayWithUnit_double_3(win_ranges, full_ranges.units))