Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''Code to create list of craters and plot the craters'''
- import numpy as np
- import matplotlib.pyplot as plt
- import random as rnd
- import math as mt
- t = 0.0 #set time to 0
- sat = 1.0 #set saturation to a number
- n=0.0 #set the number of craters equal to 0
- #n_o = 0.0
- delta_n = list() #make a list for the change in number of craters
- listrnd= list() #list of the impacts
- list_c_t = list() #create an empty list for the number ot craters at time t
- rad = 51 #radius of crater plus ejecta blaket in km
- while t<400: #start a while loop to simulate impacts over time
- x_rnd = rnd.randint(0.0,500.0) #pick a random x coordinate for the impact between 1 and 500 km
- y_rnd = rnd.randint(0.0,500.0) #pick a random y coordinate for the impact between 1 and 500 km
- listrnd.append((x_rnd,y_rnd)) #add the coordinates of the impact to the list
- for (x,y) in listrnd: #start a for loop using the tuples in listrnd
- if x==x_rnd and y == y_rnd: #when the point is the center point
- continue #don't remove it
- dist = np.sqrt((y_rnd - y)**2 + (x_rnd - x)**2) #distance formula to find how the distance between new and old craters
- if dist <= rad: #if the distance is less than the radius of a crater
- listrnd.remove((x,y)) #remove it
- n = float(len(listrnd)) #count the amount of craters
- x_pt = [x[0] for x in listrnd] #pull the x coordinates from the list
- y_pt = [x[1] for x in listrnd] #pull the y coordinates from the list
- plt.plot(x_pt,y_pt, 'ro', ms = 51) #plot the impacts
- plt.title('Impacts') #add title to the plot
- plt.ylim(0,500) #sets the y limits of the plot
- plt.xlim(0,500) #sets the x limits of the plot
- t=t+1 #iterate time
- tot_t = t*1000 #find total time in years
- list_c_t.append((n,t)) #make a list of tuples of the amount of craters with thtie time recorded
- delta_n = [float(abs(x-n)) for (x,y) in list_c_t] #fill delta_n list with the change in number so craters vs now
- listsat = [(round(x/n,2))*100.0 for x in delta_n] #make a list of the saturation percentage
- #listsat = listsat[:-1] #delete the last number because its just zero anyway to try and make calling the saturation at time t easier
- y_pt = [x[1] for x in list_c_t]
- #sat=listsat[-1]
- listsat1=list()
- listsat1 = tuple(zip(listsat,y_pt))
- sat_per = 5.0
- #lstnew = [n for n in listsat if sat_per in x]
- for (x,y) in listsat1:
- if x <= sat_per:
- delta_t = 2*y
- if t == 2*y:
- print n
- print tot_t
- plt.show()
- #x_pt = [x[0] for x in listrnd] #pull the x coordinates from the list
- #y_pt = [x[1] for x in listrnd] #pull the y coordinates from the list
- #plt.plot(x_pt,y_pt, 'ro', ms = 51) #plot the impacts
- #plt.title('Impacts') #add title to the plot
- #plt.ylim(0,500) #sets the y limits of the plot
- #plt.xlim(0,500) #sets the x limits of the plot
- #if t == 10:
- #if t ==40:
- # print listsat1
- #if sat==50:
- #when i understand the equation for saturation print plot at different saturation points
- #print n #for example half saturation
- #print list_c_t
- #plt.show()
- # print tot_t
- # print sat
- if t==400:
- #print listsat
- print listsat
- #print lstnew
- plt.show()
- #if sat==50:
- #when i understand the equation for saturation print plot at different saturation points
- #print n #for example half saturation
- #print list_c_t
- #plt.show()
- # print tot_t
- # print sat
- #if 30>=sat>=20
- #if sat<=ined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement