Skip to content

Commit

Permalink
FH: 1)Better input data cardinality handling. 2) Auxiliary slant rang…
Browse files Browse the repository at this point in the history
…e distances is now optional: mandatory only for FH with Spectral Shift Filtering enabled.

TOMO FH bug fix: median factor no more hard coded, now read from configuration.
  • Loading branch information
emanuelegiorgi committed Jan 18, 2023
1 parent 3accf6d commit a5e98e1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
18 changes: 15 additions & 3 deletions biopal/dataset_query/dataset_query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: BioPAL <[email protected]>
# SPDX-License-Identifier: MIT

import os
import os, sys
import logging
import collections
from shapely.geometry import MultiPoint
Expand Down Expand Up @@ -87,7 +87,7 @@ def _run(self, input_file):
"Cannot find any data which meets the conditions to run the processing: see the log warnings. \n"
)
logging.info("BIOMASS L2 Processor ended without any processing performed.")
return 0
sys.exit()

logging.info("Geographic Boundaries extracted [deg]:")
logging.info("Latitude min: " + str(geographic_boundaries.lat_min))
Expand Down Expand Up @@ -316,7 +316,11 @@ def data_select_by_date_and_boundaries(dataset_query_obj):
and not len(stacks_composition_only_boundaries_match)
and not len(stacks_composition_not_enough_acq)
):
logging.warning("Cannot find any data, the L1cRepository is empty")
logging.warning(
"Cannot find any data into the L1cRepository from {} to {}; data min date is {} anxd max date is {}".format(
start_date, stop_date, edge_values["date_min"], edge_values["date_max"]
)
)
pf_idx = 0

else:
Expand Down Expand Up @@ -389,6 +393,14 @@ def fill_stack_based_processing_obj(
average_covariance_folder = None
forest_height_folder = None

for stack_id, acquisitions_list in stack_composition.items():
if len(acquisitions_list) >= 4:
error_message = "FH algorithm is not compatibile with more than #3 acquisitions (#2 baselines), found #{} acquisitions instead.".format(
len(acquisitions_list)
)
logging.error(error_message)
raise InvalidInputError(error_message)

if input_params_obj.L2_product == "TOMO_FH":

stack_composition_TOMO = {}
Expand Down
2 changes: 1 addition & 1 deletion biopal/tomo/processing_TOMO.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class opt_str:
out_str = UpperThresholdForestHeight(tomo_cube, opt_str)
canopy_height = out_str.z
power_peak = out_str.peak
canopy_height = medfilt2d(canopy_height.astype("float64"), kernel_size=5)
canopy_height = medfilt2d(canopy_height.astype("float64"), kernel_size=proc_conf.median_factor)

return canopy_height, power_peak, rg_vec_subs, az_vec_subs, subs_F_r, subs_F_a

Expand Down
1 change: 0 additions & 1 deletion biopal/tomo_fh/main_TOMO_FH.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def _run(self, input_file):
unique_stack_id,
acquisitions_pf_names,
read_ref_h=read_ref_h,
read_dist=False,
)

if conf_params_obj.processing_flags.compute_geometry or not geometry_aux_are_present:
Expand Down
4 changes: 3 additions & 1 deletion biopal/utility/utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def check_if_geometry_auxiliaries_are_present(
read_slope=True,
read_kz=True,
read_ref_h=True,
read_dist=True,
read_dist=False, # No mandatory, needed only for FH if Spectral Shift Filtering
):

aux_are_present_flag = True
Expand Down Expand Up @@ -231,6 +231,8 @@ def check_if_geometry_auxiliaries_are_present(
pf_name = os.path.basename(file_names.slant_range_distances_file_names[stack_id])
folder_name = os.path.dirname(file_names.slant_range_distances_file_names[stack_id])
if not os.path.exists(os.path.join(folder_name, pf_name)):
warning_message = " Spectral Shift Filtering is enabled, the Distances Auxiliary product is mandatory in this case but it is missing."
logging.warning(warning_message)
aux_are_present_flag = False

if read_slope:
Expand Down

0 comments on commit a5e98e1

Please sign in to comment.