def test_find_processed_hourly_files_non_madis(self): """Ensures correct output from find_processed_hourly_files. In this case, primary data source is non-MADIS. """ these_file_names, _ = raw_wind_io.find_processed_hourly_files( start_time_unix_sec=PERIOD_START_TIME_UNIX_SEC, end_time_unix_sec=PERIOD_END_TIME_UNIX_SEC, primary_source=NON_MADIS_PRIMARY_SOURCE, top_directory_name=TOP_DIRECTORY_NAME, raise_error_if_missing=False) self.assertTrue( these_file_names == PROCESSED_HOURLY_FILE_NAMES_NON_MADIS)
def _read_wind_observations(storm_object_table, max_time_before_storm_start_sec, max_time_after_storm_end_sec, top_directory_name): """Reads wind observations from one or more files. :param storm_object_table: pandas DataFrame created by _read_storm_tracks. :param max_time_before_storm_start_sec: Max wind time before beginning of storm cell. If wind observation W occurs > max_time_before_storm_start_sec before the first time in storm cell S, W cannot be linked to S. :param max_time_after_storm_end_sec: Max wind time after end of storm cell. If wind observation W occurs > max_time_after_storm_end_sec after the last time in storm cell S, W cannot be linked to S. :param top_directory_name: Name of top-level directory with wind observations (files created by `raw_wind_io.write_processed_file`). :return: wind_table: pandas DataFrame with columns documented in `raw_wind_io.write_processed_file`. """ min_wind_time_unix_sec = numpy.min(storm_object_table[ tracking_io.TIME_COLUMN].values) - max_time_before_storm_start_sec max_wind_time_unix_sec = numpy.max(storm_object_table[ tracking_io.TIME_COLUMN].values) + max_time_after_storm_end_sec wind_file_names, _ = raw_wind_io.find_processed_hourly_files( start_time_unix_sec=min_wind_time_unix_sec, end_time_unix_sec=max_wind_time_unix_sec, primary_source=WIND_DATA_SOURCE, top_directory_name=top_directory_name, raise_error_if_missing=True) num_files = len(wind_file_names) list_of_wind_tables = [None] * num_files for i in range(num_files): print('Reading wind observations from file {0:d}/{1:d}:' ' "{2:s}"...').format(i + 1, num_files, wind_file_names[i]) list_of_wind_tables[i] = raw_wind_io.read_processed_file( wind_file_names[i])[REQUIRED_WIND_COLUMNS] if i == 0: continue list_of_wind_tables[i], _ = list_of_wind_tables[i].align( list_of_wind_tables[0], axis=1) return pandas.concat(list_of_wind_tables, axis=0, ignore_index=True)