using local iamges as variables in functions

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
Tommy_A.
Posts: 6
Joined: Thu Oct 10, 2013 5:26 pm

using local iamges as variables in functions

Post by Tommy_A. »

Hello !

I'm trying to do basic scripting with local GOES-12 / 13 Images, AREA format (from NOAA's CLASS catalogue), like band math (conversion, index creation, etc ...) .
When I use an image as a variable in a function, I get the message "selected image(s) not available" (I'm using VIS channel 8-bit images) .

What could be possibly wrong ?

thanks in advance ...
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: using local iamges as variables in functions

Post by jayh »

Hi Tommy_A.

There probably are a variety of things that may be happening. Perhaps the images aren't being read in correctly, etc. If you'd like to post your script or snippet of the script that does the reading, subtraction, etc. we can try to give some pointers.

I modified the formula.py script found in our scripting tutorial to simply subtract band 4 and 2 from a GOES13 area file included in the scripting data. Hopefully this example that makes a local adde dataset will help you:

Code: Select all

myUser='jayh'

#
#     Windows XP
#
#fileDir=('C:\\Documents and Settings\\'+myUser+'\\McIDAS-V\\')
#dataPath=('C:\\Documents and Settings\\'+myUser+'\\Data\\Scripting\\classify-areas')

#
#     Windows 7
#
#fileDir=('C:\\Users\\'+myUser+'\\McIDAS-V\\')
#dataPath=('C:\\Users\\'+myUser+'\\Data\\Scripting\\classify-areas')


#     Unix
#
#fileDir=('/home/'+myUser+'/McIDAS-V/')
#dataPath=('/home/'+myUser+'/Data/Scripting/classify-areas')

#
#     OSX
fileDir=('/Users/'+myUser+'/Documents/McIDAS-V/')
dataPath=('/Users/'+myUser+'/Downloads/Scripting/classify-areas')

#
#     Define a local ADDE dataset
#
localData=makeLocalADDEEntry(dataset='FOG', imageType='GOES13', mask=dataPath, format='McIDAS Area', save=True)


#
#     Define date and time
#
day='2011038'
time='18:15'

#
#     Define an ADDE request
#
ADDE_Request = dict(
    localEntry=localData,
    day=day,
    time=(time,time),
    size='ALL'
)

#
#     Request data for each band using getADDEImage
#
NearIRMetaData,NearIRData=getADDEImage(band=2, unit='TEMP', **ADDE_Request)
IRMetaData,IRData=getADDEImage(band=4, unit='TEMP', **ADDE_Request)

#
#     Subtract band 4 from band 2 and subtract band 6 from band 4
#
NIRsubIR=sub(NearIRData,IRData)

#
#     Build a window
#
panel=buildWindow(height=800,width=800,panelTypes=MAP)

#
#     Create a layer of each band and subtraction
#
NIRLayer = panel[0].createLayer('Image Display',NearIRData)
NIRLayer.setLayerLabel(label=IRMetaData['sensor-type'] + ' 3.9 micron Temperature ')
NIRLayer.setEnhancement('Gray Scale',range=(320,163))

IRLayer = panel[0].createLayer('Image Display',IRData)
IRLayer.setLayerLabel(label=IRMetaData['sensor-type'] + ' 11.0 micron Temperature ')
IRLayer.setEnhancement('Gray Scale',range=(320,163))

NIRsubIRLayer = panel[0].createLayer('Image Display',NIRsubIR)
NIRsubIRLayer.setLayerLabel(label=IRMetaData['sensor-type'] + ' 3.9 micron - 11.0 micron Temperature Difference')
NIRsubIRLayer.setEnhancement('Gray Scale',range=(-60,60))


panel[0].setProjection('US>CONUS')
panel[0].setCenter(43,-95.5,1.75)
panel[0].setWireframe(False)


You should be able to add a writeImage or writeMovie line at the end of the script depending on what type of output you are interested in.

Let us know if you have any further questions.

Thanks, Jay
User avatar
Tommy_A.
Posts: 6
Joined: Thu Oct 10, 2013 5:26 pm

Re: using local iamges as variables in functions

Post by Tommy_A. »

Thanks for the response . I'll try the formula you proided ...

Here is the code I'm using :

Code: Select all

def conversion10b(CN8) :
   m = 0.6118208
   k = 0.00189544
   b = (-m) * 29
   ((((CN8/255)**2)/k)-b)/0.6118208


It's a "reverse step" from a conversion formula by Mr Don Hillger, from NOAA, available here : http://rammb.cira.colostate.edu/researc ... 0_to_8.asp
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: using local iamges as variables in functions

Post by bobc »

Hi Tommy_A -

Assuming you are doing this through a script, have you set up a local ADDE dataset for your AREA files? This can be done either through the GUI (Tools>Manage ADDE Datasets) or through scripting with makeLocalADDEEntry(). Note that Jay's last response includes a script that uses makeLocalADDEEntry(). For more information about setting up a local dataset through the GUI, see the Local ADDE Data Manager page of the User's Guide.

Once you have this dataset made, are you able to go through the GUI to display your data through the local dataset? In the Satellite>Imagery chooser of the Data Explorer, select <LOCAL-DATA> for server, and your dataset and image type for your GOES 10/12 AREA files. Add this data, and select a field to display in the Field Selector. Are you able to display the data?

Here is a sample script that I have that creates a local ADDE dataset (makeLocalADDEEntry), gets the descriptor for the local ADDE Entry (getLocalADDEEntry), and gets the data and metadata from the server (getADDEImage). I made a slight modification to your conversion10b function so it returns the output of the formula, which I have defined as 'conv'. If you want more information about these functions, please see the Scripting page in the User's Guide. If you change the dataPath variable in the script below to point to your AREA files, you can test this script in the Jython Shell via Tools>Formulas>Jython Shell.

Code: Select all

def conversion10b(CN8) :
    m = 0.6118208
    k = 0.00189544
    b = (-m) * 29
    conv=((((CN8/255)**2)/k)-b)/0.6118208
    return conv

dataPath = 'V:\Data\AREA'
makeLocalADDEEntry(dataset='AREA3', save=True, format="McIDAS Area",
    mask=dataPath, imageType='AREA files')

desc=getLocalADDEEntry(dataset='AREA3',imageType='AREA files')

adde_parms_local = dict(
    debug=True,
    server='localhost',
    dataset='AREA',
    size='ALL',
    localEntry=desc,
    mag=(1, 1),
    unit='BRIT',
    band=1,
)

metadata,data = getADDEImage(descriptor=desc,**adde_parms_local)
CN8=data
conversionData=conversion10b(CN8)
panel=buildWindow(height=800,width=800)
conversionLayer=panel[0].createLayer('Image Display',conversionData)

Please let us know how this testing goes and let us know if you run across any problems.

Thanks -
Bob and Jay
User avatar
Tommy_A.
Posts: 6
Joined: Thu Oct 10, 2013 5:26 pm

Re: using local iamges as variables in functions

Post by Tommy_A. »

Thanks Bob & Jay for the scripts .

I tried Bob's script with small changes, and it worked . I could display a "pseudo 10 bits" data .
Sometimes I get the problem with the long load time (see : viewtopic.php?f=14&t=1333), but I can work my way out ...

It may be off-topic, but there is no way to read raw GOES McIDAS AREA 10 bit data ? I could try with an image or 2 ...
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: using local iamges as variables in functions

Post by bobc »

Hi Tommy_A -

I'm glad that you have a script that is working to display your "pseudo 10 bits" data.

As far as your raw GOES McIDAS AREA 10 bit data, I don't have any of that myself to do testing with. Could you put a sample file on our anonymous ftp server?

ftp ftp.ssec.wisc.edu
anonymous (for the user name)
your_email_address (for the password)
cd pub/incoming
bin
put file_name


Please let us know when you post the file and let us know the file's name so we can take a look.

Thanks -
Bob
User avatar
Tommy_A.
Posts: 6
Joined: Thu Oct 10, 2013 5:26 pm

Re: using local iamges as variables in functions

Post by Tommy_A. »

Hi ! Sorry for taking so long to post a reply ...

I just sent some McIDAS RAW files (10 bits) so you can take a look :
-goes12.2010.001.151514
-goes12.2010.001.154514
-2 ".indx" files, each one associated with an image file
-2 ".meta" files, each one associated with an image file
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: using local iamges as variables in functions

Post by bobc »

Hi Tommy_A -

Working with this raw GVAR data is not currently possible in McIDAS-V. There aren't any GVAR servers in McIDAS-V at the moment. I have written up Inquiry #1652 to cover adding this functionality.

http://mcidas.ssec.wisc.edu/inquiry-v/?inquiry=1652

Thanks -
Bob
Post Reply