ECOv003-L2T-STARS 1.0.1__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ECOv003_L2T_STARS/BRDF/BRDF.py +57 -0
- ECOv003_L2T_STARS/BRDF/SZA.py +65 -0
- ECOv003_L2T_STARS/BRDF/__init__.py +1 -0
- ECOv003_L2T_STARS/BRDF/statistical_radiative_transport.txt +90 -0
- ECOv003_L2T_STARS/BRDF/version.txt +1 -0
- ECOv003_L2T_STARS/ECOv003_DL.py +527 -0
- ECOv003_L2T_STARS/ECOv003_DL.xml +47 -0
- ECOv003_L2T_STARS/ECOv003_L2T_STARS.py +162 -0
- ECOv003_L2T_STARS/ECOv003_L2T_STARS.xml +47 -0
- ECOv003_L2T_STARS/L2TSTARSConfig.py +188 -0
- ECOv003_L2T_STARS/L2T_STARS.py +489 -0
- ECOv003_L2T_STARS/LPDAAC/LPDAACDataPool.py +444 -0
- ECOv003_L2T_STARS/LPDAAC/__init__.py +9 -0
- ECOv003_L2T_STARS/LPDAAC/version.txt +1 -0
- ECOv003_L2T_STARS/Manifest.toml +2332 -0
- ECOv003_L2T_STARS/Project.toml +14 -0
- ECOv003_L2T_STARS/VIIRS/VIIRSDataPool.py +294 -0
- ECOv003_L2T_STARS/VIIRS/VIIRSDownloader.py +26 -0
- ECOv003_L2T_STARS/VIIRS/VIIRS_CMR_LOGIN.py +36 -0
- ECOv003_L2T_STARS/VIIRS/VNP09GA.py +1277 -0
- ECOv003_L2T_STARS/VIIRS/VNP43IA4.py +288 -0
- ECOv003_L2T_STARS/VIIRS/VNP43MA3.py +323 -0
- ECOv003_L2T_STARS/VIIRS/__init__.py +9 -0
- ECOv003_L2T_STARS/VIIRS/version.txt +1 -0
- ECOv003_L2T_STARS/VNP43NRT/VNP43NRT.py +863 -0
- ECOv003_L2T_STARS/VNP43NRT/__init__.py +1 -0
- ECOv003_L2T_STARS/VNP43NRT/process_VNP43NRT.jl +169 -0
- ECOv003_L2T_STARS/VNP43NRT/version.txt +1 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/Manifest.toml +995 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/Project.toml +15 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/__init__.py +0 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/instantiate.jl +25 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/instantiate.py +13 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/src/VNP43NRT.jl +411 -0
- ECOv003_L2T_STARS/VNP43NRT_jl/src/__init__.py +0 -0
- ECOv003_L2T_STARS/__init__.py +3 -0
- ECOv003_L2T_STARS/calibrate_fine_to_coarse.py +60 -0
- ECOv003_L2T_STARS/constants.py +38 -0
- ECOv003_L2T_STARS/daterange/__init__.py +1 -0
- ECOv003_L2T_STARS/daterange/daterange.py +35 -0
- ECOv003_L2T_STARS/generate_L2T_STARS_runconfig.py +249 -0
- ECOv003_L2T_STARS/generate_NDVI_coarse_directory.py +21 -0
- ECOv003_L2T_STARS/generate_NDVI_coarse_image.py +30 -0
- ECOv003_L2T_STARS/generate_NDVI_fine_directory.py +14 -0
- ECOv003_L2T_STARS/generate_NDVI_fine_image.py +28 -0
- ECOv003_L2T_STARS/generate_STARS_inputs.py +231 -0
- ECOv003_L2T_STARS/generate_albedo_coarse_directory.py +18 -0
- ECOv003_L2T_STARS/generate_albedo_coarse_image.py +30 -0
- ECOv003_L2T_STARS/generate_albedo_fine_directory.py +17 -0
- ECOv003_L2T_STARS/generate_albedo_fine_image.py +30 -0
- ECOv003_L2T_STARS/generate_filename.py +37 -0
- ECOv003_L2T_STARS/generate_input_staging_directory.py +23 -0
- ECOv003_L2T_STARS/generate_model_state_tile_date_directory.py +28 -0
- ECOv003_L2T_STARS/generate_output_directory.py +28 -0
- ECOv003_L2T_STARS/install_STARS_jl.py +43 -0
- ECOv003_L2T_STARS/instantiate_STARS_jl.py +38 -0
- ECOv003_L2T_STARS/load_prior.py +248 -0
- ECOv003_L2T_STARS/prior.py +56 -0
- ECOv003_L2T_STARS/process_ECOSTRESS_data_fusion_distributed_bias.jl +420 -0
- ECOv003_L2T_STARS/process_STARS_product.py +507 -0
- ECOv003_L2T_STARS/process_julia_data_fusion.py +110 -0
- ECOv003_L2T_STARS/retrieve_STARS_sources.py +101 -0
- ECOv003_L2T_STARS/runconfig.py +70 -0
- ECOv003_L2T_STARS/timer/__init__.py +1 -0
- ECOv003_L2T_STARS/timer/timer.py +77 -0
- ECOv003_L2T_STARS/version.py +8 -0
- ECOv003_L2T_STARS/version.txt +1 -0
- {ECOv003_L2T_STARS-1.0.1.dist-info → ecov003_l2t_stars-1.1.0.dist-info}/METADATA +30 -23
- ecov003_l2t_stars-1.1.0.dist-info/RECORD +73 -0
- {ECOv003_L2T_STARS-1.0.1.dist-info → ecov003_l2t_stars-1.1.0.dist-info}/WHEEL +1 -1
- ecov003_l2t_stars-1.1.0.dist-info/entry_points.txt +3 -0
- ecov003_l2t_stars-1.1.0.dist-info/top_level.txt +1 -0
- ECOv003_L2T_STARS-1.0.1.dist-info/RECORD +0 -5
- ECOv003_L2T_STARS-1.0.1.dist-info/top_level.txt +0 -1
- {ECOv003_L2T_STARS-1.0.1.dist-info → ecov003_l2t_stars-1.1.0.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
from .VNP43NRT import *
|
@@ -0,0 +1,169 @@
|
|
1
|
+
using Glob
|
2
|
+
using Dates
|
3
|
+
using Rasters
|
4
|
+
using DimensionalData.Dimensions.LookupArrays
|
5
|
+
import ArchGDAL
|
6
|
+
using VNP43NRT
|
7
|
+
using Logging
|
8
|
+
|
9
|
+
struct CustomLogger <: AbstractLogger
|
10
|
+
stream::IO
|
11
|
+
min_level::LogLevel
|
12
|
+
end
|
13
|
+
|
14
|
+
Logging.min_enabled_level(logger::CustomLogger) = logger.min_level
|
15
|
+
|
16
|
+
function Logging.shouldlog(logger::CustomLogger, level, _module, group, id)
|
17
|
+
return level >= logger.min_level
|
18
|
+
end
|
19
|
+
|
20
|
+
function Logging.handle_message(logger::CustomLogger, level, message, _module, group, id, file, line; kwargs...)
|
21
|
+
t = Dates.format(now(), "yyyy-mm-dd HH:MM:SS")
|
22
|
+
println(logger.stream, "[$t $(uppercase(string(level)))] $message")
|
23
|
+
end
|
24
|
+
|
25
|
+
global_logger(CustomLogger(stdout, Logging.Info))
|
26
|
+
|
27
|
+
SINUSOIDAL_CRS = WellKnownText("PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"unknown\",SPHEROID[\"unknown\",6371007.181,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Sinusoidal\"],PARAMETER[\"longitude_of_center\",0],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]")
|
28
|
+
|
29
|
+
band = ARGS[1]
|
30
|
+
@info "band: $(band)"
|
31
|
+
h = parse(Int64, ARGS[2])
|
32
|
+
v = parse(Int64, ARGS[3])
|
33
|
+
@info "h: $(h) v: $(v)"
|
34
|
+
tile_width_cells = parse(Int64, ARGS[4])
|
35
|
+
@info "tile width cells: $(tile_width_cells)"
|
36
|
+
start_date = Date(ARGS[5])
|
37
|
+
@info "start date: $(start_date)"
|
38
|
+
end_date = Date(ARGS[6])
|
39
|
+
@info "end date: $(end_date)"
|
40
|
+
reflectance_directory = ARGS[7]
|
41
|
+
@info "reflectance directory: $(reflectance_directory)"
|
42
|
+
solar_zenith_directory = ARGS[8]
|
43
|
+
@info "solar zenith directory: $(solar_zenith_directory)"
|
44
|
+
sensor_zenith_directory = ARGS[9]
|
45
|
+
@info "sensor zenith directory: $(sensor_zenith_directory)"
|
46
|
+
relative_azimuth_directory = ARGS[10]
|
47
|
+
@info "relative azimuth directory: $(relative_azimuth_directory)"
|
48
|
+
SZA_filename = ARGS[11]
|
49
|
+
@info "solar zenith noon file: $(SZA_filename)"
|
50
|
+
output_directory = ARGS[12]
|
51
|
+
@info "output directory: $(output_directory)"
|
52
|
+
|
53
|
+
reflectance_image_filenames = sort(glob("*.tif", reflectance_directory))
|
54
|
+
|
55
|
+
dates = [start_date + Day(d - 1) for d in 1:((end_date - start_date).value + 1)]
|
56
|
+
|
57
|
+
t = Ti(dates)
|
58
|
+
|
59
|
+
x_dim, y_dim = sinusoidal_tile_dims(h, v, tile_width_cells)
|
60
|
+
|
61
|
+
function load_timeseries(directory::String, variable::String, start_date::Date, end_date::Date, x_dim, y_dim)
|
62
|
+
@info "searching directory: $(directory)"
|
63
|
+
filenames = sort(glob("*.tif", directory))
|
64
|
+
images = []
|
65
|
+
|
66
|
+
dates = [start_date + Day(d - 1) for d in 1:((end_date - start_date).value + 1)]
|
67
|
+
|
68
|
+
for date in dates
|
69
|
+
date = Dates.format(date, dateformat"yyyy-mm-dd")
|
70
|
+
match = findfirst(x -> occursin(date, x), filenames)
|
71
|
+
|
72
|
+
if match === nothing
|
73
|
+
@info "$(variable) image is not available on $(date)"
|
74
|
+
image = Raster(fill(NaN, tile_width_cells, tile_width_cells, 1), dims=(x_dim, y_dim, Band(1:1)), missingval=NaN)
|
75
|
+
else
|
76
|
+
filename = filenames[match]
|
77
|
+
@info "ingesting $(variable) image on $(date): $(filename)"
|
78
|
+
image = Raster(filename, dims=(x_dim, y_dim, Band(1:1)))
|
79
|
+
end
|
80
|
+
|
81
|
+
push!(images, image)
|
82
|
+
end
|
83
|
+
|
84
|
+
return images
|
85
|
+
end
|
86
|
+
|
87
|
+
reflectance_images = load_timeseries(reflectance_directory, band, start_date, end_date, x_dim, y_dim)
|
88
|
+
|
89
|
+
function stack_timeseries(timeseries)
|
90
|
+
permutedims(hcat([vec(image) for image in timeseries]...), [1,2])
|
91
|
+
end
|
92
|
+
|
93
|
+
reflectance_stack = stack_timeseries(reflectance_images)
|
94
|
+
|
95
|
+
solar_zenith_images = load_timeseries(solar_zenith_directory, band, start_date, end_date, x_dim, y_dim)
|
96
|
+
solar_zenith_stack = stack_timeseries(solar_zenith_images)
|
97
|
+
|
98
|
+
sensor_zenith_images = load_timeseries(sensor_zenith_directory, band, start_date, end_date, x_dim, y_dim)
|
99
|
+
sensor_zenith_stack = stack_timeseries(sensor_zenith_images)
|
100
|
+
|
101
|
+
relative_azimuth_images = load_timeseries(relative_azimuth_directory, band, start_date, end_date, x_dim, y_dim)
|
102
|
+
relative_azimuth_stack = stack_timeseries(relative_azimuth_images)
|
103
|
+
|
104
|
+
SZA = Raster(SZA_filename)
|
105
|
+
SZA_flat = vec(SZA)
|
106
|
+
|
107
|
+
# --- Handle missing values: replace `missing` with `NaN` in all stacks and SZA_flat ---
|
108
|
+
|
109
|
+
function replace_missing_with_nan(arr)
|
110
|
+
return map(x -> ismissing(x) ? NaN : x, arr)
|
111
|
+
end
|
112
|
+
|
113
|
+
reflectance_stack = replace_missing_with_nan(reflectance_stack)
|
114
|
+
solar_zenith_stack = replace_missing_with_nan(solar_zenith_stack)
|
115
|
+
sensor_zenith_stack = replace_missing_with_nan(sensor_zenith_stack)
|
116
|
+
relative_azimuth_stack = replace_missing_with_nan(relative_azimuth_stack)
|
117
|
+
SZA_flat = replace_missing_with_nan(SZA_flat)
|
118
|
+
|
119
|
+
results = NRT_BRDF_all(reflectance_stack, solar_zenith_stack, sensor_zenith_stack, relative_azimuth_stack, SZA_flat)
|
120
|
+
|
121
|
+
mkpath(output_directory)
|
122
|
+
|
123
|
+
date_format = dateformat"yyyy-mm-dd"
|
124
|
+
date_stamp = Dates.format(end_date, date_format)
|
125
|
+
|
126
|
+
WSA = Raster(reshape(results[:,1], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
127
|
+
WSA_filename = joinpath(output_directory, "$(date_stamp)_WSA.tif")
|
128
|
+
@info "writing WSA: $(WSA_filename)"
|
129
|
+
write(WSA_filename, WSA; force=true)
|
130
|
+
|
131
|
+
BSA = Raster(reshape(results[:,2], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
132
|
+
BSA_filename = joinpath(output_directory, "$(date_stamp)_BSA.tif")
|
133
|
+
@info "writing BSA: $(BSA_filename)"
|
134
|
+
write(BSA_filename, BSA; force=true)
|
135
|
+
|
136
|
+
NBAR = Raster(reshape(results[:,3], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
137
|
+
NBAR_filename = joinpath(output_directory, "$(date_stamp)_NBAR.tif")
|
138
|
+
@info "writing NBAR: $(NBAR_filename)"
|
139
|
+
write(NBAR_filename, NBAR; force=true)
|
140
|
+
|
141
|
+
WSA_SE = Raster(reshape(results[:,4], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
142
|
+
WSA_SE_filename = joinpath(output_directory, "$(date_stamp)_WSA_SE.tif")
|
143
|
+
@info "writing WSA_SE: $(WSA_SE_filename)"
|
144
|
+
write(WSA_SE_filename, WSA_SE; force=true)
|
145
|
+
|
146
|
+
BSA_SE = Raster(reshape(results[:,5], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
147
|
+
BSA_SE_filename = joinpath(output_directory, "$(date_stamp)_BSA_SE.tif")
|
148
|
+
@info "writing BSA_SE: $(BSA_SE_filename)"
|
149
|
+
write(BSA_SE_filename, BSA_SE; force=true)
|
150
|
+
|
151
|
+
NBAR_SE = Raster(reshape(results[:,6], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
152
|
+
NBAR_SE_filename = joinpath(output_directory, "$(date_stamp)_NBAR_SE.tif")
|
153
|
+
@info "writing NBAR_SE: $(NBAR_SE_filename)"
|
154
|
+
write(NBAR_SE_filename, NBAR_SE; force=true)
|
155
|
+
|
156
|
+
BRDF_SE = Raster(reshape(results[:,7], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
157
|
+
BRDF_SE_filename = joinpath(output_directory, "$(date_stamp)_BRDF_SE.tif")
|
158
|
+
@info "writing BRDF_SE: $(BRDF_SE_filename)"
|
159
|
+
write(BRDF_SE_filename, BRDF_SE; force=true)
|
160
|
+
|
161
|
+
BRDF_R2 = Raster(reshape(results[:,8], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
162
|
+
BRDF_R2_filename = joinpath(output_directory, "$(date_stamp)_BRDF_R2.tif")
|
163
|
+
@info "writing BRDF_R2: $(BRDF_R2_filename)"
|
164
|
+
write(BRDF_R2_filename, BRDF_R2; force=true)
|
165
|
+
|
166
|
+
count = Raster(reshape(results[:,9], (tile_width_cells, tile_width_cells)), dims=(x_dim, y_dim), missingval=NaN)
|
167
|
+
count_filename = joinpath(output_directory, "$(date_stamp)_count.tif")
|
168
|
+
@info "writing count: $(count_filename)"
|
169
|
+
write(count_filename, count; force=true)
|
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|