def run(): mtime = {} needup = [] region_tiles = glob.glob("region.*x*.png") # first pass get all tile st_mtime for fregion in region_tiles: XxY = fregion.split('.')[1] sregion = os.stat(fregion) mtime[XxY] = sregion.st_mtime fprecis = "display.%s.precis.png"%XxY if os.path.isfile(fprecis): sprecis = os.stat(fprecis) if sregion.st_mtime <= sprecis.st_mtime: continue needup.append(XxY) mtime_min = min(mtime.values()) mtime_max = max(mtime.values()) mtime_fac = 1./(mtime_max - mtime_min) mtime_col = lambda mt: (mt - mtime_min) * mtime_fac for XxY in needup: img = load("region.%s.png"%XxY) alpha = img[:,:,1] save("display.%s.precis.png"%XxY, (viridis(alpha)*255).astype('uint8')) alpha.fill(mtime_col(mtime[XxY])*255) save("display.%s.mtime.png"%XxY, (viridis(alpha)*255).astype('uint8'))
def run(): mtime = {} needup = [] region_tiles = glob.glob("region.*x*.png") # first pass get all tile st_mtime for fregion in region_tiles: XxY = fregion.split('.')[1] sregion = os.stat(fregion) mtime[XxY] = sregion.st_mtime fprecis = "display.%s.precis.png" % XxY if os.path.isfile(fprecis): sprecis = os.stat(fprecis) if sregion.st_mtime <= sprecis.st_mtime: continue needup.append(XxY) mtime_min = min(mtime.values()) mtime_max = max(mtime.values()) mtime_fac = 1. / (mtime_max - mtime_min) mtime_col = lambda mt: (mt - mtime_min) * mtime_fac for XxY in needup: img = load("region.%s.png" % XxY) alpha = img[:, :, 1] save("display.%s.precis.png" % XxY, (viridis(alpha) * 255).astype('uint8')) alpha.fill(mtime_col(mtime[XxY]) * 255) save("display.%s.mtime.png" % XxY, (viridis(alpha) * 255).astype('uint8'))
def convert(fin, fout, cmin, cmax, cmap='viridis'): iin = load(fin) # get band as a numpy.array img = iin[:,:,0] alp = iin[:,:,1] img = (img - cmin) * (1./(cmax - cmin)) img[img > 1] = 1 img[img < 0] = 0 cmap = getattr(cm, cmap) img = (cmap(img)*255).astype('uint8') img[alp < 1] = 255 save(fout, img)