diff --git a/pace_update_all.py b/pace_update_all.py new file mode 100644 index 0000000..8052e60 --- /dev/null +++ b/pace_update_all.py @@ -0,0 +1,43 @@ +import hypercoast +import earthaccess +import leafmap +import datetime +import shutil + +auth = earthaccess.login(strategy="environment") + +end_date = datetime.date.today() +start_date = end_date - datetime.timedelta(days=300) + +start_date = start_date.strftime("%Y-%m-%d") +end_date = end_date.strftime("%Y-%m-%d") + +results = earthaccess.search_data( + short_name="PACE_OCI_L3M_CHL_NRT", + temporal=(start_date, end_date), + granule_name="*.DAY.*.0p1deg.*", +) + +hypercoast.download_nasa_data(results, "data") + +files = leafmap.find_files("data", "*.nc") +for index, file in enumerate(files[6:]): + data = files[index : index + 7] + + array = hypercoast.read_pace_chla(data) + date = array.date.max().values.tolist() + mean_array = array.mean(dim="date") + + filename = f"chla/chla_{date}.tif" + latest = "chla/latest.tif" + hypercoast.pace_chla_to_image(mean_array, filename) + +# shutil.copy(filename, latest) +# print(f"Updated chla image: {filename}") + +# username = "opengeos" +# repository = "pace-data" +# tag_name = "chla" +# release_id = leafmap.github_get_release_id_by_tag(username, repository, tag_name) +# leafmap.github_upload_asset_to_release(username, repository, release_id, filename) +# leafmap.github_upload_asset_to_release(username, repository, release_id, latest)