From 89734d3422d86fbcb4b07e29d65145a3c5c89542 Mon Sep 17 00:00:00 2001
From: Narayana Rao Bhogapurapu <narayanarao.bhogapurapu@gmail.com>
Date: Sun, 1 Dec 2024 14:35:01 -0800
Subject: [PATCH] v0.5.2

added option to filter the calibration parameters
---
 algorithm_config.yaml          |  9 +++++++--
 ich.sh                         |  1 +
 src/ich/InSAR_canopy_height.py |  3 ++-
 src/ich/args_in.py             | 13 +++++++------
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/algorithm_config.yaml b/algorithm_config.yaml
index 9f1bb3b..2c2924e 100644
--- a/algorithm_config.yaml
+++ b/algorithm_config.yaml
@@ -1,6 +1,6 @@
 description: Estimates canopy height from InSAR coherence and LiDAR data
 algo_name: ich
-version: 0.5.1
+version: 0.5.2
 environment: ubuntu
 repository_url: https://repo.maap-project.org/bnarayanarao/insar_forest_height.git
 docker_url: mas.maap-project.org/root/maap-workspaces/base_images/python:v4.1.0
@@ -21,4 +21,9 @@ inputs:
     download: False
   - name: validation
     download: False
-
+  - name: algorithm
+    download: False  
+  - name: overlap
+    download: False 
+  - name: filter
+    download: False
diff --git a/ich.sh b/ich.sh
index 478dc79..2a7c5a6 100644
--- a/ich.sh
+++ b/ich.sh
@@ -22,6 +22,7 @@ options=()
 [[ "${4:-}" != "-" ]] && options+=("--validation" "${4}")
 [[ "${5:-}" != "-" ]] && options+=("--algorithm" "${5}")
 [[ "${6:-}" != "-" ]] && options+=("--overlap" "${6}")
+[[ "${7:-}" != "-" ]] && options+=("--filter" "${7}")
 
 # Run the Python script with the determined options
 ${ich_py} --correlationFile "${correlationFile}" --cal_ht "${cal_ht}" "${options[@]}"
\ No newline at end of file
diff --git a/src/ich/InSAR_canopy_height.py b/src/ich/InSAR_canopy_height.py
index 968a706..aff3a14 100644
--- a/src/ich/InSAR_canopy_height.py
+++ b/src/ich/InSAR_canopy_height.py
@@ -39,10 +39,11 @@ parser.add_argument("-c", "--correlationFile", dest = "corFile", help="correlati
 parser.add_argument("-l", "--cal_ht", dest = "lidarFile",  help="Calibration height file e.g. LiDAR heights in (m)")
 parser.add_argument("-ll", "--lower_limit",dest ="htl", default = None ,help="lower limit of canopy height (m)", type=int)
 parser.add_argument("-ul", "--upper_limit",dest = "htg", default = None,help="upper limit of canopy height (m)", type=int)
-parser.add_argument("-w", "--window",dest = "window_size", default = 10, help="Size", type=int)
+parser.add_argument("-w", "--window",dest = "window_size", default = 10, help="calibration windowsize/blocksize", type=int)
 parser.add_argument("-val", "--validation",dest = "validation", default = 0, help="fraction to split cross validation", type=float)
 parser.add_argument("-al", "--algorithm",dest = "algo", default = 1, help="Algorithm Type", type=int)
 parser.add_argument("-ol", "--overlap",dest = "window_overlap", default = 0, help="window overlap fraction", type=float)
+parser.add_argument("-f", "--filter",dest = "filt_parm", default = 0, help="filter/smoothen the calibation parameters", type=int)
 
 args = parser.parse_args()
 
diff --git a/src/ich/args_in.py b/src/ich/args_in.py
index 767776e..549d4a6 100644
--- a/src/ich/args_in.py
+++ b/src/ich/args_in.py
@@ -49,7 +49,7 @@ def rvog_inverse(args):
 
     try:
         t0 = time.time()
-        print( "-corFile {} -lidarFile {} -htl {} -htg {} -window_size {}  -validation {} -algo {} -window_overlap {}".format(
+        print( "-corFile {} -lidarFile {} -htl {} -htg {} -window_size {}  -validation {} -algo {} -window_overlap {} -filt_parm {}".format(
         args.corFile,
         args.lidarFile,
         args.htl,
@@ -57,8 +57,8 @@ def rvog_inverse(args):
         args.window_size,
         args.validation,
         args.algo,
-        args.window_overlap
-        
+        args.window_overlap,
+        args.filt_parm
         ))
 
         lidar_ht = read_bin(args.lidarFile)
@@ -453,9 +453,10 @@ def rvog_inverse(args):
 
         ci = spatial_intp_lin(c)
         si = spatial_intp_lin(s)
-
-        ci = median_filter(ci, size=args.window_size//2)
-        si = median_filter(si, size=args.window_size//2)
+        
+        if args.filt_parm:
+            ci = median_filter(ci, size=args.window_size//2)
+            si = median_filter(si, size=args.window_size//2)
         
         si[si>1.6]=1.6
         ci[ci>16]=16
-- 
GitLab