| 1 |
# this script may be used to measure running time of any function |
| 2 |
# since bench.timeit is not accurate for dask based processing |
| 3 |
|
| 4 |
from pathlib import Path |
| 5 |
from polsarpro.io import open_netcdf_beam |
| 6 |
from polsarpro.decompositions import h_a_alpha |
| 7 |
import time |
| 8 |
|
| 9 |
# change to your data paths |
| 10 |
# original dataset |
| 11 |
input_alos_slc = Path("/data/psp/test_files/SAN_FRANCISCO_ALOS1_slc.nc") |
| 12 |
input_alos_slc_re = Path("/data/psp/test_files/SAN_FRANCISCO_ALOS1_slc_rechunked.nc") |
| 13 |
|
| 14 |
# input files from C |
| 15 |
input_test_dir = Path("/data/psp/test_files/input/h_a_alpha_decomposition/") |
| 16 |
|
| 17 |
# output files from C |
| 18 |
output_test_dir = Path("/data/psp/res/h_a_alpha_c") |
| 19 |
|
| 20 |
n_runs = 3 |
| 21 |
# %% |
| 22 |
test_path = "/data/psp/test_files/test.zarr" |
| 23 |
slc = open_netcdf_beam(input_alos_slc) |
| 24 |
for _ in range(n_runs): |
| 25 |
start_time = time.perf_counter() |
| 26 |
res_slc = h_a_alpha(slc, boxcar_size=[7, 7]).compute() |
| 27 |
end_time = time.perf_counter() |
| 28 |
total_time = end_time - start_time |
| 29 |
print(f"Function took {total_time:.4f} seconds") |