Advertisement
IT123

IT's crater code

Nov 17th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. '''Code to create list of craters and plot the craters'''
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import random as rnd
  5. import math as mt
  6. t = 0.0 #set time to 0
  7. sat = 1.0 #set saturation to a number
  8. n=0.0 #set the number of craters equal to 0
  9. #n_o = 0.0
  10. delta_n = list() #make a list for the change in number of craters
  11. listrnd= list() #list of the impacts
  12. list_c_t = list() #create an empty list for the number ot craters at time t
  13. rad = 51 #radius of crater plus ejecta blaket in km
  14. while t<400: #start a while loop to simulate impacts over time
  15. x_rnd = rnd.randint(0.0,500.0) #pick a random x coordinate for the impact between 1 and 500 km
  16. y_rnd = rnd.randint(0.0,500.0) #pick a random y coordinate for the impact between 1 and 500 km
  17. listrnd.append((x_rnd,y_rnd)) #add the coordinates of the impact to the list
  18. for (x,y) in listrnd: #start a for loop using the tuples in listrnd
  19. if x==x_rnd and y == y_rnd: #when the point is the center point
  20. continue #don't remove it
  21. dist = np.sqrt((y_rnd - y)**2 + (x_rnd - x)**2) #distance formula to find how the distance between new and old craters
  22. if dist <= rad: #if the distance is less than the radius of a crater
  23. listrnd.remove((x,y)) #remove it
  24. n = float(len(listrnd)) #count the amount of craters
  25. x_pt = [x[0] for x in listrnd] #pull the x coordinates from the list
  26. y_pt = [x[1] for x in listrnd] #pull the y coordinates from the list
  27. plt.plot(x_pt,y_pt, 'ro', ms = 51) #plot the impacts
  28. plt.title('Impacts') #add title to the plot
  29.  
  30. plt.ylim(0,500) #sets the y limits of the plot
  31. plt.xlim(0,500) #sets the x limits of the plot
  32. t=t+1 #iterate time
  33. tot_t = t*1000 #find total time in years
  34. list_c_t.append((n,t)) #make a list of tuples of the amount of craters with thtie time recorded
  35. 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
  36. listsat = [(round(x/n,2))*100.0 for x in delta_n] #make a list of the saturation percentage
  37. #listsat = listsat[:-1] #delete the last number because its just zero anyway to try and make calling the saturation at time t easier
  38. y_pt = [x[1] for x in list_c_t]
  39. #sat=listsat[-1]
  40. listsat1=list()
  41. listsat1 = tuple(zip(listsat,y_pt))
  42. sat_per = 5.0
  43. #lstnew = [n for n in listsat if sat_per in x]
  44. for (x,y) in listsat1:
  45. if x <= sat_per:
  46. delta_t = 2*y
  47. if t == 2*y:
  48. print n
  49. print tot_t
  50. plt.show()
  51.  
  52.  
  53. #x_pt = [x[0] for x in listrnd] #pull the x coordinates from the list
  54. #y_pt = [x[1] for x in listrnd] #pull the y coordinates from the list
  55. #plt.plot(x_pt,y_pt, 'ro', ms = 51) #plot the impacts
  56. #plt.title('Impacts') #add title to the plot
  57.  
  58. #plt.ylim(0,500) #sets the y limits of the plot
  59. #plt.xlim(0,500) #sets the x limits of the plot
  60. #if t == 10:
  61. #if t ==40:
  62. # print listsat1
  63. #if sat==50:
  64. #when i understand the equation for saturation print plot at different saturation points
  65. #print n #for example half saturation
  66. #print list_c_t
  67. #plt.show()
  68. # print tot_t
  69. # print sat
  70. if t==400:
  71. #print listsat
  72. print listsat
  73. #print lstnew
  74. plt.show()
  75. #if sat==50:
  76. #when i understand the equation for saturation print plot at different saturation points
  77. #print n #for example half saturation
  78. #print list_c_t
  79. #plt.show()
  80. # print tot_t
  81. # print sat
  82. #if 30>=sat>=20
  83.  
  84. #if sat<=ined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement