Skip to content

Commit

Permalink
Add pace script
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Jul 2, 2024
1 parent ec970f1 commit 8f32d3e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pace_update_all.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8f32d3e

Please sign in to comment.