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: uncertainty: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertaintyLow: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: age: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: depth: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: age: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: temperature: Archaeological
Nunalleq.Ledger.2018: uncertainty: Archaeological
Nunalleq.Ledger.2018: uncertaintyHigh: Archaeological
Nunalleq.Ledger.2018: precipitation: Archaeological
Nunalleq.Ledger.2018: uncertainty: 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..
{'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993',
 'createdBy': 'matlab',
 'googleMetadataWorksheet': 'oruuxfm',
 'maxYear': 1993.042,
 'inCompilation3_': 'PAGES2k_v2.1.0',
 'minYear': 1880.792,
 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc',
 'dataContributor': {'name': 'Wu KLD'},
 'paleoData': [{'measurementTable': [{'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv',
     'googleWorkSheetKey': 'ov9tjw6',
     'tableName': 'Kuhnert',
     'columns': [{'measurementTableName': 'measurementTable1',
       'sensorGenus': 'Porites',
       'resolution': {'hasMaxValue': 0.25,
        'hasMedianValue': 0.25,
        'hasMeanValue': 0.25,
        'hasMinValue': 0.25,
        'units': 'yr AD'},
       'iso2kUI': 'CO01TUNG01A',
       'hasMinValue': -5.515,
       'hasMedianValue': -4.942,
       'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt',
       'hasMeanValue': -4.9453,
       'variableType': 'measured',
       'hasMaxValue': -4.344,
       'qCCertification': 'KLD, NJA',
       'paleoDataTableName': 'measTable',
       'useInGlobalTemperatureAnalysis': True,
       'pages2kID': 'Ocn_097',
       'notes': '; climateInterpretation_seasonality changed - was originally seasonal',
       'TSid': 'Ocean2kHR_140',
       'variableName': 'd18O',
       'proxyObservationType': 'd18O',
       'interpretation': [{'variableDetail': 'sea@surface',
         'scope': 'climate',
         'direction': 'negative',
         'seasonality': 'subannual',
         'variable': 'temperature'}],
       'inCompilationBeta': {'compilationName': 'Pages2kTemperature',
        'compilationVersion': '2_1_1'},
       'measurementTableMD5': '793853407e414221c486d2e63b32dd87',
       'ocean2kID': 'PacificMadangTudhope2001',
       'number': 1,
       'units': 'permil',
       'proxy': 'd18O',
       'archiveType': 'Coral'},
      {'measurementTableMD5': '793853407e414221c486d2e63b32dd87',
       'measurementTableName': 'measurementTable1',
       'dataType': 'float',
       'description': 'Year AD',
       'variableName': 'year',
       'hasMinValue': 1880.792,
       'hasMaxValue': 1993.042,
       'TSid': 'PYTDAS7AM1Y',
       'variableType': 'inferred',
       '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': 1936.917,
       'resolution': {'hasMeanValue': 0.25,
        'hasMinValue': 0.25,
        'hasMaxValue': 0.25,
        'hasMedianValue': 0.25,
        'units': 'yr AD'},
       'inferredVariableType': 'Year',
       'hasMeanValue': 1936.917,
       'number': 2,
       'paleoDataTableName': 'measTable',
       'units': 'yr AD',
       'archiveType': 'Coral'}],
     'missingValue': 'NaN'}]}],
 'inCompilation2_': 'PAGES2k_v2.0.0',
 'lipdVersion': 1.3,
 'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2],
   'type': 'Point'},
  'properties': {'type': 'http://linked.earth/ontology#Location',
   'longitude': 145.8167,
   'siteName': 'Madang Lagoon, Papua New Guinea',
   'elevation': -2.2,
   'latitude': -5.2167,
   'ocean': 'Pacific',
   'pages2kRegion': 'Ocean'}},
 'pub': [{'journal': 'Paleoceanography',
   'author': [{'name': 'K. Halimeda Kilbourne'},
    {'name': 'Jens Zinke'},
    {'name': 'Cyril Giry'},
    {'name': 'Jessica E. Tierney'},
    {'name': 'Michael N. Evans'},
    {'name': 'Casey P. Saenger'},
    {'name': 'Henry C. Wu'},
    {'name': 'Nerilie J. Abram'},
    {'name': 'Kevin J. Anchukaitis'}],
   'doi': '10.1002/2014PA002717',
   'issue': 3.0,
   'pages': '226-252',
   'dataUrl': ['doi.org'],
   'year': 2015,
   'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives',
   'publisher': 'Wiley-Blackwell',
   'citeKey': 'tierney2015tropicalseasurfacetempera',
   'volume': '30'},
  {'year': 2001,
   'doi': '10.1126/science.1057969',
   'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle',
   'journal': 'Science',
   'author': [{'name': 'A. W. Tudhope'}],
   'pages': '1511-1517',
   'dataUrl': ['doi.org'],
   'publisher': 'American Association for the Advancement of Science (AAAS)',
   'citeKey': 'tudhope2001variabilityintheelninosou',
   'volume': '291',
   'issue': 5508.0},
  {'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'],
   'institution': 'World Data Center for Paleoclimatology',
   'author': [{'name': 'H. Kuhnert'}],
   'title': 'World Data Center for Paleoclimatology',
   'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation',
   'urldate': 2001.0}],
 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866',
 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd',
 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc',
 'changelog': [{'notes': 'Starting the changelog',
   'timestamp': '2022-08-23 23:41:56 UTC',
   'version': '1.0.0',
   'curator': 'nicholas'}],
 'datasetId': 'm8yv2VgG97zJmSg3XhqQ',
 'inCompilation1_': 'Ocean2k_v1.0.0',
 'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001',
 '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..
