Index: trunk/SDToolBox/extract_waves.py =================================================================== diff -u -r30 -r31 --- trunk/SDToolBox/extract_waves.py (.../extract_waves.py) (revision 30) +++ trunk/SDToolBox/extract_waves.py (.../extract_waves.py) (revision 31) @@ -170,10 +170,12 @@ """ nn_lon_idx = [] nn_lat_idx = [] - # TODO: this should be dynamic, not hardcoded. - base_file_name = 'Hs\\era5_Global_Hs_1981.nc' - ref_file_path = os.path.join(directory_path, base_file_name) + ref_file_path = self.find_default_file(directory_path) + # Hardcoded: + # base_file_name = 'Hs\\era5_Global_Hs_1981.nc' + # ref_file_path = os.path.join(directory_path, base_file_name) + # Extract index and value for all input lat, lon. with Dataset(ref_file_path, 'r', self.__ds_format) \ as ref_dataset: @@ -194,6 +196,13 @@ return nn_lon_idx, nn_lat_idx @staticmethod + def find_default_file(dir: str): + for root, dirs, files in os.walk(dir): + for file in files: + if file.endswith('.nc'): + return os.path.join(root, file) + + @staticmethod def get_case_subset(dataset, variable_name, lon, lat): return dataset[variable_name][:, lat, lon]