Jython scripting in McIDAS-V display images in Google Earth

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
kaba
Posts: 51
Joined: Tue Mar 24, 2009 2:52 pm

Jython scripting in McIDAS-V display images in Google Earth

Post by kaba »

Hello Guys,
I thought I should post this in the forum for those interested in looking at Jython scripting in McIDAS-V for displaying images in Google Earth.

My goal was to write a script that reads in Simulated ABI netCDF files, read a particular variable, display the image , add title,, disable the map background,
add a color bar, then save a kmz or kml file for display in Google earth.

Attached is a small gif file showing the output for band01.

If you want to look at the output for all the bands please got to the following link in the ftp server: /ABI/kaba/mcv/kmz


I would also like to thank Joleen, Tom Rink, Tom Whittaker and the whole McIDAS-V team for helping me out with this project.

Here is the script:

setOffScreen(1)
datadir="/Users/kbah/data/input/latlon/"
outdir="/Users/kbah/data/output/latlon/conus/"
aband=["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16"]
freq=["0.47um","0.64um","0.865um","1.378um","1.61um","2.25um","3.90um","6.19um","6.95um","7.34um","8.50um","9.61um","10.35um","11.2um","12.3um","13.3um"]

atime=["1000","1030","1100","1130","1200","1230","1300","1330","1400","1430","1500","1530","1600","1300","1700","1730","1800","1830","1900","1930","2100","2130"]
label="GOES-R SIMULATED ABI JUNE 04 2005"
post_name=".nc"
num_ticks=5

loadBundle('/Users/kbah/data/output/FGF/fromscript/conus/conus.mcvz')

idv.getStateManager().setViewSize(java.awt.Dimension(3000,2000))

import ucar.unidata.util.Range
vms=idv.getVMManager().getViewManagers()
bground=vms.get(0).getControls()
bground[0].setDisplayVisibility(0)
vms.get(0).setUseProjectionFromData(0)
vms.get(0).setWireframe(0)
#vms.get(0).setProjectionByName("CONUS LATLON")

for h in range(0, 1):
pre_name="GRB_scaled_1km_conus_sim_abi_band"+aband[h]+"_2005_0604_"
label2=" BAND "+aband[h]+"["+freq[h]+"] "
if h < 3:
pre_name="GRB_scaled_1km_conus_sim_abi_band"+aband[h]+"_2005_0604_"
else:
pre_name="GRB_scaled_2km_conus_sim_abi_band"+aband[h]+"_2005_0604_"

ctm=idv.getColorTableManager()

if h < 6:
var_name="ABI_scaledint_"+aband[h]
ct=ctm.getColorTable("Square Root Visible Enhancement")
pause()
else:
var_name="ABI_TBB_"+aband[h]
ct=ctm.getColorTable("GOES DPI Composite")
pause()

for i in range(7, 8):
ds = makeDataSource(datadir+'band'+aband[h]+'/'+pre_name+atime[i]+'utc'+post_name,"netcdf.grid")
a = getData(ds.getName(),var_name)

dc = createDisplay('planviewcolor',a)
#dc = createDisplay('imagedisplay',a)
if h < 6:
dc.setRange(ucar.unidata.util.Range(0, 1))
else:
dc.setRange(ucar.unidata.util.Range(330, 190))

mapDisplay=vms[0].getMapDisplay()
mapDisplay.setBackground(java.awt.Color.black)
#vms.getMapDisplay().zoom(2.0)

dc.setDisplayListTemplate("");
dc.setShowInDisplayList(0)
dc.applyPreferences();
dc.setColorTable(ct)

####### Add band name and number
if i==0:
writeImage(outdir+'band'+aband[h]+'/'+pre_name+atime[i]+'utc'".kmz",\
"overlay text="+label+label2+atime[i]+"UTC"+" place=LM,0,-20 anchor=LM color=white fontsize=20 fontface=Arial;\
kmlcolorbar width=300 height=20 showlines=true tickmarks=6 fontsize=12 background=white color=black \
kml.name=Color Bar kml.overlayXY.x=-0.45 kml.overlayXY.y=0.5 kmloverlayXY.xunits=fraction kml.overlayXY.yunits=fraction\
kml.xscreenXY.x=0.5 kml.screenXY.xunits=fraction kml.screenXY.y=0.3 kml.screenXY.yunits=fraction")
pause()
pause()
else:
writeImage(outdir+'band'+aband[h]+'/'+pre_name+atime[i]+'utc'".kmz",\
"overlay text="+label+label2+atime[i]+"UTC"+" place=LM,0,-20 anchor=LM color=white fontsize=20 fontface=Arial")
pause()
pause()
else:
print 'band'+aband[h]+ ' Time='+atime[h]
else:
print "The for loop is over"
Attachments
band01.gif
Post Reply