本文整理汇总了Python中pylab.num2date函数的典型用法代码示例。如果您正苦于以下问题:Python num2date函数的具体用法?Python num2date怎么用?Python num2date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了num2date函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __str__
def __str__(self):
"""Print statistics about current instance"""
alist = ['projname','casename', 'trmdir', 'datadir',
'njord_module', 'njord_class', 'imt', 'jmt']
print ""
print "="*79
for a in alist:
print a.rjust(15) + " : " + str(self.__dict__[a])
if hasattr(self.nlrun, 'seedparts'):
print "%s : %i" % ("seedparts".rjust(15), self.nlrun.seedparts)
print "%s : %i" % ("seedpart_id".rjust(15),self.nlrun.seedpart_id)
for a in ['part','rank','arg1','arg2']:
if self.__dict__[a] is not None:
print "%s : %i" % (a.rjust(15), self.__dict__[a])
if hasattr(self,'x'):
print ""
print "%s : %s" % ("file".rjust(15), self.filename)
print "%s : %s - %s" % (
"time range".rjust(15),
pl.num2date(self.jdvec.min()).strftime('%Y-%m-%d'),
pl.num2date(self.jdvec.max()).strftime('%Y-%m-%d'))
print "%s : %i" % ("timesteps".rjust(15), len(self.jdvec))
print "%s : %i" % ("particles".rjust(15),
len(np.unique(self.ntrac)))
print "%s : %i" % ("positions".rjust(15), len(self.ntrac))
return ''
开发者ID:raphaeldussin,项目名称:pytraj,代码行数:29,代码来源:trm.py
示例2: copy
def copy(jd):
tr = traj('jplNOW','ftp','/Volumes/keronHD3/ormOut/')
print pl.num2date(jd), jd
tr.load(jd)
tr.remove_satnans()
if len(tr.x>0):
tr.db_copy()
开发者ID:brorfred,项目名称:pytraj,代码行数:7,代码来源:partsat.py
示例3: info
def info(self, *var, **adict):
"""
Printing descriptive statistics on selected variables
"""
# calling convenience functions to clean-up input parameters
var, sel = self.__var_and_sel_clean(var, adict)
dates, nobs = self.__dates_and_nobs_clean(var, sel)
# setting the minimum and maximum dates to be used
mindate = pylab.num2date(min(dates)).strftime("%d %b %Y")
maxdate = pylab.num2date(max(dates)).strftime("%d %b %Y")
# number of variables (excluding date if present)
nvar = len(var)
print "\n=============================================================="
print "==================== Database information ===================="
print "==============================================================\n"
print "file: %s" % self.DBname
print "# obs: %s" % nobs
print "# variables: %s" % nvar
print "Start date: %s" % mindate
print "End date: %s" % maxdate
print "\nvar min max mean std.dev"
print "=============================================================="
for i in var:
_min = self.data[i][sel].min()
_max = self.data[i][sel].max()
_mean = self.data[i][sel].mean()
_std = self.data[i][sel].std()
print """%-5s %-5.2f %-5.2f %-5.2f %-5.2f""" % tuple([i, _min, _max, _mean, _std])
开发者ID:BKJackson,项目名称:SciPy-CookBook,代码行数:35,代码来源:dbase.0.1.py
示例4: __init__
def __init__(self, ob):
# populate attributes with sounding data, initially this will
# only work with a netcdf variable object (from Sceintific.IO)
# but more objects can be added by simply adding elif..
# PLEASE always populate height in the values['alt'] position and
# append values['date_list'] and datetime
# datetime and date_list[index] are datetime objects
# check if it is a netcdf variable list
if "getValue" in dir(ob[ob.keys()[0]]):
# this is a netcdf variables object
self.datetime = num2date(datestr2num("19700101") + ob["base_time"].getValue() / (24.0 * 60.0 * 60.0))
values = {}
units = {}
longname = {}
for var in ob.keys():
values.update({var: ob[var][:]})
try:
units.update({var: ob[var].units})
except AttributeError:
units.update({var: "no units"})
try:
longname.update({var: ob[var].long_name})
except AttributeError:
longname.update({var: "no longname"})
values.update(
{"date_list": num2date(date2num(self.datetime) + values["time_offset"] / (24.0 * 60.0 * 60.0))}
)
units.update({"date_list": "unitless (object)"})
self.values = values
self.units = units
self.long_name = longname
开发者ID:vanandel,项目名称:pyart,代码行数:31,代码来源:sounding.py
示例5: interp_time_base
def interp_time_base(self, other_sounding, time_desired):
# interpolates the current sounding and the other sounding according
# to the time at launch
# fist check that time_desired fits in both
time_between_sondes = date2num(other_sounding.datetime) - date2num(self.datetime)
second_wt = (date2num(time_desired) - date2num(self.datetime)) / time_between_sondes
first_wt = (date2num(other_sounding.datetime) - date2num(time_desired)) / time_between_sondes
if date2num(self.datetime) > date2num(time_desired) > date2num(other_sounding.datetime):
order = "before" # the desired time is before self
elif date2num(self.datetime) < date2num(time_desired) < date2num(other_sounding.datetime):
order = "after" # the desired time is after self
else:
print "time desired is outside of range"
return
min_ht = array([self.alt.min(), other_sounding.alt.min()]).max()
max_ht = array([self.alt.max(), other_sounding.alt.max()]).min()
idx_min = where(abs(other_sounding.alt - min_ht) == abs(other_sounding.alt - min_ht).min())[0][0]
idx_max = where(abs(other_sounding.alt - max_ht) == abs(other_sounding.alt - max_ht).min())[0][0]
myhts = other_sounding.alt[idx_min:idx_max]
self.interpolate_values(myhts)
altshape = self.alt.shape
for key in self.values.keys():
if array(self.values[key]).shape == altshape and key != "date_list":
self.values[key] = self.values[key] * first_wt + other_sounding.values[key][idx_min:idx_max] * second_wt
self.values["date_list"] = num2date(
date2num(self.values["date_list"]) * first_wt
+ date2num(other_sounding.values["date_list"][idx_min:idx_max]) * second_wt
)
self.datetime = num2date(date2num(self.datetime) * first_wt + date2num(other_sounding.datetime) * second_wt)
开发者ID:vanandel,项目名称:pyart,代码行数:31,代码来源:sounding.py
示例6: movie
def movie(self):
import matplotlib as mpl
mpl.rcParams['axes.labelcolor'] = 'white'
pl.close(1)
pl.figure(1,(8,4.5),facecolor='k')
miv = np.ma.masked_invalid
figpref.current()
jd0 = pl.date2num(dtm(2005,1,1))
jd1 = pl.date2num(dtm(2005,12,31))
mp = projmaps.Projmap('glob')
x,y = mp(self.llon,self.llat)
for t in np.arange(jd0,jd1):
print pl.num2date(t)
self.load(t)
pl.clf()
pl.subplot(111,axisbg='k')
mp.pcolormesh(x,y,
miv(np.sqrt(self.u**2 +self.v**2)),
cmap=cm.gist_heat)
pl.clim(0,1.5)
mp.nice()
pl.title('%04i-%02i-%02i' % (pl.num2date(t).year,
pl.num2date(t).month,
pl.num2date(t).day),
color='w')
pl.savefig('/Users/bror/oscar/norm/%03i.png' % t,
bbox_inches='tight',facecolor='k',dpi=150)
开发者ID:raphaeldussin,项目名称:njord,代码行数:28,代码来源:oscar.py
示例7: movie
def movie(self, fldname, jd1=None, jd2=None, jdvec=None, fps=10, **kwargs):
curr_backend = plt.get_backend()
plt.switch_backend('Agg')
FFMpegWriter = animation.writers['ffmpeg']
metadata = dict(title='%s' % (self.projname),
artist=self.projname,
comment='https://github.com/brorfred/njord')
writer = FFMpegWriter(fps=fps, metadata=metadata,
extra_args=['-vcodec', 'libx264',"-pix_fmt", "yuv420p"])
jdvec = self.get_tvec(jd1, jd2) if jdvec is None else jdvec
fig = plt.figure()
with writer.saving(fig, "%s.mp4" % self.projname, 200):
for jd in jdvec:
pl.clf()
print(pl.num2date(jd).strftime("%Y-%m-%d %H:%M load "), end="")
sys.stdout.flush()
try:
fld= self.get_field(fldname, jd=jd)
except:
print("not downloaded" % jd)
continue
print("plot ", end="")
sys.stdout.flush()
self.pcolor(fld, **kwargs)
pl.title(pl.num2date(jd).strftime("%Y-%m-%d %H:%M"))
print("write")
writer.grab_frame()#bbox_inches="tight", pad_inches=0)
plt.switch_backend(curr_backend)
开发者ID:brorfred,项目名称:njord,代码行数:29,代码来源:base.py
示例8: load_cube
def load_cube(fname): # weird edits added for changed behaviour
ncf = NetCDFFile(fname, "r")
print "Ok1"
xar = ncf.variables["xar"][0]
# print mxar.shape
# xar=mxar[0]
print "plew"
yar = array(ncf.variables["yar"][0])
print "Ok2"
levs = array(ncf.variables["levs"][0])
print "Ok3"
parms = [
"VE",
"VR",
"CZ",
"RH",
"PH",
"ZD",
"SW",
"KD",
"i_comp",
"j_comp",
"k_comp",
"v_array",
"u_array",
"w_array",
]
radar1_poss_parms = [par + "_radar1" for par in parms]
radar2_poss_parms = [par + "_radar2" for par in parms]
radar1_parms = set(radar1_poss_parms) & set(ncf.variables.keys())
radar2_parms = set(radar2_poss_parms) & set(ncf.variables.keys())
print "Doing radar1"
radar1_dict = dict([(par[0:-7], array(ncf.variables[par].getValue())) for par in radar1_parms])
radar1_dict.update(
{
"xar": xar,
"yar": yar,
"levs": levs,
"radar_loc": ncf.variables["radar1_loc"][0],
"displacement": ncf.variables["radar1_dis"][0],
"date": num2date(ncf.variables["radar1_date"][0, 0]),
"radar_name": getattr(ncf, "radar1_name"),
}
)
print "doing radar2"
radar2_dict = dict([(par[0:-7], array(ncf.variables[par].getValue())) for par in radar2_parms])
radar2_dict.update(
{
"xar": xar,
"yar": yar,
"levs": levs,
"radar_loc": ncf.variables["radar2_loc"][0],
"displacement": ncf.variables["radar2_dis"][0],
"date": num2date(ncf.variables["radar2_date"][0, 0]),
"radar_name": getattr(ncf, "radar2_name"),
}
)
ncf.close()
return radar1_dict, radar2_dict
开发者ID:scollis,项目名称:bom_mds,代码行数:59,代码来源:netcdf_utis.py
示例9: multiplot
def multiplot(self,jd1=730120.0, djd=60, dt=20):
if not hasattr(self,'disci'):
self.generate_regdiscs()
self.x = self.disci
self.y = self.discj
if not hasattr(self,'lon'):
self.ijll()
figpref.presentation()
pl.close(1)
pl.figure(1,(10,10))
conmat = self[jd1-730120.0:jd1-730120.0+60, dt:dt+10]
x,y = self.gcm.mp(self.lon, self.lat)
self.gcm.mp.merid = []
self.gcm.mp.paral = []
pl.subplots_adjust(wspace=0,hspace=0,top=0.95)
pl.subplot(2,2,1)
pl.pcolormesh(miv(conmat),cmap=cm.hot)
pl.clim(0,250)
pl.plot([0,800],[0,800],'g',lw=2)
pl.gca().set_aspect(1)
pl.setp(pl.gca(),yticklabels=[])
pl.setp(pl.gca(),xticklabels=[])
pl.colorbar(aspect=40,orientation='horizontal',
pad=0,shrink=.8,fraction=0.05,ticks=[0,50,100,150,200])
pl.subplot(2,2,2)
colorvec = (np.nansum(conmat,axis=1)-np.nansum(conmat,axis=0))[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
pl.subplot(2,2,3)
colorvec = np.nansum(conmat,axis=1)[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
pl.subplot(2,2,4)
colorvec = np.nansum(conmat,axis=0)[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
mycolor.freecbar([0.2,.06,0.6,0.020],[2000,4000,6000,8000])
pl.suptitle("Trajectories seeded from %s to %s, Duration: %i-%i days" %
(pl.num2date(jd1).strftime("%Y-%m-%d"),
pl.num2date(jd1+djd).strftime("%Y-%m-%d"), dt,dt+10))
pl.savefig('multplot_%i_%03i.png' % (jd1,dt),transparent=True)
开发者ID:TRACMASS,项目名称:pytraj,代码行数:59,代码来源:connect.py
示例10: multiplot
def multiplot(self,jd1=730120.0, djd=60, dt=20):
if not hasattr(self,'disci'):
self.generate_regdiscs()
self.x = self.disci
self.y = self.discj
self.ijll()
figpref.manuscript()
pl.close(1)
pl.figure(1,(10,10))
conmat = self[jd1-730120.0:jd1-730120.0+60, dt:dt+10]
x,y = self.gcm.mp(self.lon, self.lat)
self.gcm.mp.merid = []
self.gcm.mp.paral = []
pl.subplots_adjust(wspace=0,hspace=0,top=0.95)
pl.subplot(2,2,1)
pl.pcolormesh(miv(conmat))
pl.clim(0,50)
pl.plot([0,800],[0,800],'g',lw=2)
pl.gca().set_aspect(1)
pl.setp(pl.gca(),yticklabels=[])
pl.setp(pl.gca(),xticklabels=[])
pl.subplot(2,2,2)
colorvec = (np.nansum(conmat,axis=1)-np.nansum(conmat,axis=0))[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
pl.subplot(2,2,3)
colorvec = np.nansum(conmat,axis=1)[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
pl.subplot(2,2,4)
colorvec = np.nansum(conmat,axis=0)[1:]
self.gcm.mp.scatter(x, y, 10, 'w', edgecolor='k')
self.gcm.mp.scatter(x, y, 10, colorvec)
self.gcm.mp.nice()
pl.clim(0,10000)
pl.suptitle("Trajectories seeded from %s to %s, Duration: %i-%i days" %
(pl.num2date(jd1).strftime("%Y-%m-%d"),
pl.num2date(jd1+djd).strftime("%Y-%m-%d"), dt,dt+10))
pl.savefig('multplot_%i_%03i.png' % (jd1,dt))
开发者ID:tamu-pong,项目名称:Py-TRACMASS,代码行数:54,代码来源:connect.py
示例11: filesave
def filesave(self, fname):
f = open(fname, 'w')
cmds = self.data['y']
vv = [v for v in cmds.values()]
xx = list(chain(*vv[0]['xx']))
if self.mode == 'ft':
xx0 = pylab.num2date(xx[0])
xx1 = [(pylab.num2date(x) - xx0).total_seconds() for x in xx]
xx = xx1
yy = [list(chain(*v['yy'])) for v in vv]
for i in range(0, len(xx)):
yyi = [k[i] for k in yy]
f.write(','.join(['%.5f' % j for j in [xx[i]] + yyi]) + '\n')
f.close()
开发者ID:ivanovev,项目名称:start,代码行数:14,代码来源:plot.py
示例12: uvmat
def uvmat(self):
hsmat = np.zeros ([20]+list(self.llat.shape)).astype(np.int16)
jd1 = pl.date2num(dtm(2003,1,1))
jd2 = pl.date2num(dtm(2009,12,31))
vlist = np.linspace(0,1.5,21)
for jd in np.arange(jd1,jd2+1):
print pl.num2date(jd)
self.load(jd=jd)
uv = np.sqrt(self.u**2 + self.v**2)
for n,(v1,v2) in enumerate(zip(vlist[:-1],vlist[1:])):
msk = (uv>=v1) & (uv<v2)
hsmat[n,msk] += 1
return hsmat
开发者ID:raphaeldussin,项目名称:njord,代码行数:14,代码来源:oscar.py
示例13: updateWindow
def updateWindow(self, val):
""" redraw the canvas based from the slider position """
# get the current value of the slider based from its position
# then set the time range of the plotter window based from this value
self.updatestarttime = self.time_scroller.val
self.updatecurrenttime = date2num(num2date(self.updatestarttime) + datetime.timedelta(seconds = 3))
self.updatecurrenttime_tick = time.mktime(num2date(self.updatecurrenttime).timetuple())
self.axes.set_xlim((self.updatestarttime, self.updatecurrenttime))
# update the x-axis ticklabels depending on the current time of plotting
self.axes.xaxis.set_ticklabels(self.createXTickLabels(self.updatecurrenttime_tick), rotation = 30, ha = "right", size = 'smaller', name = 'Calibri')
# update the plotting window based from the slider position
self.canvas.draw()
self.canvas.gui_repaint()
开发者ID:hamalawy,项目名称:telehealth,代码行数:15,代码来源:ecgplotter.py
示例14: initPlot
def initPlot(self):
""" redraw the canvas to set the initial x and y axes when plotting starts """
self.starttime = datetime.datetime.today()
self.currenttime = self.starttime + datetime.timedelta(seconds=3)
self.endtime = self.starttime + datetime.timedelta(seconds=15)
self.timeaxis = num2date(drange(self.starttime, self.endtime, datetime.timedelta(milliseconds=10)))
self.xvalues.append(self.timeaxis[0])
self.yvalues.append(self.parentPanel.myECG.ecg_leadII[0])
# for counter purposes only
self.ybuffer = self.yvalues
self.lines[0].set_data(self.xvalues, self.yvalues)
self.axes.set_xlim((date2num(self.starttime), date2num(self.currenttime)))
self.axes.xaxis.set_ticklabels(
self.createXTickLabels(self.currenttime), rotation=30, ha="right", size="smaller", name="Calibri"
)
self.samples_counter += 1
self.ysamples_counter += 1
self.buff_counter = 1
开发者ID:hamalawy,项目名称:telehealth,代码行数:25,代码来源:ecgplotter.py
示例15: parse_sounding_block
def parse_sounding_block(sounding_block):
headers=sounding_block[0].split()[0:17]
start_date_str=sounding_block[1].split()[0]+" "+sounding_block[1].split()[1]
data_dict=dict([(headers[i],array([float_conv(sounding_block[j+1].split()[i]) for j in range(len(sounding_block)-1)])) for i in range(len(headers))])
date_list=[num2date(datestr2num(sounding_block[i+1].split()[0]+" "+sounding_block[i+1].split()[1])) for i in range(len(sounding_block)-1)]
data_dict.update({'date_list':array(date_list)})
return data_dict
开发者ID:scollis,项目名称:bom_mds,代码行数:7,代码来源:read_sounding.py
示例16: heatmap
def heatmap(self, maskvec=None, jd=None, cmap=None, alpha=1, colorbar=True,
clf=True, map_region=None, log=False, kwargs={}):
"""Plot particle positions on a map
mask: Boolean vector determining which particles to plot
ntrac: Particle ID
jd: Julian date to plot, has to be included in jdvec.
cmap: color map to use
alpha: transparancy of pcolormap
clf: Clear figure if True
colorbar: Show colorbar if True (default)
map_region: Use other map_regions than set by config file
kwargs: Other arguments to pcolor (must be a dict).
"""
if maskvec is None:
maskvec = self.ntrac==self.ntrac
if jd is not None:
maskvec = maskvec & (self.jd==jd)
if USE_FIGPREF:
figpref.current()
if clf:
pl.clf()
if cmap is not None:
kwargs['cmap'] = cmap
if log is True:
kwargs['norm'] = LogNorm()
if colorbar is True:
kwargs['colorbar'] = True
mat = self.heatmat(nan=True, maskvec=maskvec, jd=None)
mat[mat==0] = np.nan
self.gcm.pcolor(mat, **kwargs)
if jd: pl.title(pl.num2date(jd).strftime("%Y-%m-%d %H:%M"))
开发者ID:brorfred,项目名称:pytraj,代码行数:34,代码来源:traj.py
示例17: monthlyTimeSeries
def monthlyTimeSeries(headers):
months = []
for h in headers:
if len(h) > 1:
timestamp = mktime(parsedate(h[1][5:].replace('.',':')))
mailstamp = datetime.fromtimestamp(timestamp)
# Time the email is arrived
y = datetime(mailstamp.year,mailstamp.month,mailstamp.day, mailstamp.hour, mailstamp.minute, mailstamp.second)
months.append(y)
""" draw the histogram of the daily distribution """
# converting dates to numbers
numtime = [date2num(t) for t in months]
# plotting the histogram
ax = figure(figsize=(18, 6), dpi=80).gca()
_, _, patches = hist(numtime, bins=30,alpha=0.5)
# adding the labels for the x axis
tks = [num2date(p.get_x()) for p in patches]
xticks(tks,rotation=30)
# formatting the dates on the x axis
ax.xaxis.set_major_formatter(DateFormatter('%Y-%m'))
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.autoscale(tight=False)
开发者ID:Diwahars,项目名称:gmail-plot,代码行数:26,代码来源:gmail-plot.py
示例18: scatter
def scatter(self,ntrac=None,ints=None,k1=None,k2=None,c="g",clf=True):
self.add_mp()
mask = self.ntrac==self.ntrac
if ints:
mask = mask & (self.ints==ints)
if ntrac:
mask = mask & (self.ntrac==ntrac)
if clf: pl.clf()
self.ijll()
x,y = self.mp(self.lon[mask],self.lat[mask])
self.mp.pcolormesh(self.mpxll,self.mpyll,
np.ma.masked_equal(self.landmask,1),cmap=GrGr())
xl,yl = self.mp(
[self.llon[0,0], self.llon[0,-1], self.llon[-1,-1],
self.llon[-1,0],self.llon[0,0]],
[self.llat[0,0], self.llat[0,-1], self.llat[-1,-1],
self.llat[-1,0], self.llat[0,0]]
)
self.mp.plot(xl,yl,'0.5')
if ntrac: self.mp.plot(x,y,'-w',lw=0.5)
self.mp.scatter(x,y,5,c)
if ints:
jd = self.jd[self.ints==ints][0]
pl.title(pl.num2date(jd).strftime("%Y-%m-%d %H:%M"))
print len(x)
开发者ID:tamu-pong,项目名称:Py-TRACMASS,代码行数:28,代码来源:trm.py
示例19: plot_date_time_graph
def plot_date_time_graph(db_name,table_name):
format='%d %b %Y %I:%M %p'
conn = sqlite3.connect(os.getcwd()+'/data/'+db_name+'.db')
c=conn.cursor()
date_time_arr=[]
tweet_count=[]
for row in c.execute('SELECT date_posted,time_posted From '+table_name):
date_string= ' '.join(row)
date_time_arr.append(datetime.strptime(date_string, format))
for row in c.execute('SELECT retweets From '+table_name):
tweet_count.append(row[0]+1)
y= np.array(tweet_count)
x=np.array(date_time_arr)
N=len(tweet_count)
colors = np.random.rand(N)
numtime = [date2num(t) for t in x]
# plotting the histogram
ax = figure().gca()
x, y, patches = hist(numtime, bins=50,alpha=.5)
print x,y
# adding the labels for the x axis
tks = [num2date(p.get_x()) for p in patches]
xticks(tks,rotation=40)
# formatting the dates on the x axis
ax.xaxis.set_major_formatter(DateFormatter('%d %b %H:%M'))
ax.set_xlabel('Time(dd-mm HH:MM)', fontsize=16)
ax.set_ylabel('Tweet Count', fontsize=16)
show()
开发者ID:abhigenie92,项目名称:social_network_extract,代码行数:29,代码来源:twitter_datetimegraph.py
示例20: get_two_best_sondes
def get_two_best_sondes(date_str, **kwargs):
sonde_file=kwargs.get('sonde_file', '/data/twpice/darwin.txt')
#outdir=kwargs.get('outdir', '/flurry/home/scollis/bom_mds/dealias/')
sonde_file=kwargs.get('sonde_file', '/data/twpice/darwin.txt')
outdir=kwargs.get('outdir', '/home/scollis/bom_mds/dealias/')
tim_date=num2date(datestr2num(date_str))
sonde_list=read_sounding_within_a_day(sonde_file, tim_date)
launch_dates=[sonde['date_list'][0] for sonde in sonde_list]
#print launch_dates
launch_date_offset=[date2num(sonde['date_list'][0])- date2num(tim_date) for sonde in sonde_list]
sonde_made_it=False
candidate=0
while not(sonde_made_it):
best_sonde=sonde_list[argsort(abs(array(launch_date_offset)))[candidate]]
candidate=candidate+1
sonde_made_it=best_sonde['alt(m)'][-1] > 18000.
if not sonde_made_it: print "Sonde Burst at ", best_sonde['alt(m)'][-1], "m rejecting"
print "Sonde Burst at ", best_sonde['alt(m)'][-1], "m Accepting"
sonde_made_it=False
while not(sonde_made_it):
sec_best_sonde=sonde_list[argsort(abs(array(launch_date_offset)))[candidate]]
candidate=candidate+1
sonde_made_it=sec_best_sonde['alt(m)'][-1] > 18000.
if not sonde_made_it: print "Sonde Burst at ", sec_best_sonde['alt(m)'][-1], "m rejecting"
print "Sonde Burst at ", sec_best_sonde['alt(m)'][-1], "m Accepting"
print 'Time of radar: ', tim_date, ' Time of best sonde_launch: ', best_sonde['date_list'][0], ' Time of sonde_termination: ', best_sonde['date_list'][-1]
print 'Time of radar: ', tim_date, ' Time of second sonde_launch: ', sec_best_sonde['date_list'][0], ' Time of sonde_termination: ', best_sonde['date_list'][-1]
for i in range(len(sonde_list)):
best_sonde=sonde_list[argsort(abs(array(launch_date_offset)))[i]]
print 'Time of radar: ', tim_date, ' Time of best sonde_launch: ', best_sonde['date_list'][0], ' Offset', abs(date2num(best_sonde['date_list'][0])-date2num(tim_date))*24.0
return best_sonde, sec_best_sonde
开发者ID:scollis,项目名称:bom_mds,代码行数:31,代码来源:read_sounding.py
注:本文中的pylab.num2date函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论