def main(): ff = evaluate.FitnessFunction() base = tools.load_nolan_bedrock() surf = tools.load_first_guess_surface() for i in range(9): mp.plot(range(58), base, "red") params = create(58, -500, 500) bed = map(operator.add, params, base) mp.plot(range(58), bed, "blue") run1 = basic_model.isothermalISM( 58, 1000, 0.0015, 0.0005, 0.00022, bed[:] ) # 55 nodes, 1000-meter spacing, basal slip was .0005 for i in range(1500): # 5000 years run1.timestep(1) if i % 100 == 0: print "on timestep", i mp.plot(range(58), run1.get_surface_elev()[:58]) mp.plot(range(57), surf, "red") mp.scatter([1, 5, 12, 20, 32], [-70, -200, -500, -600, -250]) print "surface difference:", tools.calculate_surface_difference(surf, run1.get_surface_elev()[:58]) print "evaluate surface difference:", ff.evaluate(bed, run1.get_surface_elev()) mp.show()
import numpy as np possibilities1 = [ .0008, .00082, .00085, .0009, .00095, .00097, .00099, .001, .0012, .0015] possibilities2 = [ .0005, .0006, .0007,.00072, .00075, .00077, .0008, .00082, .00085, .0009] possibilities3 = [.0001, .0002, .00022, .00024, .00026, .00028, .0003, .0004, .0005, .00055] results = np.zeros([1000, 4]) count = 0 b0 = tools.load_nolan_bedrock() obs_surface = tools.load_first_guess_surface() for i in possibilities1: for j in possibilities2: for k in possibilities3: run = basic_model.isothermalISM(58, 1000, i,j,k, b0[:]) for n in range(1000): run.timestep(1) difference = tools.calculate_surface_difference(run.get_surface_elev(), obs_surface) results[count][0] = i results[count][1] = j results[count][2] = k results[count][3] = difference count =+ 1 print i, j, k, difference f = file("experiment_results.txt","wb") np.save(f,results) f.close() #best for 2: .00095, .0002 #best for 3: 0.0015 0.0005 0.00022 564.84883375
def evaluate(self,bed_elev, surf_elev): return self.constrain_to_reality(bed_elev) + self.constrain_to_nolan(bed_elev) + self.smoothness_constraint(bed_elev) + tools.calculate_surface_difference(surf_elev, self.gps_surface)