From: Arlindo da S. <da...@al...> - 2008-07-03 02:32:55
|
Luiz, I have added you to the OpenGrADS project on sf.net and also on the OpenGrADS wiki (we do not use the sf.net wiki because it is not MediaWiki, so the wiki account is separate from sf.net). A couple of notes: 1) I have checked in your tarball and created a CVS module that includes our generic test data directory. For checking it out: export CVS_RSH=ssh cvs -z3 -d:ext:lui...@op...:/cvsroot/opengrads co -P gradsPHP* *Unless you have setup your SSH keys this will ask for your sf.net password. For SSH key info check this: http://alexandria.wiki.sourceforge.net/SSH+Key+Generation I strongly recommend you setup your ssh keys for passwordless access to cvs. 2) I have not checked in your shapefiles because I was not sure whether they were freely available; sf.net does not allow check in of proprietary data/software. It must be covered by some form of opensource license. BTW, the model.nc file is under data, you may need to adjust your test script. 3) I have created stubs for the standard files COPYING, README, INSTALL, etc. Please populate these files when you have a chance. Take a look at one of the other packages for examples, e.g., cvs .... co -P pygrads cvs ... co -P gerl 4) You should have received an e-mail with your wiki password. I have created a place holder wiki page for the PHP interface: http://opengrads.org/wiki/index.php?title=PHP_Interface_to_GrADS Edit it as you see fit. This is just a copy of the Perl wiki now. 5) You need to add licensing terms to each source file, and also in the COPYING file. Most of my stuff is under GPL, some under a Perl style license term. See the gerl/pygrads packages for examples. Sourceforge requires an opensource license. I was able to sucessfully run your test scripts on my Mac running Leopard. It ran out of the box! Let me know if you have questions, Arlindo 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. > > 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. > > 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! > > > 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? > > >> 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. > > 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. > > 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. > > Peace! > > -- > > Luiz Rodrigo Lins Tozzi > lui...@gm... > http://thedealwith.blogspot.com/ > > On Wed, Jun 25, 2008 at 9:20 AM, Arlindo da Silva <da...@al...> > wrote: > >> On Tue, Jun 24, 2008 at 11:46 PM, Luiz Rodrigo Tozzi < >> lui...@gm...> wrote: >> >>> Hi Arlindo >>> >>> After reading the Gerl code and using it, I managed to translate the >>> idea from Perl to PHP. >> >> >> This is very nice! You got something already very functional. >> >> >>> PHP is a bit different from Perl because there >>> is no prompt to deal with PHP commands, only the interpreter of the >>> command line or the web based interpreter. >>> >> >> Even in perl, most times I just write a script. >> >> >>> >>> I began to write the PHP interface and now I can open the grads with >>> the -u option, with bidirectional pipe. Some of the most common used >>> commands are implemented. For an example: >>> >> >> [...] >> >> >>> I'm preparing the code to the Echo/Verb style you did in the Gerl and >>> I can send you this first version of the code for you to have a look. >>> >> >> These get really important for debugging. In batch sometimes one wants to >> suppress most output except when something goes wrong. >> >> >>> >>> Is there something I forgot for this first pre-alpha prototype? I'm >>> open for sugestions! >>> >> >> I see that you started with a non-OO prototype. The main advantage of an >> OO interface is that you can instantiate more than one version of GrAS at a >> time. For example when dealing with HDF and OPeNDAP files in v1.9 one end up >> having to start 2 instances (one with gradshdf, another with gradsdods). >> Another advantage of an OO approach is that it makes it easy to extended it >> n different directions, while retaining the core functionality in a base >> class. >> >> >>> >>> 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.) >> >> One question: does PHP have any way of efficiently representing numerical >> arrays? >> >> Again, congratulations! This is very exciting work. I look forward to >> distribut it through opengrads as another interface to GrADS. Perhaps we >> could start checking in to the repository what you already have. >> >> Cheers! >> >> Arlindo >> >> >> ---- original message ---- >> >> Hi Arlindo >> >> After reading the Gerl code and using it, I managed to translate the >> idea from Perl to PHP. PHP is a bit different from Perl because there >> is no prompt to deal with PHP commands, only the interpreter of the >> command line or the web based interpreter. >> >> I began to write the PHP interface and now I can open the grads with >> the -u option, with bidirectional pipe. Some of the most common used >> commands are implemented. For an example: >> >> #!/usr/bin/php >> <?php >> include ("gradsPHP.php"); >> >> // OPEN GRADS WITH OR WITHOUT OPTIONS >> grads(array( >> "Bin" => "gradsnc", >> "Echo" => "0", >> "Opt" => "-b" >> )); >> // or just grads(); >> >> // OPEN THE FILE >> ga_open("model.nc","nc"); >> >> // SET LAT, LON, ETC >> ga_set("lat","-23.8 -12.6"); >> ga_set("lon","-52.2 -39.4"); >> ga_set("gxout","shaded"); >> ga_set("grads","off"); >> >> // DISPLAY PS >> ga_display("ps"); >> >> // DRAW THE TITLE CONTROLLING THE POSITION OF THE TITLE >> ga_title("Pressao - Minas >> Gerais",$opt=array("Font"=>"0","Size"=>".25","YOffset"=>".2")); >> >> // CBARN AND SHAPE CONTOURS >> ga_cmd("run cbarn.gs"); >> ga_set("line","0"); >> ga_cmd("shp_lines est"); >> ga_cmd("shp_lines mun"); >> //ga_query("pos"); >> >> // EXPORT THE IMAGE >> ga_gxyat("ok.png"); >> >> // CLOSE PIPES, PID... >> ga_submit(); >> >> // SHOW THE IMAGE >> `animate ok.png`; >> >> ?> >> >> This is a "tutorial like program", where I used the gradsPHP.php >> functions that arrange the commands and send them to grads through the >> pipe. >> >> I create the ga_title() function based in Jennifer's title.gs script, >> but in this case you can pass some attributes through an array of >> options, including the Y position of the title. I obtain this >> information using the "q gxinfo" and retriving the output using the >> pipe system. >> >> The ga_cmd() function is the most generic function of the class. It >> can send the commands like: >> >> ga_cmd("set x 1"); >> ga_cmd("set y 1"); >> ga_cmd("d ps"); >> ga_cmd("draw title something"); >> >> or >> >> ga_cmd(" >> set x 1 >> set y 1 >> d ps >> draw title something >> "); >> >> or even >> >> ga_cmd($scriptgs); >> >> [$scriptgs is the content of a gs file] >> >> >> I'm preparing the code to the Echo/Verb style you did in the Gerl and >> I can send you this first version of the code for you to have a look. >> >> Is there something I forgot for this first pre-alpha prototype? I'm >> open for sugestions! >> >> 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. >> >> >> Peace! >> >> -- >> >> Luiz Rodrigo Lins Tozzi >> lui...@gm... >> >> -- >> Arlindo da Silva >> da...@al... > > > -- Arlindo da Silva da...@al... |