datasets
Module for loading datasets
Classes
scilightcon.datasets.LogsReader
Reader object for getting time-dependent data from logs folders, created by different software (Argos, CEP, ThermoLoggers, etc.)
Examples:
>>> from scilightcon.datasets import LogsReader # doctest: +SKIP
>>> import datetime # doctest: +SKIP
>>> directory = r'\\konversija\kleja\ThermologgerLogs\v5' # doctest: +SKIP
>>> reader = LogsReader(directory) # doctest: +SKIP
>>> loggers_names_list = reader.list_loggers() # doctest: +SKIP
>>> loggers_names_list # doctest: +SKIP
['Location 2B 314', 'Location 2D 3.14 Logger 1-4', 'Location 2D 3.14 Logger 5-8', ...] # doctest: +SKIP
>>> logger_name = 'Location 2B 314' # doctest: +SKIP
>>> measurables_list = reader.list_measurables(logger_name) # doctest: +SKIP
>>> measurables_list # doctest: +SKIP
['A1-H Stalas 1', 'A1-H', 'A1-T Stalas 1', 'A1-T'] # doctest: +SKIP
>>> measurable = 'A1-H Stalas 1' # doctest: +SKIP
>>> from_date = datetime.datetime(2023,7,20) # doctest: +SKIP
>>> to_date = datetime.datetime(2023,7,21) # doctest: +SKIP
>>> times, values = reader.get_data(logger_name=logger_name, measurable=measurable, from_date=from_date, to_date=to_date) # doctest: +SKIP
Functions
scilightcon.datasets.LogsReader.get_data(logger_name, measurable, from_date=None, to_date=None)
Function checks if given logger_name
and measurable
are valid and collects timestamps and values for a given time period.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger_name |
str
|
Logger name, for example: "Location 2B 314" |
required |
measurable |
str
|
Measurable name, for example: "A1-H Stalas 1" |
required |
from_date |
datetime
|
Date from which the data will be collected |
None
|
to_date |
datetime
|
Date to which the data will be collected |
None
|
Returns:
Name | Type | Description |
---|---|---|
times |
List(datetime)
|
A list with timestamps |
values |
List(float)
|
A list with the values |
scilightcon.datasets.LogsReader.list_loggers()
Collects names of available loggers
Returns:
Type | Description |
---|---|
List[str]
|
A list of Logger names |
scilightcon.datasets.LogsReader.list_measurables(logger_name)
Collects names of measurables of a given logger
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger_name |
str
|
Logger name |
required |
Returns:
Type | Description |
---|---|
List[str]
|
A list of measurables that can be found for the specific logger |
Functions
scilightcon.datasets.load_EKSMA_OPTICS_mirror_reflections(material)
Loads wavelength-dependent reflection dataset of metal coated mirrors by EKSMA OPTICS.
Examples:
>>> from scilightcon.datasets import load_EKSMA_OPTICS_mirror_reflections
>>> data, header = load_EKSMA_OPTICS_mirror_reflections('Ag')
>>> np.shape(data)
(172, 2)
>>> header
['Wavelength (nm)', 'Reflection (%)']
Parameters:
Name | Type | Description | Default |
---|---|---|---|
material |
str
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
data |
Ndarray
|
A 2D array of data with headers excluded. Shape (n_samples, n_columns) |
header |
List
|
Column names or empty strings. Shape (n_columns) |
scilightcon.datasets.load_EO_filter_transmissions(filter)
Loads wavelength-dependent transmission dataset of chosen filter from EO file. Stock number is indicated in the second line of the dataset.
Examples:
>>> from scilightcon.datasets import load_EO_filter_transmissions
>>> data, header = load_EO_filter_transmissions('lp_450nm')
>>> np.shape(data)
(293, 2)
>>> header
['Wavelength (nm)', 'Transmission (%)']
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filter |
str
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
data |
Ndarray
|
A 2D array of data with headers excluded. Shape (n_samples, n_columns) |
header |
List
|
Column names or empty strings. Shape (n_columns) |
scilightcon.datasets.load_THORLABS_filter_transmissions(filter)
Loads wavelength-dependent transmission dataset of chosen material from thorlabs file.
Examples:
>>> from scilightcon.datasets import load_THORLABS_filter_transmissions
>>> data, header = load_THORLABS_filter_transmissions('DMLP425')
>>> np.shape(data)
(2251, 2)
>>> header
['Wavelength (nm)', 'Transmission (%)']
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filter |
str
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
data |
Ndarray
|
A 2D array of data with headers excluded. Shape (n_samples, n_columns) |
header |
List
|
Column names or empty strings. Shape (n_columns) |
scilightcon.datasets.load_atmospheric_data()
Loads atmospheric data.
Examples:
>>> from scilightcon.datasets import load_atmospheric_data
>>> data, header = load_atmospheric_data()
Returns:
Name | Type | Description |
---|---|---|
data |
Ndarray
|
A 2D array of data with headers excluded. Shape (n_samples, n_columns) |
header |
List
|
Column names or empty strings. Shape (n_columns) |
scilightcon.datasets.load_csv_data(data_file_name, *, data_module=DATA_MODULE)
Loads data_file_name
from data_module
with importlib.resources
.
Examples:
>>> from scilightcon.datasets import load_csv_data
>>> data, header = load_csv_data('Hg_lines.csv')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_file_name |
str
|
Name of csv file to be loaded from |
required |
data_module |
str or module
|
Module where data lives. The default is |
DATA_MODULE
|
Returns:
Name | Type | Description |
---|---|---|
data |
ndarray
|
A 2D array with each row representing one sample and each column representing the features of a given sample. Shape: n_samples, n_features |
target |
ndarry
|
A 1D array holding target variables for all the samples in |
target_names |
ndarry
|
A 1D array containing the names of the classifications. For example target_names[0] is the name of the target[0] class. Shape (n_samples,) |
scilightcon.datasets.load_zipped_csv_data(data_file_name, *, data_module=DATA_MODULE)
Extracts gzip file to csv.
Examples:
>>> from scilightcon.datasets import load_zipped_csv_data
>>> data_file_name = r'C:\Code\lightcon-scipack\scilightcon\datasets\data\data_test_detect_peaks.csv.gz'
>>> data, header = _load_zipped_csv_data(data_file_name)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_file_name |
str
|
Path of the file that needs to be extracted |
required |
data_module |
str or module
|
Module where data lives. The default is |
DATA_MODULE
|
Returns:
Name | Type | Description |
---|---|---|
data |
Ndarray
|
A 2D array of data with headers excluded. Shape (n_samples, n_columns) |
header |
List
|
Column names or empty strings. Shape (n_columns) |