in src/loading_manifest/osdu_laslog_manifest.py [0:0]
def create_laslog_manifest(laslog_name, preload_file_path, file_source, wellbore_id,
log_data, osdu_authorid,
schema_ns_name, schema_ns_value,
acl, legal, uom_persistable_reference,
schema_version, dict_schemas):
kind_wp = None
kind_wpc = None
kind_file = None
schema_id_lm = None
schema_id_wp = None
schema_id_wpc = None
schema_id_file = None
if schema_version == SCHEMA_VERSION_1_0_0:
kind_wp = cm.WorkProductManifest.KIND_GENERIC_WORK_PRODUCT_1_0_0
kind_wpc = cm.WorkProductComponentManifest.KIND_WELL_LOG_1_0_0
kind_file = cm.FileManifest.KIND_ID_GENERIC_DATASET_1_0_0
schema_id_lm = cm.LoadingManifest.SCHEMA_ID_1_0_0
schema_id_wp = cm.WorkProductManifest.SCHEMA_ID_GENERIC_WORK_PRODUCT_1_0_0
schema_id_wpc = cm.WorkProductComponentManifest.SCHEMA_ID_WELL_LOG_1_0_0
schema_id_file = cm.FileManifest.SCHEMA_ID_GENERIC_DATASET_1_0_0
elif schema_version == SCHEMA_VERSION_1_1_0:
kind_wp = cm.WorkProductManifest.KIND_GENERIC_WORK_PRODUCT_1_0_0
kind_wpc = cm.WorkProductComponentManifest.KIND_WELL_LOG_1_1_0
kind_file = cm.FileManifest.KIND_ID_GENERIC_DATASET_1_0_0
schema_id_lm = cm.LoadingManifest.SCHEMA_ID_1_0_0
schema_id_wp = cm.WorkProductManifest.SCHEMA_ID_GENERIC_WORK_PRODUCT_1_0_0
schema_id_wpc = cm.WorkProductComponentManifest.SCHEMA_ID_WELL_LOG_1_1_0
schema_id_file = cm.FileManifest.SCHEMA_ID_GENERIC_DATASET_1_0_0
# las_version = log_data.get('las_version', None)
# uniq_id = log_data.get('log_uniqid', None)
log_curves = log_data.get('log_curves', None)
log_quality_flag = log_data.get('log_name', None)
log_type = log_data.get('log_type', None)
log_source = log_data.get('log_source', None)
log_activity = log_data.get('log_activity', None)
log_version = log_data.get('log_version', None)
log_acquisition_vendor = log_data.get('logging_contractor', None)
log_depth_units = log_data.get('log_depth_units', None)
log_start_depth = log_data.get('log_start_depth', None)
log_stop_depth = log_data.get('log_stop_depth', None)
log_depth_step = log_data.get('log_depth_step', None)
log_top_depth = log_data.get('log_top_depth', None)
log_bottom_depth = log_data.get('log_bottom_depth', None)
# osdu (log_id, logging_tool) = log_info[log_quality_flag + '&' + uniq_id]
# log_id = None
logging_tool = None
# osdu wp_wpc_name = wellbore_name + " " + log_quality_flag + " LOG"
# wp_wpc_name = wellbore_name + " LOG"
# create the work product manifest
wp = cm.create_work_product_manifest(
kind=kind_wp,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
name=laslog_name,
description=cm.WorkProductManifest.DESCRIPTION_WELL_LOG
)
wpc = cm.create_work_product_component_manifest(
kind=kind_wpc,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
name=laslog_name,
description=cm.WorkProductComponentManifest.DESCRIPTION_WELL_LOG
)
wpc_data = wpc[cm.WorkProductComponentManifest.TAG_DATA]
if wellbore_id is None: # osdu
wellbore_id = ""
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_WELL_BORE_ID] \
= cm.WorkProductComponentManifest.WELL_BORE_ID + cm.url_quote(wellbore_id) + ":"
if log_type is not None and len(log_type) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_WELL_LOG_TYPE_ID] \
= cm.WorkProductComponentManifest.WELL_LOG_TYPE_ID + cm.url_quote(log_type) + ":"
if log_acquisition_vendor is not None and len(log_acquisition_vendor) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_SERVICE_COMPANY_ID] \
= cm.WorkProductComponentManifest.SERVICE_COMPANY_ID + cm.url_quote(log_acquisition_vendor) + ":"
if logging_tool is not None and len(logging_tool) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_TOOL_DESC] = logging_tool
if log_source is not None and len(log_source) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_LOG_SOURCE] = log_source
if log_activity is not None and len(log_activity) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_LOG_ACTIVITY] = log_activity
if log_version is not None and len(log_version) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_LOG_VERSION] = log_version
if log_top_depth is not None and len(log_top_depth) > 0:
# topd = dict()
# topd[cm.WorkProductComponentManifest.TAG_DATA_TOP_DEPTH_DEPTH] = float(log_top_depth)
# topd[cm.WorkProductComponentManifest.TAG_DATA_TOP_DEPTH_UOM] \
# = cm.WorkProductComponentManifest.UOM_ID + log_depth_units + ":"
# wpc_data[cm.WorkProductComponentManifest.TAG_DATA_TOP_DEPTH] = topd
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_TOP_DEPTH] = float(log_top_depth)
if log_bottom_depth is not None and len(log_bottom_depth) > 0:
# bottomd = dict()
# bottomd[cm.WorkProductComponentManifest.TAG_DATA_BOTTOM_DEPTH_DEPTH] \
# = float(log_bottom_depth)
# bottomd[cm.WorkProductComponentManifest.TAG_DATA_BOTTOM_DEPTH_UOM] \
# = cm.WorkProductComponentManifest.UOM_ID + log_depth_units + ":"
# wpc_data[cm.WorkProductComponentManifest.TAG_DATA_BOTTOM_DEPTH] = bottomd
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_BOTTOM_DEPTH] = float(log_bottom_depth)
if osdu_authorid is not None and len(osdu_authorid) > 0:
author_ids = list()
author_ids.append(osdu_authorid)
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_AUTHOR_IDS] = author_ids
wpc_log_curves = []
for log_curve in log_curves:
curve_item = dict()
mnemonic = log_curve.get('mnemonic', None)
top_depth = log_curve.get('top_depth', None)
bottom_depth = log_curve.get('bottom_depth', None)
depth_units = log_curve.get('depth_units', None)
curve_unit = log_curve.get('unit', None)
# osdu key_id = log_quality_flag + '&' + uniq_id + '&' + log_id + '&' + mnemonic
# osdu (curve_type, interpreter_name, business_value) = curve_info[key_id]
curve_type = None
interpreter_name = None
business_value = None
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_MNEMONIC] = mnemonic
if curve_type is not None and len(curve_type) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_LOG_CURVE_TYPE_ID] \
= cm.WorkProductComponentManifest.LOG_CURVE_TYPE_ID + cm.url_quote(curve_type) + ":"
if business_value is not None and len(business_value) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_LOG_CURVE_BV_ID] \
= cm.WorkProductComponentManifest.LOG_CURVE_BV_ID + cm.url_quote(business_value) + ":"
if log_quality_flag is not None and len(log_quality_flag) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_CURVE_QUALITY] \
= log_quality_flag
if interpreter_name is not None and len(interpreter_name) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_INTERPRETER_NAME] \
= interpreter_name
if top_depth is not None and len(top_depth) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_TOP_DEPTH] \
= float(top_depth)
if bottom_depth is not None and len(bottom_depth) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_BASE_DEPTH] \
= float(bottom_depth)
if schema_version == SCHEMA_VERSION_1_0_0:
if depth_units is not None and len(depth_units) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_DEPTH_UNIT] \
= cm.WorkProductComponentManifest.UOM_ID + cm.url_quote(depth_units) + ":"
if curve_unit is not None and len(curve_unit) > 0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_CURVE_UNIT] \
= cm.WorkProductComponentManifest.UOM_ID + cm.url_quote(curve_unit) + ":"
if schema_version >= SCHEMA_VERSION_1_1_0:
curve_item[cm.WorkProductComponentManifest.TAG_DATA_CURVES_NUMBER_OF_COLUMNS] = 1
wpc_log_curves.append(curve_item)
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_CURVES] = wpc_log_curves
if schema_version >= SCHEMA_VERSION_1_1_0:
if log_depth_step is not None and len(log_depth_step) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_INTERVAL] = float(log_depth_step)
if log_start_depth is not None and len(log_start_depth) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_START] = float(log_start_depth)
if log_stop_depth is not None and len(log_stop_depth) > 0:
wpc_data[cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_STOP] = float(log_stop_depth)
wpc_meta = wpc[cm.WorkProductComponentManifest.TAG_META]
if log_depth_units is not None and len(log_depth_units) > 0:
depth_unit_name = log_depth_units
depth_unit_pr = ""
for uom_key in uom_persistable_reference:
if uom_key.lower() == log_depth_units.lower():
depth_unit_name = uom_persistable_reference[uom_key].get('Name', depth_unit_name)
depth_unit_pr = uom_persistable_reference[uom_key].get('PersistableReference', "")
break
if depth_unit_pr == "":
logging.warning("PersistableReference not found for UOM: %s", log_depth_units)
meta_unit = dict()
wpc_meta.append(meta_unit)
meta_unit[cm.WorkProductComponentManifest.TAG_META_KIND] = cm.WorkProductComponentManifest.META_KIND_UNIT
meta_unit[cm.WorkProductComponentManifest.TAG_META_NAME] = depth_unit_name
meta_unit[cm.WorkProductComponentManifest.TAG_META_PERSIST_REF] = depth_unit_pr
meta_unit[cm.WorkProductComponentManifest.TAG_META_UOM] = \
cm.WorkProductComponentManifest.UOM_ID + cm.url_quote(log_depth_units) + ":"
meta_unit[cm.WorkProductComponentManifest.TAG_META_PROPERTY_NAMES] = []
meta_unit[cm.WorkProductComponentManifest.TAG_META_PROPERTY_NAMES].extend(
[
cm.WorkProductComponentManifest.TAG_DATA_TOP_DEPTH,
cm.WorkProductComponentManifest.TAG_DATA_BOTTOM_DEPTH,
cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_INTERVAL,
cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_START,
cm.WorkProductComponentManifest.TAG_DATA_SAMPLING_STOP,
cm.WorkProductComponentManifest.TAG_DATA_CURVES + "[]."
+ cm.WorkProductComponentManifest.TAG_DATA_CURVES_TOP_DEPTH,
cm.WorkProductComponentManifest.TAG_DATA_CURVES + "[]."
+ cm.WorkProductComponentManifest.TAG_DATA_CURVES_BASE_DEPTH
]
)
# create the laslog file manifest
laslog_file_name = laslog_name
f_doc = cm.create_file_manifest(
kind=kind_file,
schema_format_type=cm.FileManifest.SCHEMA_FORMAT_TYPE_ID_LAS2,
acl=acl,
legal=legal,
resource_security_classificaton=cm.ResourceSecurityClassification.RESTRICTED,
preload_file_path=(preload_file_path + laslog_file_name),
file_source=("" if file_source is None or len(file_source) == 0
else (file_source + laslog_file_name)),
file_name=laslog_file_name
)
# associate wpc with wp
cm.associate_work_product_components(wp, [wpc])
# associate laslog file with wpc
cm.associate_files(wpc, [f_doc])
# create laslog loading manifest
laslog = cm.create_loading_manifest(
work_product=wp,
work_product_components=[wpc],
files=[f_doc],
schema_id_lm=schema_id_lm,
schema_id_wp=schema_id_wp,
schema_id_wpc=schema_id_wpc,
schema_id_file=schema_id_file,
schema_ns_name=schema_ns_name,
schema_ns_value=schema_ns_value,
dict_schemas=dict_schemas
)
return laslog