Using Python to Study Rotational Velocity Distributions of Hot Stars

Stars are fundamental pieces that compose our Universe. By studying them we can better comprehend the environment in which we live. In this work, we have studied a sample of 350 nearby O and B stars and have characterized them in aspects of their multiplicity, temperature, spectral classifications, and projected rotational velocity. Python is a robust language with a steep learning curve, i.e. one can make rapid progress with it. In this proceeding, we will present how we used Python in


Introduction
The study of O and B stars is an important key to understanding how star formation occurs. When these stars are born, they have the greatest mass, temperature and rotation. Their mass can go from 2.5 up to 120 times the Solar mass, their temperatures ranging from 11,000 K up to 60,000 K, and rotation up to 400 km/s. By definition, a star is born when it starts synthesizing Hydrogen into Helium through nuclear fusion. The star performs this nucleosynthesis during some 90% of their life. When stars are at this stage, they are called dwarfs. Most of the studied stars on this work are dwarfs. Due to their young age, dwarf stars have not lost too much of their mass, and so, the majority of their stellar properties are kept unchanged. This helps us understand how these stars formed.
Stars are born inside molecular clouds and, usually, a molecular cloud can generate several stars. After their formation, these stars compose a stellar association, that, in its infancy, is still gravitationally bounded. With their unchanged properties, it is possible to trace the membership of these stars and then verify if some stars are from the same association.
The Python programming language is very powerful, robust, clean and easy to learn. The scripting nature allows the programmer to have a dynamic workflow and not lose too much time with debugging and compiling. With a set of packages, like Scipy, Numpy and Matplotlib, Python becomes very suited for scientific research. On the last years, it has been widely adopted in the Astronomic community and several astronomical packages are being translated to Python or just recently being created. All of these motivated us to use Python in our research.
In this proceedings, we relate how we used Python in our research. A more profound scientific analysis can be found at [Brag12].

Sample Characterization
The observed sample of stars is displayed in Figure 1 in terms of their Galactic longitude and heliocentric distance projected onto the Galactic plane. The stars in the sample are all nearby (∼ 80% are within 700 pc) and relatively bright (V ∼ 5 − 10).
We used Python allied to the Matplotlib package to construct the plot presented in Figure 1 and all plots of this work. The code for this plot is: As we have said before, stars usually are born in groups. Thus, a great majority of them are binaries or belong to multiple systems. For a spectroscopic study, as was this, the only problem occurs when the spectrum of one observation has two or more objects. The identification of these objects was done on a visual inspection and with support of the works of [Lefe09] and [Egle08]. Since the study of these stars was outside the scope of our project, we discarded them. These objects are represented in Figure 1 as red circles.
Our sample is composed of high-resolution spectroscopic observations with wavelength coverage from 3350 up to 9500 Angstrons. Sample spectra are shown in Figure 2 in the spectral  To analyze the spectra images we have used IRAF (Image and Reduction Analysis Facility), which is a suite of softwares to handle astronomic images developed by the NOAO 1 . We had to do several tasks on our spectra (e.g. slice them at a certain wavelength and normalization) to prepare our sample for further analysis. Some of these tasks had to be done manually and on a one-byone basis, but some others were automated. The automation could have been done through IRAF scrips, but fortunately, the STSCI 2 has developed a Python wrapper for IRAF called PyRAF. For example, we show how we used the IRAF task SCOPY to cut images from a list using pyRAF: We also have performed a spectral classification on the stars and, since this was not done using Python, more information can be obtained from the original paper. We have obtained effective temperature (Teff) from a calibration presented in [Mass89] that uses the photometric reddeningfree parameter index Q ([John58]).
A histogram showing the distribution of effective temperatures for OB stars with available photometry is shown in Figure 3. The effective temperatures of the target sample peak around 17,000 K, with most stars being cooler than 28,000 K.

