本文整理汇总了Python中coverage_model.ParameterContext类的典型用法代码示例。如果您正苦于以下问题:Python ParameterContext类的具体用法?Python ParameterContext怎么用?Python ParameterContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_lookup_value
def get_lookup_value(self,value):
placeholder = value.replace('LV_','')
document_key = ''
if '||' in placeholder:
document_key, placeholder = placeholder.split('||')
document_val = placeholder
placeholder = '%s_%s' % (placeholder, uuid4().hex)
pc = ParameterContext(name=placeholder, param_type=SparseConstantType(base_type=ConstantType(value_encoding='float64'), fill_value=-9999.))
pc.lookup_value = document_val
pc.document_key = document_key
ctxt_id = self.dataset_management.create_parameter_context(name=placeholder, parameter_context=pc.dump())
return ctxt_id, placeholder
示例2: get_cc_value
def get_cc_value(self, value):
placeholder = value.lower()
# Check to see if this coefficient exists already
hits, _ = Container.instance.resource_registry.find_resources(name=placeholder, restype=RT.ParameterContext, id_only=True)
if hits:
return hits[0], placeholder
pc = ParameterContext(name=placeholder, param_type=SparseConstantType(value_encoding='float64'), fill_value=-9999.)
pc.uom = '1'
ctxt_id = self.dataset_management.create_parameter_context(name=placeholder, parameter_context=pc.dump())
return ctxt_id, placeholder
示例3: create_simple_cc
def create_simple_cc(self):
contexts = {}
types_manager = TypesManager(self.dataset_management, None, None)
t_ctxt = ParameterContext('time', param_type=QuantityType(value_encoding=np.dtype('float64')))
t_ctxt.uom = 'seconds since 1900-01-01'
t_ctxt_id = self.dataset_management.create_parameter_context(name='time', parameter_context=t_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, t_ctxt_id)
contexts['time'] = t_ctxt, t_ctxt_id
temp_ctxt = ParameterContext('temp', param_type=QuantityType(value_encoding=np.dtype('float32')), fill_value=fill_value)
temp_ctxt.uom = 'deg_C'
temp_ctxt.ooi_short_name = 'TEMPWAT'
temp_ctxt_id = self.dataset_management.create_parameter_context(name='temp', parameter_context=temp_ctxt.dump(), ooi_short_name='TEMPWAT')
self.addCleanup(self.dataset_management.delete_parameter_context, temp_ctxt_id)
contexts['temp'] = temp_ctxt, temp_ctxt_id
func = NumexprFunction('offset', 'temp + offset', ['temp','offset'])
types_manager.get_pfunc = lambda pfid : func
func = types_manager.evaluate_pmap('pfid', {'temp':'temp', 'offset':'CC_coefficient'})
func_id = self.dataset_management.create_parameter_function('offset', func.dump())
self.addCleanup(self.dataset_management.delete_parameter_function, func_id)
offset_ctxt = ParameterContext('offset', param_type=ParameterFunctionType(func), fill_value=fill_value)
offset_ctxt.uom = '1'
offset_ctxt_id = self.dataset_management.create_parameter_context('offset', offset_ctxt.dump(), parameter_function_id=func_id)
self.addCleanup(self.dataset_management.delete_parameter_context, offset_ctxt_id)
contexts['offset'] = offset_ctxt, offset_ctxt_id
return contexts
示例4: create_illegal_char
def create_illegal_char(self):
contexts = {}
t_ctxt = ParameterContext('time', param_type=QuantityType(value_encoding=np.dtype('float64')))
t_ctxt.uom = 'seconds since 1900-01-01'
t_ctxt_id = self.dataset_management.create_parameter_context(name='time', parameter_context=t_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, t_ctxt_id)
contexts['time'] = (t_ctxt, t_ctxt_id)
i_ctxt = ParameterContext('ice-cream', param_type=QuantityType(value_encoding=np.dtype('float32')))
i_ctxt.uom = '1'
i_ctxt_id = self.dataset_management.create_parameter_context(name='ice-cream', parameter_context=i_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, i_ctxt_id)
contexts['ice-cream'] = (i_ctxt, i_ctxt_id)
return contexts
示例5: make_grt_qc
def make_grt_qc(self, name, data_product):
pfunc_id, pfunc = self.find_grt()
grt_min_id, grt_min_name = self.get_lookup_value('LV_grt_$designator_%s||grt_min_value' % data_product)
grt_max_id, grt_max_name = self.get_lookup_value('LV_grt_$designator_%s||grt_max_value' % data_product)
pmap = {'dat':name, 'dat_min':grt_min_name,'dat_max':grt_max_name}
pfunc.param_map = pmap
pfunc.lookup_values = [grt_min_id, grt_max_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_glblrng_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = '%s_GLBLRNG_QC' % dp_name
pc.display_name = '%s Global Range Test Quality Control Flag' % dp_name
pc.description = "The OOI Global Range quality control algorithm generates a QC flag for the input data point indicating whether it falls within a given range."
ctxt_id = self.dataset_management.create_parameter_context(name='%s_glblrng_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例6: create_lookup_contexts
def create_lookup_contexts(self):
contexts = {}
t_ctxt = ParameterContext('time', param_type=QuantityType(value_encoding=np.dtype('float64')))
t_ctxt.uom = 'seconds since 01-01-1900'
t_ctxt_id = self.dataset_management.create_parameter_context(name='time', parameter_context=t_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, t_ctxt_id)
contexts['time'] = (t_ctxt, t_ctxt_id)
temp_ctxt = ParameterContext('temp', param_type=QuantityType(value_encoding=np.dtype('float32')), fill_value=-9999)
temp_ctxt.uom = 'deg_C'
temp_ctxt_id = self.dataset_management.create_parameter_context(name='temp', parameter_context=temp_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, temp_ctxt_id)
contexts['temp'] = temp_ctxt, temp_ctxt_id
offset_ctxt = ParameterContext('offset_a', param_type=QuantityType(value_encoding='float32'), fill_value=-9999)
offset_ctxt.lookup_value = True
offset_ctxt_id = self.dataset_management.create_parameter_context(name='offset_a', parameter_context=offset_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, offset_ctxt_id)
contexts['offset_a'] = offset_ctxt, offset_ctxt_id
func = NumexprFunction('calibrated', 'temp + offset', ['temp','offset'], param_map={'temp':'temp', 'offset':'offset_a'})
func.lookup_values = ['LV_offset']
calibrated = ParameterContext('calibrated', param_type=ParameterFunctionType(func, value_encoding='float32'), fill_value=-9999)
calibrated_id = self.dataset_management.create_parameter_context(name='calibrated', parameter_context=calibrated.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, calibrated_id)
contexts['calibrated'] = calibrated, calibrated_id
return contexts
示例7: make_manual_upload_data_product
def make_manual_upload_data_product(self):
# Get a precompiled parameter dictionary with basic ctd fields
pdict_id = self.dataset_management.read_parameter_dictionary_by_name('ctd_parsed_param_dict',id_only=True)
context_ids = self.dataset_management.read_parameter_contexts(pdict_id, id_only=True)
# Add a handful of Calibration Coefficient parameters
for cc in ['temp_hitl_qc', 'cond_hitl_qc']:
c = ParameterContext(cc, param_type=BooleanType())
c.uom = '1'
context_ids.append(self.dataset_management.create_parameter_context(cc, c.dump()))
pdict_id = self.dataset_management.create_parameter_dictionary('manup_dict', context_ids, temporal_context='time')
data_product_id = self.create_data_product('manup_dp', pdict_id=pdict_id)
self.activate_data_product(data_product_id)
dataset_id, _ = self.resource_registry.find_objects(data_product_id, PRED.hasDataset, id_only=True)
return data_product_id, dataset_id[0]
示例8: make_cal_data_product
def make_cal_data_product(self):
# Get a precompiled parameter dictionary with basic ctd fields
pdict_id = self.dataset_management.read_parameter_dictionary_by_name('ctd_parsed_param_dict',id_only=True)
context_ids = self.dataset_management.read_parameter_contexts(pdict_id, id_only=True)
# Add a handful of Calibration Coefficient parameters
for cc in ['cc_ta0', 'cc_ta1', 'cc_ta2', 'cc_ta3', 'cc_toffset']:
c = ParameterContext(cc, param_type=SparseConstantType(value_encoding='float32', fill_value=-9999))
c.uom = '1'
context_ids.append(self.dataset_management.create_parameter_context(cc, c.dump()))
pdict_id = self.dataset_management.create_parameter_dictionary('calcoeff_dict', context_ids, temporal_context='time')
data_product_id = self.create_data_product('calcoeff_dp', pdict_id=pdict_id)
self.activate_data_product(data_product_id)
dataset_id, _ = self.resource_registry.find_objects(data_product_id, PRED.hasDataset, id_only=True)
return data_product_id, dataset_id[0]
示例9: make_stuckvalue_qc
def make_stuckvalue_qc(self, name, data_product):
pfunc_id, pfunc = self.find_stuck_value()
reso_id, reso_name = self.get_lookup_value('LV_svt_$designator_%s||svt_resolution' % data_product)
n_id, n_name = self.get_lookup_value('LV_svt_$designator_%s||svt_n' % data_product)
pmap = {'x' : name, 'reso': reso_name, 'num': n_name}
pfunc.param_map = pmap
pfunc.lookup_values = [reso_id, n_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_stuckvl_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = '%s_STUCKVL_QC' % dp_name
pc.display_name = '%s Stuck Value Test Quality Control Flag' % dp_name
pc.description = 'The OOI Stuck Value Test quality control algorithm generates a flag for repeated occurrence of one value in a time series.'
ctxt_id = self.dataset_management.create_parameter_context(name='%s_stuckvl_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例10: make_spike_qc
def make_spike_qc(self, name, data_product):
pfunc_id, pfunc = self.find_spike()
spike_acc_id, spike_acc_name = self.get_lookup_value('LV_spike_$designator_%s||acc' % data_product)
spike_n_id, spike_n_name = self.get_lookup_value('LV_spike_$designator_%s||spike_n' % data_product)
spike_l_id, spike_l_name = self.get_lookup_value('LV_spike_$designator_%s||spike_l' % data_product)
pmap = {'dat':name, 'acc':spike_acc_name, 'N':spike_n_name, 'L':spike_l_name}
pfunc.param_map = pmap
pfunc.lookup_values = [spike_acc_id, spike_n_id, spike_l_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_spketst_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom='1'
pc.ooi_short_name = '%s_SPKETST_QC' % dp_name
pc.display_name = '%s Spike Test Quality Control Flag' % dp_name
pc.description = "The OOI Spike Test quality control algorithm generates a flag for individual data values that deviate significantly from surrounding data values."
ctxt_id = self.dataset_management.create_parameter_context(name='%s_spketst_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例11: make_trendtest_qc
def make_trendtest_qc(self, name, data_product):
pfunc_id, pfunc = self.find_trend_test()
order_id, order_name = self.get_lookup_value('LV_trend_$designator_%s||polynomial_order' % data_product)
dev_id, dev_name = self.get_lookup_value('LV_trend_$designator_%s||standard_deviation' % data_product)
pmap = {"dat":name ,"t":'time',"ord_n":order_name,"ntsd":dev_name}
pfunc.param_map = pmap
pfunc.lookup_values = [order_id, dev_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_trndtst_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc,value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = '%s_TRNDTST_QC' % dp_name
pc.display_name = '%s Trend Test Test Quality Control Flag' % dp_name
pc.description = 'The OOI Trend Test quality control algorithm generates flags on data values within a time series where a significant fraction of the variability in the time series can be explained by a drift, where the drift is assumed to be a polynomial of specified order.'
ctxt_id = self.dataset_management.create_parameter_context(name='%s_trndtst_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例12: make_propagate_qc
def make_propagate_qc(self,inputs):
pfunc_id, pfunc = self.find_propagate_test()
pmap = {"strict_validation":False}
arg_list = ['strict_validation']
for i,val in enumerate(inputs):
if i >= 100:
break
pmap['array%s' % i] = val
arg_list.append('array%s' % i)
pfunc.param_map = pmap
pfunc.arg_list = arg_list
pc = ParameterContext(name='cmbnflg_qc', param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = 'CMBNFLG_QC'
pc.display_name = 'Combined Data Quality Control Flag'
pc.description = 'The purpose of this computation is to produce a single merged QC flag from a set of potentially many flags.'
ctxt_id = self.dataset_management.create_parameter_context(name='cmbnflg_qc', parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例13: make_localrange_qc
def make_localrange_qc(self, name, data_product):
pfunc_id, pfunc = self.find_localrange_test()
datlim_id, datlim = self.get_array_lookup_value('LV_lrt_$designator_%s||datlim' % data_product)
datlimz_id, datlimz = self.get_array_lookup_value('LV_lrt_$designator_%s||datlimz' % data_product)
dims_id, dims = self.get_string_array_lookup_value('LV_lrt_$designator_%s||dims' % data_product)
pmap = {"dat":name, "dims*":dims, "datlim*":datlim, "datlimz*":datlimz}
pfunc.param_map = pmap
pfunc.lookup_values = [datlim_id, datlimz_id, dims_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_loclrng_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = '%s_LOCLRNG_QC' % dp_name
pc.display_name = '%s Local Range Test Quality Control Flag' % dp_name
pc.description = 'The OOI Local Range Test is the computation to test whether a given data point falls within pre-defined ranges.'
ctxt_id = self.dataset_management.create_parameter_context(name='%s_loclrng_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例14: make_gradienttest_qc
def make_gradienttest_qc(self, name, data_product):
pfunc_id, pfunc = self.find_gradient_test()
ddatdx_id, ddatdx = self.get_lookup_value('LV_grad_$designator_%s_time||d_dat_dx' % data_product)
mindx_id, mindx = self.get_lookup_value('LV_grad_$designator_%s_time||min_dx' % data_product)
startdat_id, startdat = self.get_lookup_value('LV_grad_$designator_%s_time||start_dat' % data_product)
toldat_id, toldat = self.get_lookup_value('LV_grad_$designator_%s_time||tol_dat' % data_product)
pmap = {"dat":name, "x": 'time', 'ddatdx': ddatdx, 'mindx':mindx, 'startdat': startdat, 'toldat':toldat}
pfunc.param_map = pmap
pfunc.lookup_values = [ddatdx_id, mindx_id, startdat_id, toldat_id]
dp_name = self.dp_name(data_product)
pc = ParameterContext(name='%s_gradtst_qc' % dp_name.lower(), param_type=ParameterFunctionType(pfunc, value_encoding='|i1'))
pc.uom = '1'
pc.ooi_short_name = '%s_GRADTST_QC' % dp_name
pc.display_name = '%s Gradient Test Quality Control Flag' % dp_name
pc.description = 'The OOI Gradient Test is an automated quality control algorithm used on various OOI data products. This automated algorithm generates flags for data points according to whether changes between successive points are within a pre-determined range.'
ctxt_id = self.dataset_management.create_parameter_context(name='%s_gradtst_qc' % dp_name.lower(), parameter_type='function', parameter_context=pc.dump(), parameter_function_id=pfunc_id, ooi_short_name=pc.ooi_short_name, units='1', value_encoding='int8', display_name=pc.display_name, description=pc.description)
return ctxt_id, pc
示例15: create_qc_contexts
def create_qc_contexts(self):
contexts = {}
qc_whatever_ctxt = ParameterContext('qc_whatever', param_type=ArrayType())
qc_whatever_ctxt.uom = '1'
qc_whatever_ctxt_id = self.dataset_management.create_parameter_context(name='qc_whatever', parameter_context=qc_whatever_ctxt.dump())
self.addCleanup(self.dataset_management.delete_parameter_context, qc_whatever_ctxt_id)
contexts['qc_whatever'] = qc_whatever_ctxt, qc_whatever_ctxt_id
nexpr = NumexprFunction('range_qc', 'min < var > max', ['min','max','var'])
expr_id = self.dataset_management.create_parameter_function(name='range_qc', parameter_function=nexpr.dump())
self.addCleanup(self.dataset_management.delete_parameter_function, expr_id)
pmap = {'min':0, 'max':20, 'var':'temp'}
nexpr.param_map = pmap
temp_qc_ctxt = ParameterContext('temp_qc', param_type=ParameterFunctionType(function=nexpr), variability=VariabilityEnum.TEMPORAL)
temp_qc_ctxt.uom = '1'
temp_qc_ctxt_id = self.dataset_management.create_parameter_context(name='temp_qc', parameter_context=temp_qc_ctxt.dump(), parameter_function_id=expr_id)
self.addCleanup(self.dataset_management.delete_parameter_context, temp_qc_ctxt_id)
contexts['temp_qc'] = temp_qc_ctxt, temp_qc_ctxt_id
return contexts