pylipd package

Subpackages

Submodules

pylipd.utils.legacy_utils module

Legacy code from the LiPD utils in Python

class pylipd.utils.legacy_utils.LiPD_Legacy[source]

Bases: object

Methods

extract(d[, whichtables, mode, time])

LiPD Version 1.3 Main function to initiate LiPD to TSOs conversion.

extract(d, whichtables='meas', mode='paleo', time='age')[source]

LiPD Version 1.3 Main function to initiate LiPD to TSOs conversion.

Each object has a “paleoNumber” or “chronNumber” “tableNumber” “modelNumber” “time_id” “mode” - chronData or paleoData “tableType” - “meas” “ens” “summ”

Parameters:
  • d (dict) – Metadata for one LiPD file

  • whichtables (str) – all, meas, summ, or ens

  • mode (str) – paleo or chron mode

Return list _ts:

Time series

pylipd.lipd module

The LiPD class describes a LiPD (Linked Paleo Data) object. It contains an RDF Graph which is serialization of the LiPD data into an RDF graph containing terms from the LiPD Ontology <http://linked.earth/Ontology/release/core/1.2.0/index-en.html> How to browse and query LiPD objects is described in a short example below, while this notebook demonstrates how to use PyLiPD to view and query LiPD datasets.

class pylipd.lipd.LiPD(graph=None)[source]

Bases: RDFGraph

The LiPD class describes a LiPD (Linked Paleo Data) object. It contains an RDF Graph which is serialization of the LiPD data into an RDF graph containing terms from the LiPD Ontology <http://linked.earth/Ontology/release/core/1.2.0/index-en.html> How to browse and query LiPD objects is described in a short example below.

Examples

In this example, we read an online LiPD file and convert it into a time series object dictionary.

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load(["https://lipdverse.org/data/LCf20b99dfe8d78840ca60dfb1f832b9ec/1_0_1//Nunalleq.Ledger.2018.lpd"])

ts_list = lipd.get_timeseries(lipd.get_all_dataset_names())

for dsname, tsos in ts_list.items():
    for tso in tsos:
        if 'paleoData_variableName' in tso:
            print(dsname+': '+tso['paleoData_variableName']+': '+tso['archiveType'])
Loading 1 LiPD files
Loaded..
Extracting timeseries from dataset: Nunalleq.Ledger.2018 ...
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: depth: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertaintyHigh: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: age: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: age: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: uncertaintyLow: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological

Methods

clear()

Clears the graph

convert_lipd_dir_to_rdf(lipd_dir, rdf_file)

Convert a directory containing LiPD files into a single RDF file (to be used for uploading to Knowledge Bases like GraphDB)

copy()

Makes a copy of the object

create_lipd(dsname, lipdfile)

Create LiPD file for a dataset

filter_by_archive_type(archiveType)

Filters datasets to return a new LiPD object that only keeps datasets that have the specified archive type

filter_by_compilationName(compilationName)

Filters datasets to return a new LiPD object that only keeps datasets that have the specific compilation

filter_by_datasetName(datasetName)

Filters datasets to return a new LiPD object that only keeps datasets that have the specified names

filter_by_geo_bbox(lonMin, latMin, lonMax, ...)

Filters datasets to return a new LiPD object that only keeps datasets that fall within the bounding box

filter_by_time(timeBound[, timeBoundType, ...])

Filter the records according to a specified time interval and the length of the record within that interval.

get(dsnames)

Gets dataset(s) from the graph and returns the popped LiPD object

get_all_archiveTypes()

Returns a list of all the unique archiveTypes present in the LiPD object

get_all_compilation_names()

Return the names of the compilation present in the LiPD object

get_all_dataset_ids()

Get all Dataset ids

get_all_dataset_names()

Get all Dataset Names

get_all_graph_ids()

Get all Graph ids

get_all_locations([dsname])

Return geographical coordinates for all the datasets.

get_all_variable_names()

Get a list of all possible distinct variableNames.

get_all_variables()

Returns a list of all variables in the graph

get_bibtex([remote, save, path, verbose])

Get BibTeX for loaded datasets

get_dataset_properties()

Get a list of unique properties attached to a dataset.

get_datasets()

Return datasets as instances of the Dataset class

get_ensemble_tables([dsname, ...])

Gets ensemble tables from the LiPD graph

get_lipd(dsname)

Get LiPD json for a dataset

get_model_properties()

Get all the properties associated with a model

get_timeseries(dsnames[, to_dataframe, ...])

Get Legacy LiPD like Time Series Object (tso)

get_timeseries_essentials([dsnames, mode])

Returns specific properties for timeseries: 'dataSetName', 'archiveType', 'geo_meanLat', 'geo_meanLon',

get_variable_properties()

Get a list of variable properties that can be used for querying

load(lipdfiles[, parallel, standardize, ...])

Load LiPD files.

load_datasets(datasets)

Loads instances of Dataset class into the LiPD graph

load_from_dir(dir_path[, parallel, cutoff, ...])

Load LiPD files from a directory

load_remote_datasets(dsnames[, ...])

Loads remote datasets into cache if a remote endpoint is set

merge(rdf)

Merges the current LiPD object with another LiPD object

pop(dsnames)

Pops dataset(s) from the graph and returns the popped LiPD object

query(query[, remote, result])

Once data is loaded into the graph (or remote endpoint set), one can make SparQL queries to the graph

remove(dsnames)

Removes dataset(s) from the graph

serialize()

Returns RDF quad serialization of the current combined Graph .

set_endpoint(endpoint)

Sets a SparQL endpoint for a remote Knowledge Base (example: GraphDB)

to_lipd_series([parallel])

Converts the LiPD object to a LiPDSeries object

update_remote_datasets(dsnames)

Updates local LiPD Graph for datasets to remote endpoint

convert_lipd_dir_to_rdf(lipd_dir, rdf_file, parallel=False, standardize=True, add_labels=False)[source]

Convert a directory containing LiPD files into a single RDF file (to be used for uploading to Knowledge Bases like GraphDB)

Parameters:
  • lipd_dir (str) – Path to the directory containing lipd files

  • rdf_file (str) – Path to the output rdf file

create_lipd(dsname, lipdfile)[source]

Create LiPD file for a dataset

Parameters:
  • dsname (str) – dataset id

  • lipdfile (str) – path to LiPD file

Returns:

lipdjson – LiPD json

Return type:

dict

Examples

from pylipd.lipd import LiPD

# Load a local file
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
])
dsname = lipd.get_all_dataset_names()[0]
lipd.create_lipd(dsname, "test.lpd")
Loading 1 LiPD files
Loaded..
{'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2],
   'type': 'Point'},
  'properties': {'longitude': 145.8167,
   'type': 'http://linked.earth/ontology#Location',
   'latitude': -5.2167,
   'elevation': -2.2,
   'pages2kRegion': 'Ocean',
   'siteName': 'Madang Lagoon, Papua New Guinea',
   'ocean': 'Pacific'}},
 'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993',
 'createdBy': 'matlab',
 'changelog': {'timestamp': '2022-08-23 23:41:56 UTC',
  'notes': 'Starting the changelog',
  'curator': 'nicholas',
  'version': '1.0.0'},
 'inCompilation1_': 'Ocean2k_v1.0.0',
 'lipdVersion': 1.3,
 'paleoData': [{'measurementTable': [{'tableName': 'Kuhnert',
     'missingValue': 'NaN',
     'columns': [{'variableName': 'd18O',
       'variableType': 'measured',
       'qCCertification': 'KLD, NJA',
       'useInGlobalTemperatureAnalysis': True,
       'inCompilationBeta': {'compilationName': 'Pages2kTemperature',
        'compilationVersion': '2_1_1'},
       'TSid': 'Ocean2kHR_140',
       'ocean2kID': 'PacificMadangTudhope2001',
       'interpretation': [{'scope': 'climate',
         'variableDetail': 'sea@surface',
         'direction': 'negative',
         'seasonality': 'subannual',
         'variable': 'temperature'}],
       'number': 1,
       'measurementTableMD5': '793853407e414221c486d2e63b32dd87',
       'hasMeanValue': -4.9453,
       'hasMinValue': -5.515,
       'measurementTableName': 'measurementTable1',
       'notes': '; climateInterpretation_seasonality changed - was originally seasonal',
       'sensorGenus': 'Porites',
       'paleoDataTableName': 'measTable',
       'hasMaxValue': -4.344,
       'proxyObservationType': 'd18O',
       'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt',
       'hasMedianValue': -4.942,
       'resolution': {'hasMaxValue': 0.25,
        'hasMeanValue': 0.25,
        'hasMedianValue': 0.25,
        'hasMinValue': 0.25,
        'units': 'yr AD'},
       'pages2kID': 'Ocn_097',
       'iso2kUI': 'CO01TUNG01A',
       'units': 'permil',
       'proxy': 'd18O',
       'archiveType': 'Coral'},
      {'resolution': {'hasMeanValue': 0.25,
        'hasMinValue': 0.25,
        'hasMaxValue': 0.25,
        'hasMedianValue': 0.25,
        'units': 'yr AD'},
       'measurementTableMD5': '793853407e414221c486d2e63b32dd87',
       'measurementTableName': 'measurementTable1',
       'hasMaxValue': 1993.042,
       'hasMedianValue': 1936.917,
       'hasMeanValue': 1936.917,
       'inferredVariableType': 'Year',
       'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt',
       'hasMinValue': 1880.792,
       'number': 2,
       'paleoDataTableName': 'measTable',
       'description': 'Year AD',
       'TSid': 'PYTDAS7AM1Y',
       'variableName': 'year',
       'variableType': 'inferred',
       'dataType': 'float',
       'units': 'yr AD',
       'archiveType': 'Coral'}],
     'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv',
     'googleWorkSheetKey': 'ov9tjw6'}]}],
 'inCompilation2_': 'PAGES2k_v2.0.0',
 'datasetId': 'm8yv2VgG97zJmSg3XhqQ',
 'maxYear': 1993.042,
 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc',
 'pub': [{'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle',
   'journal': 'Science',
   'dataUrl': ['doi.org'],
   'doi': '10.1126/science.1057969',
   'publisher': 'American Association for the Advancement of Science (AAAS)',
   'pages': '1511-1517',
   'issue': 5508.0,
   'citeKey': 'tudhope2001variabilityintheelninosou',
   'author': [{'name': 'A. W. Tudhope'}],
   'year': 2001,
   'volume': '291'},
  {'dataUrl': ['doi.org'],
   'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives',
   'author': [{'name': 'Michael N. Evans'},
    {'name': 'Henry C. Wu'},
    {'name': 'Jessica E. Tierney'},
    {'name': 'Kevin J. Anchukaitis'},
    {'name': 'K. Halimeda Kilbourne'},
    {'name': 'Cyril Giry'},
    {'name': 'Nerilie J. Abram'},
    {'name': 'Casey P. Saenger'},
    {'name': 'Jens Zinke'}],
   'pages': '226-252',
   'volume': '30',
   'doi': '10.1002/2014PA002717',
   'citeKey': 'tierney2015tropicalseasurfacetempera',
   'issue': 3.0,
   'publisher': 'Wiley-Blackwell',
   'journal': 'Paleoceanography',
   'year': 2015},
  {'urldate': 2001.0,
   'author': [{'name': 'H. Kuhnert'}],
   'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation',
   'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'],
   'institution': 'World Data Center for Paleoclimatology',
   'title': 'World Data Center for Paleoclimatology'}],
 'minYear': 1880.792,
 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866',
 'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001',
 'dataContributor': {'name': 'Wu KLD'},
 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc',
 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd',
 'inCompilation3_': 'PAGES2k_v2.1.0',
 'googleMetadataWorksheet': 'oruuxfm',
 'archiveType': 'Coral'}
