def __init__(self, Sfilename, model='Net1_FFN_v7', verbose=False): self.index = 0 self.settingfuncs = [self.setting1, self.setting2, self.setting3, self.setting4, self.setting5, self.setting6, self.setting7, self.setting8] if isinstance(model, str): self.modelname = model self.model = FFN(model) self.model.Load(verbose=verbose) elif isinstance(model, FFN): self.model = model self.modelname = self.model.name mask1, pmask1 = self.model.apply_mask(Sfilename) rgb, self.TitleStr = Vis.FalseColour(Sfilename, False) scn = DL.scene_loader(Sfilename) scn.load(['bayes_in', 'probability_cloud_single_in']) bmask = DL.upscale_repeat(scn['bayes_in'].values).astype('int') bmask = 1 - ((bmask & 2) / 2) bpmask = DL.upscale_repeat(scn['probability_cloud_single_in'].values) self.im1 = plt.imshow(rgb) plt.title('False colour image\n' + self.TitleStr) self.im2 = plt.imshow(mask1, cmap='Blues') self.im2.set_visible(False) bmask = DL.extract_mask(Sfilename, 'bayes_in', 2) self.im3 = plt.imshow(bmask, cmap='Reds') self.im3.set_visible(False) mask1 = mask1.astype('bool') temp = np.copy(rgb) temp[~mask1, :] = 254 / 255, 253 / 255, 185 / 255 self.im4 = plt.imshow(temp) self.im4.set_visible(False) rgb[mask1, :] = 74 / 255, 117 / 255, 50 / 255 self.im5 = plt.imshow(rgb) self.im5.set_visible(False) self.im6 = plt.imshow(1 - pmask1, cmap='Oranges') self.im6.set_visible(False) self.im7 = plt.imshow(1 - bpmask, cmap='Reds') self.im7.set_visible(False) maskdiff = bmask - mask1 self.im8 = plt.imshow(maskdiff, cmap='bwr') self.im8.set_visible(False) self.cbset = False self.cb = None
def mask_debug(Sfilename, model, verbose): if isinstance(model, str): modelname = model model = FFN(model) model.Load(verbose=verbose) elif isinstance(model, FFN): modelname = model.name mask1, pmask = model.apply_mask(Sfilename) rgb, TitleStr = Vis.FalseColour(Sfilename, False) plt.figure() plt.imshow(rgb) plt.title('False colour image\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) plt.figure() plt.imshow(mask1, cmap='Blues') plt.title(modelname + ' mask\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) plt.figure() bmask = DL.extract_mask(Sfilename, 'bayes_in', 2) plt.imshow(bmask, cmap='Reds') plt.title('Bayesian mask\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) plt.figure() mask1 = mask1.astype('bool') rgb[~mask1, :] = 254 / 255, 253 / 255, 185 / 255 plt.imshow(rgb) plt.title(modelname + ' masked false colour image\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) plt.figure() ax = plt.gca() im5 = plt.imshow(pmask, cmap='Oranges_r') plt.title(modelname + ' model output\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.1) plt.colorbar(im5, cax=cax) plt.figure() maskdiff = mask1 - bmask ax = plt.gca() im6 = plt.imshow(maskdiff, cmap='bwr_r') plt.title(modelname + ' mask - Bayesian mask\n' + TitleStr) plt.xlabel('km') plt.ylabel('km') plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000], [0, 250, 500, 750, 1000, 1250, 1500]) plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000]) divider = make_axes_locatable(ax) cax = divider.append_axes("right", size="5%", pad=0.1) plt.colorbar(im6, cax=cax) plt.show()