Skip to content
Snippets Groups Projects
Commit c540dce3 authored by Narayanarao Bhogapurapu's avatar Narayanarao Bhogapurapu
Browse files

before profiling

parent f9c19b34
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -219,6 +219,7 @@ def cal_(temp_cor, temp_gedi, htl, htg): ...@@ -219,6 +219,7 @@ def cal_(temp_cor, temp_gedi, htl, htg):
result = np.array(result) result = np.array(result)
tempdf = pd.DataFrame(data={'N': result[:, 0], 'S': result[:, 1], 'C': result[:, 2], tempdf = pd.DataFrame(data={'N': result[:, 0], 'S': result[:, 1], 'C': result[:, 2],
'r': result[:, 3], 'rmse': result[:, 4]}) 'r': result[:, 3], 'rmse': result[:, 4]})
del result
tempdf.dropna(subset=['rmse'], inplace=True) tempdf.dropna(subset=['rmse'], inplace=True)
if nn>6: if nn>6:
tempdf = tempdf[tempdf['N'] > 3].sort_values(by=['rmse'], ascending=True) tempdf = tempdf[tempdf['N'] > 3].sort_values(by=['rmse'], ascending=True)
...@@ -261,6 +262,7 @@ def process_block(i, j, cohArray, lidarArray, initial_ws, htl, htg, parm_): ...@@ -261,6 +262,7 @@ def process_block(i, j, cohArray, lidarArray, initial_ws, htl, htg, parm_):
if np.all(np.array(parm) == 0): if np.all(np.array(parm) == 0):
parm = parm_.copy() parm = parm_.copy()
del parm_
if lidarBlock.shape[0]*lidarBlock.shape[1]>initial_ws*initial_ws: if lidarBlock.shape[0]*lidarBlock.shape[1]>initial_ws*initial_ws:
# mask[np.shape(mask)[0]//2,np.shape(mask)[1]//2]=1 # mask[np.shape(mask)[0]//2,np.shape(mask)[1]//2]=1
np.fill_diagonal(mask, 1) np.fill_diagonal(mask, 1)
...@@ -277,6 +279,7 @@ def process_block(i, j, cohArray, lidarArray, initial_ws, htl, htg, parm_): ...@@ -277,6 +279,7 @@ def process_block(i, j, cohArray, lidarArray, initial_ws, htl, htg, parm_):
# ht = arc_sinc_fast(gama, parm[2]) * mask # ht = arc_sinc_fast(gama, parm[2]) * mask
# print(lidarBlock.shape) # print(lidarBlock.shape)
del lidarBlock, cohBlock del lidarBlock, cohBlock
gc.collect()
return start_i, end_i, start_j, end_j, s_parm, c_parm, rmse_parm, ht, count return start_i, end_i, start_j, end_j, s_parm, c_parm, rmse_parm, ht, count
else: else:
S += 2 S += 2
...@@ -316,8 +319,10 @@ def dynamicWindow(cohArray, lidarArray, initial_ws, htl, htg, batch_size=10): ...@@ -316,8 +319,10 @@ def dynamicWindow(cohArray, lidarArray, initial_ws, htl, htg, batch_size=10):
if block_i < rows and block_j < cols: if block_i < rows and block_j < cols:
batch_futures.append((block_i, block_j)) batch_futures.append((block_i, block_j))
# Submit the batch as a single task future = executor.submit(process_batch, batch_futures, cohArray, lidarArray, initial_ws, htl, htg, parm_)
futures.append(executor.submit(process_batch, batch_futures, cohArray, lidarArray, initial_ws, htl, htg, parm_))
futures.append(future)
del future,batch_futures
# Initialize the progress bar with the total number of futures # Initialize the progress bar with the total number of futures
with tqdm(total=len(futures)) as pbar: with tqdm(total=len(futures)) as pbar:
...@@ -336,6 +341,8 @@ def dynamicWindow(cohArray, lidarArray, initial_ws, htl, htg, batch_size=10): ...@@ -336,6 +341,8 @@ def dynamicWindow(cohArray, lidarArray, initial_ws, htl, htg, batch_size=10):
pbar.update(1) pbar.update(1)
del results,future del results,future
gc.collect() gc.collect()
# Clear the futures list to prevent accumulation
futures.clear()
return s_parm, c_parm, rmse_parm, ht_, count return s_parm, c_parm, rmse_parm, ht_, count
...@@ -346,7 +353,7 @@ def process_batch(batch_futures, cohArray, lidarArray, initial_ws, htl, htg, par ...@@ -346,7 +353,7 @@ def process_batch(batch_futures, cohArray, lidarArray, initial_ws, htl, htg, par
start_i, end_i, start_j, end_j, s_p, c_p, r_p, ht, cnt = process_block(block_i, block_j, cohArray, lidarArray, initial_ws, htl, htg, parm_) start_i, end_i, start_j, end_j, s_p, c_p, r_p, ht, cnt = process_block(block_i, block_j, cohArray, lidarArray, initial_ws, htl, htg, parm_)
results.append((start_i, end_i, start_j, end_j, s_p, c_p, r_p, ht, cnt)) results.append((start_i, end_i, start_j, end_j, s_p, c_p, r_p, ht, cnt))
# Invoke garbage collection # Invoke garbage collection
# gc.collect() gc.collect()
return results return results
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment