本文整理汇总了Python中OCO_Matrix.OCO_Matrix.header['num_ils_wndepend']方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.header['num_ils_wndepend']方法的具体用法?Python OCO_Matrix.header['num_ils_wndepend']怎么用?Python OCO_Matrix.header['num_ils_wndepend']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCO_Matrix.OCO_Matrix
的用法示例。
在下文中一共展示了OCO_Matrix.header['num_ils_wndepend']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract_ils_from_hdf
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import header['num_ils_wndepend'] [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)