Projected rotational velocities
We have obtained projected rotational velocities (v sin i) for 266 stars of our sample (after rejecting spectroscopic binaries/multiple systems) using measurements of full width at half maximum of 1. National Optical Astronomy Observatory 2. Space Telescope Science Institute  He I lines and interpolation in a synthetic grid from [Dafl07]. We did not use Python to obtain v sin i, so, for more information, we suggest the reader to look in the original paper. However, to analyze the stars v sin i we used Python, especially the matplotlib package for visualization analysis and the Scipy.stats package for statistics analysis.
The boxplot is a great plot to compare several distributions side by side. In this work, we used a boxplot to analyze the v sin i for each spectral type subset, as can be seen in Figure 4. The average v sin i for the stars in each spectral type bin is roughly constant, even considering the least populated bins. The code used to plot it was:  And the distribution of v sin i for the stars of our sample is presented on Figure 5. The distribution has a modest peak at low v sin i (∼ 0 − 50 km/s) but it is overall flat (a broad distribution) for v sin i roughly between 0 and 150 km/s; the number of stars drops for higher values of v sin i. [Abt02] provide the cornerstone work of the distributions of projected rotational velocities of the so-called field OB stars. To compare our sample with Abt's, we subselected our sample on magnitude and Abt's sample on spectral type. Both distributions are shown on the bottom panel of Figure  5. The code used to build this plot follows:  0,100,20)) # Bottom Panel # Plot our sample subselected on V < 6.5 ax2 = plt.subplot2grid((3, 1), (2, 0)) # Set weights to obtain a normalized distribution weights = np.zeros_like(brighter_than_65) + 1./brighter_than_65.size # Plot Abt's subselected sample ax2.hist(brighter_than_65, np.arange(0, 400, 50), weights = weights, histtype = 'step', ec='black', color='white', label = 'This study (V<6.5)') # Set weights to obtain a normalized distribution There is evidence that there are real differences between the v sin i distributions of cluster members when compared to field ( [Wolf07], [Huan08]); there are fewer slow rotators in the clusters when compared to the field or the stars in clusters tend to rotate faster. Using literature results ( [Hump84], [Brow94], [Zeeu99], [Robi99], [Merm03], [Tetz11]), we separated our sample into four different categories according to the star's membership: field, cluster, association and runaway. We have merged our sample with that of [Dafl07] in which their results were obtained using the same methodology as ours. We present in Figure 6 the distributions of stars belonging to clusters and from associations.
We have used the Kolmogorov-Smirnov (KS) statistics to test the null hypothesis that membership subsamples are drawn from the same population. For this we used the ks_2samp task available on the scipy.stats package. The resulting values are available in Table 1. Note that, any differences between the distributions of clusters and associations in this study are not very clear and may not be statistically significant; larger studies are needed. Also, the runaway subsample seems to be more associated with the dense cluster environments, as expected from a dynamical ejection scenario.

Conclusions
We have investigated a sample of 350 OB stars from the nearby Galactic disk. Our focus was to realize a first characterization of this sample. We obtained effective temperature using a photometric calibration and determined that the temperature distribution  peaks around 17,000 K, with most stars being cooler than 28,000 K. We calculated the projected rotational velocities using the full width at half measure of He I lines and found that the distribution has a modest peak at low v sin i (∼ 0 − 50 km/s) but it is overall flat (a broad distribution) for v sin i roughly between 0 and 150 km/s; the number of stars drops for higher values of v sin i.
We subselected our sample on a membership basis and, when the OB association and cluster populations are compared with the field sample, it is found that the latter has a larger fraction of slowest rotators, as previously shown by other works. In fact, there seems to be a gradation from cluster to OB association to field in v sin i distribution.
We have constantly used Python in the development of this work. In our view, the advantages of Python are the facility of learning, the robust packages for science and data analysis, a plot package that renders beautiful plots in a fast and easy way, and the increase of packages for the astronomic community.