當前位置: 首頁>>代碼示例>>Python>>正文


Python OCO_Matrix.header['function_type']方法代碼示例

本文整理匯總了Python中OCO_Matrix.OCO_Matrix.header['function_type']方法的典型用法代碼示例。如果您正苦於以下問題:Python OCO_Matrix.header['function_type']方法的具體用法?Python OCO_Matrix.header['function_type']怎麽用?Python OCO_Matrix.header['function_type']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCO_Matrix.OCO_Matrix的用法示例。


在下文中一共展示了OCO_Matrix.header['function_type']方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: extract_ils_from_hdf

# 需要導入模塊: from OCO_Matrix import OCO_Matrix [as 別名]
# 或者: from OCO_Matrix.OCO_Matrix import header['function_type'] [as 別名]
def extract_ils_from_hdf(hdf_file, output_dir, reverse=False):
    print 'Opening HDF file: %s' % hdf_file
    with contextlib.closing(h5py.File(hdf_file, 'r')) as hdf_obj:

        reported_soundings = []
        for snd_idx, rep_val in enumerate(hdf_obj['Metadata']['ReportedSoundings']):
            if rep_val > 0:
                reported_soundings.append( snd_idx + 1 )

        ils_delta_lambda      = hdf_obj['InstrumentHeader']['ils_delta_lambda']
        ils_relative_response = hdf_obj['InstrumentHeader']['ils_relative_response']

        num_bands          = ils_delta_lambda.shape[0]
        num_ils_parameters = ils_delta_lambda.shape[2]
        num_ils_wndepend   = ils_delta_lambda.shape[3]

        labels = [ 'ILS_PIXELS' ]
        for band_num in range(1, num_bands+1):
            labels.append('ILS_DELTA_LAMBDA_%d' % band_num)
            labels.append('ILS_RESPONSE_%d' % band_num)

        for snd_idx, sounding_id in enumerate(reported_soundings):
            output_filename = os.path.join(output_dir, 'ils_%d.dat' % sounding_id)
            print 'Extracting data for sounding %d into %s' % (sounding_id, output_filename)

            ils_file = OCO_Matrix()
            ils_file.data = numpy.zeros((num_ils_parameters * num_ils_wndepend, num_bands*2+1), dtype=float)

            row_beg = 0
            for color_index in range(num_ils_parameters):
                print 'Extracting color %d' % (color_index+1)
                row_end = row_beg+num_ils_wndepend
                ils_file.data[row_beg:row_end, 0] = color_index + 1

                for band_idx, col_idx in zip(range(num_bands), range(1,1+2*num_bands,2)):
                    ils_file.data[row_beg:row_end, col_idx]   = ils_delta_lambda[band_idx, snd_idx, color_index, :]

                    if reverse:
                        ils_file.data[row_beg:row_end, col_idx+1] = ils_relative_response[band_idx, snd_idx, color_index, :][::-1]
                    else:
                        ils_file.data[row_beg:row_end, col_idx+1] = ils_relative_response[band_idx, snd_idx, color_index, :]

                row_beg = row_end


            ils_file.file_id = 'Instrument Line Shape parameters for sounding posistion %d' % sounding_id

            ils_file.labels = labels

            ils_file.header['function_type'] = 'TABLE'
            ils_file.header['interpolation'] = '100 100 100'
            ils_file.header['num_ils_parameters'] = num_ils_parameters
            ils_file.header['num_ils_wndepend']   = num_ils_wndepend

            print 'Writing to %s' % output_filename
            ils_file.write(output_filename, verbose=True)
開發者ID:E-LLP,項目名稱:RtRetrievalFramework,代碼行數:58,代碼來源:extract_ils_from_hdf.py


注:本文中的OCO_Matrix.OCO_Matrix.header['function_type']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。