Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- #15

Closed
wants to merge 2 commits into from
Closed

- #15

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions frbcat/tns.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self,

self.units = {'back_end': None,
'barycentric_event_time': None,
'burst_bandwidth': 'MHz',
#'burst_bandwidth': 'MHz',
'burst_width': 'ms',
'burst_width_err': 'ms',
'dec_frac': 'frac. degrees',
Expand All @@ -73,13 +73,13 @@ def __init__(self,
'fluence_err': 'Jy ms',
'flux': 'Jy',
'flux_err': 'Jy',
'frac_lin_pol': None,
#'frac_lin_pol': None,
'galactic_max_dm': 'pc cm^-3',
'galactic_max_dm_model': None,
'gl_frac': 'frac. degrees',
'gb_frac': 'frac. degrees',
'group': None,
'host_redshift': None,
#'host_redshift': None,
'inst_bandwidth': 'MHz',
'internal_name': None,
'lastmodified': None,
Expand All @@ -98,10 +98,10 @@ def __init__(self,
'repeater_of_objid': None,
'reporter_name': None,
'reports_id': None,
'rm': 'rad m^-2',
'rm_err': 'rad m^-2',
#'rm': 'rad m^-2',
#'rm_err': 'rad m^-2',
'sampling_time': 'ms',
'scattering_time': 'ms',
#'scattering_time': 'ms',
'scattering_time_err': 'ms',
'snr': None,
'telescope': None,
Expand Down Expand Up @@ -311,9 +311,9 @@ def clean_df(self, df):
'reports_id': int,
'photometry_id': int,
'snr': float,
'num_channels': int,
'host_redshift': float,
'frac_lin_pol': float})
'num_channels': int})
#'host_redshift': float,
#'frac_lin_pol': float})

# Clean up columns
df.repeater_of_objid = df.repeater_of_objid.replace(r'^\s*$', np.nan,
Expand Down Expand Up @@ -357,18 +357,18 @@ def clean_df(self, df):
err[err == ''] = np.nan
df['fluence_err'] = err.astype(float)

for c in ('burst_width', 'scattering_time'):
cols = df[c].str.strip(' ms').str.partition(' (')[[0, 2]]
df[c] = cols[0].astype(float)
err = cols[2].str.strip(')')
err[err == ''] = np.nan
df[c + '_err'] = err.astype(float)
#for c in ('burst_width', 'scattering_time'):
# cols = df[c].str.strip(' ms').str.partition(' (')[[0, 2]]
# df[c] = cols[0].astype(float)
# err = cols[2].str.strip(')')
# err[err == ''] = np.nan
# df[c + '_err'] = err.astype(float)

cols = df.burst_bandwidth.str.strip(' MHz').str.partition(' (')[[0, 2]]
df['burst_bandwidth'] = cols[0].astype(float)
err = cols[2].str.strip(')')
err[err == ''] = np.nan
df['burst_bandwidth_err'] = err.astype(float)
#cols = df.burst_bandwidth.str.strip(' MHz').str.partition(' (')[[0, 2]]
#df['burst_bandwidth'] = cols[0].astype(float)
#err = cols[2].str.strip(')')
#err[err == ''] = np.nan
#df['burst_bandwidth_err'] = err.astype(float)

# Commenting out as some FAST entries seem to use GHz
# instead of MHz units in the reference frequency field
Expand All @@ -378,11 +378,11 @@ def clean_df(self, df):
s = 'sampling_time'
df[s] = df[s].str.strip(' ms').astype(float)

cols = df.rm.str.strip(' rad/m2').str.partition(' (')[[0, 2]]
df['rm'] = cols[0].astype(float)
err = cols[2].str.strip(')')
err[err == ''] = np.nan
df['rm_err'] = err.astype(float)
#cols = df.rm.str.strip(' rad/m2').str.partition(' (')[[0, 2]]
#df['rm'] = cols[0].astype(float)
#err = cols[2].str.strip(')')
#err[err == ''] = np.nan
#df['rm_err'] = err.astype(float)

# Convert time columns to datetime objects
dates = ('time_received', 'barycentric_event_time', 'discovery_date',
Expand Down