From ce9790e2c4a4d9de114321549b2fc8df500b7be3 Mon Sep 17 00:00:00 2001 From: khider <11758571+khider@users.noreply.github.com> Date: Tue, 22 Apr 2025 09:06:07 -0700 Subject: [PATCH] fix graph query --- notebooks/L2_a_custom_queries.ipynb | 182 ++++++++++++++-------------- notebooks/L2_b_using_graphdb.ipynb | 84 +++++++------ 2 files changed, 139 insertions(+), 127 deletions(-) diff --git a/notebooks/L2_a_custom_queries.ipynb b/notebooks/L2_a_custom_queries.ipynb index 182e2d1..5dff6b2 100644 --- a/notebooks/L2_a_custom_queries.ipynb +++ b/notebooks/L2_a_custom_queries.ipynb @@ -83,7 +83,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|███████████████████████████████████████████| 16/16 [00:00<00:00, 64.79it/s]" + "100%|███████████████████████████████████████████| 16/16 [00:00<00:00, 73.24it/s]" ] }, { @@ -133,7 +133,7 @@ { "data": { "text/plain": [ - "{'graph': )>}" + "{'graph': )>}" ] }, "execution_count": 3, @@ -463,7 +463,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 1.47it/s]" + "100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 1.93it/s]" ] }, { @@ -750,91 +750,91 @@ " \n", " \n", " 0\n", - " http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", + " http://linked.earth/ontology#minYear\n", " \n", " \n", " 1\n", - " http://linked.earth/ontology#inCompilation1_\n", + " http://linked.earth/ontology#lipdVersion\n", " \n", " \n", " 2\n", - " http://linked.earth/ontology#maxYear\n", + " http://linked.earth/ontology#hasName\n", " \n", " \n", " 3\n", - " http://linked.earth/ontology#googleDataURL\n", + " http://linked.earth/ontology#hasPublication\n", " \n", " \n", " 4\n", - " http://linked.earth/ontology#hasPublication\n", + " http://linked.earth/ontology#hasContributor\n", " \n", " \n", " 5\n", - " http://linked.earth/ontology#hasSpreadsheetLink\n", + " http://linked.earth/ontology#hasArchiveType\n", " \n", " \n", " 6\n", - " http://linked.earth/ontology#inCompilation2_\n", + " http://linked.earth/ontology#studyName\n", " \n", " \n", " 7\n", - " http://linked.earth/ontology#hasDatasetId\n", + " http://linked.earth/ontology#inCompilation2_\n", " \n", " \n", " 8\n", - " http://linked.earth/ontology#minYear\n", + " http://linked.earth/ontology#hasUrl\n", " \n", " \n", " 9\n", - " http://linked.earth/ontology#hasOriginalDataUrl\n", + " http://linked.earth/ontology#inCompilation1_\n", " \n", " \n", " 10\n", - " http://linked.earth/ontology#hasUrl\n", + " http://linked.earth/ontology#maxYear\n", " \n", " \n", " 11\n", - " http://linked.earth/ontology#studyName\n", + " http://linked.earth/ontology#hasLocation\n", " \n", " \n", " 12\n", - " http://linked.earth/ontology#googleMetadataWor...\n", + " http://linked.earth/ontology#hasPaleoData\n", " \n", " \n", " 13\n", - " http://linked.earth/ontology#createdBy\n", + " http://linked.earth/ontology#hasOriginalDataUrl\n", " \n", " \n", " 14\n", - " http://linked.earth/ontology#lipdVersion\n", + " http://linked.earth/ontology#googleMetadataWor...\n", " \n", " \n", " 15\n", - " http://linked.earth/ontology#inCompilation3_\n", + " http://linked.earth/ontology#hasSpreadsheetLink\n", " \n", " \n", " 16\n", - " http://linked.earth/ontology#hasLocation\n", + " http://linked.earth/ontology#inCompilation3_\n", " \n", " \n", " 17\n", - " http://linked.earth/ontology#hasContributor\n", + " http://linked.earth/ontology#hasChangeLog\n", " \n", " \n", " 18\n", - " http://linked.earth/ontology#hasArchiveType\n", + " http://linked.earth/ontology#hasDatasetId\n", " \n", " \n", " 19\n", - " http://linked.earth/ontology#hasChangeLog\n", + " http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", " \n", " \n", " 20\n", - " http://linked.earth/ontology#hasPaleoData\n", + " http://linked.earth/ontology#createdBy\n", " \n", " \n", " 21\n", - " http://linked.earth/ontology#hasName\n", + " http://linked.earth/ontology#googleDataURL\n", " \n", " \n", " 22\n", @@ -842,11 +842,11 @@ " \n", " \n", " 23\n", - " http://linked.earth/ontology#hasInvestigator\n", + " http://linked.earth/ontology#lipdComplete\n", " \n", " \n", " 24\n", - " http://linked.earth/ontology#lipdComplete\n", + " http://linked.earth/ontology#hasInvestigator\n", " \n", " \n", "\n", @@ -854,31 +854,31 @@ ], "text/plain": [ " p\n", - "0 http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", - "1 http://linked.earth/ontology#inCompilation1_\n", - "2 http://linked.earth/ontology#maxYear\n", - "3 http://linked.earth/ontology#googleDataURL\n", - "4 http://linked.earth/ontology#hasPublication\n", - "5 http://linked.earth/ontology#hasSpreadsheetLink\n", - "6 http://linked.earth/ontology#inCompilation2_\n", - "7 http://linked.earth/ontology#hasDatasetId\n", - "8 http://linked.earth/ontology#minYear\n", - "9 http://linked.earth/ontology#hasOriginalDataUrl\n", - "10 http://linked.earth/ontology#hasUrl\n", - "11 http://linked.earth/ontology#studyName\n", - "12 http://linked.earth/ontology#googleMetadataWor...\n", - "13 http://linked.earth/ontology#createdBy\n", - "14 http://linked.earth/ontology#lipdVersion\n", - "15 http://linked.earth/ontology#inCompilation3_\n", - "16 http://linked.earth/ontology#hasLocation\n", - "17 http://linked.earth/ontology#hasContributor\n", - "18 http://linked.earth/ontology#hasArchiveType\n", - "19 http://linked.earth/ontology#hasChangeLog\n", - "20 http://linked.earth/ontology#hasPaleoData\n", - "21 http://linked.earth/ontology#hasName\n", + "0 http://linked.earth/ontology#minYear\n", + "1 http://linked.earth/ontology#lipdVersion\n", + "2 http://linked.earth/ontology#hasName\n", + "3 http://linked.earth/ontology#hasPublication\n", + "4 http://linked.earth/ontology#hasContributor\n", + "5 http://linked.earth/ontology#hasArchiveType\n", + "6 http://linked.earth/ontology#studyName\n", + "7 http://linked.earth/ontology#inCompilation2_\n", + "8 http://linked.earth/ontology#hasUrl\n", + "9 http://linked.earth/ontology#inCompilation1_\n", + "10 http://linked.earth/ontology#maxYear\n", + "11 http://linked.earth/ontology#hasLocation\n", + "12 http://linked.earth/ontology#hasPaleoData\n", + "13 http://linked.earth/ontology#hasOriginalDataUrl\n", + "14 http://linked.earth/ontology#googleMetadataWor...\n", + "15 http://linked.earth/ontology#hasSpreadsheetLink\n", + "16 http://linked.earth/ontology#inCompilation3_\n", + "17 http://linked.earth/ontology#hasChangeLog\n", + "18 http://linked.earth/ontology#hasDatasetId\n", + "19 http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", + "20 http://linked.earth/ontology#createdBy\n", + "21 http://linked.earth/ontology#googleDataURL\n", "22 http://linked.earth/ontology#hasChronData\n", - "23 http://linked.earth/ontology#hasInvestigator\n", - "24 http://linked.earth/ontology#lipdComplete" + "23 http://linked.earth/ontology#lipdComplete\n", + "24 http://linked.earth/ontology#hasInvestigator" ] }, "execution_count": 15, @@ -955,19 +955,19 @@ " \n", " \n", " 0\n", - " http://linked.earth/ontology#coordinates\n", + " http://linked.earth/ontology#hasElevation\n", " \n", " \n", " 1\n", - " http://www.w3.org/2003/01/geo/wgs84_pos#long\n", + " http://www.w3.org/2003/01/geo/wgs84_pos#lat\n", " \n", " \n", " 2\n", - " http://www.w3.org/2003/01/geo/wgs84_pos#alt\n", + " http://linked.earth/ontology#hasLongitude\n", " \n", " \n", " 3\n", - " http://linked.earth/ontology#hasElevation\n", + " http://linked.earth/ontology#hasSiteName\n", " \n", " \n", " 4\n", @@ -975,27 +975,27 @@ " \n", " \n", " 5\n", - " http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", + " http://linked.earth/ontology#hasLatitude\n", " \n", " \n", " 6\n", - " http://linked.earth/ontology#coordinatesFor\n", + " http://linked.earth/ontology#coordinates\n", " \n", " \n", " 7\n", - " http://www.w3.org/2003/01/geo/wgs84_pos#lat\n", + " http://www.w3.org/2003/01/geo/wgs84_pos#long\n", " \n", " \n", " 8\n", - " http://linked.earth/ontology#hasLongitude\n", + " http://linked.earth/ontology#coordinatesFor\n", " \n", " \n", " 9\n", - " http://linked.earth/ontology#hasLatitude\n", + " http://www.w3.org/2003/01/geo/wgs84_pos#alt\n", " \n", " \n", " 10\n", - " http://linked.earth/ontology#hasSiteName\n", + " http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", " \n", " \n", " 11\n", @@ -1011,17 +1011,17 @@ ], "text/plain": [ " p\n", - "0 http://linked.earth/ontology#coordinates\n", - "1 http://www.w3.org/2003/01/geo/wgs84_pos#long\n", - "2 http://www.w3.org/2003/01/geo/wgs84_pos#alt\n", - "3 http://linked.earth/ontology#hasElevation\n", + "0 http://linked.earth/ontology#hasElevation\n", + "1 http://www.w3.org/2003/01/geo/wgs84_pos#lat\n", + "2 http://linked.earth/ontology#hasLongitude\n", + "3 http://linked.earth/ontology#hasSiteName\n", "4 http://linked.earth/ontology#pages2kRegion\n", - "5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", - "6 http://linked.earth/ontology#coordinatesFor\n", - "7 http://www.w3.org/2003/01/geo/wgs84_pos#lat\n", - "8 http://linked.earth/ontology#hasLongitude\n", - "9 http://linked.earth/ontology#hasLatitude\n", - "10 http://linked.earth/ontology#hasSiteName\n", + "5 http://linked.earth/ontology#hasLatitude\n", + "6 http://linked.earth/ontology#coordinates\n", + "7 http://www.w3.org/2003/01/geo/wgs84_pos#long\n", + "8 http://linked.earth/ontology#coordinatesFor\n", + "9 http://www.w3.org/2003/01/geo/wgs84_pos#alt\n", + "10 http://www.w3.org/1999/02/22-rdf-syntax-ns#type\n", "11 http://linked.earth/ontology#region\n", "12 http://linked.earth/ontology#hasOcean" ] @@ -1452,15 +1452,15 @@ " \n", " \n", " 0\n", - " uncertainty_temperature\n", + " temperature\n", " \n", " \n", " 1\n", - " temperature\n", + " year\n", " \n", " \n", " 2\n", - " year\n", + " uncertainty_temperature\n", " \n", " \n", " 3\n", @@ -1472,15 +1472,15 @@ " \n", " \n", " 5\n", - " depth_top\n", + " notes\n", " \n", " \n", " 6\n", - " notes\n", + " depth_bottom\n", " \n", " \n", " 7\n", - " depth_bottom\n", + " depth_top\n", " \n", " \n", " 8\n", @@ -1500,14 +1500,14 @@ ], "text/plain": [ " varname\n", - "0 uncertainty_temperature\n", - "1 temperature\n", - "2 year\n", + "0 temperature\n", + "1 year\n", + "2 uncertainty_temperature\n", "3 d18O\n", "4 Mg_Ca\n", - "5 depth_top\n", - "6 notes\n", - "7 depth_bottom\n", + "5 notes\n", + "6 depth_bottom\n", + "7 depth_top\n", "8 Uk37\n", "9 trsgi\n", "10 MXD" @@ -1755,12 +1755,12 @@ " \n", " 0\n", " Ant-WAIS-Divide.Severinghaus.2012\n", - " uncertainty_temperature\n", + " temperature\n", " \n", " \n", " 1\n", " Ant-WAIS-Divide.Severinghaus.2012\n", - " temperature\n", + " uncertainty_temperature\n", " \n", " \n", " 2\n", @@ -1813,8 +1813,8 @@ ], "text/plain": [ " dsname varname\n", - "0 Ant-WAIS-Divide.Severinghaus.2012 uncertainty_temperature\n", - "1 Ant-WAIS-Divide.Severinghaus.2012 temperature\n", + "0 Ant-WAIS-Divide.Severinghaus.2012 temperature\n", + "1 Ant-WAIS-Divide.Severinghaus.2012 uncertainty_temperature\n", "2 Asi-SourthAndMiddleUrals.Demezhko.2007 temperature\n", "3 Ocn-AlboranSea436B.Nieto-Moreno.2013 temperature\n", "4 Ocn-FeniDrift.Richter.2009 temperature\n", @@ -1880,12 +1880,12 @@ " \n", " 0\n", " Ant-WAIS-Divide.Severinghaus.2012\n", - " uncertainty_temperature\n", + " temperature\n", " \n", " \n", " 1\n", " Ant-WAIS-Divide.Severinghaus.2012\n", - " temperature\n", + " uncertainty_temperature\n", " \n", " \n", " 2\n", @@ -1938,8 +1938,8 @@ ], "text/plain": [ " dsname varname\n", - "0 Ant-WAIS-Divide.Severinghaus.2012 uncertainty_temperature\n", - "1 Ant-WAIS-Divide.Severinghaus.2012 temperature\n", + "0 Ant-WAIS-Divide.Severinghaus.2012 temperature\n", + "1 Ant-WAIS-Divide.Severinghaus.2012 uncertainty_temperature\n", "2 Asi-SourthAndMiddleUrals.Demezhko.2007 temperature\n", "3 Ocn-AlboranSea436B.Nieto-Moreno.2013 temperature\n", "4 Ocn-FeniDrift.Richter.2009 temperature\n", diff --git a/notebooks/L2_b_using_graphdb.ipynb b/notebooks/L2_b_using_graphdb.ipynb index 5f435e9..9e53eaf 100644 --- a/notebooks/L2_b_using_graphdb.ipynb +++ b/notebooks/L2_b_using_graphdb.ipynb @@ -164,70 +164,82 @@ " \n", " \n", " 0\n", - " http://linked.earth/lipd/GeoB6211-2.Chiessi.2009\n", - " GeoB6211-2.Chiessi.2009\n", + " http://linked.earth/lipd/Woodroffe.2003.Christ...\n", + " Woodroffe.2003.ChristmasIs_XM1\n", " \n", " \n", " 1\n", - " http://linked.earth/lipd/Craterlake.Arcusa.2020\n", - " Craterlake.Arcusa.2020\n", + " http://linked.earth/lipd/Emile-Geay.2016.Bayes...\n", + " Emile-Geay.2016.BayesIslet_Bayes1\n", " \n", " \n", " 2\n", - " http://linked.earth/lipd/HayesLake.McAndrews.1982\n", - " HayesLake.McAndrews.1982\n", + " http://linked.earth/lipd/Ocn-TongueoftheOcean....\n", + " Ocn-TongueoftheOcean.Rosenheim.2005\n", " \n", " \n", " 3\n", - " http://linked.earth/lipd/Asi-PAKI001.Esper.2007\n", - " Asi-PAKI001.Esper.2007\n", + " http://linked.earth/lipd/Cobb.2013.ChristmasIs...\n", + " Cobb.2013.ChristmasIs_p382\n", " \n", " \n", " 4\n", - " http://linked.earth/lipd/Hussein.Haynes.1987\n", - " Hussein.Haynes.1987\n", + " http://linked.earth/lipd/Cobb.2013.ChristmasIs...\n", + " Cobb.2013.ChristmasIs_p11\n", " \n", " \n", " 5\n", - " http://linked.earth/lipd/DE14DTO03\n", - " DE14DTO03\n", + " http://linked.earth/lipd/Woodroffe.2000.KoilIs...\n", + " Woodroffe.2000.KoilIs_CW-2\n", " \n", " \n", " 6\n", - " http://linked.earth/lipd/BechanCave.Davis.1990\n", - " BechanCave.Davis.1990\n", + " http://linked.earth/lipd/McGregor.2004.KoilIs_...\n", + " McGregor.2004.KoilIs_FK05\n", " \n", " \n", " 7\n", - " http://linked.earth/lipd/Alsa.Mariscal.1993Legacy\n", - " Alsa.Mariscal.1993Legacy\n", + " http://linked.earth/lipd/Tudhope.2001.Laing_DUR-2\n", + " Tudhope.2001.Laing_DUR-2\n", " \n", " \n", " 8\n", - " http://linked.earth/lipd/LakeBI2.Gajewski.1992\n", - " LakeBI2.Gajewski.1992\n", + " http://linked.earth/lipd/Tudhope.2001.Madang_M...\n", + " Tudhope.2001.Madang_M93TBFC\n", " \n", " \n", " 9\n", - " http://linked.earth/lipd/Axe.McAndrews.No\n", - " Axe.McAndrews.No\n", + " http://linked.earth/lipd/Craterlake.Arcusa.2020\n", + " Craterlake.Arcusa.2020\n", " \n", " \n", "\n", "" ], "text/plain": [ - " ds dsname\n", - "0 http://linked.earth/lipd/GeoB6211-2.Chiessi.2009 GeoB6211-2.Chiessi.2009\n", - "1 http://linked.earth/lipd/Craterlake.Arcusa.2020 Craterlake.Arcusa.2020\n", - "2 http://linked.earth/lipd/HayesLake.McAndrews.1982 HayesLake.McAndrews.1982\n", - "3 http://linked.earth/lipd/Asi-PAKI001.Esper.2007 Asi-PAKI001.Esper.2007\n", - "4 http://linked.earth/lipd/Hussein.Haynes.1987 Hussein.Haynes.1987\n", - "5 http://linked.earth/lipd/DE14DTO03 DE14DTO03\n", - "6 http://linked.earth/lipd/BechanCave.Davis.1990 BechanCave.Davis.1990\n", - "7 http://linked.earth/lipd/Alsa.Mariscal.1993Legacy Alsa.Mariscal.1993Legacy\n", - "8 http://linked.earth/lipd/LakeBI2.Gajewski.1992 LakeBI2.Gajewski.1992\n", - "9 http://linked.earth/lipd/Axe.McAndrews.No Axe.McAndrews.No" + " ds \\\n", + "0 http://linked.earth/lipd/Woodroffe.2003.Christ... \n", + "1 http://linked.earth/lipd/Emile-Geay.2016.Bayes... \n", + "2 http://linked.earth/lipd/Ocn-TongueoftheOcean.... \n", + "3 http://linked.earth/lipd/Cobb.2013.ChristmasIs... \n", + "4 http://linked.earth/lipd/Cobb.2013.ChristmasIs... \n", + "5 http://linked.earth/lipd/Woodroffe.2000.KoilIs... \n", + "6 http://linked.earth/lipd/McGregor.2004.KoilIs_... \n", + "7 http://linked.earth/lipd/Tudhope.2001.Laing_DUR-2 \n", + "8 http://linked.earth/lipd/Tudhope.2001.Madang_M... \n", + "9 http://linked.earth/lipd/Craterlake.Arcusa.2020 \n", + "\n", + " dsname \n", + "0 Woodroffe.2003.ChristmasIs_XM1 \n", + "1 Emile-Geay.2016.BayesIslet_Bayes1 \n", + "2 Ocn-TongueoftheOcean.Rosenheim.2005 \n", + "3 Cobb.2013.ChristmasIs_p382 \n", + "4 Cobb.2013.ChristmasIs_p11 \n", + "5 Woodroffe.2000.KoilIs_CW-2 \n", + "6 McGregor.2004.KoilIs_FK05 \n", + "7 Tudhope.2001.Laing_DUR-2 \n", + "8 Tudhope.2001.Madang_M93TBFC \n", + "9 Craterlake.Arcusa.2020 " ] }, "execution_count": 4, @@ -264,7 +276,7 @@ "outputs": [], "source": [ "query = \"\"\"PREFIX le: \n", - "PREFIX le_var: \n", + "PREFIX le_var: \n", "PREFIX wgs84: \n", "\n", "\n", @@ -548,7 +560,7 @@ " 145.8170\n", " -3.0\n", " d18O\n", - " [-4.875, -4.981, -5.166, -5.06, -4.942, -4.919...\n", + " [-4.827, -4.786, -4.693, -4.852, -4.991, -4.90...\n", " permil\n", " d18O\n", " NaN\n", @@ -556,7 +568,7 @@ " [1993.042, 1992.792, 1992.542, 1992.292, 1992....\n", " yr AD\n", " iso2k\n", - " Ocean2kHR_141\n", + " Ocean2kHR_140\n", " \n", " \n", "\n", @@ -575,7 +587,7 @@ "1 d18O [-4.8011, -4.725, -4.6994, -4.86, -5.0886, -5.... \n", "2 d18O [-4.15, -3.66, -3.69, -4.07, -3.95, -4.12, -3.... \n", "3 d18O [-18.5905, -16.3244, -16.2324, -17.0112, -18.6... \n", - "4 d18O [-4.875, -4.981, -5.166, -5.06, -4.942, -4.919... \n", + "4 d18O [-4.827, -4.786, -4.693, -4.852, -4.991, -4.90... \n", "\n", " paleoData_units paleoData_proxy paleoData_proxyGeneral time_variableName \\\n", "0 permil d18O NaN year \n", @@ -596,7 +608,7 @@ "1 iso2k Ocean2kHR_177 \n", "2 iso2k Ocean2kHR_105 \n", "3 iso2k SAm_035 \n", - "4 iso2k Ocean2kHR_141 " + "4 iso2k Ocean2kHR_140 " ] }, "execution_count": 7,