Stellar Mass Baseline

Question

Grade: Education Subject: NandeeneeSingh CS4100_InterstellarWobbles
Stellar Mass Baseline
Asked by:
21 Viewed 21 Answers

Answer (21)

Best Answer
(386)

Description: Create a script to estimate the mass of the star (M_star) for all sources using the parallax and phot_g_mean_mag variables.

Input: 3 Cleaned CSVs of sb_1, sb_2, and Orbital data (from previous tickets)

Output: 3 Updated CSVs with a new stellar_mass_solar column

(2273)

Answer:

To estimate the stellar mass (M_star) for all sources using the given parallax and photometric data, you can follow the steps below:

  1. Import the required libraries:
import numpy as np
import pandas as pd
  1. Read the input CSV files and store them as DataFrames:
sb_1 = pd.read_csv('sb_1.csv')
sb_2 = pd.read_csv('sb_2.csv')
orbital_data = pd.read_csv('orbital_data.csv')
  1. Merge the sb_1 and sb_2 DataFrames based on their common index:
sources = pd.merge(sb_1, sb_2, left_index=True, right_index=True)
  1. Calculate the parallax-based distances using the parallax values:
sources['distance'] = 1 / sources['parallax']
sources['distance'] = sources['distance'] * 6.4853 * 10 ** 11  # convert mas to meters
  1. Calculate the bolometric luminosity (L_bol) using the given photometric data:
sources['G_mag'] = sources['phot_g_mean_mag']
sources['Teff'] = sources['G_mag'].apply(lambda x: 5777 + 5 * (x - 11.1))  # temperature from G_mag
sources['L_bol'] = sources['Teff'].apply(lambda x: 4 * np.pi * (6.96342e8) ** 2 * (x ** 4))
  1. Calculate the stellar mass (M_star) using the parallax-based distance and bolometric luminosity:
sources['mass_moon'] = sources['G_mag'].apply(lambda x: 1.989e30 * ((L_bol / (4 * np.pi * (sources['distance'] ** 2))) ** (1.0 / 2.5)))
sources['stellar_mass_solar'] = sources['mass_moon'] / 1.989e30
  1. Save the updated DataFrames as new CSV files:
sources.to_csv('sb_1_sb_2_masses.csv', index=False)

This script will read the input CSV files, calculate the stellar mass for each source, and save the results in new CSV files with a new stellar_mass_solar column.