Example #1
0
def get_followup():
    import os
    import StarData

    # Read in the observed target list
    filename = '{}/Dropbox/School/Research/AstarStuff/TargetLists/Observed_Targets3.xls'.format(
        os.environ['HOME'])
    sample = pd.read_excel(filename, sheetname=0, na_values=['     ~'])
    sample = sample.reset_index(drop=True)[1:]
    sample['Mag K'] = sample.apply(
        lambda row: row['Mag K'] if pd.notnull(row['Mag K']) else row['Mag V'],
        axis=1)

    # Get the targets with a detection
    detections = sample.loc[sample['Detections'].notnull()]

    # Get the detections without follow-up
    followup = detections.groupby('identifier').filter(
        lambda df: df.shape[0] == 1)
    followup.reset_index(inplace=True, drop=True)

    # Split RA/DEC field
    radec = followup['RA/DEC (J2000)'].map(Split_RA_DEC)
    followup['RA'] = radec.map(lambda l: l[0])
    followup['DEC'] = radec.map(lambda l: l[1])

    # Rename columns
    followup.rename(columns={
        'Mag K': 'mag',
        'identifier': 'Target'
    },
                    inplace=True)

    # Add the spectral type from simbad (not in the table for some silly reason)
    followup['spectype'] = followup['Target'].map(
        lambda star: StarData.GetData(star).spectype)
    followup['spt'] = followup.apply(
        lambda row: '{} + {}'.format(row['spectype'], row['Detections']),
        axis=1)

    return followup