grd file

hi all,
is there a way to plot (contourf) a .grd file from GMT directly with Basemap?
I have a problem with contourf because I can't reshape to 2D the Z values ,x
and y are in Lambert projection, so I can't compute the shape :frowning:
thanks

路路路

--
Lionel Roubeyrie - lroubeyrie@...1068...
Chag茅 d'茅tudes et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr

Lionel Roubeyrie wrote:

hi all,
is there a way to plot (contourf) a .grd file from GMT directly with Basemap? I have a problem with contourf because I can't reshape to 2D the Z values ,x and y are in Lambert projection, so I can't compute the shape :frowning:
thanks

Lionel: No, not directly. You have to read in the x,y,z values and convert them to 2D arrays. You'll have to give more details on your problem - just because x,y are in Lambert projection coordinates doesn't mean you can't reshape z.

-Jeff

路路路

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Hi Jeff,
yes, lambert is not the problem, you're right. I have some .grd files with
x,y,z values, and I want to project z values on maps and interpolate them. I
don't have the dimensions of the shape, but with m.scatter(x, y, z), I see
that the scatters are displayed in a regular grid. Then is there a way to
retrieve the dimensions of the resulting grid, and then I can reshape z to
pass it to contourf?
I tried to convert x and y to degrees, hoping removing the duplicated entries
(with rouding) gives me the dimensions, but I also have a problem with
m(x,y,inverse=True), because the results are not good ( I use m =
Basemap(llcrnrlon=0.5, llcrnrlat=44.8, urcrnrlon=2.8, urcrnrlat=46.5,
projection='lcc', lat_1=45.89891889,lat_2=47.69601444,lon_0=2.33722917)).
thanks

路路路

Le Vendredi 20 Avril 2007 13:11, Jeff Whitaker a 茅crit :

Lionel Roubeyrie wrote:
> hi all,
> is there a way to plot (contourf) a .grd file from GMT directly with
> Basemap? I have a problem with contourf because I can't reshape to 2D the
> Z values ,x and y are in Lambert projection, so I can't compute the shape
> :frowning: thanks

Lionel: No, not directly. You have to read in the x,y,z values and
convert them to 2D arrays. You'll have to give more details on your
problem - just because x,y are in Lambert projection coordinates doesn't
mean you can't reshape z.

-Jeff

--
Lionel Roubeyrie - lroubeyrie@...1068...
Chag茅 d'茅tudes et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr

Lionel Roubeyrie wrote:

Hi Jeff,
yes, lambert is not the problem, you're right. I have some .grd files with x,y,z values, and I want to project z values on maps and interpolate them. I don't have the dimensions of the shape, but with m.scatter(x, y, z), I see that the scatters are displayed in a regular grid. Then is there a way to retrieve the dimensions of the resulting grid, and then I can reshape z to pass it to contourf?
聽聽

Lionel: There should be an attribute or attributes in the netCDF file that specify the dimensions of the grid (at least there should be, according to the GMT documentation).

I tried to convert x and y to degrees, hoping removing the duplicated entries (with rouding) gives me the dimensions, but I also have a problem with m(x,y,inverse=True), because the results are not good ( I use m = Basemap(llcrnrlon=0.5, llcrnrlat=44.8, urcrnrlon=2.8, urcrnrlat=46.5, projection='lcc', lat_1=45.89891889,lat_2=47.69601444,lon_0=2.33722917)).
thanks
聽聽
You shouldn't need to do that - just pass x,y and the reshaped z to contourf. You do need to know the parameters of the projection though.

-Jeff

路路路

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Lionel Roubeyrie wrote:

Hi Jeff,
yes, lambert is not the problem, you're right. I have some .grd files with x,y,z values, and I want to project z values on maps and interpolate them. I don't have the dimensions of the shape, but with m.scatter(x, y, z), I see that the scatters are displayed in a regular grid. Then is there a way to retrieve the dimensions of the resulting grid, and then I can reshape z to pass it to contourf? I tried to convert x and y to degrees, hoping removing the duplicated entries (with rouding) gives me the dimensions, but I also have a problem with m(x,y,inverse=True), because the results are not good ( I use m = Basemap(llcrnrlon=0.5, llcrnrlat=44.8, urcrnrlon=2.8, urcrnrlat=46.5, projection='lcc', lat_1=45.89891889,lat_2=47.69601444,lon_0=2.33722917)).
thanks

