本文整理汇总了Python中OCO_Matrix.OCO_Matrix.find_labels方法的典型用法代码示例。如果您正苦于以下问题:Python OCO_Matrix.find_labels方法的具体用法?Python OCO_Matrix.find_labels怎么用?Python OCO_Matrix.find_labels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCO_Matrix.OCO_Matrix
的用法示例。
在下文中一共展示了OCO_Matrix.find_labels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Process_File
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import find_labels [as 别名]
def Process_File(source, destination, fileKeywords, moduleSections, valuesDict, mapDict):
logger = logging.getLogger(os.path.basename(__file__))
for currSection in moduleSections:
if str(source) == str(destination):
raise IOError("source and destination must be different. will not overwrite source file")
rows = Apply_Template(moduleSections[0].Get_Keyword_Value("rows"), valuesDict, mapDict=mapDict)
columns = Apply_Template(moduleSections[0].Get_Keyword_Value("columns"), valuesDict, mapDict=mapDict)
identifier = Apply_Template(moduleSections[0].Get_Keyword_Value("identifier"), valuesDict, mapDict=mapDict)
initial_value = Apply_Template(moduleSections[0].Get_Keyword_Value("initial_value"), valuesDict, mapDict=mapDict)
map_filename = Apply_Template(moduleSections[0].Get_Keyword_Value("map_filename"), valuesDict, mapDict=mapDict)
modify = moduleSections[0].Get_Keyword_Value("modify")
# Load ranges from RANGES section of module
max_range_val = None
range_values = {}
for range_sect in moduleSections[0].Get_Section("->RANGES"):
for range_spec in range_sect.Get_Matrix_Data():
(range_name, range_str) = range_spec
if range_str.find(",") > 0:
curr_range = [float(val) for val in range_str.split(",")]
else:
curr_range = [float(val) for val in range_str.split()]
if max_range_val == None:
max_range_val = max(curr_range)
else:
max_range_val = max(max_range_val, max(curr_range))
range_values[range_name] = curr_range
if len(range_values) == 0:
logger.error("No index range list supplied for operating on source: %s" % source)
return
# Load source for data to map agains
data_obj = OCO_Matrix(source)
# Set columns to all if argument not supplied,
# Otherwise try parsing as an index range list failing that try
# using the specified columns as label names
if columns == None:
columns = range(data_obj.dims[1])
else:
try:
columns = index_range_list(columns)
except ValueError, TypeError:
columns = data_obj.find_labels(columns, match_case=False, indexes=True)
示例2: adjust_file_for_trend
# 需要导入模块: from OCO_Matrix import OCO_Matrix [as 别名]
# 或者: from OCO_Matrix.OCO_Matrix import find_labels [as 别名]
def adjust_file_for_trend(self, src_apriori_file, time_struct, dst_apriori_file=None):
if dst_apriori_file == None:
dst_apriori_file = src_apriori_file
if type(dst_apriori_file) is str and os.path.realpath(os.path.dirname(dst_apriori_file)) == os.path.realpath(self.apriori_db_path):
raise IOError('Can not modify apriori file as located in database path, it must be copied first')
apriori_obj = OCO_Matrix(src_apriori_file)
co2_col_idx = apriori_obj.labels.index(apriori_obj.find_labels(CO2_APRIORI_CO2_COL)[0])
co2_offset = self.get_apriori_offset(time_struct, debug_values=apriori_obj.header)
apriori_obj.data[:, co2_col_idx] += co2_offset
apriori_obj.header['co2_offset'] = co2_offset
apriori_obj.write(dst_apriori_file)