|
From: Maria L. <li...@us...> - 2014-11-21 00:11:41
|
Hello, I have a problem plotting data which is defined on a grid other than rectangular mesh, and would greatly appreciate any advise. My data is defined for 0.1degree grid for the state of California, and I don’t want to interpolate my data outside of the defined grid when plotting it. I used pcolormesh() function for rectangular area maps, but it only accepts rectangular grid and I was wondering if there is a simple solution to my problem. The only solution I could find was to use scipy.interpolate,griddata() to “map” my grid to a bounding rectangular grid (bounding rectangle around CA state), but that would also interpolate my data to grid cells outside of CA state, which I don’t want to do. Many thanks for any hints! Masha -- li...@us... |
|
From: Thomas C. <tca...@gm...> - 2014-11-21 04:38:28
|
There are also triangular mesh plotting (I think tricolormesh is the function name). The really brute force solution is to use poly collection and draw what ever shape you want. Tom |
|
From: Shahar S. K. <ka...@po...> - 2014-11-21 09:13:52
|
When using scipy.interpolate.griddada, you could use 'nearest' if your data is sufficiently dense. This will 'map' your grid onto whatever rectangular grid leaving grid points outside the convex hull of the original grid empty. Well, not empty but nan. If you do wish to interpolate your dada, you could mask the resulting rectangular grid post interpolation. — Sent from Mailbox On Fri, Nov 21, 2014 at 2:12 AM, Maria Liukis <li...@us...> wrote: > Hello, > I have a problem plotting data which is defined on a grid other than rectangular mesh, and would greatly appreciate any advise. My data is defined for 0.1degree grid for the state of California, and I don’t want to interpolate my data outside of the defined grid when plotting it. I used pcolormesh() function for rectangular area maps, but it only accepts rectangular grid and I was wondering if there is a simple solution to my problem. > The only solution I could find was to use scipy.interpolate,griddata() to “map” my grid to a bounding rectangular grid (bounding rectangle around CA state), but that would also interpolate my data to grid cells outside of CA state, which I don’t want to do. > Many thanks for any hints! > Masha > -- > li...@us... > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Oliver <oli...@gm...> - 2014-11-21 13:13:16
|
As Thomas Caswell said, check out the "tri..." functions. No need for interpolation. This question recently reappeared on Stackoverflow and was answered there as well: https://stackoverflow.com/questions/27004422/contour-imshow-plot-for-irregular-x-y-z-data 2014-11-21 9:15 GMT+01:00 Shahar Shani Kadmiel <ka...@po...>: > When using scipy.interpolate.griddada, you could use 'nearest' if your > data is sufficiently dense. This will 'map' your grid onto whatever > rectangular grid leaving grid points outside the convex hull of the > original grid empty. Well, not empty but nan. > If you do wish to interpolate your dada, you could mask the resulting > rectangular grid post interpolation. > > — > Sent from Mailbox <https://www.dropbox.com/mailbox> > > > On Fri, Nov 21, 2014 at 2:12 AM, Maria Liukis <li...@us...> wrote: > >> Hello, >> >> I have a problem plotting data which is defined on a grid other than >> rectangular mesh, and would greatly appreciate any advise. My data is >> defined for 0.1degree grid for the state of California, and I don’t want to >> interpolate my data outside of the defined grid when plotting it. I used >> pcolormesh() function for rectangular area maps, but it only accepts >> rectangular grid and I was wondering if there is a simple solution to my >> problem. >> >> The only solution I could find was to use scipy.interpolate,griddata() to >> “map” my grid to a bounding rectangular grid (bounding rectangle around CA >> state), but that would also interpolate my data to grid cells outside of CA >> state, which I don’t want to do. >> >> Many thanks for any hints! >> Masha >> -- >> li...@us... >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> >> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
|
From: Maria L. <li...@us...> - 2014-11-21 18:18:09
|
Thank you for the suggestion, unfortunately “nearest” method for interpolation still does interpolation to some extra cells outside of my CA grid which fall within the convex hull. I thought I check if there is existing functionality for that within matplotlib, but it seems that I have to manually “map” my grid to larger rectangular grid for plotting. Many thanks for your response! Masha -- li...@us...<mailto:li...@us...> On Nov 21, 2014, at 12:15 AM, Shahar Shani Kadmiel <ka...@po...<mailto:ka...@po...>> wrote: When using scipy.interpolate.griddada, you could use 'nearest' if your data is sufficiently dense. This will 'map' your grid onto whatever rectangular grid leaving grid points outside the convex hull of the original grid empty. Well, not empty but nan. If you do wish to interpolate your dada, you could mask the resulting rectangular grid post interpolation. — Sent from Mailbox<https://www.dropbox.com/mailbox> On Fri, Nov 21, 2014 at 2:12 AM, Maria Liukis <li...@us...<mailto:li...@us...>> wrote: Hello, I have a problem plotting data which is defined on a grid other than rectangular mesh, and would greatly appreciate any advise. My data is defined for 0.1degree grid for the state of California, and I don’t want to interpolate my data outside of the defined grid when plotting it. I used pcolormesh() function for rectangular area maps, but it only accepts rectangular grid and I was wondering if there is a simple solution to my problem. The only solution I could find was to use scipy.interpolate,griddata() to “map” my grid to a bounding rectangular grid (bounding rectangle around CA state), but that would also interpolate my data to grid cells outside of CA state, which I don’t want to do. Many thanks for any hints! Masha -- li...@us...<mailto:li...@us...> ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Matplotlib-users mailing list Mat...@li...<mailto:Mat...@li...> https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Eric F. <ef...@ha...> - 2014-11-21 14:54:38
|
On 2014/11/20, 7:11 PM, Maria Liukis wrote: > Hello, > > I have a problem plotting data which is defined on a grid other than > rectangular mesh, and would greatly appreciate any advise. My data is > defined for 0.1degree grid for the state of California, and I don’t > want to interpolate my data outside of the defined grid when plotting > it. I used pcolormesh() function for rectangular area maps, but it > only accepts rectangular grid and I was wondering if there is a > simple solution to my problem. Masha, When you say your data "is defined for a 0.1 degree grid", that makes it sound like it is on a quadrilateral grid, so there should be no problem with using pcolormesh. Is it on 0.1 degree lon by 0.1 degree lat points, but only for points within California? Then you can make a masked array with this grid for a rectangle in which the points outside California are masked, and the ones inside are set to your data values. Your X and Y inputs to pcolormesh should be 2-D arrays with the boundary values rather than the centers. It sounds like you would want to do all this via mpl_toolkits.basemap.Basemap so that you will end up with a properly proportioned and labeled map. Maybe I am misinterpreting your description of your data, however. Eric > > The only solution I could find was to use > scipy.interpolate,griddata() to “map” my grid to a bounding > rectangular grid (bounding rectangle around CA state), but that would > also interpolate my data to grid cells outside of CA state, which I > don’t want to do. > > Many thanks for any hints! Masha -- li...@us... > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Maria L. <li...@us...> - 2014-11-21 18:30:11
|
Eric, Yes, my data is exactly how you understood it. I thought, as you are suggesting, to create a masked array for rectangle that bounds state of CA, to be used with pcolormesh(). The only existing functionality that I could find is griddata(), but it also interpolates data to extra cells outside of my CA grid (even with method=‘nearest’ to extra cells within the convex hull). It looks like I have to “map” my CA grid to larger rectangular grid manually, I just wanted to check if such functionality already exists within matplotlib, numpy or scipy packages, and I am just not aware of it. I also could plot each cell with ax.add_patch(), but would imagine that it would be much slower. And thank you for mentioning basemap, I am using it for my maps :) Thank you very much for your response! Masha On Nov 21, 2014, at 6:54 AM, Eric Firing <ef...@ha...> wrote: > On 2014/11/20, 7:11 PM, Maria Liukis wrote: >> Hello, >> >> I have a problem plotting data which is defined on a grid other than >> rectangular mesh, and would greatly appreciate any advise. My data is >> defined for 0.1degree grid for the state of California, and I don’t >> want to interpolate my data outside of the defined grid when plotting >> it. I used pcolormesh() function for rectangular area maps, but it >> only accepts rectangular grid and I was wondering if there is a >> simple solution to my problem. > > Masha, > > When you say your data "is defined for a 0.1 degree grid", that makes it > sound like it is on a quadrilateral grid, so there should be no problem > with using pcolormesh. Is it on 0.1 degree lon by 0.1 degree lat > points, but only for points within California? Then you can make a > masked array with this grid for a rectangle in which the points outside > California are masked, and the ones inside are set to your data values. > Your X and Y inputs to pcolormesh should be 2-D arrays with the > boundary values rather than the centers. It sounds like you would want > to do all this via mpl_toolkits.basemap.Basemap so that you will end up > with a properly proportioned and labeled map. > > Maybe I am misinterpreting your description of your data, however. > > Eric > >> >> The only solution I could find was to use >> scipy.interpolate,griddata() to “map” my grid to a bounding >> rectangular grid (bounding rectangle around CA state), but that would >> also interpolate my data to grid cells outside of CA state, which I >> don’t want to do. >> >> Many thanks for any hints! Masha -- li...@us... >> >> >> > >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Benjamin R. <ben...@ou...> - 2014-11-21 19:32:06
|
How many cells past the state boundary are you seeing? If it is never more than one cell past the boundary, it might be an offset issue. On Fri, Nov 21, 2014 at 1:30 PM, Maria Liukis <li...@us...> wrote: > Eric, > > Yes, my data is exactly how you understood it. I thought, as you are > suggesting, to create a masked array for rectangle that bounds state of CA, > to be used with pcolormesh(). The only existing functionality that I could > find is griddata(), but it also interpolates data to extra cells outside of > my CA grid (even with method=‘nearest’ to extra cells within the convex > hull). It looks like I have to “map” my CA grid to larger rectangular grid > manually, I just wanted to check if such functionality already exists > within matplotlib, numpy or scipy packages, and I am just not aware of it. > > I also could plot each cell with ax.add_patch(), but would imagine that it > would be much slower. > > And thank you for mentioning basemap, I am using it for my maps :) > > Thank you very much for your response! > Masha > > > On Nov 21, 2014, at 6:54 AM, Eric Firing <ef...@ha...> wrote: > > > On 2014/11/20, 7:11 PM, Maria Liukis wrote: > >> Hello, > >> > >> I have a problem plotting data which is defined on a grid other than > >> rectangular mesh, and would greatly appreciate any advise. My data is > >> defined for 0.1degree grid for the state of California, and I don’t > >> want to interpolate my data outside of the defined grid when plotting > >> it. I used pcolormesh() function for rectangular area maps, but it > >> only accepts rectangular grid and I was wondering if there is a > >> simple solution to my problem. > > > > Masha, > > > > When you say your data "is defined for a 0.1 degree grid", that makes it > > sound like it is on a quadrilateral grid, so there should be no problem > > with using pcolormesh. Is it on 0.1 degree lon by 0.1 degree lat > > points, but only for points within California? Then you can make a > > masked array with this grid for a rectangle in which the points outside > > California are masked, and the ones inside are set to your data values. > > Your X and Y inputs to pcolormesh should be 2-D arrays with the > > boundary values rather than the centers. It sounds like you would want > > to do all this via mpl_toolkits.basemap.Basemap so that you will end up > > with a properly proportioned and labeled map. > > > > Maybe I am misinterpreting your description of your data, however. > > > > Eric > > > >> > >> The only solution I could find was to use > >> scipy.interpolate,griddata() to “map” my grid to a bounding > >> rectangular grid (bounding rectangle around CA state), but that would > >> also interpolate my data to grid cells outside of CA state, which I > >> don’t want to do. > >> > >> Many thanks for any hints! Masha -- li...@us... > >> > >> > >> > > > >> > ------------------------------------------------------------------------------ > >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards > >> with Interactivity, Sharing, Native Excel Exports, App Integration & > more > >> Get technology previously reserved for billion-dollar corporations, FREE > >> > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > >> _______________________________________________ > >> Matplotlib-users mailing list > >> Mat...@li... > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > > > > > > > ------------------------------------------------------------------------------ > > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > > with Interactivity, Sharing, Native Excel Exports, App Integration & more > > Get technology previously reserved for billion-dollar corporations, FREE > > > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
|
From: Maria L. <li...@us...> - 2014-11-21 22:21:02
|
Thank you for the note, but it is definitely many more extra cells than just one around the border. Especially bounding area on the east side of the state is affected the most. Thanks, Masha On Nov 21, 2014, at 11:31 AM, Benjamin Root <ben...@ou...<mailto:ben...@ou...>> wrote: How many cells past the state boundary are you seeing? If it is never more than one cell past the boundary, it might be an offset issue. On Fri, Nov 21, 2014 at 1:30 PM, Maria Liukis <li...@us...<mailto:li...@us...>> wrote: Eric, Yes, my data is exactly how you understood it. I thought, as you are suggesting, to create a masked array for rectangle that bounds state of CA, to be used with pcolormesh(). The only existing functionality that I could find is griddata(), but it also interpolates data to extra cells outside of my CA grid (even with method=‘nearest’ to extra cells within the convex hull). It looks like I have to “map” my CA grid to larger rectangular grid manually, I just wanted to check if such functionality already exists within matplotlib, numpy or scipy packages, and I am just not aware of it. I also could plot each cell with ax.add_patch(), but would imagine that it would be much slower. And thank you for mentioning basemap, I am using it for my maps :) Thank you very much for your response! Masha On Nov 21, 2014, at 6:54 AM, Eric Firing <ef...@ha...<mailto:ef...@ha...>> wrote: > On 2014/11/20, 7:11 PM, Maria Liukis wrote: >> Hello, >> >> I have a problem plotting data which is defined on a grid other than >> rectangular mesh, and would greatly appreciate any advise. My data is >> defined for 0.1degree grid for the state of California, and I don’t >> want to interpolate my data outside of the defined grid when plotting >> it. I used pcolormesh() function for rectangular area maps, but it >> only accepts rectangular grid and I was wondering if there is a >> simple solution to my problem. > > Masha, > > When you say your data "is defined for a 0.1 degree grid", that makes it > sound like it is on a quadrilateral grid, so there should be no problem > with using pcolormesh. Is it on 0.1 degree lon by 0.1 degree lat > points, but only for points within California? Then you can make a > masked array with this grid for a rectangle in which the points outside > California are masked, and the ones inside are set to your data values. > Your X and Y inputs to pcolormesh should be 2-D arrays with the > boundary values rather than the centers. It sounds like you would want > to do all this via mpl_toolkits.basemap.Basemap so that you will end up > with a properly proportioned and labeled map. > > Maybe I am misinterpreting your description of your data, however. > > Eric > >> >> The only solution I could find was to use >> scipy.interpolate,griddata() to “map” my grid to a bounding >> rectangular grid (bounding rectangle around CA state), but that would >> also interpolate my data to grid cells outside of CA state, which I >> don’t want to do. >> >> Many thanks for any hints! Masha -- li...@us...<mailto:li...@us...> >> >> >> > >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li...<mailto:Mat...@li...> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li...<mailto:Mat...@li...> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Matplotlib-users mailing list Mat...@li...<mailto:Mat...@li...> https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Ian T. <ian...@gm...> - 2014-11-22 19:49:35
|
Masha, As suggested before, take a look at the triangular mesh functions. There are simple contour ( http://matplotlib.org/examples/pylab_examples/tricontour_demo.html) and pcolor plots ( http://matplotlib.org/examples/pylab_examples/tripcolor_demo.html), plus linear and cubic interpolation ( http://matplotlib.org/examples/pylab_examples/tricontour_smooth_delaunay.html and http://matplotlib.org/examples/pylab_examples/tricontour_smooth_user.html). The API documentation is at http://matplotlib.org/dev/api/tri_api.html. Ian |