本文整理汇总了Python中OCO_Matrix.OCO_Matrix.get_header_value方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.get_header_value方法的具体用法?Python OCO_Matrix.get_header_value怎么用?Python OCO_Matrix.get_header_value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCO_Matrix.OCO_Matrix
的用法示例。
在下文中一共展示了OCO_Matrix.get_header_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resample_aerosol_file
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import get_header_value [as 别名]
def resample_aerosol_file(input_file, output_file, output_pressure_file, verbose=False):
# Load aerosol file to resample
aero_obj = OCO_Matrix(input_file)
# Load files containing pressure column
pres_obj = OCO_Matrix(output_pressure_file)
# Compute size information
num_in_levels = aero_obj.dims[0]
num_out_levels = pres_obj.dims[0]
# Load data into arrays
press_col_in = aero_obj.labels_lower.index("pressure")
pressures_in = numpy.zeros(num_in_levels, dtype=float)
for row_idx in range(num_in_levels):
pressures_in[row_idx] = aero_obj.data[row_idx][press_col_in]
press_col_out = pres_obj.labels_lower.index("pressure")
pressures_out = numpy.zeros(num_out_levels, dtype=float)
for row_idx in range(num_out_levels):
pressures_out[row_idx] = pres_obj.data[row_idx][press_col_out]
# Only do resample if the grids are different since the
# resampling operation has some issues at the top of the profile
# and will not 100% preserve values
if len(pressures_in) != len(pressures_out) or numpy.any(numpy.abs(pressures_in - pressures_out) > 1e-6):
all_in_cols = range(aero_obj.dims[1])
aero_columns = all_in_cols
all_in_cols.remove(press_col_in)
num_aerosols = len(aero_columns)
if aero_obj.get_header_value('retrieval_mode').lower().find('log') == 0:
aero_data = numpy.zeros((num_in_levels, len(aero_columns)), dtype=float)
for col in range(len(aero_columns)):
for row in range(num_in_levels):
acol = aero_columns[col]
aero_data[row, col] = math.exp( aero_obj.data[row, acol] )
has_log = True
else:
aero_data = aero_obj.data[:, aero_columns]
has_log = False
ext_out = resample_aerosol(pressures_in, aero_data, pressures_out, debug=verbose)
new_aero_data = numpy.zeros((num_out_levels, num_aerosols+1), dtype=float)
new_aero_data[:, press_col_in] = pressures_out
ext_idx = 0
for aero_data_idx in aero_columns:
if has_log:
for row in range(num_out_levels):
new_aero_data[row, aero_data_idx] = math.log(ext_out[ext_idx][row])
else:
new_aero_data[:, aero_data_idx] = ext_out[ext_idx]
ext_idx += 1
aero_obj.data = new_aero_data
# Write to output file whether we modified the data or not
aero_obj.write(output_file)