Lionel: Basemap assumes that x=0,y=0 is the lower left corner of the projection region. You may have to adjust the x,y values coming from your grd file accordingly.

-Jeff

路路路

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

By grd file, I mean csv like file, with one line by value, like
X1 Y1 Z1
X2 Y1 Z2
X3 Y1 Z3
...
X1 Y2 Zk
X2 Y2 Zk+1
...
Xi Yj Zn
this is in geographic format, where there is a repetition in the X values and
the Y values, because the grid is regular, but not in lambert projection,
then I can't retrieve the dimensions of the grid.

路路路

Le Vendredi 20 Avril 2007 14:54, Jeff Whitaker a 茅crit :

Lionel Roubeyrie wrote:
> Hi Jeff,
> yes, lambert is not the problem, you're right. I have some .grd files
> with x,y,z values, and I want to project z values on maps and interpolate
> them. I don't have the dimensions of the shape, but with m.scatter(x, y,
> z), I see that the scatters are displayed in a regular grid. Then is
> there a way to retrieve the dimensions of the resulting grid, and then I
> can reshape z to pass it to contourf?

Lionel: There should be an attribute or attributes in the netCDF file
that specify the dimensions of the grid (at least there should be,
according to the GMT documentation).

> I tried to convert x and y to degrees, hoping removing the duplicated
> entries (with rouding) gives me the dimensions, but I also have a problem
> with m(x,y,inverse=True), because the results are not good ( I use m =
> Basemap(llcrnrlon=0.5, llcrnrlat=44.8, urcrnrlon=2.8, urcrnrlat=46.5,
> projection='lcc', lat_1=45.89891889,lat_2=47.69601444,lon_0=2.33722917)).
> thanks

You shouldn't need to do that - just pass x,y and the reshaped z to
contourf. You do need to know the parameters of the projection though.

-Jeff

--
Lionel Roubeyrie - lroubeyrie@...1068...
Chag茅 d'茅tudes et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr

Lionel Roubeyrie wrote:

By grd file, I mean csv like file, with one line by value, like
X1 Y1 Z1
X2 Y1 Z2
X3 Y1 Z3
...
X1 Y2 Zk
X2 Y2 Zk+1
...
Xi Yj Zn
this is in geographic format, where there is a repetition in the X values and the Y values, because the grid is regular, but not in lambert projection, then I can't retrieve the dimensions of the grid.

[SNIP]

Lionel: Well, I guess you are stuck without knowing what the dimensions of the grid are. Can't you find that out from the data provider?

-Jeff

路路路

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Hi Jeff,
sorry for the latency.
Problems come from the implementation of GMT into our programs, which only
uses Lambert coords, and we are now with a deadlock. We're going to replace
it by MPL because we believe in it and we think it's the better way to make
plots and maps, so if for that we have to rewrite all the codes, we can then
try to catch geographic coords instead of Lambert.
Thanks for your help, and for basemap too.

路路路

Le Vendredi 20 Avril 2007 18:10, Jeff Whitaker a 茅crit :

Lionel Roubeyrie wrote:
> By grd file, I mean csv like file, with one line by value, like
> X1 Y1 Z1
> X2 Y1 Z2
> X3 Y1 Z3
> ...
> X1 Y2 Zk
> X2 Y2 Zk+1
> ...
> Xi Yj Zn
> this is in geographic format, where there is a repetition in the X values
> and the Y values, because the grid is regular, but not in lambert
> projection, then I can't retrieve the dimensions of the grid.
>
> [SNIP]

Lionel: Well, I guess you are stuck without knowing what the dimensions
of the grid are. Can't you find that out from the data provider?

-Jeff

--
Lionel Roubeyrie - lroubeyrie@...1068...
Chag茅 d'茅tudes et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr