# set remaining stars as members of background if using_bg: z[stars_so_far:,-1] = 1. return z assoc_name = sys.argv[1] try: label = sys.argv[2] except IndexError: label = None star_pars_file = '../data/{}_xyzuvw.fits'.format(assoc_name) if not os.path.isfile(star_pars_file): banyan_data = '../data/gagne_bonafide_full_kinematics_with_lit' \ '_and_best_radial_velocity_comb_binars.fits' star_pars_file = dt.loadDictFromTable(banyan_data, assoc_name) print("Loaded association {} from banyan data".format(assoc_name)) print("with total of {} stars".format(len(star_pars_file['xyzuvw']))) rdir_suffix = 'em_fit/{}'.format(assoc_name.replace(' ','_')) if label: rdir_suffix += '_{}/'.format(label) else: rdir_suffix += '/' rdir = '/data/mash/tcrun/' + rdir_suffix if not os.path.isdir(rdir): rdir = '../results/' + rdir_suffix print("Operating in directory: {}".format(rdir)) if os.path.isfile(rdir + 'bg_hists.npy'): bg_hists = np.load(rdir + 'bg_hists.npy') else:
import pandas as pd from astropy.table import Table import sys sys.path.insert(0, '..') import chronostar.retired2.datatool as dt if __name__ == '__main__': input_file = '../data/beta_Pictoris_with_gaia_small_everything.fits' output_file = '../data/beta_Pictoris_with_gaia_small_everything_final.fits' my_banyan_table_file = '../data/gagne_bonafide_full_kinematics_with_lit_' \ 'and_best_radial_velocity_comb_binars_with_banyan_' \ 'radec.fits' banyan_file = '../data/banyan_data.txt' banyan_data = Table.read(banyan_file, format='ascii') sp = dt.loadDictFromTable(input_file) master_sp = dt.loadDictFromTable(my_banyan_table_file) master_table = master_sp['table'] beta_table = sp['table'] # insert new columns into master table new_cols = [ 'r_RVel', 'r_SpT', ] for col_name in new_cols: master_table[col_name] = banyan_data[col_name] # use a join to get the references beta_table['r_RVel'] = np.array(len(beta_table) * '', dtype='S10') beta_table['r_SpT'] = np.array(len(beta_table) * '', dtype='S3')
# coding: utf-8 get_ipython().magic(u'ls ') import numpy as np z = np.load('final_membership.npy') fmerrs = np.load('final_med_errs.npy') fmerrs fmerrs[0] import sys sys.path.insert(0, '/home/tcrun/chronostar/') import chronostar.retired2.datatool as dt sp = dt.loadDictFromTable('../../../data/marusa_galah_li_strong_stars_xyzuvw.fits') get_ipython().magic(u'ls ') sp['table'].info comp_a = sp['table'][np.where(z[:,0] > 0.5)] len(comp_a) comp_a['X'] comp_a['U'] comp_a['V'] import matplotlib.pyplot as plt plt.plot(comp_a['X'], comp_a['U'], '.') plt.show() plt.clf() plt.plot(comp_a['U'], comp_a['V'], '.') plt.show() np.mean(comp_a['U']) np.mean(comp_a['V']) import chronostar.coordinate as coord coord.lsr u_mean = np.mean(comp_a['U']) v_mean = np.mean(comp_a['V']) xyzuvw = sp['xyzuvw'][np.where(z[:,0] > 0.5)]
import pandas as pd from astropy.table import Table import sys sys.path.insert(0, '..') import chronostar.retired2.datatool as dt if __name__ == '__main__': input_file = '../data/beta_Pictoris_with_gaia_small_everything.fits' output_file = '../data/beta_Pictoris_with_gaia_small_everything_final.fits' my_banyan_table_file = '../data/gagne_bonafide_full_kinematics_with_lit_' \ 'and_best_radial_velocity_comb_binars_with_banyan_' \ 'radec.fits' banyan_file = '../data/banyan_data.txt' banyan_data = Table.read(banyan_file, format='ascii') sp = dt.loadDictFromTable(input_file) master_sp = dt.loadDictFromTable(my_banyan_table_file) master_table = master_sp['table'] beta_table = sp['table'] # insert new columns into master table new_cols = [ 'r_RVel', 'r_SpT', ] for col_name in new_cols: master_table[col_name] = banyan_data[col_name] # use a join to get the references beta_table['r_RVel'] = np.array(len(beta_table) * '', dtype='S10') beta_table['r_SpT'] = np.array(len(beta_table) * '', dtype='S3')
other_name = row[slice(*other_name_range)].strip() star_labels[gaia_id] = (two_mass_id, primary_name or other_name) return star_labels if __name__ == '__main__': rdir = '../results/em_fit/beta_Pictoris_wgs_inv2_5B_res/' final_memb_file = rdir + 'final_membership.npy' # bp_star_pars_file = '../data/beta_Pictoris_with_gaia_small_xyzuvw.fits' bp_star_pars_file = '../data/bpmg_w_nearby_gaia_memberships_magnitudes.fits' gagne_star_pars_file = '../data/gagne_bonafide_full_kinematics_with_lit_and' \ '_best_radial_velocity_comb_binars.fits' z = np.load(final_memb_file) bp_sp = dt.loadDictFromTable(bp_star_pars_file) gg_sp = dt.loadDictFromTable(gagne_star_pars_file) banyan_data = bp.readBanyanTxtFile() banyan_upper_ix = 38 new_chronostar_membs = (np.where(z[banyan_upper_ix:,0]>0.5)[0] + banyan_upper_ix,) # -- insert ra dec for stars not matched with Gaia -- # first incorporate BANYAN radec into all members table bd_ras = [] bd_des = [] assert len(banyan_data) == len(gg_sp['table']) for row in banyan_data: if row[3] == '':
# coding: utf-8 get_ipython().magic(u'ls ') import numpy as np z = np.load('final_membership.npy') fmerrs = np.load('final_med_errs.npy') fmerrs fmerrs[0] import sys sys.path.insert(0, '/home/tcrun/chronostar/') import chronostar.retired2.datatool as dt sp = dt.loadDictFromTable( '../../../data/marusa_galah_li_strong_stars_xyzuvw.fits') get_ipython().magic(u'ls ') sp['table'].info comp_a = sp['table'][np.where(z[:, 0] > 0.5)] len(comp_a) comp_a['X'] comp_a['U'] comp_a['V'] import matplotlib.pyplot as plt plt.plot(comp_a['X'], comp_a['U'], '.') plt.show() plt.clf() plt.plot(comp_a['U'], comp_a['V'], '.') plt.show() np.mean(comp_a['U']) np.mean(comp_a['V']) import chronostar.coordinate as coord coord.lsr u_mean = np.mean(comp_a['U']) v_mean = np.mean(comp_a['V'])
if PLOT_BPMG_REAL: for iteration in ['5B']: #, '6C']: star_pars_file = '../../data/beta_Pictoris_with_gaia_small_xyzuvw.fits' star_pars = dt.loadXYZUVW(star_pars_file) fit_name = 'bpmg_and_nearby' rdir = '../../results/em_fit/beta_Pictoris_wgs_inv2_{}_res/'.format(iteration) memb_file = rdir + 'final_membership.npy' groups_file = rdir + 'final_groups.npy' z = np.load(memb_file) groups = dt.loadGroups(groups_file) # Assign markers based on BANYAN membership gt_sp = dt.loadDictFromTable('../../data/banyan_with_gaia_near_bpmg_xyzuvw.fits') banyan_membership = len(star_pars['xyzuvw']) * ['N/A'] for i in range(len(star_pars['xyzuvw'])): master_table_ix = np.where(gt_sp['table']['source_id']==star_pars['gaia_ids'][i]) banyan_membership[i] = gt_sp['table']['Moving group'][master_table_ix[0][0]] # assign markers based on present moving groups, keep track of # assoc -> marker relationship incase a legend is called for banyan_membership=np.array(banyan_membership) banyan_markers = np.array(len(banyan_membership) * ['.']) banyan_memb_set = set(banyan_membership) for bassoc in set(gt_sp['table']['Moving group']): if bassoc not in acronyms.keys(): acronyms[bassoc] = bassoc banyan_markers[np.where(banyan_membership=='beta Pictoris')] = 'v'
# bpmg_range[1] = temp_range # To ensure consistency, we now plot the BANYAN bpmg stars only, # and use the ragnes from previous plot # 2019-07-13 [TC]: not sure why this is here... if False: fit_name = 'banyan_bpmg' rdir = '../../results/em_fit/beta_Pictoris/' memb_file = rdir + 'final_membership.npy' groups_file = rdir + 'final_best_groups.npy' star_pars_file = '../../data/beta_Pictoris_with_gaia_small_xyzuvw.fits' z = np.load(memb_file) groups = dt.loadGroups(groups_file) star_pars = dt.loadDictFromTable(star_pars_file, 'beta Pictoris') nstars = len(star_pars['xyzuvw']) # First do all, then just do possible membs of BPMG for dim1, dim2 in DEFAULT_DIMS: #[(0,1), (0, 3), (1, 4), (2,5)]: #, (2, 5)]: # , 'yv', 'zw']: # if dim1 == 0 and dim2 == 1 and debugging_circles: # temp_range = bpmg_range[1] # bpmg_range[1] = [-120, 80] # import pdb; pdb.set_trace() fp.plotPane( dim1, dim2, groups=groups, star_pars=star_pars, group_now=True, membership=z,
near BPMG, removes duplicates (especially binaries/ternaries absorbed into centre of mass references), and packages up neatly for an EM run """ from astropy.table import Table import numpy as np import sys sys.path.insert(0, '..') import chronostar.retired2.datatool as dt cart_gaia_table = '../data/gaia_cartesian_full_6d_table.fits' gagne_table = '../data/gagne_bonafide_full_kinematics_with_lit_and_best_'\ 'radial_velocity_comb_binars.fits' assoc_name = 'beta Pictoris' bp_star_pars = dt.loadDictFromTable(gagne_table, assoc_name=assoc_name) print("Reading in gaia table...") gt = Table.read(cart_gaia_table) print("Gaia table read in") MARGIN = 0.5 xyzuvw_file = "../data/{}_with_gaia_small_xyzuvw.fits".format( assoc_name.replace(' ', '_')) # construct box kin_max = np.max(bp_star_pars['xyzuvw'], axis=0) kin_min = np.min(bp_star_pars['xyzuvw'], axis=0) span = kin_max - kin_min upper_boundary = kin_max + MARGIN * span lower_boundary = kin_min - MARGIN * span
from master_table and membership array """ import numpy as np import sys sys.path.insert(0, '..') import chronostar.retired2.datatool as dt save_file_name = '../results/tables/bpmg_members_astro_table.tex' rdir = '../results/em_fit/beta_Pictoris_with_gaia_small_1.0/3/A/final/' z_file = rdir + 'final_membership.npy' table_file = '../data/beta_Pictoris_with_gaia_small_xyzuvw.fits' star_pars = dt.loadDictFromTable(table_file) bpmg_comp_ix = 0 bpmg_memb_probs = np.load(z_file)[:,bpmg_comp_ix] threshold = 0.05 bpmg_table_mask = np.array(star_pars['indices'])[np.where(bpmg_memb_probs > threshold)] # columns: Gaia DR2 id, main designation, ra, dec, parallax, pmra, pmdec, rv, # membership prob, references col_names = [ 'source_id', 'Main designation', 'ra', 'ra_error', 'dec',