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: How big are the pixels? Is the text file lon,lat,data or lat,lon,data? -Jeff > 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 representing a >>>>> set of points - for that you should use the scatter method. pcolor, >>>>> pcolormesh and friends are for plotting gridded data. >>>>> >>>>> -Jeff >>>>> >>>>> >>>>>> >>>>>> >>>>>> >>>>>>> De Pauw Antoine wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>>> Dear sir, >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> I’m currently trying to improve our plotting tools here at the >>>>>>>> > “Quantum > >>>>>>>> Chemistry and Photophysics” section of the Université Libre de >>>>>>>> > > >>>>>>>> Bruxelles, and I ran, after many time passed at searching for a >>>>>>>> solution, on an explanation from you here: >>>>>>>> >>>>>>>> > http://www.nabble.com/Re:-matplotlib-basemap-question-tt17759370.html > >>>>>>>> >>>>>>>> >>>>>>>> It seems that you could help me find a solution, as I cannot plot >>>>>>>> > any > >>>>>>>> points on maps. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Could you please tell me what I could do to plot data in a simple >>>>>>>> > way, > >>>>>>>> assuming I have 3 unordered arrays containing respectively latitude, >>>>>>>> > > >>>>>>>> longitude and values to plot? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Some tips would be very nice from you as any method I have tried so >>>>>>>> > far > >>>>>>>> give me some errors… >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thank you very much in advance, >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Best regards, >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> PS: I give you the code I’m using currently, missing the >>>>>>>> > plotting part > >>>>>>>> >>>>>>>> >>>>>>>> from mpl_toolkits.basemap import Basemap >>>>>>>> >>>>>>>> from numpy import * >>>>>>>> >>>>>>>> from scipy.io.numpyio import fread >>>>>>>> >>>>>>>> import matplotlib.pyplot as plt >>>>>>>> >>>>>>>> import numpy as np >>>>>>>> >>>>>>>> import os >>>>>>>> >>>>>>>> import sys >>>>>>>> >>>>>>>> import array >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> fileName="c:/20080821.b56" >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> print('preparing map') >>>>>>>> >>>>>>>> map = >>>>>>>> >>>>>>>> > Basemap(projection='mill',lat_0=0,lon_0=0,resolution='i',area_thresh=30000.) > >>>>>>>> map.drawcoastlines(0.5,antialiased=1) >>>>>>>> >>>>>>>> map.drawmapboundary() >>>>>>>> >>>>>>>> #map.drawmeridians(np.arange(-180,180,60),linewidth=0.5, >>>>>>>> labels=np.arange(-180,180,60), labelstyle="+/-") >>>>>>>> >>>>>>>> #map.drawparallels(np.arange(-90,90,30), linewidth=0.5, >>>>>>>> labels=np.arange(-180,180,30), labelstyle="+/-") >>>>>>>> >>>>>>>> print('reading binary data') >>>>>>>> >>>>>>>> nbreligne=long(os.stat(fileName)[6])/(8*int(fileName[-2:])) >>>>>>>> >>>>>>>> Lat=zeros(nbreligne) >>>>>>>> >>>>>>>> Lon=zeros(nbreligne) >>>>>>>> >>>>>>>> Val=zeros(nbreligne) >>>>>>>> >>>>>>>> rawfile=fromfile(open(fileName,'rb'),'d',-1) >>>>>>>> >>>>>>>> Lat=rawfile[0:nbreligne] >>>>>>>> >>>>>>>> Lon=rawfile[nbreligne:nbreligne*2] >>>>>>>> >>>>>>>> Val=rawfile[nbreligne*21:nbreligne*22] >>>>>>>> >>>>>>>> print('shifting latitudes and projecting to map') >>>>>>>> >>>>>>>> i=0 >>>>>>>> >>>>>>>> while i < nbreligne: >>>>>>>> >>>>>>>> if(Lon[i]>180): >>>>>>>> >>>>>>>> print(Lon[i]) >>>>>>>> >>>>>>>> Lon[i]-=360 >>>>>>>> >>>>>>>> print(Lon[i]) >>>>>>>> >>>>>>>> i+=1 >>>>>>>> >>>>>>>> print('plotting data') >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> #plotting code comes here >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> Antoine: If you send me a self-contained script that produces the >>>>>>> problem you see, I can help you debug it. As it stands now, I have >>>>>>> > very > >>>>>>> little to work with - it could be your plotting commands, or it could >>>>>>> > be > >>>>>>> your data. >>>>>>> >>>>>>> -Jeff >>>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> print('saving map') >>>>>>>> >>>>>>>> plt.savefig("testfig.png",dpi=600) >>>>>>>> >>>>>>>> print('done') >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> *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 <http://ww.ulb.ac.be/>* >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> -- >>>>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>>>> Meteorologist FAX : (303)497-6449 >>>>>>> NOAA/OAR/PSD R/PSD1 Email : [EMAIL PROTECTED] >>>>>>> 325 Broadway Office : Skaggs Research Cntr 1D-113 >>>>>>> Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> -- >>>>> Jeffrey S. Whitaker Phone : (303)497-6313 >>>>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>>>> 325 Broadway Boulder, CO, USA 80305-3328 >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> -- >>> Jeffrey S. Whitaker Phone : (303)497-6313 >>> NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 >>> 325 Broadway Boulder, CO, USA 80305-3328 >>> >>> >>> >>> >> > > > -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, 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=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users