diff --git a/docs/examples/pace_cyano.ipynb b/docs/examples/pace_cyano.ipynb index e031dbc..24658b1 100644 --- a/docs/examples/pace_cyano.ipynb +++ b/docs/examples/pace_cyano.ipynb @@ -6,12 +6,9 @@ "id": "yk1OuuFc-_I4" }, "source": [ - "## What is HyperCoast?\n", - "HyperCoast streamlines the processing of hyperspectral data from existing spaceborne and airborne missions (e.g., PACE, EMIT, AVIRIS, NEON, and DESIS) and upcoming hyperspectral missions, such as, SBG and GLIMR.\n", + "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/HyperCoast/blob/main/docs/examples/pace_cyano.ipynb)\n", "\n", - "https://hypercoast.org\n", - "\n", - "\"HyperCoast" + "# Mapping Cyanobacteria with PACE data" ] }, { @@ -20,16 +17,27 @@ "id": "AvpjFXjN-_I_" }, "source": [ + "## Install packages\n", + "\n", "Uncomment the following cell to install the HyperCoast package." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %pip install -U \"hypercoast[extra]\"" + ] + }, { "cell_type": "markdown", "metadata": { "id": "ASucI-Sc-_JD" }, "source": [ - "Import libraries" + "## Import libraries" ] }, { @@ -40,8 +48,8 @@ }, "outputs": [], "source": [ - "import hypercoast\n", - "import pandas as pd" + "import earthaccess\n", + "import hypercoast" ] }, { @@ -50,604 +58,84 @@ "id": "bsEz1U-e-_JE" }, "source": [ - "Download a sample dataset." + "## Download PACE data\n", + "\n", + "To download and access the PACE AOP data, you will need to create an Earthdata login. You can register for an account at [urs.earthdata.nasa.gov](https://urs.earthdata.nasa.gov). Once you have an account, run the following cell and enter your NASA Earthdata login credentials." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "id": "oY5qbVGL-_JF" - }, + "metadata": {}, "outputs": [], "source": [ - "filepath = \"./PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc\"\n", - "dataset = hypercoast.read_pace(filepath)" + "earthaccess.login(persist=True)" ] }, { "cell_type": "markdown", - "metadata": { - "id": "oIUM0vLh-_JG" - }, + "metadata": {}, "source": [ - "Load the HYpoxia field data." + "Search for PACE AOP data:" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 377 - }, - "id": "4QV5JjIZ-_JG", - "outputId": "82773c91-a525-4c7b-9b4d-4736fac2a743" - }, + "metadata": {}, "outputs": [], "source": [ - "kml_path = \"./GOM_Hypoxia.kml\"\n", - "filepath = \"./Hypoxia_Data_Sheet.xlsx\"\n", - "df = pd.read_excel(filepath)\n", - "df.head()" + "results = hypercoast.search_pace(\n", + " bounding_box=(-83, 25, -81, 28),\n", + " temporal=(\"2024-07-30\", \"2024-08-15\"),\n", + " short_name=\"PACE_OCI_L2_AOP_NRT\",\n", + " count=1,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Download PACE AOP data:" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 377 - }, - "id": "hq6TIsGs-_JH", - "outputId": "fe56aa5f-483c-473d-c2d6-f4837a825dda" - }, + "metadata": {}, "outputs": [], "source": [ - "df_filtered = df.dropna(subset=[\"Lon\", \"Lat\"]).reset_index(drop=True)\n", - "df_filtered.head()" + "hypercoast.download_pace(results[:1], out_dir=\"data\")" ] }, { "cell_type": "markdown", - "metadata": { - "id": "csMuk4GW-_JH" - }, + "metadata": {}, "source": [ - "Visualize PACE image and field data on an interactive map." + "## Read PACE data\n", + "\n", + "Read PACE AOP data as an `xarray.Dataset`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 621, - "referenced_widgets": [ - "be80ca51182d478e99a1660335dcbeca", - "6db2efdcce5c4e388751ac0673451e4b", - "4e890464e94e475583af3f962fa2c09c", - "af2f16ec6a4540fb9fda5f40aca124a3", - "f6cf3b1f6b61471dab82efe1d86599e1", - "8ed36c9e4d554391a00200856f1c2252", - "b4f2210818de4ddd90d4a7a082a17c19", - "3341eed36f0f4037a68b2dad33a57170", - "a90909af426641c5a0a667d9004c0876", - "a7dd1183199b4a99a685fe056e726033", - "cba0ad2011904b96b047f22ea56ccf27", - "3ab801ee431245a8ae31bc06035b979e", - "6647d055590845028528b3338fdf37d4", - "2bad66cacd234937aac32ffc8c6f0383", - "1da7de786206454b8018932318cec1f5", - "5bf94e7e2907410a951f67865875dd05", - "d53be3ad8a1742e0bd12ba1be3b84e97", - "b9c06a1e0933477b8c0ec8ea64233bfb", - "f42dc14279644710a02774e56b49fb30", - "2f318c1619174b7bb1a0da0b04f70b44", - "ce665bd9d7c04fe5970271f8b3796a1e", - "d6146066004447659d6ea8429d4e203c", - "3e62f86dd8ea42569f2453071fef098f", - "dae8b0c6f57941bd9936f40d6ef38b59", - "ddb841276b344a8a849d46bfc9359f7f", - "86531836668d4ac18f97b07c00e09fdb", - "a4427096ca0642d7a2e2603e2316bb8a", - "74d85dc791b04306a6540adf5910c1f1", - "30ce83b4487747a5a8c8059ef637a7ce", - "ac86d385c8e945929e39eba9917c4430", - "94a78ff36a6e4ec1ac7ba25f4b64b1f4", - "4b6ba4b155084d2fb0fff03904f11e16", - "f472dfeb24064f8285b36b827a37838a", - "13a96b8c026a4254a709fe56af4bad09", - "a3f3a3bf99534ea998132a06ec7d3a0f", - "0ee86747c488408dab2fb1aaf0551935", - "2a6772909c234681a882a32911511578", - "41fb1ad002ff42189380cba41f32579d", - "b9b478a6c49040c29591dd74fa12c41d", - "9478952dea9f49f4855691b00dcc606d", - "04931bd2d37d419aaee6c34739001eb4", - "993cf873174e4140b0131b3cade59a6f", - "8230eae0440d46d0b38a45f25400c2f6", - "e0b2a264c1b84483b2ad26c979eb06ba", - "8c02a5175a2347f3b59b4d2b9ccd7d83", - "6562e5f44a13425bb99c253cf95ae57e", - "3478c449625045e0be76a5063c15042c", - "f818c745f33949dda2d584b5bfdd2b06", - "637cc457cbfd402f9757e448ab1e83d4", - "d8b40b7a4b2f4ea4ac628fe1c40e0d05", - "58c08210ce0b4e9b96043bd98c02f955", - "41ccfc427d724fefa6c3693c4dd3e232", - "5764d18599e3466a9614f649cfa5accf", - "a2148ee468d34abaa0195b6d50e17ac1", - "883d5664fe2343029321f0f6fd427281", - "f7ca2e5ea4944ed8a4dfbd20c8a466f5", - "7a3b385df1bb4a5c921160b4f855d659", - "ca728777bfd34229b6e94c0c9cee219a", - "ca62ef3f87f4462584850a0ab7e8a983", - "ed7090f2450c49b581cd6c4f0235ff0a", - "73d8547b86d8461f9665e46b76845491", - "23ec5de7f1fc4fb1a1e38d5ad64569a3", - "c06593588eec4c8bb561b9eede2559fa", - "121d30efdf9b47d2a935556c523ad2d4", - "00edd3764f51432c8cfe8ea6557a1e08", - "1ca88fe5b29c4fa396f10f9196f4c926", - "09a172672184405a93767aa35e82aca2", - "e7f1cfae3af04ac1b9991429ce5d8696", - "1b943502daa142d198b21fbd50edf1b5", - "e8a22131273c444d9170627482d95bc6", - "3adab95244be43bfaaacaca3d245cdc6", - "628d8822921a4533a7cf0a88d47e3c76", - "c8e9ec9138934a5096094c2fd1037164", - "27bde86c125c49478df930f4cb59b496", - "69e685cc03fb428b80e1158705f5f606", - "1ea659eee74e48a585c539d3174f170d", - "7a9fa70ca0e9494291acbb7e94b83ac8", - "4af93ea50f4849f6aa5f46705ec30b1a", - "5e4d6ebad2f44c458031ec761acb84ba", - "1dbbca6de06c483590abc97cb0aedb98", - "53c3ef09c0a44e5c8f47b1fed626803d", - "34ccf4366bb4496f8df03a8df87cbc92", - "c556792a3bcf4d5fb8f59e87fb9aba4e", - "f25b088dd35c4ca0ac8312863c97b307", - "713815ebbb1c4e5fa932df5312373d97", - "cfedde6227e847ce831f0f088b229201", - "c13749fb80e64c0eae9dc6620d4c5c4b", - "345018a1358d445eb768910cc3fbd4ad", - "74c97d95dfc14910b51f8ee052fb7564", - "4e9a7372624543cbac757ebefe64e9aa", - "c444b94927aa478f9668271cac855eff", - "5478add9556d4bcd80ee2348e5972b08", - "99d7238f6c6f4361a9563603f9e498a5", - "523e128320524eff83dd9740deefe336", - "4946f44209434912bd31ecc4ba35a013", - "a8b5dceac4f348e48216302cf77d9a13", - "136e1fe79dd64ec3acb858ad2e4dc771", - "bcb292930e3d455e92b667acbc4e650e", - "a29b0744412241bba1e58fb494d4e91c", - "993e4855eb794092ace8a525efbe6afb", - "4f51af3003344f55b4c8399289d718ec", - "7264488c5682466d88538b70febab456", - "c290286a52c841a2a7b220f242b48d76", - "79522d7a97884af6b53eff4de7267711", - "c943a936e4da41a092c179952201f0e7", - "be911ade949340d1b9d1aab5c24db305", - "eb296a3af8b84e00bc48206711bf8823", - "8a8949b2a10b462899a5d7b08ffc07c7", - "a6aefd2973a242b982faafbd96ba9e9a", - "4f1c2c199f074f18bf24cb6a1293368a", - "cc1a485fc50841db9e713a028e2e8a9d", - "8077278ad4c94fd9840212d82cfbf327", - "9c93c88df4df4be78564ab78b7221492", - "f5c53b720fb04c02bc93bab175b0bd01", - "fc17ba989534419dac07bf63fcaa241f", - "ebea935f9517438592db790064c7a02c", - "b8c92a60cffc4bc49c54f1a60408cda8", - "b7c59d9637f2475eae47d812fcdc45e3", - "ac1a57d752a5487092741305a95007c0", - "8632211ad72e40ba98e23c8e1b5438c4", - "190ace0a34b3433982954242747fa316", - "8c244d3733af4e54836447862aae4585", - "bfd528630b7240379a9fb0cee5c039a3", - "4317a66ffb674e43be7090f29e892b1a", - "1de92d2117704c749dc3c18552bd17af", - "e3d8a0f210da4502bf94ce59c76c2c22", - "aec3edb10731471e89aa35020620fe91", - "7a71d1ff986e45c1be382022f4679186", - "e1ed61786eb04e3bb9e8f26b3defe04e", - "1356521558c8410f9cd3fef8b56ee05e", - "6fdffb06b26a4aeeb56d526730551a8d", - "5585109469e3438498b3c6fd55e0ea8d", - "6b3e9af851f44c7ca1e3c1648608e9f2", - "b05676e840a64aa8b2efb719b726eb15", - "e27b2cf47323474b9ffb4827d020b14a", - "f322013814a54c45bdf422f566c968ad", - "263277d1f6884d71971c97c6c88bb91b", - "f4127025a083450ea04e788dd0564393", - "e19616b8b70b4694ae288ccfb9600a4b", - "7b79099cd6db45a5b6908ba45da6281f", - "bfa41d40f142465ead1d667f88cb4d18", - "d38613308c2b40378f7be7dd125f1b80", - "a82dbaf6816f4df9b3f472d26334f014", - "5a5c1f09b2fd48c6933cfd5424acb367", - "9088264c95224cbcadd296ea355472ad", - "3c774e67e26a4cd0a75c2e4f42b7d85b", - "006249ad7aef42ad9d377f3debf8573e", - "f9e154dde1574543862402e794ebf259", - "afd986831d074237811a240bda4d9044", - "d2d098d167884da5ab12c2a981eb3be8", - "5a8b45a97981467ebb722fe99b2049b7", - "258e38817b7e45bdb5980344d8eb78a7", - "8c014d7d3991425b8e1be992e167afa1", - "27668aab760e4ff080ac49ff3ead80a3", - "b767aefdd2bd4eeeb6e1aa4dd76229d7", - "4163830b735a480fb281345fe50aec30", - "789d4e67d6a24c1eb840806f202b6366", - "1bb67ad1967a415ab0536e3e44da4a66", - "1687525bb93940fb82391ccc3056d4a6", - "4315121946e04e068b0450f03292f62b", - "6fa3a75291d8475c957fa165716fc859", - "4304a17f3ad84c57bd1c86d5314c78b6", - "05394bb536ad45e39b67a971e4543b41", - "3a43ae623d1e4b1599c0e200db3b79df", - "a1edf8e5266e4b31801bd726f16c3451", - "84b676b894e945e583f104738f5a08e5", - "86a6d986a1a241f28ded75d6279c5f0e", - "e70c642e108646f8b06d87540277efe6", - "f84e8235ed3d426db696b0f3cd743f5f", - "0f9daa8c65be46b49949f538251df5b9", - "2d5f1b8743bc4ae3a67e96eba2ea50e5", - "b7999483506344829dda4a732d896962", - "5fa236becd3a4a01a556ea737b49eeb3", - "413e594d336644d0a2e381b526f83488", - "5ee623916f674ff99034a753a48cc80e", - "02af5e4f881c4392970ec96729c78787", - "63ed7eb80b754fc694146b0d3c1044da", - "b8bf91eb75de4e52abddc9664e924e08", - "a906ae743d1f4df792f801ca981bead3", - "a0db7faad7fb4386a0f8f2764c8fa2d7", - "8cc309a7886f4c9fb18b180ddd7acfb4", - "448e57b34c4c426b8cc8be7a9a471a1e", - "674c119afb2b48b9bc15ed2b261411b6", - "6232368e8be145d7804ac0c09e5b6940", - "af9cccdade01467383cecd50245552f2", - "6ea8ac55797444bab73f0b66e47cad10", - "cecbb6d5d50a4ffbb21de2cde3aaaf13", - "160a44e635b24bba97e030683ee2f146", - "e94ae1870582469aafd868e5d063ae69", - "1de540398a8f48b3bdba01ae2ae54932", - "81b7d5a37044401690873d93c78f4397", - "8dd9024e965643a480914692399276a0", - "dc34a69ac07d4bb5ac971232156e2f0c", - "ad38856ac1e44faf86bc57ed568a4328", - "99aaa6a247144eda9218a18785fc1a00", - "c489767877d041d891042c91fe1b1cb1", - "78ccb481a46548a09d69e2cc20f738b2", - "4107ae92238f41cc88152ab8f1035a32", - "0d03e610223544b183e8b7efbc26f0b0", - "44359f72246c45578c9474012505004d", - "e56f97c0283a46fd871b1c58b0be72a5", - "461400fe70364187a2f0934cbb624b0e", - "a4c42e4a76544b0184e0cc91b342dc38", - "cbf206c82feb420084867def69be966d", - "db9f2886c7f4451cac037910a4a72f71", - "9731d4e5b76442d6a4385c80e9544d29", - "12cbfe9979ac4fa6b5ebd26e2ae3bfa8", - "37c42733f9314166b9a7f32347dcfe3d", - "1fca711253b3489eae61aadf7af2877d", - "d62b6c71dd0f45ffb2ee889404167148", - "210dd8a8ff4d4d0aa82e49d2318751b1", - "a42b727f470a4e08ac3620e587908adc", - "60ad05e48cba49ae8a14bd0147999233", - "07473718c7424cf5a25f6fbf06207998", - "4ca6bf14cf234359af48cf5d83d6d081", - "40b43dd3003848bb8d5e13a01d5b93b8", - "791bdc791f8f44999f23d2b2680fe317", - "81d3083adeba4b60b42f4b213b079e0b", - "9a9ca2ceeba146a2af34c52d262531c6", - "af865eb6ac2b472ab25efd1f0659c5a8", - "1c7c0e7d6d9d4051ba65bc721f4d000f", - "08028f0c7e40479f9fce10b2872204fb", - "b902f8584f504bc6ac15df8b96f82338", - "9c4f9eaa4aa048caa68792dba9854174", - "f4f1913bac594003a369558323547a20", - "0114275a27f144f98a79856dec7ac89d", - "66e17e5a092c46d59caef5421546426c", - "e6fdb977c5ba4e5694dfffb0500da3c8", - "f48c5e64e30140bc9bfcbaba92731659", - "0bc2251bc6304aaf883bba7f4ccccb57", - "4493b9338b584422b427768a19bf2162", - "ea31eb206e34444491e3e44185778e89", - "cc3c64692ed049c3a56b0aec50cd5548", - "13b7c080ac4b40719f71c1935a1c6e29", - "0cff4add2012441d979fca4cac3b1973", - "4906567b7544414b94f3e6eb6c1ad55c", - "23bbe340e5bf4866896e6780fef09483", - "28b7d35e550e4b2580c3b605b545fb27", - "ed5d3e1d04904ad690f93f070a486a47", - "32c91ae86dd148218e8c9c6f3cbbd9a5", - "cdc9ddff09994aafab4157402e56497c", - "b37eb7f71eed4b21904077804e45afd4", - "e90d9ab9ebab4535bb985a5e8e57a661", - "3b6e3ff964754afeae063df511e8230a", - "81515131abd549d691a80f69980b2fef", - "184fff8e0ee54249ae9a631dc0a5b327", - "c25653739a9546efad85db0de08be947", - "1a11486adc9f40f38827a6baf1e81a7b", - "5b9f4c7de2ae40eda57ccfe2065124b8", - "c769d884085a481794d2364a95cdb8e9", - "d77bcd8c61fb498d8a00afb16a2ee80e", - "c18f19358d804e1b97c6985023092e6f", - "8240eae21c534f8c92a5901f79604c88", - "4d5dbfc138284b4ea7f1cb7ff2d7f748", - "c0b01fb2554f4915a0ea979135ba6913", - "4b2ec3a8cb034969a3cc02cd6d80891e", - "15d11eb54f13477ab6c8dadb47813375", - "c516cd60e9d04435a42fe13e7ddf9d67", - "1bbc1ca8b8cc4d5bab948d0fd567eaa9", - "d0239bc543794a1fbbf4aa671e5cac3f", - "37742d35a4ad4ad687fa3f0e62d94e6a", - "922df67c14a14be4a91e0d6b66e5ae15", - "ec5ef6bc603c4955b17b8e4dcdeab3a5", - "da81d183822f4b55a915514d4f10d127", - "42d07648fedd456c85c389a87e82ca96", - "b7156d72d1a94ecb9c78e5590a35c420", - "ed16362c93c64f9185f904ce47c9edbd", - "7e34e560cecc44a0987032c3af68be65", - "52a762a3acb449159d0be83253fd488d", - "0e7934b26e0a4573a191f94b18bf08d9", - "bd1aac0b685b44bb9c2a272d4080a108", - "a64593d86afa4979b1180b46f2ffa9e6", - "9dd22e09e8164fc9839f54472037933a", - "e8ad3e70e878473a9b52f1edc6b878e7", - "0b882620850a4de285c30d7871e727be", - "1f02c5cd908643bfa373d12a58fe27e2", - "f08362dae0e94dd0ae9a1d6441c26cd1", - "38cd0c8afc73498ab1930861883a7719", - "18697ebaa3c1453e84ff077e866780b2", - "db0a9c5e51694a8e9de5f9e8e490b33e", - "26796c8c43424b03be4906939cc0c45e", - "f17d5a397bb84db4a69f621c5046848d", - "55fb450d54b44f028268de387074a7a7", - "37e0f855643e4fc99b6fc4d22747861f", - "534170985cb44f36bd1d958805a64687", - "078f4e3d71684ed581cee9770de62029", - "09f19087d46a4de293f1557989ab8577", - "580450467ea14f7d8e0d25707dd144a9", - "77668e57c6ff44cb999e185f1b26a089", - "bd26fd16a63d4ab0a297a3966a6d885e", - "9d9fd80e0d094602abe8d588886fc57b", - "95d5837a059241469831b2ce1edf0ec8", - "026f3e95ca6948a681916de3993a7b76", - "c6f8cedc6eac4d25a33578f0873c1a99", - "d9d43de1ea754c0685ddad4ec8623da6", - "a377d06412e9433ba0aa9e029379d83a", - "6b306893269c4b9d9971b837185d032c", - "b43ae58a49964f6496dce10cc80346f6", - "a7bdb37085794f96b65bd22133f3e855", - "a0edfb99f4bf4d8798c98c9f7d256767", - "637d7bd93c22485185acf3a44390d9d1", - "9baa448536444c108e42ca63b796d7c8", - "5d9aa5d39e25499d8c54a7f0879d8645", - "0287767fcc4245f2a8857a2af8f767e5", - "697a785b86c64d6c8f031e8234cd01a2", - "8f5de281a21a4d1283dfc437e188c9bb", - "5868673c13b04eb3aef8c4318b1f76d4", - "460db80fc26944d2a8afdd7f5e717253", - "dfb9ca005dac44e5bee4e1bad8808c38", - "28de2994eded49b386a556374a70f909", - "fb8fbefc34cc448fb949f34110f6ebdf", - "06115205a9c547ee9a5be04666bc1a1c", - "f5129f3436b94ced9cdbf4385e932165", - "7d699732e4b24f9d94eb20574d47b00e", - "49113615e6cf4ccbabe0db3bbca271fb", - "4902bf6056a4475298bb43eabc10f9e5", - "9210a93006ee444c8346220623bc316e", - "24444dc4890842ab999432f6e4f0898b", - "be9277304e1f4f4ab4cebb84d17592fc", - "5d8abc00d692462da54b7ea86d61b1d0", - "49cdcfabff17405b8c1106a659cfb90a", - "c21f41d3912f4a4a95c080b340c7ce8f", - "8150ef1be719439aae33cbe5a4d8931a", - "da9cfed5ae5b4ee4beb4a4fda383d23d", - "7d0bcb911beb49aa9e1fbff8f4685002", - "d56e0cf6f6f546a594c75637db9693fb", - "2c745dc86e2a48d194bb6c384dc9ab58", - "29aee80bf9b9456c990593dfc7a4e58a", - "d178f765541e4e3a9c69b58caf9c96f0", - "4c7e66f9e87a4fd8b858c3a6fa805c5d", - "63c503a9f1ea47d6ba9bcf20fe1d231f", - "fc125b6ffbad4f5ab1a7449cd0d47db8", - "7405988f813d44db9ca121c367e7024e", - "3c6f8be2defd4be49b45d69c700403c6", - "bbc2fa5c2866469b813213929c580c03", - "ae7a331177a841f48b8dc4846f610468", - "9e18b47261cf4ed2bdecd78faec77eef", - "6265f2a43b5b415e8df0d20ba48c6781", - "5ba236ee520c40219ca27240fdfa9239", - "e97b85940f9147b0939ef9e95d04ed82", - "9b11abb211234089815a5aba90b32b00", - "547d38b3dd05492eb1f152ae528701fa", - "9a8c0b47067e42b1b636d7258db9d10f", - "91f4b5d4effa4f61a4aaa75e9a21d178", - "09faf72ed0994b28a35deb20a3268bee", - "334c134d2eea4ef794bcbc4295c44277", - "2993c9990ce8460e8d314ce7ccc84ee5", - "561df268f4834899a6112b5250b13555", - "53bd8312211d421abd50e7fa5229d9e9", - "139e6a68a879488b852ca1249b8954b8", - "021c2ef3dd4a4a02bce48b5cc5f0d896", - "d1e05b541aab4d00ac2a01722ae8eb01", - "e38f698d2e4045899ece23b479fe1086", - "f961a76c3ad0439d875bc5950fe98b08", - "a8673441e1e34dd9baef637896de1247", - "fe5655c3c01f4769aaeb83c52c61b92d", - "3e2e9bc2d78d44aa9462c749a70ddcbe", - "36d5f7bfde984468abf7e89ce75f4779", - "720a4cb1483c4417a0f739126004e1b5", - "27045133357d4c5293a484d238a9b3d9", - "1a2fa894019641858a93470eb1c1e638", - "1020fd907d82413b95016cf53640f97d", - "100c2c9887934ae59d9047fd91c02a9b", - "7304170c13d044f69259e9eabd59af38", - "f7c25091b458473eac34a514c502db93", - "b8001228821a439dbc541cb13a00f7be", - "0eef0571144f40839d8436ac73325cd7", - "c483e6194b65457fbe65f06c1c35a2d3", - "df090948c524402dad2ee050ecd9a94b", - "de92bfa661574935abe3c20198177469", - "fa866082b5d4442bb427b53207bdc406", - "7011f453f677422ba9eec44da61455fa", - "a57ed11c76d742458d86c302ecd836e5", - "587cc0aa3b0a405198f5f20e8f5290b7", - "20a671bb64894fc6ba957a4f47d6d081", - "67371e0ee5d647ebb9605ceb814bf98d", - "d615a70949184021beb6f38deab4e61d", - "ae2512bac389487bab96929404d9c86d", - "d478194e42784006ab4b414b821b869d", - "9c1b559ce0684e6689da1d1ff071c575", - "922a46229dd04d2f9878688101f0c03e", - "fe9aa3d6e0264868a5c6d0335961bd89", - "62cef00d67784ec8b0245817171ac0f2", - "2a05597a37d54394bca4abe74d815de9", - "587082b40e2d4d9b97712de288426e14", - "1df178391f794be88db9a759b5d7773e", - "55a50b5aa57a42cb895e8e56514834ec", - "26395615086c4991bcb5869772b9877f", - "f414baf5a08243f080f5567a674bef14", - "a63fabf5342f4de5b2b6f8c85bd5ab34", - "3aa5d75e3ac74a5c8a4f633cf0e1137a", - "76772d651ab547529f9485452f9d5847", - "73bab41992854beb83e906ea40ff0540", - "47c1f99c583c4253892c324572be9965", - "77b19f664da24c10ab3c015055cf380c", - "c9987ef8b8ef43f4beac6c90ba7a5675", - "737c0621e7894598941f60eb42d7933f", - "168f860653c5451b88eac3ea93d336b4", - "cf6520aed61a4601a5ae74e3daa306b6", - "154b6f55dc384a9287ac74f9e1b6fd7d", - "5228bf0766c5482e8352c687a8297ad0", - "ca18f3f9d42942e391e921d667763b5f", - "558ac0bb64684361a329936cab181b0f", - "c7a00881794f43899c39a545b96645ef", - "143b6a615ac648059d8319a0347fcb0f", - "60739821c5e94772bb21de4a8d7cbbda", - "b7c13054db244fe3880e3a3a108c6970", - "09fb76638d8244628964e5ee289604eb", - "69312f9c2018452aa33dd38ed8eb89c1", - "85fe425b1f8b438f832d3eec0aae4055", - "81ad376665a34e67a29faf1b5c4a2b8e", - "8ac9cc6556ae4a77aeb9f2cddb435ba2", - "571482a8dbd043f89d007bfb301ecabb", - "bed90d1e83794b9e9a64b5b4fa9c4b78", - "0165cf2cfe584db0ac8b5557dc07613e", - "74d4366d3f744617b065e3a3e6fbf523", - "a90d78647c7c4e2d848a03f68788ed28", - "9e2356bdc868461b9b024ac2c4354644", - "2696b888414447da8fc0222ddda62c85", - "c43a10ccd24c4881a4046261979f93df", - "68f42e05923a4835aea321c94c9d16c0", - "eed5934aeefe447b8d024a982cb72659", - "c3c2cdd7412d4290acdd3fd0ea8c0732", - "8c4ac42cdcd24291a948bbcb827c029c", - "f370a8cb3f29435794ad774fffdc86de", - "18bfb1396330461ebb5ae3deba83005c", - "0e93210d5abe4a2db3a1781fd73fea33", - "7a80d98e86d548a8abf10620cd2220ae", - "a9e4dc95bb854d2bbf51a8d280c4218e", - "404144853dfe4ce3ade5f0efc37befaf", - "6d10dea71e714f94bb5958d813f649cc", - "10bdbdfd2d7447289efe884cee4b1af8", - "7f0290b0c09d4c6cbe865e4e2f609ffd", - "6c2810005ade4f76a63e4f68cc1b5766", - "49c5f6712e6648428d2152cd18210c23", - "bd56db73d83e488b9d47394e7f8250bc", - "e33ebc3aba34474aba698db97b0744d9", - "3befae3deb6f486e95d7be0ead544323", - "69d99eb2a9d448979d06f1e51fc32c19", - "40d09355e35d4b34926054a5d8aa5919", - "f1711e1cc20343f98863e9b8afda5866", - "7f8f098cbb3d4c35a82e8129488efe14", - "0c4811beb5b94b258e660474f4863a4e", - "9b3d817ffbf843c8864e1221f53bc93a", - "a77747b70d4e46d78546c2d973f9e655", - "c538071256084246aafbd2a8438c854e", - "cb34e63faca84745892eb27926a94aeb", - "817ac325411942598e38570e44a1cd78", - "fb7d2df2338d4e30a759ac37949ae14c", - "397428e309ea4d05ab2f4ce9ed51187d", - "4e4e7d320a014ea0b97fb403c2e12b0d", - "55b34edaa5d247cd9731cacec3d78cc0", - "739248a24c334db6931c7102398c65de", - "f6f213069cfc4349a604183dc315c015", - "6a3e6e3bd9614f2293febcdd4aaa6c2b", - "28b80d3c0af94f4ab4374dda65c9fabf", - "688d7fed51c34b86aaa9e0ba4e877249", - "79a76a13392846448e24ecff76664abe", - "0196ea2cebcd4cc88c698ea2bd6d59a0", - "18e00e793dd247ccac363d800cf97666", - "8c63d714ef8d407d86c7b8e026445b2e", - "c8a2be9cd4774bb7a08fbb4056792603", - "ded6fa414ad9445f9260b4894cb29a3e", - "085f457e019b4e6994f1cbd274c27f81", - "118792e005ac4e6ab6f1886dbaf0300b", - "426e531c95d846b3b58e47b6d2ecfac5", - "b128cccc1ee2488c8cc07659a7c293a2", - "452fc8ae38944c1f8429ac67a8dc78e2", - "b3c71d44d1e047feac2f1203d99903f4", - "dd937f989eb24a6b870a00152af8fcda", - "899636029d47449b9d8f7e0dfe478aa3", - "5f454dbaf8694be889760d87a7abc0b9", - "619ccc9bb0ed4f7886e1c2edd622b24c", - "b59050f64b07415fb42e80dd9fcc2959", - "13074abdbcf34ff7a0bf0e38d2e66b86", - "376fb75d58e74233ba50671bd8bca557", - "417be0799afd44f78166b6ee7e7e35f8", - "e2cf4737e83f43a997230d6604770bd1", - "918ca0d532eb4865991054a7338a27e6", - "a3049ec66aea42fbb7b6338140ea967b", - "c9db744e88e54d45bb992aca6a6e597e", - "b7421fb32b6e47e9b2ffc61819a09683", - "c33ce28e496e4b50965c628f09d06e3e", - "dc5c870a1ec045b49d592fb57aa3cc3b", - "ed48954a1ac4493d804e10939517fb12", - "73479fd0479f40e5b41c5afd34972e48" - ] - }, - "id": "IMtsAbVj-_JH", - "outputId": "179c7bd8-2ea9-499d-a628-26bd77cf9f89" + "id": "oY5qbVGL-_JF" }, "outputs": [], "source": [ - "m = hypercoast.Map()\n", - "m.add_basemap(\"Hybrid\")\n", - "wavelengths = [450, 550, 650]\n", - "m.add_pace(\n", - " dataset, wavelengths, indexes=[3, 2, 1], vmin=0, vmax=0.02, layer_name=\"PACE\"\n", - ")\n", - "m.add(\"spectral\")\n", - "style = {\"weight\": 2, \"color\": \"red\"}\n", - "m.add_kml(kml_path, style=style, layer_name=\"Hypoxia Path\", info_mode=None)\n", - "m.add_points_from_xy(\n", - " df_filtered,\n", - " x=\"Lon\",\n", - " y=\"Lat\",\n", - " max_cluster_radius=50,\n", - " layer_name=\"Hypoxia Data Points\",\n", - ")\n", - "m.set_center(-91.46118, 28.89758, zoom=8)\n", - "m\n", - "dataset" + "filepath = \"data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc\"\n", + "dataset = hypercoast.read_pace(filepath)\n", + "# dataset" ] }, { "cell_type": "markdown", - "metadata": { - "id": "3EK3XYY2-_JI" - }, + "metadata": {}, "source": [ - "![](https://i.imgur.com/JdgotIT.gif)" + "![image](https://github.com/user-attachments/assets/56b1fae3-9acf-4ee1-8dc9-7f6784bedf88)" ] }, { @@ -656,7 +144,7 @@ "id": "NYo6cw13-_JI" }, "source": [ - "Compute band ratios." + "## Compute band ratios" ] }, { @@ -672,7 +160,8 @@ " (da.sel(wavelength=650) > da.sel(wavelength=620))\n", " & (da.sel(wavelength=701) > da.sel(wavelength=681))\n", " & (da.sel(wavelength=701) > da.sel(wavelength=450))\n", - ")" + ")\n", + "# data" ] }, { @@ -692,7 +181,7 @@ "id": "EuKeNoNp-_JJ" }, "source": [ - "Visualize the selected region based on band ratios." + "## Visualize the selected region based on band ratios" ] }, { @@ -751,7 +240,7 @@ "id": "7WHdt4El-_JJ" }, "source": [ - "## What you can do next about Cyanobacteria using PACE???\n", + "## Cyanobacteria and Spectral Angle Mapper\n", "\n", "Spectral Angle Mapper: Spectral similarity\n", "Input: library of Cyanobacteria bloom Rrs spectra with Chla at different levels\n", @@ -762,17 +251,22 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "## K-means applied to the whole image" + ] }, { - "cell_type": "markdown", - "metadata": {}, + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "jDrdL13RcLFm" + }, + "outputs": [], "source": [ - "# K-means applied to whole image" + "import numpy as np\n", + "from sklearn.cluster import KMeans" ] }, { @@ -823,20 +317,6 @@ "print(\"Size of each dimension:\", da.sizes)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "jDrdL13RcLFm" - }, - "outputs": [], - "source": [ - "import xarray as xr\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "from sklearn.cluster import KMeans" - ] - }, { "cell_type": "code", "execution_count": null, @@ -914,6 +394,18 @@ "cluster_labels = labels.reshape(da.shape[:-1])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import matplotlib.colors as mcolors\n", + "import cartopy.crs as ccrs\n", + "import cartopy.feature as cfeature" + ] + }, { "cell_type": "code", "execution_count": null, @@ -927,11 +419,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import matplotlib.colors as mcolors\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "\n", "# Assume 'cluster_labels' contains the K-means classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -946,7 +433,7 @@ "\n", "# Create a figure and axis with the correct map projection\n", "fig, ax = plt.subplots(\n", - " figsize=(12, 10), dpi=400, subplot_kw={\"projection\": ccrs.PlateCarree()}\n", + " figsize=(6, 4), dpi=200, subplot_kw={\"projection\": ccrs.PlateCarree()}\n", ")\n", "\n", "# Plot the K-means classification results on the map\n", @@ -993,7 +480,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Keans applied to selected pixels" + "## Keans applied to selected pixels" ] }, { @@ -1004,12 +491,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import matplotlib.colors as mcolors\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import numpy as np\n", - "\n", "# Assume 'cluster_labels' contains the K-means classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1034,7 +515,7 @@ "\n", "# Create a figure and axis with the correct map projection\n", "fig, ax = plt.subplots(\n", - " figsize=(12, 10), dpi=400, subplot_kw={\"projection\": ccrs.PlateCarree()}\n", + " figsize=(6, 4), dpi=200, subplot_kw={\"projection\": ccrs.PlateCarree()}\n", ")\n", "\n", "# Plot the filtered K-means classification results on the map\n", @@ -1081,7 +562,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# PCA + SAM applied to whole image" + "## PCA + SAM applied to whole image" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.decomposition import PCA" ] }, { @@ -1129,8 +619,6 @@ }, "outputs": [], "source": [ - "from sklearn.decomposition import PCA\n", - "\n", "# Apply PCA to reduce dimensionality\n", "pca = PCA(n_components=3)\n", "pca_data = pca.fit_transform(reshaped_data_no_nan)\n", @@ -1209,11 +697,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import matplotlib.colors as mcolors\n", - "\n", "# Assume 'best_match_full' contains the SAM classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1279,12 +762,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import matplotlib.colors as mcolors\n", - "import numpy as np\n", - "\n", "# Assume 'best_match_full' contains the SAM classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1348,12 +825,6 @@ }, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import matplotlib.colors as mcolors\n", - "import numpy as np\n", - "\n", "# Assume 'best_match_full' contains the SAM classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1423,7 +894,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# SAM" + "## Spectral Angle Mapper (SAM)" ] }, { @@ -1432,13 +903,11 @@ "metadata": {}, "outputs": [], "source": [ - "import xarray as xr\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import matplotlib.colors as mcolors\n", - "from scipy.interpolate import interp1d\n", - "import hypercoast" + "from scipy.interpolate import interp1d" ] }, { @@ -1448,20 +917,11 @@ "outputs": [], "source": [ "# Load the netCDF data\n", - "file_path = \"./PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc\"\n", + "file_path = \"data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc\"\n", "dataset = hypercoast.read_pace(file_path)\n", "da = dataset[\"Rrs\"] # Assuming 'Rrs' contains the reflectance data" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(dataset)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -1469,15 +929,7 @@ "outputs": [], "source": [ "# Extract PACE wavelengths\n", - "pace_wavelengths = da[\"wavelength\"].values" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ + "pace_wavelengths = da[\"wavelength\"].values\n", "print(pace_wavelengths)" ] }, @@ -1504,6 +956,23 @@ " return resampled_spectra" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Download the SAM spectral library:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "url = \"https://github.com/opengeos/datasets/releases/download/hypercoast/SAM_spectral_library.zip\"\n", + "hypercoast.download_file(url)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1639,12 +1108,6 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import matplotlib.colors as mcolors\n", - "import numpy as np\n", - "\n", "# Assume 'best_match' contains the SAM classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1710,12 +1173,6 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "import cartopy.crs as ccrs\n", - "import cartopy.feature as cfeature\n", - "import matplotlib.colors as mcolors\n", - "import numpy as np\n", - "\n", "# Assume 'best_match' contains the SAM classification results reshaped to the original spatial dimensions\n", "# Also assume that 'da' has the original latitude and longitude data\n", "latitudes = da.coords[\"latitude\"].values\n", @@ -1812,7 +1269,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/hypercoast/pace.py b/hypercoast/pace.py index d9cd63a..446a679 100644 --- a/hypercoast/pace.py +++ b/hypercoast/pace.py @@ -592,8 +592,8 @@ def grid_pace_bgc( Args: dataset (xr.Dataset): The input dataset containing PACE BGC data with latitude and longitude coordinates. variable (str, optional): The variable within the dataset to grid. Can be - one of chlor_a, carbon_phyto, poc, chlor_a_unc, carbon_phyto_unc, and l2_flags. - Defaults to "chlor_a". + one of chlor_a, carbon_phyto, poc, chlor_a_unc, carbon_phyto_unc, and l2_flags. + Defaults to "chlor_a". method (str, optional): The interpolation method to use. Options include "nearest", "linear", and "cubic". Defaults to "nearest". **kwargs (Any): Additional keyword arguments to pass to the xr.Dataset creation. diff --git a/mkdocs.yml b/mkdocs.yml index 72ac7a6..75ecb95 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,7 +60,6 @@ plugins: "image_slicing.ipynb", "temperature.ipynb", "pace_oci_l1.ipynb", - "pace_cyano.ipynb", ] markdown_extensions: @@ -105,6 +104,7 @@ nav: - examples/temperature.ipynb - examples/pace_oci_l1.ipynb - examples/pace_oci_l2.ipynb + - examples/pace_cyano.ipynb - examples/multispectral.ipynb - examples/pca.ipynb - examples/field_data.ipynb diff --git a/pyproject.toml b/pyproject.toml index 72a12aa..f6ad0b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ extra = [ "geopandas", "openpyxl", "pyvista[jupyter]", + "scikit-learn", ] diff --git a/requirements_dev.txt b/requirements_dev.txt index f89ef3a..705bd29 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -30,6 +30,7 @@ pytest pytest-runner pyvista reuse>=4.0.3 +scikit-learn sphinx twine watchdog