Skip to content

Commit

Permalink
PR polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
profxj committed Jul 10, 2023
1 parent 5230cd1 commit 448e723
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 54 deletions.
34 changes: 1 addition & 33 deletions astropath/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load_galaxies(cosmos_file:str=None):
df = pandas.read_feather(cosmos_file)

# Cut
df = df[df['mu_class'] == 1]
df = df[df['mu_class'] == 1] # Filter out stars
df = df[~np.isnan(df['kron_radius'])]

pix_to_arcsec_kron = 0.03*units.arcsec
Expand All @@ -52,35 +52,3 @@ def load_galaxies(cosmos_file:str=None):
# Return
return df


'''
# NOT IMPLEMENTED YET
def gen_frb_galaxy_pairs(cosmos_df:pandas.DataFrame,
a_sigma:units.Quantity=1*units.arcsec,
b_sigma:units.Quantity=1*units.arcsec,
pa_mode:str='fixed',
pa_value:float=0.):
frbs = []
frb_with_gal = []
for i, row in tqdm.tqdm(cosmos_df.iterrows()):
coord = SkyCoord(ra=row['ra']*units.degree, dec=row['dec']*u.degree)
#
loc_uncertainity = np.random.normal(scale=loc_sigma.value)*units.arcsec
loc_pa = float(np.random.uniform(size=1, low=0., high=360.))
coord_with_loc_uncertainity = coord.directional_offset_by(loc_pa*units.deg, loc_uncertainity)
# theta_max = pix_to_arcsec*row['flux_radius']
theta_max = 2*row['half_light']
galaxy_offset = np.random.uniform(low=0, high=theta_max)*units.arcsec
gal_pa = float(np.random.uniform(size=1, low=0., high=360.))
frb_coord = coord_with_loc_uncertainity.directional_offset_by(gal_pa*units.deg, galaxy_offset)
row['frb_ra'] = frb_coord.ra.value
row['frb_dec'] = frb_coord.dec.value
frbs.append([row['name'], row['frb_ra'], row['frb_dec'], loc_sigma.value])
frb_with_gal.append(row)
'''
35 changes: 15 additions & 20 deletions astropath/montecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def run_em(mc_frbs:pandas.DataFrame, mc_galaxies:pandas.DataFrame,
debug:bool=False):
""" Run the Monte Carlo analysis
Upon completion, a CSV file of the results is written to outfile.
Args:
mc_frbs (pandas.DataFrame):
Table of FRBs to analyze
Expand All @@ -102,16 +104,19 @@ def run_em(mc_frbs:pandas.DataFrame, mc_galaxies:pandas.DataFrame,
Prior for the PATH analysis
outfile (str):
Name of the output file
frb_ee (dict):
FRB error ellipse parameters
galaxy_coords (_type_, optional): _description_. Defaults to None.
box_hwidth (float, optional): _description_. Defaults to 20..
step_size (float, optional): _description_. Defaults to 0.1.
mag_lim (float, optional): _description_. Defaults to None.
ncpu (int, optional): _description_. Defaults to 15.
multi (bool, optional): _description_. Defaults to True.
mc_defs (dict, optional): _description_. Defaults to None.
debug (bool, optional): _description_. Defaults to False.
frb_ee (dict or str):
FRB error ellipse parameters as dictionary or string ('loc_sig')
which then uses the loc_sig column of mc_frbs
galaxy_coords (_type_, optional): Galaxy coordiantes. Defaults to None.
box_hwidth (float, optional): PATH parameter setting the analysis region (arcsec). Defaults to 20..
step_size (float, optional): PATH parameter setting the step size of the analysis region (arcsec). Defaults to 0.1.
mag_lim (float, optional): If provided, treats any source brighter than this limit as a star
and ignore is. Defaults to None.
ncpu (int, optional): If multi=True and we use multi-processing, use this many CPUs. Defaults to 15.
multi (bool, optional): If True, use multi-processing. Defaults to True.
mc_defs (dict, optional): A dict describing the plate_scale and filter
of the survey. Defaults to None.
debug (bool, optional): Defaults to False.
Raises:
IOError: _description_
Expand Down Expand Up @@ -208,16 +213,6 @@ def run_em(mc_frbs:pandas.DataFrame, mc_galaxies:pandas.DataFrame,
results = path_calc(idx_FRB, frb_coords[idx_FRB], frb_ee_list[idx_FRB],
list_candidates[idx_FRB], path_prior,
box_hwidth, step_size)
embed(header='211 of montecarlo.py')
'''
all_tbls = []
for idx_FRB in range(nFRB):
sv_tbl = path_calc(frb_coords[idx_FRB], mc_galaxies, galaxy_coords,
FRB, frbA, mc_defs, prior)
sv_tbl['iFRB'] = idx_FRB
all_tbls.append(sv_tbl)
'''
if debug:
embed(header='montecarlo: 195')

Expand Down
2 changes: 1 addition & 1 deletion calculations/CHIME/GBO/py/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_frbs(outfile:str, chime_mr_tbl:str='CHIME_mr_5Jyms_150.parquet',
outfile (str):
Filename for the output table (pandas)
chime_mr_tbl (str, optional): Defaults to 'CHIME_mr_5Jyms_150.parquet'.
Table of estimated CHIME/FRB m_r values for FRBs
Table of estimated host magnitude m_r values for CHIME/FRBs
m_r_min (float, optional): Defaults to 15..
Minimum m_r value for the CHIME/FRB distribution
m_r_max (float, optional): Defaults to 26..
Expand Down

0 comments on commit 448e723

Please sign in to comment.