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


Python pylab.num2date函数代码示例

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


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


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