From e9e186b21bde109abf40dab7e3c3e531b632b43c Mon Sep 17 00:00:00 2001 From: Cogan Shimizu Date: Mon, 19 Feb 2024 22:57:11 -0500 Subject: [PATCH] updated to interact with local spase --- bookend/bookend.ipynb | 295 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 257 insertions(+), 38 deletions(-) diff --git a/bookend/bookend.ipynb b/bookend/bookend.ipynb index 7747006..ee50ec5 100644 --- a/bookend/bookend.ipynb +++ b/bookend/bookend.ipynb @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 106, + "execution_count": null, "id": "6cf6e8fd", "metadata": {}, "outputs": [], @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 107, + "execution_count": null, "id": "4c80e5b7", "metadata": {}, "outputs": [], @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 108, + "execution_count": null, "id": "9afa019d", "metadata": {}, "outputs": [], @@ -158,24 +158,57 @@ }, { "cell_type": "code", - "execution_count": 109, + "execution_count": null, "id": "09b7e98d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Connection success.\n" - ] - } - ], + "outputs": [], "source": [ "db_loc = \"http://localhost:3030\"\n", "dataset = \"bookend\"\n", - "endpoint = f\"{db_loc}/{dataset}\"\n", - "sparql = SPARQLWrapper(endpoint) # default location of fuseki\n", - "sparql.setReturnFormat(JSON)\n", + "endpoint_url = f\"{db_loc}/{dataset}\"\n", + "endpoint = SPARQLWrapper(endpoint_url) # default location of fuseki\n", + "endpoint.setReturnFormat(JSON)\n", + "\n", + "# Construct the query\n", + "query = \"\"\"\n", + " PREFIX poly-ont: \n", + "\n", + " SELECT *\n", + " WHERE {\n", + " ?person a poly-ont:Person .\n", + " }\n", + " \"\"\"\n", + "# Set the query\n", + "endpoint.setQuery(query)\n", + "\n", + "try:\n", + " ret = endpoint.queryAndConvert()\n", + " print(\"Connection success.\")\n", + "except Exception as e:\n", + " print(e)" + ] + }, + { + "cell_type": "markdown", + "id": "6a82b434", + "metadata": {}, + "source": [ + "## Local SPASE\n", + "The current expectation is that there is an RDF-ified version of the SPASE dataset locally available. For more information in generating this, see the [spase-rdf-tools](https://github.com/polyneme/spase-rdf-tools/tree/master/spase_rdf_tools)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e041283d", + "metadata": {}, + "outputs": [], + "source": [ + "spase_dataset = \"spase-rdf\"\n", + "spase_endpoint_url = f\"{db_loc}/{spase_dataset}\"\n", + "\n", + "spase_endpoint = SPARQLWrapper(spase_endpoint_url) # default location of fuseki\n", + "spase_endpoint.setReturnFormat(JSON)\n", "\n", "# Construct the query\n", "query = \"\"\"\n", @@ -187,10 +220,10 @@ " }\n", " \"\"\"\n", "# Set the query\n", - "sparql.setQuery(query)\n", + "spase_endpoint.setQuery(query)\n", "\n", "try:\n", - " ret = sparql.queryAndConvert()\n", + " ret = spase_endpoint.queryAndConvert()\n", " print(\"Connection success.\")\n", "except Exception as e:\n", " print(e)" @@ -198,13 +231,23 @@ }, { "cell_type": "code", - "execution_count": 110, + "execution_count": null, + "id": "d7301a8a", + "metadata": {}, + "outputs": [], + "source": [ + "## Utility Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "72a0bbbc", "metadata": {}, "outputs": [], "source": [ "## This query will be useful\n", - "def instanceExists(uri, sparql=sparql):\n", + "def instanceExists(uri, sparql=endpoint):\n", " query = f\"\"\"\n", " PREFIX poly-ont: \n", "\n", @@ -234,7 +277,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": null, "id": "e1ed503e", "metadata": {}, "outputs": [], @@ -273,22 +316,186 @@ }, { "cell_type": "code", - "execution_count": 113, + "execution_count": 24, "id": "77a30b13", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT1M\n", + "NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP4_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP4_PT32S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_A16W_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_A16W_PT32S\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_A16W_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_A16W_PT32S\n", + "NOAA_NumericalData_GOES_13_EPS_MAGED_19ME5_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGED_19ME5_PT32S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_CPFLUX_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_CPFLUX_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP15_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP15_PT5M\n", + "NOAA_NumericalData_GOES_6_SEM_A_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_SEM_A_PT5M\n", + "NOAA_NumericalData_GOES_1_MFM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_1_MFM_PT3S\n", + "NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP1_PT16S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP1_PT16S\n", + "NOAA_NumericalData_GOES_15_EPS_HEPAD_S15_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_HEPAD_S15_PT1M\n", + "NOAA_NumericalData_GOES_8_SEM_Z_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_SEM_Z_PT5M\n", + "NOAA_NumericalData_GOES_15_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_MAG_PT1M\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_P27E_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_P27E_PT32S\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_CPFLUX_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_CPFLUX_PT5M\n", + "NOAA_NumericalData_GOES_2_EPM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_2_EPM_PT3S\n", + "NOAA_NumericalData_GOES_10_HEPAD_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_HEPAD_PT5M\n", + "NOAA_NumericalData_GOES_2_MFM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_2_MFM_PT3S\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_P17EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_P17EW_PT5M\n", + "NOAA_NumericalData_GOES_12_HEPAD_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_HEPAD_PT5M\n", + "NOAA_NumericalData_GOES_13_EPS_HEPAD_AP_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_HEPAD_AP_PT1M\n", + "NOAA_NumericalData_GOES_12_SEM_I_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_SEM_I_PT5M\n", + "NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP3_PT16S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP3_PT16S\n", + "NOAA_NumericalData_GOES_12_SEM_A_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_SEM_A_PT5M\n", + "NOAA_NumericalData_GOES_14_EPS_HEPAD_S15_PT4S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_HEPAD_S15_PT4S\n", + "NOAA_NumericalData_GOES_13_EPS_MAGED_19ME15_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGED_19ME15_PT1M\n", + "NOAA_NumericalData_GOES_12_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_MAG_PT1M\n", + "NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP15_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP15_PT5M\n", + "NOAA_NumericalData_GOES_11_SEM_I_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_11_SEM_I_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_E13EW_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_E13EW_PT1M\n", + "NOAA_NumericalData_GOES_7_SEM_G_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_7_SEM_G_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP15_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_MAGPD_19MP15_PT1M\n", + "NOAA_NumericalData_GOES_9_MAG_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_9_MAG_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT32S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_P17EW_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_P17EW_PT1M\n", + "NOAA_NumericalData_GOES_12_EPS_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_EPS_PT5M\n", + "NOAA_NumericalData_GOES_10_SEM_H_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_SEM_H_PT5M\n", + "NOAA_NumericalData_GOES_10_SEM_G_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_SEM_G_PT5M\n", + "NOAA_NumericalData_GOES_10_SEM_G_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_SEM_G_PT1M\n", + "NOAA_NumericalData_GOES_9_MAG_NGDC_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_9_MAG_NGDC_PT1M\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_A16EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_A16EW_PT5M\n", + "NOAA_NumericalData_GOES_14_EPS_MAGED_19ME3_PT4S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_MAGED_19ME3_PT4S\n", + "NOAA_NumericalData_GOES_11_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_11_MAG_PT1M\n", + "NOAA_NumericalData_GOES_5_SEM_A_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_5_SEM_A_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_MAGED_19ME15_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_MAGED_19ME15_PT1M\n", + "NOAA_NumericalData_GOES_8_MAG_NGDC_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_MAG_NGDC_PT1M\n", + "NOAA_NumericalData_GOES_8_EPS_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_EPS_PT5M\n", + "NOAA_NumericalData_GOES_6_SEM_G_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_SEM_G_PT1M\n", + "NOAA_NumericalData_GOES_13_EPS_MAGED_19ME4_PT16S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGED_19ME4_PT16S\n", + "NOAA_NumericalData_GOES_8_EPS_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_EPS_PT1M\n", + "NOAA_NumericalData_GOES_7_EPM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_7_EPM_PT3S\n", + "NOAA_NumericalData_GOES_5_MAG_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_5_MAG_PT3S\n", + "NOAA_NumericalData_GOES_9_SEM_A_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_9_SEM_A_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT1M\n", + "NOAA_NumericalData_GOES_13_EPS_HEPAD_AP_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_HEPAD_AP_PT32S\n", + "NOAA_NumericalData_GOES_14_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_MAG_PT1M\n", + "NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT1M\n", + "NOAA_NumericalData_GOES_8_HEPAD_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_HEPAD_PT5M\n", + "NOAA_NumericalData_GOES_5_EPS_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_5_EPS_PT3S\n", + "NOAA_NumericalData_GOES_5_SEM_G_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_5_SEM_G_PT5M\n", + "NOAA_NumericalData_GOES_10_MAG_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_MAG_PT5M\n", + "NOAA_NumericalData_GOES_6_MAG_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_MAG_PT3S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_P17EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_P17EW_PT5M\n", + "NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP4_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGPD_19MP4_PT32S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_A16E_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_A16E_PT32S\n", + "NOAA_NumericalData_GOES_7_SEM_I_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_7_SEM_I_PT5M\n", + "NOAA_NumericalData_GOES_13_EPS_MAGED_19ME1_PT2S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_MAGED_19ME1_PT2S\n", + "NOAA_NumericalData_GOES_12_SEM_G_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_SEM_G_PT1M\n", + "NOAA_NumericalData_GOES_10_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_MAG_PT1M\n", + "NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT32S\n", + "NOAA_NumericalData_GOES_9_SEM_G_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_9_SEM_G_PT1M\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_E13EW_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_E13EW_PT1M\n", + "NOAA_NumericalData_GOES_13_MAG_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_MAG_PT1M\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_P1EW_PT8S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_P1EW_PT8S\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT5M\n", + "NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_HEPAD_AP_PT5M\n", + "NOAA_NumericalData_GOES_Ephemeris_P1D: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_Ephemeris_P1D\n", + "NOAA_NumericalData_GOES_6_SEM_Z_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_SEM_Z_PT5M\n", + "NOAA_NumericalData_GOES_11_SEM_H_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_11_SEM_H_PT5M\n", + "NOAA_NumericalData_GOES_10_SEM_A_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_10_SEM_A_PT5M\n", + "NOAA_NumericalData_GOES_6_MFM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_MFM_PT3S\n", + "NOAA_NumericalData_GOES_7_SEM_H_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_7_SEM_H_PT5M\n", + "NOAA_NumericalData_GOES_8_SEM_H_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_SEM_H_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_A16EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_A16EW_PT5M\n", + "NOAA_NumericalData_GOES_12_MAG_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_12_MAG_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_E2EW_PT16S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_E2EW_PT16S\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_P1EW_PT8S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_P1EW_PT8S\n", + "NOAA_NumericalData_GOES_6_EPM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_EPM_PT3S\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_P27E_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_P27E_PT32S\n", + "NOAA_NumericalData_GOES_15_EPS_EPEAD_E13EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_EPEAD_E13EW_PT5M\n", + "NOAA_NumericalData_GOES_15_MAG_PT0_512S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_MAG_PT0_512S\n", + "NOAA_NumericalData_GOES_8_MAG_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_8_MAG_PT5M\n", + "NOAA_NumericalData_GOES_14_EPS_MAGED_19ME15_PT1M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_MAGED_19ME15_PT1M\n", + "NOAA_NumericalData_GOES_13_EPS_EPEAD_A16EW_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_A16EW_PT5M\n", + "NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_15_EPS_HEPAD_AP_PT5M\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_A16E_PT32S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_A16E_PT32S\n", + "NOAA_NumericalData_GOES_7_MFM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_7_MFM_PT3S\n", + "NOAA_NumericalData_GOES_14_EPS_EPEAD_E2EW_PT16S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_14_EPS_EPEAD_E2EW_PT16S\n", + "NOAA_NumericalData_GOES_5_MFM_PT3S: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_5_MFM_PT3S\n", + "NOAA_NumericalData_GOES_6_SEM_H_PT5M: http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_6_SEM_H_PT5M\n" + ] + } + ], "source": [ - "# Code to do data set discovery\n", - "## PySat?\n", - "## HDPE.io\n", - "## CDAWeb\n", - "pass\n", + "# This code is currently set to query for data products (spase:NumericalData) by keyword.\n", + "keyword = \"GOES\"\n", + "query = f\"\"\"\n", + "PREFIX rdf: \n", + "PREFIX rdfs: \n", + "PREFIX spase: \n", "\n", - "# It is important to note that we have a record of which datasets we start with\n", - "data_inputs = list()\n", + "SELECT ?label ?uri WHERE {{\n", + " ?uri a spase:NumericalData ;\n", + " spase:keyword ?\"{keyword}\" ;\n", + " rdfs:label ?label .\n", + "}} LIMIT 100\n", + "\"\"\"\n", + "\n", + "spase_endpoint.setQuery(query)\n", + "try:\n", + " ret = spase_endpoint.queryAndConvert()\n", + " for res in ret[\"results\"][\"bindings\"]:\n", + " print(f'{res[\"label\"][\"value\"]}: {res[\"uri\"][\"value\"]}')\n", + "except Exception as e:\n", + " print(e)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "9890213b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You can get your data from here. In the future, we will attempt to get this for you.\n", + "https://spdf.gsfc.nasa.gov/pub/data/goes/goes13/epead-electrons/e13ew_1min/\n" + ] + } + ], + "source": [ + "# Now, you choose one of those label, URI pairs \n", + "dataset_label = \"NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT1M\"\n", + "dataset_uri = \"http://www.spase-group.org/data/schema/NOAA_NumericalData_GOES_13_EPS_EPEAD_E13EW_PT1M\"\n", + "\n", + "query = f\"\"\"\n", + "PREFIX rdf: \n", + "PREFIX rdfs: \n", + "PREFIX spase: \n", + "\n", + "SELECT ?actual_url WHERE {{\n", + " <{dataset_uri}> spase:has_access_information ?o .\n", + " ?o spase:has_access_url ?url .\n", + " ?url spase:name ?\"HTTPS from SPDF\" ;\n", + " spase:url ?actual_url .\n", + "}} LIMIT 100\n", + "\"\"\"\n", + "\n", + "spase_endpoint.setQuery(query)\n", + "try:\n", + " ret = spase_endpoint.queryAndConvert()\n", + " print(\"You can get your data from here. In the future, we will attempt to get this for you.\")\n", + " for res in ret[\"results\"][\"bindings\"]:\n", + " print(f'{res[\"actual_url\"][\"value\"]}')\n", + "except Exception as e:\n", + " print(e)\n", "\n", + "# It is important to note that we have a record of which datasets we start with\n", "## Populated sample dataset names\n", - "data_inputs = [\"dataset1\", \"dataset2\"]" + "data_inputs = [dataset_uri]" ] }, { @@ -302,11 +509,23 @@ }, { "cell_type": "code", - "execution_count": 114, + "execution_count": 30, "id": "6bb4c8ea", "metadata": {}, "outputs": [], "source": [ + "## Import Stuff\n", + "pass" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "eb4788c8", + "metadata": {}, + "outputs": [], + "source": [ + "## Do Stuff\n", "pass" ] }, @@ -321,7 +540,7 @@ }, { "cell_type": "code", - "execution_count": 115, + "execution_count": null, "id": "6ee5b89e", "metadata": {}, "outputs": [], @@ -349,7 +568,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "d2044052", "metadata": {}, "outputs": [], @@ -375,7 +594,7 @@ }, { "cell_type": "code", - "execution_count": 116, + "execution_count": null, "id": "e55c53d1", "metadata": {}, "outputs": [], @@ -427,7 +646,7 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": null, "id": "95c8782e", "metadata": {}, "outputs": [], @@ -438,7 +657,7 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": null, "id": "4fc488fe", "metadata": {}, "outputs": [], @@ -464,7 +683,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.12" } }, "nbformat": 4,