コード例 #1
0
def GetAllFluxes(source_name):
    logging.warn('CURRENTLY USING HARDCODED RA/DEC')
    coords = SkyCoord.from_name(source_name)
    source_ra = coords.ra.deg
    source_dec = coords.dec.deg

    cat_files = glob.glob(
        'sources/{}/swift/uvot/cat/*.cat'.format(source_name))
    try:
        logging.debug('Looking for prebuilt swift_uvot flux df')
        df = pd.read_csv(
            'sources/{}/swift/uvot/cat/flux_df.csv'.format(source_name))
        return df
    except FileNotFoundError:
        logging.debug('Could not find prebuilt swift_uvot flux df')
        pass

    # source_ra = 49.58333   #NGC1313 HARDCODED
    # source_dec = -66.48639 #NGC1313 HARDCODED
    search_radius = 0.1

    # catobsID = swift.GetObservationID(source_name)
    observation_list = aux.GetObservationList(source_name)
    start_times = swift.GetStartTimes(observation_list)

    rows = []
    logging.debug('Getting all fluxes for Swift UVOT from .cat files')
    for file in tqdm(cat_files):
        obsID = GetObsIDFromCatFile(file)
        flux_df = GetFluxesFromCatFile(file, source_ra, source_dec,
                                       search_radius)
        mean_flux = np.mean(flux_df['FLUX'])
        mean_flux_err = np.mean(flux_df['FLUX_ERR'])  #TODO Check this

        mask = start_times['OBSID'] == obsID
        try:
            start = start_times[mask]['START_TIME'].values[0]
        except:
            start = None

        rows.append([obsID, start, mean_flux, mean_flux_err])
        # print(obsID, start, mean_flux, mean_flux_err)

    df = pd.DataFrame.from_records(rows)
    df.columns = ['OBSID', 'START_TIME', 'MEAN_FLUX', 'MEAN_FLUX_ERR']
    df = df.sort_values(by=['START_TIME'])
    df.to_csv('sources/{}/swift/uvot/cat/flux_df.csv'.format(source_name))
    return df
コード例 #2
0
    def query(self):
        missions = OrderedDict([
            ('XMM SSC', 'xmmssc'),
            ('XMM Optical SSC', 'xmmosuss'),
            ('Swift', 'swiftmstr'),
            ('NiCER', 'nicermastr'),
            ('RXTE', 'xtemaster'),
            ('NuSTAR', 'numaster'),
            ('Chandra', 'chanmaster'),
            ('ROSAT', 'rass2rxs'),
            ('SUZAKU', 'suzamaster'),
            ('MAXI', 'maximaster'),
        ])

        observation_lists = OrderedDict()

        for mission_name, mission in missions.items():
            observation_list = aux.GetObservationList(self.SOURCE_NAME,
                                                      mission)
            observation_lists[mission_name] = observation_list

        print('============================================================')
        print('Results for source:', self.SOURCE_NAME)
        header = ['Mission', '#Observations', 'Earliest obs', 'Latest obs']
        spacing = '{:<15} {:<15} {:<15} {:<15}'
        print(spacing.format(*header))

        for mission_name, observation_list in observation_lists.items():
            earliest_mjd, latest_mjd = aux.GetEarliestAndLatestFromObsList(
                observation_list)
            earliest = round(aux.mjd2year(earliest_mjd), 3)
            latest = round(aux.mjd2year(latest_mjd), 3)
            try:
                row = [mission_name, len(observation_list), earliest, latest]
            except TypeError:  #Nontype has no length
                row = [mission_name, 'N/A', 'N/A', 'N/A']
            print(spacing.format(*row))
        print('============================================================')
コード例 #3
0
ファイル: rxte.py プロジェクト: nx1/FluxQuery
 def __init__(self):
     super(RXTE, self).__init__()
     self.RXTE_OBS_LIST = aux.GetObservationList(self.SOURCE_NAME, 'xtemaster')
コード例 #4
0
 def __init__(self):
     super(NICER, self).__init__()
     self.NICER_OBS_LIST = aux.GetObservationList(self.SOURCE_NAME, 'nicermastr')
コード例 #5
0
 def __init__(self):
     super(SWIFT, self).__init__()
     self.SWIFT_OBS_LIST = aux.GetObservationList(self.SOURCE_NAME,
                                                  'swiftmastr')
     self.LIGHTCURVE_SWIFT_UVOT = None