66import pandas as pd
77import rasterio as rio
88
9- from ._utils import get_dates
9+ from .utils import get_dates
1010
1111
1212def process_coherence_data (
1313 directory : str | Path ,
1414 by_date : bool = False ,
1515 subsample : int = 1 ,
1616 difference_dir : str | Path = "differences" ,
17+ trim : int = 20 ,
1718) -> pd .DataFrame :
1819 """Process InSAR coherence data from a directory and return analysis dataframe.
1920
@@ -23,8 +24,8 @@ def process_coherence_data(
2324 Path to the directory containing the InSAR data with the following structure:
2425 - directory/
2526 - differences/*.tif
26- - interferograms/temporal_coherence.tif
27- - interferograms/similarity.tif
27+ - interferograms/temporal_coherence* .tif
28+ - interferograms/similarity* .tif
2829 by_date : bool, optional
2930 If True, return a dataframe with one row per date, by default False
3031 subsample : int, optional
@@ -58,28 +59,25 @@ def process_coherence_data(
5859 file_list = sorted (diff_dir .glob ("*tif" ))
5960
6061 temp_coh = _load_gdal (
61- main_dir / "interferograms/temporal_coherence.tif" , subsample_factor = subsample
62+ next (iter (main_dir .glob ("interferograms/temporal_coherence_[0-9]*.tif" ))),
63+ subsample_factor = subsample ,
64+ )
65+ sim = _load_gdal (
66+ next (iter (main_dir .glob ("interferograms/similarity_[0-9]*.tif" ))),
67+ subsample_factor = subsample ,
6268 )
6369 # sim = _load_gdal(main_dir / "interferograms/similarity.tif")
6470 # sim = _load_gdal(next(sorted(Path(main_dir / "linked_phase")
6571 # .rglob("similarity_*.tif"))))
6672 # AVERAGE sim... since this is average temp coh?
6773 # Or should i just do a single one...
6874 # print(sorted(Path(main_dir / "linked_phase").rglob("similarity_*.tif")))
69- if (pl_dir := Path (main_dir / "linked_phase" )).exists ():
70- sim_f = sorted (pl_dir .rglob ("similarity_*.tif" ))[0 ]
71- else :
72- pl_dir = Path (main_dir / "phase_linking/linked_phase" )
73- sim_f = sorted (pl_dir .rglob ("similarity_*.tif" ))[0 ]
74- sim = _load_gdal (
75- sim_f ,
76- subsample_factor = subsample ,
77- )
7875
7976 # Process differences
8077 pixels = np .stack (
8178 [_load_gdal (f , subsample_factor = subsample ) for f in file_list ], axis = 0
8279 )
80+ pixels = pixels [..., trim :- trim , trim :- trim ]
8381 pixels = pixels .reshape (pixels .shape [0 ], - 1 )
8482
8583 if not by_date :
0 commit comments