['Marine sediment', 'Coral']
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.1/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-CoastofPortugal.Abrantes.2011.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-SpannagelCave.Mangini.2005.lpd', "/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/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.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-FinnishLakelands.Helama.2014.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-LakeSilvaplana.Trachsel.2010.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-Stockholm.Leijonhufvud.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/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.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-RedSea.Felis.2000.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-AlboranSea436B.Nieto-Moreno.2013.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/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.1/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.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Asi-SourthAndMiddleUrals.Demezhko.2007.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Ocn-FeniDrift.Richter.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Pages2k/Eur-NorthernScandinavia.Esper.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/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.1/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.1/lib/python3.11/site-packages/pylipd/data/Temp12k/ElGygytgynCrater.Schwamborn.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Temp12k/MD03-2601.Kim.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Temp12k/NevadoHuascaran.Thompson.1995.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Temp12k/SouthernCalifornia.Ohlwein.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.4.1/lib/python3.11/site-packages/pylipd/data/Temp12k/RC24_08GC.Arbuszewski.2013.lpd']
Loading 22 LiPD files
Loaded..
['MD03-2601.Kim.2012',
 'RC24_08GC.Arbuszewski.2013',
 'ElGygytgynCrater.Schwamborn.2006',
 'NevadoHuascaran.Thompson.1995']
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-RedSea.Felis.2000',
 'Eur-SpanishPyrenees.Dorado-Linan.2012',
 'Ocn-SinaiPeninsula_RedSea.Moustafa.2000',
 'Eur-LakeSilvaplana.Trachsel.2010',
 'Eur-SpannagelCave.Mangini.2005']
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..
['Eur-CoastofPortugal.Abrantes.2011',
 'Eur-NorthernSpain.Martin-Chivelet.2011',
 'Ocn-RedSea.Felis.2000',
 'Eur-FinnishLakelands.Helama.2014',
 'Eur-Stockholm.Leijonhufvud.2009',
 'Eur-SpanishPyrenees.Dorado-Linan.2012',
 'Ocn-AlboranSea436B.Nieto-Moreno.2013',
 'Ant-WAIS-Divide.Severinghaus.2012',
 'Eur-NorthernScandinavia.Esper.2012',
 'Asi-SourthAndMiddleUrals.Demezhko.2007',
 'Eur-LakeSilvaplana.Trachsel.2010',
 'Eur-SpannagelCave.Mangini.2005',
 'Ocn-FeniDrift.Richter.2009']
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)
Loading 5 LiPD files
Loaded..
['Temp12k', 'HoloceneAbruptChange', 'wNAm']
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-CoastofPortugal.Abrantes.2011        41.10      -8.9000   
1              Eur-CoastofPortugal.Abrantes.2011        41.10      -8.9000   
2              Eur-CoastofPortugal.Abrantes.2011        41.10      -8.9000   
3              Eur-CoastofPortugal.Abrantes.2011        41.10      -8.9000   
4              Eur-CoastofPortugal.Abrantes.2011        41.10      -8.9000   
..                                           ...          ...          ...   
123  Ocn-PedradeLume-CapeVerdeIslands.Moses.2006        16.76     -22.8883   
124  Ocn-PedradeLume-CapeVerdeIslands.Moses.2006        16.76     -22.8883   
125  Ocn-PedradeLume-CapeVerdeIslands.Moses.2006        16.76     -22.8883   
126  Ocn-PedradeLume-CapeVerdeIslands.Moses.2006        16.76     -22.8883   
127  Ocn-PedradeLume-CapeVerdeIslands.Moses.2006        16.76     -22.8883   

     geo_meanElev  
