In [89]:
from planet4 import io
In [110]:
p = Path('/Users/klay6683/Dropbox/data/planet4/duplicates_testing/')
In [111]:
p = p / 'applied_cut_0.5'
p
Out[111]:
In [112]:
def hunt_bug(fname):
df = pd.read_csv(fname)
return (df[df.duplicated()].shape[0])
In [113]:
fnames = p.glob('*.csv')
obsids = []
no_of_dupes = []
kind = []
i = 0
for fname in fnames:
i+=1
tokens = fname.name.split('_')
obsids.append('_'.join(tokens[:3]))
kind.append(tokens[3].split('.')[0])
no_of_dupes.append(hunt_bug(fname))
print(i, 'no of files.')
In [114]:
df = pd.DataFrame(dict(obsids=obsids, no_of_dupes=no_of_dupes,
kind=kind))
df.sort_values(by='no_of_dupes', ascending=False)
Out[114]:
In [7]:
df[df.no_of_dupes>0].shape
Out[7]:
In [8]:
from hirise import hirise_tools as ht
In [9]:
df['orbit'] = df.obsids.map(lambda x: int(ht.OBSERVATION_ID(x).orbit))
In [10]:
%matplotlib inline
In [11]:
df.orbit.plot()
Out[11]:
In [12]:
df[df.orbit < 18000].head(15)
Out[12]:
In [94]:
obsid = 'ESP_021520_0925'
In [95]:
fnames = list(p.glob(obsid+'*.csv'))
fnames
Out[95]:
In [96]:
blotches = pd.read_csv(fnames[0])
fans = pd.read_csv(fnames[1])
# fnotches = pd.read_csv(fnames[2])
In [97]:
for item in [blotches,fans]:
print(item.duplicated().value_counts())
In [98]:
g = blotches[blotches.duplicated(keep='first')].groupby('image_id')
g.size().sort_values(ascending=False).head(10)
Out[98]:
In [99]:
from planet4 import plotting,markings
In [100]:
image_id = 'APF0000w0x'
blotches_id = blotches[blotches.image_id==image_id]
fans_id = fans[fans.image_id==image_id]
In [101]:
blotches_id.head()
Out[101]:
In [102]:
dbname = '/Users/klay6683/Dropbox/data/planet4/2016-05-29_planet_four_classifications_queryable_cleaned_seasons2and3.h5'
p4id = markings.ImageID(image_id, dbname=dbname, scope='planet4')
In [103]:
%matplotlib nbagg
In [38]:
p4id.plot_blotches()
In [27]:
fig, ax = plt.subplots()
p4id.plot_blotches(blotches=blotches_id, ax=ax)
In [104]:
fig, ax = plt.subplots()
p4id.plot_fans(ax=ax)
In [105]:
fig, ax = plt.subplots()
p4id.plot_fans(fans=fans_id, ax=ax)
In [40]:
from planet4 import clustering,io
In [128]:
fname = '/Users/klay6683/data/planet4/2016-05-29_planet_four_classifications_queryable_cleaned.h5'
In [129]:
cm = clustering.ClusteringManager(output_dir='duplicates_testing',
dbname=fname)
In [130]:
cm.db.dbname
Out[130]:
In [48]:
db = io.DBManager(dbname=fname)
In [54]:
obsiddata = db.get_image_name_markings(obsid)
In [57]:
image_id
Out[57]:
In [64]:
twoids = obsiddata.image_id.unique()[:2]
In [71]:
imageids = list(twoids) + [image_id]
In [72]:
imageids
Out[72]:
In [73]:
data = obsiddata[obsiddata.image_id.isin(imageids)]
In [82]:
x_tiles = [1,3]
y_tiles = [36, 38]
data = []
for x_tile in x_tiles:
for y_tile in y_tiles:
f1 = obsiddata.x_tile == x_tile
f2 = obsiddata.y_tile == y_tile
data.append(obsiddata[f1 & f2])
data.append(obsiddata[obsiddata.image_id==image_id])
data = pd.concat(data)
In [83]:
data.image_id.unique()
Out[83]:
In [84]:
cm.cluster_image_name(obsid, data=data)
In [115]:
plotting.plot_clustered_fans(datapath='duplicates_testing',image_id=image_id, scope_id=obsid)
In [131]:
cm = clustering.ClusteringManager(scope='hirise', output_dir='testing_by_obsid',
dbname=fname)
In [133]:
cm.db.dbname
Out[133]:
In [87]:
cm.cluster_image_name(obsid)
In [107]:
plotting.plot_clustered_fans(datapath='testing_by_obsid', image_id=image_id,
scope_id=obsid)
In [146]:
from hirise import hirise_tools as ht
from pathlib import Path
pid = ht.PRODUCT_ID("PSP_003092_0985_RED")
ht.download_product(Path(pid.jp2_path), saveroot="your_jp2_folder")
In [147]:
pid.jp2_path
Out[147]:
In [ ]: