methane_super_emitters.visualize

 1import numpy as np
 2import matplotlib.pyplot as plt
 3import click
 4import glob
 5import os
 6import random
 7
 8
 9@click.command()
10@click.option("-i", "--input-dir", help="Folder with samples")
11def main(input_dir):
12    sample = random.sample(glob.glob(os.path.join(input_dir, "*.npz")), 64)
13    fig = plt.figure(figsize=(8, 8))
14    row = 0
15    col = 0
16    for image in sample:
17        data = np.load(image)
18        m = data["methane"]
19        mask = data["mask"]
20        m[mask] = 0.0
21        ax = fig.add_subplot(8, 8, row * 8 + col + 1)
22        ax.imshow(m, vmin=-30, vmax=30)
23        ax.set_xticks([])
24        ax.set_yticks([])
25        ax.set_aspect("equal")
26        col = col + 1
27        if col >= 8:
28            col = 0
29            row += 1
30            if row >= 8:
31                row = 0
32    plt.subplots_adjust(wspace=0, hspace=0)
33    plt.show()
34
35
36if __name__ == "__main__":
37    main()