# Read data
f = cdms2.open(data_sample(ncfile))
u = f('u')
v = f('v')
f.close()

# Transect specs
tlons, tlats = transect_specs(u.getGrid(), lon0, lat0, lon1, lat1)
ttimes = (time0, time1)

# Compute transect
tu = transect(u, tlons, tlats, times=ttimes)
tv = transect(v, tlons, tlats, times=ttimes)

# Plot along time
s = stick2(tu,
           tv,
           figsize=(8, 3),
           title='Space-time transect of speed',
           show=False,
           top=0.85,
           quiver_width=0.002)

# Add a small map to show the transect positions
add_map_lines(u.getGrid(), tlons, tlats, map_zoom=0.5)

# Save
figfile = code_file_name(ext='png')
if os.path.exists(figfile): os.remove(figfile)
s.savefig(figfile, pdf=True)
Exemple #2
0
    kwplot[att] = getattr(args, att)
for att in ('color', 'linewidth'):
    val = getattr(args, att)
    if val is not None:
        kwplot[att] = val
kwplot['quiver_norm'] = args.qnorm
if len(vv) == 2 and args.qonly:
    kwplot['contour'] = kwplot['fill'] = False
if args.figsize:
    kwplot['figsize'] = tuple([float(v) for v in args.figsize.split(',')])
if args.res == 'off':
    args.res = None
kwplot['res'] = args.res

#del kwplot['color']
#kwplot = {'color':None}

# Adaptative plot
if ndim == 2:
    if order in ['yx', 'xy']:
        map2(vv, **kwplot)
    elif 't' in order:
        hov2(vv, **kwplot)
    else:
        plot2d(vv, **kwplot)
else:
    if len(vv) > 1:
        stick2(*vv, **kwplot)
    else:
        curve2(vv, **kwplot)
Exemple #3
0
    kwplot[att] = getattr(args, att)
for att in ('color', 'linewidth'):
    val = getattr(args, att)
    if val is not None:
        kwplot[att] = val
kwplot['quiver_norm'] = args.qnorm
if len(vv)==2 and args.qonly:
    kwplot['contour'] = kwplot['fill'] = False
if args.figsize:
    kwplot['figsize'] = tuple([float(v) for v in args.figsize.split(',')])
if args.res=='off':
    args.res = None
kwplot['res'] = args.res

#del kwplot['color']
#kwplot = {'color':None}

# Adaptative plot
if ndim==2:
    if order in ['yx', 'xy']:
        map2(vv, **kwplot)
    elif 't' in order:
        hov2(vv, **kwplot)
    else:
        plot2d(vv, **kwplot)
else:
    if len(vv)>1:
        stick2(*vv, **kwplot)
    else:
        curve2(vv, **kwplot)
# Imports
from vcmq import cdms2, data_sample, N, transect, stick2, code_file_name, os, \
    transect_specs, add_map_lines, create_time, IterDates, P

# Read data
f = cdms2.open(data_sample(ncfile))
u = f('u')
v = f('v')
f.close()

# Transect specs
tlons, tlats = transect_specs(u.getGrid(), lon0, lat0, lon1, lat1)
ttimes = create_time(IterDates((time0, time1), len(tlons), closed=True))

# Compute transect
tu = transect(u, tlons, tlats, times=ttimes)
tv = transect(v, tlons, tlats, times=ttimes)

# Plot along time
s = stick2(tu, tv, figsize=(8,3), title='Space-time transect of speed', 
    show=False, top=0.85, quiver_width=0.002)

# Add a small map to show the transect positions
add_map_lines(u.getGrid(), tlons, tlats, map_zoom=0.5)

# Save
figfile = code_file_name(ext='png')
if os.path.exists(figfile): os.remove(figfile)
s.savefig(figfile, pdf=True)