Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import numpy as np
  2. from pylab import *
  3. from pylab import loadtxt
  4. from scipy import *
  5. from astropy.io import fits
  6. import matplotlib.pyplot as plt
  7. import scipy.constants as const
  8. import scipy.stats as stats
  9. from scipy import optimize
  10.  
  11. #Open our fits and turn them into 2D numpy arrays
  12. FPtau = fits.open("/home/kmiskove/Documents/lab-5/FP_Tau.cleaned.fits")
  13. FPt_w = FPtau[0].data
  14.  
  15. #Make arrays for wavelengths and flux density and plot them
  16. FPt_wl = FPt_w[0]
  17. FPt_fd = FPt_w[1]
  18. plt.plot(FPt_wl, FPt_fd)
  19. plt.ylabel('Flux density')
  20. plt.xlabel('Wavelength (microns)')
  21.  
  22. #But our plot isn't that coherent, so let's try plotting less of it:
  23. plt.axis([2.3, 2.31, 9.4743346e-15, 1.3214704e-14])
  24. #plt.show()
  25.  
  26. #We pick a little dip and try to fit a gaussian to it now
  27. plt.axis([2.3025, 2.3035, 9.4743346e-15, 1.2e-14,])
  28.  
  29. #Define our gaussian function
  30. def gaussian(x,a,b,c):
  31. e = np.e
  32. t = (-(x-b)**2)
  33. s = (2*c**2)
  34. m = e**(t/s)
  35. g = (1-(a*m))
  36. return g
  37.  
  38. #By manually fiddling with the following and looking for when it outputs values closest to 2.3025 and 2.3035, we can manually set our limits:
  39. #print(FPt_wl[24759:24872])
  40. #we found our indices should be from 24759 to 24872.
  41.  
  42. #Now let's define our a, b, and c values and plot our gaussian
  43. a = 0.1
  44. b = 2.30297
  45. c = 0.00015
  46.  
  47. guess = gaussian(FPt_wl[24759:24872],a,b,c)
  48. d = 1.12e-14
  49.  
  50. plt.plot(FPt_wl[24759:24872], FPt_fd[24759:24872])
  51. plt.plot(FPt_wl[24759:24872], guess*d)
  52. plt.ylabel('Flux density')
  53. plt.xlabel('Wavelength (microns)')
  54. plt.show()
  55.  
  56. #Now let's do the standard deviation velocity thing...
  57.  
  58. c = 3e8
  59. velocity = c*(2.3035-2.3025/2.3035)
  60. print(velocity)
  61. print("This is the velocity of HK Tau in m/s")
  62.  
  63. #Sun's diameter: 10.3e9
  64. d = 10.3e9
  65. #convert to circumference:
  66. cir = 32358404332
  67. rot = cir/velocity
  68. print(rot)
  69. print("This is the star's rotational period in seconds.")
  70. print("The sun's rotational period is 2114208 seconds, so this is absolutely insane.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement