Esempio n. 1
0
cmap.set_under('#FFFFFF')
# Define a normalization from values -> colors
bndry = [1, 10, 50, 100, 200, 500, 1000, 2000]
norm = colors.BoundaryNorm(bndry, len(bndry))

plotter_options = {
    'imshow_options': {
        'cmap': cmap,
        'norm': norm,
    },
    'title': title,
}

# make a plot template
p = plotter_solo.Plotter(array=arr,
                         tstamps=tstamps,
                         extent=extent,
                         plotter_options=plotter_options)


# function to save one time frame
def saveone(i):
    ts = tstamps[i]
    # oname = wdir / ts.strftime('img-%m%d%H%M.png')
    oname = wdir / f'{i:04}.png'
    footnote = str(ts)
    p(oname, tidx=i, footnote=footnote)


# save all frames in parallel
# 68 for stampede, 24 for ls5
with Pool(24) as pool:
Esempio n. 2
0
# save better resolution image
mpl.rcParams['savefig.dpi'] = 300

fname = '../data/tseries_ch4_1min_conc_co_fl.dat'
with open(fname) as f:
    dat = reader.Reader(f, slice(60 * 12, 60 * 12 + 1))

g = dat['grid']
ext = (g['x0'], g['x0'] + g['dx'] * g['nx'], g['y0'],
       g['y0'] + g['dy'] * g['ny'])
ext = [_ * 1000 for _ in ext]
print(ext)

arr = dat['v'][:, ::-1, :]

# https://ocefpaf.github.io/python4oceanographers/blog/2015/03/02/geotiff/
bga = pu.background_adder('../resources/gamma3_res2.tif')

p = psolo.Plotter(
    arr,
    dat['ts'],
    extent=ext,
    plotter_options={
        'customize_once': bga.set_background,
        #'customize_after': bga.refresh_background,
    })

p('r.png')

# i may get image from NAIP or something and use it as background?
Esempio n. 3
0
                Polygon([(extent[x], extent[y])
                         for x, y in ((0, 2), (0, 3), (1, 3), (1, 2), (0, 2))])
            ],
            crs=LambertConformalTCEQ(),
            facecolor='none',
            edgecolor='black',
            lw=.6,
        ),
        # grid lines
        lambda p: add_gridlines(p.ax, {
            'bottom_labels': False,
            'right_labels': False
        })
    ]
}

# make a plot template
p = plotter_solo.Plotter(array=arr,
                         tstamps=tstamps,
                         x=x,
                         y=y,
                         projection=LambertConformalTCEQ(),
                         plotter_options=plotter_options)

# make single image file (for QA)
ntsteps = len(tstamps)
p.savefig((odir / oname).with_suffix('.png'), tidx=min(16 * 60, ntsteps - 1))

# make mpeg file
p.savemp4(odir / oname, wdir=wdir)
Esempio n. 4
0
# save better resolution image
mpl.rcParams['savefig.dpi'] = 300

fname = '../data/tseries_ch4_1min_conc_co_fl.dat'
with open(fname) as f:
    dat = reader.Reader(f, slice(60 * 12, 60 * 12 + 1))

g = dat['grid']
ext = (g['x0'], g['x0'] + g['dx'] * g['nx'], g['y0'],
       g['y0'] + g['dy'] * g['ny'])
ext = [_ * 1000 for _ in ext]
print(ext)

arr = dat['v'][:, ::-1, :]

p = psolo.Plotter(arr, dat['ts'], extent=ext)
# the number is "zoom level"
# i found max i can go is 22, but it still ugly
# p.ax.add_image(GoogleTiles(), 22)#, alpha=.1)
# p.ax.add_image(GoogleTiles(style='satellite'), 22)#, alpha=.1)

# https://ocefpaf.github.io/python4oceanographers/blog/2015/03/02/geotiff/
ds = gdal.Open('../resources/gamma3_res2.tif')
data = ds.ReadAsArray()
gt = ds.GetGeoTransform()
projection = p.ax.projection  # i know they match
extent = (gt[0], gt[0] + ds.RasterXSize * gt[1],
          gt[3] + ds.RasterYSize * gt[5], gt[3])
print(extent)
extent = p.ax.get_xlim() + p.ax.get_ylim()
print(extent)