From: Arlindo da S. <da...@al...> - 2008-07-02 05:20:47
|
Rodrigo, A quick answer before bedtime. On Wed, Jul 2, 2008 at 12:11 AM, Luiz Rodrigo Tozzi < lui...@gm...> wrote: > Hi Arlindo > > I'm sending to you the first prototype of the PHP interface, for you to > test and see what I did until now. > > I spent some time trying to figure out how PHP deals with the data stream > between grads and the PHP pipe system. I think I'll have to test it more > along with the getError() function. For really basic stuff, its functional. > That sounds great. I'll take a look at it and check it in to the repository. It would be good if you could use the repo for maintaining the PHP interface. Are you familiar with CVS? Also, I'd need your sourceforge userid to give you commit privileges to the repository and to the wiki. > > Just like you suggested in the previous email, I rewrote the functions to > be OO based and I organized it better. Now all of the functions obey the > Echo and Verb-like output flags and most of the functions are able to handle > this output in a raw way or in an array way. > Nice. > > In the this tarball there are two simple examples of how it works. > grads_shaded.php is a step by step script that only opens a nc file, sets > the environment and plots an image. grads_points.php is a php script that > coordinates a series of calls to retrieve variable values from some points > using arrays, loops and other php stuff. this grads_points.php could receive > the points coordinates and names from a MySQL database, get some information > through GrADS and show it in a HTML-like PHP in the server. I already did > that but creating the gs file and submiting into GrADS. Now it can be done > within the PHP script! > One of the advantage of this approach is that you can parse the output of each grads command and handle it appropriately if an error occurs. > > > I'm interested in handling the graphical output of GrADS through GD >>> but I don't know how to do it. I used to deal with GD programming in >>> PHP but i don't know how it works in GrADS. >>> >> >> >> I am not clear exactly what kind of things would you like to do. You can >> always write PNG from GrADS and read it from disk. You could also capture >> the GrADS metafile through the pipe (I'd need to add an simple grads >> extension for that) and then use GD interface to PHP to create the image in >> PHP. (I'd recommend Cairo over GD as it is more capable.) >> > > I noticed that using libipc I can get some slice of data and that's what > I'm about to try now, but I was asking about capturing the GrADS metafile. > In PHP, as in your Python interface, there are powerful tools to handle > graphics, using GD or Cairo. One of those applications is the web based > capability of displaying something you dynamically created. In my > applications I can place a PNG over a satellite image using alpha channels > and transparency, add text with TTF font, with "Portuguese characters" and > use the image area completely, with no blanks in the sides. > > The point is: is it possible to add this grads extension, to handle GrADS > metafile? > Yes, the gxyat extension extracts the metafile instructions and renders it using cairo (from C). The idea is to add a function to IPC that grabs the metafile instructions and writes it to stdout so that the extensions can handle it. In PyGrADS I'd like to render it with Matplotlib on top of a blue marble basemap or a satellite image (the PyGrADS screenshots are plotted exclusively with Matplotlib). Now, gxyat can write SVG which cairo can handle (of course, cairo wrote it) so this could be a viable initial path to get the GrADS vector graphics instructions into PHP. > >> One question: does PHP have any way of efficiently representing numerical >> arrays? >> >> > If you are asking about n dimensional arrays, lists, vectors and things > like these the answer is yes. Its not hard to work with it but I really dont > know if there is a limit to the size of objects or something like it. But > its easy to implement. > Perl and Python also have "arrays" but these are really "lists" and are very inefficient for numerical work. PDL in perl and numpy in Python are extensions for efficient handling of numerical n-dimensional arrays. Does PHP have anything similar? > > I just subscribed to opengrads-devel list and I saw that you are working on > a Matlab interface. Do you know if someone has ever tried to do a "R" (< > http://www.r-project.org/>) interface? I used to work on it and its a very > useful environment. > Funny that you ask. I was looking into R yesterday. However, I found out that I could use R from Python using the Rpy extension. It seems to work well on my Mac. One might be able to develop a native R interface to GrADS but I do not know much about R internals myself, and the python route works me. If you have any interest, go for it. > > By the way, there is something off-topic that I'm curious about: your name > looks like a Portuguese-like name. Are you from Brazil or Portugal? Have you > ever been here in Brazil? There are lots of people from here in the GrADS > user list, specially in CPTEC, where I used to work. You may know José > Pesquero, he is a heavy user from the GrADS list and a friend of mine. > Yes, I am from Niteroi and visited CPTEC many times. I helped them implement PSAS for both regional and global data assimilation. Yes, I know Pesquero for some time. BTW, Pedro invited me for a round table this summer at CBMET, so I might be coming to Sao Paulo in August. Cheers, Arlindo -- Arlindo da Silva da...@al... |