本文整理汇总了Python中pylab.date2num函数的典型用法代码示例。如果您正苦于以下问题:Python date2num函数的具体用法?Python date2num怎么用?Python date2num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date2num函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setTicks
def setTicks(self):
""" set x and y axes major and minor tick locators, formatters and labels """
# define tick locators
self.xMajor = LinearLocator(numticks = 16)
self.xMinor = LinearLocator(numticks = 76)
self.yMajor = LinearLocator(numticks = 5)
self.yMinor = LinearLocator(numticks = 17)
self.starttime = datetime.datetime.today()
self.starttime_tick = time.mktime(self.starttime.timetuple())
self.currenttime = self.starttime + datetime.timedelta(seconds = 3)
self.currenttime_tick = time.mktime(self.currenttime.timetuple())
self.lines = self.axes.plot([self.starttime], [0], 'r-')
# set tick locators
self.axes.xaxis.set_major_locator(self.xMajor)
self.axes.xaxis.set_minor_locator(self.xMinor)
self.axes.yaxis.set_major_locator(self.yMajor)
self.axes.yaxis.set_minor_locator(self.yMinor)
self.axes.set_xlim((date2num(self.starttime),date2num(self.currenttime)))
# create x-axis tick labels (seconds)
self.axes.xaxis.set_ticklabels(self.createXTickLabels(self.currenttime_tick), rotation = 30, ha = "right", size = 'smaller', name = 'Calibri')
self.axes.set_ylim(self.ymin,self.ymax)
# create y-axis tick labels (mV)
self.axes.yaxis.set_ticklabels(self.createYTickLabels(self.ymin), size = 'smaller', name = 'Calibri')
# set the properties of the minor axes
self.axes.grid(color = 'lightgrey', linewidth = 0.05, linestyle = ':', which = 'minor')
# set the properties of the major axes
self.axes.grid(color = 'slategrey', linewidth = 0.5, linestyle = '-', which = 'major')
开发者ID:hamalawy,项目名称:telehealth,代码行数:32,代码来源:ecgplotter.py
示例2: 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
示例3: plot_1d_comparison
def plot_1d_comparison(data_dict,style_dict,time_dict,start_date,finish_date,file_path,axis_label,interval=3):
"""
"""
start_time = date2num(datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S"))
finish_time = date2num(datetime.strptime(finish_date, "%Y-%m-%d %H:%M:%S"))
# plot 1d graph...
fig = figure(figsize=(15,8),dpi=90)
ax = fig.add_axes([.05,.12,.9,.85])
max_value = 0.0
for key, data_arr in data_dict.iteritems():
ax.plot(time_dict[key],data_arr,style_dict[key], label=key)
data_arr = vtktools.arr(data_arr)
if data_arr.max() > max_value:
max_value = data_arr.max()
max_value += max_value * 0.1
dateFmt = mpl.dates.DateFormatter('%m/%Y')
ax.xaxis.set_major_formatter(dateFmt)
monthsLoc = mpl.dates.MonthLocator(interval=interval)
ax.xaxis.set_major_locator(monthsLoc)
labels = ax.get_xticklabels()
for label in labels:
label.set_rotation(30)
ax.set_ylim(max_value, 0)
ax.set_xlim(start_time,finish_time)
xlabel('Date (mm/yyyy)')
ylabel(axis_label)
legend(loc=0)
form = file_path.split('.')[-1].strip()
savefig(file_path, dpi=90,format=form)
close(fig)
开发者ID:jhill1,项目名称:python_scripts,代码行数:33,代码来源:mld_util.py
示例4: 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
示例5: setXYlim
def setXYlim(self, data, para):
for label in self.axes.get_xaxis().get_ticklabels():
label.set_fontsize(9)
if data[1][-1] > 0: #正
if data[1][-1] > para["open"]*0.75:
self.axes.axhline(y = para["open"], linestyle = "--", linewidth = 0.5, color = "gray")
if data[1][-1] > para["stop"]*0.85:
self.axes.axhline(y = para["stop"], linestyle = "--", linewidth = 0.5, color = "red")
if data[1][-1] < para["close"]*1.15:
self.axes.axhline(y = para["close"], linestyle = "--", linewidth = 0.5, color = "green")
else: #反
if data[1][-1] < -para["open"]*0.75:
self.axes.axhline(y = -para["open"], linestyle = "--", linewidth = 0.5, color = "gray")
if data[1][-1] < -para["stop"]*0.85:
self.axes.axhline(y = -para["stop"], linestyle = "--", linewidth = 0.5, color = "red")
if data[1][-1] > -para["close"]*1.15:
self.axes.axhline(y = -para["close"], linestyle = "--", linewidth = 0.5, color = "green")
thisDate = copy.copy(data[0][-1])
if data[0][-1].time() <= datetime.time(11,30,0):
self.axes.axis(xmin=pylab.date2num(thisDate.replace(hour=9,minute=30,second=0)), xmax=pylab.date2num(thisDate.replace(hour=11,minute=30)))
else:
self.axes.axis(xmin=pylab.date2num(thisDate.replace(hour=13,minute=0,second=0)), xmax=pylab.date2num(thisDate.replace(hour=15,minute=0)))
pass
开发者ID:sharmaking,项目名称:CoIntegrationAnalysis,代码行数:25,代码来源:mlpCanvas.py
示例6: 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
示例7: generate_filename
def generate_filename(self, fld='chl', fldtype="DAY", **kwargs):
"""Generate filename"""
if len(kwargs):
self._timeparams(**kwargs)
ydmax = (pl.date2num(dtm(self.yr, 12, 31)) -
pl.date2num(dtm(self.yr, 1, 1))) + 1
if fldtype == "MC":
self.add_mnclim()
datestr = self.mc_datedict[self.mn]
if "mo" in fldtype.lower():
self.add_filepreflist(fldtype="mo")
datestr = self.mo_fileprefs[self.yr*100 + self.mn]
elif fldtype == "DAY":
datestr = "%i%03i" % (self.yr, self.yd)
elif fldtype == "8D":
yd1 = np.arange(1,365,8)
yd2 = np.arange(8,370,8)
yd2[-1] = ydmax
pos = np.nonzero(self.yd >= yd1)[0].max()
datestr = ("%i%03i%i%03i" %
(self.yr, yd1[pos], self.yr, yd2[pos]))
elif fldtype == "CU":
self.a_cu_url_9km = 'MODISA/Mapped/Cumulative/4km/chlor/'
datestr = max(self._retrieve_datestamps(self.a_cu_url_9km))
else:
raise TypeError, "File average type not included"
return("%s%s.L3m_%s_%s_%s%s.nc" % (self.fp, datestr, fldtype,
self.vc[fld][0], self.res[0],
self.vc[fld][1]))
开发者ID:brorfred,项目名称:njord,代码行数:29,代码来源:nasa.py
示例8: _timeparams
def _timeparams(self, **kwargs):
"""Calculate time parameters from given values"""
for key in kwargs.keys():
self.__dict__[key] = kwargs[key]
if "date" in kwargs:
self.jd = pl.datestr2num(kwargs['date'])
self.jd = int(self.jd) if self.jd == int(self.jd) else self.jd
elif ('yd' in kwargs) & ('yr' in kwargs):
if self.yd < 1:
self.yr = self.yr -1
ydmax = (pl.date2num(dtm(self.yr, 12, 31)) -
pl.date2num(dtm(self.yr, 1, 1))) + 1
self.yd = ydmax + self.yd
self.jd = self.yd + pl.date2num(dtm(self.yr,1,1)) - 1
elif ('yr' in kwargs) & ('mn' in kwargs) & ('dy' in kwargs):
self.jd = pl.date2num(dtm(self.yr,self.mn,self.dy))
elif not 'jd' in kwargs:
if hasattr(self, 'defaultjd'):
self.jd = self.defaultjd
else:
raise KeyError, "Time parameter missing"
if hasattr(self,'hourlist'):
dd = self.jd-int(self.jd)
ddlist = np.array(self.hourlist).astype(float)/24
ddpos = np.argmin(np.abs(ddlist-dd))
self.jd = int(self.jd) + ddlist[ddpos]
self._jd_to_dtm()
开发者ID:raphaeldussin,项目名称:njord,代码行数:27,代码来源:base.py
示例9: save_data_cube
def save_data_cube(radar1, radar2, ncf_fname):
ncf = NetCDFFile(ncf_fname, "w")
ncf.createDimension("nx", len(radar1["xar"]))
ncf.createDimension("ny", len(radar1["yar"]))
ncf.createDimension("nl", len(radar1["levs"]))
ncf.createDimension("one", 1)
ncf.createDimension("two", 2)
avail_vars_radar1 = set(radar1.keys()) & set(
["VE", "VR", "CZ", "RH", "PH", "ZD", "SW", "KD", "i_comp", "j_comp", "k_comp", "u_array", "v_array", "w_array"]
)
avail_vars_radar2 = set(radar2.keys()) & set(
["VE", "VR", "CZ", "RH", "PH", "ZD", "SW", "KD", "i_comp", "j_comp", "k_comp"]
)
# testme=make_var(ncf, var, 'f', ('nx', 'ny', 'nl'), gp[var])
ncf_varlist_radar1 = [
make_var(ncf, var + "_radar1", "f", ("nx", "ny", "nl"), radar1[var]) for var in avail_vars_radar1
]
ncf_varlist_radar2 = [
make_var(ncf, var + "_radar2", "f", ("nx", "ny", "nl"), radar2[var]) for var in avail_vars_radar2
]
xvar = ncf.createVariable("xar", "f", ("one", "nx"))
for i in range(len(radar1["xar"])):
xvar[0, i] = float(radar1["xar"][i])
yvar = ncf.createVariable("yar", "f", ("one", "ny"))
for j in range(len(radar1["yar"])):
yvar[0, j] = float(radar1["yar"][j])
# yvar.assignValue(array([gp['yar']]))
lvar = ncf.createVariable("levs", "f", ("one", "nl"))
for k in range(len(radar1["levs"])):
lvar[0, k] = float(radar1["levs"][k])
# lvar.assignValue(array([gp['levs']]))
rad1_locvar = ncf.createVariable("radar1_loc", "f", ("one", "two"))
rad2_locvar = ncf.createVariable("radar2_loc", "f", ("one", "two"))
rad1_disvar = ncf.createVariable("radar1_dis", "f", ("one", "two"))
rad2_disvar = ncf.createVariable("radar2_dis", "f", ("one", "two"))
rad1_datvar = ncf.createVariable("radar1_date", "d", ("one", "one"))
rad2_datvar = ncf.createVariable("radar2_date", "d", ("one", "one"))
rad1_locvar[0, 0] = float(radar1["radar_loc"][0])
rad1_locvar[0, 1] = float(radar1["radar_loc"][1])
rad2_locvar[0, 0] = float(radar2["radar_loc"][0])
rad2_locvar[0, 1] = float(radar2["radar_loc"][1])
rad1_disvar[0, 0] = float(radar1["displacement"][0])
rad1_disvar[0, 1] = float(radar1["displacement"][1])
rad2_disvar[0, 0] = float(radar2["displacement"][0])
rad2_disvar[0, 1] = float(radar2["displacement"][1])
rad1_datvar[0, 0] = float(date2num(radar1["date"]))
rad2_datvar[0, 0] = float(date2num(radar2["date"]))
setattr(ncf, "radar1_name", radar1["radar_name"])
setattr(ncf, "radar2_name", radar2["radar_name"])
# ncf_varlist_gp=dict([(var+'_gp',ncf.createVariable(var+'_gp', 'f', ('nx', 'ny', 'nl'))) for var in avail_vars_gp])
# for var in avail_vars_gp:
# for i in range(ncf_varlist_gp[var+'_gp'].shape[0]):
# for j in range(ncf_varlist_gp[var+'_gp'].shape[1]):
# for k in range(ncf_varlist_gp[var+'_gp'].shape[2]):
# ncf_varlist_gp[var+'_gp'][i,j,k]=gp[var][i,j,k]
ncf.close()
开发者ID:scollis,项目名称:bom_mds,代码行数:57,代码来源:netcdf_utis.py
示例10: addSlider
def addSlider(self, valmax):
""" put a slider widget to navigate through the whole ECG plot """
### FIX ME: Make all time objects as parameters??? (for flexibility)
### Maybe the self.endtime? Kase constant lagi ang starting point
### added valmax as the endtime parameter
self.axtime = self.figure.add_axes([0.125, 0.1, 0.775, 0.03])
self.time_scroller = matplotlib.widgets.Slider(
self.axtime, "", date2num(self.starttime), date2num(valmax), valinit=date2num(self.starttime)
)
self.time_scroller.on_changed(self.updateWindow)
开发者ID:hamalawy,项目名称:telehealth,代码行数:10,代码来源:ecgplotter.py
示例11: make_hourly
def make_hourly(data):
'''
'''
time = data['time']
ntimesnew = int((time[-1]-time[0]).total_seconds() / 3600)
timenew = [time[0]+dt.timedelta(i)/24 for i in range(ntimesnew)]
for varname, var in data.iteritems():
if (varname == 'time'):
continue
var = sp.interp(pl.date2num(timenew), pl.date2num(time), var)
data[varname] = var
data['time'] = timenew
return 0
开发者ID:johannesro,项目名称:waveverification,代码行数:13,代码来源:collectdatatools.py
示例12: extraPlots
def extraPlots():
import datetime
from matplotlib.dates import MONDAY, MonthLocator, WeekdayLocator, DateFormatter
#converts dates to format matplotlib understands...
time = P.date2num(data[:,dict['DateTimeUT']])
mondays = WeekdayLocator(MONDAY)
months = MonthLocator(range(1,13, 2), bymonthday=2)
monthsFmt = DateFormatter("%b '%y")
y2007 = datetime.date(2007, 1, 1)
y2008 = datetime.date(2008, 1, 1)
y2007plot = P.date2num(y2007)
y2008plot = P.date2num(y2008)
widening = 5.
fig = P.figure()
P.subplots_adjust(hspace=0.1)
ax = fig.add_subplot(211)
P.title('ALFOSC focus pyramid data')
ax.plot_date(time, telfocusOld, 'wo', xdate = True)
ax.plot_date(time, telfocusCorrected, 'bo')
ax.axhline(medianNew, color = 'b', label = 'New Median', lw = 1., ls = '-')
ax.axhline(medianOld, color = 'r', label ='Old Median', lw = 1., ls = '--')
ax.axvline(y2007plot, color = 'k')
ax.axvline(y2008plot, color = 'k')
ax.legend(shadow = True, loc = 'best')
P.ylabel('Telescope Focus + Median Offset')
P.xlim(min(time)-widening, max(time)+widening)
P.ylim(23300.,23500.)
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)
ax.xaxis.set_minor_locator(mondays)
fig.autofmt_xdate()
bx = fig.add_subplot(212)
bx.plot_date(time, data[:,dict['TempInAirDegC']], fmt='ro', xdate=True)
bx.axhline(0.)
bx.axvline(y2007plot, color = 'k')
bx.axvline(y2008plot, color = 'k')
bx.xaxis.set_major_locator(months)
bx.xaxis.set_major_formatter(monthsFmt)
bx.xaxis.set_minor_locator(mondays)
P.xlim(min(time)-widening, max(time)+widening)
P.ylabel('Temperature In Air (DegC)')
fig.autofmt_xdate()
fig.savefig('foc-pyr_time.png')
P.close()
开发者ID:eddienko,项目名称:SamPy,代码行数:51,代码来源:al_focpyr_test.py
示例13: 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
示例14: calc_mld
def calc_mld(files,start,x0=0.0,y0=0.0):
""" Caclulate density-based MLD from a bunch of VTU files
"""
mld = []
times = []
dates = []
for file in files:
try:
os.stat(file)
except:
print("No such file: %s" % file)
sys.exit(1)
# open vtu and derive the field indices of the edge at (x=0,y=0) ordered by depth
u=vtktools.vtu(file)
pos = u.GetLocations()
ind = get_1d_indices(pos, x0, y0)
# from this we can derive the 1D profile of any field like this:
depth = vtktools.arr([-pos[i,2] for i in ind])
# handle time for different types of plots
time = u.GetScalarField('Time')
times.append(time[0]) # seconds
dates.append( date2num(start + timedelta(seconds=time[0])) ) # integer datetime
# grab density profile and calculate MLD_den (using 2 different deviation parameters
d = u.GetScalarField('Density')
den = vtktools.arr( [d[i] * 1000 for i in ind] )
mld.append( calc_mld_den(den, depth) ) #den0 = 0.03 is default
return mld, times, dates
开发者ID:FluidityProject,项目名称:fluidity,代码行数:35,代码来源:gls_ocean_param.py
示例15: __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
示例16: plot_dwaf_data
def plot_dwaf_data(realtime, file_name='data_plot.png', gauge=True):
x = pl.date2num(realtime.date)
y = realtime.q
pl.clf()
pl.figure(figsize=(7.5, 4.5))
pl.rc('text', usetex=True)# TEX fonts
pl.plot_date(x,y,'b-',linewidth=1)
pl.grid(which='major')
pl.grid(which='minor')
if gauge:
pl.ylabel(r'Flow rate (m$^3$s$^{-1}$)')
title = 'Real-time flow -- %s [%s]' % (realtime.station_id[0:6], realtime.station_desc)
else:
title = 'Real-time capacity -- %s [%s]' % (realtime.station_id[0:6], realtime.station_desc)
pl.ylabel('Percentage of F.S.C')
labeled_days = DayLocator(interval=3)
ticked_days = DayLocator()
dayfmt = DateFormatter('%d/%m/%Y')
ax = pl.gca()
ax.xaxis.set_major_locator(labeled_days)
ax.xaxis.set_major_formatter(dayfmt)
ax.xaxis.set_minor_locator(ticked_days)
pl.xticks(fontsize=10)
pl.yticks(fontsize=10)
pl.title(title, fontsize=14)
pl.savefig(file_name, dpi=100)
开发者ID:pkaza,项目名称:SAHGutils,代码行数:33,代码来源:dwafdata.py
示例17: work_1
def work_1():
data_in = datetime(2010,6,24,8,00,0)
data_fin = datetime(2010,6,24,22,00,0)
#np.concatenate((dati,dati2))
dati = df.query_db('greenhouse.db','data',data_in,data_fin)
Is = dati['rad_int_sup_solar']
lista_to_filter = df.smooht_Is(Is)
Is_2 = df.smooth_value(Is,lista_to_filter)
tra_P_M = mf.transpiration_P_M(Is_2,dati['rad_int_inf_solar'],0.64,2.96,((dati['temp_1']+dati['temp_2'])/2)+273.15,(dati['RH_1']+dati['RH_2'])/200)
tra_weight = mf.transpiration_from_balance(dati['peso_balanca'],300,2260000)
delta_peso = np.diff(dati['peso_balanca'])
fr,lista_irr,lista_irr_free = mf.find_irrigation_point(delta_peso,dati['data'])
lista_night = mf.remove_no_solar_point(dati['rad_int_sup_solar'],50)
lista_no = list(set(lista_irr+ lista_night))
tran_weight,lista_yes = mf.transpiration_from_balance_irr(dati['peso_balanca'],300,2260000,lista_no)
min_avg = 6
tra_weigh_avg,time_weight = df.avg2(tran_weight,lista_yes,min_avg)
tra_P_M_avg,time_P_M = df.avg2(tra_P_M,lista_yes,min_avg)
data_plot.plot_time_data_2_y_same_axis(dati['data'][time_P_M], tra_P_M_avg, 'tra Penman', tra_weigh_avg, 'trans weight')
RMSE = df.RMSE(tra_P_M_avg, tra_weigh_avg)
print "RMSE is", RMSE
print "RRMSE is", df.RRMSE(RMSE, tra_weigh_avg)
date = dati['data'][time_P_M].astype(object)
dates= pylab.date2num(date)
pylab.plot_date(dates,tra_weigh_avg,'rx')
开发者ID:dpiscia,项目名称:green_building,代码行数:33,代码来源:data_analysis.py
示例18: _jd_to_dtm
def _jd_to_dtm(self):
dtobj = pl.num2date(self.jd)
njattrlist = ['yr', 'mn', 'dy', 'hr', 'min', 'sec']
dtattrlist = ['year','month','day','hour','minute', 'second']
for njattr,dtattr in zip(njattrlist, dtattrlist):
setattr(self, njattr, getattr(dtobj, dtattr))
self.yd = self.jd - pl.date2num(dtm(self.yr,1,1)) + 1
开发者ID:raphaeldussin,项目名称:njord,代码行数:7,代码来源:base.py
示例19: calc
def calc(self):
p0=3.
a0=15.
ts = wn.TrainStrategy.BFGS
inp = plb.date2num(self.time)
tar = self.value-np.average(self.value)
inp -= np.min(inp)
delta = np.max(inp)-np.min(inp)
k = 4*24/delta
inp *= k
w = wn.Net(10, np.min(inp), np.max(inp), np.average(tar),
a0, .01, p0)
track = w.train(inp, tar, ts, 200, 100000, 1, True, True)
#import pdb; pdb.set_trace()
#tool.show(inp, tar, w, track)
we = wn.Net(10, np.min(inp), np.max(inp), np.average(tar),
a0, .01, p0)
tracke = we.train(inp, tar, ts, 200, 100000, 1, False, False)
plb.title('Суммарная квадратичная ошибка')
plb.plot(tracke['e'][0], label='Обычная вейвсеть')
plb.plot(track['e'][0], linestyle='--', label='Полиморфная вейвсеть')
plb.xlabel('Эпохи')
plb.legend()
print (tracke['e'][-1])
print (track['e'][-1])
plb.show()
tool.show(inp, tar, w, tracke)
sys.exit()
开发者ID:abalckin,项目名称:cwavenet,代码行数:28,代码来源:geown100.py
示例20: time_string_to_pylab_float_time
def time_string_to_pylab_float_time(string):
# I don't want this entire module to be dependent on pylab.
try:
import pylab
except:
print >> sys.stderr, "Couldn't import pylab module."
sys.exit(1)
# strptime can't handle the fractional part. Split that off.
pieces = string.split('.')
date_and_time_part = pieces[0]
time_struct = date_and_time_part_to_time_struct(date_and_time_part)
float_time = pylab.date2num(time_struct)
# Add in the fractional part. Also try to handle the timezone part,
# if any.
if len(pieces) > 1:
remaining_pieces = pieces[1].split()
if len(remaining_pieces) == 1:
pass # No timezone offset
elif len(remaining_pieces) == 2:
pass # Timezone offset; ignore it.
else:
print >> sys.stderr, "Extra stuff in time string ", string
sys.exit(1)
sec_frac = float('.' + remaining_pieces[0])
return float_time + sec_frac / 24 / 60 / 60
else:
return float_time
开发者ID:bodboy,项目名称:scripts,代码行数:30,代码来源:tabutil_m.py
注:本文中的pylab.date2num函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论