def filter(hit_rate=0.3): cat = get_catalog() infile = 'stamps2.h5' on_id = np.array(map(int, h5py.File(infile, 'r')['on'].keys())) rgbs = h5py.File(infile, 'r')['on'].values() #has green channel... def has_green(rgb): return (rgb[:, :, 1] == 0).mean() < 0.3 good = np.array([has_green(r) for r in rgbs], dtype=np.bool) #...and hit rate > 0.3 good = good & (cat[on_id, -1] > 0.3) result = [_on_args(cat, row) for row in on_id[good]] return result
def main(): cat = get_catalog() lon, lat, pa, a, b, t, hr = cat.T cat_stamps = np.column_stack((lon, lat, 1.3 * (a + t))) scores = json.load(open('../models/bubble_scores.json')) stamps = np.array(scores['params']) stamps = stamps[:, 1:] scores = np.array(scores['scores']) ind = xmatch(stamps, cat_stamps) assert (stamps[ind] == cat_stamps).all() scores = pbubble(scores[ind], hr) print (scores > .5).sum(), (scores > .8).sum() table = Table([lon, lat, pa, a, b, t, scores], names=('lon', 'lat', 'pa', 'a', 'b', 't', 'prob')) with open('pdr1.csv', 'w') as outfile: ascii.write(table, outfile, delimiter=',')
from astropy.io import ascii from bubbly.dr1 import get_catalog from astropy.table import Column hr = get_catalog()[:, -1] data = ascii.read('../data/pdr1.csv') caption=r"""Bubble probabilities for objects in the Milky Way Project catalog. Non-finite probabilities correspond to objects near the edge of the data, which Brut cannot analyze.\label{table:prob_table}""" data['a'] *= 60 data['b'] *= 60 data['t'] *= 60 hr = Column(name='Hit Rate', data=hr) data.add_column(hr, index=6) data.rename_column('lon', '$\ell$') data.rename_column('lat', '$b$') data.rename_column('pa', 'PA') data.rename_column('a', 'Semimajor axis') data.rename_column('b', 'Semiminor axis') data.remove_columns(['t']) data.rename_column('prob', 'P(Bubble)') formats = {'P(Bubble)': "%0.3f", 'PA': '%i', 'Semimajor axis': '%0.1f', 'Semiminor axis': '%0.1f', 'Thickness': '%0.1f'} units = {'$\ell$': 'deg',
from astropy.io import ascii from bubbly.dr1 import get_catalog from astropy.table import Column hr = get_catalog()[:, -1] data = ascii.read('../data/pdr1.csv') caption = r"""Bubble probabilities for objects in the Milky Way Project catalog. Non-finite probabilities correspond to objects near the edge of the data, which Brut cannot analyze.\label{table:prob_table}""" data['a'] *= 60 data['b'] *= 60 data['t'] *= 60 hr = Column(name='Hit Rate', data=hr) data.add_column(hr, index=6) data.rename_column('lon', '$\ell$') data.rename_column('lat', '$b$') data.rename_column('pa', 'PA') data.rename_column('a', 'Semimajor axis') data.rename_column('b', 'Semiminor axis') data.remove_columns(['t']) data.rename_column('prob', 'P(Bubble)') formats = { 'P(Bubble)': "%0.3f", 'PA': '%i', 'Semimajor axis': '%0.1f', 'Semiminor axis': '%0.1f', 'Thickness': '%0.1f' }