Help with script to create/display SEVIRI RGBcomposite Image

New McIDAS-V features under development. Feedback is appreciated.
User avatar
CraigM
Posts: 11
Joined: Wed Aug 15, 2012 7:22 am

Help with script to create/display SEVIRI RGBcomposite Image

Post by CraigM »

Hi,

I am presently at Jython101 level with the script programming, but I have managed to obtain a sample script and with some minor modification, can display and create normal satellite images - step 1.

The next task is to automate the process of creating enhanced images using the 'SEVIRI RGB' formula set. My question is related to the correct format/syntax to call the functions "def NCMP" and "def VOLC" within a script. I have searched the Web and your forums extensively, but have not found a solution and method.

The script (below) that I am using for calling the regular satellite imagery includes with my interpretation in adding the "def NCMP" function. Any assistance and guidance in getting this or another script together to allow me to generate these images would be most appreciated.

Regards Craig

from visad import *
from visad.python.JPythonMethods import *
import sys
sys.add_extdir(".")
sys.add_package('visad.data.mcidas')
#
imageDir=('C:\\temp\\')
#
# Create a dictionary for requesting images
#
parms = dict(
debug=True,
server='localhost:8112',
dataset='MYDATA',
descriptor='8B363563',
coordinateSystem=LATLON,
location=(-25,135),
mag=(1,1),
time=('02:32','02:32'),
day=('2012201,2012201'),
size=(1500, 2200)
)
#
ir109Metadata,ir109Data=getADDEImage(band=2,unit='TEMP',**parms)
ir39Metadata,ir39Data=getADDEImage(band=5,unit='TEMP',**parms)
ir120Metadata,ir120Data=getADDEImage(band=3,unit='TEMP',**parms)
#
# Night cloud microphysics
# units: K
# R: 10-09 -4K..2K
# G: 09-04 0K..10K
# B: 10 243K..293K
#
def NCMP_RGB(ch04,ch09,ch10):
red = rescale(ch10-ch09,-4,2,0,255)
grn = rescale(ch09-ch04,0,10,0,255)
blu = rescale(ch09,243,293,0,255)
return combineRGB(red,grn,blu)
#
productData=NCMP_RGB(ir39Data,ir109Data,ir120Data)
#
# Build a window
#
panel = buildWindow(height=800,width=1500)
#
# Create a layer from the infrared data object
#
ir_layer = panel[0].createLayer('Image Display', productData)
#ir_layer = panel[0].createLayer('Image Display', combineRGB) - ***trying various calling options***
#
panel[0].setProjection('Australia')
panel[0].setWireframe(False)
panel[0].setCenter(-25,135,scale=1.0)
ir_layer.setLayerLabel(label='RGB Fog Enhancement', size=14)
panel[0].captureImage(imageDir+'Fog_RGB.jpg')
User avatar
hproe
Posts: 503
Joined: Sat Nov 27, 2010 3:46 pm

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by hproe »

Hi Craig -

I recommend to install the miscallenaous plugin "RGB-Eumetsat". Then things are quite straightforward. Here a snippet from my script that creates and displays a Dust RGB with data from a remote ADDE server:

mIR87,IR87=getADDEImage(band=7,**ADDE_params)
mIR108,IR108=getADDEImage(band=9,**ADDE_params)
mIR120,IR120=getADDEImage(band=10,**ADDE_params)
DUST=DUST_RGB(IR87,IR108,IR120)
panel=buildWindow(720,560)
imLayer=panel[0].createLayer('3 Color (RGB) Image',DUST)

br, HP
User avatar
CraigM
Posts: 11
Joined: Wed Aug 15, 2012 7:22 am

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by CraigM »

hproe,

thank you for providing the answer I needed. After a little tweaking and following your example, my script is doing what I wanted it to do. I will next time save myself some wasted nights and endless searching and seek assistance from this forum a little earlier.
One area that had me stumped was the createLayer funtion - nowhere did I come across any mention of '3 Color (RGB) Image'. And I now know the logic behind the DUST_RGB call function.

Again many thanks
Craig
User avatar
mhiley
Posts: 90
Joined: Mon Jan 23, 2012 10:22 pm

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by mhiley »

CraigM wrote:One area that had me stumped was the createLayer funtion - nowhere did I come across any mention of '3 Color (RGB) Image'.

Hi Craig,

createLayer can create any of the display types listed in the Field Selector tab of the Data Explorer window (look in the upper-right list labeled "Displays"). The string passed to createLayer can be any of the strings shown in this part of the GUI. So "3 Color (RGB) Image", "3 Color (RGB) over topography", "Contour Plan View" are all examples of valid arguments to createLayer.

Hopefully that clarifies things - let me know if it only confused you more!

Mike
User avatar
CraigM
Posts: 11
Joined: Wed Aug 15, 2012 7:22 am

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by CraigM »

mhiley,

no this doesn't confuse things - it made it all the more clearer. I can now see the link between a script and the available functions in the formula listing. Thanks for the explanation and your help.
User avatar
CraigM
Posts: 11
Joined: Wed Aug 15, 2012 7:22 am

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by CraigM »

Just prolonging this thread a little longer......
Another question I have is with regards to adding a map layer to a script. My current list of commands to create an image is below.
What I wish to do now is remove the default coastal outline map that is generated automatically and replace with a higher resolution map that I have created and is stored within a local folder. There is a second map layer I would also like to add on top again, a map of aerodromes with the option to alter the color and line widths.
Once again, I have not been able to find any commands relating to map overlays.

