#NEWLINE# def compute_sort_for_data_set( name , no_time = False ) : #NEWLINE# #INDENT# data_set_path = join ( DATA_DIR_PATH , ( name + '.npy' ) ) #NEWLINE# time_string = ( '_notime' if no_time else '' ) #NEWLINE# sort_path = join ( DATA_DIR_PATH , ( name + '_um{}.npy' . format ( time_string ) ) ) #NEWLINE# if isfile ( sort_path ) : #NEWLINE# #INDENT# raise Exception ( ( 'Sorted file already exists! Please delete sort file ' + "to re-compute sort for set: '{}'" . format ( name ) ) ) #NEWLINE# #UNINDENT# print ( 'Loading data set from {}...' . format ( data_set_path ) ) #NEWLINE# data_set = load_numpy_array_from_file ( file_name = data_set_path ) #NEWLINE# print ( 'Computing sort...' ) #NEWLINE# if no_time : #NEWLINE# #INDENT# print ( '(Excluding time from final numpy)' ) #NEWLINE# keep_columns = ( 0 , 1 , 3 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# keep_columns = ( 0 , 1 , 2 , 3 ) #NEWLINE# #UNINDENT# sorted_set = np . sort ( data_set . view ( 'i4,i4,i4,i4' ) , order = [ 'f0' , 'f1' ] , kind = 'mergesort' , axis = 0 ) . view ( np . int32 ) [ : , keep_columns ] #NEWLINE# print ( 'Got sort: ' ) #NEWLINE# print ( sorted_set ) #NEWLINE# print ( 'Saving sort to file: {}' . format ( sort_path ) ) #NEWLINE# write_numpy_array_to_file ( file_path = sort_path , array = sorted_set )