0           -80.0  
1           -80.0  
2           -80.0  
3           -80.0  
4           -80.0  
..            ...  
123          -5.0  
124          -5.0  
125          -5.0  
126          -5.0  
127          -5.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..
['temperature', 'year', 'd18O', 'Uk37', 'trsgi', 'uncertainty_temperature', 'Mg_Ca', 'depth_top', 'depth_bottom', 'notes', 'MXD']
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/ODP846.Lawrence.2006....  PYTM9N6HCQM   
1   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTI487BQDZ   
2   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTGO6NV72Y   
3   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTPQ0FJO1S   
4   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTDW6AIJPW   
5   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT2ZB6MLZ9   
6   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT3ZMI0BXW   
7   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTTD7XCQGS   
8   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTUHE3XLGQ   
9   http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTXJB98403   
10  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTTUPVG4K3   
11  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT19MC8WE2   
12  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT9CFQ4GK0   
13  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTKRFVW61B   
14  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTS96EE0CB   
15  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTGOFY4KZD   
16  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTCHXB40SL   
17  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTPWX0LH3I   
18  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTE5EC1JBW   
19  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTLEHYPAYV   
20  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT68HYMYHH   
21  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT4Y96QMUU   
22  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT10H23U2E   
23  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT8BDSRW3H   
24  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT7DLYN7X4   
25  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTJZ4GLRYP   
26  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTJ3PSH0LT   
27  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYT95DVDUU3   
28  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTYDOYFVYD   
29  http://linked.earth/lipd/ODP846.Lawrence.2006....  PYTDIEKUM44   

             variableName  
