当前位置: 首页>>代码示例>>Python>>正文


Python pylab.datestr2num函数代码示例

本文整理汇总了Python中pylab.datestr2num函数的典型用法代码示例。如果您正苦于以下问题:Python datestr2num函数的具体用法?Python datestr2num怎么用?Python datestr2num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了datestr2num函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的pylab.datestr2num函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。