In [ ]:
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
In [ ]:
image_ids = pd.read_csv("./gold_data_ids.txt", header=None, names=['image_id'])
image_ids = image_ids.image_id.values
In [ ]:
image_ids
In [ ]:
datapath='gold_comparison'
In [ ]:
from planet4 import markings, clustering, gold_standard_checker, gold_standard_plotter, io
In [ ]:
len(image_ids)
In [ ]:
from pathlib import Path
from planet4 import plotting
def plot_gold_comparison(id_, datapath):
fig, axes = plt.subplots(2, 2, figsize=(8, 5))
axes = axes.ravel()
fig.suptitle(id_)
plotting.plot_finals(id_, datapath, axes[0])
axes[0].set_title(f'Final objects.')
imgid = markings.ImageID(id_)
for ax, member in zip(axes[1:], markings.gold_members[:]):
ax.set_title(member)
for kind in ['fan', 'blotch']:
imgid.plot_markings(kind, ax=ax, user_name=member)
fig.savefig(f"plots/gold_member_comparisons/{id_}_gold_comparison.png", dpi=150)
plt.close('all')
In [ ]:
savedir = Path('plots/gold_member_comparisons')
savedir.mkdir(exist_ok=True, parents=True)
catalog = 'gold_comparison'
for id_ in image_ids:
plot_gold_comparison(id_, datapath=catalog)
In [ ]:
db = io.DBManager()
In [ ]:
data = db.get_image_id_markings('bsn')
In [ ]:
data.filter(regex='tile').drop_duplicates()
In [ ]:
data.filter(regex='image_name').drop_duplicates()
In [ ]:
from planet4 import plotting, markings
In [ ]:
imgid = markings.ImageID('bsn')
In [ ]:
imgid.plot_all()
In [ ]:
fig, ax = plt.subplots()
plotting.plot_finals('bsn', datapath=datapath, ax=ax)
In [ ]:
plotting.plot_clustered_blotches('bsn', datapath=datapath)
In [ ]:
In [ ]:
In [ ]:
pm = io.PathManager(image_ids[0])
In [ ]:
pm.final_blotchfile.exists()
In [ ]:
io.check_and_pad_id(image_ids.iloc[0])
In [ ]:
io.check_and_pad_id('l1r')
In [ ]:
image_ids.iloc[0]
In [ ]:
def check_and_pad_id(imgid):
if imgid is None:
return None
imgid_template = "APF0000000"
if len(imgid) < len(imgid_template):
imgid = imgid_template[:-len(imgid)] + imgid
return imgid
In [ ]:
check_and_pad_id()
In [ ]:
savedir = Path('plots/gold_member_comparisons')
savedir.mkdir(exist_ok=True, parents=True)
catalog = 'catalog_1.0b'
for i,apfid in enumerate(apfids):
print(100*i/len(apfids))
pm = io.PathManager(id_=apfid, datapath=catalog)
imgid = markings.ImageID(id_, scope='planet4')
for kind in ['fan', 'blotch']:
fig, axes = plt.subplots(2, 2, figsize=(10,8))
axes = axes.ravel()
fig.suptitle(apfid+' '+kind)
imgid.plot_markings(kind, data=getattr(pm, f"final{kind}df"), with_center=True)
axes[0].set_title(f'Final {kind} objects.')
for goldstar, ax in zip(markings.gold_members[:3], axes[1:]):
func(ax=ax, user_name=goldstar)
ax.set_title(goldstar)
fname = "{number}_{apfid}_{kind}.png".format(number=str(i).zfill(2),
apfid=apfid,
kind=func.__name__.split('_')[1])
plt.savefig(savepath+fname, dpi=150)
plt.close(fig)
In [ ]: