|
From: Arlindo da S. <da...@al...> - 2008-06-25 12:20:27
|
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...
|