Skip to content

Commit dfbcd62

Browse files
deprecating pull_MODIS.jl with artifacts in experiments/integrated/fluxnet
using ClimaArtifact's modis_lai_fluxnet_sites to deprecate and remove…
2 parents 209b792 + 8b653bf commit dfbcd62

File tree

4 files changed

+39
-81
lines changed

4 files changed

+39
-81
lines changed

Artifacts.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,10 @@ git-tree-sha1 = "c35ba0e899040cb8153226ab751f69100f475d39"
185185
[[mizoguchi_soil_freezing_data.download]]
186186
sha256 = "0027cc080ba45ba33dc790b176ec2854353ce7dce4eae4bef72963b0dd944e0b"
187187
url = "https://caltech.box.com/shared/static/tn1bnqjmegyetw5kzd2ixq5pbnb05s3u.gz"
188+
189+
[modis_lai_fluxnet_sites]
190+
git-tree-sha1 = "cdcc1708832654d2209d267e01a3893c4b25c085"
191+
192+
[[modis_lai_fluxnet_sites.download]]
193+
sha256 = "c74780775d98b56eed74222377604272658f59686d4d7881c7b815b6c230080b"
194+
url = "https://caltech.box.com/shared/static/g6vubma6vcxulb9fl0pvzq6v0oto4iu3.gz"

experiments/integrated/fluxnet/met_drivers_FLUXNET.jl

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import ClimaComms
1212

1313
context = ClimaComms.context()
1414

15-
# Methods for reading in the LAI data from MODIS data
16-
include(
17-
joinpath(pkgdir(ClimaLand), "experiments/integrated/fluxnet/pull_MODIS.jl"),
18-
)
19-
2015
data_path = ClimaLand.Artifacts.experiment_fluxnet_data_path(site_ID)
2116
driver_data = readdlm(data_path, ',')
2217

@@ -180,24 +175,26 @@ radiation = ClimaLand.PrescribedRadiativeFluxes(
180175
earth_param_set = earth_param_set,
181176
)
182177

183-
# Start and end dates of data in MODIS format
184-
modis_start_date = "A$(Dates.year(UTC_DATETIME[1]))$(lpad(Dates.dayofyear(UTC_DATETIME[1]), 3, "0"))"
185-
modis_end_date = "A$(Dates.year(UTC_DATETIME[end]))$(lpad(Dates.dayofyear(UTC_DATETIME[end]), 3, "0"))"
186-
187-
MODIS_LAI = single_col_data_matrix(
188-
parse_response(
189-
check_response(
190-
send_get_subset(
191-
"MCD15A2H",
192-
modis_start_date,
193-
modis_end_date,
194-
site_ID,
195-
band = "Lai_500m",
196-
),
197-
),
198-
),
178+
# Desired start and end dates of data in MODIS format
179+
modis_start_date = DateTime(
180+
"$(Dates.year(UTC_DATETIME[1]))-$(Dates.month(UTC_DATETIME[1]))-$(Dates.day(UTC_DATETIME[1]))T00:00:00.0",
181+
)
182+
modis_end_date = DateTime(
183+
"$(Dates.year(UTC_DATETIME[end]))-$(Dates.month(UTC_DATETIME[end]))-$(Dates.day(UTC_DATETIME[end]))T00:00:00.0",
199184
)
200185

186+
MODIS_LAI_path = ClimaLand.Artifacts.get_modis_lai_fluxnet_data(site_ID)
187+
MODIS_LAI_raw, header = readdlm(MODIS_LAI_path, ',', header = true)
188+
dates = DateTime.(MODIS_LAI_raw[:, 1])
189+
190+
# Trim MODIS_LAI to start_date and end_date
191+
indices = findall(d -> modis_start_date <= d <= modis_end_date, dates)
192+
filtered_rows = MODIS_LAI_raw[indices, :]
193+
filtered_dates = dates[indices]
194+
195+
# Create final matrix with properly formatted data for computation
196+
MODIS_LAI = hcat(filtered_dates, filtered_rows[:, 2])
197+
201198
LAI_dt = Second(MODIS_LAI[2, 1] - MODIS_LAI[1, 1]).value
202199
LAI_seconds = FT.(0:LAI_dt:((length(MODIS_LAI[:, 1]) - 1) * LAI_dt))
203200

experiments/integrated/fluxnet/pull_MODIS.jl

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/Artifacts.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,4 +532,18 @@ function era5_surface_data_1979_2024_path(; context = nothing)
532532
)
533533
end
534534

535+
"""
536+
get_modis_lai_fluxnet_data(site_ID; context = nothing)
537+
Returns the path to the folder that contains MODIS LAI data at:
538+
US-Ha1, US-Var, US-NR1, US-Ha1
539+
from 2002 to 2025.
540+
"""
541+
function get_modis_lai_fluxnet_data(site_ID; context = nothing)
542+
@assert site_ID ("US-MOz", "US-Var", "US-NR1", "US-Ha1")
543+
544+
folder_path = @clima_artifact("modis_lai_fluxnet_sites", context)
545+
data_path = joinpath(folder_path, "modis_lai_$(site_ID).csv")
546+
return data_path
547+
end
548+
535549
end

0 commit comments

Comments
 (0)