## Re: [Plplot-devel] NaN, geometry && plgriddata

 Re: [Plplot-devel] NaN, geometry && plgriddata From: Alan W. Irwin - 2003-12-02 22:07:42 ```On 2003-12-02 20:59+0100 Christophe TROESTLER wrote: > Hi all, > > I am experimenting with PLplot to display functions obtained by the > finite elements method on non-square domains. I use plgriddata() to > transform the data to a suitable format for plmesh*() but I get > problems with the fact that plgriddata() generates NaNs on the > complement of the domain in the surrounding square. Fortunately my > interest at the moment is in Dirichlet boundary conditions so I just > convert any NaN to 0.0 and everything is fine. However, IMHO, a much > better solution would be that PLplot does not draw any line for NaN > data. Is there a way to do that? How am I supposed to plot solutions > of PDEs with e.g. Neumann boundary conditions? > > Thanks for any help, > ChriS If you changed plgriddata to specify the resulting non-rectangular boundaries, then getting plcont, plshade, and plshades to plot the results is entirely straightforward because the z(x,y) grid for those routines is specified as x(ix,iy), and y(ix,iy). So ix, and iy must be defined on a rectangular grid, but x and y don't have to be for those routines so you can just keep repeating the boundary values of z(x,y) and either x(y) or y(x) whenever you reach it, and all is well. (I have tried this for the non-rectangular region where my own data are defined, and this method works fine for plcont, plshade, and plshades.) plmeshc and friends constitute a more difficult case since drawing occurs only along constant x vectors(DRAW_LINEY), constant y vectors (DRAW_LINEX), or both (DRAW_LINEXY). Thus their arguments are z(x,y), and the x(ix) and y(iy) vectors. But there is no intrinsic reason why the defined grid of ix and iy has to be rectangular in this case. Thus, in principle, it should be possible to modify plgriddata to produce and plmeshc to accept monotonically changing boundaries for x(ix) and y(iy), that are specified either by ix ranging from ixmin(iy) to ixmax(iy) with iy in the range from 0 to ny-1 or the equivalent form (for montonic bondaries) where the iy range is a function of ix. (You would need both forms of specifying the boundaries or else internally transform from one to the other because plmeshc has options to draw just in x, just in y, or in both coordinates.) I say "in principle", since I need this enhanced functionality myself, but I am having trouble understanding the plmeshc code well enough to change it. Chris, I assume your PDE solution has monotonic boundaries (otherwise, plmeshc would produce a mess for the default DRAW_LINEXY) so if you think my idea of specifying the ix and iy limits would work for your needs and you are game to make the required coding changes, that would also be a big help to me (and probably many other users). Alan __________________________ Alan W. Irwin email: irwin@... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the PLplot scientific plotting software package (plplot.org), the Yorick front-end to PLplot (yplot.sf.net), the Loads of Linux Links project (loll.sf.net), and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ```

 [Plplot-devel] NaN, geometry && plgriddata From: Christophe TROESTLER - 2003-12-02 19:59:10 ```Hi all, I am experimenting with PLplot to display functions obtained by the finite elements method on non-square domains. I use plgriddata() to transform the data to a suitable format for plmesh*() but I get problems with the fact that plgriddata() generates NaNs on the complement of the domain in the surrounding square. Fortunately my interest at the moment is in Dirichlet boundary conditions so I just convert any NaN to 0.0 and everything is fine. However, IMHO, a much better solution would be that PLplot does not draw any line for NaN data. Is there a way to do that? How am I supposed to plot solutions of PDEs with e.g. Neumann boundary conditions? Thanks for any help, ChriS ```
 Re: [Plplot-devel] NaN, geometry && plgriddata From: - 2003-12-02 20:38:00 ```On Tuesday 02 December 2003 19:59, Christophe TROESTLER wrote: | Hi all, | | I am experimenting with PLplot to display functions obtained by the | finite elements method on non-square domains. I use plgriddata() to | transform the data to a suitable format for plmesh*() but I get | problems with the fact that plgriddata() generates NaNs on the | complement of the domain in the surrounding square. Fortunately my | interest at the moment is in Dirichlet boundary conditions so I just | convert any NaN to 0.0 and everything is fine. However, IMHO, a much | better solution would be that PLplot does not draw any line for NaN | data. Is there a way to do that? Yes, make PLplot handle NaNs :-) Unfortunately Plplot was not designed like that, and handling NaNs is probably a major, but desirable, task. | How am I supposed to plot | solutions of PDEs with e.g. Neumann boundary conditions? Contribute a method to plgriddata() that does not generate NaNs? Some crude methods exists in plgriddata() that already do that. But how can one interpolate in the borders or corners? It would be desirable for to PLplot to handle NaNs, because there are times when real world data is missing, and coding it as NaNs would allow one to plot the data. Some years ago I start changing pline() to accept NaNs, and it was not that difficult, but I'm afraid that handling the general API is a major effort. Joao | | Thanks for any help, | ChriS | | | ------------------------------------------------------- | This SF.net email is sponsored by: SF.net Giveback Program. | Does SourceForge.net help you be more productive? Does it | help you create better code? SHARE THE LOVE, and help us help | YOU! Click Here: http://sourceforge.net/donate/ | _______________________________________________ | Plplot-devel mailing list | Plplot-devel@... | https://lists.sourceforge.net/lists/listinfo/plplot-devel ```
 Re: [Plplot-devel] NaN, geometry && plgriddata From: Arjen Markus - 2003-12-03 08:54:11 ```Jo=E3o Cardoso wrote: >=20 > On Tuesday 02 December 2003 19:59, Christophe TROESTLER wrote: > | Hi all, > | > | I am experimenting with PLplot to display functions obtained by the > | finite elements method on non-square domains. I use plgriddata() to > | transform the data to a suitable format for plmesh*() but I get > | problems with the fact that plgriddata() generates NaNs on the > | complement of the domain in the surrounding square. Fortunately my > | interest at the moment is in Dirichlet boundary conditions so I just > | convert any NaN to 0.0 and everything is fine. However, IMHO, a much > | better solution would be that PLplot does not draw any line for NaN > | data. Is there a way to do that? >=20 > Yes, make PLplot handle NaNs :-) > Unfortunately Plplot was not designed like that, and handling NaNs is > probably a major, but desirable, task. >=20 > | How am I supposed to plot > | solutions of PDEs with e.g. Neumann boundary conditions? >=20 > Contribute a method to plgriddata() that does not generate NaNs? Some > crude methods exists in plgriddata() that already do that. But how can > one interpolate in the borders or corners? >=20 > It would be desirable for to PLplot to handle NaNs, because there are > times when real world data is missing, and coding it as NaNs would > allow one to plot the data. > Some years ago I start changing pline() to accept NaNs, and it was not > that difficult, but I'm afraid that handling the general API is a major > effort. >=20 > Joao >=20 My personal experiences with handling NaNs are such that I find them at best a mixed blessing. Some platforms seem to be able to handle them fairly well, that is: you have the ability to check if a number is NaN or not, some cause pain and suffering beyond compare. A somewhat related and somewhat off-topic issue arises with denormalised=20 numbers: in one of the programs I maintain there is a bizarre problem with=20 such numbers that pops up on _some_ PC running _a_ version of Windows 98=20 (please note the underlining!) On these PCs my program will crash. If I even try to filter out these=20 things, by adding a loop with checks like: if ( number < 1.0e-20 && number > -1.0e-20) number =3D 0.0=20 the program crashes because it tries to do something with these numbers (that is: look at them)! Some compilers will optimise out checks like: if ( number !=3D number ) ... (this is the check that should be enough according to the definition) So you will need a library function (called isnan() typically) which=20 does not exist on all platforms. And if it is there, hope for the best. (Sorry, if that does not help you, just a few personal frustrations ...) Regards, Arjen ```
 Re: [Plplot-devel] NaN, geometry && plgriddata From: Alan W. Irwin - 2003-12-02 22:07:42 ```On 2003-12-02 20:59+0100 Christophe TROESTLER wrote: > Hi all, > > I am experimenting with PLplot to display functions obtained by the > finite elements method on non-square domains. I use plgriddata() to > transform the data to a suitable format for plmesh*() but I get > problems with the fact that plgriddata() generates NaNs on the > complement of the domain in the surrounding square. Fortunately my > interest at the moment is in Dirichlet boundary conditions so I just > convert any NaN to 0.0 and everything is fine. However, IMHO, a much > better solution would be that PLplot does not draw any line for NaN > data. Is there a way to do that? How am I supposed to plot solutions > of PDEs with e.g. Neumann boundary conditions? > > Thanks for any help, > ChriS If you changed plgriddata to specify the resulting non-rectangular boundaries, then getting plcont, plshade, and plshades to plot the results is entirely straightforward because the z(x,y) grid for those routines is specified as x(ix,iy), and y(ix,iy). So ix, and iy must be defined on a rectangular grid, but x and y don't have to be for those routines so you can just keep repeating the boundary values of z(x,y) and either x(y) or y(x) whenever you reach it, and all is well. (I have tried this for the non-rectangular region where my own data are defined, and this method works fine for plcont, plshade, and plshades.) plmeshc and friends constitute a more difficult case since drawing occurs only along constant x vectors(DRAW_LINEY), constant y vectors (DRAW_LINEX), or both (DRAW_LINEXY). Thus their arguments are z(x,y), and the x(ix) and y(iy) vectors. But there is no intrinsic reason why the defined grid of ix and iy has to be rectangular in this case. Thus, in principle, it should be possible to modify plgriddata to produce and plmeshc to accept monotonically changing boundaries for x(ix) and y(iy), that are specified either by ix ranging from ixmin(iy) to ixmax(iy) with iy in the range from 0 to ny-1 or the equivalent form (for montonic bondaries) where the iy range is a function of ix. (You would need both forms of specifying the boundaries or else internally transform from one to the other because plmeshc has options to draw just in x, just in y, or in both coordinates.) I say "in principle", since I need this enhanced functionality myself, but I am having trouble understanding the plmeshc code well enough to change it. Chris, I assume your PDE solution has monotonic boundaries (otherwise, plmeshc would produce a mess for the default DRAW_LINEXY) so if you think my idea of specifying the ix and iy limits would work for your needs and you are game to make the required coding changes, that would also be a big help to me (and probably many other users). Alan __________________________ Alan W. Irwin email: irwin@... phone: 250-727-2902 Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the PLplot scientific plotting software package (plplot.org), the Yorick front-end to PLplot (yplot.sf.net), the Loads of Linux Links project (loll.sf.net), and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ```