units on captureImage colorbar

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

units on captureImage colorbar

Post by joleenf »

Hi,

I am finding that if I user "interval", the showUnit parameter works, but if I use "values", showUnit is not respected.

Code: Select all

label='Full Disk ({} um)     Conus ({} um)     Meso ({} um)'.format((fd[0]['satband-band-label'].split())[0],
(conus[0]['satband-band-label'].split())[0],(meso[0]['satband-band-label'].split())[0])

formatStuff=[Matte(
                    background='black',
                    top=130,
                    ),
            Colorbar(
                    display=fd_layer,
                    width="700",
                    height="20",
                    orientation="top",
                    values="180,200,220,240,260,280,300,320",
                    #interval="20",
                    fontSize="18",
                    place="UM,0,30",
                    anchor="UM",
                    showUnit="true",
                    showLines="true",
                    lineColor="yellow",
                    color="yellow",
                    ),
            TextOverlay(
                    text=label,
                    place="UM,0,60",
                    anchor="UM",
                    fontSize="24",
                    color="yellow",
                    ),
            TextOverlay(
                    text=str(timestep),
                    place="UM,0,90",
                    anchor="UM",
                    fontSize="24",
                    color="yellow",
                    ),
           
                 ]
panel[0].captureImage(filename=fname, formatting=formatStuff)



Thanks,
Joleen
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: units on captureImage colorbar

Post by bobc »

Hi Joleen -

Thanks for the script. There are known issues with showUnit that are written up as Inquiry 2333. From this inquiry, if you have showUnit set to either "true" or "false" the unit will be plotted for the colorbar regardless of what other parameters are defined. This is what I'm replicating using today's nightly on Windows 7 and OS X, regardless of if I'm using "interval" or "values", having showUnit set to "true" or "false" always plots the unit. The two ways I'm finding to not plot the unit is to not include showUnit at all in the formatting or to use "showUnit=None".

You mentioned that showUnit is working for you if using "interval". Does this mean that setting showUnit "true"/"false" both actually work as expected? Are you running in the foreground from the Jython Shell or from the background? What format are you capturing your images in (e.g. GIF, JPG, ...)?

Thanks -
Bob
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: units on captureImage colorbar

Post by joleenf »

Hi Bob,

I checked this again with the code below and found that I was wrong, the unit is plotting correctly whether or not value or interval is used. What you noted is correct, showUnit="false" does not work as expected. showUnit=None does work.

Joleen

Code: Select all

def test1(fd_layer,windowWidth):
   formatStuff=[Matte(
                       background='black',
                       top=180,
                       ),
               TextOverlay(
                       text='Full Disk Brightness Temperature',
                       place="UM,0,50",
                       anchor="UM",
                       fontSize="24",
                       color="yellow",
                       ),
             
               Colorbar(
                       display=fd_layer,
                       width=str(windowWidth*2/3),
                       height="20",
                       orientation="top",
                       interval="20",
                       fontSize="18",
                       place="UM,0,30",
                       anchor="UM",
                       showUnit="true",
                       showLines="true",
                       lineColor="yellow",
                       color="yellow",
                       ),
                    ]
   panel[0].captureImage('/Users/joleenf/data/test/colorbar_interval_2016Dec22build.jpg', formatting=formatStuff)
   return
def test2(fd_layer,windowWidth):
   formatStuff=[Matte(
                       background='black',
                       top=180,
                       ),
               TextOverlay(
                       text='Full Disk Brightness Temperature',
                       place="UM,0,50",
                       anchor="UM",
                       fontSize="24",
                       color="yellow",
                       ),
             
               Colorbar(
                       display=fd_layer,
                       width=str(windowWidth*2/3),
                       height="20",
                       orientation="top",
                       values="180,200,220,240,260,280,300,320",
                       fontSize="18",
                       place="UM,0,30",
                       anchor="UM",
                       showUnit="true",
                       showLines="true",
                       lineColor="yellow",
                       color="yellow",
                       ),
                    ]
   panel[0].captureImage('/Users/joleenf/data/test/colorbar_values_2016Dec22build.jpg', formatting=formatStuff)
   return
if __name__ == '__main__':
   homeDir=expandpath('~')
   imageDir=os.path.join(homeDir,'data','goesr','images','sectorInSector')
   dataDir=os.path.join(homeDir,'data','goesr','sectors')
       
   fdband=9
   fdColorTable=('WVSCOTT_180to320K',(180,320))
   
   winSize=(600,710)
   
   panel=buildWindow(height=winSize[0], width=winSize[1])
   
   parms=dict(
       field='CMI',
       stride=20
       )
   fd_file=os.path.join(dataDir,'OR_ABI-L2-CMIPF-M3C09_G16_s20170711700030_e20170711710402_c20170711710474.nc')

   fdData=loadGrid(filename=fd_file,**parms)

   fd_layer=panel[0].createLayer('Image Display', fdData)

   fd_layer.setEnhancement(fdColorTable[0],range=fdColorTable[1])
   
   test1(fd_layer,winSize[1])
   test2(fd_layer,winSize[1])
Post Reply