Script to perform Data Probe

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
tbanks
Posts: 4
Joined: Tue Oct 27, 2009 5:17 pm

Script to perform Data Probe

Post by tbanks »

Hi,

I would like to create a script to perform a Data Probe on an image in McIDAS V.

Ideally, when a new image appears in a directory, the script would probe the
image at a specified Lat-Long, and save out the cell value as a .csv file.

I am new to McIDAS and have been exploring the User's Guide.
Any advice will be appreciated.

Thanks,
Todd
User avatar
beckys
Posts: 173
Joined: Wed Jan 07, 2009 7:50 pm

Re: Script to perform Data Probe

Post by beckys »

Hi, Todd -

There is currently no quick and easy way to do this, but one of our programmers did come up with a Jython script that could give you the results you need. Here is his response:


There are two issues:

1. determining when a "new file appears in the directory"
2. obtaining the data value at a given lat/lon

#1 -- have a separate script that looks for a new file -- however that is defined

#2 -- the quickest evaluation for this is to run a Jython script like
this (I've added some extra "print" statements for clarity):

from edu.wisc.ssec.mcidas import AreaFile as af;
import math;
a = af("z:/src/visad/python/AREA0001");
n = a.getNavigation()
print "nav = ",n
pt = n.toLinEle(((43.,),(-89.,))); // lat = 43 lon = -89
print "point = ",pt
d = a.getFloatData();
elem = int(pt[0][0]+.5); // round the coordinates
line = int(pt[1][0]+.5);
print "line=",line," ele=",elem;
print "value = ",d[0][line][elem]; // first band....

And then provide for writing the csv-type file at the end using Python
file writing. The key here is getting this to run with the proper
libraries, so you need something like this (from a McV 32-bit install
on a 64 bit Windows machine), if the above script is named
"area_nav.py":

"C:\Program Files (x86)\McIDAS-V\jre\bin\java.exe" -mx500m
"-Dpython.home=c:\jythontemp" -cp "C:\Program Files
(x86)\McIDAS-V\jython.jar;c:\Program Files (x86)\McIDAS-V\visad.jar"
org.python.util.jython area_nav.py

This could then be run whenever #1 detects a new file (and perhaps
another parameter would have to be supplied to be that file name....).

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

Re: Script to perform Data Probe

Post by joleenf »

The post above which explains how to run the script makes little sense to me. If I am on a mac and am trying to make sure all the libraries run, how do I do this? In addition, is there a way to automate the linking of libraries so that I don't need to type this every time I run a script for McIDAS-V?

Joleen
User avatar
jayh
Posts: 424
Joined: Thu Jan 15, 2009 10:34 pm

Re: Script to perform Data Probe

Post by jayh »

Hi Joleen-

I received the following information on this:

I don't know what the McV install looks like on a Mac or Linux box,
but at the end of the code in Becky's posting is the Windows command
line to start the Java Virtual Machine with a "classpath" set to point
to the visad.jar and jython.jar files(that's the -cp..... stuff). You
need to locate those jar files in the install environment, plus the
path to the "java" command used to normally start McV.



I hope this information helps. Let us know of any further questions.

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

Re: Script to perform Data Probe

Post by joleenf »

Hi,

I spoke with Kaba and he pointed me in the right direction again. First, if I change directories to where my local copy of McIDAS is installed, and type ./runMcV, I can see all the linked paths. Second, if I am in that directory (in my case /Users/joleenf/Applications/McIDAS-V-System), I can type ./runMcV -islfile myscript.py and then my python script runs. This would be true for and isl script as well.

This information is also found here...

http://www.ssec.wisc.edu/mcidas/doc/mcv ... index.html

Joleen
Post Reply