0               ukprime37  
1                 lower95  
2             temp muller  
3              depth comp  
4                     sst  
5                interval  
6   c. wuellerstorfi d18o  
7                     age  
8                     age  
9                     age  
10      u. peregrina d13c  
11  c. wuellerstorfi d13c  
12                  depth  
13                  depth  
14                  depth  
15                  depth  
16                  depth  
17                  depth  
18                  event  
19                   d18o  
20               depth cr  
21                   d180  
22              c37 total  
23                section  
24                 median  
25           sample label  
26              site/hole  
27             temp prahl  
28      u. peregrina d18o  
29                upper95  
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
([' @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', '@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{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={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', ' @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'],                                         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  Tropical sea surface temperatures for the past...   
1             World Data Center for Paleoclimatology   
2  Variability in the El Nino-Southern Oscillatio...   
3  Southern Hemisphere and deep-sea warming led d...   
4                                               None   

                                             authors                      doi  \
0  Jens Zinke and Cyril Giry and Jessica E. Tiern...     10.1002/2014PA002717   
1                                         H. Kuhnert                     None   
2                                      A. W. Tudhope  10.1126/science.1057969   
3          L. Stott and R. Thunell and A. Timmermann  10.1126/science.1143791   
4                                                        10.1029/2006PA001379   

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

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

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

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

                                         url2  
0                                        None  
1  https://www.ncdc.noaa.gov/paleo/study/1866  
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', 'hasChangeLog', 'hasLocation', 'hasName', 'hasDatasetId', 'lipdVersion', 'hasPublication', 'hasOriginalDataUrl', 'hasPaleoData', 'hasArchiveType', 'minYear', 'googleMetadataWorksheet', 'maxYear', 'googleDataURL', 'hasSpreadsheetLink', 'type', 'hasUrl', 'inCompilation2_', 'inCompilation3_', 'inCompilation1_', 'hasContributor', 'studyName', 'hasNotes', 'hasInvestigator', 'hasFunding']
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 0x7369bd4c1690>,
 <pylipd.classes.dataset.Dataset at 0x7369bd4c2490>,
 <pylipd.classes.dataset.Dataset at 0x7369bc123a10>,
 <pylipd.classes.dataset.Dataset at 0x7369b7481d90>,
 <pylipd.classes.dataset.Dataset at 0x7369bdd74250>,
 <pylipd.classes.dataset.Dataset at 0x7369be102050>,
 <pylipd.classes.dataset.Dataset at 0x7369b7aa1a10>,
 <pylipd.classes.dataset.Dataset at 0x7369b7a822d0>,
 <pylipd.classes.dataset.Dataset at 0x7369bd583610>,
 <pylipd.classes.dataset.Dataset at 0x7369b746ecd0>,
 <pylipd.classes.dataset.Dataset at 0x7369b7b1f290>,
 <pylipd.classes.dataset.Dataset at 0x7369b759cd10>,
 <pylipd.classes.dataset.Dataset at 0x7369b746f610>,
 <pylipd.classes.dataset.Dataset at 0x7369b6dd4a50>,
 <pylipd.classes.dataset.Dataset at 0x7369b7c4ddd0>,
 <pylipd.classes.dataset.Dataset at 0x7369b7b8dc90>]
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/ODP846.Lawrence.2006....   

  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..
{'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993', 'pub': [{'pages': '226-252', 'author': [{'name': 'Casey P. Saenger'}, {'name': 'Henry C. Wu'}, {'name': 'Nerilie J. Abram'}, {'name': 'Kevin J. Anchukaitis'}, {'name': 'K. Halimeda Kilbourne'}, {'name': 'Jens Zinke'}, {'name': 'Cyril Giry'}, {'name': 'Jessica E. Tierney'}, {'name': 'Michael N. Evans'}], 'year': 2015, 'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives', 'journal': 'Paleoceanography', 'issue': 3.0, 'publisher': 'Wiley-Blackwell', 'citeKey': 'tierney2015tropicalseasurfacetempera', 'doi': '10.1002/2014PA002717', 'dataUrl': ['doi.org'], 'volume': '30'}, {'publisher': 'American Association for the Advancement of Science (AAAS)', 'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle', 'citeKey': 'tudhope2001variabilityintheelninosou', 'volume': '291', 'issue': 5508.0, 'dataUrl': ['doi.org'], 'author': [{'name': 'A. W. Tudhope'}], 'journal': 'Science', 'year': 2001, 'doi': '10.1126/science.1057969', 'pages': '1511-1517'}, {'title': 'World Data Center for Paleoclimatology', 'author': [{'name': 'H. Kuhnert'}], 'institution': 'World Data Center for Paleoclimatology', 'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation', 'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'], 'urldate': 2001.0}], 'createdBy': 'matlab', 'googleMetadataWorksheet': 'oruuxfm', 'maxYear': 1993.042, 'inCompilation3_': 'PAGES2k_v2.1.0', 'minYear': 1880.792, 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'dataContributor': {'name': 'Wu KLD'}, 'paleoData': [{'measurementTable': [{'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv', 'googleWorkSheetKey': 'ov9tjw6', 'tableName': 'Kuhnert', 'columns': [{'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'measurementTableName': 'measurementTable1', 'dataType': 'float', 'description': 'Year AD', 'variableName': 'year', 'hasMinValue': 1880.792, 'hasMaxValue': 1993.042, 'TSid': 'PYTDAS7AM1Y', 'variableType': 'inferred', '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': 1936.917, 'resolution': {'hasMeanValue': 0.25, 'hasMinValue': 0.25, 'hasMaxValue': 0.25, 'hasMedianValue': 0.25, 'units': 'yr AD'}, 'inferredVariableType': 'Year', 'hasMeanValue': 1936.917, 'number': 2, 'paleoDataTableName': 'measTable', '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]}, {'inCompilationBeta': {'compilationName': 'Pages2kTemperature', 'compilationVersion': '2_1_1'}, 'measurementTableName': 'measurementTable1', 'sensorGenus': 'Porites', 'resolution': {'hasMaxValue': 0.25, 'hasMedianValue': 0.25, 'hasMeanValue': 0.25, 'hasMinValue': 0.25, 'units': 'yr AD'}, 'iso2kUI': 'CO01TUNG01A', 'hasMinValue': -5.515, 'hasMedianValue': -4.942, 'wDSPaleoUrl': 'https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/pages2k-temperature-v2-2017/data-version-2.0.0/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.txt', 'hasMeanValue': -4.9453, 'variableType': 'measured', 'hasMaxValue': -4.344, 'qCCertification': 'KLD, NJA', 'paleoDataTableName': 'measTable', 'useInGlobalTemperatureAnalysis': True, 'pages2kID': 'Ocn_097', 'notes': '; climateInterpretation_seasonality changed - was originally seasonal', 'TSid': 'Ocean2kHR_140', 'variableName': 'd18O', 'proxyObservationType': 'd18O', 'interpretation': [{'variableDetail': 'sea@surface', 'scope': 'climate', 'direction': 'negative', 'seasonality': 'subannual', 'variable': 'temperature'}], 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'ocean2kID': 'PacificMadangTudhope2001', 'number': 1, '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]}], 'missingValue': 'NaN'}]}], 'inCompilation2_': 'PAGES2k_v2.0.0', 'lipdVersion': 1.3, 'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2], 'type': 'Point'}, 'properties': {'type': 'http://linked.earth/ontology#Location', 'longitude': 145.8167, 'siteName': 'Madang Lagoon, Papua New Guinea', 'elevation': -2.2, 'latitude': -5.2167, 'ocean': 'Pacific', 'pages2kRegion': 'Ocean'}}, 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866', 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd', 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'changelog': [{'notes': 'Starting the changelog', 'timestamp': '2022-08-23 23:41:56 UTC', 'version': '1.0.0', 'curator': 'nicholas'}], 'datasetId': 'm8yv2VgG97zJmSg3XhqQ', 'inCompilation1_': 'Ocean2k_v1.0.0', 'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', '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.1/lib/python3.11/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd']
Loading 1 LiPD files
Loaded..
['hasEnsembleTable', 'type', '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.1/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  c. wuellerstorfi d18o   
3         -3296.0  c. wuellerstorfi d18o   
4         -3296.0  c. wuellerstorfi d18o   
..            ...                    ...   
195       -3296.0      u. peregrina d18o   
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    [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...     per mil PDB   
3    [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...     per mil PDB   
4    [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...     per mil PDB   
..                                                 ...             ...   
195  [0.14, 0.01, -0.1, -0.06, -0.17, -0.21, -0.41,...     per mil PDB   
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              None   
3              None                   None              None   
4              None                   None              None   
..              ...                    ...               ...   
195            None                   None              None   
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                                                 None       None   
3                                                 None       None   
4                                                 None       None   
..                                                 ...        ...   
195                                               None       None   
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 comp  [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73....   
3             depth cr  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
4                depth  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
..                 ...                                                ...   
195              depth  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
196              depth  [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8...   
197         depth comp  [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73....   
198           depth cr  [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7...   
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           mcd  
3          rmcd  
4             m  
..          ...  
195           m  
196           m  
197         mcd  
198        rmcd  
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.1/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                  depth   
1        -3296.0                   d18o   
2        -3296.0                    age   
3        -3296.0                  depth   
4        -3296.0                   d18o   
5        -3296.0                    age   
6        -3296.0                  depth   
7        -3296.0                   d18o   
8        -3296.0                    age   
9        -3296.0                  depth   
10       -3296.0                   d18o   
11       -3296.0                    age   
12       -3296.0                  depth   
13       -3296.0                   d18o   
14       -3296.0                    age   
15       -3296.0                  depth   
16       -3296.0                   d18o   
17       -3296.0                    age   
18       -3296.0                  depth   
19       -3296.0                   d18o   
20       -3296.0                    age   
21       -3296.0                  depth   
22       -3296.0                   d18o   
23       -3296.0                    age   

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

   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..
['hasType', 'foundInDataset', 'hasUnits', 'hasDescription', 'hasMaxValue', 'paleoDataTableName', 'hasColumnNumber', 'foundInTable', 'hasMedianValue', 'hasVariableId', 'hasArchiveType', 'hasResolution', 'hasMeanValue', 'hasStandardVariable', 'measurementTableName', 'wDSPaleoUrl', 'dataType', 'hasName', 'inferredVariableType', 'hasValues', 'hasMinValue', 'type', 'measurementTableMD5', 'precededBy', 'pages2kID', 'hasNotes', 'partOfCompilation', 'useInGlobalTemperatureAnalysis', 'hasInterpretation', 'calibratedVia', 'hasProxy', 'qCCertification', 'proxyObservationType', 'detail', 'ocean2kID', 'sensorSpecies', 'sensorGenus', 'iso2kUI', 'hasUncertainty', 'measurementMethod', 'measurementMaterial']
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..
['Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'ODP846.Lawrence.2006', 'MD98_2181.Stott.2007', '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://www.wikidata.org/entity/Q12418   
1  http://data.europeana.eu/item/04802/243FA86189...   
2                          http://example.org/bob#me   
3              http://www.wikidata.org/entity/Q12418   
4                          http://example.org/bob#me   
5                          http://example.org/bob#me   
6                          http://example.org/bob#me   

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

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

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 0x7369b4aea4d0>
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())
['N4dd700e5db7a4db498661f1123072893']
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://www.wikidata.org/entity/Q12418   
1  http://data.europeana.eu/item/04802/243FA86189...   
2                          http://example.org/bob#me   
3              http://www.wikidata.org/entity/Q12418   
4                          http://example.org/bob#me   
5                          http://example.org/bob#me   
6                          http://example.org/bob#me   

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

                                               o  
0  http://dbpedia.org/resource/Leonardo_da_Vinci  
1          http://www.wikidata.org/entity/Q12418  
2          http://www.wikidata.org/entity/Q12418  
3                                      Mona Lisa  
4                                     1990-07-04  
5                    http://example.org/alice#me  
6               http://xmlns.com/foaf/0.1/Person  
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://www.wikidata.org/entity/Q12418   
1  http://data.europeana.eu/item/04802/243FA86189...   
2                          http://example.org/bob#me   
3              http://www.wikidata.org/entity/Q12418   
4                          http://example.org/bob#me   
5                          http://example.org/bob#me   
6                          http://example.org/bob#me   

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

                                               o  
0  http://dbpedia.org/resource/Leonardo_da_Vinci  
1          http://www.wikidata.org/entity/Q12418  
2          http://www.wikidata.org/entity/Q12418  
3                                      Mona Lisa  
4                                     1990-07-04  
5                    http://example.org/alice#me  
6               http://xmlns.com/foaf/0.1/Person  
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://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/creator> <http://dbpedia.org/resource/Leonardo_da_Vinci> _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619> <http://purl.org/dc/terms/subject> <http://www.wikidata.org/entity/Q12418> _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/topic_interest> <http://www.wikidata.org/entity/Q12418> _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/title> "Mona Lisa" _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://example.org/bob#me> <http://schema.org/birthDate> "1990-07-04"^^<http://www.w3.org/2001/XMLSchema#date> _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://example.org/bob#me> <http://xmlns.com/foaf/0.1/knows> <http://example.org/alice#me> _:Nb6c088355fd745ceb454fe8ec6a9f907 .
<http://example.org/bob#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> _:Nb6c088355fd745ceb454fe8ec6a9f907 .


...
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