def Translation_analytical_raypath( velocity_translation=2.01 * 1221.0 / 1.0e6, direction=positions.CartesianPoint(1, 0, 0) ): # Initialize map m, fig = plot_data.setting_map() cm = plt.cm.get_cmap("RdYlBu") # seismic data set (from Lauren's file) data_points = read_write.read_from_file( "results.dat", slices=[ "PKIKP-PKiKP travel time residual", "turn lat", "turn lon", "turn depth", "in lat", "in lon", "out lat", "out lon", ], ) nlines, ncolumns = data_points.shape print data_points.info # translate it in the correct format dataset = [] translation_dataset = [] phi, theta, age, dt = [], [], [], [] print nlines, "points to write." for i in range(nlines): if i % 100 == 0: # print every 100 values print "Writing point ", i, ". Coordinates: ", data_points.ix[i] # because it's analytical solution, we don't need to define a grid. model is calulated exactly. translation_dataset.append( geodynamic.Translation( positions.SeismoPoint( 1221.0 - data_points.ix[i, "turn depth"], data_points.ix[i, "turn lat"], data_points.ix[i, "turn lon"], ) ) ) translation_dataset[i].analytical(velocity_translation, direction) phi.append(translation_dataset[i].initial_position.phi) theta.append(translation_dataset[i].initial_position.theta) age.append(translation_dataset[i].exact_solution) x, y = m(phi, theta) m.scatter(x, y, c=age, zorder=10, cmap=plt.cm.RdYlGn) m.colorbar() fig, ax = plt.subplots() ax.plot(phi, age / max(age), ".") dt = data_points["PKIKP-PKiKP travel time residual"] print dt.shape ax.plot(phi, dt, ".r") plt.show()
def find_difficulty(word): """A prompt asking the difficulty of each question""" difficulty = 0 while difficulty not in range(1, 6): try: difficulty = input('Rate difficulty from 1(EASY) to 5(HARD): ') difficulty = int(difficulty) if difficulty in range(1, 6): clear_screen() known_words = read_from_file(KNOWN_WORDS_LOCATION) known_words[difficulty].append(word) save_to_file(known_words, KNOWN_WORDS_LOCATION) except: difficulty = 0
os.system('open ' + filename) if __name__ == '__main__': # matrix = [ # [None, None, None, None, 7, 2, None, None, None], # [9, None, None, None, None, None, None, 3, None], # [None, 6, None, 1, None, None, 4, None, None], # [None, 8, None, None, 3, None, 5, None, None], # [None, 7, 5, None, None, None, 2, 9, None], # [None, None, 6, None, 4, None, None, 8, None], # [None, None, 7, None, None, 8, None, 2, None], # [None, 1, None, None, None, None, None, None, 9], # [None, None, None, 9, 1, None, None, None, None] # ] # result = sudoku_solve(matrix) # print "-----------" # print read_write.sudoku_html_table(result) filename = sys.argv[1] if len(filename) > 3: extension = filename[-3:] image_arr = None if extension == 'txt': image_arr = rw.read_from_file(filename) else: image_arr = rw.read_from_image(filename) if image_arr is not None: solution = sudoku_solve(image_arr) rw.sudoku_html_table(solution) # subprocess.Popen(['out.pdf'],shell=True) open_file('out.pdf')
rand_pair = known_words_list[rand_index] spanish = rand_pair[0] english = rand_pair[1] if question == True: if spanish not in used_words: used_words.add(spanish) done = True return spanish, english else: continue else: done = True return english words_list = csv_to_list('100_words.csv') known_words = read_from_file('known_words.dictionary') known_words_set = dict2set(known_words) known_words_translation_dict = translate_to_dict(known_words_set, words_list) known_words_list = dict2list(known_words_translation_dict) clear_screen() print(rand_pair(known_words_list, False)) print(rand_pair(known_words_list))
if __name__ == '__main__': # matrix = [ # [None, None, None, None, 7, 2, None, None, None], # [9, None, None, None, None, None, None, 3, None], # [None, 6, None, 1, None, None, 4, None, None], # [None, 8, None, None, 3, None, 5, None, None], # [None, 7, 5, None, None, None, 2, 9, None], # [None, None, 6, None, 4, None, None, 8, None], # [None, None, 7, None, None, 8, None, 2, None], # [None, 1, None, None, None, None, None, None, 9], # [None, None, None, 9, 1, None, None, None, None] # ] # result = sudoku_solve(matrix) # print "-----------" # print read_write.sudoku_html_table(result) filename = sys.argv[1] if len(filename) > 3: extension = filename[-3:] image_arr = None if extension == 'txt': image_arr = rw.read_from_file(filename) else: image_arr = rw.read_from_image(filename) if image_arr is not None: solution = sudoku_solve(image_arr) rw.sudoku_html_table(solution) # subprocess.Popen(['out.pdf'],shell=True) open_file('out.pdf')