本文整理汇总了Python中OCO_Matrix.OCO_Matrix.header[out_name]方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.header[out_name]方法的具体用法?Python OCO_Matrix.header[out_name]怎么用?Python OCO_Matrix.header[out_name]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCO_Matrix.OCO_Matrix
的用法示例。
在下文中一共展示了OCO_Matrix.header[out_name]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_spectra_files
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import header[out_name] [as 别名]
def write_spectra_files(output_dir, ids, data):
for curr_id, curr_data in zip(ids, data):
out_filename = '%s/%s.dat' % (output_dir, curr_id)
used_data = []
out_obj = OCO_Matrix()
out_obj.labels = FILE_LABELS
out_obj.units = FILE_UNITS
out_obj.file_id = FILE_ID_TMPL % (curr_id)
out_obj.data = numpy.zeros((curr_data['Num_Points'], len(FILE_LABELS)), dtype=float)
used_data.append('Num_Points')
for column_idx, column_name in enumerate(FILE_LABELS):
if curr_data.has_key(column_name):
out_obj.data[:, column_idx] = curr_data[column_name]
used_data.append(column_name)
header_dict = copy.copy(curr_data)
header_dict.update(HEADER_FILL_VALUES)
for data_name, data_values in header_dict.items():
if data_name in used_data:
continue
out_name = translate_header_name(data_name)
try:
if len(data_values.shape) == 0:
out_obj.header[out_name] = str(data_values)
else:
out_obj.header[out_name] = ' '.join([ str(item) for item in iter(data_values)])
except:
try:
out_obj.header[out_name] = str(data_values)
except:
print >>sys.stderr, 'Barfed on parsing %s with values: %s for header of file %s' % (data_name, data_values, out_filename)
print 'Writing: %s' % out_filename
out_obj.write(out_filename)