Any assistance would again be very much appreciated........Craig

# Build a window
#
panel = buildWindow(height=2000,width=2200)
#
# Create a layer from the infrared data object
#
ir_layer = panel[0].createLayer('3 Color (RGB) Image', productData)
#
panel[0].setProjection('Australia')
panel[0].setWireframe(False)
panel[0].setCenter(-25,135,scale=2.0)
ir_layer.setLayerLabel(label='RGB Fog Enhancement', size=14)
panel[0].captureImage(imageDir+'Fog_RGB.jpg')
User avatar
mhiley
Posts: 90
Joined: Mon Jan 23, 2012 10:22 pm

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by mhiley »

We are working on developing better ways of dealing with map layers via scripting for the next version of McV, but for now, here is some code to hopefully get you started:

Code: Select all

panel = buildWindow()

# Default maps are usually on the first layer, so make that layer invisible.
panel[0].getLayer(0).setLayerVisible(False)

# Make a data source for your map file.  Second arg represents type of
# data source you want to make...probably "Shapefile"
map_source = createDataSource(
    '/Users/mhiley/Desktop/auxdata/maps/OUTLCNTY', 'Shapefile')

# Now add map to display by creating a new map layer using the data
# source we just created.
map_layer = _mcv.doMakeControl(
    'shapefilecontrol', map_source.getDataChoices()[0])

# Now you could set various map properties.  Here is line width as an example-
# I can point you toward a more complete list if you want.
map_layer.setLineWidth(2)

Hopefully something similar will work for your particular map file. Feel free to upload it if you have trouble and I'll try tinkering with it.

Good luck!
Mike
User avatar
CraigM
Posts: 11
Joined: Wed Aug 15, 2012 7:22 am

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by CraigM »

Thanks Mike,

once again your help is appreciated. You mentioned a longer list of commands......do you mind pointing me to them.

PS: Your layer command worked fine.

Regards
Craig
User avatar
joleenf
Posts: 1120
Joined: Mon Jan 19, 2009 7:16 pm

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by joleenf »

Is there a way to make an image sequence of RGB's? In training, a loop was made using position numbers and an image sequence display. I tried creating a loop with the following code:

Code: Select all

dataSet = 'AVIATION'
imageType = 'GOES'
timesArray = ['18:32:00', '18:45:00', '19:02:00','19:15:00','19:32:00']

# get a list of local adde server entries
desc = None
localEntries = _mcv.getServerManager().getLocalEntries().toArray()     
for entry in localEntries:
   if entry.getName() == imageType and entry.getGroup() == dataSet:   
      desc = str(entry.getDescriptor()).upper()
      break

mySampleRGB=[]

if (type(desc).__name__ != 'NoneType'):
   for currTime in timesArray:
      params = dict(
         mag=(1,1),
         size=(600,900),
         location=(31,-84.2),
         place=CENTER,
         coordinateSystem=LATLON,
         time=(currTime,currTime),
      )

      metaData, visALB = getADDEImage(server='localhost:8112',dataset=dataSet, descriptor=desc, unit='ALB', band=1, **params)
   
      metaDataIR2, irBRIT2 = getADDEImage(server='localhost:8112',dataset=dataSet, descriptor=desc, unit='BRIT', band=2, **params)
   
      metaDataIR4, irTEMP4 = getADDEImage(server='localhost:8112',dataset=dataSet, descriptor=desc, unit='TEMP', band=4, **params)
   

      r=visALB
      g=irBRIT2
      b=irTEMP4
      singleRGB = mycombineRGB(r,g,b)

      mySampleRGB.append(singleRGB)

   panels=buildWindow()
   panels[0].createLayer('Image Sequence Display', mySampleRGB)


However, a TypeError is thrown: ucar.unidata.data.DataDataChoice(): 2nd arg can't be coerced to visad.Data. Is this type of sequence possible right now?
User avatar
jayh
Posts: 414
Joined: Thu Jan 15, 2009 10:34 pm

Re: Help with script to create/display SEVIRI RGBcomposite Image

Post by jayh »

Hi Joleen-

I believe this is possible with using NavigatedImage from the visad library to accomplish this. We did this 'challenge' example at the end of our scripting training which created a loop of a formula. Here is the snippet that I think applies to your code above:

Code: Select all

#     Create a dictionary for requesting images
#
desc = getDescriptor('JOPLIN', 'GOES13')
parms = dict(
    debug=True,
    server='localhost:8112',
    dataset='JOPLIN',
    descriptor=desc,
    coordinateSystem=CoordinateSystems.LATLON,
    location=(37.15,-94.5),
    place=Places.CENTER,
    size=(1000, 2000),
)

productLoop=[]

for pos in range(-4,1):
    irMetadata,irData=getADDEImage(position=(pos),band=4,unit='TEMP',**parms)
    wvMetadata,wvData=getADDEImage(position=(pos),band=3,unit='TEMP',**parms)
    productData=sub(wvData,irData)

    productLoop.append(NavigatedImage(productData, wvData.getStartTime(), "wvData minus irData"))

#
#    Build a window
#
productPanel = buildWindow(height=600,width=900)
productLayer = productPanel[0].createLayer('Image Sequence Display',productLoop)




I hope this helps, let us know if you have any further questions.

Thanks, Jay
Post Reply