Index: trunk/SDToolBox/extract_waves.py =================================================================== diff -u -r35 -r36 --- trunk/SDToolBox/extract_waves.py (.../extract_waves.py) (revision 35) +++ trunk/SDToolBox/extract_waves.py (.../extract_waves.py) (revision 36) @@ -78,11 +78,7 @@ self.check_for_longitude(lon) for lon in self.__input_lon] years = self.generate_years_array(year_from, year_to) - - nn_lon_idx, nn_lat_idx = self.__get_corrected_lon_lat( - directory_path, cases_dict - ) - + nn_idx = None for n_variable, variable_name in enumerate(variable_dict): case_name_value = variable_dict[variable_name] for year in years: @@ -99,6 +95,11 @@ 'does not exist or could not be found.') continue + if not nn_idx: + nn_idx = self.__get_corrected_lon_lat( + case_file_path, cases_dict + ) + # Lazy loading of the dataset. with Dataset(case_file_path, 'r', self.__ds_format) \ as case_dataset: @@ -107,7 +108,7 @@ cases_dict[self.__out_val_key][variable_name], case_dataset, variable_name, - (nn_lon_idx, nn_lat_idx) + nn_idx ) # Get the time for the variable. if n_variable == 0: @@ -157,11 +158,11 @@ axis=0) def __get_corrected_lon_lat( - self, directory_path: str, cases_dict: dict): + self, ref_file_path: str, cases_dict: dict): """Gets the corrected index and value for the given input coordinates. Arguments: - directory_path {str} -- Parent directory. + ref_file_path {str} -- Path to the refernce file. cases_dict {dict} -- Dictionary with all values that need format. Returns: @@ -170,7 +171,7 @@ nn_lon_idx = [] nn_lat_idx = [] - ref_file_path = self.find_default_file(directory_path) + # 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)