def _convert_files(top_probsevere_dir_name, date_string, top_output_dir_name): """Converts probSevere tracking files for one day. :param top_probsevere_dir_name: See documentation at top of file. :param date_string: Same. :param top_output_dir_name: Same. """ date_unix_sec = time_conversion.string_to_unix_sec(date_string, DATE_FORMAT) raw_file_names = probsevere_io.find_raw_files_one_day( top_directory_name=top_probsevere_dir_name, unix_time_sec=date_unix_sec, file_extension=probsevere_io.ASCII_FILE_EXTENSION, raise_error_if_all_missing=True) for this_raw_file_name in raw_file_names: print 'Reading data from "{0:s}"...'.format(this_raw_file_name) this_storm_object_table = probsevere_io.read_raw_file( this_raw_file_name) this_time_unix_sec = probsevere_io.raw_file_name_to_time( this_raw_file_name) this_new_file_name = tracking_io.find_processed_file( unix_time_sec=this_time_unix_sec, data_source=tracking_utils.PROBSEVERE_SOURCE_ID, top_processed_dir_name=top_output_dir_name, tracking_scale_metres2=DUMMY_TRACKING_SCALE_METRES2, raise_error_if_missing=False) print 'Writing data to "{0:s}"...'.format(this_new_file_name) tracking_io.write_processed_file( storm_object_table=this_storm_object_table, pickle_file_name=this_new_file_name)
def test_raw_file_name_to_time_json(self): """Ensures correct output from raw_file_name_to_time. In this case, the file type is JSON and file name does *not* include the alternative prefix. """ this_time_unix_sec = probsevere_io.raw_file_name_to_time( JSON_FILE_NAME) self.assertTrue(this_time_unix_sec == VALID_TIME_UNIX_SEC)
def test_raw_file_name_to_time_ascii_alternative(self): """Ensures correct output from raw_file_name_to_time. In this case, the file type is ASCII and file name includes the alternative prefix. """ this_time_unix_sec = probsevere_io.raw_file_name_to_time( ALTERNATIVE_ASCII_FILE_NAME) self.assertTrue(this_time_unix_sec == VALID_TIME_UNIX_SEC)