filter_by_archive_type(archiveType)[source]

Filters datasets to return a new LiPD object that only keeps datasets that have the specified archive type

Parameters:

archiveType (str) – The archive type to filter by

Returns:

A new LiPD object that only contains datasets that have the specified archive type (regex)

Return type:

pylipd.lipd.LiPD

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
Lfiltered = lipd.filter_by_archive_type('marine')
Lfiltered.get_all_archiveTypes()
Loading 16 LiPD files
Loaded..
['Marine sediment']

If searching for multiple archiveTypes, you can construct the name as follows:

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
Lfiltered = lipd.filter_by_archive_type('marine|coral')
Lfiltered.get_all_archiveTypes()
Loading 16 LiPD files
Loaded..
['Coral', 'Marine sediment']
filter_by_compilationName(compilationName)[source]

Filters datasets to return a new LiPD object that only keeps datasets that have the specific compilation

Parameters:

compilationName (str) – The name of the compilation to filter by

Returns:

A new LiPD object that only contains datasets that have the specified archive type (regex)

Return type:

pylipd.lipd.LiPD

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import available_dataset_names, load_datasets

dsList = available_dataset_names()
D = load_datasets(dsList)
Dfiltered = D.filter_by_compilationName('Temp12k')
Dfiltered.get_all_dataset_names()
['/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-Stockholm.Leijonhufvud.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-NorthernScandinavia.Esper.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-FinnishLakelands.Helama.2014.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Asi-SourthAndMiddleUrals.Demezhko.2007.lpd', "/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Arc-Kongressvatnet.D'Andrea.2012.lpd", '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-NorthernSpain.Martin-Chivelet.2011.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-SpanishPyrenees.Dorado-Linan.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-SinaiPeninsula,RedSea.Moustafa.2000.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-RedSea.Felis.2000.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-FeniDrift.Richter.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-LakeSilvaplana.Trachsel.2010.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ant-WAIS-Divide.Severinghaus.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-CoastofPortugal.Abrantes.2011.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-PedradeLume-CapeVerdeIslands.Moses.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-SpannagelCave.Mangini.2005.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-AlboranSea436B.Nieto-Moreno.2013.lpd']
Loading 17 LiPD files
Loaded..
[]
filter_by_datasetName(datasetName)[source]

Filters datasets to return a new LiPD object that only keeps datasets that have the specified names

Parameters:

datasetName (str) – The datasetNames to filter by

Returns:

A new LiPD object that only contains datasets that have the specified archive type (regex)

Return type:

pylipd.lipd.LiPD

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
Lfiltered = lipd.filter_by_datasetName('Ocn-RedSea.Felis.2000')
Lfiltered.get_all_dataset_names()
Loading 16 LiPD files
Loaded..
['Ocn-RedSea.Felis.2000']

If searching for multiple dataset names, you can construct the name as follows:

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
dsnames = ['Ocn-RedSea.Felis.2000','Ant-WAIS-Divide.Severinghaus.2012']
dsquery = '|'.join(dsnames)
Lfiltered = lipd.filter_by_datasetName(dsquery)
Lfiltered.get_all_dataset_names()
Loading 16 LiPD files
Loaded..
['Ocn-RedSea.Felis.2000', 'Ant-WAIS-Divide.Severinghaus.2012']
filter_by_geo_bbox(lonMin, latMin, lonMax, latMax)[source]

Filters datasets to return a new LiPD object that only keeps datasets that fall within the bounding box

Parameters:
  • lonMin (float) – Minimum longitude

  • latMin (float) – Minimum latitude

  • lonMax (float) – Maximum longitude

  • latMax (float) – Maximum latitude

Returns:

A new LiPD object that only contains datasets that fall within the bounding box

Return type:

pylipd.lipd.LiPD

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir()
Lfiltered = lipd.filter_by_geo_bbox(0,25,50,50)
Lfiltered.get_all_dataset_names()
Loading 16 LiPD files
Loaded..
['Ocn-SinaiPeninsula_RedSea.Moustafa.2000',
 'Eur-LakeSilvaplana.Trachsel.2010',
 'Eur-SpannagelCave.Mangini.2005',
 'Ocn-RedSea.Felis.2000',
 'Eur-SpanishPyrenees.Dorado-Linan.2012']
filter_by_time(timeBound, timeBoundType='any', recordLength=None)[source]

Filter the records according to a specified time interval and the length of the record within that interval. Note that this function assumes that all records use the same time representation.

If you are unsure about the time representation, you may need to use .get_timeseries_essentials.

Parameters:
  • timeBound (list) – Minimum and Maximum age value to search for.

  • timeBoundType (str, optional) – The type of querying to perform. Possible values include: “any”, “entire”, and “entirely”. - any: Overlap any portions of matching datasets (default) - entirely: are entirely overlapped by matching datasets - entire: overlap entire matching datasets but dataset can be shorter than the bounds The default is ‘any’.

  • recordLength (float, optional) – The minimum length the record needs to have while matching the ageBound criteria. The default is None.

Raises:

ValueError – timeBoundType must take the values in [“any”, “entire”, and “entirely”]

Returns:

A new LiPD object that only contains datasets that have the specified time interval

Return type:

pylipd.lipd.LiPD

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
Lfiltered = lipd.filter_by_time(timeBound=[0,1800])
Lfiltered.get_all_dataset_names()
Loading 16 LiPD files
Loaded..
['Asi-SourthAndMiddleUrals.Demezhko.2007',
 'Eur-LakeSilvaplana.Trachsel.2010',
 'Eur-NorthernSpain.Martin-Chivelet.2011',
 'Eur-CoastofPortugal.Abrantes.2011',
 'Eur-NorthernScandinavia.Esper.2012',
 'Eur-SpannagelCave.Mangini.2005',
 'Ocn-RedSea.Felis.2000',
 'Ocn-FeniDrift.Richter.2009',
 'Eur-Stockholm.Leijonhufvud.2009',
 'Eur-SpanishPyrenees.Dorado-Linan.2012',
 'Eur-FinnishLakelands.Helama.2014',
 'Ant-WAIS-Divide.Severinghaus.2012',
 'Ocn-AlboranSea436B.Nieto-Moreno.2013']
get(dsnames)[source]

Gets dataset(s) from the graph and returns the popped LiPD object

Parameters:

dsnames (str or list of str) – dataset name(s) to get.

Returns:

LiPD object with the retrieved dataset(s)

Return type:

pylipd.lipd.LiPD

Examples

from pylipd.lipd import LiPD

# Load LiPD files from a local directory
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])

all_datasets = lipd.get_all_dataset_names()
print("Loaded datasets: " + str(all_datasets))
ds = lipd.get(all_datasets[0])
print("Got dataset: " + str(ds.get_all_dataset_names()))
Loading 2 LiPD files
Loaded..
Loaded datasets: ['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007']
Got dataset: ['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001']
get_all_archiveTypes()[source]

Returns a list of all the unique archiveTypes present in the LiPD object

Returns:

A list of archiveTypes

Return type:

list

Examples

from pylipd.lipd import LiPD

# Load Local files
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
print(lipd.get_all_archiveTypes())
Loading 2 LiPD files
Loaded..
['Coral', 'Marine sediment']
get_all_compilation_names()[source]

Return the names of the compilation present in the LiPD object

Returns:

l – A list returning the names of the available compilations.

Return type:

list

Examples

from pylipd.utils.dataset import load_dir

lipd = load_dir('Temp12k')
df = lipd.get_all_compilation_names()
print(df)
Directory /home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/Temp12k does not exist
[]
get_all_dataset_ids()[source]

Get all Dataset ids

Returns:

  • dsids (list)

  • A list of datasetnames

Examples

from pylipd.lipd import LiPD

# Load local files
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
print(lipd.get_all_dataset_ids())
Loading 2 LiPD files
Loaded..
['m8yv2VgG97zJmSg3XhqQ', 't0E8pOLYdyzmUspGZwbe']
get_all_dataset_names()[source]

Get all Dataset Names

Returns:

  • dsnames (list)

  • A list of datasetnames

Examples

from pylipd.lipd import LiPD

# Load local files
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
print(lipd.get_all_dataset_names())
Loading 2 LiPD files
Loaded..
['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007']
get_all_locations(dsname=None)[source]

Return geographical coordinates for all the datasets.

Parameters:

dsname (str, optional) – The name of the dataset for which to return the timeseries information. The default is None.

Returns:

df – A pandas dataframe returning the latitude, longitude and elevation for each dataset

Return type:

pandas.DataFrame

Examples

from pylipd.utils.dataset import load_dir
lipd = load_dir('Pages2k')
df = lipd.get_all_locations()
print(df)
Loading 16 LiPD files
Loaded..
                              dataSetName  geo_meanLat  geo_meanLon  \
0         Eur-Stockholm.Leijonhufvud.2009      59.3200      18.0600   
1         Eur-Stockholm.Leijonhufvud.2009      59.3200      18.0600   
2         Eur-Stockholm.Leijonhufvud.2009      59.3200      18.0600   
3         Eur-Stockholm.Leijonhufvud.2009      59.3200      18.0600   
4         Eur-Stockholm.Leijonhufvud.2009      59.3200      18.0600   
..                                    ...          ...          ...   
123  Ocn-AlboranSea436B.Nieto-Moreno.2013      36.2053      -4.3133   
124  Ocn-AlboranSea436B.Nieto-Moreno.2013      36.2053      -4.3133   
125  Ocn-AlboranSea436B.Nieto-Moreno.2013      36.2053      -4.3133   
126  Ocn-AlboranSea436B.Nieto-Moreno.2013      36.2053      -4.3133   
127  Ocn-AlboranSea436B.Nieto-Moreno.2013      36.2053      -4.3133   

     geo_meanElev  
0            10.0  
1            10.0  
2            10.0  
3            10.0  
4            10.0  
..            ...  
123       -1108.0  
124       -1108.0  
125       -1108.0  
126       -1108.0  
127       -1108.0  

[128 rows x 4 columns]
get_all_variable_names()[source]

Get a list of all possible distinct variableNames. Useful for filtering and qeurying.

Returns:

A list of unique variableName

Return type:

list

Examples

from pylipd.utils.dataset import load_dir
lipd = load_dir('Pages2k')
varName = lipd.get_all_variable_names()
print(varName)
Loading 16 LiPD files
Loaded..
['year', 'temperature', 'MXD', 'Uk37', 'd18O', 'trsgi', 'Mg_Ca', 'notes', 'depth_bottom', 'depth_top', 'uncertainty_temperature']
get_all_variables()[source]

Returns a list of all variables in the graph

Returns:

A dataframe of all variables in the graph with columns uri, varid, varname

Return type:

pandas.DataFrame

Examples

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load([
    "../examples/data/ODP846.Lawrence.2006.lpd"
])

df = lipd.get_all_variables()
print(df)
Loading 1 LiPD files
Loaded..
                                                  uri         TSID  \
0   http://linked.earth/lipd/paleo0measurement1.PY...  PYTJZ4GLRYP   
1   http://linked.earth/lipd/chron0model0summary0....  PYTDIEKUM44   
2   http://linked.earth/lipd/paleo0measurement1.PY...  PYTS96EE0CB   
3   http://linked.earth/lipd/chron0model0ensemble0...  PYTGOFY4KZD   
4   http://linked.earth/lipd/chron0model0summary0....  PYTPWX0LH3I   
5   http://linked.earth/lipd/paleo0model0ensemble0...  PYTCHXB40SL   
6   http://linked.earth/lipd/chron0measurement0.PY...  PYT9CFQ4GK0   
7   http://linked.earth/lipd/paleo0measurement0.PY...  PYTKRFVW61B   
8   http://linked.earth/lipd/paleo0measurement0.PY...  PYTXJB98403   
9   http://linked.earth/lipd/chron0model0ensemble0...  PYTUHE3XLGQ   
10  http://linked.earth/lipd/chron0measurement0.PY...  PYTTD7XCQGS   
11  http://linked.earth/lipd/paleo0measurement1.PY...  PYT68HYMYHH   
12  http://linked.earth/lipd/paleo0measurement0.PY...  PYT2ZB6MLZ9   
13  http://linked.earth/lipd/chron0model0summary0....  PYTI487BQDZ   
14  http://linked.earth/lipd/paleo0measurement0.PY...  PYTM9N6HCQM   
15  http://linked.earth/lipd/chron0measurement0.PY...  PYTLEHYPAYV   
16  http://linked.earth/lipd/paleo0measurement1.PY...  PYT3ZMI0BXW   
17  http://linked.earth/lipd/chron0model0summary0....  PYT7DLYN7X4   
18  http://linked.earth/lipd/paleo0model0ensemble0...  PYTDW6AIJPW   
19  http://linked.earth/lipd/paleo0measurement0.PY...  PYTJ3PSH0LT   
20  http://linked.earth/lipd/paleo0measurement1.PY...  PYT19MC8WE2   
21  http://linked.earth/lipd/paleo0measurement1.PY...  PYTE5EC1JBW   
22  http://linked.earth/lipd/paleo0measurement0.PY...  PYTGO6NV72Y   
23  http://linked.earth/lipd/paleo0measurement0.PY...  PYT10H23U2E   
24  http://linked.earth/lipd/paleo0measurement0.PY...  PYT95DVDUU3   
25  http://linked.earth/lipd/chron0model0summary0....  PYT4Y96QMUU   
26  http://linked.earth/lipd/paleo0measurement0.PY...  PYT8BDSRW3H   
27  http://linked.earth/lipd/paleo0measurement1.PY...  PYTPQ0FJO1S   
28  http://linked.earth/lipd/paleo0measurement1.PY...  PYTTUPVG4K3   
29  http://linked.earth/lipd/paleo0measurement1.PY...  PYTYDOYFVYD   

             variableName  
0            sample label  
1                 upper95  
2                   depth  
3                   depth  
4                   depth  
5                   depth  
6                   depth  
7                   depth  
8                     age  
9                     age  
10                    age  
11               depth cr  
12               interval  
13                lower95  
14              ukprime37  
15                   d18o  
16  c. wuellerstorfi d18o  
17                 median  
18                    sst  
19              site/hole  
20  c. wuellerstorfi d13c  
21                  event  
22            temp muller  
23              c37 total  
24             temp prahl  
25                   d180  
26                section  
27             depth comp  
28      u. peregrina d13c  
29      u. peregrina d18o  
get_bibtex(remote=True, save=True, path='mybiblio.bib', verbose=False)[source]

Get BibTeX for loaded datasets

Parameters:
  • remote (bool) – (Optional) If set to True, will return the bibliography by checking against the DOI

  • save (bool) – (Optional) Whether to save the bibliography to a file

  • path (str) – (Optional) Path where to save the file

  • verbose (bool) – (Optional) Whether to print out on the console. Note that this option will turn on automatically if saving to a file fails.

Returns:

  • bibs (list) – List of BiBTex entry

  • df (pandas.DataFrame) – Bibliography information in a Pandas DataFrame

Examples

from pylipd.lipd import LiPD

# Fetch LiPD data from remote RDF Graph
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
print(lipd.get_bibtex(save=False))
Loading 2 LiPD files
Loaded..
Cannot find a matching record for the provided DOI (None), creating the entry manually
(['@misc{kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation,\n    author = "H. Kuhnert",\n    title = "World Data Center for Paleoclimatology",\n    institution = "World Data Center for Paleoclimatology",\n    url = "https://www.ncdc.noaa.gov/paleo/study/1866"\n}\n', ' @article{Tierney_2015, title={Tropical sea surface temperatures for the past four centuries reconstructed from coral archives}, volume={30}, ISSN={1944-9186}, url={http://dx.doi.org/10.1002/2014PA002717}, DOI={10.1002/2014pa002717}, number={3}, journal={Paleoceanography}, publisher={American Geophysical Union (AGU)}, author={Tierney, Jessica E. and Abram, Nerilie J. and Anchukaitis, Kevin J. and Evans, Michael N. and Giry, Cyril and Kilbourne, K. Halimeda and Saenger, Casey P. and Wu, Henry C. and Zinke, Jens}, year={2015}, month=mar, pages={226–252} }\n', ' @article{Tudhope_2001, title={Variability in the El Niño-Southern Oscillation Through a Glacial-Interglacial Cycle}, volume={291}, ISSN={1095-9203}, url={http://dx.doi.org/10.1126/science.1057969}, DOI={10.1126/science.1057969}, number={5508}, journal={Science}, publisher={American Association for the Advancement of Science (AAAS)}, author={Tudhope, Alexander W. and Chilcott, Colin P. and McCulloch, Malcolm T. and Cook, Edward R. and Chappell, John and Ellam, Robert M. and Lea, David W. and Lough, Janice M. and Shimmield, Graham B.}, year={2001}, month=feb, pages={1511–1517} }\n', ' @article{Stott_2007, title={Comment on “Anomalous radiocarbon ages for foraminifera shells” by W. Broecker et al.: A correction to the western tropical Pacific MD9821‐81 record}, volume={22}, ISSN={1944-9186}, url={http://dx.doi.org/10.1029/2006PA001379}, DOI={10.1029/2006pa001379}, number={1}, journal={Paleoceanography}, publisher={American Geophysical Union (AGU)}, author={Stott, Lowell D.}, year={2007}, month=feb }\n', ' @article{Stott_2007, title={Southern Hemisphere and Deep-Sea Warming Led Deglacial Atmospheric CO\n            2\n            Rise and Tropical Warming}, volume={318}, ISSN={1095-9203}, url={http://dx.doi.org/10.1126/science.1143791}, DOI={10.1126/science.1143791}, number={5849}, journal={Science}, publisher={American Association for the Advancement of Science (AAAS)}, author={Stott, Lowell and Timmermann, Axel and Thunell, Robert}, year={2007}, month=oct, pages={435–438} }\n'],                                         dsname  \
0  Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001   
1  Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001   
2  Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001   
3                         MD98_2181.Stott.2007   
4                         MD98_2181.Stott.2007   

                                               title  \
0             World Data Center for Paleoclimatology   
1  Tropical sea surface temperatures for the past...   
2  Variability in the El Nino-Southern Oscillatio...   
3                                               None   
4  Southern Hemisphere and deep-sea warming led d...   

                                             authors                      doi  \
0                                         H. Kuhnert                     None   
1  Kevin J. Anchukaitis and K. Halimeda Kilbourne...     10.1002/2014PA002717   
2                                      A. W. Tudhope  10.1126/science.1057969   
3                                                        10.1029/2006PA001379   
4          L. Stott and A. Timmermann and R. Thunell  10.1126/science.1143791   

  pubyear    year           journal volume   issue      pages  \
0    None     NaN              None   None     NaN       None   
1    None  2015.0  Paleoceanography     30     3.0    226-252   
2    None  2001.0           Science    291  5508.0  1511-1517   
3    None     NaN              None   None     NaN       None   
4    None  2007.0           Science    318  5849.0  435   438   

              type                                          publisher report  \
0     dataCitation                                               None   None   
1  journal-article                                    Wiley-Blackwell   None   
2  journal-article  American Association for the Advancement of Sc...   None   
3             None                                               None   None   
4             None                                               None   None   

                                             citeKey edition  \
0  kuhnert2001httpswwwncdcnoaagovpaleostudy1866Da...    None   
1               tierney2015tropicalseasurfacetempera    None   
2               tudhope2001variabilityintheelninosou    None   
3                                               None    None   
4                                           WMGAVB7S    None   

                              institution   url  \
0  World Data Center for Paleoclimatology  None   
1                                    None  None   
2                                    None  None   
3                                    None  None   
4                                    None  None   

                                         url2  
0  https://www.ncdc.noaa.gov/paleo/study/1866  
1                                        None  
2                                        None  
3                                        None  
4                                        None  )
get_dataset_properties()[source]

