本文整理汇总了Python中vcs.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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)
示例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)
示例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) )
示例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
示例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
示例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
示例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
示例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
示例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
示例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()
示例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()
示例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