本文整理汇总了Python中pylab.datestr2num函数的典型用法代码示例。如果您正苦于以下问题:Python datestr2num函数的具体用法?Python datestr2num怎么用?Python datestr2num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了datestr2num函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_timeseries
def plot_timeseries(ns,nsexp):
pl.clf()
pl.subplot(2,1,1)
pl.scatter(ns.jdvec[:,np.newaxis,np.newaxis] +
ns.timecube[:,20:30,20:30]*0,ns.timecube[:,20:30,20:30],2,'r')
pl.scatter(ns.jdvec,nanmean(nanmean(ns.timecube[:,20:30,20:30],axis=1),axis=1),5,'y')
pl.legend(('Satellite Observations','Daily means'))
pl.gca().xaxis.axis_date()
pl.xlim(pl.datestr2num('2003-01-01'), pl.datestr2num('2013-05-31'))
pl.setp(pl.gca(), yscale="log")
pl.ylim(0.01,5)
pl.title('BATS')
pl.ylabel(r'Chl (mg m$^{-3}$ d$^{-1}$)')
pl.subplot(2,1,2)
pl.scatter(nsexp.jdvec[:,np.newaxis,np.newaxis] +
nsexp.timecube[:,20:30,20:30]*0,
nsexp.timecube[:,20:30,20:30],2,'r')
pl.scatter(nsexp.jdvec,
nanmean(nanmean(nsexp.timecube[:,20:30,20:30],axis=1),axis=1),5,'y')
pl.gca().xaxis.axis_date()
pl.xlim(pl.datestr2num('2003-01-01'), pl.datestr2num('2013-05-31'))
pl.setp(pl.gca(), yscale="log")
pl.ylabel(r'Chl (mg m$^{-3}$ d$^{-1}$)')
pl.ylim(0.01,5)
pl.title(r'Experiment Site (45$\degree$N 24$\degree$W)')
开发者ID:brorfred,项目名称:satmap,代码行数:26,代码来源:dimhistory.py
示例2: _l3read_nc4
def _l3read_nc4(self):
self.vprint( "Reading netCDF4 file")
print(self.filename)
nc = Dataset(self.filename)
nc.set_auto_mask(False)
nc.set_auto_scale(True)
var = nc.variables[nc.variables.keys()[0]]
field = var[self.j1:self.j2, self.i1:self.i2].copy()
try:
self.minval = var.valid_min
except AttributeError:
self.minval = var.display_min
try:
valid_max = var.valid_max
except AttributeError:
valid_max = 0
try:
display_max = var.display_max
except AttributeError:
display_max = 0
self.maxval = max(valid_max, display_max)
start_jd = pl.datestr2num(nc.time_coverage_start)
end_jd = pl.datestr2num(nc.time_coverage_end)
self.jd = ((start_jd + end_jd)/2)
self.date = pl.num2date(self.jd)
return field
开发者ID:brorfred,项目名称:njord,代码行数:28,代码来源:nasa.py
示例3: __init__
def __init__(self, lon1=-30,lon2=-15,lat1=40,lat2=50,res="4km",**kwargs):
self.projname = "nasa.MODIS"
super(L3, self).__init__(lon1=lon1, lat1=lat1, lon2=lon2, lat2=lat2,
res=res, map_region='dimensions', **kwargs)
jd1 = pl.datestr2num('2003-01-01')
jd2 = pl.datestr2num('2013-05-30')+1
self.jdvec = np.arange(jd1, jd2)
开发者ID:brorfred,项目名称:satmap,代码行数:7,代码来源:dimhistory.py
示例4: get_tvec
def get_tvec(self, jd1, jd2):
jd1 = pl.datestr2num(jd1) if type(jd1) is str else jd1
jd2 = pl.datestr2num(jd2) if type(jd2) is str else jd2
tvec = self.fulltvec
if jd1 < tvec.min():
raise ValueError, "jd1 too small"
if jd2 > tvec.max():
raise ValueError, "jd2 too large"
return tvec[(tvec >= jd1) & (tvec <= jd2)]
开发者ID:brorfred,项目名称:njord,代码行数:9,代码来源:base.py
示例5: dealias_berrimah_volume
def dealias_berrimah_volume(filename, **kwargs):
pattern=kwargs.get('pattern', 'BerrimaVol')
deal_add=kwargs.get('deal_add', '_deal')
raw_path=kwargs.get('raw_path', '/data/uf_ber/')
deal_path=kwargs.get('deal_path', '/data/deal_ber/')
deal_files=os.listdir(deal_path)
raw_files=os.listdir(raw_path)
#deal_files=[]
#raw_files=[]
#for file in uf_files:
# if 'deal' in file:
# deal_files.append(file)
# else:
# raw_files.append(file)
#
if not(filename in raw_files):
raise IOError, 'File not there'
deal_files.sort()
raw_files.sort()
this_date_str=filename[len(pattern):-3].replace('_', ' ')
this_date_str=this_date_str[0:this_date_str.find(' ')+5]
sonde_name=read_sounding.make_deal_sonde(this_date_str)
deal_date=sonde_name[0:sonde_name.find('_')]
date_num_list=[]
for file in deal_files:
deal_str=file[len(pattern):-8].replace('_', ' ')
deal_str=deal_str[0:deal_str.find(' ')+5]
date_num_list.append(datestr2num(deal_str))
offset=array(date_num_list)-datestr2num(this_date_str)
idec_where=nwhere(offset < 0.0)[0]
offset_least=100.0
if len(idec_where)!=0: offset_least=offset[idec_where[-1]]
print "**********************"
if abs(offset_least) < 30.0/(60.0*24.0):
deal_fname=deal_files[idec_where[-1]]
print "Found a previous de-aliased file ", deal_fname
else:
print "No de-aliased file found within 30 minutes, only using sounding"
deal_fname='dummy'
print "********************"
outfile=filename[0:-3]+deal_add+".uf"
cwd=os.getcwd()
os.chdir('/home/scollis/bom_mds/dealias/')
execbl='./FourDD_berrimah '
command=execbl+deal_path+deal_fname+' '+raw_path+filename+' '+deal_path+outfile+' '+ sonde_name+' '+deal_date+' '+'0 1 1 1'
print command
os.system(command)
os.chdir(cwd)
return outfile
开发者ID:scollis,项目名称:bom_mds,代码行数:53,代码来源:dealias.py
示例6: dealias_single_volume
def dealias_single_volume(filename, **kwargs):
pattern=kwargs.get('pattern', 'Gunn_pt_')
deal_add=kwargs.get('deal_add', '_deal')
lassen_path=kwargs.get('lassen_path', '/bm/gscratch/scollis/lassen_cpol/')
uf_path=kwargs.get('lassen_path', '/bm/gscratch/scollis/uf_cpol/')
deal_files=os.listdir(uf_path)
raw_files=os.listdir(lassen_path)
#deal_files=[]
#raw_files=[]
#for file in uf_files:
# if 'deal' in file:
# deal_files.append(file)
# else:
# raw_files.append(file)
#
if not(filename in raw_files):
raise IOError, 'File not there: '+filename
deal_files.sort()
raw_files.sort()
this_date_str=filename[len(pattern):-11]
#this_date_str=this_date_str[0:this_date_str.find(' ')+5]
sonde_name=read_sounding.make_deal_sonde(this_date_str)
deal_date=sonde_name[0:sonde_name.find('_')]
date_num_list=[]
for file in deal_files:
deal_str=file[len(pattern):-8]
#print deal_str
#deal_str=deal_str[0:deal_str.find(' ')+5]
#print deal_str
date_num_list.append(datestr2num(deal_str))
offset=array(date_num_list)-datestr2num(this_date_str)
idec_where=nwhere(offset < 0.0)[0]
offset_least=100.0
if len(idec_where)!=0: offset_least=offset[idec_where[-1]]
print "**********************"
if abs(offset_least) < 30.0/(60.0*24.0):
deal_fname=deal_files[idec_where[-1]]
print "Found a previous de-aliased file ", deal_fname
else:
print "No de-aliased file found within 30 minutes, only using sounding"
deal_fname='dummy'
print "********************"
outfile=filename[0:-11]+deal_add+".uf"
cwd=os.getcwd()
os.chdir('/flurry/home/scollis/bom_mds/dealias/')
execbl='./FourDD_lassen '
command=execbl+uf_path+deal_fname+' '+lassen_path+filename+' '+uf_path+outfile+' '+ sonde_name+' '+deal_date+' '+'1 1 1 1'
print command
os.system(command)
os.chdir(cwd)
return outfile
开发者ID:scollis,项目名称:bom_mds,代码行数:51,代码来源:dealias_gunnpt_volume.py
示例7: time
def time(self, i=500,j=250):
if not hasattr(self,'h5f'): self.h5open()
mat = self.h5f.root.chl[:,j-5:j+5,i-5:i+5]
figpref.presentation()
jd = pl.datestr2num('2012-01-01')
jd2 = pl.datestr2num('2013-04-30')+1
pl.gca().xaxis.axis_date()
pl.scatter(self.jdvec[:,np.newaxis,np.newaxis]+mat*0,mat, 5,'g')
pl.xlim(jd,jd2)
pl.scatter(self.jdvec,nanmean(nanmean(mat,axis=1),axis=1),20,'y')
#setp(gca(),yscale='log')
pl.ylim(0.01,5)
return pl.gca()
开发者ID:brorfred,项目名称:satmap,代码行数:15,代码来源:dimhistory.py
示例8: drawCity
def drawCity(self):
"""
作图
:return:
"""
pl.title("pm25 / time " + str(self.numMonitors) + "_monitors")# give plot a title
pl.xlabel('time')# make axis labels
pl.ylabel('pm2.5')
self.fill_cityPm25List()
for monitorStr in self.cityPm25List:
data = np.loadtxt(StringIO(monitorStr), dtype=np.dtype([("t", "S13"),("v", float)]))
datestr = np.char.replace(data["t"], "T", " ")
t = pl.datestr2num(datestr)
v = data["v"]
pl.plot_date(t, v, fmt="-o")
pl.subplots_adjust(bottom=0.3)
# pl.legend(loc=4)#指定legend的位置,读者可以自己help它的用法
ax = pl.gca()
ax.fmt_xdata = pl.DateFormatter('%Y-%m-%d %H:%M:%S')
pl.xticks(rotation=70)
# pl.xticks(t, datestr) # 如果以数据点为刻度,则注释掉这一行
ax.xaxis.set_major_formatter(pl.DateFormatter('%Y-%m-%d %H:%M'))
pl.grid()
pl.show()# show the plot on the screen
开发者ID:KGBUSH,项目名称:AQI-Forecast,代码行数:29,代码来源:DrawCityPm25.py
示例9: 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
示例10: 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
示例11: process_data_ria
def process_data_ria ( data ):
"""This function proesses the data bundle downloaded from a RIA
station, and returns a number of arrays with the data."""
t_string = [ line.split()[0] for line in data[2:] \
if len(line.split()) == 13 ]
year = [ 2000 + int ( line.split()[0].split( "-" )[-1] ) \
for line in data[2:] if len(line.split()) == 13 ]
doy = [ int ( line.split()[1]) \
for line in data[2:] if len(line.split()) == 13 ]
tmax = [ float ( line.split()[2]) \
for line in data[2:] if len(line.split()) == 13 ]
tmin = [ float ( line.split()[4]) \
for line in data[2:] if len(line.split()) == 13 ]
tmean = [ float ( line.split()[6]) \
for line in data[2:] if len(line.split()) == 13 ]
swrad = [ float ( line.split()[-3]) \
for line in data[2:] if len(line.split()) == 13 ]
wspd = [ float ( line.split()[-5]) \
for line in data[2:] if len(line.split()) == 13 ]
eto = [ float ( line.split()[-1]) \
for line in data[2:] if len(line.split()) == 13 ]
hum = [ float ( line.split()[9]) \
for line in data[2:] if len(line.split()) == 13 ]
prec = [ float ( line.split()[-2]) \
for line in data[2:] if len(line.split()) == 13 ]
t_axis = [ time.strftime("%Y-%m-%d", \
time.strptime( line.split()[0], "%d-%m-%y")) \
for line in data[2:] if len(line.split()) == 13 ]
t_axis = pylab.datestr2num ( t_axis )
return ( t_axis, t_string,year, doy, tmax, tmin, tmean, swrad, \
wspd, eto, hum, prec )
开发者ID:jgomezdans,项目名称:get_ria,代码行数:32,代码来源:GetRIA.py
示例12: refresh
def refresh(self, fld, fldtype="DAY", jd1=None, jd2=None, delall=False):
""" Read a L3 mapped file and add field to current instance"""
jd1 = pl.datestr2num('2003-01-01') if jd1 is None else jd1
jd2 = int(pl.date2num(dtm.now())) - 1 if jd2 is None else jd2
for jd in np.arange(jd1, jd2):
print " --- %s --- " % pl.num2date(jd).strftime('%Y-%m-%d')
filename = os.path.join(
self.datadir, self.generate_filename(jd,fld,fldtype) + ".nc")
if delall:
for fn in glob.glob(filename + "*"):
print "Deleted %s" % fn
os.remove(fn)
print "Checking files"
if not os.path.isfile(filename[:-3] + '.npz'):
try:
self.load(fld, fldtype, jd=jd, verbose=True)
except IOError:
print "Downloading failed. Trying to remove old files."
try:
os.remove(filename)
except:
pass
try:
self.load(fld,fldtype,jd=jd,verbose=True)
except:
print (" ### Warning! Failed to add %s ###" %
os.path.basename(filename))
print "\n"
else:
print "found"
开发者ID:brorfred,项目名称:njord,代码行数:30,代码来源:nasa.py
示例13: __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
示例14: load_csv
def load_csv(self,f):
"""
Loading data from a csv file. Uses pylab's load function. Seems much faster
than scipy.io.read_array.
"""
varnm = f.readline().split(',')
# what is the date variable's key if any, based on index passed as argument
if self.date_key != '':
try:
rawdata = pylab.load(f, delimiter=',',converters={self.date_key:pylab.datestr2num}) # don't need to 'skiprow' here
except ValueError: # if loading via pylab doesn't work use csv
rawdata = self.load_csv_nf(f)
# converting the dates column to a date-number
rawdata[self.date_key] = pylab.datestr2num(rawdata[self.date_key])
self.date_key = varnm[self.date_key]
else:
try:
rawdata = pylab.load(f, delimiter=',') # don't need to 'skiprow' here
except ValueError: # if loading via pylab doesn't work use csv
rawdata = self.load_csv_nf(f)
# making sure that the variable names contain no leading or trailing spaces
varnm = [i.strip() for i in varnm]
# transforming the data into a dictionary
if type(rawdata) == list:
# if the csv module was used
self.data = dict(zip(varnm,rawdata))
else:
# if the pylab.load module was used
self.data = dict(zip(varnm,rawdata.T))
开发者ID:BKJackson,项目名称:SciPy-CookBook,代码行数:34,代码来源:dbase.0.3.py
示例15: timeseries
def timeseries(self, fieldname, jd1, jd2, mask=None):
"""Create a timeseries of fields using mask to select data"""
mask = mask if mask is not None else self.llat == self.llat
jd1 = pl.datestr2num(jd1) if type(jd1) is str else jd1
jd2 = pl.datestr2num(jd2) if type(jd2) is str else jd2
self.tvec = np.arange(jd1, jd2+1)
field = np.zeros((len(self.tvec),) + self.llat.shape, dtype=np.float32)
for n,jd in enumerate(self.tvec):
print pl.num2date(jd), pl.num2date(jd2)
try:
field[n,:,:] = self.get_field(fieldname, jd=jd).astype(np.float32)
except KeyError:
field[n,:,:] = np.nan
field[n, ~mask] = np.nan
setattr(self, fieldname + 't', field)
开发者ID:raphaeldussin,项目名称:njord,代码行数:16,代码来源:base.py
示例16: load
def load(self,**kwargs):
""" Load Oscar fields for a given day"""
self._timeparams(**kwargs)
md = self.jd - pl.datestr2num('1992-10-05')
filename = os.path.join(self.datadir, "oscar_vel%i.nc" % self.yr)
if not os.path.exists(filename):
self.download(filename)
filenam2 = os.path.join(self.datadir, "oscar_vel%i.nc" % (self.yr+1))
if not os.path.exists(filenam2):
self.download(filenam2)
nc1 = netcdf_file(filename)
tvec = nc1.variables['time'][:]
t1 = int(np.nonzero((tvec<=md))[0].max())
print t1,max(tvec)
if t1<(len(tvec)-1):
nc2 = nc1
t2 = t1 +1
else:
nc2 = netcdf_file(filenam2)
t2 = 0
def readfld(ncvar):
return self.gmt.field(ncvar[t1, 0,:,:self.imt])[self.j1:self.j2,
self.i1:self.i2]
u1 = readfld(nc1.variables['u'])
v1 = readfld(nc1.variables['v'])
u2 = readfld(nc2.variables['u'])
v2 = readfld(nc2.variables['v'])
rat = float(md-tvec[t1])/float(tvec[t2]-tvec[t1])
self.u = u2*rat + u1*(1-rat)
self.v = v2*rat + v1*(1-rat)
print self.jd,md,t1,t2
开发者ID:raphaeldussin,项目名称:njord,代码行数:32,代码来源:oscar.py
示例17: _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
示例18: parse_info_line
def parse_info_line(info_line):
# date_obj=num2date(datestr2num(info_line[(info_line.find('date/time=')+len('date/time=')):-1]))
# n_rays=int(info_line[(info_line.find('number_of_rays=')+len('number_of_rays=')):(info_line.find('date/time=')-1)])
ilsplit = info_line.split()
date_obj = num2date(datestr2num(ilsplit[-2] + " " + ilsplit[-1]))
sweep_number = int(ilsplit[ilsplit.index("sweep_no=") + 1])
nrays = int(ilsplit[ilsplit.index("number_of_rays=") + 1])
return {"date": date_obj, "sweep number": sweep_number, "rays": nrays}
开发者ID:scollis,项目名称:bom_mds,代码行数:8,代码来源:read_rays.py
示例19: analysisImg
def analysisImg(rslist,spercode,start,end):
# import matplotlib.font_manager as font_manager
#
# path = '/usr/share/fonts/winfonts/simfang.ttf'
#
# prop = font_manager.FontProperties(fname=path)
# prop.set_weight = 'light'
#
# matplotlib.rc('font', family='sans-serif')
# matplotlib.rc('font', serif='FangSong')
# matplotlib.rc('text', usetex='false')
# matplotlib.rcParams.update({'font.size': 12})
#日期:结束日期 >= 27 ,取每月的周三
# 13< 。。。< 27 , 取奇数
# 6 <= 。。。<= 13 ,顺序数
# 。。。<6 ,每日00:00,12:00
list = []
if rslist:
for item in rslist:
sd = pylab.datestr2num(item[0])
dict = (sd,float(item[6].quantize(decimal.Decimal('0.0'))))
list.append(dict)
#排序
dict= sorted(list, key=lambda d:d[0])
x,xt,y = [],[],[]
for item in dict:
x.append(item[0])
y.append(item[1])
if x:
xmin = min(x)
xmax = max(x)
plt.xlim(xmin,xmax)
if y:
ymin = min(y)
ymax = max(y)
plt.ylim(ymin,ymax)
plt.plot(x, y, linestyle='-',color="red")
ds = [pylab.num2date(d) for d in x]
xt = [(d.strftime('%d')+"-"+d.strftime("%m")+"月") for d in ds]
plt.xticks(x,xt)
plt.xlabel('时间(天)')
plt.ylabel('金额(元)')
plt.title('供应商日销售汇总折线图')
plt.grid(True)
root = settings.BASE_DIR
filepath = "/static/image/daysale/" + spercode+".png"
plt.savefig(root+filepath)
return filepath
开发者ID:KGPython,项目名称:scm,代码行数:58,代码来源:analysis.py
示例20: _convert_options
def _convert_options(self):
"""
Convert options, which are only strings in the beginning
to numerical values or execute functions to set directory
names appropriately
"""
for v in self.options.keys():
var = self.options[v]
for s in var.keys(): # each section
sec = var[s]
for k in sec.keys():
if k == 'start':
sec.update({k: pl.num2date(pl.datestr2num(sec[k]))})
elif k == 'stop':
sec.update({k: pl.num2date(pl.datestr2num(sec[k]))})
else:
# update current variable with valid value
sec.update({k: self.__convert(sec[k])})
开发者ID:jian-peng,项目名称:pycmbs,代码行数:18,代码来源:config.py
注:本文中的pylab.datestr2num函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论