# program to read in data from a file # and plot it # read in a multi coloumn data file from pylab import * import matplotlib.pyplot as plt # read in MV, B-V, and temp of main sequence stars from colrmag.dat MV,BV,temp=loadtxt('colormag.dat',unpack=True,skiprows=4,usecols=(0,1,2)) # plot the data MV versus B-V plt.plot(BV,MV,'b*',label='My Plot') plt.xlabel('B-V') plt.ylabel('Apparent mag.') axis([-0.4,3,18,-5]) # set range on axis plt.annotate('my label',(1,4)) # read in orion data num,s,V,BmV=loadtxt('OrionUBV.dat',unpack=True,skiprows=4,usecols=(0,1,2,3)) # overplot orion data plt.plot(BmV,V,'ro') # adjust the data to match the theoretical main sequence for d=400 # distance in pc d=100 # try 100 pc distance dm=5.*np.log10(d/10) magV=V-dm # deredden and extinct the data if desired #AV=0.1 # extinction at V band in magnitudes #R=3.1 # ratio of extinction to reddening #EBMV=AV/3.1 # this is teh excess B-V called E(B-V) # deredmagV=magV+AV # deredmagBmV=BV+EBMV #magBmV=BmV-EBMV show() # now print out a new file with only the magnitudes of each star from astropy.io import ascii ascii.write([magV,magBmV], 'newdata.dat', names=['V mag.', 'B-V color'])