In [ ]:
    
from planet4 import plotting, catalog_production
    
In [ ]:
    
rm = catalog_production.ReleaseManager('v1.0b4')
    
In [ ]:
    
fans = rm.read_fan_file()
blotches = rm.read_blotch_file()
    
In [ ]:
    
cols = ['angle', 'distance', 'tile_id', 'marking_id',
       'obsid', 'spread', 
       'l_s', 'map_scale', 'north_azimuth',
       'PlanetographicLatitude',
       'PositiveEast360Longitude']
    
In [ ]:
    
fans.head()
    
In [ ]:
    
fans[cols].rename(dict(PlanetographicLatitude='Latitude',
                       PositiveEast360Longitude='Longitude'),
                  axis=1).head()
    
In [ ]:
    
fans.columns
    
In [ ]:
    
fan_counts = fans.groupby('tile_id').size()
blotch_counts = blotches.groupby('tile_id').size()
    
In [ ]:
    
ids = fan_counts[fan_counts > 4][fan_counts < 10].index
    
In [ ]:
    
pure_fans = list(set(ids) - set(blotches.tile_id))
    
In [ ]:
    
len(ids)
    
In [ ]:
    
len(pure_fans)
    
In [ ]:
    
rm.savefolder
    
In [ ]:
    
%matplotlib ipympl
    
In [ ]:
    
plt.close('all')
    
In [ ]:
    
from ipywidgets import interact
    
In [ ]:
    
id_ = pure_fans[51]
    
In [ ]:
    
def do_plot(i):
    id_ = pure_fans[i]
    plotting.plot_image_id_pipeline(id_, datapath=rm.savefolder, via_obsid=False,
                                    save=True, figsize=(8,4),
                                    saveroot='/Users/klay6683/Dropbox/src/p4_paper1/figures')
    
In [ ]:
    
interact(do_plot, i=48)
    
In [ ]:
    
from planet4 import markings
    
In [ ]:
    
def do_plot(i=0):
    plt.close('all')
    fig, ax = plt.subplots()
    markings.ImageID(pure_fans[i]).show_subframe(ax=ax)
    ax.set_title(pure_fans[i])
    
In [ ]:
    
interact(do_plot, i=(0,len(pure_fans),1))
    
In [ ]:
    
markings.ImageID('6n3').image_name
    
In [ ]:
    
from planet4 import markings
    
In [ ]:
    
markings.ImageID(pure_fans[15]).image_name
    
In [ ]:
    
plotting.plot_raw_fans(id_)
    
In [ ]:
    
plotting.plot_finals(id_, datapath=rm.savefolder)
    
In [ ]:
    
g_id = fans.groupby('tile_id')
    
In [ ]:
    
g_id.size().sort_values(ascending=False).head()
    
In [ ]:
    
blotches.groupby('tile_id').size().sort_values(ascending=False).head()
    
In [ ]:
    
plotting.plot_finals('6mr', datapath=rm.savefolder)
    
In [ ]:
    
plotting.plot_finals('7t9', datapath=rm.savefolder)
    
In [ ]:
    
from planet4 import dbscan
    
In [ ]:
    
db = dbscan.DBScanner()
    
In [ ]:
    
import seaborn as sns
sns.set_context('paper')
    
In [ ]:
    
db.parameter_scan(id_, 'fan', [0.13, 0.2], [10, 20, 30], size_to_scan='small')
    
In [ ]:
    
plotting.plot_image_id_pipeline('bk7', datapath=rm.savefolder, via_obsid=False,
                                    save=True, figsize=(8,4), do_title=False,
                                    saveroot='/Users/klay6683/Dropbox/src/p4_paper1/figures')
    
In [ ]:
    
plotting.plot_image_id_pipeline('ops', datapath=rm.savefolder, via_obsid=False,
                                    save=True, figsize=(8,4), do_title=False,
                                    saveroot='/Users/klay6683/Dropbox/src/p4_paper1/figures')
    
In [ ]:
    
plotting.plot_image_id_pipeline('b0t', datapath=rm.savefolder, via_obsid=False,
                                    save=True, figsize=(8,4), do_title=False,
                                    saveroot='/Users/klay6683/Dropbox/src/p4_paper1/figures')
    
In [ ]:
    
from astropy.table import Table
tab = Table.read('/Users/klay6683/Dropbox/src/p4_paper1/rois_table.tex')
    
In [ ]:
    
rois = tab.to_pandas()
    
In [ ]:
    
rois.drop(0, inplace=True)
    
In [ ]:
    
rois.head()
    
In [ ]:
    
rois.columns = ['Latitude', 'Longitude', 'Informal Name', '# Images (MY29)', '# Images (MY30)']
    
In [ ]:
    
rois.head()
    
In [ ]:
    
rois.to_csv('/Users/klay6683/Dropbox/data/planet4/p4_analysis/rois.csv')
    
In [ ]: