This is the zipped bundle
The Script
Code: Select all
# Set the home directory, this works on my mac, but I am not certain it works on every system
import sys
homeDir=os.getenv("HOME")
print homeDir
# Open the bundle and change the size of the display frame to 640 by 480
loadBundle("/Users/joleenf/mcidas/bundles/2012_02_09.mcvz",None,640,480)
pause()
#---Get the display and use a preset projection
myDisplay=firstDisplay() # get the view managers for the display
myDisplay.setProjectionByName("US>States>West>Oklahoma") # this sets the new Projection
#---end of commands which center the image to user chosen location---
#Save the images (Loop through the time sequences and save each image)
myAnim=myDisplay.getAnimation() # this gets the animation sequence in the bundle
loopTime=myAnim.getTimes() # this returns an array of times in that time sequence
steps=myAnim.getNumSteps() # this is the number of frames in the sequence
#Loop through the frames, save each to a filename of the form afterScript<frameNumber>.jpg
#Use writeImage to add colorbar
for x in range(steps):
fileName=("%s%s%s%s" % (homeDir,"/afterScript",x,".jpg"))
print fileName
strTime=str(loopTime[x])
writeImage(fileName,"matte background=white top=80; colorbar width=200 height=20 anchor=UM place=UM,0,30 showlines=true tickmarks=4 showunit=true;\
overlay text="+strTime+" anchor=UM place=UM,0,50 color=black fontsize=20 fontface=Arial")
myAnim.takeStep()
After running this code, notice the default text for the layer labels is still visible in the frame. This can be removed: obtain control for a layer from a script by adding a unique id for the layer.
1. Under the Layer Controls for each layer, select Edit>Properties
2. Add an id for each layer (see image)
The expanded script gets the layer control by using "findDisplayControl" and turns off the layer label with the method "setShowInDisplay"
Code: Select all
# Get the home directory
import sys
homeDir=os.getenv("HOME")
print homeDir
# Open the bundle and change the size of the display frame to 640 by 480
loadBundle("/Users/joleenf/mcidas/bundles/2012_02_09.mcvz",None,640,480)
pause()
##### New Section #####
# Find the control for the Image Display layer assigned id of G15Layer in the bundle
controlG15Layer=findDisplayControl("G15Layer")
# Remove the layer label
controlG15Layer.setShowInDisplayList(0)
##### End New Section #####
#---Get the display and use a preset projection
myDisplay=firstDisplay() # get the view managers for the display
myDisplay.setProjectionByName("US>States>West>Oklahoma") # this sets the new Projection
#---end of commands which center the image to user chosen location---
#Save the images (Loop through the time sequences and save each image)
myAnim=myDisplay.getAnimation() # this gets the animation sequence in the bundle
loopTime=myAnim.getTimes() # this returns an array of times in that time sequence
steps=myAnim.getNumSteps() # this is the number of frames in the sequence
#Loop through the frames, save each to a filename of the form afterScript<frameNumber>.jpg
#Use writeImage to add colorbar
for x in range(steps):
fileName=("%s%s%s%s" % (homeDir,"/afterScript",x,".jpg"))
print fileName
strTime=str(loopTime[x])
writeImage(fileName,"matte background=white top=80; colorbar width=200 height=20 anchor=UM place=UM,0,15 showlines=true tickmarks=4 showunit=true;\
overlay text="+strTime+" anchor=UM place=UM,0,50 color=black fontsize=20 fontface=Arial")
myAnim.takeStep()