Ejemplo n.º 1
0
def plot_time_series(varname='salt',
                     x=-123.1126,
                     y=47.4218,
                     dir='.',
                     seconds=3600,
                     filelist=None,
                     imgfile='~/tmp/rompy.time_series.png',
                     title=None,
                     dt0=None,
                     dt1=None):

    if filelist == None or filelist == []:
        filelist = glob.glob(os.path.join(dir, 'ocean_his*.nc'))

    # lat lon points for Hoodsport ORCA buoy
    x = [x]
    y = [y]

    clim_map = {
        'temp': [0, 8, 20, 20],
        'salt': [0, 21, 33, 33],
        'U': [-2, -2, 2, 2]
    }
    clabel_map = {'temp': u'\u00B0 C', 'salt': 'psu', 'U': 'm/s'}
    #(data, coords) = rompy.extract('ocean_his_1000.nc', varname='salt', extraction_type='profile', x=x, y=y)
    #	(data, time,z) = extract_from_series(filelist,varname=varname,extraction_type='profile',x=x,y=y,freq=dt.timedelta(seconds=seconds))

    if dt0 is None:
        dt0 = dt.datetime(2006, 06, 01, 0, 0, 0)
    else:
        dt0 = dt.datetime.strptime(dt0, '%Y%m%d%H%M')
    if dt1 is None:
        dt1 = dt.datetime(2006, 07, 01, 0, 0, 0)
    else:
        dt1 = dt.datetime.strptime(dt1, '%Y%m%d%H%M')

    (data, time, z) = extract_from_two_datetimes(x=x,
                                                 y=y,
                                                 dt0=dt0,
                                                 dt1=dt1,
                                                 varname=varname,
                                                 interval=seconds,
                                                 basedir=dir)

    if not os.path.exists(os.path.dirname(imgfile)):
        os.makedirs(os.path.dirname(imgfile))
    plot_utils.plot_time_series_profile(time,
                                        z,
                                        data,
                                        filename=imgfile,
                                        clim=clim_map[varname],
                                        varname=varname,
                                        title=title,
                                        caxis_label=clabel_map[varname])
Ejemplo n.º 2
0
def plot_time_series(varname='salt', x=-123.1126, y=47.4218, dir='.', seconds=3600, filelist=None, imgfile='~/tmp/rompy.time_series.png',title=None, dt0=None, dt1=None):
	
	if filelist == None or filelist == []:
		filelist = glob.glob(os.path.join(dir,'ocean_his*.nc'))
	
	# lat lon points for Hoodsport ORCA buoy
	x = [x]
	y = [y]
	
	clim_map = {
		'temp':[0,8,20,20],
		'salt':[0,21,33,33],
		'U':[-2,-2,2,2]
		}
	clabel_map = {
		'temp': u'\u00B0 C',
		'salt': 'psu',
		'U': 'm/s'
		}
	#(data, coords) = rompy.extract('ocean_his_1000.nc', varname='salt', extraction_type='profile', x=x, y=y)
#	(data, time,z) = extract_from_series(filelist,varname=varname,extraction_type='profile',x=x,y=y,freq=dt.timedelta(seconds=seconds))
	
	if dt0 is None:
		dt0 = dt.datetime(2006,06,01,0,0,0)
	else:
		dt0 = dt.datetime.strptime(dt0,'%Y%m%d%H%M')
	if dt1 is None:
		dt1 = dt.datetime(2006,07,01,0,0,0)
	else:
		dt1 = dt.datetime.strptime(dt1,'%Y%m%d%H%M')
	
	(data, time,z) = extract_from_two_datetimes(x=x,
												y=y,
												dt0=dt0,
												dt1=dt1,
												varname=varname,
												interval=seconds,
												basedir=dir)
	
	if not os.path.exists(os.path.dirname(imgfile)):
		os.makedirs(os.path.dirname(imgfile))
	plot_utils.plot_time_series_profile(time,z,data,
										filename=imgfile,
										clim=clim_map[varname],
										varname=varname,
										title=title,
										caxis_label=clabel_map[varname])
