本文整理汇总了Python中time.append函数的典型用法代码示例。如果您正苦于以下问题:Python append函数的具体用法?Python append怎么用?Python append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了append函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_experiment
def run_experiment(mode, cmd, t):
file.write(" ".join(cmd) + "\n")
time = []
timeout = 120
if mode == "stm" or mode == "gen":
timeout = 1200
for i in range(t):
while (True) :
out = timeout_command(cmd, timeout)
if out == None:
print "Timed out ", cmd
continue
r = re.search("(?<=Time = )[0-9]*\.[0-9]*", out)
if r == None:
print "retry ", cmd
continue
out = r.group(0);
break
time.append(float(out))
file.write(out + " ")
file.write("\n")
file.write("Std dev = " + "%.3f" % (numpy.std(time)))
file.write("\n")
file.write("min = " + "%.3f" % (numpy.amin(time)) + "\n")
file.write("max = " + "%.3f" % (numpy.amax(time)) + "\n")
return (numpy.median(time), numpy.amin(time), numpy.amax(time))
开发者ID:nathanielherman,项目名称:sto-stamp,代码行数:26,代码来源:script.py
示例2: get_details
def get_details(html):
soup=BeautifulSoup(html)
#得到作者、作者链接、微博正文
div_content=soup.find_all(attrs={'class': 'content clearfix'})
#得到发微博时间
div_time=soup.find_all(attrs={'class':'feed_from W_textb'})
#将用户名称,用户主页地址、微博正文、发微博时间初始化
nick_name=[]
nickname_href=[]
content_text=[]
time=[]
#print get_content[0]
for i in range(len(div_content)):
#查找a标签
a_tag=div_content[i].find('a')
nick_name.append(a_tag.get('nick-name'))
nickname_href.append(a_tag.get('href'))
#查找p标签
p_tag=div_content[i].find('p')
content_text.append(p_tag.get_text())
#得到发微博时间
for j in range(len(div_time)):
a_time=div_time[j].find('a')
time.append(a_time.get('title'))
return (nick_name,nickname_href,content_text,time)
开发者ID:callMeBigKing,项目名称:workSpace,代码行数:25,代码来源:weibo.py
示例3: fivePinjun
def fivePinjun(self,action):
#datetime.datetime.strptime("12:10:20",'%H:%M:%S')
#date_time = datetime.datetime.strptime("2012-10-20",'%Y-%m-%d')
#.resample(rule="5M",how="mean")
#time=pandas.tseries.index.DatetimeIndex
time=[]
for tab in xrange(len(self.df["Time"])):
#print datetime.datetime.strptime(self.df["Date"][tab]+' '+self.df["Time"][tab],'%Y-%m-%d %H:%M:%S')
time.append(datetime.datetime.strptime(self.df["Date"][tab]+' '+self.df["Time"][tab],'%Y-%m-%d %H:%M:%S'))
#time=pandas.PeriodIndex(time,freq='S')
ts=Series(np.array(self.df[self.df.columns[self.columnChooseIndex[0]+6]]), index=time)
#self.ts1=pandas.DataFrame({"DateTime":ts.index,self.df.columns[self.columnChooseIndex[0]+6]:ts})
temps1=ts.resample("5Min")
self.ts1=pandas.DataFrame({"DateTime":temps1.index,self.df.columns[self.columnChooseIndex[0]+6]:temps1})
self.dataModel = DataFrameModel()
self.dtableView.setModel(self.dataModel)
self.dataModel.setDataFrame(self.ts1)
self.dataModel.signalUpdate()
self.dtableView.resizeColumnsToContents()
self.dtableView.show()
self.isProcess=True
开发者ID:designer357,项目名称:AOPAS,代码行数:25,代码来源:MainWindow.py
示例4: Process
def Process(self):
process=Process(self)
process.exec_()
time=[]
PP=process.combine.split('\\')
for tab in xrange(len(self.df["Time"])):
time.append(datetime.datetime.strptime(self.df["Date"][tab]+' '+self.df["Time"][tab],'%Y-%m-%d %H:%M:%S'))
#time=pandas.PeriodIndex(time,freq='S')
ts=Series(np.array(self.df[self.df.columns[self.columnChooseIndex[0]+6]]), index=time)
#self.ts1=pandas.DataFrame({"DateTime":ts.index,self.df.columns[self.columnChooseIndex[0]+6]:ts})
#temps1=eval("ts."+str(PP[0])+'.'+'("'+str(PP[1])+'")')
if str(PP[0])=="resample":
temps1=ts.resample(str(PP[1]))
self.ts1=pandas.DataFrame({"DateTime":temps1.index,self.df.columns[self.columnChooseIndex[0]+6]:temps1})
self.dataModel = DataFrameModel()
self.dtableView.setModel(self.dataModel)
self.dataModel.setDataFrame(self.ts1)
self.dataModel.signalUpdate()
self.dtableView.resizeColumnsToContents()
self.dtableView.show()
self.isProcess=True
开发者ID:designer357,项目名称:AOPAS,代码行数:26,代码来源:MainWindow.py
示例5: elapsedTime
def elapsedTime(seconds, suffixes=["y", "w", "d", "h", "m", "s"], add_s=False, separator=" "):
"""
Takes an amount of seconds and turns it into a human-readable amount of time.
"""
# the formatted time string to be returned
if seconds == 0:
return "0s"
time = []
# the pieces of time to iterate over (days, hours, minutes, etc)
# - the first piece in each tuple is the suffix (d, h, w)
# - the second piece is the length in seconds (a day is 60s * 60m * 24h)
parts = [
(suffixes[0], 60 * 60 * 24 * 7 * 52),
(suffixes[1], 60 * 60 * 24 * 7),
(suffixes[2], 60 * 60 * 24),
(suffixes[3], 60 * 60),
(suffixes[4], 60),
(suffixes[5], 1),
]
# for each time piece, grab the value and remaining seconds, and add it to
# the time string
for suffix, length in parts:
value = seconds / length
if value > 0:
seconds = seconds % length
time.append("%s%s" % (str(value), (suffix, (suffix, suffix + "s")[value > 1])[add_s]))
if seconds < 1:
break
return separator.join(time)
开发者ID:ginomics,项目名称:acpype,代码行数:32,代码来源:run_test_acpype_db_ligands.py
示例6: stop_test
def stop_test():
global record_data
global data
record_data = False
speed = []
time = []
verticalSpeed = []
pitch = []
altitude = []
for i in range(0,len(data)):
speed.append( data[i]['speed'])
time.append( data[i]['time'])
verticalSpeed.append(data[i]['verticalSpeed'])
pitch.append(data[i]['pitch'])
altitude.append(data[i]['altitude'])
plotting.plot_chart(time,speed,"time-speed")
plotting.plot_chart(time,verticalSpeed,"time-verticalSpeed")
plotting.plot_chart(time,pitch,"time-pitch")
plotting.plot_chart(time,altitude,"time-altitude")
开发者ID:gunerguney,项目名称:Xpanel,代码行数:26,代码来源:comm.py
示例7: plot_save
def plot_save(af_stat_file, plot_path):
#at_time(sec), nonNLP_percentage, insect_percentage, poison_percentage, insecticide_percentage
time = []
non_nlp = []
insect = []
poison = []
insecticide = []
line_no = 0
#Expected CSV format
with open(af_stat_file) as f:
for line in f:
if line_no == 0:
line_no = line_no + 1
continue
line = [x.strip() for x in line.split(',') ]
time.append(float(line[0]))
non_nlp.append(float(line[1]))
insect.append(float(line[2]))
poison.append(float(line[3]))
insecticide.append(float(line[4]))
plt.plot(time, insect)
plt.plot(time, poison)
plt.plot(time, insecticide)
plt.plot(time, non_nlp)
plt.legend(['Insect', 'Poison', 'Insecticide', 'Non-nlp'], loc='best')
plt.ylabel('Percentage in AF')
plt.xlabel('Time(sec)')
plt.savefig(plot_path+"/plot.png")
plt.clf()
开发者ID:aro-ai-robots,项目名称:opencog,代码行数:30,代码来源:launch_exp.py
示例8: flux2011
def flux2011( ) :
time = []
flux = []
fin = open( "fluxes.txt", "r" )
fout = open( "fluxVsTime", "w" )
for line in fin :
a = line.split()
if len(a) == 2 :
time.append( 24.*float(a[0]) ) # dechrs
flux.append( float(a[1]) ) # flux
# ... create decimal time array
t = numpy.array( time, dtype=float )
print t
# ... retrieve tsys, rmspath, tau230, elev arrays
rmspath = getVar( "rmspath.log", t )
tau230 = getVar( "tau230.log", t )
source = getSource ( "uvindex.log", t )
elevarray = getVar15( "elev.log", t )
# ... use elev of C1 as the elevation
elev = numpy.empty( (len(time)), dtype=float )
for n in range (0, len(time) ) :
elev[n] = elevarray[n][0]
# ... all array lengths should match, otherwise this routine will crash!
print len(time), len(flux), len(rmspath), len(tau230), len(source), len(elev)
fout.write("# UThrs S(Jy) el tau path source\n")
for n in range (0, len(time)) :
fout.write("%10.5f %6.3f %4.1f %4.2f %4.0f %s\n" % (t[n], flux[n], elev[n], tau230[n], rmspath[n], source[n] ))
fin.close()
fout.close()
开发者ID:richardplambeck,项目名称:tadpol,代码行数:35,代码来源:vCal.py
示例9: seconds_to_human_time
def seconds_to_human_time(cls, seconds, suffixes=['y','w','d','h','m','s'], add_s=False, separator=' '):
"""
convert seconds to human time
"""
# the formatted time string to be returned
time = []
# the pieces of time to iterate over (days, hours, minutes, etc)
# - the first piece in each tuple is the suffix (d, h, w)
# - the second piece is the length in seconds (a day is 60s * 60m * 24h)
parts = [(suffixes[0], 60 * 60 * 24 * 7 * 52),
(suffixes[1], 60 * 60 * 24 * 7),
(suffixes[2], 60 * 60 * 24),
(suffixes[3], 60 * 60),
(suffixes[4], 60),
(suffixes[5], 1)]
# for each time piece, grab the value and remaining seconds, and add it to
# the time string
for suffix, length in parts:
value = seconds / length
if value > 0:
seconds = seconds % length
time.append('%s%s' % (str(value),
(suffix, (suffix, suffix + 's')[value > 1])[add_s]))
if seconds < 1:
break
return separator.join(time)
开发者ID:smgoller,项目名称:gmvault,代码行数:29,代码来源:gmvault_utils.py
示例10: diffuseave
def diffuseave(self):
self.difffile=open('diffusion.xvg','w')
diffave=[]
diffave2=[]
for i in range(self.diffmax):
diffave.append(0.)
diffave2.append(0.)
for iatom in self.atoms:
iatom.diffusecalc(self.diffmax)
for i in range(self.diffmax):
diffave[i]+=iatom.diffusion[i]
diffave2[i]+=iatom.diffusion2[i]
for i in range(self.diffmax):
diffave[i]/=float(self.NAtom)
diffave2[i]/=float(self.NAtom)
print>>self.difffile,'#Mean square displacement of all atoms'
print>>self.difffile,'#Time <r2>'
print>>self.difffile,'@ title \"Mean square displacement\"'
print>>self.difffile,'@ xaxis label \"Time (reduced time units)\"'
print>>self.difffile,'@ yaxis label \"Mean square displacement (sigma^2)\"'
for i in range(self.diffmax):
print>>self.difffile,'%8.4lf %8.4lf'%(i*self.Step,diffave2[i])
self.difffile.close()
#Fit linear regression line to <r^2>=6Dt
time=[]
for i in range(self.diffmax):
time.append(i*self.Step)
slope,intercept,r2=regression(time,diffave2)
print 'displace^2 vs t: slope=%lf intercept=%lf R2=%lf'\
%(slope,intercept,r2)
self.diffconst=slope/6.
print 'Diffusion constant from Einstein relation=%lf (reduced units)'%(self.diffconst)
diffusion_cgs=self.diffconst*0.1344*self.Step*100000.
print 'Diffusion constant from Einstein relation=%lf (x10-5 cm^2/sec)'%(diffusion_cgs)
开发者ID:msinghal2,项目名称:Scientific-Computing---Simulation-and-Data-analysis,代码行数:34,代码来源:MDSS.py
示例11: getdrift_raw
def getdrift_raw(filename,id3,interval,datetime_wanted):
# range_time is a number,unit by one day. datetime_wanted format is num
d=ml.load(filename)
lat1=d[:,8]
lon1=d[:,7]
idd=d[:,0]
year=[]
for n in range(len(idd)):
year.append(str(idd[n])[0:2])
h=d[:,4]
day=d[:,3]
month=d[:,2]
time1=[]
for i in range(len(idd)):
time1.append(date2num(datetime.datetime.strptime(str(int(h[i]))+' '+str(int(day[i]))+' '+str(int(month[i]))+' '+str(int(year[i])), "%H %d %m %y")))
idg1=list(ml.find(idd==id3))
idg2=list(ml.find(np.array(time1)<=datetime_wanted+interval/24))
"'0.25' means the usual Interval, It can be changed base on different drift data "
idg3=list(ml.find(np.array(time1)>=datetime_wanted-0.1))
idg23=list(set(idg2).intersection(set(idg3)))
# find which data we need
idg=list(set(idg23).intersection(set(idg1)))
print 'the length of drifter data is '+str(len(idg)),str(len(set(idg)))+' . if same, no duplicate'
lat,lon,time=[],[],[]
for x in range(len(idg)):
lat.append(round(lat1[idg[x]],4))
lon.append(round(lon1[idg[x]],4))
time.append(round(time1[idg[x]],4))
# time is num
return lat,lon,time
开发者ID:jian-cui,项目名称:pyocean,代码行数:34,代码来源:hx.py
示例12: readInVariable
def readInVariable():
gc.disable()
print("In readInVariable() function")
wb = load_workbook('resources/dbMetrics.xlsx', use_iterators = True, read_only = True)
ws = wb.get_sheet_by_name("metrics")
numRows = ws.get_highest_row()
#print(numRows)
date = []
time = []
RCMPL = []
Unblocked = []
timeInitial = datetime.datetime.now()
#print(numRow)
#print(ws.iter_rows('A2:S'+str(numRows)))
ws_iter = tuple(ws.iter_rows('A2:D'+str(numRows)))
#print("11111")
#print(type(ws_iter))
i = 0
j= 1
for row in ws_iter:
#if(i%500 == 0):
#print(i, datetime.datetime.now()-timeInitial)
for cell in row:
if j == 1:
date.append(cell.value)
elif j == 2:
time.append(cell.value)
elif j == 3:
RCMPL.append(cell.value)
elif j == 4:
Unblocked.append(cell.value)
j = j+1
j = 1
print("Length of date ",len(date), len(RCMPL))
开发者ID:debasishdebs,项目名称:parameterTesting,代码行数:34,代码来源:HoltWinters.py
示例13: smooth_values
def smooth_values(timestamps, values, totals, radius):
"""
Sliding window
>>> t = [dt(2011, 01, 20, 0, 0), dt(2011, 01, 21, 0, 0), \
dt(2011, 01, 22, 0, 0), dt(2011, 01, 23, 0, 0), \
dt(2011, 01, 28, 0, 0), dt(2011, 01, 30, 0, 0), \
dt(2011, 01, 31, 0, 0)]
>>> v = [1,2,3,4,5,6,7]
>>> tot = [2,3,4,5,6,7,8]
>>> smooth_values(t, v, tot, 3)
([datetime.datetime(2011, 1, 20, 0, 0), datetime.datetime(2011, 1, 20, 12, 0), datetime.datetime(2011, 1, 21, 0, 0), datetime.datetime(2011, 1, 22, 0, 0), datetime.datetime(2011, 1, 24, 8, 0), datetime.datetime(2011, 1, 27, 0, 0), datetime.datetime(2011, 1, 29, 16, 0), datetime.datetime(2011, 1, 30, 12, 0), datetime.datetime(2011, 1, 31, 0, 0)], [1, 3, 6, 9, 12, 15, 18, 13, 7], [2, 5, 9, 12, 15, 18, 21, 15, 8])
"""
time = []
ser = []
tot = []
k = radius / 2
for i in range(-(radius / 2 + 1), len(timestamps) - (radius / 2) + 1):
v = i if i > 0 else 0
time.append(dt_average(timestamps[v:v + k]))
ser.append(sum(values[v:v + k]))
tot.append(sum(totals[v:v + k]))
if k < radius:
k += 1
return time, ser, tot
开发者ID:SoNetFBK,项目名称:wiki-network,代码行数:25,代码来源:pywc_plot.py
示例14: graph_axis_trajectory
def graph_axis_trajectory(axis, pdf_name):
time = []
pos = []
vel = []
acc = []
for t in axis:
time.append(t[0])
pos.append(t[1])
vel.append(t[2])
acc.append(t[3])
fig = plt.figure()
fig.clf()
ax1 = fig.add_subplot(311)
ax1.plot(time, pos)
ax1.set_xlabel('Time (s)')
ax1.set_ylabel('Position (m)')
ax2 = fig.add_subplot(312)
ax2.plot(time, vel)
ax2.set_xlabel('Time (s)')
ax2.set_ylabel('Velocity (m/s)')
ax3 = fig.add_subplot(313)
ax3.plot(time, acc)
ax3.set_xlabel('Time (s)')
ax3.set_ylabel('Acceleration (m/s^2)')
fig.savefig((pdf_name + ".pdf"))
开发者ID:cvra,项目名称:inverse-kinematics,代码行数:26,代码来源:debra_arm_sequence_visualiser.py
示例15: format_time
def format_time(timespan, precision=3):
"""Formats the timespan in a human readable form"""
if timespan >= 60.0:
# we have more than a minute, format that in a human readable form
parts = [("d", 60 * 60 * 24), ("h", 60 * 60), ("min", 60), ("s", 1)]
time = []
leftover = timespan
for suffix, length in parts:
value = int(leftover / length)
if value > 0:
leftover = leftover % length
time.append('{0}{1}'.format(str(value), suffix))
if leftover < 1:
break
return " ".join(time)
# Unfortunately the unicode 'micro' symbol can cause problems in
# certain terminals.
# See bug: https://bugs.launchpad.net/ipython/+bug/348466
# Try to prevent crashes by being more secure than it needs to
# E.g. eclipse is able to print a mu, but has no sys.stdout.encoding set.
units = ["s", "ms", 'us', "ns"] # the save value
if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding:
try:
'\xb5'.encode(sys.stdout.encoding)
units = ["s", "ms", '\xb5s', "ns"]
except Exception:
pass
scaling = [1, 1e3, 1e6, 1e9]
if timespan > 0.0:
order = min(-int(math.floor(math.log10(timespan)) // 3), 3)
else:
order = 3
return "{1:.{0}g} {2}".format(precision, timespan * scaling[order],
units[order])
开发者ID:VHarisop,项目名称:xonsh,代码行数:35,代码来源:timings.py
示例16: read_coft
def read_coft():
try:
with open('COFT','r'):
f = open('COFT','r')
line = f.readline()
s = line.split(',')
time = []
flux_1 = []
flux_2 = []
flux_3 = []
while line:
time.append(float(s[1]))
flux_1.append(float(s[3]))
flux_2.append(float(s[4]))
flux_3.append(float(s[5]))
line = f.readline()
s = line.split(',')
t = np.asarray(time)
f1 = np.asarray(flux_1)
f2 = np.asarray(flux_2)
f3 = np.asarray(flux_3)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(t, f1, label='gas flow')
ax.plot(t, f2, label='liquid flow')
ax.plot(t, f3, label='total flow')
ax.legend()
plt.show()
except IOError:
print "COFT WAS NOT GENERATED"
return 0
开发者ID:evanl,项目名称:vesa_tough_comparison,代码行数:32,代码来源:t2_output_funcs.py
示例17: readfire
def readfire(s): # reads the output of a fire file and
# returns the time vector and the population vector
# input file should have two columns: first column is time in generations
# second column is population
time = []
pop = []
with open(s, 'r') as input_file:
for line in input_file:
temp = line.strip()
if 'f()' in temp:
time = []
pop = []
temp = line.strip()
a,b = temp.split()
time.append(float(a))
pop.append(float(b))
#with open(s, 'r') as input_file:
#throwaway = input_file.readline()
#while throwaway.strip() != 'START HERE':
#throwaway = input_file.readline()
#for line in input_file:
#print 'hello'
#temp = line.strip()
#a,b = temp.split()
#time.append(float(a))
#pop.append(float(b))
#print a, b
print 'readfire is done'
return [time, pop]
开发者ID:michaelbateman,项目名称:DemographicInference,代码行数:35,代码来源:mdb.py
示例18: elapsed_time
def elapsed_time(self, seconds, suffixes=['y','w','d','h','m','s'], add_s=False, separator=''):
"""
Takes an amount of seconds and turns it into a human-readable amount
of time.
From http://snipplr.com/view.php?codeview&id=5713
"""
# the formatted time string to be returned
time = []
# the pieces of time to iterate over (days, hours, minutes, etc)
# - the first piece in each tuple is the suffix (d, h, w)
# - the second piece is the length in seconds (a day is 60s * 60m * 24h)
parts = [(suffixes[0], 60 * 60 * 24 * 7 * 52),
(suffixes[1], 60 * 60 * 24 * 7),
(suffixes[2], 60 * 60 * 24),
(suffixes[3], 60 * 60),
(suffixes[4], 60),
(suffixes[5], 1)]
# for each time piece, grab the value and remaining seconds, and add it to
# the time string
for suffix, length in parts:
value = seconds // length
if value > 0:
seconds = seconds % length
time.append('%s%s' % (str(value),
(suffix, (suffix, suffix + 's')[value > 1])[add_s]))
if seconds < 1:
break
return separator.join(time)
开发者ID:craigeley,项目名称:toggl-cli,代码行数:31,代码来源:toggl.py
示例19: lastUpdate
def lastUpdate(self):
time = [self.parser.source.time()]
h = inspect.getmro(self.__class__)
h = h[:-3]
for c in h:
time.append(int(os.path.getmtime(inspect.getfile(c))+.5))
return max(time)
开发者ID:tyndare,项目名称:osmose-backend,代码行数:7,代码来源:Analyser_Merge.py
示例20: getGains
def getGains( infile ) :
time = []
gain = []
p= subprocess.Popen( ( shlex.split('gplist vis=%s options=all' % infile) ), \
stdout=subprocess.PIPE,stdin=subprocess.PIPE,stderr=subprocess.STDOUT)
result = p.communicate()[0]
lines = result.split("\n")
ngains = (len(lines) - 3)/23
# caution: this presumes 23 antennas will be listed for each time, and that
# gains output has 3 header lines (and one blank line at the end ?)
gainComplex = numpy.zeros( (ngains,15), dtype=complex )
ng = -1
for n in range(3, len(lines) ) :
a = lines[n].split()
if ( (len(a) > 0) and (a[0] != "Ant") ) :
ng = ng + 1
time.append( a[0] )
nant = int(a[2])
if ( nant != 1 ) :
print "getGains error - unexpected ant number"
gainComplex[ng][nant-1] = float(a[5]) + 1j * float(a[6])
elif ( len(a) > 0 ) :
nant = int(a[1])
if ( nant < 16 ) :
gainComplex[ng][nant-1] = float(a[4]) + 1j * float(a[5])
return [time, gainComplex]
开发者ID:richardplambeck,项目名称:tadpol,代码行数:26,代码来源:vlbiCal.py
注:本文中的time.append函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论