-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquicklook.py
82 lines (66 loc) · 2.6 KB
/
quicklook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Quicklook generation from L2bmin products.
Authors: Philip G. Brodrick, philip.brodrick@jpl.nasa.gov
"""
from spectral.io import envi
import numpy as np
from osgeo import gdal
import argparse
import os
import subprocess
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from mpl_toolkits.axes_grid1 import make_axes_locatable
from emit_utils.file_checks import envi_header
plt.switch_backend('agg')
def main():
parser = argparse.ArgumentParser(description="Translate to Rrs. and/or apply masks")
parser.add_argument('input_file', type=str, metavar='l2b file')
parser.add_argument('output_file', type=str, metavar='output file to write')
parser.add_argument('--unc_file', type=str, metavar='uncertainty file')
args = parser.parse_args()
ds = envi.open(envi_header(args.input_file))
dat = ds.open_memmap(interleave='bip').copy()
dat[dat == -9999] = np.nan
if args.unc_file is not None:
unc_ds = envi.open(envi_header(args.unc_file))
unc = unc_ds.open_memmap(interleave='bip').copy()
unc[unc == -9999] = np.nan
fig = plt.figure(figsize=(20,20))
gs = gridspec.GridSpec(2, 2, width_ratios=[1, 1], height_ratios=[1, 1])
ax = plt.subplot(gs[0,0])
im = plt.imshow(dat[...,0], vmin=0, vmax=0.25)
plt.xlabel('Crosstrack')
plt.ylabel('Downtrack')
plt.title('Group 1 Band Depth')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im, cax=cax)
ax = plt.subplot(gs[0,1])
im = plt.imshow(dat[...,2], vmin=0, vmax=0.25)
plt.xlabel('Crosstrack')
plt.ylabel('Downtrack')
plt.title('Group 2 Band Depth')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im, cax=cax)
if args.unc_file is not None:
ax = plt.subplot(gs[1,0])
im = plt.imshow(unc[...,0], vmin=0, vmax=0.025)
plt.xlabel('Crosstrack')
plt.ylabel('Downtrack')
plt.title('Group 1 Band Depth Uncertainty')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im, cax=cax)
ax = plt.subplot(gs[1,1])
im = plt.imshow(unc[...,2], vmin=0, vmax=0.025)
plt.xlabel('Crosstrack')
plt.ylabel('Downtrack')
plt.title('Group 2 Band Depth Uncertainty')
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
plt.colorbar(im, cax=cax)
plt.savefig(args.output_file, dpi=400, bbox_inches='tight')
if __name__ == "__main__":
main()