Ejemplo n.º 3
0
#---------------------------------------------------------------------------------------------------
filelist = glob.glob('ocean_his*.nc')

#x,y = utils.station_to_lat_lon([20])
x = [-122.3904]
y = [47.6108]
varname='salt'
clim_map = {
	'temp':[0,8,20,20],
	'salt':[0,21,33,33],
	'U':[-2,-2,2,2]
	}
#(data, coords) = rompy.extract('ocean_his_1000.nc', varname='salt', extraction_type='profile', x=x, y=y)
(data, time,z) = extract_from_series(filelist,varname=varname,extraction_type='profile',x=x,y=y,freq=dt.timedelta(seconds=1800))

plot_time_series_profile(time,z,data,clim=clim_map[varname],varname=varname)

#print(len(time),len(time[0]))
#print(data)
#print(z)

# 
# fontsize = 8
# 
# clim = [0,21,33,33]
# cmap = banas_hsv_cm(clim[0],clim[1],clim[2],clim[3])
# norm = Normalize(vmin=clim[0],vmax=clim[-1],clip=False)
# sm = ScalarMappable(norm=norm,cmap=cmap)
# sm.set_clim(vmin=clim[0],vmax=clim[-1])
# sm.set_array(np.array([0]))
# 
Ejemplo n.º 4
0
clim_map = {
    'temp': [0, 8, 20, 20],
    'salt': [0, 21, 33, 33],
    'U': [-2, -2, 2, 2]
}
#(data, coords) = rompy.extract('ocean_his_1000.nc', varname='salt', extraction_type='profile', x=x, y=y)
(data, time, z) = extract_from_series(filelist,
                                      varname=varname,
                                      extraction_type='profile',
                                      x=x,
                                      y=y,
                                      freq=dt.timedelta(seconds=1800))

plot_time_series_profile(time,
                         z,
                         data,
                         clim=clim_map[varname],
                         varname=varname)

#print(len(time),len(time[0]))
#print(data)
#print(z)

#
# fontsize = 8
#
# clim = [0,21,33,33]
# cmap = banas_hsv_cm(clim[0],clim[1],clim[2],clim[3])
# norm = Normalize(vmin=clim[0],vmax=clim[-1],clip=False)
# sm = ScalarMappable(norm=norm,cmap=cmap)
# sm.set_clim(vmin=clim[0],vmax=clim[-1])
#x = [-122.3904]
#y = [47.6108]

#x,y = station_to_lat_lon(['admiralty inlet'])
x,y = station_to_lat_lon([4])


dt0 = dt.datetime(2006,06,11,0,0,0)
dt1 = dt.datetime(2006,06,13,0,0,0)

interval = 3600 # seconds

varname='salt'

clim_map = {
	'temp':[0,8,20,20],
	'salt':[0,21,33,33],
	'U':[-2,-2,2,2]
	}

d,t,z = extract_from_series.extract_from_two_datetimes(x,y,dt0,dt1,varname=varname,interval=interval)

#print('z')
#print(z)
#print('time')
#print(t)
#print('data')
#print(d)
plot_time_series_profile(t,z,d,clim=clim_map[varname],varname=varname,filename='/Users/lederer/tmp/rompy.arbitrary_time_series_profile.png')
interval = 3600  # seconds

varname = 'salt'

clim_map = {
    'temp': [0, 8, 20, 20],
    'salt': [0, 21, 33, 33],
    'U': [-2, -2, 2, 2]
}

d, t, z = extract_from_series.extract_from_two_datetimes(x,
                                                         y,
                                                         dt0,
                                                         dt1,
                                                         varname=varname,
                                                         interval=interval)

#print('z')
#print(z)
#print('time')
#print(t)
#print('data')
#print(d)
plot_time_series_profile(
    t,
    z,
    d,
    clim=clim_map[varname],
    varname=varname,
    filename='/Users/lederer/tmp/rompy.arbitrary_time_series_profile.png')