Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import astropy.io.fits as fits
  3. import astropy.modeling.blackbody as bb
  4.  
  5. #1A
  6.  
  7. f1 = fits.open('ckp00_3500.fits') #These lines are used to load in the .fits files.
  8. f2 = fits.open('ckp00_5750.fits')
  9. f3 = fits.open('ckp00_7500.fits')
  10.  
  11. data1 = f1[1].data #Here the necessary data is extracted.
  12. data2 = f2[1].data
  13. data3 = f3[1].data
  14.  
  15. wavelength1 = data1.field('wavelength') #The array with measured wavelengths is requested for each of the stars.
  16. wavelength2 = data2.field('wavelength')
  17. wavelength3 = data3.field('wavelength')
  18.  
  19. flux1 = data1.field('g00') #The array with measured flux is reuqested for each of the stars.
  20. flux2 = data2.field('g00')
  21. flux3 = data3.field('g05') #I use g05 instead of g00 here, because the g00 measurement isn't a valid spectrum.
  22.  
  23. plt.plot(wavelength1,flux1) #Plot the model spectrum of the star.
  24. plt.xlim([3000,10000]) #We limit the wavelength to include only the optical part of the EM-spectrum.
  25. plt.title('Model spectrum of star with T = 3500')
  26. plt.xlabel('Wavelength (Ångstrom)')
  27. plt.ylabel('Flux (erg/s/cm²/Å)')
  28. plt.show()
  29. plt.plot(wavelength2,flux2)
  30. plt.xlim([3000,10000])
  31. plt.title('Model spectrum of star with T = 5750')
  32. plt.xlabel('Wavelength (Ångstrom)')
  33. plt.ylabel('Flux (erg/s/cm²/Å)')
  34. plt.show()
  35. plt.plot(wavelength3,flux3)
  36. plt.xlim([3000,10000])
  37. plt.title('Model spectrum of star with T = 7500')
  38. plt.xlabel('Wavelength (Ångstrom)')
  39. plt.ylabel('Flux (erg/s/cm²/Å)')
  40. plt.show()
  41.  
  42. #2A
  43.  
  44. plt.plot(wavelength1,flux1,label='Model spectrum')
  45. plt.plot(wavelength1,bb.blackbody_lambda(wavelength1,3500),label='Blackbody curve')
  46. #In the line above, the imported blackbody modeling is used to plot a blackbody curve, which is constructed using
  47. #the array with wavelengths and the blackbody temperature of the star.
  48. plt.vlines(8279,1e-16,1e9,label='Peak (Wiens law)',linestyle='--') #The calculated location of the peak according to Wien.
  49. plt.xlim([1000,100000])
  50. plt.ylim([1e-16,1e9])
  51. plt.xscale('log') #Logaritmic scaling of the axis.
  52. plt.yscale('log')
  53. plt.legend(loc='lower right') #Legend to label the different plotted lines.
  54. plt.title('Model spectrum of star with T = 3500 K, with overplotted blackbody curve')
  55. plt.xlabel('Wavelength (Ångstrom)')
  56. plt.ylabel('Flux (erg/s/cm²/Å)')
  57. plt.show()
  58.  
  59. plt.plot(wavelength2,flux2,label='Model spectrum')
  60. plt.plot(wavelength2,bb.blackbody_lambda(wavelength2,5750),label='Blackbody curve')
  61. plt.vlines(5039.6,1e-16,1e9,label='Peak (Wiens law)',linestyle='--')
  62. plt.xlim([1000,100000])
  63. plt.ylim([1e-16,1e9])
  64. plt.xscale('log')
  65. plt.yscale('log')
  66. plt.legend(loc='lower right')
  67. plt.title('Model spectrum of star with T = 5750 K, with overplotted blackbody curve')
  68. plt.xlabel('Wavelength (Ångstrom)')
  69. plt.ylabel('Flux (erg/s/cm²/Å)')
  70. plt.show()
  71.  
  72. plt.plot(wavelength3,flux3,label='Model spectrum')
  73. plt.plot(wavelength3,bb.blackbody_lambda(wavelength3,7500),label='Blackbody curve')
  74. plt.vlines(3864,1e-16,1e9,label='Peak (Wiens law)',linestyle='--')
  75. plt.xlim([1000,100000])
  76. plt.ylim([1e-16,1e9])
  77. plt.xscale('log')
  78. plt.yscale('log')
  79. plt.legend(loc='lower right')
  80. plt.title('Model spectrum of star with T = 7500 K, with overplotted blackbody curve')
  81. plt.xlabel('Wavelength (Ångstrom)')
  82. plt.ylabel('Flux (erg/s/cm²/Å)')
  83. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement