From: Arlindo da S. <da...@al...> - 2008-05-06 19:21:27
|
On Fri, May 2, 2008 at 3:28 PM, Shun Jie Liu <shu...@li...> wrote: > Hello again. > Meanwhile, can I take alook at whats written for the GrADs/Matlab script ? > > Over the weekend I looked at extending what I had done for Octave to the real Matlab. Alas, the standard popen2() function that Octave (and IDL, perl, Python,...) implements is not available in Matlab. It would be relatively easy to implement it as a Matlab C-extension (mex). However, this would require separate builds for each platform, something I'd like to avoid if all possible. Now the good news. Matlab has a very nice integration with Java and Java integrates nicely with Python (through Jython). With a relatively small piece of Java glue code I was able to implement the basically functionality of the Matlab interface, reusing most of my Python code. Here is I am able to do: % ga = grads('gradsnc -l') % ga.cmd('open model') % ga.cmd('d ts') % ga.cmd('q config') % ver = ga.rword(1,2) % returns 2nd word of 1st line: 1.9.0-rc1 The ga.query() and ga.open() functions will be very easy to add. The next step is to return a GrADS expression as a Matlab array, e.g., % ts = ga.expr('ts - 273') In the other interfaces I have implemented symmetric functions to get data *in* and *out* of GrADS. It will be much easier to implement something to extract data from GrADS like the ga.expr() above, and I might be able to get it working even for v2. Put data back into GrADS would require a bit more effort. A couple of questions for you: 1) Which platform do you usually run Matlab on? 2) How important is it for you to save a Matlab array as a GrADS defined variable? Where do you usually do your plots, in GrADS or in Matlab? Do you have the "Mapping Toolbox" available (this is a separate Matlab product)? 3) By any chance, do you know any Java? Are you familiar with Matlab graphics? With just a bit more effort I shall be able to have the equivalent of the PyGrADS "core" capabilities. As a side effect, I'll have also a Java interface which could be useful down the line. The advanced numerical capabilities (EOFs, least square fits, ...) and the fancy Matplotlib graphics would be easier to implement natively in Matlab in a m-file and I was hoping you could help me out with this. Jennifer: Would a Java-GrADS interface be of any use for GDS? Say, to keep a GrADS session open in association with each active connection. Give me a another week or so and I'll send you a prototype. Cheers! Arlindo -- Arlindo da Silva da...@al... |