本文整理汇总了Python中OCO_Matrix.OCO_Matrix.header[SOURCE_FILE_HEADER_NAME]方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.header[SOURCE_FILE_HEADER_NAME]方法的具体用法?Python OCO_Matrix.header[SOURCE_FILE_HEADER_NAME]怎么用?Python OCO_Matrix.header[SOURCE_FILE_HEADER_NAME]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCO_Matrix.OCO_Matrix
的用法示例。
在下文中一共展示了OCO_Matrix.header[SOURCE_FILE_HEADER_NAME]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract_sounding_noise
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import header[SOURCE_FILE_HEADER_NAME] [as 别名]
def extract_sounding_noise(l1b_obj, sounding_id, gain_code=None, modification_params=None):
# Get the gain code used for current sounding id
if gain_code == None:
gain_code = l1b_obj.get_sounding_info('gain', sounding_id)
out_obj = OCO_Matrix()
if hasattr(gain_code, 'shape'):
if numpy.all(gain_code == gain_code[0]):
gain_code = gain_code[0]
else:
raise ValueError('Sounding %s does not have same gain code for both polarizations: %s' % (sounding_id, gain_code))
noise_data = l1b_obj.get_error_data(sounding_id, calculate_noise=False, gain_code=gain_code)
max_diodes = 0
for band_cnv, band_noise_val in noise_data:
num_diodes = band_cnv.shape[-1]
max_diodes = max(max_diodes, num_diodes)
if modification_params != None:
radiances = l1b_obj.get_radiance_data(sounding_id)
band_noise_values = []
cnv_data = numpy.zeros((max_diodes, len(BAND_COLUMN_LABELS)), dtype=float)
for band_idx, band_noise_tuple in enumerate(noise_data):
band_cnv, band_noise_val = band_noise_tuple
if len(band_cnv.shape) > 1:
band_cnv = numpy.average( band_cnv, axis=0 )
if hasattr(band_noise_val, 'shape') and band_noise_val.shape[0] > 1:
band_noise_val = numpy.average( band_noise_val, axis=0 )
num_diodes = band_cnv.shape[0]
band_noise_values.append( band_noise_val)
if modification_params != None:
band_params = modification_params[band_idx]
out_obj.header[BAND_PARAM_HEADER_TMPL % (band_idx+1)] = ' '.join([str(curr_val) for curr_val in band_params])
# Derive signal from average of top N radiance values
band_radiance = radiances[band_idx]
if len(band_radiance.shape) > 1:
band_radiance = numpy.average(band_radiance, axis=0)
band_radiance.sort()
signal = numpy.mean(band_radiance[-SIGNAL_AVG_COUNT:])
# Calculated updated band_cnv
param_a1, param_b1 = band_params
band_cnv[:] = (param_a1 * signal) / band_noise_val + param_b1 * band_cnv[:]
cnv_data[:num_diodes, band_idx*2] = numpy.arange(1,num_diodes+1)
cnv_data[:num_diodes, band_idx*2+1] = band_cnv[:]
out_obj.header[NOISE_VALUES_HEADER_NAME] = ' '.join([ ('%e' % val) for val in band_noise_values ])
out_obj.header[SOURCE_FILE_HEADER_NAME] = os.path.realpath(l1b_obj.filename)
out_obj.header[SOURCE_SOUNDING_HEADER_NAME] = sounding_id
out_obj.file_id = FILE_ID % (sounding_id, gain_code)
out_obj.labels = BAND_COLUMN_LABELS
out_obj.data = cnv_data
return out_obj