1111OUTPUT_ROOT = "/mnt/ceph-hdd/cold_store/projects/nim00007/AZ_predictions"
1212
1313
14- def run_az_thinning ():
15- files = sorted (glob (os .path .join (ROOT , "**/*.h5" ), recursive = True ))
14+ def run_az_thinning (folder = ROOT , out_path = OUTPUT_ROOT ):
15+ files = sorted (glob (os .path .join (folder , "**/*.h5" ), recursive = True ))
1616 for ff in tqdm (files ):
1717 ds_name = os .path .basename (os .path .split (ff )[0 ])
18- if not ds_name .startswith (("04" , "06" )):
18+ ''' if not ds_name.startswith(("04", "06")):
1919 continue
2020 if "rescaled" in ds_name:
21- continue
21+ continue'''
2222
23- # print(ff)
24- ff_out = os .path .join (OUTPUT_ROOT , os .path .relpath (ff , ROOT ))
23+ print (f"ff { ff } " )
24+ ff_out = os .path .join (out_path , os .path .relpath (ff , folder ))
25+ print (f"ff_out { ff_out } " )
2526 with h5py .File (ff_out , "r" ) as f_out , h5py .File (ff , "r" ) as f_in :
2627 # if "labels/az_thin2" in f_out:
2728 # continue
@@ -38,19 +39,19 @@ def run_az_thinning():
3839 )
3940
4041 with h5py .File (ff_out , "a" ) as f :
41- ds = f .require_dataset ("labels/az_thin2 " , shape = az_thin .shape , dtype = az_thin .dtype , compression = "gzip" )
42+ ds = f .require_dataset ("labels/az_thin " , shape = az_thin .shape , dtype = az_thin .dtype , compression = "gzip" )
4243 ds [:] = az_thin
4344
4445
45- def check_az_thinning ():
46- files = sorted (glob (os .path .join (ROOT , "**/*.h5" ), recursive = True ))
46+ def check_az_thinning (folder = ROOT , out_path = OUTPUT_ROOT ):
47+ files = sorted (glob (os .path .join (folder , "**/*.h5" ), recursive = True ))
4748 for ff in files :
4849
49- f_out = os .path .join (OUTPUT_ROOT , os .path .relpath (ff , ROOT ))
50+ f_out = os .path .join (out_path , os .path .relpath (ff , folder ))
5051 with h5py .File (f_out , "r" ) as f :
5152 if "labels/az_thin" not in f :
5253 continue
53- az_thin = f ["labels/az_thin2 " ][:]
54+ az_thin = f ["labels/az_thin " ][:]
5455
5556 with h5py .File (ff , "r" ) as f :
5657 tomo = f ["raw" ][:]
@@ -63,13 +64,15 @@ def check_az_thinning():
6364
6465def main ():
6566 parser = argparse .ArgumentParser ()
67+ parser .add_argument ("-i" ,"--input_folder" , type = str )
68+ parser .add_argument ("-o" ,"--out_path" , type = str )
6669 parser .add_argument ("--check" , action = "store_true" )
6770 args = parser .parse_args ()
6871
6972 if args .check :
70- check_az_thinning ()
73+ check_az_thinning (args . input_folder , args . out_path )
7174 else :
72- run_az_thinning ()
75+ run_az_thinning (args . input_folder , args . out_path )
7376
7477
7578if __name__ == "__main__" :
0 commit comments