LiPD Utilities¶
This modules allow basic manipulation of LiPD files
Creating Directories and saving¶
-
pyleoclim.LipdUtils.
createDir
(path, foldername)¶ Create a new folder in a working directory
Create a new folder in a working directory to save outputs from Pyleoclim.
- Args:
path(str): the path to the new folder. foldername(str): the name of the folder to be created
- Returns:
newdir - the full path to the new directory
-
pyleoclim.LipdUtils.
saveFigure
(name, format='eps', dir=None)¶ Save a figure
Save the figure in the directory. If not given, creates a folder in the current working directory.
- Args:
name (str): name of the file format (str): One of the file extensions supported by the active
backend. Default is “eps”. Most backend support png, pdf, ps, eps, and svg.
- dir (str): the name of the folder in the LiPD working directory.
If not provided, creates a default folder called ‘figures’.
LiPD files¶
-
pyleoclim.LipdUtils.
enumerateLipds
(lipds)¶ Enumerate the LiPD files loaded in the workspace
- Args:
- lipds (dict): A dictionary of LiPD files. Can be obtained from
pyleoclim.readLipd()
-
pyleoclim.LipdUtils.
getLipd
(lipds)¶ Prompt for a LiPD file
Ask the user to select a LiPD file from a list Use this function in conjunction with enumerateLipds()
- Args:
- lipds (dict): A dictionary of LiPD files. Can be obtained from
pyleoclim.readLipd()
- Returns:
The index of the LiPD file
Handling Variables¶
-
pyleoclim.LipdUtils.
promptForVariable
()¶ Prompt for a specific variable
Ask the user to select the variable they are interested in. Use this function in conjunction with readHeaders() or getTSO()
- Returns:
The index of the variable
-
pyleoclim.LipdUtils.
xAxisTs
(timeseries)¶ Prompt the user to choose a x-axis representation for the timeseries.
- Args:
timeseries: a timeseries object
- Returns:
x_axis - the values for the x-axis representation,
label - returns either “age”, “year”, or “depth”
-
pyleoclim.LipdUtils.
checkXaxis
(timeseries, x_axis=None)¶ Check that a x-axis is present for the timeseries
- Args:
timeseries : a timeseries x_axis (str) : the x-axis representation, either depth, age or year
- Returns:
x - the values for the x-axis representation,
label - returns either “age”, “year”, or “depth”
-
pyleoclim.LipdUtils.
checkTimeAxis
(timeseries, x_axis=None)¶ This function makes sure that time is available for the timeseries
- Args:
timeseries (dict): A LiPD timeseries object
- Returns:
x: the time values for the timeseries label: the time representation for the timeseries
-
pyleoclim.LipdUtils.
searchVar
(timeseries_list, key, exact=True, override=True)¶ This function search for key words (exact match) for a variable
- Args:
timeseries_list (list): A list of available series key (list): A list of keys to search exact (bool): if True, looks for an exact match. override (bool): if True, override the exact match if no match is found
- Returns:
- match (list)- A list of keys for the timeseries that match the selection
criteria.
Handling timeseries objects¶
-
pyleoclim.LipdUtils.
enumerateTs
(timeseries_list)¶ Enumerate the available time series objects
- Args:
- timeseries_list: a list of available timeseries objects.
To use the timeseries loaded upon initiation of the pyleoclim package, use pyleo.time_series.
-
pyleoclim.LipdUtils.
getTs
(timeseries_list, option=None)¶ Get a specific timeseries object from a dictionary of timeseries
- Args:
- timeseries_list: a list of available timeseries objects.
To use the timeseries loaded upon initiation of the pyleoclim package, use pyleo.time_series.
option: An expression to filter the datasets. Uses lipd.filterTs()
- Returns:
A single timeseries object if not optional filter selected or a filtered list if optional arguments given
Linking LiPDs to the LinkedEarth Ontology¶
-
pyleoclim.LipdUtils.
LipdToOntology
(archiveType)¶ standardize archiveType
Transform the archiveType from their LiPD name to their ontology counterpart
- Args:
archiveType (STR): name of the archiveType from the LiPD file
- Returns:
archiveType according to the ontology
-
pyleoclim.LipdUtils.
timeUnitsCheck
(units)¶ This function attempts to make sense of the time units by checking for equivalence
- Args:
units (str): The units string for the timeseries
- Returns:
unit_group (str): Whether the units belongs to age_units, kage_units, year_units, or undefined
Dealing with models¶
-
pyleoclim.LipdUtils.
isModel
(csvName, lipd)¶ Check for the presence of a model in the same object than the measurement table
- Args:
csvName (str): The name of the csv file corresponding to the measurement table lipd (dict): A LiPD object
- Returns:
model (list): List of models already available
- dataObject (str): The name of the paleoData or ChronData
object in which the model(s) are stored
-
pyleoclim.LipdUtils.
modelNumber
(model)¶ Assign a new or existing model number
- Args:
model (list): List of possible model number. Obtained from isModel
- Returns:
modelNum (int): The number of the model
Extracting tables¶
-
pyleoclim.LipdUtils.
isMeasurement
(csv_dict)¶ Check whether measurement tables are available
- Args:
csv_dict (dict): Dictionary of available csv
- Returns:
paleoMeasurementTables - List of available paleoMeasurementTables chronMeasurementTables - List of available chronMeasurementTables
-
pyleoclim.LipdUtils.
whichMeasurement
(measurementTableList, csv_dict)¶ Select a measurement table from a list
Use in conjunction with the function isMeasurement
- Args:
- measurementTableList (list): List of measurement tables contained in the
LiPD file. Output from the isMeasurement function
csv_list (list): Dictionary of available csv
- Returns:
csvName (str) - the name of the csv file
-
pyleoclim.LipdUtils.
getMeasurement
(csvName, lipd)¶ Extract the dictionary corresponding to the measurement table
- Args:
csvName (str): The name of the csv file lipd (dict): The LiPD object from which to extract the data
- Returns:
- ts_list - A dictionary containing data and metadata for each column in the
csv file.
Dealing with ensembles¶
-
pyleoclim.LipdUtils.
isEnsemble
(csv_dict)¶ Check whether ensembles are available
- Args:
csv_dict (dict): Dictionary of available csv
- Returns:
paleoEnsembleTables - List of available paleoEnsembleTables
chronEnsembleTables - List of availale chronEnsemble Tables
-
pyleoclim.LipdUtils.
mapAgeEnsembleToPaleoData
(ensembleValues, depthEnsemble, depthPaleo)¶ Map the depth for the ensemble age values to the paleo depth
- Args:
- ensembleValues (array): A matrix of possible age models. Realizations
should be stored in columns
- depthEnsemble (array): A vector of depth. The vector should have the same
length as the number of rows in the ensembleValues
- depthPaleo (array): A vector corresponding to the depth at which there
are paleodata information
- Returns:
ensembleValuesToPaleo - A matrix of age ensemble on the PaleoData scale