本文整理匯總了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)