Get a list of unique properties attached to a dataset.

Note: Some properties will return another object (e.g., ‘publishedIn’ will give you a Publication object with its own properties) Note: Not all datasets will have the same available properties (i.e., not filled in by a user)

Returns:

clean_list – A list of avialable properties that can queried

Return type:

list

Examples

from pylipd.utils.dataset import load_dir
lipd = load_dir(name='Pages2k')
dataset_properties = lipd.get_dataset_properties()
print(dataset_properties)
Loading 16 LiPD files
Loaded..
['createdBy', 'hasDatasetId', 'hasUrl', 'hasPaleoData', 'hasName', 'hasSpreadsheetLink', 'lipdVersion', 'hasArchiveType', 'hasOriginalDataUrl', 'hasLocation', 'hasChangeLog', 'googleMetadataWorksheet', 'hasPublication', 'type', 'minYear', 'maxYear', 'googleDataURL', 'inCompilation1_', 'inCompilation3_', 'inCompilation2_', 'hasContributor', 'studyName', 'hasFunding', 'hasNotes', 'hasInvestigator']
get_datasets() list[Dataset][source]

Return datasets as instances of the Dataset class

Returns:

A list of Dataset objects

Return type:

list of pylipd.classes.Dataset

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
lipd.get_datasets()
Loading 16 LiPD files
Loaded..
[<pylipd.classes.dataset.Dataset at 0x722ddd299fd0>,
 <pylipd.classes.dataset.Dataset at 0x722dd3107f50>,
 <pylipd.classes.dataset.Dataset at 0x722dd31c5c50>,
 <pylipd.classes.dataset.Dataset at 0x722dd3141c90>,
 <pylipd.classes.dataset.Dataset at 0x722dd305a750>,
 <pylipd.classes.dataset.Dataset at 0x722dd2544090>,
 <pylipd.classes.dataset.Dataset at 0x722dd254dbd0>,
 <pylipd.classes.dataset.Dataset at 0x722dd2db8410>,
 <pylipd.classes.dataset.Dataset at 0x722dd0726810>,
 <pylipd.classes.dataset.Dataset at 0x722dd2d52e90>,
 <pylipd.classes.dataset.Dataset at 0x722dd2d25290>,
 <pylipd.classes.dataset.Dataset at 0x722dd2d14b90>,
 <pylipd.classes.dataset.Dataset at 0x722dd078e6d0>,
 <pylipd.classes.dataset.Dataset at 0x722dd074af50>,
 <pylipd.classes.dataset.Dataset at 0x722dd2dba3d0>,
 <pylipd.classes.dataset.Dataset at 0x722dd078cf90>]
get_ensemble_tables(dsname=None, ensembleVarName=None, ensembleDepthVarName='depth')[source]

Gets ensemble tables from the LiPD graph

Parameters:
  • dsname (str) – The name of the dataset if you wish to analyse one at a time (Set to “.*” to match all datasets with a common root)

  • ensembleVarName (None or str) – ensemble variable name. Default is None, which searches for names that contain “year” or “age” (Set to “.*” to match all ensemble variable names)

  • ensembleDepthVarName (str) – ensemble depth variable name. Default is ‘depth’ (Set to “.*” to match all ensemble depth variable names)

Returns:

ensemble_tables – A dataframe containing the ensemble tables

Return type:

dataframe

Examples

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load([
    "../examples/data/ODP846.Lawrence.2006.lpd"
])
all_datasets = lipd.get_all_dataset_names()
print("Loaded datasets: " + str(all_datasets))

ens_df = lipd.get_ensemble_tables(
    ensembleVarName="age",
    ensembleDepthVarName="depth"
)
print(ens_df)
Loading 1 LiPD files
Loaded..
Loaded datasets: ['ODP846.Lawrence.2006']
            datasetName                                   ensembleTable  \
0  ODP846.Lawrence.2006  http://linked.earth/lipd/chron0model0ensemble0   

  ensembleVariableName                             ensembleVariableValues  \
