import os setOffScreen(1) homeDir=os.path.expanduser('~') outFileName='/Users/joleenf/size1080by1920GOES_B1_HD_G15_HURR' labelColor='white' labelBackground='black' cTable='Gray Scale' userKeywords = dict( accounting=('JMF','9801'), dataset='AGOES15', descriptor='NH', server='geoarc01.ssec.wisc.edu', day=2011326, location=(13.0,-114.0), place=Places.CENTER, size=(1080,1920), mag=(2,1), position=30, band=1, unit='BRIT', debug=True, coordinateSystem=CoordinateSystems.LATLON, ) import re """ All text within these triple quotes are comments command line options have been removed. Use this script as a template and use sed, awk or whatever works to insert necessary parameters. create a look up table of different desired keywords (parameters) for getting the ADDE request. Below is an example of the necessary parameters userKeywords = dict( accounting=('JMF','9801'), dataset="EASTS", descriptor="CONUS", server="easts.ssec.wisc.edu", location=(44.0,-90.0), place=Places.CENTER, size=(1000,1000), mag=(1,1), position=30, band=2, unit='BRIT', debug=True, coordinateSystem=CoordinateSystems.LATLON, ) """ ############## Trap errors and assign variables that are expected ################### # try to get the size from the userKeywords, if not defined, set a default try: lin_size = userKeywords['size'][0] except NameError: lin_size = 600 try: ele_size = userKeywords['size'][1] except NameError: ele_size = 800 # check to make sure the color for the label and background has been set try: labelColor except NameError: labelColor = 'black' try: labelBackground except NameError: labelBackground='white' # check on scale factor try: scaleFactor except NameError: scaleFactor = 1.0 # Check min and max for data range try: dataMin except NameError: dataMin = None try: dataMax except NameError: dataMax = None # Set Projection? try: proj except NameError: proj = None # color table try: cTable except NameError: cTable="Inverse Gray Scale" try: outFileName except NameError: outFileName=homeDir+"/test" ############ End Trap errors and assign variables that are expected ################# print "The frame size will be "+str(lin_size)+"X"+str(ele_size) # --- request via ADDE data based on each dictionary - dictionary referenced using **(dictionary variable) # areaMetaData,navigatedImage=getADDEImage(**userKeywords) # only run the next block of code if no errors were encountered when trying to get the data. if navigatedImage != -1: #### GET LABELS #### #### call areaLabel to get the date/time which will be used as a label underneath the color bar. outLabel, colorBarLabel=areaFrmLabel(areaMetaData,form=["(jday)","_","(time)","UTC"]) #### call again to get a slightly different format for the image label extraLabel, colorBarLabel=areaFrmLabel(areaMetaData,form=["(sensor)","(Band","(band)","rmNBSP",")","(mdy)","(hhmmss)","UTC"]) areaDate, areaTime = outLabel.split("_") strDate=("%s%s" % (areaDate,areaTime)) # replace all spaces in string fullDate=re.sub(r'\s','',strDate) #### DISPLAY THE IMAGE ### err, num_ticks, interval, tickLabel=imgDisp2(myDisplayObj=navigatedImage, cTable=cTable, projection=proj,wsize=(lin_size,ele_size),spacing=(None,None),scale=scaleFactor,band=userKeywords['band'],dataMin=dataMin, dataMax=dataMax,layerLabel=extraLabel) #### SAVE THE IMAGE #### writeImage(outFileName+fullDate+".jpg",\ "matte background="+labelColor+" top=80;matte background="+labelBackground+" bottom=40;\ colorbar width=300 height=20 anchor=UM place=UM,0,20 showlines=true tickmarks="+num_ticks+" values="+tickLabel[:-1]+" showunit=true interval="+str(interval)+";\ overlay text="+extraLabel+" place=LM,0,-20 anchor=LM color="+labelColor+" fontsize=20 fontface=Arial;\ overlay text="+colorBarLabel+" anchor=UM place=UM,0,60 color="+labelBackground+" fontsize=12 fontface=Arial") print "File written to ", outFileName+fullDate+".jpg" else: print 'ADDE image request failed'