Skip to content

Commit 9854ef7

Browse files
committed
Add qa_total_count_clear to the outputs
Add qa_total_count_clear to the outputs Add some GDAL parameters to get around processes giving up to quickly when a scene is in cold storage. os.environ["GDAL_HTTP_TIMEOUT"] = "300" # default is 30s os.environ["GDAL_HTTP_MAX_RETRY"] = "10" # default is 0 os.environ["GDAL_HTTP_RETRY_DELAY"] = "5" # seconds between retries
1 parent 4d68ff1 commit 9854ef7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

intertidal/composites.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def tidal_composites(
198198
log.info(f"{run_id}: Loading red band to identify nodata pixels")
199199
nodata = satellite_ds.nbart_red.nodata
200200
nodata_array = (satellite_ds.nbart_red != nodata).compute()
201+
202+
#calculate the total clear pixel count for each pixel
203+
qa_total_count_clear = nodata_array.copy().sum(dim="time").astype("int16")
201204

202205
# Mask tides to make nodata match satellite data array
203206
tides_highres = tides_highres.where(nodata_array)
@@ -262,6 +265,9 @@ def tidal_composites(
262265
(ds_low_masked.nbart_red != nodata).sum(dim="time").astype("int16")
263266
)
264267

268+
# Add the total count clear (Only add once)
269+
ds_lowtide["qa_total_count_clear"] = qa_total_count_clear
270+
265271
# Add low and high tide thresholds to the output datasets
266272
ds_lowtide["qa_low_threshold"] = low_threshold
267273
ds_hightide["qa_high_threshold"] = high_threshold
@@ -484,6 +490,11 @@ def tidal_composites_cli(
484490
# Record params in logs
485491
log.info(f"{run_id}: Using parameters {input_params}")
486492

493+
# This is to help when scenes need to be moved from s3 cold storage
494+
os.environ["GDAL_HTTP_TIMEOUT"] = "300" # default is 30s
495+
os.environ["GDAL_HTTP_MAX_RETRY"] = "10" # default is 0
496+
os.environ["GDAL_HTTP_RETRY_DELAY"] = "5" # seconds between retries
497+
487498
# Configure S3
488499
configure_s3_access(cloud_defaults=True, aws_unsigned=aws_unsigned)
489500

@@ -593,6 +604,7 @@ def tidal_composites_cli(
593604
"qa_low_threshold": (np.float32, np.nan),
594605
"qa_high_threshold": (np.float32, np.nan),
595606
"qa_count_clear": (np.int16, -999),
607+
"qa_total_count_clear": (np.int16, -999),
596608
}
597609

598610
# Sets correct dtypes and nodata

0 commit comments

Comments
 (0)