nvcl_kit package¶
Submodules¶
nvcl_kit.reader module¶
This module is the main interface used to NVCL borehole data from the NVCL services..
-
nvcl_kit.reader.
ENFORCE_IS_PUBLIC
= True¶ Enforce the ‘is_public’ flag , i.e. any data with ‘is_public’ set to ‘false’ will be ignored
-
nvcl_kit.reader.
LOG_LVL
= 20¶ Initialise debug level, set to ‘logging.INFO’ or ‘logging.DEBUG’
-
nvcl_kit.reader.
MAX_DEPTH
= 10000.0¶ Default maximum depth to search for boreholes
-
nvcl_kit.reader.
MIN_DEPTH
= 0.0¶ Default minimum depth to search for boreholes
-
class
nvcl_kit.reader.
NVCLReader
(param_obj, wfs=None, log_lvl=None)¶ Bases:
object
A class to extract NVCL borehole data (see README.md for details)
- Parameters
param_obj –
SimpleNamespace() object with parameters. Fields are:
NVCL_URL - URL of NVCL service
WFS_URL - URL of WFS service, GeoSciML V4.1 BoreholeView
WFS_VERSION - (optional - default “1.1.0”)
BOREHOLE_CRS - (optional - default “EPSG:4326”)
DEPTHS - (optional) Tuple of range of depths (min,max) [metres]
POLYGON - (optional) 2D ‘shapely.geometry.LinearRing’ object, only boreholes within this ring are retrieved
BBOX - (optional - default {“west”: -180.0,”south”: -90.0,”east”: 180.0,”north”: 0.0}) 2D bounding box in EPSG:4326, only boreholes within box are retrieved
MAX_BOREHOLES - (optional - default 0) Maximum number of boreholes to retrieve. If < 1 then all boreholes are loaded
e.g. from types import SimpleNamespace from shapely.geometry.polygon import LinearRing param_obj = SimpleNamespace() # Uses EPSG:4326 param_obj.BBOX = { "west": 132.76, "south": -28.44, "east": 134.39, "north": -26.87 } # Or use a POLYGON instead of a BBOX param_obj.POLYGON = LinearRing([(132.76, -28.44), (132.76, -26.87), (134.39, -26.87), (134.39, -28.44), (132.76, -28.44)]) param_obj.DEPTHS = (100.0, 900.0) param_obj.WFS_URL = "http://blah.blah.blah/geoserver/wfs" param_obj.NVCL_URL = "https://blah.blah.blah/nvcl/NVCLDataServices" param_obj.MAX_BOREHOLES = 20
wfs – optional owslib ‘WebFeatureService’ object
log_lvl – optional logging level (see ‘logging’ package), default is logging.INFO
NOTE: Check if ‘wfs’ is not ‘None’ to see if this instance initialised properly
-
get_all_imglogs
(dataset_id)¶ Retrieves a list of all log objects from mosaic service
- Parameters
dataset_id – dataset id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace() objects, attributes are: log_id, log_name, sample_count. On error returns empty list
-
get_borehole_data
(log_id, height_resol, class_name, top_n=1)¶ Retrieves borehole mineral data for a borehole
- Parameters
log_id – borehole log identifier, string e.g. ‘ce2df1aa-d3e7-4c37-97d5-5115fc3c33d’ This is the first id from the list of triplets [log id, log type, log name] fetched from ‘get_imagelog_data()’
height_resol – height resolution, float
class_name – name of mineral class
top_n – optional number
- Returns
dict: key - depth, float; value - if top_n=1 then SimpleNamespace( ‘colour’= RGBA float tuple, ‘className’= class name, ‘classText’= mineral name ) & if top_n>1 then [ SimpleNamespace(..) .. ]
-
get_boreholes_list
()¶ Returns a list of dictionary objects, extracted from WFS requests of boreholes. Fields are mostly taken from GeoSciML v4.1 Borehole View:
‘nvcl_id’, ‘identifier’, ‘name’, ‘description’, ‘purpose’, ‘status’, ‘drillingMethod’, ‘operator’, ‘driller’, ‘drillStartDate’, ‘drillEndDate’, ‘startPoint’, ‘inclinationType’, ‘href’, ‘boreholeMaterialCustodian’, ‘boreholeLength_m’, ‘elevation_m’, ‘elevation_srs’, ‘positionalAccuracy’, ‘source’, ‘x’, ‘y, ‘z’, ‘parentBorehole_uri’, ‘metadata_uri’, ‘genericSymbolizer’
- NB:
Depending on the WFS, not all fields will have values
‘href’ corresponds to ‘gsmlp:identifier’
‘x’, ‘y’, ‘z’ are x-coordinate, y-coordinate and elevation
‘nvcl_id’ is the GML ‘id’, used as an id in the NVCL services
- Returns
a list of dictionaries whose fields correspond to a response from a WFS request of GeoSciML v4.1 BoreholeView
-
get_dataset_list
(nvcl_id)¶ Retrieves a list of dataset objects
- Parameters
nvcl_id – NVCL ‘holeidentifier’ parameter, the ‘nvcl_id’ from each dict item retrieved from ‘get_boreholes_list()’ or ‘get_nvcl_id_list()’
- Returns
a list of SimpleNamespace objects, attributes are: dataset_id, dataset_name, borehole_uri, tray_id, section_id, domain_id
-
get_datasetid_list
(nvcl_id)¶ Retrieves a list of dataset ids
- Parameters
nvcl_id – NVCL ‘holeidentifier’ parameter, the ‘nvcl_id’ from each dict item retrieved from ‘get_boreholes_list()’ or ‘get_nvcl_id_list()’
- Returns
a list of dataset ids
-
get_imagelog_data
(nvcl_id)¶ Retrieves a set of image log data for a particular borehole
- Parameters
nvcl_id – NVCL ‘holeidentifier’ parameter, the ‘nvcl_id’ from each dict item retrieved from ‘get_boreholes_list()’ or ‘get_nvcl_id_list()’
- Returns
a list of SimpleNamespace() objects with attributes: log_id, log_type, log_name
-
get_imagery_imglogs
(dataset_id)¶ Retrieves ‘Imagery’ log objects from mosaic service
- Parameters
dataset_id – dataset id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace objects. Fields are: ‘log_id’, ‘log_name’, ‘sample_count’. On error returns an empty list.
-
get_mosaic_image
(log_id, **options)¶ Retrieves images of NVCL core trays
- Parameters
log_id – obtained through calling ‘get_mosaic_imglogs()’ or ‘get_tray_thumb_imglogs()’ or ‘get_tray_image_imglogs()’ or ‘get_imagery_imglogs()’
options – optional parameters: width: number of column the images are to be displayed, default value=3 startsampleno: the first sample image to be displayed, default value=0 endsampleno: the last sample image to be displayed, default value=99999
- Returns
NVCL core tray images
-
get_mosaic_imglogs
(dataset_id)¶ Retrieves a list of ‘Mosaic’ log objects from mosaic service
- Parameters
dataset_id – dataset id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace objects. Fields are: ‘log_id’, ‘log_name’, ‘sample_count’. On error returns an empty list.
-
get_nvcl_id_list
()¶ Returns a list of NVCL ids, can be used as input to other ‘nvcl_kit’ API calls e.g. get_spectrallog_data()
- Returns
a list of NVCL id strings
-
get_profilometer_data
(nvcl_id)¶ Retrieves a set of profilometer logs for a particular borehole
- Parameters
nvcl_id – NVCL ‘holeidentifier’ parameter, the ‘nvcl_id’ from each dict item retrieved from ‘get_boreholes_list()’ or ‘get_nvcl_id_list()’
- Returns
a list of SimpleNamespace() objects with attributes: log_id, log_name, sample_count, floats_per_sample, min_val, max_val
-
get_sampled_scalar_data
(log_id, **options)¶ Returns data in downsampled format, to a certain height resolution
- Parameters
log_id – obtained through calling ‘get_scalar_logs()’
outputformat – (optional) string ‘csv’ or ‘json’
startdepth – (optional) start of depth range, in metres from borehole collar
enddepth – (optional) end of depth range, in metres from borehole collar
interval – (optional) resolution to bin or average over
-
get_scalar_data
(log_id_list)¶ Downloads scalar data in CSV format
- Parameters
log_id_list – a list of log ids obtained through calling ‘get_scalar_logs()’
- Returns
scalar data in CSV format
-
get_scalar_logs
(dataset_id)¶ Retrieves a list of log objects for scalar plot service
- Parameters
dataset_id – dataset_id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace() objects, attributes are: log_id, log_name, is_public, log_type, algorithm_id. On error returns empty list
-
get_spectrallog_data
(nvcl_id)¶ Retrieves a set of spectral log data for a particular borehole
- Parameters
nvcl_id – NVCL ‘holeidentifier’ parameter, the ‘nvcl_id’ from each dict item retrieved from ‘get_boreholes_list()’ or ‘get_nvcl_id_list()’
- Returns
a list of SimpleNamespace() objects with attributes: log_id, log_name, wavelength_units, sample_count, script, wavelengths
-
get_tray_depths
(log_id)¶ Gets tray depths
- Parameters
log_id – obtained through calling ‘get_tray_thumb_imglogs()’ or ‘get_tray_imglogs()’
- Returns
a list of SimpleNamespace objects, with attributes: ‘sample_no’, ‘start_value’ and ‘end_value’
-
get_tray_imglogs
(dataset_id)¶ Retrieves ‘Tray Image’ log objects from mosaic service
- Parameters
dataset_id – dataset id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace objects. Fields are: ‘log_id’, ‘log_name’, ‘sample_count’. On error returns an empty list.
-
get_tray_thumb_html
(dataset_id, log_id, **options)¶ Gets core tray thumbnail images as HTML
- Parameters
dataset_id – obtained through calling ‘get_datasetid_list()’
log_id – obtained through calling ‘get_tray_thumb_imglogs()’
width – specify the number of column the images are to be displayed, default value=3
startsampleno – the first sample image to be displayed, default value=0
endsampleno – the last sample image to be displayed, default value=99999
- Returns
thumbnail image in HTML format
-
get_tray_thumb_imglogs
(dataset_id)¶ Retrieves a list of ‘Tray Thumbnail Images’ log objects from mosaic service
- Parameters
dataset_id – dataset id, taken from ‘get_datasetid_list()’ or ‘get_dataset_list()’
- Returns
a list of SimpleNamespace objects. Fields are: ‘log_id’, ‘log_name’, ‘sample_count’. On error returns an empty list.
-
get_tray_thumb_jpg
(log_id, sample_no='0')¶ Gets core tray thumbnail images as JPEG
- Parameters
log_id – obtained through calling ‘get_tray_thumb_imglogs()’
sample_no – sample number, string e.g. ‘0’,’1’,’2’… optional, default is ‘0’
- Returns
thumbnail image in PNG format
-
plot_scalar_png
(log_id, **options)¶ Draws a plot as an image in PNG format.
- Parameters
log_id – obtained through calling ‘get_scalar_logs()’
startdepth – (optional) the start depth of a borehole collar, default value=0
enddepth – (optional) the end depth of a borehole collar, default value=99999
samplinginterval – (optional) the interval of the sampling, default value=1
width – (optional) the width of the image in pixel, default value=300
height – (optional) the height of the image in pixel, default value=600
graphtype – (optional) an integer range from 1 to 3, 1=Stacked Bar Chart, 2=Scattered Chart, 3=Line Chart, default value=1
legend – (optional) value=1 or 0, 1 - indicates to show the legend, 0 to hide it, optional, default to 1
- Returns
a 2d plot as a PNG image
-
plot_scalars_html
(log_id_list, **options)¶ Draws multiple plots, returned in HTML format
- Parameters
log_id_list – a list of up to 6 log ids, obtained through calling ‘get_scalar_logs()’
startdepth – (optional) the start depth of a borehole collar, default value=0
enddepth – (optional) the end depth of a borehole collar, default value=99999
samplinginterval – (optional) the interval of the sampling, default value=1
width – (optional) the width of the image in pixel, default value=300
height – (optional) the height of the image in pixel, default value=600
graphtype – (optional) an integer range from 1 to 3, 1=Stacked Bar Chart, 2=Scattered Chart, 3=Line Chart, default value=1
legend – (optional) value=yes or no, if yes - indicate to show the legend, default to yes
- Returns
one or more 2d plots as HTML
-
nvcl_kit.reader.
TIMEOUT
= 6000¶ Timeout for querying WFS and NVCL services (seconds)
-
nvcl_kit.reader.
bgr2rgba
(bgr)¶ Converts BGR colour integer into an RGB tuple
- Parameters
bgr – BGR colour integer
- Returns
RGBA float tuple
nvcl_kit.svc_interface module¶
This forms the interface between the ‘reader’ class and the low-level web APIs.
-
nvcl_kit.svc_interface.
LOG_LVL
= 20¶ Initialise debug level, set to ‘logging.INFO’ or ‘logging.DEBUG’