From gr.maravelias at gmail.com Fri Nov 4 09:56:21 2011 From: gr.maravelias at gmail.com (Grigoris Maravelias) Date: Fri, 04 Nov 2011 15:56:21 +0200 Subject: [AstroPy] question on matplotlib's loadtxt Message-ID: <4EB3EF05.10501@gmail.com> Hello to all! I would like to ask about an error I face with matplotlib's loadtxt... Suppose that we have a file (called "test.test") with 6 columns like: 1496548. 862.235400937 14.008 0 20110523.201416 tth*g 1690289. 919.424007603 13.875 0 20110523.221527 hgf4 1667241. 996.262754039 13.890 0 20110524.001639 nb.mj 739181.6 881.1753527 14.774 0 20110524.010203 vbfhg When I use x, y = loadtxt('test.test', unpack=True, usecols=(0,1), dtype=(float,float)) it prints normally the first and second column. If I add another column like: x, y, z = loadtxt('test.test', unpack=True,usecols=(0,1,3), dtype=(float,float,float)) the output is this: File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in loadtxt dtype = np.dtype(dtype) TypeError: data type not understood Even if I use a dictionary, like: dt = dtype({'names':['n1','n2','n3'],'formats':[float,float,float]}) x, y, z = loadtxt('test.test', unpack=True, usecols=(0,1,2) , dtype=dt) the output is the same as previous. Additionaly, when I am trying to load the last column as strings: x, y = loadtxt('test.test', delimiter=' ', unpack=True,usecols=(0,5), dtype=(float,'S5')) I get this error: File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in loadtxt dtype = np.dtype(dtype) ValueError: mismatch in size of old and new data-descriptor What am I doing wrong ? I am sorry if it is something really obvious ... but I am unable to find it... Thanks for your time! Grigoris From marquett at iap.fr Fri Nov 4 10:45:06 2011 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Fri, 4 Nov 2011 15:45:06 +0100 Subject: [AstroPy] A question about multiprocessing Message-ID: Dear Python gurus, I'm not sure to be on the right mailing list, but I have the following problem: I have this code ran from Eclipse/PyDev: import multiprocessing as multi def CatDistort(queue): for Image in iter(queue.get, 'STOP'): etc... queue = multi.Queue() for Image in glob.glob(DirImg + '*r.sdf'): queue.put(Image) print os.path.basename(Image), 'queued' queue.put('STOP') Jobs = [] for i in range(NPROC): proc= multi.Process(target=CatDistort, args=[queue]) Jobs.append(proc) proc.start() for job in Jobs: job.join(360) print 'Process completed' exit(0) The target and the queue work well, but the process never terminates. In other words, the final print is never displayed. Any hint ? Thanks for your help, Cheers Jean-Baptiste -------------- next part -------------- An HTML attachment was scrubbed... URL: From miguel.deval at gmail.com Fri Nov 4 10:56:16 2011 From: miguel.deval at gmail.com (Miguel de Val-Borro) Date: Fri, 4 Nov 2011 15:56:16 +0100 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: <4EB3EF05.10501@gmail.com> References: <4EB3EF05.10501@gmail.com> Message-ID: <20111104145616.GA10435@poincare.pc.linmpi.mpg.de> Hi Grigoris, On Fri, Nov 04, 2011 at 03:56:21PM +0200, Grigoris Maravelias wrote: > Suppose that we have a file (called "test.test") with 6 columns like: > > 1496548. 862.235400937 14.008 0 20110523.201416 tth*g > 1690289. 919.424007603 13.875 0 20110523.221527 hgf4 > 1667241. 996.262754039 13.890 0 20110524.001639 nb.mj > 739181.6 881.1753527 14.774 0 20110524.010203 vbfhg > > When I use > x, y = loadtxt('test.test', unpack=True, usecols=(0,1), dtype=(float,float)) > > it prints normally the first and second column. > If I add another column like: > > x, y, z = loadtxt('test.test', unpack=True,usecols=(0,1,3), > dtype=(float,float,float)) This seems to work because the default dtype in loadtxt is float: x, y, z = numpy.loadtxt('test.test', unpack=True,usecols=(0,1,3)) > Additionaly, when I am trying to load the last column as strings: > x, y = loadtxt('test.test', delimiter=' ', unpack=True,usecols=(0,5), > dtype=(float,'S5')) > > I get this error: > File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in > loadtxt > dtype = np.dtype(dtype) > ValueError: mismatch in size of old and new data-descriptor I'm not sure about this error message. I suggest that you try numpy.genfromtxt which is a very convenient function to read text data from a file into a recarray. There are several examples with mixed data types in the documentation. For example specifying the dtypes: data = numpy.genfromtxt('test.test', dtype="f8,f8,f8,f8,f8,S5") Then the last column could be accessed as data['f5'] Miguel From derek at astro.physik.uni-goettingen.de Fri Nov 4 11:14:15 2011 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Fri, 4 Nov 2011 16:14:15 +0100 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: <4EB3EF05.10501@gmail.com> References: <4EB3EF05.10501@gmail.com> Message-ID: <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> Hi Grigoris, > Hello to all! I would like to ask about an error I face with > matplotlib's loadtxt... > > Suppose that we have a file (called "test.test") with 6 columns like: > > 1496548. 862.235400937 14.008 0 20110523.201416 tth*g > 1690289. 919.424007603 13.875 0 20110523.221527 hgf4 > 1667241. 996.262754039 13.890 0 20110524.001639 nb.mj > 739181.6 881.1753527 14.774 0 20110524.010203 vbfhg > > When I use > x, y = loadtxt('test.test', unpack=True, usecols=(0,1), dtype=(float,float)) > > it prints normally the first and second column. > If I add another column like: > > x, y, z = loadtxt('test.test', unpack=True,usecols=(0,1,3), > dtype=(float,float,float)) > > the output is this: > File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in > loadtxt > dtype = np.dtype(dtype) > TypeError: data type not understood > I don't quit understand that part, I admit - dtype only takes a single type or pairs of names and types, so it would seem the first case actually only worked by accident: In [193]: np.dtype((float,float)) Out[193]: dtype('float64') I have no idea how it interprets the second float, but as you see it has no effect anyway. You could in fact get the same result with 'usecols=[0,1,3], dtype=float' which will simply apply the dtype to all columns (and is the default already...). > > Even if I use a dictionary, like: > dt = dtype({'names':['n1','n2','n3'],'formats':[float,float,float]}) > x, y, z = loadtxt('test.test', unpack=True, usecols=(0,1,2) , dtype=dt) > > the output is the same as previous. > No things are getting strange - the above is the correct (and I think, only) way to define dtypes with different formats - np.dtype([('n1',float),('n2',float),('n3',float)]) would be equivalent. As there is no error on the first line (i.e., dt is a valid dtype), this seems to be a bug in loadtxt. Could you check what happens if you try the above without the 'unpack' option? Should return a structured array with the 3 fields 'n1','n2','n3'... Also (as loadtxt is actually part of numpy), which is your installed version of numpy (numpy.__version__ or np.__version__, you may have to re-import it as pylab unfortunately imports everything into one namespace). I recall that there have been issues with unpacking structured arrays prior to 1.6 or 1.6.1. > Additionaly, when I am trying to load the last column as strings: > x, y = loadtxt('test.test', delimiter=' ', unpack=True,usecols=(0,5), > dtype=(float,'S5')) > > I get this error: > File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in > loadtxt > dtype = np.dtype(dtype) > ValueError: mismatch in size of old and new data-descriptor > > > What am I doing wrong ? I am sorry if it is something really obvious ... > but I am unable to find it... Similar problem - this ought to work with dtype=[('n1', 'f'), ('n6','S5')] ; but it might be broken in the same way as above - if you can update to numpy 1.6.x, you should hopefully be set. HTH, Derek From erin.sheldon at gmail.com Fri Nov 4 11:35:28 2011 From: erin.sheldon at gmail.com (Erin Sheldon) Date: Fri, 4 Nov 2011 11:35:28 -0400 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> References: <4EB3EF05.10501@gmail.com> <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> Message-ID: This is the proper syntax, and works for me on your file: loadtxt('tmp/test.txt',dtype=[('x','f8'),('s','S5')], usecols=[0,5]) You need to give a proper dtype with full field description. -e On Fri, Nov 4, 2011 at 11:14 AM, Derek Homeier wrote: > Hi Grigoris, > >> Hello to all! ?I would like to ask about an error I face with >> matplotlib's loadtxt... >> >> Suppose that we have a file (called "test.test") with 6 columns like: >> >> 1496548. ?862.235400937 ?14.008 ?0 ?20110523.201416 ?tth*g >> 1690289. ?919.424007603 ?13.875 ?0 ?20110523.221527 ?hgf4 >> 1667241. ?996.262754039 ?13.890 ?0 ?20110524.001639 ?nb.mj >> 739181.6 ?881.1753527 ?14.774 ?0 ?20110524.010203 ?vbfhg >> >> When I use >> x, y = loadtxt('test.test', unpack=True, usecols=(0,1), dtype=(float,float)) >> >> it prints normally the first and second column. >> If I add another column like: >> >> x, y, z = loadtxt('test.test', unpack=True,usecols=(0,1,3), >> dtype=(float,float,float)) >> >> the output is this: >> ? File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in >> loadtxt >> ? ? dtype = np.dtype(dtype) >> TypeError: data type not understood >> > I don't quit understand that part, I admit - dtype only takes a single type or pairs of names and > types, so it would seem the first case actually only worked by accident: > > In [193]: np.dtype((float,float)) > Out[193]: dtype('float64') > > I have no idea how it interprets the second float, but as you see it has no effect anyway. > You could in fact get the same result with 'usecols=[0,1,3], dtype=float' > which will simply apply the dtype to all columns (and is the default already...). >> >> Even if I use a dictionary, like: >> dt = dtype({'names':['n1','n2','n3'],'formats':[float,float,float]}) >> x, y, z = loadtxt('test.test', unpack=True, usecols=(0,1,2) , dtype=dt) >> >> the output is the same as previous. >> > No things are getting strange - the above is the correct (and I think, only) way to > define dtypes with different formats - > np.dtype([('n1',float),('n2',float),('n3',float)]) > would be equivalent. As there is no error on the first line (i.e., dt is a valid dtype), > this seems to be a bug in loadtxt. Could you check what happens if you try the > above without the 'unpack' option? Should return a structured array with the 3 > fields 'n1','n2','n3'... > Also (as loadtxt is actually part of numpy), which is your installed version of numpy > (numpy.__version__ or np.__version__, you may have to re-import it as pylab > unfortunately imports everything into one namespace). I recall that there have > been issues with unpacking structured arrays prior to 1.6 or 1.6.1. > >> Additionaly, when I am trying to load the last column as strings: >> x, y = loadtxt('test.test', delimiter=' ?', unpack=True,usecols=(0,5), >> dtype=(float,'S5')) >> >> I get this error: >> ? File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in >> loadtxt >> ? ? dtype = np.dtype(dtype) >> ValueError: mismatch in size of old and new data-descriptor >> >> >> What am I doing wrong ? I am sorry if it is something really obvious ... >> but I am unable to find it... > > Similar problem - this ought to work with dtype=[('n1', 'f'), ('n6','S5')] ; but it might > be broken in the same way as above - if you can update to numpy 1.6.x, you > should hopefully be set. > > HTH, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Derek > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Erin Scott Sheldon Brookhaven National Laboratory From sontag at stsci.edu Fri Nov 4 11:51:37 2011 From: sontag at stsci.edu (Chris Sontag) Date: Fri, 4 Nov 2011 11:51:37 -0400 Subject: [AstroPy] A question about multiprocessing In-Reply-To: References: Message-ID: <4EB40A09.2050905@stsci.edu> Hi Jean-Baptiste, I'm not sure this code is doing what you want. Each of NPROC subprocesses runs CatDistort(), which does some processing on EACH image in your queue. So each image actually gets processed NPROC times (by every subprocess), is that your intention? If not, send one image as the value for the args of CatDistort(). Chris On 11/4/11 10:45 AM, Jean-Baptiste Marquette wrote: > Dear Python gurus, > > I'm not sure to be on the right mailing list, but I have the following problem: > > I have this code ran from Eclipse/PyDev: > > import multiprocessing as multi > > def CatDistort(queue): > for Image in iter(queue.get, 'STOP'): > etc... > > queue = multi.Queue() > > for Image in glob.glob(DirImg + '*r.sdf'): > queue.put(Image) > print os.path.basename(Image), 'queued' > queue.put('STOP') > > Jobs = [] > for i in range(NPROC): > proc= multi.Process(target=CatDistort, args=[queue]) > Jobs.append(proc) > proc.start() > > > for job in Jobs: > job.join(360) > > print'Process completed' > exit(0) > > The target and the queue work well, but the process never terminates. In other words, the final print is never displayed. > > Any hint ? > Thanks for your help, > > Cheers > Jean-Baptiste > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek at astro.physik.uni-goettingen.de Fri Nov 4 11:54:38 2011 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Fri, 4 Nov 2011 16:54:38 +0100 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: References: <4EB3EF05.10501@gmail.com> <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> Message-ID: <9A1221CE-2965-4019-A941-1929823B3885@astro.physik.uni-goettingen.de> On 4 Nov 2011, at 16:35, Erin Sheldon wrote: > This is the proper syntax, and works for me on your file: > > loadtxt('tmp/test.txt',dtype=[('x','f8'),('s','S5')], usecols=[0,5]) > > You need to give a proper dtype with full field description. Yep. But dtype({'names':['n1','n2','n3'], 'formats':[float,float,float]}) is a proper dtype, too, so I am cautious of the outcome (here, with numpy 1.6.1, it works too, of course). Cheers, Derek From beaumont at hawaii.edu Fri Nov 4 11:59:42 2011 From: beaumont at hawaii.edu (Chris Beaumont) Date: Fri, 4 Nov 2011 11:59:42 -0400 Subject: [AstroPy] A question about multiprocessing In-Reply-To: <4EB40A09.2050905@stsci.edu> References: <4EB40A09.2050905@stsci.edu> Message-ID: I suspect you may want to use the Pool() and map functions instead: def process_image(image): do stuff to a single image p = multi.Pool() images = glob.glob(DirImg + '*r.sdf') results = p.map(process_image, images) this just farms out each function call to processors as they become available. cheers, Chris Beaumont On Fri, Nov 4, 2011 at 11:51 AM, Chris Sontag wrote: > Hi Jean-Baptiste, > > I'm not sure this code is doing what you want. Each of NPROC subprocesses > runs CatDistort(), which does some processing on EACH image in your queue. > So each image actually gets processed NPROC times (by every subprocess), is > that your intention? If not, send one image as the value for the args of > CatDistort(). > > Chris > > > On 11/4/11 10:45 AM, Jean-Baptiste Marquette wrote: > > Dear Python gurus, > > I'm not sure to be on the right mailing list, but I have the following > problem: > > I have this code ran from Eclipse/PyDev: > > import multiprocessing as multi > > def CatDistort(queue): > for Image in iter(queue.get, 'STOP'): > etc... > > queue = multi.Queue() > > for Image in glob.glob(DirImg + '*r.sdf'): > queue.put(Image) > print os.path.basename(Image), 'queued' > queue.put('STOP') > > Jobs = [] > for i in range(NPROC): > proc= multi.Process(target=CatDistort, args=[queue]) > Jobs.append(proc) > proc.start() > > > for job in Jobs: > job.join(360) > > print 'Process completed' > exit(0) > > The target and the queue work well, but the process never terminates. In > other words, the final print is never displayed. > > Any hint ? > Thanks for your help, > > Cheers > Jean-Baptiste > > > > _______________________________________________ > AstroPy mailing listAstroPy at scipy.orghttp://mail.scipy.org/mailman/listinfo/astropy > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- ************************************ Chris Beaumont Graduate Student Institute for Astronomy University of Hawaii at Manoa 2680 Woodlawn Drive Honolulu, HI 96822 www.ifa.hawaii.edu/~beaumont ************************************ -------------- next part -------------- An HTML attachment was scrubbed... URL: From fpierfed at stsci.edu Fri Nov 4 12:00:28 2011 From: fpierfed at stsci.edu (Francesco Pierfederici) Date: Fri, 4 Nov 2011 12:00:28 -0400 Subject: [AstroPy] A question about multiprocessing In-Reply-To: References: Message-ID: Hi Jean-Baptiste, A possibly simpler way to do what I *think* you want to do is using multiprocessing.Pool: ------------- #!/usr/bin/env python import multiprocessing as multi def CatDistort(Image): print('Working on Image %s' % (Image)) return('Processed ' + Image) NPROC = 4 Images = 'abcdefghijklmnopqrstuvwxyz' pool = multi.Pool(processes=NPROC) results = pool.map(CatDistort, Images) print 'Process completed' print(results) exit(0) --------------------- But then again I might be misunderstanding what you are trying to accomplish. Cheers, Francesco On Fri, Nov 4, 2011 at 10:45 AM, Jean-Baptiste Marquette wrote: > Dear Python gurus, > I'm not sure to be on the right mailing list, but I have the following > problem: > I have this code ran from Eclipse/PyDev: > import multiprocessing as multi > def CatDistort(queue): > ? ? for Image in iter(queue.get, 'STOP'): > etc... > queue = multi.Queue() > for Image in glob.glob(DirImg + '*r.sdf'): > ? ? queue.put(Image) > ? ? print os.path.basename(Image), 'queued' > queue.put('STOP') > Jobs = [] > for i in range(NPROC): > ? ? proc= multi.Process(target=CatDistort, args=[queue]) > ? ? Jobs.append(proc) > ? ? proc.start() > > > > for job in Jobs: > ? ? job.join(360) > print 'Process completed' > exit(0) > The target and the queue work well, but the process never terminates. In > other words, the final print is never displayed. > Any hint ? > Thanks for your help, > Cheers > Jean-Baptiste > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > From marquett at iap.fr Fri Nov 4 12:05:24 2011 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Fri, 4 Nov 2011 17:05:24 +0100 Subject: [AstroPy] A question about multiprocessing In-Reply-To: <4EB40A09.2050905@stsci.edu> References: <4EB40A09.2050905@stsci.edu> Message-ID: <42A53E81-DCB3-4B63-BB35-CEB9A875FEB9@iap.fr> Le 4 nov. 2011 ? 16:51, Chris Sontag a ?crit : > I'm not sure this code is doing what you want. Each of NPROC subprocesses runs CatDistort(), which does some processing on EACH image in your queue. So each image actually gets processed NPROC times (by every subprocess), is that your intention? If not, send one image as the value for the args of CatDistort(). Hi Chris, No, each image is processed once on one of my 4 processors which are able to manage the queue in such a way. I know that because an xterm with label and given position on the screen is attached to each processor. Thus the queue feeds the available processors sequentially. Cheers JB -------------- next part -------------- An HTML attachment was scrubbed... URL: From marquett at iap.fr Fri Nov 4 12:13:03 2011 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Fri, 4 Nov 2011 17:13:03 +0100 Subject: [AstroPy] A question about multiprocessing In-Reply-To: References: Message-ID: <2B569043-BB0D-421F-8940-4C71C9F00B33@iap.fr> Hi Francesco, I think you're right. I missed the .map method in my previous attempts. Thanks for the recall. Cheers JB Le 4 nov. 2011 ? 17:00, Francesco Pierfederici a ?crit : > Hi Jean-Baptiste, > > A possibly simpler way to do what I *think* you want to do is using > multiprocessing.Pool: > > ------------- > #!/usr/bin/env python > import multiprocessing as multi > > > def CatDistort(Image): > print('Working on Image %s' % (Image)) > return('Processed ' + Image) > > > > NPROC = 4 > Images = 'abcdefghijklmnopqrstuvwxyz' > pool = multi.Pool(processes=NPROC) > > results = pool.map(CatDistort, Images) > > print 'Process completed' > > print(results) > exit(0) > --------------------- > > But then again I might be misunderstanding what you are trying to accomplish. > > Cheers, > Francesco > > > > > > On Fri, Nov 4, 2011 at 10:45 AM, Jean-Baptiste Marquette > wrote: >> Dear Python gurus, >> I'm not sure to be on the right mailing list, but I have the following >> problem: >> I have this code ran from Eclipse/PyDev: >> import multiprocessing as multi >> def CatDistort(queue): >> for Image in iter(queue.get, 'STOP'): >> etc... >> queue = multi.Queue() >> for Image in glob.glob(DirImg + '*r.sdf'): >> queue.put(Image) >> print os.path.basename(Image), 'queued' >> queue.put('STOP') >> Jobs = [] >> for i in range(NPROC): >> proc= multi.Process(target=CatDistort, args=[queue]) >> Jobs.append(proc) >> proc.start() >> >> >> >> for job in Jobs: >> job.join(360) >> print 'Process completed' >> exit(0) >> The target and the queue work well, but the process never terminates. In >> other words, the final print is never displayed. >> Any hint ? >> Thanks for your help, >> Cheers >> Jean-Baptiste >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> From gr.maravelias at gmail.com Fri Nov 4 12:19:41 2011 From: gr.maravelias at gmail.com (Grigoris Maravelias) Date: Fri, 04 Nov 2011 18:19:41 +0200 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: References: <4EB3EF05.10501@gmail.com> <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> Message-ID: <4EB4109D.8000304@gmail.com> Hello! I forgot to mention that I call this through a script ... If I use this: x, y, z = numpy.loadtxt('test.test', unpack=True,usecols=(0,1,3)) without specifying dtype (as float are default) it works. But if I try to use it then it fails: In [7]: dt = dtype({'names':['n1','n2','n3'],'formats':[float,float,float]}) In [8]: x, y, z = loadtxt('test.test', unpack=True, usecols=(0,1,2) , dtype=dt) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/.../ in () ValueError: too many values to unpack And I get the same even for 2 variables (as Erin's proposal without the strings): In [23]: s,d = loadtxt('test.test',unpack=True,dtype=[('x','f8'),('y','f8')], usecols=[0,1]) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/.../ in () ValueError: too many values to unpack Derek, I checked the version of numpy and it is 1.3.0 - So I suppose it should be due to the version only? Regards Grigoris On 11/04/2011 05:35 PM, Erin Sheldon wrote: > This is the proper syntax, and works for me on your file: > > loadtxt('tmp/test.txt',dtype=[('x','f8'),('s','S5')], usecols=[0,5]) > > You need to give a proper dtype with full field description. > > -e > > On Fri, Nov 4, 2011 at 11:14 AM, Derek Homeier > wrote: >> Hi Grigoris, >> >>> Hello to all! I would like to ask about an error I face with >>> matplotlib's loadtxt... >>> >>> Suppose that we have a file (called "test.test") with 6 columns like: >>> >>> 1496548. 862.235400937 14.008 0 20110523.201416 tth*g >>> 1690289. 919.424007603 13.875 0 20110523.221527 hgf4 >>> 1667241. 996.262754039 13.890 0 20110524.001639 nb.mj >>> 739181.6 881.1753527 14.774 0 20110524.010203 vbfhg >>> >>> When I use >>> x, y = loadtxt('test.test', unpack=True, usecols=(0,1), dtype=(float,float)) >>> >>> it prints normally the first and second column. >>> If I add another column like: >>> >>> x, y, z = loadtxt('test.test', unpack=True,usecols=(0,1,3), >>> dtype=(float,float,float)) >>> >>> the output is this: >>> File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in >>> loadtxt >>> dtype = np.dtype(dtype) >>> TypeError: data type not understood >>> >> I don't quit understand that part, I admit - dtype only takes a single type or pairs of names and >> types, so it would seem the first case actually only worked by accident: >> >> In [193]: np.dtype((float,float)) >> Out[193]: dtype('float64') >> >> I have no idea how it interprets the second float, but as you see it has no effect anyway. >> You could in fact get the same result with 'usecols=[0,1,3], dtype=float' >> which will simply apply the dtype to all columns (and is the default already...). >>> Even if I use a dictionary, like: >>> dt = dtype({'names':['n1','n2','n3'],'formats':[float,float,float]}) >>> x, y, z = loadtxt('test.test', unpack=True, usecols=(0,1,2) , dtype=dt) >>> >>> the output is the same as previous. >>> >> No things are getting strange - the above is the correct (and I think, only) way to >> define dtypes with different formats - >> np.dtype([('n1',float),('n2',float),('n3',float)]) >> would be equivalent. As there is no error on the first line (i.e., dt is a valid dtype), >> this seems to be a bug in loadtxt. Could you check what happens if you try the >> above without the 'unpack' option? Should return a structured array with the 3 >> fields 'n1','n2','n3'... >> Also (as loadtxt is actually part of numpy), which is your installed version of numpy >> (numpy.__version__ or np.__version__, you may have to re-import it as pylab >> unfortunately imports everything into one namespace). I recall that there have >> been issues with unpacking structured arrays prior to 1.6 or 1.6.1. >> >>> Additionaly, when I am trying to load the last column as strings: >>> x, y = loadtxt('test.test', delimiter=' ', unpack=True,usecols=(0,5), >>> dtype=(float,'S5')) >>> >>> I get this error: >>> File "/usr/lib/python2.7/site-packages/numpy/lib/io.py", line 584, in >>> loadtxt >>> dtype = np.dtype(dtype) >>> ValueError: mismatch in size of old and new data-descriptor >>> >>> >>> What am I doing wrong ? I am sorry if it is something really obvious ... >>> but I am unable to find it... >> Similar problem - this ought to work with dtype=[('n1', 'f'), ('n6','S5')] ; but it might >> be broken in the same way as above - if you can update to numpy 1.6.x, you >> should hopefully be set. >> >> HTH, >> Derek >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > From derek at astro.physik.uni-goettingen.de Fri Nov 4 12:57:55 2011 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Fri, 4 Nov 2011 17:57:55 +0100 Subject: [AstroPy] question on matplotlib's loadtxt In-Reply-To: <4EB4109D.8000304@gmail.com> References: <4EB3EF05.10501@gmail.com> <31EA4FE1-950E-470F-ADAA-CBFB9A7E4EBB@astro.physik.uni-goettingen.de> <4EB4109D.8000304@gmail.com> Message-ID: <0C158A48-D4E4-4D83-B2F4-6DB2307ADB9F@astro.physik.uni-goettingen.de> On 4 Nov 2011, at 17:19, Grigoris Maravelias wrote: > In [23]: s,d = > > --------------------------------------------------------------------------- > ValueError Traceback (most recent call last) > > /home/.../ in () > > ValueError: too many values to unpack > > > > Derek, I checked the version of numpy and it is 1.3.0 - So I suppose it > should be due to the version only? > I've checked with a version 1.2.1 and unpacking is definitely broken there - in your example, it would try to return something like np.array(('1496548.', 'tth*g')), np.array(('1690289.', 'hgf4')), which of course does not match your dtypes... Try to upgrade; otherwise a workaround could be as I described A = loadtxt('test.test', dtype=[('x','f8'),('y','f8')], usecols=[0,1]) x, y = A['x'], A['y'] Or you may indeed give genfromtxt a try, but I am not sure how far this had evolved as of 1.3.0 (coming to think of it, I believe it currently still has the same unpacking bug that is now fixed in loadtxt). Cheers, Derek From marquett at iap.fr Mon Nov 7 09:58:47 2011 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Mon, 7 Nov 2011 15:58:47 +0100 Subject: [AstroPy] A question about contour maps Message-ID: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> Dear AstroPy people, I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. How to export from ASCII to FITS? Thanks for your help, Jean-Baptiste Marquette From wkerzendorf at googlemail.com Mon Nov 7 10:26:37 2011 From: wkerzendorf at googlemail.com (Wolfgang Kerzendorf) Date: Mon, 7 Nov 2011 10:26:37 -0500 Subject: [AstroPy] A question about contour maps In-Reply-To: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> Message-ID: Hi Jean-Baptiste, So I figure you do not want to plot points at each location of the points specified in your ASCII table? I think APLPy works with pixel coordinates internally and just overplots a wcs grid. You can convert these points with wcstools xy2sky (It also works with pywcs, but for some projections there's something off) to pixel coordinates and then use histogram2d to make a 2d density array. Finally, you use contour to plot it over your aplply plot. I don't know of any easier way for now. May Thomas knows more. Cheers Wolfgang On 2011-11-07, at 9:58 AM, Jean-Baptiste Marquette wrote: > Dear AstroPy people, > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > How to export from ASCII to FITS? > > Thanks for your help, > Jean-Baptiste Marquette > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From msk at astro.umd.edu Mon Nov 7 10:28:23 2011 From: msk at astro.umd.edu (Michael S. Kelley) Date: Mon, 7 Nov 2011 10:28:23 -0500 Subject: [AstroPy] A question about contour maps In-Reply-To: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> Message-ID: Hi Jean-Baptiste, I'm not sure what kind of projection you are interested in, but, at the most basic level, you can do a weighted 2D histogram on your data list. For example: import numpy as np import matplotlib.pyplot as mpl ra = np.random.randn(1000) dec = np.random.randn(1000) + 10 w = np.random.randn(1000)**2 h = np.histogram2d(dec, ra, bins=100, weights=w) mpl.clf() mpl.imshow(h[0], extent=np.r_[h[2][[0, -1]], h[1][[0, -1]]], cmap=mpl.cm.gray_r) mpl.plot(ra, dec, 'rx') mpl.draw() - Mike Kelley On Mon, Nov 7, 2011 at 9:58 AM, Jean-Baptiste Marquette wrote: > Dear AstroPy people, > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > How to export from ASCII to FITS? > > Thanks for your help, > Jean-Baptiste Marquette > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Michael S Kelley Department of Astronomy University of Maryland -- College Park 301-405-3796 From miguel.deval at gmail.com Mon Nov 7 10:31:02 2011 From: miguel.deval at gmail.com (Miguel de Val-Borro) Date: Mon, 7 Nov 2011 16:31:02 +0100 Subject: [AstroPy] A question about contour maps In-Reply-To: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> Message-ID: <20111107153102.GA28133@poincare.pc.linmpi.mpg.de> Dear Jean-Baptiste, If the data is in ASCII format you could use numpy.loadtxt to load the data into numpy arrays and use directly the matplotlib.pyplot.contourf function to make a contour plot. The first example in this cookbook shows how to make a contour plot from irregularly spaced data using the scipy.interpolate.griddata function for interpolation onto a uniform grid: http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data Regards, Miguel On Mon, Nov 07, 2011 at 03:58:47PM +0100, Jean-Baptiste Marquette wrote: > Dear AstroPy people, > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > How to export from ASCII to FITS? > > Thanks for your help, > Jean-Baptiste Marquette > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From ebressert at cfa.harvard.edu Mon Nov 7 15:52:48 2011 From: ebressert at cfa.harvard.edu (Eli Bressert) Date: Mon, 7 Nov 2011 21:52:48 +0100 Subject: [AstroPy] AstroPy Digest, Vol 63, Issue 4 In-Reply-To: References: Message-ID: <325424D1C8294E3480DFA8CE2808DF52@gmail.com> Dear Jean Baptiste, I have written up a script to do exactly what you have requested. This code is not fine-tuned for sharing, but you're free to use it. Also, the code is optimized for Galactic plane images. I have not tried using it for high declination images. Hope you find it useful. http://dl.dropbox.com/u/1356410/fits_creator.py Cheers, Eli On Monday, 7 November 2011 at 19:00, astropy-request at scipy.org wrote: > Send AstroPy mailing list submissions to > astropy at scipy.org (mailto:astropy at scipy.org) > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.scipy.org/mailman/listinfo/astropy > or, via email, send a message with subject or body 'help' to > astropy-request at scipy.org (mailto:astropy-request at scipy.org) > > You can reach the person managing the list at > astropy-owner at scipy.org (mailto:astropy-owner at scipy.org) > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of AstroPy digest..." > > > Today's Topics: > > 1. A question about contour maps (Jean-Baptiste Marquette) > 2. Re: A question about contour maps (Wolfgang Kerzendorf) > 3. Re: A question about contour maps (Michael S. Kelley) > 4. Re: A question about contour maps (Miguel de Val-Borro) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 7 Nov 2011 15:58:47 +0100 > From: Jean-Baptiste Marquette > Subject: [AstroPy] A question about contour maps > To: astropy at scipy.org (mailto:astropy at scipy.org) > Message-ID: <8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr (mailto:8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr)> > Content-Type: text/plain; charset=us-ascii > > Dear AstroPy people, > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > How to export from ASCII to FITS? > > Thanks for your help, > Jean-Baptiste Marquette > > ------------------------------ > > Message: 2 > Date: Mon, 7 Nov 2011 10:26:37 -0500 > From: Wolfgang Kerzendorf > Subject: Re: [AstroPy] A question about contour maps > To: Jean-Baptiste Marquette > Cc: astropy at scipy.org (mailto:astropy at scipy.org) > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Hi Jean-Baptiste, > > So I figure you do not want to plot points at each location of the points specified in your ASCII table? I think APLPy works with pixel coordinates internally and just overplots a wcs grid. You can convert these points with wcstools xy2sky (It also works with pywcs, but for some projections there's something off) to pixel coordinates and then use histogram2d to make a 2d density array. Finally, you use contour to plot it over your aplply plot. I don't know of any easier way for now. May Thomas knows more. > > Cheers > Wolfgang > On 2011-11-07, at 9:58 AM, Jean-Baptiste Marquette wrote: > > > Dear AstroPy people, > > > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > > How to export from ASCII to FITS? > > > > Thanks for your help, > > Jean-Baptiste Marquette > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org (mailto:AstroPy at scipy.org) > > http://mail.scipy.org/mailman/listinfo/astropy > > > > > > ------------------------------ > > Message: 3 > Date: Mon, 7 Nov 2011 10:28:23 -0500 > From: "Michael S. Kelley" > Subject: Re: [AstroPy] A question about contour maps > To: Jean-Baptiste Marquette > Cc: astropy at scipy.org (mailto:astropy at scipy.org) > Message-ID: > > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Jean-Baptiste, > > I'm not sure what kind of projection you are interested in, but, at > the most basic level, you can do a weighted 2D histogram on your data > list. For example: > > import numpy as np > import matplotlib.pyplot as mpl > ra = np.random.randn(1000) > dec = np.random.randn(1000) + 10 > w = np.random.randn(1000)**2 > h = np.histogram2d(dec, ra, bins=100, weights=w) > mpl.clf() > mpl.imshow(h[0], extent=np.r_[h[2][[0, -1]], h[1][[0, -1]]], cmap=mpl.cm.gray_r) > mpl.plot(ra, dec, 'rx') > mpl.draw() > > - Mike Kelley > > On Mon, Nov 7, 2011 at 9:58 AM, Jean-Baptiste Marquette wrote: > > Dear AstroPy people, > > > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > > How to export from ASCII to FITS? > > > > Thanks for your help, > > Jean-Baptiste Marquette > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org (mailto:AstroPy at scipy.org) > > http://mail.scipy.org/mailman/listinfo/astropy > > > > > > -- > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > Michael S Kelley > Department of Astronomy > University of Maryland -- College Park > 301-405-3796 > > > ------------------------------ > > Message: 4 > Date: Mon, 7 Nov 2011 16:31:02 +0100 > From: Miguel de Val-Borro > Subject: Re: [AstroPy] A question about contour maps > To: Jean-Baptiste Marquette > Cc: astropy at scipy.org (mailto:astropy at scipy.org) > Message-ID: <20111107153102.GA28133 at poincare.pc.linmpi.mpg.de (mailto:20111107153102.GA28133 at poincare.pc.linmpi.mpg.de)> > Content-Type: text/plain; charset=utf-8 > > Dear Jean-Baptiste, > > If the data is in ASCII format you could use numpy.loadtxt to load the > data into numpy arrays and use directly the matplotlib.pyplot.contourf > function to make a contour plot. The first example in this cookbook > shows how to make a contour plot from irregularly spaced data using the > scipy.interpolate.griddata function for interpolation onto a uniform > grid: > http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data > > Regards, > Miguel > > On Mon, Nov 07, 2011 at 03:58:47PM +0100, Jean-Baptiste Marquette wrote: > > Dear AstroPy people, > > > > I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. > > How to export from ASCII to FITS? > > > > Thanks for your help, > > Jean-Baptiste Marquette > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org (mailto:AstroPy at scipy.org) > > http://mail.scipy.org/mailman/listinfo/astropy > > > > > ------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org (mailto:AstroPy at scipy.org) > http://mail.scipy.org/mailman/listinfo/astropy > > > End of AstroPy Digest, Vol 63, Issue 4 > ************************************** From marquett at iap.fr Tue Nov 8 08:56:38 2011 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Tue, 8 Nov 2011 14:56:38 +0100 Subject: [AstroPy] AstroPy Digest, Vol 63, Issue 4 In-Reply-To: <325424D1C8294E3480DFA8CE2808DF52@gmail.com> References: <325424D1C8294E3480DFA8CE2808DF52@gmail.com> Message-ID: <089E9BC2-7D3C-4849-B1BB-0FBDDDA25EE9@iap.fr> Dear all, Thanks to all for your suggestions, it seems that np.histogram2d fits my needs. I am currently finishing the script. Cheers JB Le 7 nov. 2011 ? 21:52, Eli Bressert a ?crit : > Dear Jean Baptiste, > > I have written up a script to do exactly what you have requested. This code is not fine-tuned for sharing, but you're free to use it. Also, the code is optimized for Galactic plane images. I have not tried using it for high declination images. Hope you find it useful. > > http://dl.dropbox.com/u/1356410/fits_creator.py > > Cheers, > Eli > > > > On Monday, 7 November 2011 at 19:00, astropy-request at scipy.org wrote: > >> Send AstroPy mailing list submissions to >> astropy at scipy.org (mailto:astropy at scipy.org) >> >> To subscribe or unsubscribe via the World Wide Web, visit >> http://mail.scipy.org/mailman/listinfo/astropy >> or, via email, send a message with subject or body 'help' to >> astropy-request at scipy.org (mailto:astropy-request at scipy.org) >> >> You can reach the person managing the list at >> astropy-owner at scipy.org (mailto:astropy-owner at scipy.org) >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of AstroPy digest..." >> >> >> Today's Topics: >> >> 1. A question about contour maps (Jean-Baptiste Marquette) >> 2. Re: A question about contour maps (Wolfgang Kerzendorf) >> 3. Re: A question about contour maps (Michael S. Kelley) >> 4. Re: A question about contour maps (Miguel de Val-Borro) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Mon, 7 Nov 2011 15:58:47 +0100 >> From: Jean-Baptiste Marquette >> Subject: [AstroPy] A question about contour maps >> To: astropy at scipy.org (mailto:astropy at scipy.org) >> Message-ID: <8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr (mailto:8829B407-25F3-4E64-98E9-8D55D070C206 at iap.fr)> >> Content-Type: text/plain; charset=us-ascii >> >> Dear AstroPy people, >> >> I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. >> How to export from ASCII to FITS? >> >> Thanks for your help, >> Jean-Baptiste Marquette >> >> ------------------------------ >> >> Message: 2 >> Date: Mon, 7 Nov 2011 10:26:37 -0500 >> From: Wolfgang Kerzendorf >> Subject: Re: [AstroPy] A question about contour maps >> To: Jean-Baptiste Marquette >> Cc: astropy at scipy.org (mailto:astropy at scipy.org) >> Message-ID: >> Content-Type: text/plain; charset=us-ascii >> >> Hi Jean-Baptiste, >> >> So I figure you do not want to plot points at each location of the points specified in your ASCII table? I think APLPy works with pixel coordinates internally and just overplots a wcs grid. You can convert these points with wcstools xy2sky (It also works with pywcs, but for some projections there's something off) to pixel coordinates and then use histogram2d to make a 2d density array. Finally, you use contour to plot it over your aplply plot. I don't know of any easier way for now. May Thomas knows more. >> >> Cheers >> Wolfgang >> On 2011-11-07, at 9:58 AM, Jean-Baptiste Marquette wrote: >> >>> Dear AstroPy people, >>> >>> I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. >>> How to export from ASCII to FITS? >>> >>> Thanks for your help, >>> Jean-Baptiste Marquette >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org (mailto:AstroPy at scipy.org) >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> >> >> ------------------------------ >> >> Message: 3 >> Date: Mon, 7 Nov 2011 10:28:23 -0500 >> From: "Michael S. Kelley" >> Subject: Re: [AstroPy] A question about contour maps >> To: Jean-Baptiste Marquette >> Cc: astropy at scipy.org (mailto:astropy at scipy.org) >> Message-ID: >> >> Content-Type: text/plain; charset=ISO-8859-1 >> >> Hi Jean-Baptiste, >> >> I'm not sure what kind of projection you are interested in, but, at >> the most basic level, you can do a weighted 2D histogram on your data >> list. For example: >> >> import numpy as np >> import matplotlib.pyplot as mpl >> ra = np.random.randn(1000) >> dec = np.random.randn(1000) + 10 >> w = np.random.randn(1000)**2 >> h = np.histogram2d(dec, ra, bins=100, weights=w) >> mpl.clf() >> mpl.imshow(h[0], extent=np.r_[h[2][[0, -1]], h[1][[0, -1]]], cmap=mpl.cm.gray_r) >> mpl.plot(ra, dec, 'rx') >> mpl.draw() >> >> - Mike Kelley >> >> On Mon, Nov 7, 2011 at 9:58 AM, Jean-Baptiste Marquette wrote: >>> Dear AstroPy people, >>> >>> I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. >>> How to export from ASCII to FITS? >>> >>> Thanks for your help, >>> Jean-Baptiste Marquette >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org (mailto:AstroPy at scipy.org) >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> >> >> -- >> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >> Michael S Kelley >> Department of Astronomy >> University of Maryland -- College Park >> 301-405-3796 >> >> >> ------------------------------ >> >> Message: 4 >> Date: Mon, 7 Nov 2011 16:31:02 +0100 >> From: Miguel de Val-Borro >> Subject: Re: [AstroPy] A question about contour maps >> To: Jean-Baptiste Marquette >> Cc: astropy at scipy.org (mailto:astropy at scipy.org) >> Message-ID: <20111107153102.GA28133 at poincare.pc.linmpi.mpg.de (mailto:20111107153102.GA28133 at poincare.pc.linmpi.mpg.de)> >> Content-Type: text/plain; charset=utf-8 >> >> Dear Jean-Baptiste, >> >> If the data is in ASCII format you could use numpy.loadtxt to load the >> data into numpy arrays and use directly the matplotlib.pyplot.contourf >> function to make a contour plot. The first example in this cookbook >> shows how to make a contour plot from irregularly spaced data using the >> scipy.interpolate.griddata function for interpolation onto a uniform >> grid: >> http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data >> >> Regards, >> Miguel >> >> On Mon, Nov 07, 2011 at 03:58:47PM +0100, Jean-Baptiste Marquette wrote: >>> Dear AstroPy people, >>> >>> I have an ASCII table with RA/DEC coordinates and the values of a given parameter at those positions. I would like to plot a contour map of this parameter on an image with RA/DEC coordinates. I was able create a blank image using pyfits. I guess I could use the APLpy FITSFigure.show_contour method if my data were organized as a FITS file. >>> How to export from ASCII to FITS? >>> >>> Thanks for your help, >>> Jean-Baptiste Marquette >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org (mailto:AstroPy at scipy.org) >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> >> ------------------------------ >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org (mailto:AstroPy at scipy.org) >> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> End of AstroPy Digest, Vol 63, Issue 4 >> ************************************** > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From steven.d.christe at nasa.gov Tue Nov 8 11:23:37 2011 From: steven.d.christe at nasa.gov (Christe, Steven D. (GSFC-6710)) Date: Tue, 8 Nov 2011 10:23:37 -0600 Subject: [AstroPy] A question about CLEAN In-Reply-To: <20111107153102.GA28133@poincare.pc.linmpi.mpg.de> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> <20111107153102.GA28133@poincare.pc.linmpi.mpg.de> Message-ID: <9D7B2BD3-3EB1-46A4-BC3C-D3E37104FED3@nasa.gov> Hello, Does anyone know if there is a CLEAN algorithm (from radio astronomy) implemented anywhere in Python? Thanks, Steven From shupe at ipac.caltech.edu Tue Nov 8 11:27:49 2011 From: shupe at ipac.caltech.edu (David Shupe) Date: Tue, 8 Nov 2011 08:27:49 -0800 Subject: [AstroPy] A question about CLEAN In-Reply-To: <9D7B2BD3-3EB1-46A4-BC3C-D3E37104FED3@nasa.gov> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> <20111107153102.GA28133@poincare.pc.linmpi.mpg.de> <9D7B2BD3-3EB1-46A4-BC3C-D3E37104FED3@nasa.gov> Message-ID: It's implemented in CASA (http://casa.nrao.edu/) but it is likely the underlying code is in C++ with a wrapper in Python. Regards, David On Nov 8, 2011, at 8:23 AM, Christe, Steven D. (GSFC-6710) wrote: > > Hello, > > Does anyone know if there is a CLEAN algorithm (from radio astronomy) implemented anywhere in Python? > > Thanks, > Steven > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From sransom at nrao.edu Tue Nov 8 11:30:16 2011 From: sransom at nrao.edu (Scott Ransom) Date: Tue, 08 Nov 2011 11:30:16 -0500 Subject: [AstroPy] A question about CLEAN In-Reply-To: <9D7B2BD3-3EB1-46A4-BC3C-D3E37104FED3@nasa.gov> References: <8829B407-25F3-4E64-98E9-8D55D070C206@iap.fr> <20111107153102.GA28133@poincare.pc.linmpi.mpg.de> <9D7B2BD3-3EB1-46A4-BC3C-D3E37104FED3@nasa.gov> Message-ID: <4EB95918.9070405@nrao.edu> I found this toy implementation: http://www.mrao.cam.ac.uk/~bn204/alma/python-clean.html And one that is used for the PAPER project, called AIPY (Astronomical Interferometry in Python) by Aaron Parsons can be gotten here: https://casper.berkeley.edu/astrobaki/index.php/AIPY Scott On 11/08/2011 11:23 AM, Christe, Steven D. (GSFC-6710) wrote: > > Hello, > > Does anyone know if there is a CLEAN algorithm (from radio astronomy) > implemented anywhere in Python? > > Thanks, Steven _______________________________________________ > AstroPy mailing list AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Scott M. Ransom Address: NRAO Phone: (434) 296-0320 520 Edgemont Rd. email: sransom at nrao.edu Charlottesville, VA 22903 USA GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989 From embray at stsci.edu Wed Nov 16 16:59:25 2011 From: embray at stsci.edu (Erik Bray) Date: Wed, 16 Nov 2011 16:59:25 -0500 Subject: [AstroPy] PyFITS beta testing Message-ID: <4EC4323D.4000607@stsci.edu> Hi all, I've been working off and on for a few months on a big changeset to PyFITS which changes some details about how Headers are worked with. The biggest overall change to be aware of is that the CardList class is completely deprecated. Headers are worked with entirely through Header objects, which have assumed much of the former responsibility of CardLists. Header objects themselves work mostly the same way as before, but they are now more powerful objects that combine a mostly transparent interface to header as an ordered dict-like object with a list-like interface that allows manipulating a Header on the level of individual cards. The pyfits.Card class is still in use, but there are not many reasons to use it directly. All methods that accept a Card object will also accept a simple (keyword, value, comment) tuple in its place, or even (keyword, value) tuples. I've also worked hard to maintain backwards compatibility for now with the old API. There is still a class called CardList, for example, and it works similarly to the old class. There's no reason to use it, however, except to support older code. I've tested the backwards compatibility pretty extensively through the stsci_python regtests. So far I've only found one (rare) use case that is not backwards compatible, but that is a one line fix (it has to do with iteration over slices of Headers--I'll give more details if anyone asks). So I'm sending out a call to get a couple of people to try out the new interface and see how it works for them. I'm interested in both backwards compatibility with old code, and in opinions on the new API. Nothing here is set in stone, so as much feedback as I can get would be greatly appreciated. The new code can be found at: https://svn6.assembla.com/svn/pyfits/branches/header-refactoring. The branch is kept up to date with pyfits's trunk, so if you already do any development off of that the only major changes should be to headers. Thanks, Erik From thomas.robitaille at gmail.com Fri Nov 18 11:59:51 2011 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Fri, 18 Nov 2011 17:59:51 +0100 Subject: [AstroPy] arbitrary coordinate systems and data cube slicing in APLpy Message-ID: Hi everyone, Over the last couple of months, I've made extensive changes to the core APLpy code to allow us to support plotting of FITS files with arbitrary coordinates rather than just sky coordinates, and to also allow slicing of multi-dimensional data cubes. It is now very easy for example to make position-velocity plots from a 3D FITS cube. Due to the extensive nature of the changes, and before releasing a stable release (0.9.7), I would like to request beta testers to try installing the latest developer version of APLpy and try out the new functionality. Since the under-the-hood changes even affect plotting of normal 2D 'sky' images, I would also welcome volunteers to try using the latest developer version of APLpy with your current scripts to help diagnose any issues. To install the latest developer version: git clone git://github.com/aplpy/aplpy.git cd aplpy python setup.py install I have written up a documentation page regarding arbitrary coordinate systems: http://aplpy.github.com/documentation/arbitrary_coordinate_systems.html as well as regarding slicing (in particular, check out the example): http://aplpy.github.com/documentation/slicing.html Please report any issues via GitHub: https://github.com/aplpy/aplpy/issues and if you need to send me any example files to reproduce issues, you can send them to me at thomas.robitaille at gmail.com (data will be treated as confidential). Note that these updates supersede the userwcs branch of APLpy that was created by Adam Ginsburg to support non-coordinate axes. Please let me know if you have any comments or suggestions regarding this functionality, or suggestions for improving the documentation! Cheers, Tom From perry at stsci.edu Mon Nov 21 11:51:18 2011 From: perry at stsci.edu (Perry Greenfield) Date: Mon, 21 Nov 2011 11:51:18 -0500 Subject: [AstroPy] [job] two STScI positions Message-ID: <833ABCF7-8E82-4DC3-A764-EA230D5A901D@stsci.edu> STScI has posted two positions in the Science Software Branch: astronomical applications developer: https://rn11.ultipro.com/SPA1004/jobboard/JobDetails.aspx?__ID=*B12AC582943DA7BA software distribution and installation support: https://rn11.ultipro.com/SPA1004/jobboard/JobDetails.aspx?__ID=*61BE073DB16951DE From d.berry at jach.hawaii.edu Thu Nov 24 04:08:40 2011 From: d.berry at jach.hawaii.edu (David Berry) Date: Thu, 24 Nov 2011 09:08:40 +0000 Subject: [AstroPy] Starlink PyAST Message-ID: Hi All, I'd like to draw people's attention to a new Python library called "PyAST" that provides wrappers for the starlink AST library. AST provides a comprehensive range of facilities for attaching world co-ordinate systems to astronomical data, for retrieving and interpreting that information in a variety of formats, including FITS-WCS, and for generating graphical output based on it (annotated coordinate grids, etc). AST provides the WCS facilities for such popular tools as DS9, Gaia and Splat. More information about AST is available at www.starlink.ac.uk/ast. PyAST was presented at the recent Paris ADASS conference - the poster can be seen at starlink.jach.hawaii.edu/starlink/AST?action=AttachFile&do=view&target=adass2011.pdf Documentation for PyAST is available at dsberry.github.com/starlink/pyast.html, and PyAST can be downloaded from github.com/timj/starlink-pyast/downloads. David Berry From omar.vpa at gmail.com Thu Nov 24 13:21:48 2011 From: omar.vpa at gmail.com (=?ISO-8859-1?Q?Omar_Trinidad_Guti=E9rrez_M=E9ndez?=) Date: Thu, 24 Nov 2011 12:21:48 -0600 Subject: [AstroPy] AstroPy Digest, Vol 63, Issue 9 In-Reply-To: References: Message-ID: So good! On Thu, Nov 24, 2011 at 12:00 PM, wrote: > Send AstroPy mailing list submissions to > astropy at scipy.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.scipy.org/mailman/listinfo/astropy > or, via email, send a message with subject or body 'help' to > astropy-request at scipy.org > > You can reach the person managing the list at > astropy-owner at scipy.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of AstroPy digest..." > > > Today's Topics: > > 1. Starlink PyAST (David Berry) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 24 Nov 2011 09:08:40 +0000 > From: David Berry > Subject: [AstroPy] Starlink PyAST > To: astropy at scipy.org > Message-ID: > > > Content-Type: text/plain; charset=ISO-8859-1 > > Hi All, > I'd like to draw people's attention to a new Python library > called "PyAST" that provides wrappers for the starlink AST library. > AST provides a comprehensive range of facilities for attaching world > co-ordinate systems to astronomical data, for retrieving and > interpreting that information in a variety of formats, including > FITS-WCS, and for generating graphical output based on it (annotated > coordinate grids, etc). AST provides the WCS facilities for such > popular tools as DS9, Gaia and Splat. More information about AST is > available at www.starlink.ac.uk/ast. > > PyAST was presented at the recent Paris ADASS conference - the poster > can be seen at > > starlink.jach.hawaii.edu/starlink/AST?action=AttachFile&do=view&target=adass2011.pdf > > Documentation for PyAST is available at > dsberry.github.com/starlink/pyast.html, and PyAST can be downloaded > from github.com/timj/starlink-pyast/downloads. > > David Berry > > > ------------------------------ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > > End of AstroPy Digest, Vol 63, Issue 9 > ************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From embray at stsci.edu Mon Nov 28 10:34:28 2011 From: embray at stsci.edu (Erik Bray) Date: Mon, 28 Nov 2011 10:34:28 -0500 Subject: [AstroPy] PyFITS beta testing In-Reply-To: References: <4EC4323D.4000607@stsci.edu> Message-ID: <4ED3AA04.5060506@stsci.edu> Thanks for pointing that out Philip. Bringing this back to the list if you don't mind. PyFITS doesn't normally include documentation for building the docs since normally users don't have to. But I should add some anyways. Building the PyFITS docs requires the stsci.sphinxext package, which can be downloaded from PyPI (http://pypi.python.org/pypi/stsci.sphinxext) and installed with easy_install, pip, etc. However, I went up and put a version of the docs from the header branch online here: http://stsdas.stsci.edu/download/docs/pyfits/header-refactoring/ so you shouldn't have to bother. The main differences are in all the header-specific docs: * http://stsdas.stsci.edu/download/docs/pyfits/header-refactoring/users_guide/users_tutorial.html#working-with-a-fits-header * http://stsdas.stsci.edu/download/docs/pyfits/header-refactoring/users_guide/users_headers.html * http://stsdas.stsci.edu/download/docs/pyfits/header-refactoring/api_docs/api_headers.html These docs now explain the new way of working with Headers (which isn't much different for the most part). The old ways should work too. I'm interested both in feedback on the new API and whether or not it makes sense, as well as on how well backwards compatibility has been maintained with your old code. Thanks, Erik On 11/25/2011 09:10 PM, Philip Tait wrote: > Hi Erik, > > I thought I would give this a try. The PyFITS module built OK, but I > seem to be missing a module needed to build the docs: > >> make html > sphinx-build -b html -d build/doctrees source build/html > Making output directory... > Running Sphinx v1.0.7 > > Exception occurred: > File "/home/pjt/pyfits/header-refactoring/docs/source/conf.py", line > 17, in > from stsci.sphinxext.conf import * > ImportError: No module named stsci.sphinxext.conf > > > Clues welcome. > > Philip > On Wed, Nov 16, 2011 at 11:59, Erik Bray wrote: >> Hi all, >> >> I've been working off and on for a few months on a big changeset to >> PyFITS which changes some details about how Headers are worked with. >> >> The biggest overall change to be aware of is that the CardList class is >> completely deprecated. Headers are worked with entirely through Header >> objects, which have assumed much of the former responsibility of CardLists. >> >> Header objects themselves work mostly the same way as before, but they >> are now more powerful objects that combine a mostly transparent >> interface to header as an ordered dict-like object with a list-like >> interface that allows manipulating a Header on the level of individual >> cards. >> >> The pyfits.Card class is still in use, but there are not many reasons to >> use it directly. All methods that accept a Card object will also accept >> a simple (keyword, value, comment) tuple in its place, or even (keyword, >> value) tuples. >> >> I've also worked hard to maintain backwards compatibility for now with >> the old API. There is still a class called CardList, for example, and >> it works similarly to the old class. There's no reason to use it, >> however, except to support older code. I've tested the backwards >> compatibility pretty extensively through the stsci_python regtests. So >> far I've only found one (rare) use case that is not backwards >> compatible, but that is a one line fix (it has to do with iteration over >> slices of Headers--I'll give more details if anyone asks). >> >> So I'm sending out a call to get a couple of people to try out the new >> interface and see how it works for them. I'm interested in both >> backwards compatibility with old code, and in opinions on the new API. >> Nothing here is set in stone, so as much feedback as I can get would be >> greatly appreciated. >> >> The new code can be found at: >> >> https://svn6.assembla.com/svn/pyfits/branches/header-refactoring. >> >> The branch is kept up to date with pyfits's trunk, so if you already do >> any development off of that the only major changes should be to headers. >> >> Thanks, >> Erik >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > > From thomas.robitaille at gmail.com Mon Nov 28 11:18:30 2011 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Mon, 28 Nov 2011 17:18:30 +0100 Subject: [AstroPy] Using MacPorts for Python In-Reply-To: References: Message-ID: I was wondering whether anyone has used the instructions below to install Python on 10.7 using MacPorts, and if so, whether everything works fine? Tom On 25 July 2011 18:36, Thomas Robitaille wrote: > Hi Everyone, > > Earlier this year I was given commit privileges to the MacPorts > (http://www.macports.org/) package index, and I've already added a few > Astronomy Python packages. After moved between various install methods > in the last couple of years (system Python, EPD, source install, > python.org distribution, ...) I've now settled on using the Python > distribution from MacPorts. One of my main reasons for doing this is > that I needed some complex packages (Qt and GTK+) which are not > included in EPD, and by far the easiest way to install them has been > through MacPorts. However, I believe a MacPorts Python distribution > can still be very useful even if you don't need these packages, so > I've compiled a list of simple instructions to set up a full Python > distribution using MacPorts on Mac: > > http://astrofrog.github.com/macports-python/ > > Updating packages is easy, and dependencies are automatically taken > care of. For now I recommend using Python 2.7 as indicated in the > instructions. I would welcome any feedback, especially if you run into > issues, and would also welcome suggestions for other packages to add. > For new packages you can either email me directly or open a ticket on > MacPorts and cc robitaille at macports.org on the ticket. To report > issues with the instructions, open an issue at: > > https://github.com/astrofrog/macports-python > > Note that it's possible/easy to install several Python versions with > MacPorts at the same time and you can switch which one is the default > with 'port select', or call the version you want directly with > ipython-3.1 for example. This makes it ideal if you want to be able to > test your code using different python versions or want to experiment > with Python 3. > > Cheers, > Thomas > From dave31415 at gmail.com Mon Nov 28 12:02:45 2011 From: dave31415 at gmail.com (David Johnston) Date: Mon, 28 Nov 2011 11:02:45 -0600 Subject: [AstroPy] Using MacPorts for Python In-Reply-To: References: Message-ID: Yes, I have found it to work well. It is probably the best way to install these packages on Mac. I have found that a few things do not install. I think wxpython was one of those. Some packages are not available at Mac ports so you should install those using pip or easyinstall with the --user flag which install them in your home directory. Dave On Mon, Nov 28, 2011 at 10:18 AM, Thomas Robitaille < thomas.robitaille at gmail.com> wrote: > I was wondering whether anyone has used the instructions below to > install Python on 10.7 using MacPorts, and if so, whether everything > works fine? > > Tom > > On 25 July 2011 18:36, Thomas Robitaille > wrote: > > Hi Everyone, > > > > Earlier this year I was given commit privileges to the MacPorts > > (http://www.macports.org/) package index, and I've already added a few > > Astronomy Python packages. After moved between various install methods > > in the last couple of years (system Python, EPD, source install, > > python.org distribution, ...) I've now settled on using the Python > > distribution from MacPorts. One of my main reasons for doing this is > > that I needed some complex packages (Qt and GTK+) which are not > > included in EPD, and by far the easiest way to install them has been > > through MacPorts. However, I believe a MacPorts Python distribution > > can still be very useful even if you don't need these packages, so > > I've compiled a list of simple instructions to set up a full Python > > distribution using MacPorts on Mac: > > > > http://astrofrog.github.com/macports-python/ > > > > Updating packages is easy, and dependencies are automatically taken > > care of. For now I recommend using Python 2.7 as indicated in the > > instructions. I would welcome any feedback, especially if you run into > > issues, and would also welcome suggestions for other packages to add. > > For new packages you can either email me directly or open a ticket on > > MacPorts and cc robitaille at macports.org on the ticket. To report > > issues with the instructions, open an issue at: > > > > https://github.com/astrofrog/macports-python > > > > Note that it's possible/easy to install several Python versions with > > MacPorts at the same time and you can switch which one is the default > > with 'port select', or call the version you want directly with > > ipython-3.1 for example. This makes it ideal if you want to be able to > > test your code using different python versions or want to experiment > > with Python 3. > > > > Cheers, > > Thomas > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave31415 at gmail.com Mon Nov 28 12:27:17 2011 From: dave31415 at gmail.com (David Johnston) Date: Mon, 28 Nov 2011 11:27:17 -0600 Subject: [AstroPy] Using MacPorts for Python In-Reply-To: References: Message-ID: Just to confirm. wxpython does indeed fail. Davids-MacBook-Pro:~ davej$ sudo port install py27-wxpython Password: ---> Computing dependencies for py27-wxpython ---> Dependencies to be installed: wxWidgets ---> Building wxWidgets Error: Target org.macports.build returned: shell command failed (see log for details) Error: Failed to install wxWidgets Log for wxWidgets is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_wxWidgets/wxWidgets/main.log Error: The following dependencies were not installed: wxWidgets Error: Status 1 encountered during processing. To report a bug, see On Mon, Nov 28, 2011 at 11:02 AM, David Johnston wrote: > Yes, I have found it to work well. It is probably the best way to install > these packages on Mac. > > I have found that a few things do not install. I think wxpython was one of > those. Some packages are not available at Mac ports so you should install > those using pip or easyinstall with the --user flag which install them in > your home directory. > Dave > > > > On Mon, Nov 28, 2011 at 10:18 AM, Thomas Robitaille < > thomas.robitaille at gmail.com> wrote: > >> I was wondering whether anyone has used the instructions below to >> install Python on 10.7 using MacPorts, and if so, whether everything >> works fine? >> >> Tom >> >> On 25 July 2011 18:36, Thomas Robitaille >> wrote: >> > Hi Everyone, >> > >> > Earlier this year I was given commit privileges to the MacPorts >> > (http://www.macports.org/) package index, and I've already added a few >> > Astronomy Python packages. After moved between various install methods >> > in the last couple of years (system Python, EPD, source install, >> > python.org distribution, ...) I've now settled on using the Python >> > distribution from MacPorts. One of my main reasons for doing this is >> > that I needed some complex packages (Qt and GTK+) which are not >> > included in EPD, and by far the easiest way to install them has been >> > through MacPorts. However, I believe a MacPorts Python distribution >> > can still be very useful even if you don't need these packages, so >> > I've compiled a list of simple instructions to set up a full Python >> > distribution using MacPorts on Mac: >> > >> > http://astrofrog.github.com/macports-python/ >> > >> > Updating packages is easy, and dependencies are automatically taken >> > care of. For now I recommend using Python 2.7 as indicated in the >> > instructions. I would welcome any feedback, especially if you run into >> > issues, and would also welcome suggestions for other packages to add. >> > For new packages you can either email me directly or open a ticket on >> > MacPorts and cc robitaille at macports.org on the ticket. To report >> > issues with the instructions, open an issue at: >> > >> > https://github.com/astrofrog/macports-python >> > >> > Note that it's possible/easy to install several Python versions with >> > MacPorts at the same time and you can switch which one is the default >> > with 'port select', or call the version you want directly with >> > ipython-3.1 for example. This makes it ideal if you want to be able to >> > test your code using different python versions or want to experiment >> > with Python 3. >> > >> > Cheers, >> > Thomas >> > >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gr.maravelias at gmail.com Wed Nov 30 03:52:25 2011 From: gr.maravelias at gmail.com (Grigoris Maravelias) Date: Wed, 30 Nov 2011 10:52:25 +0200 Subject: [AstroPy] matplotlib's pie colors Message-ID: <4ED5EEC9.30709@gmail.com> Hello list! I have a question regarding the colors of the pie diagram of matplotlib. When no colors are assigned then the pie function automatically selects some colors, like the example image I have attached. But in this case the black color covers the text. How can we avoid this?Is there an easy (perhaps?) way to exclude a color? Of course there is not problem if I specifically select the colors but I do not know how many parts exist beforehand (and I would like to assign it automatically). Thanks! Regards Grigoris -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 81045 bytes Desc: not available URL: From jslavin at cfa.harvard.edu Wed Nov 30 09:27:39 2011 From: jslavin at cfa.harvard.edu (Jonathan Slavin) Date: Wed, 30 Nov 2011 09:27:39 -0500 Subject: [AstroPy] matplotlib's pie colors Message-ID: <1322663259.21974.12.camel@shevek> Grigoris, I'm afraid I don't have an answer for you off the top of my head, but I do have a recommendation: post questions specific to matplotlib to the the matplotlib-users list (see: https://lists.sourceforge.net/lists/listinfo/matplotlib-users ). While many on the astropy list are matplotlib users, you're more likely to get good and quick answers on matplotlib functionality there. Jon > Date: Wed, 30 Nov 2011 10:52:25 +0200 > From: Grigoris Maravelias > Subject: [AstroPy] matplotlib's pie colors > To: astropy at scipy.org > Message-ID: <4ED5EEC9.30709 at gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hello list! > > I have a question regarding the colors of the pie diagram of > matplotlib. > When no colors are assigned then the pie function automatically > selects > some colors, like the example image I have attached. But in this case > the black color covers the text. How can we avoid this?Is there an > easy > (perhaps?) way to exclude a color? > > Of course there is not problem if I specifically select the colors but > I > do not know how many parts exist beforehand (and I would like to > assign > it automatically). > > Thanks! > > Regards > > Grigoris -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ From vanderplas at astro.washington.edu Wed Nov 30 11:26:15 2011 From: vanderplas at astro.washington.edu (Jacob VanderPlas) Date: Wed, 30 Nov 2011 08:26:15 -0800 Subject: [AstroPy] matplotlib's pie colors Message-ID: <4ED65927.3030006@astro.washington.edu> Try the following: >>> ax = pylab.axes() >>> ax.set_color_cycle(['green', 'orange', 'blue', 'red','brown','pink']) >>> ax.plot(x1, y1) >>> ax.plot(x2, y2) >>> Jake From gr.maravelias at gmail.com Wed Nov 30 19:12:19 2011 From: gr.maravelias at gmail.com (Grigoris Maravelias) Date: Thu, 01 Dec 2011 02:12:19 +0200 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: <1322663259.21974.12.camel@shevek> References: <1322663259.21974.12.camel@shevek> Message-ID: <4ED6C663.8080709@gmail.com> Thanks Jon! I did contacted the matplotlib list, although we didn't conclude to something solid so I decided to change the plan and go for a bar plot instead of the pie diagram (thanks to another answer which has been really clarifying) Thanks for your response too! Wishes Grigoris On 11/30/2011 04:27 PM, Jonathan Slavin wrote: > Grigoris, > > I'm afraid I don't have an answer for you off the top of my head, but I > do have a recommendation: post questions specific to matplotlib to the > the matplotlib-users list (see: > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ). While > many on the astropy list are matplotlib users, you're more likely to get > good and quick answers on matplotlib functionality there. > > Jon > >> Date: Wed, 30 Nov 2011 10:52:25 +0200 >> From: Grigoris Maravelias >> Subject: [AstroPy] matplotlib's pie colors >> To: astropy at scipy.org >> Message-ID:<4ED5EEC9.30709 at gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> Hello list! >> >> I have a question regarding the colors of the pie diagram of >> matplotlib. >> When no colors are assigned then the pie function automatically >> selects >> some colors, like the example image I have attached. But in this case >> the black color covers the text. How can we avoid this?Is there an >> easy >> (perhaps?) way to exclude a color? >> >> Of course there is not problem if I specifically select the colors but >> I >> do not know how many parts exist beforehand (and I would like to >> assign >> it automatically). >> >> Thanks! >> >> Regards >> >> Grigoris From gr.maravelias at gmail.com Wed Nov 30 19:16:17 2011 From: gr.maravelias at gmail.com (Grigoris Maravelias) Date: Thu, 01 Dec 2011 02:16:17 +0200 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: <4ED65927.3030006@astro.washington.edu> References: <4ED65927.3030006@astro.washington.edu> Message-ID: <4ED6C751.6030909@gmail.com> Thanks Jake, but I know that I can set the colors but I would like it to happen without me specifying the colors like this. Another approach would be to create a list of colors according to the objects automatically somehow by using #hex codes but it is getting too much without really a purpose. Thanks for you answer! Grigoris On 11/30/2011 06:26 PM, Jacob VanderPlas wrote: > Try the following: > > >>> ax = pylab.axes() > >>> ax.set_color_cycle(['green', 'orange', 'blue', 'red','brown','pink']) > >>> ax.plot(x1, y1) > >>> ax.plot(x2, y2) > >>> > > Jake > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From derek at astro.physik.uni-goettingen.de Wed Nov 30 20:38:02 2011 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Thu, 1 Dec 2011 02:38:02 +0100 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: <4ED6C751.6030909@gmail.com> References: <4ED65927.3030006@astro.washington.edu> <4ED6C751.6030909@gmail.com> Message-ID: <9631592B-1798-4FED-877A-1C9219754ECD@astro.physik.uni-goettingen.de> On 01.12.2011, at 1:16AM, Grigoris Maravelias wrote: > Thanks Jake, but I know that I can set the colors but I would like it to > happen without me specifying the colors like this. Another approach > would be to create a list of colors according to the objects > automatically somehow by using #hex codes but it is getting too much > without really a purpose. > > Thanks for you answer! > > Grigoris > > On 11/30/2011 06:26 PM, Jacob VanderPlas wrote: >> Try the following: >> >>>>> ax = pylab.axes() >>>>> ax.set_color_cycle(['green', 'orange', 'blue', 'red','brown','pink']) >>>>> ax.plot(x1, y1) >>>>> ax.plot(x2, y2) >>>>> > Thanks everyone, that's a very useful pointer - I have been wondering as well how to best set the default sequence of colours. Constructing a sequence is actually not that different using the *range() functions; e.g. you could apply them on rgb tuples, or even more comfortable, directly access any of the default colourmaps like ax.set_color_cycle(pylab.cm.coolwarm(xrange(8,256,16))) and just pick your favourite from http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html - now there'd only have to be a wider choice of maps that would all print well as lines on white bg ;-) but for pie charts etc. a lot of them should work well. Cheers, Derek