Re: [Matplotlib-users] Information request
Jeff, I totally agree this is due to missing values Again I've got difficulties to find good words so forgive me, what I tried to say is that the ability to have that border transparent would be a good feature in next releases, for people who need to interpolate and plot such data and have an aesthetic result Imshow is the ideal candidate for satellite data as it has some nice interpolation features and it is fast, so it can be batch-run on the server every time we receive data, without too much computation time The alternative I'm using now is a double or quadruple size grid to reduce the width of that border, with background color set to the lower colormap color That way, the border is really hard to see and it makes (almost) quality plots for publications -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: Thursday, 25 September, 2008 15:34 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, Thanks for the tip, it's now working perfectly However, there's still that border with the imshow plot, and I think it would be good to have it transparent There's a zoomed picture I made: http://img218.imageshack.us/img218/5833/imshowborderxz9.png You see the shadow around the data... It would be nice for next releases of Matplotlib to get rid of that, but I'm not able to patch it myself or so... I know there's still a lot of work with the lib but keep the good work, it is really fantastic Thanks for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I thought we agreed that it's not an imshow bug - but rather due to the griddata gridding procedure returning missing values outside the convex hull of the input data. Do you disagree? I see no such border around an imshow plot that contains no missing values. If you shrink the size of the map plotting region so it's fully within the convex hull of the data, the border disappears. -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 25 septembre 2008 14:15 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I finally found out how to fill my figure with a background color using axes.set_axis_bgcolor(color), but I'm facing the following problem now: How could I get the lower color of a colormap? This is quite undocumented and I dont know the colormap properties I could use for that I know there must be an accessible value somewhere, like for the ax.get_yticklabels() you gave me If someone had the clue, my problems would then be completely solved Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: To get the RGBA value associated with a particular data value, just call the colormap as a function as pass it that value. For example import matplotlib.pyplot as plt plt.cm.jet(1) (0.0, 0.0, 0.517825311942959, 1.0) BTW: the 'fill_color' kwarg of drawmapboundary basemap method allows you to set the background color of the map. http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html It fills only the map region (which for some projections, like the orthographic, is not the same as the axes region). -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 23 septembre 2008 20:38 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can
Re: [Matplotlib-users] Information request
Hi Jeff, I finally found out how to fill my figure with a background color using axes.set_axis_bgcolor(color), but I'm facing the following problem now: How could I get the lower color of a colormap? This is quite undocumented and I dont know the colormap properties I could use for that I know there must be an accessible value somewhere, like for the ax.get_yticklabels() you gave me If someone had the clue, my problems would then be completely solved Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 23 septembre 2008 20:38 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can easily see where you actually have data. HTH, -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\ urcrnrlon=180,llcrnrlon=-180,resolution='l') x, y = map(Lon, Lat) plt.scatter(x,y,s=25,c=Val,marker='s',edgecolor=None,cmap=plt.cm.winter,vm in=-5,vmax=-1.2, alpha=0.5) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0],fontsize=7,linewidth=0.25) map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=7,linewidth=0.25) map.drawcoastlines(0.25,antialiased=1) plt.title(titre) plt.show() -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED] Sent: jeudi 18 septembre 2008 17:23 To: Jeff Whitaker; [EMAIL PROTECTED] Cc: 'John Hunter'; 'Matplotlib Users' Subject: re:Re: [Matplotlib-users] Information request Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think it's the imshow layer that is not totally transparent on the map background.. I tried every trick I could for example to put some zero-valued points on each corner to make imshow
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Hi Jeff, I finally found out how to fill my figure with a background color using axes.set_axis_bgcolor(color), but I'm facing the following problem now: How could I get the lower color of a colormap? This is quite undocumented and I don’t know the colormap properties I could use for that I know there must be an accessible value somewhere, like for the ax.get_yticklabels() you gave me If someone had the clue, my problems would then be completely solved Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: To get the RGBA value associated with a particular data value, just call the colormap as a function as pass it that value. For example import matplotlib.pyplot as plt plt.cm.jet(1) (0.0, 0.0, 0.517825311942959, 1.0) BTW: the 'fill_color' kwarg of drawmapboundary basemap method allows you to set the background color of the map. http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html It fills only the map region (which for some projections, like the orthographic, is not the same as the axes region). -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 23 septembre 2008 20:38 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can easily see where you actually have data. HTH, -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\ urcrnrlon=180,llcrnrlon=-180,resolution='l') x, y = map(Lon, Lat) plt.scatter(x,y,s=25,c=Val,marker='s',edgecolor=None,cmap=plt.cm.winter,vm in=-5,vmax=-1.2, alpha=0.5) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0],fontsize=7,linewidth=0.25) map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=7,linewidth=0.25) map.drawcoastlines(0.25,antialiased=1) plt.title(titre) plt.show() -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED
Re: [Matplotlib-users] Information request
On Thu, Sep 25, 2008 at 7:15 AM, Jeff Whitaker [EMAIL PROTECTED] wrote: De Pauw Antoine wrote: Hi Jeff, I finally found out how to fill my figure with a background color using axes.set_axis_bgcolor(color), but I'm facing the following problem now: How could I get the lower color of a colormap? This is quite undocumented and I don't know the colormap properties I could use for that I know there must be an accessible value somewhere, like for the ax.get_yticklabels() you gave me If someone had the clue, my problems would then be completely solved You can get the lowest color of a colormap by evaluating it at zero, eg In [1]: import matplotlib.cm as cm In [2]: cm.jet(0) Out[2]: (0.0, 0.0, 0.5, 1.0) - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Jeff, Thanks for the tip, it's now working perfectly However, there's still that border with the imshow plot, and I think it would be good to have it transparent There's a zoomed picture I made: http://img218.imageshack.us/img218/5833/imshowborderxz9.png You see the shadow around the data... It would be nice for next releases of Matplotlib to get rid of that, but I'm not able to patch it myself or so... I know there's still a lot of work with the lib but keep the good work, it is really fantastic Thanks for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I thought we agreed that it's not an imshow bug - but rather due to the griddata gridding procedure returning missing values outside the convex hull of the input data. Do you disagree? I see no such border around an imshow plot that contains no missing values. If you shrink the size of the map plotting region so it's fully within the convex hull of the data, the border disappears. -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 25 septembre 2008 14:15 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I finally found out how to fill my figure with a background color using axes.set_axis_bgcolor(color), but I'm facing the following problem now: How could I get the lower color of a colormap? This is quite undocumented and I don’t know the colormap properties I could use for that I know there must be an accessible value somewhere, like for the ax.get_yticklabels() you gave me If someone had the clue, my problems would then be completely solved Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: To get the RGBA value associated with a particular data value, just call the colormap as a function as pass it that value. For example import matplotlib.pyplot as plt plt.cm.jet(1) (0.0, 0.0, 0.517825311942959, 1.0) BTW: the 'fill_color' kwarg of drawmapboundary basemap method allows you to set the background color of the map. http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html It fills only the map region (which for some projections, like the orthographic, is not the same as the axes region). -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 23 septembre 2008 20:38 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can easily see where you actually have data. HTH, -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\ urcrnrlon=180,llcrnrlon=-180,resolution='l') x, y = map(Lon, Lat) plt.scatter(x,y,s=25,c=Val,marker='s',edgecolor=None,cmap=plt.cm.winter,vm in=-5,vmax=-1.2, alpha=0.5) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0
Re: [Matplotlib-users] Information request
Jeff, Thanks for your help, I now know that it's a missing data problem However, I need to make, for example, orthographic maps of ozone centered on the polar region, and there is no possibility to cut the unaesthetic regions of the plot in that case I'll try to plot a data grid containing the weaker value for all points before the actual data I'm plotting, to see if I can set the background color and avoid these gaps If you know of any method to do that instead of plotting a whole grid before anything else, please tell I have to thank you for your help and I wonder how you find the time required to work on that mailing list Have a nice day, Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 23 septembre 2008 20:38 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can easily see where you actually have data. HTH, -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\ urcrnrlon=180,llcrnrlon=-180,resolution='l') x, y = map(Lon, Lat) plt.scatter(x,y,s=25,c=Val,marker='s',edgecolor=None,cmap=plt.cm.winter,vm in=-5,vmax=-1.2, alpha=0.5) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0],fontsize=7,linewidth=0.25) map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=7,linewidth=0.25) map.drawcoastlines(0.25,antialiased=1) plt.title(titre) plt.show() -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED] Sent: jeudi 18 septembre 2008 17:23 To: Jeff Whitaker; [EMAIL PROTECTED] Cc: 'John Hunter'; 'Matplotlib Users' Subject: re:Re: [Matplotlib-users] Information request Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think
Re: [Matplotlib-users] Information request
Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED] Sent: jeudi 18 septembre 2008 17:23 To: Jeff Whitaker; [EMAIL PROTECTED] Cc: 'John Hunter'; 'Matplotlib Users' Subject: re:Re: [Matplotlib-users] Information request Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think it's the imshow layer that is not totally transparent on the map background.. I tried every trick I could for example to put some zero-valued points on each corner to make imshow interpolate correctly the sides, but that doesn't make any difference De Pauw Antoine wrote: Jeff, Yes they disappear, and they fluctuate with the interpolation method used For example, nearest interpolation don't show the line Also, if I reduce the grid resolution, the line is thicker, and if I use a masked array to get rid of undesired values, the border shows really strongly Here's an example everyone will see: http://img225.imageshack.us/img225/2671/testfigep2.png (everything except the clouds is noise) Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Sorry to seem dense, but I don't see anything wrong with that plot. I see a white border along the north and south pole, but I intrepret that to be missing values. However, my eyes are notoriously bad. I'd like to be to run a script that generates the artifacts myself, so I can zoom in and see the problem myself. Does the griddata_demo.py script show the same problem for you? -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 19:05 To: John Hunter Cc: De Pauw Antoine; Matplotlib Users Subject: Re: [Matplotlib-users] Information request John Hunter wrote: On Wed, Sep 17, 2008 at 11:54 AM, John Hunter [EMAIL PROTECTED] wrote: Attached is a screenshot (zoom.png) from the gimp, zoomed in near the axes border. The black horizontal line is the top axes border, the horizontal grey line is the artifact, the vertical dashed line is a grid line. I don't know if this offers a clue, but if you look at a zoom in the upper right corner, the grey line seems to break up and curve down and to the right (corner.png) Sorry, screwed up corner.png (I attached the original and not the screenshot). The correct screenshot is attached John: OK, now I finally see it. Antoine: Do these artifacts disappear if you comment out the imshow call? -Jeff -- Jeffrey S. Whitaker
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: As I suspected, that gap around the edges of the plot is a consequence of the gridding procedure. griddata doesn't do extrapolation, so there are missing values on the grid outside the convex hull of the input observations. You can either just live with it, or set the plotting region so that it fits entirely within the convex hull of the data. This is what I've done in the modified version of your script below. I've also eliminated the transform_scalar call by gridding directly on the projection grid (instead of gridding to a lat/lon grid, then interpolating to the projection grid). Hope this helps. -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' nx = 360; ny = 180 titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-89,urcrnrlat=89,\ urcrnrlon=179,llcrnrlon=-179,resolution='l') xi=np.linspace(map.xmin,map.xmax,nx) yi=np.linspace(map.ymin,map.ymax,ny) x, y = map(Lon, Lat) zi=mlab.griddata(x,y,Val,xi,yi) map.imshow(zi,plt.cm.winter,vmin=-5,vmax=-1.2) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0],fontsize=7,linewidth=0.25) map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=7,linewidth=0.25) map.drawcoastlines(0.25,antialiased=1) plt.title(titre) plt.show() -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED] Sent: jeudi 18 septembre 2008 17:23 To: Jeff Whitaker; [EMAIL PROTECTED] Cc: 'John Hunter'; 'Matplotlib Users' Subject: re:Re: [Matplotlib-users] Information request Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think it's the imshow layer that is not totally transparent on the map background.. I tried every trick I could for example to put some zero-valued points on each corner to make imshow interpolate correctly the sides, but that doesn't make any difference De Pauw Antoine wrote: Jeff, Yes they disappear, and they fluctuate with the interpolation method used For example, nearest interpolation don't show the line Also, if I reduce the grid resolution, the line is thicker, and if I use a masked array to get
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Jeff, I still don't know how to either remove this artifact or fill my arrays with values to remove empty regions, and I'll make a last attempt to resolve it I uploaded a data file here: http://scqp.ulb.ac.be/20080821.b56 The actual code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to reproduce it, I set the cmap to winter for you to see the gap... setting it to hot will make the grayish border visible in high resolution by zooming it... I think the border (not the empty zone) could be an artifact with the hot colormap Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Here is a version that just plots the pixels directly, without interpolating to a grid. I personally like this better, since you can easily see where you actually have data. HTH, -Jeff from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import os fileName = '20080821.b56' titre='SO2' legende='Delta Brightness Temperature (K)' nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) rawfile=np.fromfile(open(fileName,'rb'),'d',-1) Lat=rawfile[0:nbreligne] Lon=rawfile[nbreligne:nbreligne*2] Val=rawfile[nbreligne*21:nbreligne*22] map=Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\ urcrnrlon=180,llcrnrlon=-180,resolution='l') x, y = map(Lon, Lat) plt.scatter(x,y,s=25,c=Val,marker='s',edgecolor=None,cmap=plt.cm.winter,vmin=-5,vmax=-1.2, alpha=0.5) cb=plt.colorbar(shrink=0.6) cb.ax.set_ylabel(legende,fontsize=11) for t in cb.ax.get_yticklabels(): t.set_fontsize(7) meridians = np.arange(-180,180,60) parallels = np.arange(-90,90,30) map.drawparallels(parallels,labels=[1,0,0,0],fontsize=7,linewidth=0.25) map.drawmeridians(meridians,labels=[0,0,0,1],fontsize=7,linewidth=0.25) map.drawcoastlines(0.25,antialiased=1) plt.title(titre) plt.show() -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: lundi 22 septembre 2008 13:59 To: De Pauw Antoine Cc: 'John Hunter'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, I included here a figure where you'll see the border problem for imshow in my case http://img217.imageshack.us/img217/5240/testfigzp3.png The border wraps at -180 and 180 to form the white line PS: it is atmospheric ice and not SO2, I just omitted to change the title ^^ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I hate to keep repeating myself - but we can't do much if you don't provide a self-contained script, that I can run, which reproduces the problem. My guess is that the line along the dateline, and the point at the South Pole are missing values (which griddata set to missing because they are outside the extent of the data) - but that's just a guess until I can reproduce it. -Jeff -Original Message- From: Antoine De Pauw [mailto:[EMAIL PROTECTED] Sent: jeudi 18 septembre 2008 17:23 To: Jeff Whitaker; [EMAIL PROTECTED] Cc: 'John Hunter'; 'Matplotlib Users' Subject: re:Re: [Matplotlib-users] Information request Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think it's the imshow layer that is not totally transparent on the map background.. I tried every trick I could for example to put some zero-valued points on each corner to make imshow interpolate correctly the sides, but that doesn't make any difference De Pauw Antoine wrote: Jeff, Yes they disappear, and they fluctuate with the interpolation method used For example, nearest interpolation don't show the line Also, if I reduce the grid resolution, the line is thicker, and if I use a masked array to get rid of undesired values, the border shows really strongly Here's an example everyone will see: http://img225.imageshack.us/img225/2671/testfigep2.png (everything except the clouds is noise) Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Sorry to seem dense, but I don't see anything
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Jeff, Yes they disappear, and they fluctuate with the interpolation method used For example, nearest interpolation don't show the line Also, if I reduce the grid resolution, the line is thicker, and if I use a masked array to get rid of undesired values, the border shows really strongly Here's an example everyone will see: http://img225.imageshack.us/img225/2671/testfigep2.png (everything except the clouds is noise) Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Sorry to seem dense, but I don't see anything wrong with that plot. I see a white border along the north and south pole, but I intrepret that to be missing values. However, my eyes are notoriously bad. I'd like to be to run a script that generates the artifacts myself, so I can zoom in and see the problem myself. Does the griddata_demo.py script show the same problem for you? -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 19:05 To: John Hunter Cc: De Pauw Antoine; Matplotlib Users Subject: Re: [Matplotlib-users] Information request John Hunter wrote: On Wed, Sep 17, 2008 at 11:54 AM, John Hunter [EMAIL PROTECTED] wrote: Attached is a screenshot (zoom.png) from the gimp, zoomed in near the axes border. The black horizontal line is the top axes border, the horizontal grey line is the artifact, the vertical dashed line is a grid line. I don't know if this offers a clue, but if you look at a zoom in the upper right corner, the grey line seems to break up and curve down and to the right (corner.png) Sorry, screwed up corner.png (I attached the original and not the screenshot). The correct screenshot is attached John: OK, now I finally see it. Antoine: Do these artifacts disappear if you comment out the imshow call? -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
Jeff, No the example doesn't show that line If I reduce the amount of data, the border will be on every side of the plot I'll show you an orthographic plot with no maskinf tomorrow and you will see the problem easily, it wraps in a white line along the 0° meridian and a white circle in the pole I think it's the imshow layer that is not totally transparent on the map background.. I tried every trick I could for example to put some zero-valued points on each corner to make imshow interpolate correctly the sides, but that doesn't make any difference De Pauw Antoine wrote: Jeff, Yes they disappear, and they fluctuate with the interpolation method used For example, nearest interpolation don't show the line Also, if I reduce the grid resolution, the line is thicker, and if I use a masked array to get rid of undesired values, the border shows really strongly Here's an example everyone will see: http://img225.imageshack.us/img225/2671/testfigep2.png (everything except the clouds is noise) Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Sorry to seem dense, but I don't see anything wrong with that plot. I see a white border along the north and south pole, but I intrepret that to be missing values. However, my eyes are notoriously bad. I'd like to be to run a script that generates the artifacts myself, so I can zoom in and see the problem myself. Does the griddata_demo.py script show the same problem for you? -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 19:05 To: John Hunter Cc: De Pauw Antoine; Matplotlib Users Subject: Re: [Matplotlib-users] Information request John Hunter wrote: On Wed, Sep 17, 2008 at 11:54 AM, John Hunter [EMAIL PROTECTED] wrote: Attached is a screenshot (zoom.png) from the gimp, zoomed in near the axes border. The black horizontal line is the top axes border, the horizontal grey line is the artifact, the vertical dashed line is a grid line. I don't know if this offers a clue, but if you look at a zoom in the upper right corner, the grey line seems to break up and curve down and to the right (corner.png) Sorry, screwed up corner.png (I attached the original and not the screenshot). The correct screenshot is attached John: OK, now I finally see it. Antoine: Do these artifacts disappear if you comment out the imshow call? -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
Hi John, I used your example with the missing .ax to modify these font sizes and it works nicely Anyway, by investigation, I found that there is no way of interpolation using scattered data I tried to figure out how to grid my values and use imshow or pcolor, but with no success yet.. Could you explain me how I could do to grid, for example, that data: Lat[] (double array containing latitudes) Lon[] (double array containing longitudes) Val[] (double array containing values) Each of the arrays having the same size, and Val[1] has latitude Lat[1] and longitude Lon[1], and so on, and the coordinates are completely unordered When I try to use griddata and use imshow or pcolor with the output array, my figure is blank A simple example or guideline would do, I guess, as I've already gained a good knowledge of the language Thanks in advance PS: Here's the code snippet: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: John Hunter [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:00 To: De Pauw Antoine Cc: Eric Firing; Jeff Whitaker; Matplotlib Users Subject: Re: [Matplotlib-users] Information request On Wed, Sep 17, 2008 at 3:28 AM, De Pauw Antoine [EMAIL PROTECTED] wrote: The image generated is here: http://www.kirikoo.net/images/5shrad-20080917-102544.png Also, I couldn't find any way to reduce the colorbar font size The colorbar method returns a matplotlib.colorbar.Colorbar instance, which has matplotlib.axes.Axes instance stored as an attribute. Thus you can do: cb = colorbar(something) for t in cb.get_yticklabels(): t.set_fontsize(10) Eric: when you get some time, could you add docstrings to colorbar which document the publicly accessible attributes? JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Hi John, I used your example with the missing .ax to modify these font sizes and it works nicely Anyway, by investigation, I found that there is no way of interpolation using scattered data I tried to figure out how to grid my values and use imshow or pcolor, but with no success yet.. Could you explain me how I could do to grid, for example, that data: Lat[] (double array containing latitudes) Lon[] (double array containing longitudes) Val[] (double array containing values) Each of the arrays having the same size, and Val[1] has latitude Lat[1] and longitude Lon[1], and so on, and the coordinates are completely unordered When I try to use griddata and use imshow or pcolor with the output array, my figure is blank A simple example or guideline would do, I guess, as I've already gained a good knowledge of the language Thanks in advance PS: Here's the code snippet: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Griddata should work fine. Your code snippet does not try to use griddata, so I can't guess what is wrong. Let me suggest again - please post complete, self-contained examples that demonstrate your problem. Did you look at the griddata_demo.py example? -Jeff -Original Message- From: John Hunter [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:00 To: De Pauw Antoine Cc: Eric Firing; Jeff Whitaker; Matplotlib Users Subject: Re: [Matplotlib-users] Information request On Wed, Sep 17, 2008 at 3:28 AM, De Pauw Antoine [EMAIL PROTECTED] wrote: The image generated is here: http://www.kirikoo.net/images/5shrad-20080917-102544.png Also, I couldn't find any way to reduce the colorbar font size The colorbar method returns a matplotlib.colorbar.Colorbar instance, which has matplotlib.axes.Axes instance stored as an attribute. Thus you can do: cb = colorbar(something) for t in cb.get_yticklabels(): t.set_fontsize(10) Eric: when you get some time, could you add docstrings to colorbar which document the publicly accessible attributes? JDH -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
Jeff, Sorry, I have forgotten to add this piece of code since I'm continually adding/removing bits This code comes instead of the scatter method and colorbar things: xi=np.linspace(-180,180,360) yi=np.linspace(-90,90,180) zi=griddata(Lon,Lat,Val_masked,xi,yi) Is it done the good way? If it is, what's the best method to display it with interpolation? Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:40 To: De Pauw Antoine Cc: 'John Hunter'; 'Eric Firing'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi John, I used your example with the missing .ax to modify these font sizes and it works nicely Anyway, by investigation, I found that there is no way of interpolation using scattered data I tried to figure out how to grid my values and use imshow or pcolor, but with no success yet.. Could you explain me how I could do to grid, for example, that data: Lat[] (double array containing latitudes) Lon[] (double array containing longitudes) Val[] (double array containing values) Each of the arrays having the same size, and Val[1] has latitude Lat[1] and longitude Lon[1], and so on, and the coordinates are completely unordered When I try to use griddata and use imshow or pcolor with the output array, my figure is blank A simple example or guideline would do, I guess, as I've already gained a good knowledge of the language Thanks in advance PS: Here's the code snippet: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Griddata should work fine. Your code snippet does not try to use griddata, so I can't guess what is wrong. Let me suggest again - please post complete, self-contained examples that demonstrate your problem. Did you look at the griddata_demo.py example? -Jeff -Original Message- From: John Hunter [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:00 To: De Pauw Antoine Cc: Eric Firing; Jeff Whitaker; Matplotlib Users Subject: Re: [Matplotlib-users] Information request On Wed, Sep 17, 2008 at 3:28 AM, De Pauw Antoine [EMAIL PROTECTED] wrote: The image generated is here: http://www.kirikoo.net/images/5shrad-20080917-102544.png Also, I couldn't find any way to reduce the colorbar font size The colorbar method returns a matplotlib.colorbar.Colorbar instance, which has matplotlib.axes.Axes instance stored as an attribute. Thus you can do: cb = colorbar(something) for t in cb.get_yticklabels(): t.set_fontsize(10) Eric: when you get some time, could you add docstrings to colorbar which document the publicly accessible attributes? JDH -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
Jeff, I finally managed to obtain a neat image with imshow and griddata The code snippet is here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ The only problem I have is now a grey line surrounding the plot, as you can see in this low-res sample: http://www.kirikoo.net/images/5shrad-20080917-151205.png I have added zero-value points at the corners of the map, thinking that interpolation simply didn't do its job between the points because of a lack of data, but it's still the same The masked array has been replaced with a replace by zero if superior to -1.2 thing as the border was surrounding masked zone as well Is there a border to imshow? If yes, how to remove it? Also, I tried with aspect='auto' as it seemed to be there for that, but still no progress Thanks for the tips and have a nice evening! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:40 To: De Pauw Antoine Cc: 'John Hunter'; 'Eric Firing'; 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi John, I used your example with the missing .ax to modify these font sizes and it works nicely Anyway, by investigation, I found that there is no way of interpolation using scattered data I tried to figure out how to grid my values and use imshow or pcolor, but with no success yet.. Could you explain me how I could do to grid, for example, that data: Lat[] (double array containing latitudes) Lon[] (double array containing longitudes) Val[] (double array containing values) Each of the arrays having the same size, and Val[1] has latitude Lat[1] and longitude Lon[1], and so on, and the coordinates are completely unordered When I try to use griddata and use imshow or pcolor with the output array, my figure is blank A simple example or guideline would do, I guess, as I've already gained a good knowledge of the language Thanks in advance PS: Here's the code snippet: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: Griddata should work fine. Your code snippet does not try to use griddata, so I can't guess what is wrong. Let me suggest again - please post complete, self-contained examples that demonstrate your problem. Did you look at the griddata_demo.py example? -Jeff -Original Message- From: John Hunter [mailto:[EMAIL PROTECTED] Sent: mercredi 17 septembre 2008 13:00 To: De Pauw Antoine Cc: Eric Firing; Jeff Whitaker; Matplotlib Users Subject: Re: [Matplotlib-users] Information request On Wed, Sep 17, 2008 at 3:28 AM, De Pauw Antoine [EMAIL PROTECTED] wrote: The image generated is here: http://www.kirikoo.net/images/5shrad-20080917-102544.png Also, I couldn't find any way to reduce the colorbar font size The colorbar method returns a matplotlib.colorbar.Colorbar instance, which has matplotlib.axes.Axes instance stored as an attribute. Thus you can do: cb = colorbar(something) for t in cb.get_yticklabels(): t.set_fontsize(10) Eric: when you get some time, could you add docstrings to colorbar which document the publicly accessible attributes? JDH -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1FAX : (303)497-6449 325 BroadwayBoulder, CO, USA 80305-3328 - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
On Wed, Sep 17, 2008 at 11:54 AM, John Hunter [EMAIL PROTECTED] wrote: Attached is a screenshot (zoom.png) from the gimp, zoomed in near the axes border. The black horizontal line is the top axes border, the horizontal grey line is the artifact, the vertical dashed line is a grid line. I don't know if this offers a clue, but if you look at a zoom in the upper right corner, the grey line seems to break up and curve down and to the right (corner.png) Sorry, screwed up corner.png (I attached the original and not the screenshot). The correct screenshot is attached attachment: corner.png- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
Jeff, In fact my satellite data is displaying clouds of various gases, and I dont like the fact that empty places are left dark blue (I use jet reversed cmap) By masking data under a certain value, I isolate the clouds and then they are in evidence When I use vmin and vmax I'm able to avoid the colormap rescaling and I keep the cloud's original colour, but then it is the colorbar which poses problems, as there's a part of the bar that is useless I guess what I should do is setting a new colorbar myself, but there again, it is not very easy to understand... that kind of libraries are really occult for a non-scientific IT graduate like me Now for the antialiasing and interpolation, the thing I try to do is making it look less pixeled, I don't need all the points to be interpolated, but just make the existing points smoother to have a smooth, quality figure You have helped me a lot, and I know my questions were beginners ones, so I'll understand if you prefer giving some time to something more interesting Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mardi 16 septembre 2008 13:16 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I have played a bit with Matplotlib since last week, and I may still have some questions for you I have masked my value array so it doesn't draw points under a certain value, but doing this causes the colormap to rescale for the new values Antoine: Don't quite know what you're trying to accomplish, but you can use the vmin/vmax keywords to imshow, pcolor or scatter to scale the colormap to a certain range. Also, take a look at the image_masked.py example to see how to set the 'over/under' color in a colormap. I have tried to set a custom colormap but it isn't the thing to do as data is varying in time So is it possible to avoid the colormap to rescale itself? Also, I had a look at imshow and the interpolation process is really interesting for smooth maps.. does a way to interpolate scattered data exist? If you have the most recent version of matplotlib you can use the griddata function to interpolate scattered data to a regular grid. -Jeff The code I use didn't change since last time, all I did is adding a bit, testing and deleting.. Best regards, Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: vendredi 12 septembre 2008 13:26 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I updated my code snippet and uploaded the image I created with a complete set of data: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ And here's the picture generated: http://www.kirikoo.net/images/5shrad-20080912-105759.png I now understand the process and I'm able to reproduce it for other datasets, but I need to implement some antialiasing for it.. Is it possible to do? Many thanks for your precious help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: If you do from pylab import scatter help(scatter) you will see that scatter takes an antialised keyword antialiasedBoolean or sequence of booleans -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 16:48 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, The map object is from the Basemap type, the only different thing is the Lon,Lat and Val objects which are from the type array instead of lists Anyway, solutions are slowly showing themselves and I thank you all Have a nice day Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: It should not matter if Lon and Lat are python arrays, lists or numpy arrays. The Basemap instance __call__ method handles them all. There must be something else going on. It is always better to post actual code so we can see what is happening and test it ourselves. -Jeff -Original Message
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Jeff, In fact my satellite data is displaying clouds of various gases, and I don’t like the fact that empty places are left dark blue (I use jet reversed cmap) By masking data under a certain value, I isolate the clouds and then they are in evidence When I use vmin and vmax I'm able to avoid the colormap rescaling and I keep the cloud's original colour, but then it is the colorbar which poses problems, as there's a part of the bar that is useless Can you provide a compact example script, completely self-contained, that illustrates the problem with the colorbar? Perhaps by modifying one of the standard mpl examples, such as image_masked.py? From what you have said, I would expect that some combination of masking, using vmin and vmax, and using the special value colors, would work adequately with the present colorbar. Eric - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Information request
De Pauw Antoine wrote: Hi Jeff, I updated my code snippet and uploaded the image I created with a complete set of data: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ And here's the picture generated: http://www.kirikoo.net/images/5shrad-20080912-105759.png I now understand the process and I'm able to reproduce it for other datasets, but I need to implement some antialiasing for it.. Is it possible to do? Many thanks for your precious help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: If you do from pylab import scatter help(scatter) you will see that scatter takes an antialised keyword antialiasedBoolean or sequence of booleans -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 16:48 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, The map object is from the Basemap type, the only different thing is the Lon,Lat and Val objects which are from the type array instead of lists Anyway, solutions are slowly showing themselves and I thank you all Have a nice day Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: It should not matter if Lon and Lat are python arrays, lists or numpy arrays. The Basemap instance __call__ method handles them all. There must be something else going on. It is always better to post actual code so we can see what is happening and test it ourselves. -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 15:29 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Thanks Jeff, This seems to work with csv file types, and I've been experimenting a bit with it However, when I try to implement this with my original code (with binary files), I get an error like that one: Traceback (most recent call last): File C:\Python25\Projects\FigPlot\FigPlot.py, line 39, in module x,y = map(Lon,Lat) TypeError: 'numpy.ndarray' object is not callable I think this is coming from the fact I use array objects to store values... could you confirm it? Antoine: It looks like you the object map is not a Basemap instance, but a numpy array. Try putting 'print type(map)' just ahead of this statement to verify this. I suspect your re-using the name 'map' in your code, overwriting the Basemap class instance. -Jeff Also, I'll see if it is possible to invert color scale and mask everything under a certain value Thanks very much for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 14:10 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I have put the code online with a sample of the data here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to give me some advice as it is quite difficult for someone new in python and scientific computation Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I may have the size of the pixels wrong, and lat/lon transposed, but this is the general idea: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np lats = []; lons = []; data = [] for line in open('pixels.dat'): linesplit = line.split(',') lons.append(float(linesplit[1])) lats.append(float(linesplit[0])) data.append(float(linesplit[2])) map = Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') x,y = map(lons,lats) plt.scatter(x,y,s=25,c=data,marker='s',edgecolor=None,cmap=plt.cm.jet) plt.colorbar(shrink=0.6) map.drawcoastlines() plt.show() -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi
Re: [Matplotlib-users] Information request
Thanks Jeff, Antialiasing is not very useful as my pixel size is small... also, I used octagon shapes to have a smoother picture Now I'm looking for suppressing pixels under (or over) a certain value, but a couple hours of searching and testing didn't help... I'll see Monday if I find some tips Have a nice weekend Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: vendredi 12 septembre 2008 13:26 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I updated my code snippet and uploaded the image I created with a complete set of data: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ And here's the picture generated: http://www.kirikoo.net/images/5shrad-20080912-105759.png I now understand the process and I'm able to reproduce it for other datasets, but I need to implement some antialiasing for it.. Is it possible to do? Many thanks for your precious help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: If you do from pylab import scatter help(scatter) you will see that scatter takes an antialised keyword antialiasedBoolean or sequence of booleans -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 16:48 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Jeff, The map object is from the Basemap type, the only different thing is the Lon,Lat and Val objects which are from the type array instead of lists Anyway, solutions are slowly showing themselves and I thank you all Have a nice day Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: It should not matter if Lon and Lat are python arrays, lists or numpy arrays. The Basemap instance __call__ method handles them all. There must be something else going on. It is always better to post actual code so we can see what is happening and test it ourselves. -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 15:29 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Thanks Jeff, This seems to work with csv file types, and I've been experimenting a bit with it However, when I try to implement this with my original code (with binary files), I get an error like that one: Traceback (most recent call last): File C:\Python25\Projects\FigPlot\FigPlot.py, line 39, in module x,y = map(Lon,Lat) TypeError: 'numpy.ndarray' object is not callable I think this is coming from the fact I use array objects to store values... could you confirm it? Antoine: It looks like you the object map is not a Basemap instance, but a numpy array. Try putting 'print type(map)' just ahead of this statement to verify this. I suspect your re-using the name 'map' in your code, overwriting the Basemap class instance. -Jeff Also, I'll see if it is possible to invert color scale and mask everything under a certain value Thanks very much for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 14:10 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I have put the code online with a sample of the data here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to give me some advice as it is quite difficult for someone new in python and scientific computation Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I may have the size of the pixels wrong, and lat/lon transposed, but this is the general idea
Re: [Matplotlib-users] Information request
Hi Jeff, I have put the code online with a sample of the data here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to give me some advice as it is quite difficult for someone new in python and scientific computation Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 10 septembre 2008 16:45 To: Antoine De Pauw Cc: Matplotlib Users Subject: Re: Information request Antoine De Pauw wrote: Thanks Jeff, In fact my points are arranged in three unsorted arrays, with a simple scheme (thats why I couldn't plot them with imshow and others) arrays: [lat][lon][val] [-10][ 17][0.3] [ 37][ 23][3.7] ... ... ... and so for many rows... what I have to do is looping through my arrays like that while i rowcount: plot_to_map(lat[i],lon[i],val[i]) it is evidently an idea of how it could be done easily but my knowledge of these libraries is too weak for me to figure out how to do it my data comes from huge binary files but is extremely simple, so it would be really easy for anyone to help me as the problem itself is how to put unsorted points on the map with latitude and longitude coordinates Antoine: You haven't said if your data forms a rectangular array. If so, you can build a 2-d array from the input file and plot it with imshow. If not, you can still plug the elements into a 2-d masked array, leaving the missing pixels masked. You say the points are 'unsorted', does that mean they are randomly distributed and do not form a rectangular grid? It would really be much easier to help if you gave us more information, such as how the data is structured, what the pixel footprint is, etc. Perhaps you could post the binary file on an ftp site somewhere with code to read it. Also, please hit 'reply all' when replying, so the matplotlib users mailing list is CC'ed. -Jeff Antoine De Pauw wrote: Sir, I'm sorry, as english is not my mothertongue and it is sometimes difficult to be understandable. All is in the script I gave to you initially, except the point drawing code which would be useless as it is proven not to work (I dont know the method to do it). What I have is a map, and a set of pixels I have to put on it with geographic coordinates. I cannot find the right method to put colour pixels on the map, that's the problem. I have that map in miller projection, and three arrays containing respectively latitude, longitude and satellite measured value. What I need to obtain is something approximately like this: http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 _00_lr.gif but with the basemap toolkit. So, my question is: how could I do to plot a coloured pixel at coordinates lat:lon on that map? If I have just the method to project a geographic coordinate on the map and put a coloured pixel at the right place, all is done and I just have to loop my arrays... Also, I would have to implement some antialiasing on the map. Antoine: Are the pixels arranged on a regular grid - or are they randomly distributed? If they are on a grid, it's easy (using pcolor or imshow). If you could send me your data I may be able to get you started. (I'm cc'ing the matplotlib list so others can join in the discussion). -Jeff If this is not possible to do it in a simple and explainable way, please tell me and I'll continue using matlab or searching for the bit of code which will save me Anyway, I have to thank you for your interest to help me.. Many thanks, Antoine De Pauw Antoine De Pauw wrote: Hi, and thanks for the answer In fact, what I do is reading a binary file to obtain 3 arrays (Lat,Lon,Val) describing geographic points which are associated by index (like point 1 is Lat[0]:Lon[0] with value Val[0]) What I need to do is to plot some points on the map (miller projection for most) based on latitude and longitude, to obtain a colour map (points are unordered, it is from IASI satellite computations) I'm able to create a map, draw simple things on it, etc but the problem I have is any method I try for plotting points is failing, either pcolor, pcolormesh, imshow, etc. When I found your post on that mailing list, I figured out that you might have the experience and skills to easily explain to me how to manipulate these points and plot them on the map, as there's like no help on the web except standard examples... Please tell me if this is possible for you to give me some tips, or if it takes too much of your time just advice me some lectures Best regards, De Pauw Antoine Antoine: It would really help to have a script demonstrating your problem. It sounds to me like you want to plot markers
Re: [Matplotlib-users] Information request
Thanks Jeff, This seems to work with csv file types, and I've been experimenting a bit with it However, when I try to implement this with my original code (with binary files), I get an error like that one: Traceback (most recent call last): File C:\Python25\Projects\FigPlot\FigPlot.py, line 39, in module x,y = map(Lon,Lat) TypeError: 'numpy.ndarray' object is not callable I think this is coming from the fact I use array objects to store values... could you confirm it? Also, I'll see if it is possible to invert color scale and mask everything under a certain value Thanks very much for your help! Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: jeudi 11 septembre 2008 14:10 To: De Pauw Antoine Cc: 'Matplotlib Users' Subject: Re: [Matplotlib-users] Information request De Pauw Antoine wrote: Hi Jeff, I have put the code online with a sample of the data here: http://snipplr.com/view/8307/map-plotting-python-code-temporary/ I hope you'll be able to give me some advice as it is quite difficult for someone new in python and scientific computation Antoine De Pauw Collaborateur de recherches, Informatique - Research collaborator, IT Laboratoire de chimie quantique et photophysique - Quantum chemistry and photophysics laboratory Université Libre de Bruxelles - ULB Antoine: I may have the size of the pixels wrong, and lat/lon transposed, but this is the general idea: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np lats = []; lons = []; data = [] for line in open('pixels.dat'): linesplit = line.split(',') lons.append(float(linesplit[1])) lats.append(float(linesplit[0])) data.append(float(linesplit[2])) map = Basemap(projection='mill',llcrnrlat=min(lats)-5,urcrnrlat=max(lats)+5,\ urcrnrlon=max(lons)+5,llcrnrlon=min(lons)-5,resolution='l') x,y = map(lons,lats) plt.scatter(x,y,s=25,c=data,marker='s',edgecolor=None,cmap=plt.cm.jet) plt.colorbar(shrink=0.6) map.drawcoastlines() plt.show() -Jeff -Original Message- From: Jeff Whitaker [mailto:[EMAIL PROTECTED] Sent: mercredi 10 septembre 2008 16:45 To: Antoine De Pauw Cc: Matplotlib Users Subject: Re: Information request Antoine De Pauw wrote: Thanks Jeff, In fact my points are arranged in three unsorted arrays, with a simple scheme (thats why I couldn't plot them with imshow and others) arrays: [lat][lon][val] [-10][ 17][0.3] [ 37][ 23][3.7] ... ... ... and so for many rows... what I have to do is looping through my arrays like that while i rowcount: plot_to_map(lat[i],lon[i],val[i]) it is evidently an idea of how it could be done easily but my knowledge of these libraries is too weak for me to figure out how to do it my data comes from huge binary files but is extremely simple, so it would be really easy for anyone to help me as the problem itself is how to put unsorted points on the map with latitude and longitude coordinates Antoine: You haven't said if your data forms a rectangular array. If so, you can build a 2-d array from the input file and plot it with imshow. If not, you can still plug the elements into a 2-d masked array, leaving the missing pixels masked. You say the points are 'unsorted', does that mean they are randomly distributed and do not form a rectangular grid? It would really be much easier to help if you gave us more information, such as how the data is structured, what the pixel footprint is, etc. Perhaps you could post the binary file on an ftp site somewhere with code to read it. Also, please hit 'reply all' when replying, so the matplotlib users mailing list is CC'ed. -Jeff Antoine De Pauw wrote: Sir, I'm sorry, as english is not my mothertongue and it is sometimes difficult to be understandable. All is in the script I gave to you initially, except the point drawing code which would be useless as it is proven not to work (I dont know the method to do it). What I have is a map, and a set of pixels I have to put on it with geographic coordinates. I cannot find the right method to put colour pixels on the map, that's the problem. I have that map in miller projection, and three arrays containing respectively latitude, longitude and satellite measured value. What I need to obtain is something approximately like this: http://www.oma.be/BIRA-IASB/Molecules/SO2archive/info/background/so2sc200703 _00_lr.gif but with the basemap toolkit. So, my question is: how could I do to plot a coloured pixel at coordinates lat:lon on that map? If I have just