Guest User

Untitled

a guest
Apr 6th, 2019
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def makecubelimits(axis, centers=None, hw=None):
  2.     lims = ax.get_xlim(), ax.get_ylim(), ax.get_zlim()
  3.     if centers == None:
  4.         centers = [0.5*sum(pair) for pair in lims]
  5.  
  6.     if hw == None:
  7.         widths  = [pair[1] - pair[0] for pair in lims]
  8.         hw      = 0.5*max(widths)
  9.         ax.set_xlim(centers[0]-hw, centers[0]+hw)
  10.         ax.set_ylim(centers[1]-hw, centers[1]+hw)
  11.         ax.set_zlim(centers[2]-hw, centers[2]+hw)
  12.         print("hw was None so set to:", hw)
  13.     else:
  14.         try:
  15.             hwx, hwy, hwz = hw
  16.             print("ok hw requested: ", hwx, hwy, hwz)
  17.  
  18.             ax.set_xlim(centers[0]-hwx, centers[0]+hwx)
  19.             ax.set_ylim(centers[1]-hwy, centers[1]+hwy)
  20.             ax.set_zlim(centers[2]-hwz, centers[2]+hwz)
  21.         except:
  22.             print("nope hw requested: ", hw)
  23.             ax.set_xlim(centers[0]-hw, centers[0]+hw)
  24.             ax.set_ylim(centers[1]-hw, centers[1]+hw)
  25.             ax.set_zlim(centers[2]-hw, centers[2]+hw)
  26.  
  27.     return centers, hw
  28.  
  29. def make_lats_lons():
  30.  
  31.     theta = np.linspace(0, twopi, 201)
  32.     cth, sth, zth = [f(theta) for f in (np.cos, np.sin, np.zeros_like)]
  33.     lon0 = Re*np.vstack((cth, zth, sth))
  34.     lons = []
  35.     for phi in rads*np.arange(0, 180, 15):
  36.         cph, sph = [f(phi) for f in (np.cos, np.sin)]
  37.         lon = np.vstack((lon0[0]*cph - lon0[1]*sph,
  38.                          lon0[1]*cph + lon0[0]*sph,
  39.                          lon0[2]) )
  40.         lons.append(lon)
  41.  
  42.     lat0 = Re*np.vstack((cth, sth, zth))
  43.     lats = []
  44.     for phi in rads*np.arange(-75, 90, 15):
  45.         cph, sph = [f(phi) for f in (np.cos, np.sin)]
  46.         lat = Re*np.vstack((cth*cph, sth*cph, zth+sph))
  47.         lats.append(lat)
  48.     return lats, lons
  49.  
  50. debris_TLEs = """MICROSAT-R DEB          
  51. 1 44117U 19006C   19094.64070647  .00455742  26153-4  80334-2 0  9998
  52. 2 44117  95.3237   4.1062 0861779 350.0688   8.4347 13.95892635  1153
  53. MICROSAT-R DEB          
  54. 1 44118U 19006D   19094.46329163  .03050626  31109-2  24862-1 0  9992
  55. 2 44118  96.1629   6.2262 0272847 356.3910   3.5361 15.35582568  1229
  56. MICROSAT-R DEB          
  57. 1 44119U 19006E   19094.46646588  .06439739  12728-5  97304-2 0  9996
  58. 2 44119  94.9178   4.6437 0181254  28.4691 332.6337 15.80679644  1248
  59. MICROSAT-R DEB          
  60. 1 44120U 19006F   19095.00036339  .00527918  52265-4  56871-2 0  9990
  61. 2 44120  95.5094   5.4447 0422033 357.9318   2.0147 14.99373378  1301
  62. MICROSAT-R DEB          
  63. 1 44121U 19006G   19095.01964115  .01508404  50846-3  14651-1 0  9995
  64. 2 44121  95.5844   5.6491 0360459 355.4980   4.3038 15.14169030  1318
  65. MICROSAT-R DEB          
  66. 1 44122U 19006H   19094.75258187  .01086181  27867-3  91501-2 0  9991
  67. 2 44122  95.6006   5.5919 0297801 357.2150   2.7421 15.29557898  1264
  68. MICROSAT-R DEB          
  69. 1 44123U 19006J   19095.06527372  .00842597  15862-3  65277-2 0  9995
  70. 2 44123  96.9468   7.8798 0329609 328.4083  29.7731 15.24689115  1321
  71. MICROSAT-R DEB          
  72. 1 44124U 19006K   19095.01748409  .02829797  25262-2  22519-1 0  9991
  73. 2 44124  95.5327   5.6875 0284095 357.7110   2.2814 15.33730995  1318
  74. MICROSAT-R DEB          
  75. 1 44125U 19006L   19094.82916466  .01599065  62368-3  14033-1 0  9992
  76. 2 44125  95.4484   5.4059 0316221 356.8319   3.0912 15.25133571  1273
  77. MICROSAT-R DEB          
  78. 1 44126U 19006M   19094.58326523  .03116733  28646-2  27747-1 0  9990
  79. 2 44126  95.4679   5.2200 0335316 358.4564   3.3570 15.21318838  1238
  80. MICROSAT-R DEB          
  81. 1 44127U 19006N   19095.03666368  .02187619  17695-2  13453-1 0  9997
  82. 2 44127  96.0706   6.8319 0171368 349.2468  10.5144 15.59755513  1133
  83. MICROSAT-R DEB          
  84. 1 44128U 19006P   19095.07940328  .00382116  42589-4  23241-2 0  9999
  85. 2 44128  96.2830   7.3605 0146784 354.4416   5.5208 15.63728289  1155
  86. MICROSAT-R DEB          
  87. 1 44129U 19006Q   19094.99492147  .01670420  99478-3  93211-2 0  9992
  88. 2 44129  96.2485   7.1558 0148156 351.6408   8.2387 15.65407990  1133
  89. MICROSAT-R DEB          
  90. 1 44130U 19006R   19095.00058036  .00153632  65541-5  14379-2 0  9996
  91. 2 44130  96.3346   7.0172 0280946 346.9670  12.4412 15.30818108  1129
  92. MICROSAT-R DEB          
  93. 1 44131U 19006S   19094.06316062  .00600230  47213-4  10182-1 0  9991
  94. 2 44131  95.4882   4.0634 0798088 353.5981   5.5555 14.10377672   757
  95. MICROSAT-R DEB          
  96. 1 44132U 19006T   19094.73963079  .12979788  19429-5  11454-1 0  9994
  97. 2 44132  96.4009   7.4170 0027412 339.9728  20.0480 16.12094571   954
  98. MICROSAT-R DEB          
  99. 1 44133U 19006U   19095.04008018  .00142556  57788-5  12170-2 0  9992
  100. 2 44133  96.4939   7.2182 0324841 329.5554  28.7166 15.23879318   964
  101. MICROSAT-R DEB          
  102. 1 44134U 19006V   19094.98522109  .00061942  16890-5  96352-3 0  9990
  103. 2 44134  96.0918   5.7448 0663376 349.5401   9.2536 14.41154034   907
  104. MICROSAT-R DEB          
  105. 1 44135U 19006W   19094.87046930  .02680902  37410-2  12244-1 0  9991
  106. 2 44135  96.2107   7.1091 0112268 355.6726   4.3559 15.75469894   954
  107. MICROSAT-R DEB          
  108. 1 44136U 19006X   19095.04109403  .00809162  14876-3  71821-2 0  9995
  109. 2 44136  94.5750   4.3171 0296364 354.3855   5.4088 15.28815365   963
  110. MICROSAT-R DEB          
  111. 1 44137U 19006Y   19094.80053007  .03433409  10222-1  12967-1 0  9991
  112. 2 44137  96.1784   7.0131 0082221 347.2816  12.6380 15.84654719   958
  113. MICROSAT-R DEB          
  114. 1 44138U 19006Z   19095.04584499  .01687024  20239-5  42295-3 0  9997
  115. 2 44138  96.6639   8.4300 0125246 256.7733 101.9558 16.11801396  1016
  116. MICROSAT-R DEB          
  117. 1 44139U 19006AA  19095.01018649  .01863761  14334-2  76060-2 0  9990
  118. 2 44139  95.4641   6.0314 0132951 316.5326  42.5520 15.73941483   983
  119. MICROSAT-R DEB          
  120. 1 44140U 19006AB  19094.99401962  .00937025  14528-3  10253-1 0  9993
  121. 2 44140  95.6393   5.3278 0564445   4.3929 356.1942 14.68800488  1288
  122. MICROSAT-R DEB          
  123. 1 44141U 19006AC  19095.05118892  .00929759  13751-3  12486-1 0  9991
  124. 2 44141  96.1001   5.9232 0590442 356.3473   3.3508 14.59478967  1289
  125. MICROSAT-R DEB          
  126. 1 44142U 19006AD  19095.08823010  .00450387  29805-4  67642-2 0  9999
  127. 2 44142  96.5890   6.4539 0677192 345.9062  12.4022 14.38737046  1276
  128. MICROSAT-R DEB          
  129. 1 44143U 19006AE  19095.05197432  .09474171  20938-5  60107-2 0  9993
  130. 2 44143  96.7877   8.4977 0027864 281.4570  78.3589 16.16667874  1307
  131. MICROSAT-R DEB          
  132. 1 44144U 19006AF  19095.07438984  .00377444  46376-4  18035-2 0  9998
  133. 2 44144  95.6350   6.4585 0094274 347.7575  12.1403 15.76217231   645
  134. MICROSAT-R DEB          
  135. 1 44145U 19006AG  19095.04888338  .01607578  46803-3  17450-1 0  9996
  136. 2 44145  95.6463   5.3980 0532778   2.6283 357.7536 14.75786071   597
  137. MICROSAT-R DEB          
  138. 1 44146U 19006AH  19095.02837073  .00089273  19163-5  14515-3 0  9992
  139. 2 44146  96.5911   8.1980 0103814 264.0180  94.9258 15.93838830   630
  140. MICROSAT-R DEB          
  141. 1 44147U 19006AJ  19095.06147560  .00157958  41062-5  23269-2 0  9996
  142. 2 44147  95.7673   5.1413 0774807   1.8709 358.5090 14.17974235   565
  143. MICROSAT-R DEB          
  144. 1 44148U 19006AK  19095.05278179  .00260163  23632-4  10121-2 0  9995
  145. 2 44148  96.6499   8.1178 0099791 308.5716  50.6643 15.79515068   625
  146. MICROSAT-R DEB          
  147. 1 44149U 19006AL  19095.04985371  .00138584  63554-5  90991-3 0  9997
  148. 2 44149  96.1023   6.9822 0182961   3.3819 356.8627 15.56156057   618
  149. MICROSAT-R DEB          
  150. 1 44150U 19006AM  19094.24965542  .03380564  82179-2  13716-1 0  9997
  151. 2 44150  96.1314   6.4062 0109734 347.4104  13.2096 15.79057773   490
  152. MICROSAT-R DEB          
  153. 1 44151U 19006AN  19095.07776720  .01139469  39308-3  70293-2 0  9993
  154. 2 44151  96.1917   7.1013 0175670 351.4915   8.3374 15.58677746   614
  155. MICROSAT-R DEB          
  156. 1 44152U 19006AP  19095.00425471  .00274120  17165-4  25192-2 0  9990
  157. 2 44152  95.0640   5.0844 0281536 351.5372   8.1175 15.31038960   596
  158. MICROSAT-R DEB          
  159. 1 44153U 19006AQ  19095.10037387  .00335950  24673-4  29766-2 0  9999
  160. 2 44153  95.0683   5.1111 0309678 359.8179   0.2901 15.26184379   608
  161. MICROSAT-R DEB          
  162. 1 44154U 19006AR  19095.03166584  .00440937  19896-4  10013-1 0  9991
  163. 2 44154  96.7141   5.2587 1287411 353.6687   4.9420 12.99476955   508
  164. MICROSAT-R DEB          
  165. 1 44155U 19006AS  19095.04684293  .00311061  27074-4  21063-2 0  9995
  166. 2 44155  96.0164   6.8512 0167909 345.7280  13.9264 15.58091161   608
  167. MICROSAT-R DEB          
  168. 1 44156U 19006AT  19094.69707226  .05553740  38015-1  26327-1 0  9996
  169. 2 44156  96.2572   7.0051 0089971 352.8442   7.1537 15.81344557   554
  170. MICROSAT-R DEB          
  171. 1 44157U 19006AU  19094.99880469  .00367995  17112-4  47305-2 0  9999
  172. 2 44157  95.4389   4.4696 0889261   7.5858 353.7787 13.95328540   535
  173. MICROSAT-R DEB          
  174. 1 44158U 19006AV  19095.70863833  .00188098  10550-4  13478-2 0  9994
  175. 2 44158  96.3272   7.8877 0184127 337.4424  21.8813 15.54187536   705
  176. MICROSAT-R DEB          
  177. 1 44159U 19006AW  19094.21895253  .16047287  19078-5  10135-1 0  9993
  178. 2 44159  96.3834   6.9600 0020619 341.3096  18.7434 16.17187137   484
  179. MICROSAT-R DEB          
  180. 1 44160U 19006AX  19095.08101037  .00234973  69896-5  43180-2 0  9994
  181. 2 44160  95.3215   4.1745 0976328 347.1157  10.6586 13.70329689   538
  182. MICROSAT-R DEB          
  183. 1 44161U 19006AY  19095.04864178  .00114018  53545-5  36847-3 0  9997
  184. 2 44161  96.2750   7.3879 0190135 296.2142  61.9683 15.67668399   605
  185. MICROSAT-R DEB          
  186. 1 44162U 19006AZ  19095.07873983  .00836557  10839-3  11532-1 0  9993
  187. 2 44162  96.0404   5.8159 0611774 356.4193   3.2724 14.54410367   561
  188. MICROSAT-R DEB          
  189. 1 44163U 19006BA  19095.07356566  .01011177  21458-3  99281-2 0  9998
  190. 2 44163  95.5073   5.5907 0365152 357.0211   2.8845 15.12958148   434
  191. MICROSAT-R DEB          
  192. 1 44164U 19006BB  19095.09553700  .00177287  73485-5  19099-2 0  9992
  193. 2 44164  96.6780   7.3048 0403399 338.2118  20.2360 15.03284262   436
  194. MICROSAT-R DEB          
  195. 1 44165U 19006BC  19095.07242078  .00225857  14659-4  14543-2 0  9997
  196. 2 44165  96.7326   7.9452 0202955 324.2145  34.5647 15.52942310   445
  197. MICROSAT-R DEB          
  198. 1 44166U 19006BD  19095.04140141  .00362798  15115-4  72119-2 0  9990
  199. 2 44166  95.7142   4.5173 1043123 357.1107   2.4300 13.54482014   381
  200. MICROSAT-R DEB          
  201. 1 44167U 19006BE  19095.05516230  .01576780  86773-3  88344-2 0  9991
  202. 2 44167  95.7015   6.3580 0149222 336.5257  22.9240 15.65131666   441
  203. MICROSAT-R DEB          
  204. 1 44168U 19006BF  19095.04961209  .00527696  86952-4  28336-2 0  9997
  205. 2 44168  96.3473   7.5037 0118347 350.9074   9.0046 15.70583958   449
  206. MICROSAT-R DEB          
  207. 1 44169U 19006BG  19095.04600491  .00244967  21667-4  83571-3 0  9993
  208. 2 44169  97.2645   9.1181 0110262 298.8316  60.1918 15.80462905   294
  209. MICROSAT-R DEB          
  210. 1 44170U 19006BH  19094.29776842  .01477004  51465-3  13916-1 0  9998
  211. 2 44170  94.7415   4.0349 0321201 354.4045   5.3637 15.22743226   167
  212. MICROSAT-R DEB          
  213. 1 44171U 19006BJ  19095.07665140  .00743869  12904-3  63401-2 0  9998
  214. 2 44171  95.6686   6.0475 0278790 356.6778   3.2606 15.33067039   280
  215. MICROSAT-R DEB          
  216. 1 44172U 19006BK  19093.24832937  .06491989  10561-5  62839-2 0  9998
  217. 2 44172  94.5693   3.5604 0110923  40.5090 320.5757 15.99896821    05
  218. MICROSAT-R DEB          
  219. 1 44173U 19006BL  19093.25107377  .00092895  25285-5  10000-2 0  9992
  220. 2 44173  95.4100   4.1032 0410196   3.5176 356.9078 15.01902668    09"""
  221.  
  222. satellite_TLE = """MICROSAT-R              
  223. 1 43947U 19006A   19095.00723967  .00076236  19544-5  99204-4 0  9991
  224. 2 43947  96.6394   8.2964 0101419 255.9464 103.0490 15.97527363 11238"""
  225. rocket_body_TLE = """KALAMSAT-V2 & PSLV R/B  
  226. 1 43948U 19006B   19095.85094231  .00001425  00000-0  39567-4 0  9996
  227. 2 43948  98.7968  24.1719 0005302  24.0083 336.1406 15.39198615 10921"""
  228. ISS_TLE = """ISS (ZARYA)            
  229. 1 25544U 98067A   19096.14813315  .00001499  00000-0  31543-4 0  9994
  230. 2 25544  51.6445 359.3289 0002204 153.5880 353.9123 15.52488458164067"""
  231.  
  232.  
  233. # https://celestrak.com/NORAD/elements/2019-006.php
  234.  
  235. debris_TLEs     = debris_TLEs.splitlines()
  236. debris_triplets = zip(*[debris_TLEs[i::3] for i in range(3)])
  237.  
  238. class Thing(object):
  239.     def __init__(self, name, L1, L2):
  240.         self.name   = name.rstrip()
  241.         self.obj    = EarthSatellite(L1, L2)
  242.  
  243. import numpy as np
  244. import matplotlib.pyplot as plt
  245. from skyfield.api import Topos, Loader, EarthSatellite
  246. from mpl_toolkits.mplot3d import Axes3D
  247.  
  248. halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
  249. degs, rads = 180/pi, pi/180
  250.  
  251. Re  = 6378.137  # km
  252.  
  253. load    = Loader('~/Documents/fishing/SkyData')  # avoids multiple copies of large files
  254. data    = load('de421.bsp')
  255. # data405    = load('de405.bsp')
  256. # data       = data405   # need the longer time range for the outer planets
  257. ts      = load.timescale()
  258.  
  259. earth = data['earth']
  260.  
  261. debris = []
  262. for triplet in debris_triplets:   #debris
  263.     thing  = Thing(*triplet)
  264.     debris.append(thing)
  265.  
  266. satellite      = Thing(*satellite_TLE.splitlines())
  267. rocket_body    = Thing(*rocket_body_TLE.splitlines())
  268. ISS            = Thing(*ISS_TLE.splitlines())
  269.  
  270. minutes = np.arange(-150, 150.0, 0.1)
  271. times = ts.utc(2019, 4, 6, 0, minutes)
  272.  
  273. for thing in debris + [satellite, rocket_body, ISS]:
  274.     thing.posn  = thing.obj.at(times).position.km
  275.     thing.r     = np.sqrt((thing.posn**2).sum(axis=0))
  276.     thing.z     = thing.posn[2]
  277.     i1          = np.argmax((thing.z[   2:]>0) * (thing.z[   1:-1]<=0)) + 2
  278.     i2          = np.argmax((thing.z[i1+2:]>0) * (thing.z[i1+1:-1]<=0)) + i1+2
  279.     thing.i1, thing.i2 = i1, i2
  280.  
  281. if True:
  282.     fig = plt.figure(figsize=[10, 8])  # [12, 10]
  283.     lw = 0.5
  284.    
  285.     ax  = fig.add_subplot(1, 1, 1, projection='3d')
  286.  
  287.     for deb in debris:
  288.         x, y, z = deb.posn[:, deb.i1:deb.i2+1]
  289.         ax.plot(x, y, z, linewidth=0.5)
  290.     for thing in (satellite, rocket_body, ISS):
  291.         x, y, z = thing.posn[:, thing.i1:thing.i2+1]
  292.         if 'ISS' in thing.name:
  293.             ax.plot(x, y, z, '-k', linewidth=2)
  294.         else:
  295.             ax.plot(x, y, z, linewidth=0.5)
  296.    
  297.     lats, lons = make_lats_lons()
  298.     if False:
  299.         for x, y, z in lons:
  300.             ax.plot(x, y, z, '-k', linewidth=0.5)
  301.         for x, y, z in lats:
  302.             ax.plot(x, y, z, '-k', linewidth=0.5)
  303.  
  304.     centers, hw = makecubelimits(ax)
  305.  
  306.     print("centers are: ", centers)
  307.     print("hw is:       ", hw)
  308.  
  309.     plt.show()
  310.  
  311. if True:
  312.     fig = plt.figure()  # [12, 10]
  313.     ax  = fig.add_subplot(1, 1, 1)  # , projection='3d'
  314.     dmins = minutes[1] - minutes[0]
  315.     for thing in debris:
  316.         r    = thing.r[thing.i1:thing.i2+1]
  317.         # mins = minutes[thing.i1:thing.i2+1]
  318.         mins  = dmins * np.arange(len(r))
  319.         ax.plot(mins, r - Re, linewidth=0.5)
  320.     for thing in (satellite, rocket_body, ISS):
  321.         r = thing.r[thing.i1:thing.i2+1]
  322.         # mins = minutes[thing.i1:thing.i2+1]
  323.         mins  = dmins * np.arange(len(r))
  324.         if 'ISS' in thing.name:
  325.             ax.plot(mins, r - Re, '-k', linewidth=2)
  326.         else:
  327.             ax.plot(mins, r - Re, linewidth=0.5)
  328.     plt.show()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×