0                  age  [[4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,...   

  ensembleVariableUnits ensembleDepthName  \
0                kyr BP             depth   

                                 ensembleDepthValues ensembleDepthUnits notes  \
0  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...                  m  None   

  methodobj methods  
0      None    None  
get_lipd(dsname)[source]

Get LiPD json for a dataset

Parameters:

dsname (str) – dataset id

Returns:

lipdjson – LiPD json

Return type:

dict

Examples

from pylipd.lipd import LiPD

# Load a local LiPD file
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
])
lipd_json = lipd.get_lipd(lipd.get_all_dataset_names()[0])
print(lipd_json)
Loading 1 LiPD files
Loaded..
{'pub': [{'doi': '10.1002/2014PA002717', 'citeKey': 'tierney2015tropicalseasurfacetempera', 'pages': '226-252', 'volume': '30', 'author': [{'name': 'Jens Zinke'}, {'name': 'K. Halimeda Kilbourne'}, {'name': 'Michael N. Evans'}, {'name': 'Henry C. Wu'}, {'name': 'Jessica E. Tierney'}, {'name': 'Kevin J. Anchukaitis'}, {'name': 'Cyril Giry'}, {'name': 'Nerilie J. Abram'}, {'name': 'Casey P. Saenger'}], 'issue': 3.0, 'publisher': 'Wiley-Blackwell', 'dataUrl': ['doi.org'], 'journal': 'Paleoceanography', 'year': 2015, 'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives'}, {'year': 2001, 'issue': 5508.0, 'publisher': 'American Association for the Advancement of Science (AAAS)', 'citeKey': 'tudhope2001variabilityintheelninosou', 'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle', 'author': [{'name': 'A. W. Tudhope'}], 'dataUrl': ['doi.org'], 'doi': '10.1126/science.1057969', 'pages': '1511-1517', 'journal': 'Science', 'volume': '291'}, {'institution': 'World Data Center for Paleoclimatology', 'title': 'World Data Center for Paleoclimatology', 'author': [{'name': 'H. Kuhnert'}], 'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation', 'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'], 'urldate': 2001.0}], 'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2], 'type': 'Point'}, 'properties': {'longitude': 145.8167, 'type': 'http://linked.earth/ontology#Location', 'latitude': -5.2167, 'elevation': -2.2, 'pages2kRegion': 'Ocean', 'siteName': 'Madang Lagoon, Papua New Guinea', 'ocean': 'Pacific'}}, 'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993', 'createdBy': 'matlab', 'changelog': {'timestamp': '2022-08-23 23:41:56 UTC', 'notes': 'Starting the changelog', 'curator': 'nicholas', 'version': '1.0.0'}, 'inCompilation1_': 'Ocean2k_v1.0.0', 'lipdVersion': 1.3, 'paleoData': [{'measurementTable': [{'tableName': 'Kuhnert', 'missingValue': 'NaN', 'columns': [{'resolution': {'hasMeanValue': 0.25, 'hasMinValue': 0.25, 'hasMaxValue': 0.25, 'hasMedianValue': 0.25, 'units': 'yr AD'}, 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'measurementTableName': 'measurementTable1', 'hasMaxValue': 1993.042, 'hasMedianValue': 1936.917, 'hasMeanValue': 1936.917, 'inferredVariableType': 'Year', 'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt', 'hasMinValue': 1880.792, 'number': 2, 'paleoDataTableName': 'measTable', 'description': 'Year AD', 'TSid': 'PYTDAS7AM1Y', 'variableName': 'year', 'variableType': 'inferred', 'dataType': 'float', 'units': 'yr AD', 'archiveType': 'Coral', 'values': [1993.042, 1992.792, 1992.542, 1992.292, 1992.042, 1991.792, 1991.542, 1991.292, 1991.042, 1990.792, 1990.542, 1990.292, 1990.042, 1989.792, 1989.542, 1989.292, 1989.042, 1988.792, 1988.542, 1988.292, 1988.042, 1987.792, 1987.542, 1987.292, 1987.042, 1986.792, 1986.542, 1986.292, 1986.042, 1985.792, 1985.542, 1985.292, 1985.042, 1984.792, 1984.542, 1984.292, 1984.042, 1983.792, 1983.542, 1983.292, 1983.042, 1982.792, 1982.542, 1982.292, 1982.042, 1981.792, 1981.542, 1981.292, 1981.042, 1980.792, 1980.542, 1980.292, 1980.042, 1979.792, 1979.542, 1979.292, 1979.042, 1978.792, 1978.542, 1978.292, 1978.042, 1977.792, 1977.542, 1977.292, 1977.042, 1976.792, 1976.542, 1976.292, 1976.042, 1975.792, 1975.542, 1975.292, 1975.042, 1974.792, 1974.542, 1974.292, 1974.042, 1973.792, 1973.542, 1973.292, 1973.042, 1972.792, 1972.542, 1972.292, 1972.042, 1971.792, 1971.542, 1971.292, 1971.042, 1970.792, 1970.542, 1970.292, 1970.042, 1969.792, 1969.542, 1969.292, 1969.042, 1968.792, 1968.542, 1968.292, 1968.042, 1967.792, 1967.542, 1967.292, 1967.042, 1966.792, 1966.542, 1966.292, 1966.042, 1965.792, 1965.542, 1965.292, 1965.042, 1964.792, 1964.542, 1964.292, 1964.042, 1963.792, 1963.542, 1963.292, 1963.042, 1962.792, 1962.542, 1962.292, 1962.042, 1961.792, 1961.542, 1961.292, 1961.042, 1960.792, 1960.542, 1960.292, 1960.042, 1959.792, 1959.542, 1959.292, 1959.042, 1958.792, 1958.542, 1958.292, 1958.042, 1957.792, 1957.542, 1957.292, 1957.042, 1956.792, 1956.542, 1956.292, 1956.042, 1955.792, 1955.542, 1955.292, 1955.042, 1954.792, 1954.542, 1954.292, 1954.042, 1953.792, 1953.542, 1953.292, 1953.042, 1952.792, 1952.542, 1952.292, 1952.042, 1951.792, 1951.542, 1951.292, 1951.042, 1950.792, 1950.542, 1950.292, 1950.042, 1949.792, 1949.542, 1949.292, 1949.042, 1948.792, 1948.542, 1948.292, 1948.042, 1947.792, 1947.542, 1947.292, 1947.042, 1946.792, 1946.542, 1946.292, 1946.042, 1945.792, 1945.542, 1945.292, 1945.042, 1944.792, 1944.542, 1944.292, 1944.042, 1943.792, 1943.542, 1943.292, 1943.042, 1942.792, 1942.542, 1942.292, 1942.042, 1941.792, 1941.542, 1941.292, 1941.042, 1940.792, 1940.542, 1940.292, 1940.042, 1939.792, 1939.542, 1939.292, 1939.042, 1938.792, 1938.542, 1938.292, 1938.042, 1937.792, 1937.542, 1937.292, 1937.042, 1936.792, 1936.542, 1936.292, 1936.042, 1935.792, 1935.542, 1935.292, 1935.042, 1934.792, 1934.542, 1934.292, 1934.042, 1933.792, 1933.542, 1933.292, 1933.042, 1932.792, 1932.542, 1932.292, 1932.042, 1931.792, 1931.542, 1931.292, 1931.042, 1930.792, 1930.542, 1930.292, 1930.042, 1929.792, 1929.542, 1929.292, 1929.042, 1928.792, 1928.542, 1928.292, 1928.042, 1927.792, 1927.542, 1927.292, 1927.042, 1926.792, 1926.542, 1926.292, 1926.042, 1925.792, 1925.542, 1925.292, 1925.042, 1924.792, 1924.542, 1924.292, 1924.042, 1923.792, 1923.542, 1923.292, 1923.042, 1922.792, 1922.542, 1922.292, 1922.042, 1921.792, 1921.542, 1921.292, 1921.042, 1920.792, 1920.542, 1920.292, 1920.042, 1919.792, 1919.542, 1919.292, 1919.042, 1918.792, 1918.542, 1918.292, 1918.042, 1917.792, 1917.542, 1917.292, 1917.042, 1916.792, 1916.542, 1916.292, 1916.042, 1915.792, 1915.542, 1915.292, 1915.042, 1914.792, 1914.542, 1914.292, 1914.042, 1913.792, 1913.542, 1913.292, 1913.042, 1912.792, 1912.542, 1912.292, 1912.042, 1911.792, 1911.542, 1911.292, 1911.042, 1910.792, 1910.542, 1910.292, 1910.042, 1909.792, 1909.542, 1909.292, 1909.042, 1908.792, 1908.542, 1908.292, 1908.042, 1907.792, 1907.542, 1907.292, 1907.042, 1906.792, 1906.542, 1906.292, 1906.042, 1905.792, 1905.542, 1905.292, 1905.042, 1904.792, 1904.542, 1904.292, 1904.042, 1903.792, 1903.542, 1903.292, 1903.042, 1902.792, 1902.542, 1902.292, 1902.042, 1901.792, 1901.542, 1901.292, 1901.042, 1900.792, 1900.542, 1900.292, 1900.042, 1899.792, 1899.542, 1899.292, 1899.042, 1898.792, 1898.542, 1898.292, 1898.042, 1897.792, 1897.542, 1897.292, 1897.042, 1896.792, 1896.542, 1896.292, 1896.042, 1895.792, 1895.542, 1895.292, 1895.042, 1894.792, 1894.542, 1894.292, 1894.042, 1893.792, 1893.542, 1893.292, 1893.042, 1892.792, 1892.542, 1892.292, 1892.042, 1891.792, 1891.542, 1891.292, 1891.042, 1890.792, 1890.542, 1890.292, 1890.042, 1889.792, 1889.542, 1889.292, 1889.042, 1888.792, 1888.542, 1888.292, 1888.042, 1887.792, 1887.542, 1887.292, 1887.042, 1886.792, 1886.542, 1886.292, 1886.042, 1885.792, 1885.542, 1885.292, 1885.042, 1884.792, 1884.542, 1884.292, 1884.042, 1883.792, 1883.542, 1883.292, 1883.042, 1882.792, 1882.542, 1882.292, 1882.042, 1881.792, 1881.542, 1881.292, 1881.042, 1880.792]}, {'variableName': 'd18O', 'variableType': 'measured', 'qCCertification': 'KLD, NJA', 'useInGlobalTemperatureAnalysis': True, 'inCompilationBeta': {'compilationName': 'Pages2kTemperature', 'compilationVersion': '2_1_1'}, 'TSid': 'Ocean2kHR_140', 'ocean2kID': 'PacificMadangTudhope2001', 'interpretation': [{'scope': 'climate', 'variableDetail': 'sea@surface', 'direction': 'negative', 'seasonality': 'subannual', 'variable': 'temperature'}], 'number': 1, 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'hasMeanValue': -4.9453, 'hasMinValue': -5.515, 'measurementTableName': 'measurementTable1', 'notes': '; climateInterpretation_seasonality changed - was originally seasonal', 'sensorGenus': 'Porites', 'paleoDataTableName': 'measTable', 'hasMaxValue': -4.344, 'proxyObservationType': 'd18O', 'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt', 'hasMedianValue': -4.942, 'resolution': {'hasMaxValue': 0.25, 'hasMeanValue': 0.25, 'hasMedianValue': 0.25, 'hasMinValue': 0.25, 'units': 'yr AD'}, 'pages2kID': 'Ocn_097', 'iso2kUI': 'CO01TUNG01A', 'units': 'permil', 'proxy': 'd18O', 'archiveType': 'Coral', 'values': [-4.827, -4.786, -4.693, -4.852, -4.991, -4.904, -4.855, -4.862, -4.856, -4.947, -5.005, -5.298, -5.196, -5.298, -5.106, -5.375, -5.169, -5.083, -4.996, -5.027, -4.846, -4.646, -4.589, -4.972, -4.917, -4.795, -4.759, -5.301, -5.12, -5.086, -5.103, -5.244, -5.186, -5.059, -4.971, -5.356, -5.206, -4.885, -4.756, -4.959, -4.812, -4.667, -4.494, -5.117, -5.189, -5.133, -5.081, -5.165, -5.049, -4.883, -4.839, -5.103, -5.083, -4.96, -4.921, -5.204, -5.082, -5.133, -5.026, -5.334, -5.129, -4.889, -4.855, -5.214, -5.003, -4.842, -4.864, -5.038, -4.878, -5.027, -5.181, -5.515, -5.334, -5.06, -4.958, -5.268, -5.228, -5.136, -5.123, -5.304, -5.072, -4.748, -4.785, -5.234, -5.164, -5.053, -5.03, -5.188, -4.931, -4.99, -5.142, -5.216, -5.09, -4.865, -4.894, -5.041, -5.037, -5.064, -5.11, -5.291, -5.198, -5.242, -5.297, -5.492, -5.382, -5.087, -5.009, -5.282, -4.831, -4.524, -4.556, -5.071, -4.995, -4.958, -4.991, -5.08, -4.942, -4.908, -4.848, -4.993, -4.964, -5.031, -5.02, -5.245, -5.157, -5.041, -5.19, -5.39, -5.244, -5.072, -5.082, -5.362, -5.148, -4.889, -4.942, -4.895, -4.995, -4.924, -4.962, -5.0, -4.912, -4.774, -4.87, -5.104, -5.01, -4.996, -5.031, -5.112, -4.962, -5.003, -4.886, -5.095, -5.409, -4.992, -4.859, -5.151, -5.087, -5.031, -5.02, -5.355, -5.148, -5.13, -5.106, -5.228, -5.05, -4.868, -4.854, -4.937, -4.903, -4.902, -4.821, -4.963, -4.792, -4.886, -4.891, -5.146, -4.912, -4.856, -4.771, -4.964, -4.866, -4.909, -5.07, -5.459, -5.246, -4.871, -4.847, -5.086, -4.91, -4.912, -4.991, -5.203, -5.149, -4.957, -4.979, -5.232, -5.087, -5.072, -5.013, -5.329, -5.239, -5.016, -5.016, -5.079, -4.87, -4.786, -4.385, -4.525, -4.707, -4.607, -4.403, -4.607, -4.773, -4.846, -4.832, -4.925, -4.677, -4.487, -4.495, -4.597, -4.594, -4.629, -4.582, -4.832, -4.836, -4.687, -4.644, -4.967, -4.739, -4.803, -4.786, -5.133, -4.839, -4.899, -4.813, -4.973, -4.913, -5.002, -4.904, -5.114, -4.917, -4.886, -4.72, -4.926, -4.874, -4.677, -4.601, -4.924, -5.175, -4.906, -4.725, -5.135, -4.907, -4.829, -4.79, -5.185, -5.123, -4.988, -5.104, -5.33, -5.185, -5.158, -5.06, -5.282, -5.163, -5.06, -4.911, -5.03, -5.049, -4.688, -4.775, -5.055, -4.936, -4.807, -4.774, -5.162, -5.014, -4.975, -4.65, -4.919, -5.268, -4.892, -4.984, -5.139, -5.146, -4.998, -4.875, -5.035, -5.149, -5.123, -4.942, -5.108, -5.254, -4.856, -4.766, -5.051, -5.097, -4.715, -4.613, -4.786, -5.022, -4.986, -4.899, -4.96, -4.779, -4.897, -5.019, -5.453, -5.06, -4.788, -4.659, -4.767, -4.79, -4.378, -4.344, -4.727, -4.903, -4.875, -4.756, -4.988, -5.185, -4.943, -4.816, -4.839, -4.795, -4.747, -4.636, -4.753, -4.796, -4.716, -4.636, -4.775, -4.845, -4.809, -4.832, -5.013, -5.084, -4.909, -4.94, -5.031, -4.735, -4.625, -4.703, -4.933, -4.787, -4.808, -4.824, -5.266, -4.987, -4.634, -4.786, -5.08, -4.978, -4.988, -4.774, -5.006, -5.014, -4.866, -4.767, -4.722, -4.546, -4.359, -4.582, -5.062, -5.27, -5.077, -5.174, -5.2, -4.911, -4.96, -4.89, -5.115, -4.926, -4.839, -4.866, -5.211, -5.128, -5.037, -4.995, -5.131, -5.041, -4.969, -4.949, -5.052, -4.941, -4.671, -4.616, -5.11, -5.048, -4.751, -4.634, -5.052, -4.846, -4.742, -4.741, -4.903, -4.947, -4.848, -4.877, -4.886, -4.878, -4.956, -4.681, -4.941, -4.83, -5.185, -5.012, -4.967, -4.924, -4.77, -4.612, -4.957, -5.018, -4.97, -4.792, -4.788, -4.696, -4.525, -4.527, -4.721, -4.691, -4.853, -4.788, -4.931, -4.912, -4.954, -5.027, -4.937, -4.718, -4.512, -4.494, -4.675, -4.651, -4.666, -4.64, -4.849, -4.888, -4.833, -4.803, -4.863, -4.915, -4.733, -4.792, -4.872, -5.023, -4.923, -4.792, -4.906, -4.94, -4.801]}], 'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv', 'googleWorkSheetKey': 'ov9tjw6'}]}], 'inCompilation2_': 'PAGES2k_v2.0.0', 'datasetId': 'm8yv2VgG97zJmSg3XhqQ', 'maxYear': 1993.042, 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'minYear': 1880.792, 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866', 'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'dataContributor': {'name': 'Wu KLD'}, 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd', 'inCompilation3_': 'PAGES2k_v2.1.0', 'googleMetadataWorksheet': 'oruuxfm', 'archiveType': 'Coral'}
get_model_properties()[source]

Get all the properties associated with a model

Returns:

A list of unique properties attached to models

Return type:

List

Examples

from pylipd.utils.dataset import load_datasets
lipd = load_datasets(names='ODP846')
model_properties = lipd.get_model_properties()
print(model_properties)
['/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd']
Loading 1 LiPD files
Loaded..
['type', 'hasEnsembleTable', 'hasCode', 'hasSummaryTable']
get_timeseries(dsnames, to_dataframe=False, mode='paleo', time='age')[source]

Get Legacy LiPD like Time Series Object (tso)

Parameters:
  • dsnames (list) – array of dataset id or name strings

  • to_dataframe (bool {True; False}) – Whether to return a dataframe along the dictionary. Default is False

Returns:

  • ts (dict) – A dictionary containing Time Series Object

  • df (Pandas.DataFrame) – If to_dataframe is set to True, returns a queriable Pandas DataFrame

Examples

from pylipd.lipd import LiPD

# Fetch LiPD data from remote RDF Graph
lipd_remote = LiPD()
lipd_remote.set_endpoint("https://linkedearth.graphdb.mint.isi.edu/repositories/LiPDVerse-dynamic")
ts_list = lipd_remote.get_timeseries(["Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001", "MD98_2181.Stott.2007", "Ant-WAIS-Divide.Severinghaus.2012"])
for dsname, tsos in ts_list.items():
    for tso in tsos:
        if 'paleoData_variableName' in tso:
            print(dsname+': '+tso['paleoData_variableName']+': '+tso['archiveType'])
Extracting timeseries from dataset: Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001 ...
Extracting timeseries from dataset: MD98_2181.Stott.2007 ...
Extracting timeseries from dataset: Ant-WAIS-Divide.Severinghaus.2012 ...
get_timeseries_essentials(dsnames=None, mode='paleo')[source]
Returns specific properties for timeseries: ‘dataSetName’, ‘archiveType’, ‘geo_meanLat’, ‘geo_meanLon’,

‘geo_meanElev’, ‘paleoData_variableName’, ‘paleoData_values’, ‘paleoData_units’, ‘paleoData_proxy’ (paleo only), ‘paleoData_proxyGeneral’ (paleo only), ‘time_variableName’, ‘time_values’, ‘time_units’, ‘depth_variableName’, ‘depth_values’, ‘depth_units’

Parameters:
  • dsnames (list) – array of dataset id or name strings

  • mode (paleo, chron) – Whether to retrun the information stored in the PaleoMeasurementTable or the ChronMeasurementTable. The default is ‘paleo’.

Raises:

ValueError – Need to select either ‘chron’ or ‘paleo’

Returns:

qres_df – A pandas dataframe returning the properties in columns for each series stored in a row of the dataframe

Return type:

pandas.DataFrame

Example

from pylipd.utils.dataset import load_datasets
lipd = load_datasets('ODP846.Lawrence.2006.lpd')
df_paleo = lipd.get_timeseries_essentials(mode='paleo')
print(df_paleo)
['/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd']
Loading 1 LiPD files
Loaded..
              dataSetName      archiveType  geo_meanLat  geo_meanLon  \
0    ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
1    ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
2    ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
3    ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
4    ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
..                    ...              ...          ...          ...   
195  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
196  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
197  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
198  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
199  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   

     geo_meanElev paleoData_variableName  \
0         -3296.0               interval   
1         -3296.0              c37 total   
2         -3296.0              site/hole   
3         -3296.0                section   
4         -3296.0  c. wuellerstorfi d13c   
..            ...                    ...   
195       -3296.0              ukprime37   
196       -3296.0             temp prahl   
197       -3296.0           sample label   
198       -3296.0           sample label   
199       -3296.0           sample label   

                                      paleoData_values paleoData_units  \
