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:
objectMethods
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:
RDFGraphThe 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. 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: temperature: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: uncertaintyHigh: Archaeological Nunalleq.Ledger.2018: precipitation: Archaeological Nunalleq.Ledger.2018: precipitation: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: precipitation: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: depth: Archaeological Nunalleq.Ledger.2018: age: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: precipitation: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: precipitation: Archaeological Nunalleq.Ledger.2018: uncertaintyLow: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: uncertainty: Archaeological Nunalleq.Ledger.2018: temperature: Archaeological Nunalleq.Ledger.2018: age: 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
Returns a list of all the unique archiveTypes present in the LiPD object
Return the names of the compilation present in the LiPD object
Get all Dataset ids
Get all Dataset Names
get_all_graph_ids()Get all Graph ids
get_all_locations([dsname])Return geographical coordinates for all the datasets.
Get a list of all possible distinct variableNames.
Returns a list of all variables in the graph
get_bibtex([remote, save, path, verbose])Get BibTeX for loaded datasets
Get a list of unique properties attached to a dataset.
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 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 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(update_query[, remote])Execute a SPARQL UPDATE query on the graph
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..
{'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'pub': [{'citeKey': 'tudhope2001variabilityintheelninosou', 'author': [{'name': 'A. W. Tudhope'}], 'issue': 5508.0, 'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle', 'pages': '1511-1517', 'volume': '291', 'dataUrl': ['doi.org'], 'year': 2001, 'publisher': 'American Association for the Advancement of Science (AAAS)', 'doi': '10.1126/science.1057969', 'journal': 'Science'}, {'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'], 'title': 'World Data Center for Paleoclimatology', 'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation', 'institution': 'World Data Center for Paleoclimatology', 'author': [{'name': 'H. Kuhnert'}], 'urldate': 2001.0}, {'author': [{'name': 'Henry C. Wu'}, {'name': 'Nerilie J. Abram'}, {'name': 'Michael N. Evans'}, {'name': 'Jessica E. Tierney'}, {'name': 'Cyril Giry'}, {'name': 'K. Halimeda Kilbourne'}, {'name': 'Kevin J. Anchukaitis'}, {'name': 'Casey P. Saenger'}, {'name': 'Jens Zinke'}], 'volume': '30', 'publisher': 'Wiley-Blackwell', 'year': 2015, 'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives', 'dataUrl': ['doi.org'], 'doi': '10.1002/2014PA002717', 'journal': 'Paleoceanography', 'issue': 3.0, 'citeKey': 'tierney2015tropicalseasurfacetempera', 'pages': '226-252'}], 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd', 'createdBy': 'matlab', 'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993', 'googleMetadataWorksheet': 'oruuxfm', 'datasetId': 'm8yv2VgG97zJmSg3XhqQ', 'inCompilation2_': 'PAGES2k_v2.0.0', 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'inCompilation3_': 'PAGES2k_v2.1.0', 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'inCompilation1_': 'Ocean2k_v1.0.0', 'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2], 'type': 'Point'}, 'properties': {'pages2kRegion': 'Ocean', 'longitude': 145.8167, 'ocean': 'Pacific', 'elevation': -2.2, 'type': 'http://linked.earth/ontology#Location', 'siteName': 'Madang Lagoon, Papua New Guinea', 'latitude': -5.2167}}, 'dataContributor': {'name': 'Wu KLD'}, 'paleoData': [{'measurementTable': [{'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv', 'columns': [{'qCCertification': 'KLD, NJA', 'hasMaxValue': -4.344, 'resolution': {'hasMeanValue': 0.25, 'hasMedianValue': 0.25, 'hasMaxValue': 0.25, 'hasMinValue': 0.25, 'units': 'yr AD'}, 'notes': '; climateInterpretation_seasonality changed - was originally seasonal', 'paleoDataTableName': 'measTable', 'pages2kID': 'Ocn_097', 'inCompilationBeta': [{'compilationVersion': ['2_1_2', '2_1_1'], 'compilationName': 'Pages2kTemperature'}], 'iso2kUI': 'CO01TUNG01A', 'proxyObservationType': 'd18O', 'hasMinValue': -5.515, 'TSid': 'Ocean2kHR_140', 'interpretation': [{'scope': 'climate', 'direction': 'negative', 'variableDetail': 'sea@surface', 'seasonality': 'subannual', 'variable': 'temperature'}], 'number': 1, 'useInGlobalTemperatureAnalysis': True, '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', 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'variableType': 'measured', 'variableName': 'd18O', 'sensorGenus': 'Porites', 'hasMeanValue': -4.9453, 'ocean2kID': 'PacificMadangTudhope2001', 'measurementTableName': 'measurementTable1', 'units': 'permil', 'proxy': 'd18O', 'archiveType': 'Coral'}, {'paleoDataTableName': 'measTable', 'TSid': 'PYTDAS7AM1Y', 'variableName': 'year', 'dataType': 'float', 'inferredVariableType': 'Year', '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', 'hasMaxValue': 1993.042, 'number': 2, 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'resolution': {'hasMaxValue': 0.25, 'hasMinValue': 0.25, 'hasMeanValue': 0.25, 'hasMedianValue': 0.25, 'units': 'yr AD'}, 'hasMinValue': 1880.792, 'hasMedianValue': 1936.917, 'hasMeanValue': 1936.917, 'measurementTableName': 'measurementTable1', 'description': 'Year AD', 'units': 'yr AD', 'archiveType': 'Coral'}], 'googleWorkSheetKey': 'ov9tjw6', 'missingValue': 'NaN', 'tableName': 'Kuhnert'}]}], 'lipdVersion': 1.3, 'minYear': 1880.792, 'maxYear': 1993.042, 'changelog': [{'notes': 'Starting the changelog', 'version': '1.0.0', 'curator': 'nicholas', 'timestamp': '2022-08-23 23:41:56 UTC'}], 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866', '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:
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:
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.5.3/lib/python3.12/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-CoastofPortugal.Abrantes.2011.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-SpannagelCave.Mangini.2005.lpd', "/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Arc-Kongressvatnet.D'Andrea.2012.lpd", '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-FinnishLakelands.Helama.2014.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-LakeSilvaplana.Trachsel.2010.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-Stockholm.Leijonhufvud.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-SpanishPyrenees.Dorado-Linan.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ocn-RedSea.Felis.2000.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ocn-AlboranSea436B.Nieto-Moreno.2013.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-NorthernSpain.Martin-Chivelet.2011.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ant-WAIS-Divide.Severinghaus.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Asi-SourthAndMiddleUrals.Demezhko.2007.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ocn-FeniDrift.Richter.2009.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Eur-NorthernScandinavia.Esper.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ocn-SinaiPeninsula,RedSea.Moustafa.2000.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Pages2k/Ocn-PedradeLume-CapeVerdeIslands.Moses.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Temp12k/ElGygytgynCrater.Schwamborn.2006.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Temp12k/MD03-2601.Kim.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Temp12k/NevadoHuascaran.Thompson.1995.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Temp12k/SouthernCalifornia.Ohlwein.2012.lpd', '/home/docs/checkouts/readthedocs.org/user_builds/pylipd/conda/v1.5.3/lib/python3.12/site-packages/pylipd/data/Temp12k/RC24_08GC.Arbuszewski.2013.lpd'] Loading 22 LiPD files
Loaded..
['NevadoHuascaran.Thompson.1995', 'RC24_08GC.Arbuszewski.2013', 'ElGygytgynCrater.Schwamborn.2006', 'SouthernCalifornia.Ohlwein.2012', 'MD03-2601.Kim.2012']
- 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:
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:
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', 'Ocn-RedSea.Felis.2000', 'Eur-SpanishPyrenees.Dorado-Linan.2012', '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:
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..
['Ocn-AlboranSea436B.Nieto-Moreno.2013', 'Eur-Stockholm.Leijonhufvud.2009', 'Eur-NorthernSpain.Martin-Chivelet.2011', 'Eur-LakeSilvaplana.Trachsel.2010', 'Ocn-RedSea.Felis.2000', 'Ant-WAIS-Divide.Severinghaus.2012', 'Asi-SourthAndMiddleUrals.Demezhko.2007', 'Eur-SpanishPyrenees.Dorado-Linan.2012', 'Eur-NorthernScandinavia.Esper.2012', 'Eur-SpannagelCave.Mangini.2005', 'Ocn-FeniDrift.Richter.2009', 'Eur-CoastofPortugal.Abrantes.2011', 'Eur-FinnishLakelands.Helama.2014']
- 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:
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.. ['RapidArcticWarming', 'Temp12k', 'HoloceneAbruptChange', 'wNAm', 'HoloceneHydroclimate']
- 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.1000 -8.9000 1 Eur-SpannagelCave.Mangini.2005 47.1000 11.6000 2 Arc-Kongressvatnet.D'Andrea.2012 78.0217 13.9311 3 Eur-FinnishLakelands.Helama.2014 62.0000 28.3250 4 Eur-LakeSilvaplana.Trachsel.2010 46.5000 9.8000 5 Eur-Stockholm.Leijonhufvud.2009 59.3200 18.0600 6 Eur-SpanishPyrenees.Dorado-Linan.2012 42.5000 1.0000 7 Ocn-RedSea.Felis.2000 27.8500 34.3200 8 Ocn-AlboranSea436B.Nieto-Moreno.2013 36.2053 -4.3133 9 Eur-NorthernSpain.Martin-Chivelet.2011 42.9000 -3.5000 10 Ant-WAIS-Divide.Severinghaus.2012 -79.4630 -112.1250 11 Asi-SourthAndMiddleUrals.Demezhko.2007 55.0000 59.5000 12 Ocn-FeniDrift.Richter.2009 55.5000 -13.9000 13 Eur-NorthernScandinavia.Esper.2012 68.0000 25.0000 14 Ocn-SinaiPeninsula,RedSea.Moustafa.2000 27.8483 34.3100 15 Ocn-PedradeLume-CapeVerdeIslands.Moses.2006 16.7600 -22.8883 geo_meanElev 0 -80.0 1 2347.0 2 94.0 3 130.0 4 1791.0 5 10.0 6 1200.0 7 -6.0 8 -1108.0 9 1250.0 10 1766.0 11 1900.0 12 -2543.0 13 300.0 14 -3.0 15 -5.0
- get_all_variable_names()[source]
Get a list of all possible distinct variableNames. Useful for filtering and querying.
- 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', 'd18O', 'Uk37', 'trsgi', 'uncertainty_temperature', 'depth_top', 'Mg_Ca', '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.... PYTE5EC1JBW 1 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTXJB98403 2 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTTD7XCQGS 3 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTUHE3XLGQ 4 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTLEHYPAYV 5 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTKRFVW61B 6 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT9CFQ4GK0 7 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTCHXB40SL 8 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTGOFY4KZD 9 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTS96EE0CB 10 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTPWX0LH3I 11 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT95DVDUU3 12 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTDW6AIJPW 13 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTM9N6HCQM 14 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT7DLYN7X4 15 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTTUPVG4K3 16 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT4Y96QMUU 17 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTYDOYFVYD 18 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT2ZB6MLZ9 19 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT8BDSRW3H 20 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTI487BQDZ 21 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT68HYMYHH 22 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTJZ4GLRYP 23 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT3ZMI0BXW 24 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTJ3PSH0LT 25 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT19MC8WE2 26 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTDIEKUM44 27 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTPQ0FJO1S 28 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYT10H23U2E 29 http://linked.earth/lipd/ODP846.Lawrence.2006.... PYTGO6NV72Y variableName 0 event 1 age 2 age 3 age 4 d18o 5 depth 6 depth 7 depth 8 depth 9 depth 10 depth 11 temp prahl 12 sst 13 ukprime37 14 median 15 u. peregrina d13c 16 d180 17 u. peregrina d18o 18 interval 19 section 20 lower95 21 depth cr 22 sample label 23 c. wuellerstorfi d18o 24 site/hole 25 c. wuellerstorfi d13c 26 upper95 27 depth comp 28 c37 total 29 temp muller
- 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', ' @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', '@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{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 Tropical sea surface temperatures for the past... 1 Variability in the El Nino-Southern Oscillatio... 2 World Data Center for Paleoclimatology 3 None 4 Southern Hemisphere and deep-sea warming led d... authors doi \ 0 K. Halimeda Kilbourne and Kevin J. Anchukaitis... 10.1002/2014PA002717 1 A. W. Tudhope 10.1126/science.1057969 2 H. Kuhnert None 3 10.1029/2006PA001379 4 A. Timmermann and L. Stott and R. Thunell 10.1126/science.1143791 pubyear year journal volume issue pages \ 0 None 2015.0 Paleoceanography 30 3.0 226-252 1 None 2001.0 Science 291 5508.0 1511-1517 2 None NaN None None NaN None 3 None NaN None None NaN None 4 None 2007.0 Science 318 5849.0 435 438 type publisher report \ 0 journal-article Wiley-Blackwell None 1 journal-article American Association for the Advancement of Sc... None 2 dataCitation None None 3 None None None 4 None None None citeKey edition \ 0 tierney2015tropicalseasurfacetempera None 1 tudhope2001variabilityintheelninosou None 2 kuhnert2001httpswwwncdcnoaagovpaleostudy1866Da... None 3 None None 4 WMGAVB7S None institution url \ 0 None None 1 None None 2 World Data Center for Paleoclimatology None 3 None None 4 None None url2 0 None 1 None 2 https://www.ncdc.noaa.gov/paleo/study/1866 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 available 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.. ['googleDataURL', 'createdBy', 'hasSpreadsheetLink', 'hasOriginalDataUrl', 'hasArchiveType', 'hasDatasetId', 'type', 'minYear', 'hasChangeLog', 'hasUrl', 'googleMetadataWorksheet', 'hasPublication', 'hasLocation', 'lipdVersion', 'hasName', 'hasPaleoData', 'maxYear', 'inCompilation1_', 'inCompilation2_', 'inCompilation3_', 'hasContributor', 'studyName', 'hasInvestigator', 'hasFunding', 'hasNotes']
- 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 0x73d1f54b4920>, <pylipd.classes.dataset.Dataset at 0x73d1f58d6360>, <pylipd.classes.dataset.Dataset at 0x73d1f54b5940>, <pylipd.classes.dataset.Dataset at 0x73d1eee665a0>, <pylipd.classes.dataset.Dataset at 0x73d1f56ff320>, <pylipd.classes.dataset.Dataset at 0x73d1f5f14890>, <pylipd.classes.dataset.Dataset at 0x73d1f62ee5d0>, <pylipd.classes.dataset.Dataset at 0x73d1f5e21d60>, <pylipd.classes.dataset.Dataset at 0x73d1f4231580>, <pylipd.classes.dataset.Dataset at 0x73d1ef04a1b0>, <pylipd.classes.dataset.Dataset at 0x73d1eb97d850>, <pylipd.classes.dataset.Dataset at 0x73d22e4ef0b0>, <pylipd.classes.dataset.Dataset at 0x73d1eeb3f140>, <pylipd.classes.dataset.Dataset at 0x73d1f7b65e80>, <pylipd.classes.dataset.Dataset at 0x73d1ef2616a0>, <pylipd.classes.dataset.Dataset at 0x73d1f651c5c0>]
- 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..
{'dataSetName': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001', 'pub': [{'author': [{'name': 'A. W. Tudhope'}], 'year': 2001, 'publisher': 'American Association for the Advancement of Science (AAAS)', 'dataUrl': ['doi.org'], 'doi': '10.1126/science.1057969', 'issue': 5508.0, 'title': 'Variability in the El Nino-Southern Oscillation Through a Glacial-Interglacial Cycle', 'pages': '1511-1517', 'journal': 'Science', 'volume': '291', 'citeKey': 'tudhope2001variabilityintheelninosou'}, {'author': [{'name': 'Casey P. Saenger'}, {'name': 'Nerilie J. Abram'}, {'name': 'Jens Zinke'}, {'name': 'Henry C. Wu'}, {'name': 'Jessica E. Tierney'}, {'name': 'Michael N. Evans'}, {'name': 'Cyril Giry'}, {'name': 'K. Halimeda Kilbourne'}, {'name': 'Kevin J. Anchukaitis'}], 'dataUrl': ['doi.org'], 'doi': '10.1002/2014PA002717', 'journal': 'Paleoceanography', 'citeKey': 'tierney2015tropicalseasurfacetempera', 'pages': '226-252', 'publisher': 'Wiley-Blackwell', 'issue': 3.0, 'year': 2015, 'volume': '30', 'title': 'Tropical sea surface temperatures for the past four centuries reconstructed from coral archives'}, {'title': 'World Data Center for Paleoclimatology', 'citeKey': 'kuhnert2001httpswwwncdcnoaagovpaleostudy1866DataCitation', 'institution': 'World Data Center for Paleoclimatology', 'author': [{'name': 'H. Kuhnert'}], 'url': ['https://www.ncdc.noaa.gov/paleo/study/1866'], 'urldate': 2001.0}], 'hasUrl': 'https://data.mint.isi.edu/files/lipd/Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.lpd', 'createdBy': 'matlab', 'studyName': 'Madang, Papua New Guinea oxygen isotope record 1880-1993', 'googleMetadataWorksheet': 'oruuxfm', 'datasetId': 'm8yv2VgG97zJmSg3XhqQ', 'inCompilation2_': 'PAGES2k_v2.0.0', 'googleSpreadSheetKey': '1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'inCompilation3_': 'PAGES2k_v2.1.0', 'googleDataURL': 'https://docs.google.com/spreadsheets/d/1wf30P-s54OTBdLw4dyeaIN53VDoN0u_hOqIwvAeLxtc', 'inCompilation1_': 'Ocean2k_v1.0.0', 'geo': {'geometry': {'coordinates': [145.8167, -5.2167, -2.2], 'type': 'Point'}, 'properties': {'pages2kRegion': 'Ocean', 'longitude': 145.8167, 'ocean': 'Pacific', 'elevation': -2.2, 'type': 'http://linked.earth/ontology#Location', 'siteName': 'Madang Lagoon, Papua New Guinea', 'latitude': -5.2167}}, 'dataContributor': {'name': 'Wu KLD'}, 'paleoData': [{'measurementTable': [{'filename': 'Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001.paleo1measurement1.csv', 'columns': [{'qCCertification': 'KLD, NJA', 'hasMaxValue': -4.344, 'resolution': {'hasMeanValue': 0.25, 'hasMedianValue': 0.25, 'hasMaxValue': 0.25, 'hasMinValue': 0.25, 'units': 'yr AD'}, 'notes': '; climateInterpretation_seasonality changed - was originally seasonal', 'paleoDataTableName': 'measTable', 'pages2kID': 'Ocn_097', 'iso2kUI': 'CO01TUNG01A', 'proxyObservationType': 'd18O', 'hasMinValue': -5.515, 'TSid': 'Ocean2kHR_140', 'interpretation': [{'scope': 'climate', 'direction': 'negative', 'variableDetail': 'sea@surface', 'seasonality': 'subannual', 'variable': 'temperature'}], 'number': 1, 'useInGlobalTemperatureAnalysis': True, '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', 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'variableType': 'measured', 'variableName': 'd18O', 'sensorGenus': 'Porites', 'hasMeanValue': -4.9453, 'inCompilationBeta': [{'compilationName': 'Pages2kTemperature', 'compilationVersion': ['2_1_1', '2_1_2']}], 'ocean2kID': 'PacificMadangTudhope2001', 'measurementTableName': 'measurementTable1', '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]}, {'paleoDataTableName': 'measTable', 'TSid': 'PYTDAS7AM1Y', 'variableName': 'year', 'dataType': 'float', 'inferredVariableType': 'Year', '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', 'hasMaxValue': 1993.042, 'number': 2, 'measurementTableMD5': '793853407e414221c486d2e63b32dd87', 'resolution': {'hasMaxValue': 0.25, 'hasMinValue': 0.25, 'hasMeanValue': 0.25, 'hasMedianValue': 0.25, 'units': 'yr AD'}, 'hasMinValue': 1880.792, 'hasMedianValue': 1936.917, 'hasMeanValue': 1936.917, 'measurementTableName': 'measurementTable1', 'description': 'Year AD', '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]}], 'googleWorkSheetKey': 'ov9tjw6', 'missingValue': 'NaN', 'tableName': 'Kuhnert'}]}], 'lipdVersion': 1.3, 'minYear': 1880.792, 'maxYear': 1993.042, 'changelog': [{'notes': 'Starting the changelog', 'version': '1.0.0', 'curator': 'nicholas', 'timestamp': '2022-08-23 23:41:56 UTC'}], 'originalDataURL': 'https://www.ncdc.noaa.gov/paleo/study/1866', '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.5.3/lib/python3.12/site-packages/pylipd/data/ODP846.Lawrence.2006.lpd'] Loading 1 LiPD files
Loaded.. ['type', 'hasCode', 'hasEnsembleTable', 'hasSummaryTable']
- get_timeseries(dsnames, to_dataframe=False, mode='paleo', time='age')[source]
Get Legacy LiPD like Time Series Object (tso)
This function is meant to provide legacy support to the older version of the LiPD utilities, which returns a dictionary of timeseries objects. The function also supports returning to a pandas.DataFrame, essentially flattening all the information. This is useful to explore all possible properties but can be slow for large number of datasets or if you only require some standard information. In this case, use get_timeseries_essentials.
- 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
mode ('paleo' or 'chron') – Whether to return information from the PaleoData or ChronData objects
time ('age' or 'year') – Whether the time is expressed as year or age
- Returns:
ts (dict) – A dictionary containing Time Series Object
df (Pandas.DataFrame) – If to_dataframe is set to True, returns a queryable Pandas DataFrame
Examples
To only return a list of timeseries objects
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 ...
To return a dataframe in addition to the list of timeseries objects
from pylipd.lipd import LiPD lipd_remote = LiPD() lipd_remote.set_endpoint("https://linkedearth.graphdb.mint.isi.edu/repositories/LiPDVerse-dynamic") ts_list, df = lipd_remote.get_timeseries(["Ocn-MadangLagoonPapuaNewGuinea.Kuhnert.2001", "MD98_2181.Stott.2007", "Ant-WAIS-Divide.Severinghaus.2012"], to_dataframe = True) df.head()
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 return 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
Examples
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.5.3/lib/python3.12/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 24 ODP846.Lawrence.2006 Marine sediment -3.1 -90.8 geo_meanElev paleoData_variableName \ 0 -3296.0 u. peregrina d13c 1 -3296.0 u. peregrina d13c 2 -3296.0 u. peregrina d13c 3 -3296.0 temp prahl 4 -3296.0 c37 total 5 -3296.0 temp muller 6 -3296.0 event 7 -3296.0 event 8 -3296.0 event 9 -3296.0 site/hole 10 -3296.0 u. peregrina d18o 11 -3296.0 u. peregrina d18o 12 -3296.0 u. peregrina d18o 13 -3296.0 c. wuellerstorfi d13c 14 -3296.0 c. wuellerstorfi d13c 15 -3296.0 c. wuellerstorfi d13c 16 -3296.0 c. wuellerstorfi d18o 17 -3296.0 c. wuellerstorfi d18o 18 -3296.0 c. wuellerstorfi d18o 19 -3296.0 interval 20 -3296.0 section 21 -3296.0 sample label 22 -3296.0 sample label 23 -3296.0 sample label 24 -3296.0 ukprime37 paleoData_values paleoData_units \ 0 [nan, nan, nan, nan, nan, nan, nan, nan, nan, ... per mil PDB 1 [nan, nan, nan, nan, nan, nan, nan, nan, nan, ... per mil PDB 2 [nan, nan, nan, nan, nan, nan, nan, nan, nan, ... per mil PDB 3 [23.0, 23.1, 23.2, 22.0, 21.7, 21.4, 21.7, 21.... deg C 4 [2.37, 2.1, 1.87, 2.74, 3.75, 7.62, 7.86, 7.73... nmol/kg 5 [23.545, 23.648, 23.752, 22.515, 22.206, 21.89... deg C 6 [138-846B, 138-846B, 138-846B, 138-846B, 138-8... unitless 7 [138-846B, 138-846B, 138-846B, 138-846B, 138-8... unitless 8 [138-846B, 138-846B, 138-846B, 138-846B, 138-8... unitless 9 [846B, 846B, 846B, 846B, 846B, 846B, 846B, 846... unitless 10 [0.14, 0.01, -0.1, -0.06, -0.17, -0.21, -0.41,... per mil PDB 11 [0.14, 0.01, -0.1, -0.06, -0.17, -0.21, -0.41,... per mil PDB 12 [0.14, 0.01, -0.1, -0.06, -0.17, -0.21, -0.41,... per mil PDB 13 [3.38, 3.46, 3.65, 3.88, 4.14, 4.47, 4.99, 4.9... per mil PDB 14 [3.38, 3.46, 3.65, 3.88, 4.14, 4.47, 4.99, 4.9... per mil PDB 15 [3.38, 3.46, 3.65, 3.88, 4.14, 4.47, 4.99, 4.9... per mil PDB 16 [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... per mil PDB 17 [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... per mil PDB 18 [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... per mil PDB 19 [15-16, 25-26, 35-36, 45-46, 55-56, 65-66, 75-... cm 20 [1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-1, 1H-... unitless 21 [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ... unitless 22 [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ... unitless 23 [138-846B-1H-1, 138-846B-1H-1, 138-846B-1H-1, ... unitless 24 [0.821, 0.824, 0.828, 0.787, 0.777, 0.767, 0.7... unitless paleoData_proxy paleoData_proxyGeneral time_variableName \ 0 None None None 1 None None None 2 None None None 3 None None age 4 None None age 5 None None age 6 None None None 7 None None None 8 None None None 9 None None age 10 None None None 11 None None None 12 None None None 13 None None None 14 None None None 15 None None None 16 None None None 17 None None None 18 None None None 19 None None age 20 None None age 21 None None None 22 None None None 23 None None None 24 None None age time_values time_units \ 0 None None 1 None None 2 None None 3 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 4 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 5 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 6 None None 7 None None 8 None None 9 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 10 None None 11 None None 12 None None 13 None None 14 None None 15 None None 16 None None 17 None None 18 None None 19 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 20 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP 21 None None 22 None None 23 None None 24 [5.228, 8.947, 11.966, 14.427, 16.502, 18.41, ... kyr BP depth_variableName depth_values \ 0 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 1 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 2 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 3 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 4 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 5 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 6 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 7 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 8 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 9 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 10 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 11 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 12 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 13 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 14 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 15 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 16 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 17 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 18 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 19 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 20 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... 21 depth cr [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 22 depth [0.12, 0.23, 0.33, 0.33, 0.43, 0.53, 0.63, 0.7... 23 depth comp [12.0, 23.0, 33.0, 33.0, 43.0, 53.0, 63.0, 73.... 24 depth [0.16, 0.26, 0.36, 0.46, 0.56, 0.66, 0.76, 0.8... depth_units 0 rmcd 1 m 2 mcd 3 m 4 m 5 m 6 rmcd 7 m 8 mcd 9 m 10 rmcd 11 m 12 mcd 13 rmcd 14 m 15 mcd 16 rmcd 17 m 18 mcd 19 m 20 m 21 rmcd 22 m 23 mcd 24 mTo 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.5.3/lib/python3.12/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 geo_meanElev chronData_variableName \ 0 -3296.0 d18o 1 -3296.0 depth 2 -3296.0 age chronData_values chronData_units \ 0 [3.38, 3.46, 3.765, 4.14, 4.47, 4.99, 4.99, 4.... permil 1 [0.12, 0.23, 0.33, 0.43, 0.53, 0.63, 0.73, 0.8... m 2 [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... time_units depth_variableName \ 0 ky BP depth 1 ky BP depth 2 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
- 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.. ['hasInterpretation', 'calibratedVia', 'hasProxy', 'inferredVariableType', 'hasMeanValue', 'hasStandardVariable', 'measurementTableMD5', 'foundInDataset', 'hasMinValue', 'hasValues', 'paleoDataTableName', 'hasVariableId', 'wDSPaleoUrl', 'foundInTable', 'precededBy', 'hasNotes', 'hasName', 'hasMedianValue', 'useInGlobalTemperatureAnalysis', 'hasColumnNumber', 'partOfCompilation', 'hasUnits', 'qCCertification', 'type', 'hasDescription', 'hasResolution', 'measurementTableName', 'hasMaxValue', 'pages2kID', 'hasArchiveType', 'hasType', 'dataType', 'proxyObservationType', 'detail', 'sensorSpecies', 'iso2kUI', 'ocean2kID', 'sensorGenus', 'measurementMaterial', 'measurementMethod', 'hasUncertainty']
- 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:
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..
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:
objectThe 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)
pylipd.utils.multi_processing module
- pylipd.utils.multi_processing.multi_convert_to_rdf(filemap, parallel=True, standardize=True, add_labels=True)[source]
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:
objectThe 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
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:
objectThe 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://www.wikidata.org/entity/Q12418 2 http://data.europeana.eu/item/04802/243FA86189... 3 http://example.org/bob#me 4 http://example.org/bob#me 5 http://example.org/bob#me 6 http://www.wikidata.org/entity/Q12418 p \ 0 http://schema.org/birthDate 1 http://purl.org/dc/terms/creator 2 http://purl.org/dc/terms/subject 3 http://xmlns.com/foaf/0.1/knows 4 http://xmlns.com/foaf/0.1/topic_interest 5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type 6 http://purl.org/dc/terms/title o 0 1990-07-04 1 http://dbpedia.org/resource/Leonardo_da_Vinci 2 http://www.wikidata.org/entity/Q12418 3 http://example.org/alice#me 4 http://www.wikidata.org/entity/Q12418 5 http://xmlns.com/foaf/0.1/Person 6 Mona LisaMethods
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
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
Returns RDF quad serialization of the current combined Graph .
set_endpoint(endpoint)Sets a SparQL endpoint for a remote Knowledge Base (example: GraphDB)
update(update_query[, remote])Execute a SPARQL UPDATE query on the graph
- 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 0x73d1edb87c20>
- 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())
['N17e506e6265242648ed50a92722c1e12']
- 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://www.wikidata.org/entity/Q12418 2 http://data.europeana.eu/item/04802/243FA86189... 3 http://example.org/bob#me 4 http://example.org/bob#me 5 http://example.org/bob#me 6 http://www.wikidata.org/entity/Q12418 p \ 0 http://schema.org/birthDate 1 http://purl.org/dc/terms/creator 2 http://purl.org/dc/terms/subject 3 http://xmlns.com/foaf/0.1/knows 4 http://xmlns.com/foaf/0.1/topic_interest 5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type 6 http://purl.org/dc/terms/title o 0 1990-07-04 1 http://dbpedia.org/resource/Leonardo_da_Vinci 2 http://www.wikidata.org/entity/Q12418 3 http://example.org/alice#me 4 http://www.wikidata.org/entity/Q12418 5 http://xmlns.com/foaf/0.1/Person 6 Mona Lisa
- 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:
- 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:
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://www.wikidata.org/entity/Q12418 2 http://data.europeana.eu/item/04802/243FA86189... 3 http://example.org/bob#me 4 http://example.org/bob#me 5 http://example.org/bob#me 6 http://www.wikidata.org/entity/Q12418 p \ 0 http://schema.org/birthDate 1 http://purl.org/dc/terms/creator 2 http://purl.org/dc/terms/subject 3 http://xmlns.com/foaf/0.1/knows 4 http://xmlns.com/foaf/0.1/topic_interest 5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type 6 http://purl.org/dc/terms/title o 0 1990-07-04 1 http://dbpedia.org/resource/Leonardo_da_Vinci 2 http://www.wikidata.org/entity/Q12418 3 http://example.org/alice#me 4 http://www.wikidata.org/entity/Q12418 5 http://xmlns.com/foaf/0.1/Person 6 Mona Lisa
- 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> _:N041def56fb9144a48c955f37c31947c1 . <http://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/creator> <http://dbpedia.org/resource/Leonardo_da_Vinci> _:N041def56fb9144a48c955f37c31947c1 . <http://data.europeana.eu/item/04802/243FA8618938F4117025F17A8B813C5F9AA4D619> <http://purl.org/dc/terms/subject> <http://www.wikidata.org/entity/Q12418> _:N041def56fb9144a48c955f37c31947c1 . <http://example.org/bob#me> <http://xmlns.com/foaf/0.1/knows> <http://example.org/alice#me> _:N041def56fb9144a48c955f37c31947c1 . <http://example.org/bob#me> <http://xmlns.com/foaf/0.1/topic_interest> <http://www.wikidata.org/entity/Q12418> _:N041def56fb9144a48c955f37c31947c1 . <http://example.org/bob#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> _:N041def56fb9144a48c955f37c31947c1 . <http://www.wikidata.org/entity/Q12418> <http://purl.org/dc/terms/title> "Mona Lisa" _:N041def56fb9144a48c955f37c31947c1 . ...
- 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")
- update(update_query, remote=False)[source]
Execute a SPARQL UPDATE query on the graph
- Parameters:
update_query (str) – SPARQL UPDATE query (INSERT, DELETE, etc.)
remote (bool) – (Optional) If set to True, the update will be made to the remote endpoint (if set)
- Return type:
None
Examples
from pylipd.utils.rdf_graph import RDFGraph rdf = RDFGraph() rdf.load(["../examples/rdf/graph.ttl"]) update_query = """PREFIX le: <http://linked.earth/ontology#> DELETE { ?var le:hasMinValue ?oldMin } INSERT { ?var le:hasMinValue "10.5"^^xsd:double } WHERE { ?var le:hasMinValue ?oldMin }""" rdf.update(update_query)
pylipd.utils.utils module
- 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.