本文整理汇总了Python中vcs.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_a_ratio
def plot_a_ratio(s,gm,ratio):
x=vcs.init()
x.open()
x.geometry(400,800)
y=vcs.init()
y.open()
y.geometry(800,400)
for X in [x,y]:
X.plot(s,gm,ratio=ratio)
if X.islandscape():
orient = "ldscp"
else:
orient = "port"
X.png("aspect_ratio_%s_%s.png" % (orient,ratio))
return x
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:15,代码来源:test_aspect_ratio.py
示例2: __init__
def __init__(self, *arg, **kw):
super(VcsPlot, self).__init__(*arg, **kw)
self._window = None
self._canvas = vcs.init()
self._plot = PlotManager(self._canvas)
self._plot.graphics_method = vcs.getisofill() # default
self._plot.template = vcs.elements['template']['default'] # default
开发者ID:UV-CDAT,项目名称:cdatweb,代码行数:7,代码来源:vcs_vis.py
示例3: plot_one_average
def plot_one_average (self, averager, template='default', graphics_mode='isofill'):
import vcs, cdms
canvas=vcs.init() # Construct VCS object to generate image
cdms.setAutoReshapeMode('off')
a, keyargs = averager(self.var)
apply(canvas.plot, (a, template, graphics_mode), keyargs) # Generate VCS isofill image
return gifiate(canvas)
开发者ID:MartinDix,项目名称:cdat_lite_test,代码行数:7,代码来源:cdms_templates.py
示例4: __init__
def __init__(self, parent=None, customPath=None, styles=None):
super(UVCDATMainWindow, self).__init__(parent)
self.root = self
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setDocumentMode(True)
# init user options
self.initCustomize(customPath, styles)
self.root = self
# self.tool_bar = mainToolbarWidget.QMainToolBarContainer(self)
self.canvas = []
self.canvas.append(vcs.init())
self.colormapEditor = QColormapEditor(self)
# Create the command recorder widget
self.recorder = commandsRecorderWidget.QCommandsRecorderWidget(self)
# Adds a shortcut to the record function
self.record = self.recorder.record
self.preferences = preferencesWidget.QPreferencesDialog(self)
self.preferences.hide()
self.cdmsCacheWidget = CdmsCacheWidget(self)
# self.regridding = regriddingWidget.QRegriddingDialog(self)
# self.regridding.hide()
###########################################################
# Init Menu Widget
###########################################################
self.mainMenu = mainMenuWidget.QMenuWidget(self)
self.createDockWindows()
self.createActions()
self.updateMenuActions()
self.embedSpreadsheet()
self.connectSignals()
self.resize(1150, 800)
开发者ID:painter1,项目名称:vistrails,代码行数:33,代码来源:mainwindow.py
示例5: updateContents
def updateContents(self, inputPorts):
""" Get the vcs canvas, setup the cell's layout, and plot """
spreadsheetWindow = spreadsheetController.findSpreadsheetWindow()
spreadsheetWindow.setUpdatesEnabled(False)
# Set the canvas
self.canvas = inputPorts[0]
if self.canvas is None:
self.canvas = vcs.init()
self.canvas.clear()
# Place the mainwindow that the plot will be displayed in, into this
# cell widget's layout
self.window = VCSQtManager.window(self.windowIndex)
layout = QtGui.QVBoxLayout()
layout.addWidget(self.window)
self.setLayout(layout)
# Plot
if len(inputPorts) > 2:
args = inputPorts[1]
kwargs = inputPorts[2]
self.canvas.plot(*args, **kwargs)
spreadsheetWindow.setUpdatesEnabled(True)
开发者ID:cjh1,项目名称:VisTrails,代码行数:25,代码来源:cdat_cell.py
示例6: execute
def execute(self):
import cdms2, vcs
cdms2.setNetcdfShuffleFlag(0)
cdms2.setNetcdfDeflateFlag(0)
cdms2.setNetcdfDeflateLevelFlag(0)
start_time = time.time()
dataIn=self.loadData()[0]
location = self.loadDomain()
cdms2keyargs = self.domain2cdms(location)
url = dataIn["url"]
id = dataIn["id"]
var_cache_id = ":".join( [url,id] )
dataset = self.loadFileFromURL( url )
logging.debug( " $$$ Data Request: '%s', '%s' ", var_cache_id, str( cdms2keyargs ) )
variable = dataset[ id ]
read_start_time = time.time()
result_variable = variable(**cdms2keyargs)
result_data = result_variable.squeeze()[...]
time_axis = result_variable.getTime()
read_end_time = time.time()
x = vcs.init()
bf = x.createboxfill('new')
x.plot( result_data, bf, 'default', variable=result_variable, bg=1 )
x.gif( OutputPath + '/plot.gif' )
result_obj = {}
result_obj['url'] = OutputDir + '/plot.gif'
result_json = json.dumps( result_obj )
self.result.setValue( result_json )
final_end_time = time.time()
logging.debug( " $$$ Execution time: %f (with init: %f) sec", (final_end_time-start_time), (final_end_time-self.init_time) )
开发者ID:geoslegend,项目名称:esgf-compute-wps,代码行数:34,代码来源:vcsplot.py
示例7: manageCanvas
def manageCanvas(self, showing):
if showing and self.canvas is None:
self.canvas = vcs.init(backend=self.mRenWin)
self.canvas.open()
if not showing and self.canvas is not None:
self.canvas.onClosing((0, 0))
self.canvas = None
开发者ID:rexissimus,项目名称:cdatgui,代码行数:7,代码来源:vtk_classes.py
示例8: plot_template
def plot_template():
tmpl = json.loads(request.args["tmpl"])
t = templ_from_json(tmpl)
canvas = vcs.init(bg=True)
g = vcs.createboxfill()
g.xmtics1 = {.5 * i: "" for i in range(1,20,2)}
g.xmtics2 = g.xmtics1
g.ymtics1 = g.xmtics1
g.ymtics2 = g.xmtics1
ticlabels = {i: str(i) for i in range(10)}
g.xticlabels1 = ticlabels
g.yticlabels1 = ticlabels
g.yticlabels2 = ticlabels
g.xticlabels2 = ticlabels
v = [[0] * 10] * 10
v = cdms2.tvariable.TransientVariable(v)
t.plot(canvas, v, g)
if t.legend.priority:
t.drawColorBar([(0,0,0,0)], [0, 1], x=canvas)
_, tmp = tempfile.mkstemp(suffix=".png")
# For certain templates the renWin can be None
if(canvas.backend.renWin):
# Only call render if renWin exists
canvas.backend.renWin.Render()
canvas.png(tmp)
# create response from the tmp file, blank or otherwise
resp = send_file(tmp)
# Clean up file automatically after request
wr = weakref.ref(resp, lambda x: os.remove(tmp))
canvas.close()
# clean up temporary boxfill and template we created
del vcs.elements["boxfill"][g.name]
del vcs.elements["template"][t.name]
return resp
开发者ID:UV-CDAT,项目名称:vcdat,代码行数:35,代码来源:app.py
示例9: animation
def animation(self):
import vcs,cdms,tempfile,os
canvas=vcs.init() # Construct VCS object to generate image
# Get subset of data
cdms.setAutoReshapeMode('on')
if (len(self.var.shape) == 4):
a = self.var[0:12,0]
elif (len(self.var.shape) == 3):
a = self.var[0:12]
else:
a = None
cdms.setAutoReshapeMode('off')
# Create image in background
if (a != None):
gif_file = tempfile.mktemp() # Generate temporary file to store GIF image
for i in range(a.shape[0]):
canvas.plot(a[i],'default','isofill',variable=self.var,bg=1) # Generate VCS isofill image
gif_name = canvas.gif(gif_file) # Generate temporary GIF image
canvas.clear() # Clear the VCS Canvas for next image
f=open(gif_name,'rb') # Open temporary GIF image
s=f.read() # Read temporary GIF image
f.close() # Close GIF image
os.remove(gif_name) # Remove temporary GIF image,
else:
s=None
return s # Return GIF image string
开发者ID:MartinDix,项目名称:cdat_lite_test,代码行数:32,代码来源:cdms_templates.py
示例10: convert_to_working_copy
def convert_to_working_copy(sb, folder_to_publish, options):
vprint('Converting %s to working copy.' % folder_to_publish, verbosity=1)
use_master = False
branch = '%s%s/%s/built.%s' % (options.repo, sb.get_branch(), sb.get_top_component(), #fix_julie repo structure knowledge
sb.get_targeted_platform_variant())
if bzr_node_needs_creating(branch, 'version-info', 'branch-nick:'):
err = vcs.init(branch)
if err:
return err
use_master = True
tmpfldr = sb.get_built_root() + '.' + sb.get_top_component() + '~tmp~'
wr = vcs.get_working_repository()
err = wr.create_or_update_checkout(tmpfldr, sb.get_top_component(),
'built.%s' % sb.get_targeted_platform_variant(),
sb.get_branch(), revision=None,
use_master=use_master)
if err:
return err
try:
for x in [x for x in os.listdir(tmpfldr) if x.startswith('.bzr')]:
dest = os.path.join(folder_to_publish, x)
if os.path.exists(dest):
if os.path.isfile(dest):
os.remove(dest)
else:
vprint('Error: %s already exists.' % dest)
return 1
src = os.path.join(tmpfldr, x)
os.rename(src, dest)
finally:
shutil.rmtree(tmpfldr)
return 0
开发者ID:perfectsearch,项目名称:sandman,代码行数:32,代码来源:publish.py
示例11: plot
def plot(self):
"""Plot self using first time and level only."""
import vcs, cdms, VCSRegion
canvas=vcs.init() # Construct VCS object to generate image
cdms.setAutoReshapeMode('off')
a, keyargs = VCSRegion.getRegion(self.var, time=None, level=None, other=None)
apply(canvas.plot, (a, 'default', 'isofill'), keyargs) # Generate VCS isofill image
return gifiate(canvas) # Return GIF image string
开发者ID:MartinDix,项目名称:cdat_lite_test,代码行数:8,代码来源:cdms_templates.py
示例12: init
def init(*args, **kwargs):
testingDir = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(testingDir)
if ((('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs))):
vcsinst = vcs.init(*args, **dict(kwargs, bg=1))
if ('geometry' not in kwargs):
vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
else:
xy = kwargs['geometry']
vcsinst.setbgoutputdimensions(xy[0], xy[1], units="pixels")
else:
vcsinst = vcs.init(*args, **dict(kwargs, bg=0))
vcsinst.setantialiasing(0)
vcsinst.drawlogooff()
return vcsinst
开发者ID:UV-CDAT,项目名称:uvcdat,代码行数:17,代码来源:regression.py
示例13: simpleanimation
def simpleanimation():
import vcs, cdms2, sys
x = vcs.init()
f = cdms2.open(vcs.prefix+"/sample_data/clt.nc")
v = f["clt"]
dv3d = vcs.get3d_scalar()
x.plot( v, dv3d )
x.interact()
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:8,代码来源:clt_test_demo.py
示例14: preloadModules
def preloadModules(self):
self.splash.showMessage("Loading VCS")
import vcs
x = vcs.init()
x.close()
x = None
self.splash.showMessage("Loading CDMS2")
import cdms2
self.ready()
开发者ID:sampsonbryce,项目名称:cdatgui,代码行数:9,代码来源:application.py
示例15: doPlotPS2D
def doPlotPS2D(rawOrAnomaly, filteredOrNot, year,
seasons=['sum', 'win', 'all'], pdf=0, png=1):
"""
Written By : Arulalan.T
Date : 22.07.2013
"""
v = vcs.init()
if isinstance(year, int):
yearDir = str(year)
elif isinstance(year, tuple):
yearDir = str(year[0]) + '_' + str(year[1])
inpath = os.path.join(processfilesPath, 'Level1', 'WaveNumber',
rawOrAnomaly, filteredOrNot, yearDir)
for subName in os.listdir(inpath):
anopath = os.path.join(inpath, subName)
opath = os.path.join(plotsgraphsPath, 'Level1', 'PowerSpectrum2D',
rawOrAnomaly, filteredOrNot, yearDir)
for seasonName in os.listdir(anopath):
wvpath = os.path.join(anopath, seasonName)
for wavefile in os.listdir(wvpath):
varName = wavefile.split('.')[0].split('_')[0]
wvfile = os.path.join(wvpath, wavefile)
outpath = os.path.join(opath, subName, varName, seasonName)
if not os.path.isdir(outpath):
os.makedirs(outpath)
print "Path has created ", outpath
# end of if not os.path.isdir(outpath):
title = 'Equatorial Space Time Spectra - %s %s %s %s %s' % (varName.upper(),
seasonName, subName, yearDir, filteredOrNot)
outfile = '%s_%s_%s_%s_%s_%s_ps2d' % (varName, seasonName, subName,
yearDir, filteredOrNot, rawOrAnomaly)
imgpath = os.path.join(outpath, outfile)
if pdf:
imgpath_ext = imgpath + '.pdf'
else:
imgpath_ext = imgpath + '.png'
# end of if pdf:
if os.path.isfile(imgpath_ext):
print "The image file already exists in the path ", imgpath
print "So skipping summerVariance"
else:
f = cdms2.open(wvfile)
data = f(varName) # latitude=(0,8),longitude=(-0.05,0.05))
# options to extract needed portion # wavenumber=(0,8), frequency=(-0.05,0.05))
f.close()
plotPowerSpectrum2D(data, imgpath, seasonName, title, pdf=pdf, png=png, x=v)
print "Plotted power spectrum 2d", imgpath
# make memory free
del data
开发者ID:arulalant,项目名称:mmDiagnosis,代码行数:57,代码来源:plot_ps_2d.py
示例16: initialize
def initialize(self):
print "initialize"
global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor
# Bring used components
self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
self.registerVtkWebProtocol(protocols.vtkWebViewPort())
self.registerVtkWebProtocol(protocols.vtkWebViewPortImageDelivery())
self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())
self.registerVtkWebProtocol(protocols.vtkWebFileBrowser('.', '.'))
# Create default pipeline (Only once for all the session)
# Update authentication key to use
self.updateSecret(_WebCone.authKey)
if not _WebCone.view:
# # VTK specific code
# renderer = vtk.vtkRenderer()
# renderWindow = vtk.vtkRenderWindow()
# renderWindow.AddRenderer(renderer)
# renderWindowInteractor = vtk.vtkRenderWindowInteractor()
# renderWindowInteractor.SetRenderWindow(renderWindow)
# renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
# cone = vtk.vtkConeSource()
# mapper = vtk.vtkPolyDataMapper()
# actor = vtk.vtkActor()
# mapper.SetInputConnection(cone.GetOutputPort())
# actor.SetMapper(mapper)
# renderer.AddActor(actor)
# renderer.ResetCamera()
# renderWindow.Render()
# VCS specific code
import vcs, cdms2, sys
x = vcs.init(bg=1)
f = cdms2.open( vcs.sample_data+"/geos5-sample.nc" )
v = f["uwnd"]
dv3d = vcs.get3d_scalar()
dv3d.ToggleClipping = ( 40, 360, -28, 90 )
dv3d.YSlider = ( 0.0, vcs.off)
dv3d.XSlider = ( 180.0, vcs.on )
dv3d.ZSlider = ( 0.0, vcs.on )
dv3d.ToggleVolumePlot = vcs.on
dv3d.ToggleSurfacePlot = vcs.on
dv3d.IsosurfaceValue = 31.0
dv3d.ScaleOpacity = [0.0, 1.0]
dv3d.BasemapOpacity = 0.5
dv3d.Camera={ 'Position': (-161, -171, 279),
'ViewUp': (.29, 0.67, 0.68),
'FocalPoint': (146.7, 8.5, -28.6) }
dv3d.VerticalScaling = 5.0
dv3d.ScaleColormap = [ -46.0, 48.0 ]
dv3d.ScaleTransferFunction = [ 12.0, 77.0 ]
x.plot( v, dv3d )
renderWindow = x.backend.renWin
# VTK Web application specific
_WebCone.view = renderWindow
self.getApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)
开发者ID:UV-CDAT,项目名称:vcs-js,代码行数:57,代码来源:vcs_server.py
示例17: doPlotLineCEOF
def doPlotLineCEOF(rawOrAnomaly='Anomaly', filteredOrNot='Filtered',
variables=['olr', 'u850', 'u200'],
seasons=['sum', 'win', 'all'], year=None, **kwarg):
"""
Written By : Arulalan.T
Date : 22.07.2013
"""
x = kwarg.get('x', None)
if x is None:
x = vcs.init()
print "x init"
# end of if x is None:
x.clear()
x.portrait()
if __vcsSlow__:
x.pause_time = 1
if isinstance(year, int):
yearDir = str(year)
elif isinstance(year, tuple):
yearDir = str(year[0]) + '_' + str(year[1])
inpath = os.path.join(processfilesPath, 'Level2', 'Ceof',
rawOrAnomaly, filteredOrNot, yearDir)
opath = os.path.join(plotsgraphsPath, 'Level2', 'Ceof',
rawOrAnomaly, filteredOrNot, yearDir)
for subName in os.listdir(inpath):
anopath = os.path.join(inpath, subName)
for season in os.listdir(anopath):
sea = season.lower()[:3]
if not sea in seasons:
print "Though '%s' Season is available, skipping it without \
plotting because in the arg seasons list it is not available.\
So enable it by passing this '%s' season to seasons list " % \
(season, sea)
continue
# end of if not sea in seasons:
ceofncpath = os.path.join(anopath, season)
outpath = os.path.join(opath, subName, season)
if not os.path.isdir(outpath):
os.makedirs(outpath)
print "The path has created ", outpath
# end of if not os.path.isdir(outpath):
infile = 'ceof_vars_%s_%s_%s_%s_%s.nc' % (season, yearDir,
rawOrAnomaly, filteredOrNot, subName)
file_input = os.path.join(ceofncpath, infile)
endname = [yearDir, rawOrAnomaly, filteredOrNot, subName]
plotfile_endname = '_'.join(endname)
plotttitle_endname = ' '.join(endname)
plotLineCEOF(file_input, outpath, variables, season=sea,
ofileEndName=plotfile_endname,
titleEndName=plotttitle_endname, pdf=1, x=x)
开发者ID:arulalant,项目名称:mmDiagnosis,代码行数:57,代码来源:plot_ceof.py
示例18: simplevector
def simplevector():
import vcs, cdms2, sys
x = vcs.init()
f = cdms2.open(vcs.prefix+"/sample_data/clt.nc")
v = f["v"]
u = f["u"]
dv3d = vcs.get3d_vector()
dv3d.BasemapOpacity = 0.15
x.plot( u, v, dv3d )
x.interact()
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:10,代码来源:clt_test_demo.py
示例19: run_scalar_ctest
def run_scalar_ctest( filename, varname, parms, template = "default" ):
import vcs, cdms2
x = vcs.init()
f = cdms2.open(vcs.sample_data+"/"+filename )
v = f[varname]
dv3d = vcs.get3d_scalar( template )
for item in parms.items():
dv3d.setParameter( item[0], item[1] )
x.plot( v, dv3d )
x.interact()
开发者ID:NESII,项目名称:uvcdat,代码行数:10,代码来源:clt_test_demo.py
示例20: test_save_loaded_script
def test_save_loaded_script(tmpdir):
_ = vcs.init()
dirpath = os.path.dirname(__file__)
load_file = os.path.join(dirpath, "data", "clt_u_v_iso.py")
save_file = tmpdir.join("clt_u_v_iso.py")
loaded = import_script(load_file)
canvases = [vcs.init() for _ in range(loaded.num_canvases)]
canvas_displays = loaded.plot(canvases)
for canvas in canvases:
canvas.close()
plot_managers = []
for display_group in canvas_displays:
pm_group = []
for display in display_group:
pm = PlotManager(mocks.PlotInfo)
# Determine which of the graphics methods created in loaded
gm = vcs.getgraphicsmethod(display.g_type, display.g_name)
pm.graphics_method = closest(gm, loaded.graphics_methods)
pm.template = vcs.gettemplate(display._template_origin)
pm.variables = display.array
pm_group.append(pm)
plot_managers.append(pm_group)
mocks.PlotInfo.canvas.close()
export_script(str(save_file), loaded.variables.values(), plot_managers)
saved = import_script(str(save_file))
assert saved.rows == loaded.rows
assert saved.columns == loaded.columns
assert saved.num_canvases == loaded.num_canvases
assert len(saved.files) == len(loaded.files)
assert saved.files[0].id == loaded.files[0].id
assert len(saved.variables) == len(loaded.variables)
for save_var, load_var in zip(saved.variables.values(), loaded.variables.values()):
assert save_var.id == load_var.id
assert len(saved.graphics_methods) == len(loaded.graphics_methods)
assert len(saved.templates) == len(loaded.templates)
开发者ID:sampsonbryce,项目名称:cdatgui,代码行数:43,代码来源:test_save_load.py
注:本文中的vcs.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论