0    [15-16, 25-26, 35-36, 45-46, 55-56, 65-66, 75-...              cm   
1    [2.37, 2.1, 1.87, 2.74, 3.75, 7.62, 7.86, 7.73...         nmol/kg   
2    [846B, 846B, 846B, 846B, 846B, 846B, 846B, 846...        unitless   
3    [1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-...        unitless   
4    [3.38, 3.46, 3.65, 3.88, 4.14, 4.47, 4.99, 4.9...     per mil PDB   
..                                                 ...             ...   
195  [0.821, 0.824, 0.828, 0.787, 0.777, 0.767, 0.7...        unitless   
196  [23.0, 23.1, 23.2, 22.0, 21.7, 21.4, 21.7, 21....           deg C   
197  [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ...        unitless   
198  [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ...        unitless   
199  [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ...        unitless   

    paleoData_proxy paleoData_proxyGeneral time_variableName  \
0              None                   None               age   
1              None                   None               age   
2              None                   None               age   
3              None                   None               age   
4              None                   None              None   
..              ...                    ...               ...   
195            None                   None               age   
196            None                   None               age   
197            None                   None              None   
198            None                   None              None   
199            None                   None              None   

                                           time_values time_units  \
0    [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
1    [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
2    [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
3    [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
4                                                 None       None   
..                                                 ...        ...   
195  [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
196  [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ...     kyr BP   
197                                               None       None   
198                                               None       None   
199                                               None       None   

    depth_variableName                                       depth_values  \
0                depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
1                depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
2                depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
3                depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
4             depth cr  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
..                 ...                                                ...   
195              depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
196              depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
197           depth cr  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
198         depth comp  [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73....   
199              depth  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   

    depth_units  
0             m  
1             m  
2             m  
3             m  
4          rmcd  
..          ...  
195           m  
196           m  
197        rmcd  
198         mcd  
199           m  

[200 rows x 16 columns]

To return the information stored in the ChronTable:

from pylipd.utils.dataset import load_datasets
lipd = load_datasets('ODP846.Lawrence.2006.lpd')
df_chron = lipd.get_timeseries_essentials(mode='chron')
print(df_chron)
['/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.0/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd']
Loading 1 LiPD files
Loaded..
             dataSetName      archiveType  geo_meanLat  geo_meanLon  \
0   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
1   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
2   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
3   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
4   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
5   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
6   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
7   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
8   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
9   ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
10  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
11  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
12  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
13  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
14  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
15  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
16  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
17  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
18  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
19  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
20  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
21  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
22  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   
23  ODP846.Lawrence.2006  Marine sediment         -3.1        -90.8   

    geo_meanElev chronData_variableName  \
0        -3296.0                    age   
1        -3296.0                  depth   
2        -3296.0                   d18o   
3        -3296.0                    age   
4        -3296.0                  depth   
5        -3296.0                   d18o   
6        -3296.0                    age   
7        -3296.0                  depth   
8        -3296.0                   d18o   
9        -3296.0                    age   
10       -3296.0                  depth   
11       -3296.0                   d18o   
12       -3296.0                    age   
13       -3296.0                  depth   
14       -3296.0                   d18o   
15       -3296.0                    age   
16       -3296.0                  depth   
17       -3296.0                   d18o   
18       -3296.0                    age   
19       -3296.0                  depth   
20       -3296.0                   d18o   
21       -3296.0                    age   
22       -3296.0                  depth   
23       -3296.0                   d18o   

                                     chronData_values chronData_units  \
0   [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
1   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
2   [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
3   [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
4   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
5   [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
6   [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
7   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
8   [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
9   [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
10  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
11  [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
12  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
13  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
14  [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
15  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
16  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
17  [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
18  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
19  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
20  [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   
21  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...           ky BP   
22  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...               m   
23  [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4....          permil   

   time_variableName                                        time_values  \
0                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
1                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
2                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
3                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
4                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
5                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
6                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
7                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
8                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
9                age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
10               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
11               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
12               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
13               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
14               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
15               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
16               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
17               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
18               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
19               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
20               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
21               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
22               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   
23               age  [3.645, 7.99, 11.18, 13.803, 15.886, 17.93, 19...   

   time_units depth_variableName  \
0       ky BP              depth   
1       ky BP              depth   
2       ky BP              depth   
3       ky BP              depth   
4       ky BP              depth   
5       ky BP              depth   
6       ky BP              depth   
7       ky BP              depth   
8       ky BP              depth   
9       ky BP              depth   
10      ky BP              depth   
11      ky BP              depth   
12      ky BP              depth   
13      ky BP              depth   
14      ky BP              depth   
15      ky BP              depth   
16      ky BP              depth   
17      ky BP              depth   
18      ky BP              depth   
19      ky BP              depth   
20      ky BP              depth   
21      ky BP              depth   
22      ky BP              depth   
23      ky BP              depth   

                                         depth_values depth_units  
0   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
1   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
2   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
3   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
4   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
5   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
6   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
7   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
8   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
9   [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
10  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
11  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
12  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
13  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
14  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
15  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
16  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
17  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
18  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
19  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
20  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
21  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
22  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
23  [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8...           m  
get_variable_properties()[source]

Get a list of variable properties that can be used for querying

Returns:

A list of unique variable properties

Return type:

list

Examples

from pylipd.utils.dataset import load_dir
lipd = load_dir(name='Pages2k')
variable_properties = lipd.get_variable_properties()
print(variable_properties)
Loading 16 LiPD files
Loaded..
['hasName', 'hasVariableId', 'measurementTableMD5', 'hasArchiveType', 'hasMeanValue', 'foundInDataset', 'hasValues', 'hasUnits', 'dataType', 'paleoDataTableName', 'hasMedianValue', 'foundInTable', 'measurementTableName', 'hasStandardVariable', 'type', 'hasColumnNumber', 'hasMinValue', 'wDSPaleoUrl', 'hasResolution', 'inferredVariableType', 'hasType', 'hasMaxValue', 'hasDescription', 'hasInterpretation', 'partOfCompilation', 'hasProxy', 'pages2kID', 'hasNotes', 'calibratedVia', 'useInGlobalTemperatureAnalysis', 'qCCertification', 'proxyObservationType', 'precededBy', 'hasUncertainty', 'measurementMethod', 'detail', 'measurementMaterial', 'ocean2kID', 'sensorSpecies', 'sensorGenus', 'iso2kUI']
load(lipdfiles, parallel=False, standardize=True, add_labels=True)[source]

Load LiPD files.

Parameters:
  • lipdfiles (list of str) – array of paths to lipd files (the paths could also be urls)

  • parallel (bool) – (Optional) set to True to process lipd files in parallel. You must run this function under the “__main__” process for this to work

Examples

In this example, we load LiPD files for an array of paths.

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd",
    "../examples/data/Ant-WAIS-Divide.Severinghaus.2012.lpd",
    "https://lipdverse.org/data/LCf20b99dfe8d78840ca60dfb1f832b9ec/1_0_1/Nunalleq.Ledger.2018.lpd"
])

print(lipd.get_all_dataset_names())
Loading 4 LiPD files
Loaded..
['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007', 'Ant-WAIS-Divide.Severinghaus.2012', 'Nunalleq.Ledger.2018']
load_datasets(datasets: list[Dataset])[source]

Loads instances of Dataset class into the LiPD graph

Parameters:

pylipd.classes.Dataset (list of) – A list of Dataset objects

Examples

pyLipd ships with existing datasets that can be loaded directly through the package. Let’s load the Pages2k sample datasets using this method.

from pylipd.utils.dataset import load_dir

lipd = load_dir('Pages2k')
dses = lipd.get_datasets()

# Modify the datasets if needed, then write them to the same, or another LiPD object

lipd2 = LiPD()
lipd2.load_datasets(dses)
Loading 16 LiPD files
Loaded..
load_from_dir(dir_path, parallel=False, cutoff=None, standardize=True, add_labels=True)[source]

Load LiPD files from a directory

Parameters:
  • dir_path (str) – path to the directory containing lipd files

  • parallel (bool) – (Optional) set to True to process lipd files in parallel. You must run this function under the “__main__” process for this to work

  • cutoff (int) – (Optional) the maximum number of files to load at once.

Examples

In this example, we load LiPD files from a directory.

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load_from_dir("../examples/data")

print(lipd.get_all_dataset_names())
Loading 4 LiPD files
Loaded..
['MD98_2181.Stott.2007', 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'ODP846.Lawrence.2006', 'Ant-WAIS-Divide.Severinghaus.2012']
load_remote_datasets(dsnames, load_default_graph=True)[source]

Loads remote datasets into cache if a remote endpoint is set

Parameters:

dsnames (array) – array of dataset names

Examples

from pylipd.lipd import LiPD

# Fetch LiPD data from remote RDF Graph
lipd_remote = LiPD()
lipd_remote.set_endpoint("https://linkedearth.graphdb.mint.isi.edu/repositories/LiPDVerse-dynamic")
lipd_remote.load_remote_datasets(["Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001", "MD98_2181.Stott.2007", "Ant-WAIS-Divide.Severinghaus.2012"])
print(lipd_remote.get_all_dataset_names())
Caching datasets from remote endpoint..
Making remote query to endpoint: https://linkedearth.graphdb.mint.isi.edu/repositories/LiPDVerse-dynamic
Done..
['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007', 'Ant-WAIS-Divide.Severinghaus.2012']
pop(dsnames)[source]

Pops dataset(s) from the graph and returns the popped LiPD object

Parameters:

dsnames (str or list of str) – dataset name(s) to be popped.

Returns:

LiPD object with the popped dataset(s)

Return type:

pylipd.lipd.LiPD

Examples

from pylipd.lipd import LiPD

# Load local files
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
all_datasets = lipd.get_all_dataset_names()
print("Loaded datasets: " + str(all_datasets))
popped = lipd.pop(all_datasets[0])
print("Loaded datasets after pop: " + str(lipd.get_all_dataset_names()))
print("Popped dataset: " + str(popped.get_all_dataset_names()))
Loading 2 LiPD files
Loaded..
Loaded datasets: ['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007']
Loaded datasets after pop: ['MD98_2181.Stott.2007']
Popped dataset: ['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001']
remove(dsnames)[source]

Removes dataset(s) from the graph

Parameters:

dsnames (str or list of str) – dataset name(s) to be removed

Examples

from pylipd.lipd import LiPD

# Load local files
lipd = LiPD()
lipd.load([
    "../examples/data/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd",
    "../examples/data/MD98_2181.Stott.2007.lpd"
])
all_datasets = lipd.get_all_dataset_names()
print("Loaded datasets: " + str(all_datasets))
lipd.remove(all_datasets[0])
print("Loaded datasets after remove: " + str(lipd.get_all_dataset_names()))
Loading 2 LiPD files
Loaded..
Loaded datasets: ['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'MD98_2181.Stott.2007']
Loaded datasets after remove: ['MD98_2181.Stott.2007']
to_lipd_series(parallel=False)[source]

Converts the LiPD object to a LiPDSeries object

Parameters:

parallel (bool) – Whether to use parallel processing to load the data. Default is False

Returns:

A LiPDSeries object

Return type:

pylipd.lipd.LiPDSeries

Examples

from pylipd.lipd import LiPD

lipd = LiPD()
lipd.load([
    "../examples/data/ODP846.Lawrence.2006.lpd"
])

S = lipd.to_lipd_series()
Loading 1 LiPD files
Loaded..
Creating LiPD Series...
- Extracting dataset subgraphs
- Extracting variable subgraphs
Done..
update_remote_datasets(dsnames)[source]

Updates local LiPD Graph for datasets to remote endpoint

pylipd.utils.lipd_to_rdf module

The LipdToRDF class helps in converting a LiPD file to an RDF Graph. It uses the SCHEMA dictionary (from globals/schema.py) to do the conversion

class pylipd.utils.lipd_to_rdf.LipdToRDF(standardize=True, add_labels=True)[source]

Bases: object

The LipdToRDF class helps in converting a LiPD file to an RDF Graph. It uses the SCHEMA dictionary (from globals/schema.py) to do the conversion

Methods

convert(lipdpath)

Convert LiPD file to RDF Graph

serialize(topath[, type])

Write LiPD RDF Graph to RDF file (or Pickle file)

convert(lipdpath)[source]

Convert LiPD file to RDF Graph

Parameters:

lipdpath (str) – path to lipd file (the path could also be a url)

serialize(topath, type='rdf')[source]

Write LiPD RDF Graph to RDF file (or Pickle file)

Parameters:
  • topath (str) – path to the output file

  • type (str) – the output file type : rdf or pickle (we store the pickled rdf graph for efficiency sometimes)

pylipd.utils.multi_processing module

pylipd.utils.multi_processing.convert_lipd_to_graph(arg)[source]
pylipd.utils.multi_processing.convert_to_rdf(files)[source]
pylipd.utils.multi_processing.extract_variables_graph(arg)[source]
pylipd.utils.multi_processing.multi_convert_to_rdf(filemap, parallel=True, standardize=True, add_labels=True)[source]
pylipd.utils.multi_processing.multi_load_lipd(graph, lipdfiles, parallel=True, standardize=True, add_labels=True)[source]

Load all lipdfiles to the RDF graph

pylipd.utils.multi_processing.multi_load_lipd_series(graph, single_dataset_lipds, parallel=True)[source]

Load all lipd variables to the RDF graph

pylipd.utils.rdf_to_lipd module

The RDFToLiPD class helps in converting an RDF Graph to a LiPD file. It uses the SCHEMA dictionary (from globals/schema.py) to do the conversion

class pylipd.utils.rdf_to_lipd.RDFToLiPD(graph)[source]

Bases: object

The RDFToLiPD class helps in converting an RDF Graph to a LiPD file. It uses the SCHEMA dictionary (from globals/schema.py) to do the conversion

Methods

convert(dsname, lipdfile)

Convert RDF graph to a LiPD file

convert_to_json(dsname)

Convert RDF graph to a LiPD file

convert(dsname, lipdfile)[source]

Convert RDF graph to a LiPD file

Parameters:

graph (rdflib.ConjunctiveGraph) – the RDF graph object

convert_to_json(dsname)[source]

Convert RDF graph to a LiPD file

Parameters:

graph (rdflib.ConjunctiveGraph) – the RDF graph object

pylipd.utils.rdfrdf_graph module

The RDF Graph class contains an RDF Graph using the RDFLib library, and allows querying over it using SPARQL. It also allows querying over a remote endpoint.

class pylipd.utils.rdf_graph.RDFGraph(graph=None)[source]

Bases: object

The RDF Graph class contains an RDF Graph using the RDFLib library, and allows querying over it

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Load RDF file into graph
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"])
(result, result_df) = rdf.query("SELECT ?s ?p ?o WHERE {?s ?p ?o} LIMIT 10")
print(result_df)
                                                   s  \
0                          http://example.org/bob#me   
1                          http://example.org/bob#me   
2              http://www.wikidata.org/entity/Q12418   
3                          http://example.org/bob#me   
4              http://www.wikidata.org/entity/Q12418   
5  http://data.europeana.eu/item/04802/243FA86189...   
6                          http://example.org/bob#me   

                                                 p  \
0                      http://schema.org/birthDate   
1         http://xmlns.com/foaf/0.1/topic_interest   
2                 http://purl.org/dc/terms/creator   
3  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   
4                   http://purl.org/dc/terms/title   
5                 http://purl.org/dc/terms/subject   
6                  http://xmlns.com/foaf/0.1/knows   

                                               o  
0                                     1990-07-04  
1          http://www.wikidata.org/entity/Q12418  
2  http://dbpedia.org/resource/Leonardo_da_Vinci  
3               http://xmlns.com/foaf/0.1/Person  
4                                      Mona Lisa  
5          http://www.wikidata.org/entity/Q12418  
6                    http://example.org/alice#me  

Methods

clear()

Clears the graph

copy()

Makes a copy of the object

get(ids)

Get id(s) from the graph and returns the LiPD object

get_all_graph_ids()

Get all Graph ids

load(files[, graphid])

Loads a RDF file into the graph

merge(rdf)

Merges the current LiPD object with another LiPD object

pop(ids)

Pops graph(s) from the combined graph and returns the popped RDF Graph

query(query[, remote, result])

Once data is loaded into the graph (or remote endpoint set), one can make SparQL queries to the graph

remove(ids)

Removes ids(s) from the graph

serialize()

Returns RDF quad serialization of the current combined Graph .

set_endpoint(endpoint)

Sets a SparQL endpoint for a remote Knowledge Base (example: GraphDB)

clear()[source]

Clears the graph

copy()[source]

Makes a copy of the object

Returns:

a copy of the original object

Return type:

pylipd.utils.rdf_graph.RDFGraph

get(ids)[source]

Get id(s) from the graph and returns the LiPD object

Parameters:

ids (str or list of str) – graph id(s) to get.

Returns:

RDFGraph object with the retrieved graph(s)

Return type:

pylipd.utils.utils.rdf_graph.RDFGraph

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Fetch RDF graph data for given id(s)
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"], graphid="http://example.org/graph")
rdf.get("http://example.org/graph")
<pylipd.utils.rdf_graph.RDFGraph at 0x722dc5dd51d0>
get_all_graph_ids()[source]

Get all Graph ids

Returns:

  • ids (list)

  • A list of graph ids

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Fetch RDF Graph Data
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"], graphid="http://example.org/graph")
print(rdf.get_all_graph_ids())
['Nefde7f122d944c57939cac115a701474']
load(files, graphid=None)[source]

Loads a RDF file into the graph

Parameters:

rdf_file (str) – Path to the RDF file

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Load RDF file into graph
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"])
(result, result_df) = rdf.query("SELECT ?s ?p ?o WHERE {?s ?p ?o} LIMIT 10")
print(result_df)
                                                   s  \
0                          http://example.org/bob#me   
1                          http://example.org/bob#me   
2              http://www.wikidata.org/entity/Q12418   
3                          http://example.org/bob#me   
4              http://www.wikidata.org/entity/Q12418   
5  http://data.europeana.eu/item/04802/243FA86189...   
6                          http://example.org/bob#me   

                                                 p  \
0                      http://schema.org/birthDate   
1         http://xmlns.com/foaf/0.1/topic_interest   
2                 http://purl.org/dc/terms/creator   
3  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   
4                   http://purl.org/dc/terms/title   
5                 http://purl.org/dc/terms/subject   
6                  http://xmlns.com/foaf/0.1/knows   

                                               o  
0                                     1990-07-04  
1          http://www.wikidata.org/entity/Q12418  
2  http://dbpedia.org/resource/Leonardo_da_Vinci  
3               http://xmlns.com/foaf/0.1/Person  
4                                      Mona Lisa  
5          http://www.wikidata.org/entity/Q12418  
6                    http://example.org/alice#me  
merge(rdf)[source]

Merges the current LiPD object with another LiPD object

Parameters:

rdf (pylipd.rdf_graph.RDFGraph) – RDFGraph object to merge with

Returns:

merged RDFGraph object

Return type:

pylipd.utils.rdf_graph.RDFGraph

pop(ids)[source]

Pops graph(s) from the combined graph and returns the popped RDF Graph

Parameters:

ids (str or list of str) – rdf id(s) to be popped.

Returns:

RDFGraph object with the popped graph(s)

Return type:

pylipd.utils.rdf_graph.RDFGraph

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Pop RDF graph data for given id(s)
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"], graphid="http://example.org/graph")
popped = rdf.pop("http://example.org/graph")
query(query, remote=False, result='sparql')[source]

Once data is loaded into the graph (or remote endpoint set), one can make SparQL queries to the graph

Parameters:
  • query (str) – SparQL query

  • remote (bool) – (Optional) If set to True, the query will be made to the remote endpoint (if set)

  • result (str) – (Optional) Result return type

Returns:

  • result (dict) – Dictionary of sparql variable and binding values

  • result_df (pandas.Dataframe) – Return the dictionary above as a pandas.Dataframe

Examples

from pylipd.utils.rdf_graph import RDFGraph

rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"])
query = """PREFIX le: <http://linked.earth/ontology#>
        select ?s ?p ?o where {
            ?s ?p ?o
        } LIMIT 10 """
result, result_df = rdf.query(query)
print(result_df)
                                                   s  \
0                          http://example.org/bob#me   
1                          http://example.org/bob#me   
2              http://www.wikidata.org/entity/Q12418   
3                          http://example.org/bob#me   
4              http://www.wikidata.org/entity/Q12418   
5  http://data.europeana.eu/item/04802/243FA86189...   
6                          http://example.org/bob#me   

                                                 p  \
0                      http://schema.org/birthDate   
1         http://xmlns.com/foaf/0.1/topic_interest   
2                 http://purl.org/dc/terms/creator   
3  http://www.w3.org/1999/02/22-rdf-syntax-ns#type   
4                   http://purl.org/dc/terms/title   
5                 http://purl.org/dc/terms/subject   
6                  http://xmlns.com/foaf/0.1/knows   

                                               o  
0                                     1990-07-04  
1          http://www.wikidata.org/entity/Q12418  
2  http://dbpedia.org/resource/Leonardo_da_Vinci  
3               http://xmlns.com/foaf/0.1/Person  
4                                      Mona Lisa  
5          http://www.wikidata.org/entity/Q12418  
6                    http://example.org/alice#me  
remove(ids)[source]

Removes ids(s) from the graph

Parameters:

ids (str or list of str) – graph id(s) to be removed

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Remove RDF graph data for given id(s)
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"], graphid="http://example.org/graph")
rdf.remove("http://example.org/graph")
serialize()[source]

Returns RDF quad serialization of the current combined Graph .. rubric:: Examples

from pylipd.utils.rdf_graph import RDFGraph

# Fetch RDF data
rdf = RDFGraph()
rdf.load(["../examples/rdf/graph.ttl"], graphid="http://example.org/graph")
nquads = rdf.serialize()
print(nquads[:10000])
print("...")
<http://example.org/bob#me> <http://schema.org/birthDate> "1990-07-04"^^<http://www.w3.org/2001/XMLSchema#date> _:Ne4a33aecb214489889a10907bb8370cd .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/topic_interest> <http://www.wikidata.org/entity/Q12418> _:Ne4a33aecb214489889a10907bb8370cd .
<http://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/creator> <http://dbpedia.org/resource/Leonardo_da_Vinci> _:Ne4a33aecb214489889a10907bb8370cd .
<http://example.org/bob#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> _:Ne4a33aecb214489889a10907bb8370cd .
<http://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/title> "Mona Lisa" _:Ne4a33aecb214489889a10907bb8370cd .
<http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619> <http://purl.org/dc/terms/subject> <http://www.wikidata.org/entity/Q12418> _:Ne4a33aecb214489889a10907bb8370cd .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/knows> <http://example.org/alice#me> _:Ne4a33aecb214489889a10907bb8370cd .


...
set_endpoint(endpoint)[source]

Sets a SparQL endpoint for a remote Knowledge Base (example: GraphDB)

Parameters:

endpoint (str) – URL for the SparQL endpoint

Examples

from pylipd.utils.rdf_graph import RDFGraph

# Fetch LiPD data from remote RDF Graph
rdf = RDFGraph()
rdf.set_endpoint("https://linkedearth.graphdb.mint.isi.edu/repositories/LiPDVerse2")
(result, result_df) = rdf.query("SELECT ?s ?p ?o WHERE {?s ?p ?o} LIMIT 10")

pylipd.utils.utils module

pylipd.utils.utils.camelCase(id)[source]
pylipd.utils.utils.escape(str)[source]
pylipd.utils.utils.expand_schema(schema)[source]
pylipd.utils.utils.fromCamelCase(str)[source]
pylipd.utils.utils.lcfirst(s)[source]
pylipd.utils.utils.sanitizeId(id)[source]
pylipd.utils.utils.sparql_results_to_df(results: SPARQLResult) DataFrame[source]

Export results from an rdflib SPARQL query into a pandas.DataFrame, using Python types. See https://github.com/RDFLib/rdflib/issues/1179.

pylipd.utils.utils.ucfirst(s)[source]
pylipd.utils.utils.unCamelCase(id)[source]
pylipd.utils.utils.uniqid(prefix='', more_entropy=False)[source]
pylipd.utils.utils.unzip_string(string)[source]
pylipd.utils.utils.zip_string(string)[source]

Module contents