From thomas.robitaille at gmail.com Tue Apr 1 11:44:06 2014 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Tue, 01 Apr 2014 17:44:06 +0200 Subject: [AstroPy] SciPy 2014 abstract submission and financial support deadline today Message-ID: <533ADEC6.4020604@gmail.com> Hi everyone, Today is the final deadline (which was extended) for submitting abstracts for the SciPy 2014 conference: https://conference.scipy.org/scipy2014/ Note that if you want to attend SciPy but your travel budget does not allow it, you can also apply for financial support, and the deadline is today too. As a reminder, SciPy 2014 will include a 'mini-symposium' on Astronomy, so this is your chance to come and present the Python-based projects you have been working on, and find out what others are doing! Cheers, Tom From ghang.naoc at gmail.com Wed Apr 2 09:55:57 2014 From: ghang.naoc at gmail.com (gonghang.naoc) Date: Wed, 2 Apr 2014 21:55:57 +0800 Subject: [AstroPy] how to make a sky plot Message-ID: Hi everybody, I made an all sky map following the standard procedure here http://matplotlib.org/examples/pylab_examples/geo_demo.html . However, I can not adjust the data range. It is always -180 to 180 and I do not know what does [-180,180] means. And I can not rotate the map. As you can see, the middle is always zero. Besides, I can not define a range which could let me plot a part sky map. Anybody knows a convenient way via EPD or Mayavi? Thanks. hang -------------- next part -------------- An HTML attachment was scrubbed... URL: From jniehof at lanl.gov Wed Apr 2 10:10:23 2014 From: jniehof at lanl.gov (Jonathan T. Niehof) Date: Wed, 02 Apr 2014 08:10:23 -0600 Subject: [AstroPy] how to make a sky plot In-Reply-To: References: Message-ID: <533C1A4F.6070804@lanl.gov> On 04/02/2014 07:55 AM, gonghang.naoc wrote: > However, I can not adjust the data range. It is always -180 to 180 and I > do not know what does [-180,180] means. > And I can not rotate the map. As you can see, the middle is always zero. > Besides, I can not define a range which could let me plot a part sky map. Trying to do set_xlim on the axes with a defined projection raises an error "It is not possible to change axes limits for geographic projections. Please consider using Basemap or Cartopy." So, try basemap? http://matplotlib.org/basemap/ It's fairly geographic-specific but should be bendable. (Don't know if it's possible to label RA in hours instead of degrees longitude.) -- Jonathan Niehof ISR-3 Space Data Systems Los Alamos National Laboratory MS-D466 Los Alamos, NM 87545 Phone: 505-667-9595 email: jniehof at lanl.gov Correspondence / Technical data or Software Publicly Available From ejensen1 at swarthmore.edu Wed Apr 2 10:31:44 2014 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Wed, 2 Apr 2014 10:31:44 -0400 Subject: [AstroPy] how to make a sky plot In-Reply-To: <533C1A4F.6070804@lanl.gov> References: <533C1A4F.6070804@lanl.gov> Message-ID: On Apr 2, 2014, at 10:10 AM, Jonathan T. Niehof wrote: > (Don't know if it's possible to label RA in hours > instead of degrees longitude.) If it isn't possible to do this directly in the plotting routine, you could do something like this to manipulate the x-axis tick labels directly. (But if you do this, don't forget when looking at your plot and modifying your plot code that you are really still plotting a variable in degrees even if your label is in hours! e.g. your limits would still have to be degrees ) fig = plt.figure() ax = fig.add_subplot(111) [ Code in here to plot your data and set axis limits. ] # Need to draw the canvas in order for ticklabels to be set: fig.canvas.draw() ticklist= ax.get_xticklabels() new_label_list = [] for label in ticklist: # Get rid of dollar signs if using Latex labels: string= label.get_text().replace('$', '') # Some labels may be blank, leave as-is: if string == '': new_label = string else: # Get numeric equivalent, change to hours: tick_num = float(string) tick_num = tick_num/15. # Note that this rounds to integer, might not be what you want: tick_string = "%d" % tick_num # Add a raised "h" to denote hours: new_label = "$" + tick_string + "^h$" new_label_list.append(new_label) new = ax.set_xticklabels(new_label_list) (Based on code from http://stackoverflow.com/questions/11244514/matplotlib-modify-tick-label-text ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From trive at astro.su.se Wed Apr 2 11:02:51 2014 From: trive at astro.su.se (=?UTF-8?B?VGjDuGdlciBFbWlsIFJpdmVyYS1UaG9yc2Vu?=) Date: Wed, 02 Apr 2014 17:02:51 +0200 Subject: [AstroPy] how to make a sky plot In-Reply-To: References: <533C1A4F.6070804@lanl.gov> Message-ID: <533C269B.1060909@astro.su.se> As far as I remember, the Kapteyn python package has some pretty good functions for doing this exact kind of thing. It uses Matplotlib as a backend. By the way, EPD is outdated. I recommend updating to Canopy or, even better *in my personal opinion) switch to Anaconda. On Wed 02 Apr 2014 04:31:44 PM CEST, Eric Jensen wrote: > > On Apr 2, 2014, at 10:10 AM, Jonathan T. Niehof wrote: > >> (Don't know if it's possible to label RA in hours >> instead of degrees longitude.) > > If it isn't possible to do this directly in the plotting routine, you > could do something like this to manipulate the x-axis tick labels > directly. (But if you do this, don't forget when looking at your plot > and modifying your plot code that you are really still plotting a > variable in degrees even if your label is in hours! e.g. your limits > would still have to be degrees ) > > fig = plt.figure() > ax = fig.add_subplot(111) > > [ Code in here to plot your data and set axis limits. ] > > # Need to draw the canvas in order for ticklabels to be set: > fig.canvas.draw() > ticklist= ax.get_xticklabels() > new_label_list = [] > for label in ticklist: > # Get rid of dollar signs if using Latex labels: > string= label.get_text().replace('$', '') > # Some labels may be blank, leave as-is: > if string == '': > new_label = string > else: > # Get numeric equivalent, change to hours: > tick_num = float(string) > tick_num = tick_num/15. > # Note that this rounds to integer, might not be what you want: > tick_string = "%d" % tick_num > # Add a raised "h" to denote hours: > new_label = "$" + tick_string + "^h$" > new_label_list.append(new_label) > new = ax.set_xticklabels(new_label_list) > > (Based on code from > http://stackoverflow.com/questions/11244514/matplotlib-modify-tick-label-text > ) > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From d.berry at jach.hawaii.edu Wed Apr 2 11:06:39 2014 From: d.berry at jach.hawaii.edu (David Berry) Date: Wed, 2 Apr 2014 16:06:39 +0100 Subject: [AstroPy] how to make a sky plot In-Reply-To: <533C269B.1060909@astro.su.se> References: <533C1A4F.6070804@lanl.gov> <533C269B.1060909@astro.su.se> Message-ID: On 2 April 2014 16:02, Th?ger Emil Rivera-Thorsen wrote: > As far as I remember, the Kapteyn python package has some pretty good > functions for doing this exact kind of thing. It uses Matplotlib as a > backend. Pyast also does this, using matplotlib as a backend. See http://dsberry.github.io/starlink/pyast.html and particularly the "Display a Graphical Coordinate Grid" section in the "Examples" section. David From marquett at iap.fr Wed Apr 2 11:06:29 2014 From: marquett at iap.fr (Marquette Jean-Baptiste) Date: Wed, 2 Apr 2014 17:06:29 +0200 Subject: [AstroPy] how to make a sky plot In-Reply-To: <533C269B.1060909@astro.su.se> References: <533C1A4F.6070804@lanl.gov> <533C269B.1060909@astro.su.se> Message-ID: <9F2B78ED-71DF-435F-8DFB-A1C39173ED9D@iap.fr> Hi all, > As far as I remember, the Kapteyn python package has some pretty good > functions for doing this exact kind of thing. It uses Matplotlib as a > backend. Have a look to APLpy: http://aplpy.github.io/ Cheers, JB -------------- next part -------------- An HTML attachment was scrubbed... URL: From trive at astro.su.se Wed Apr 2 11:22:18 2014 From: trive at astro.su.se (=?UTF-8?B?VGjDuGdlciBFbWlsIFJpdmVyYS1UaG9yc2Vu?=) Date: Wed, 02 Apr 2014 17:22:18 +0200 Subject: [AstroPy] how to make a sky plot In-Reply-To: References: <533C1A4F.6070804@lanl.gov> <533C269B.1060909@astro.su.se> Message-ID: <533C2B2A.4040404@astro.su.se> Here is an example gallery with source code of all/sky maps from Kapteyn. Looks pretty neat to me. http://www.astro.rug.nl/software/kapteyn/allsky.html On Wed 02 Apr 2014 05:06:39 PM CEST, David Berry wrote: > On 2 April 2014 16:02, Th?ger Emil Rivera-Thorsen wrote: >> As far as I remember, the Kapteyn python package has some pretty good >> functions for doing this exact kind of thing. It uses Matplotlib as a >> backend. > > Pyast also does this, using matplotlib as a backend. See > > http://dsberry.github.io/starlink/pyast.html > > and particularly the "Display a Graphical Coordinate Grid" section in > the "Examples" section. > > David > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From lsinger at caltech.edu Wed Apr 2 13:24:48 2014 From: lsinger at caltech.edu (Leo Singer) Date: Wed, 2 Apr 2014 10:24:48 -0700 Subject: [AstroPy] how to make a sky plot In-Reply-To: References: Message-ID: Hi, This is in just plain Matplotlib, but I have an axes subclass called AstroMollweideAxes that has RA running from 0h to 24h from right to left: http://www.lsc-group.phys.uwm.edu/cgit/lalsuite/tree/lalinference/python/bayestar/plot.py Cheers, Leo On Apr 2, 2014, at 6:55 AM, "gonghang.naoc" wrote: > Hi everybody, > I made an all sky map following the standard procedure here > http://matplotlib.org/examples/pylab_examples/geo_demo.html . > > However, I can not adjust the data range. It is always -180 to 180 and I do not know what does [-180,180] means. > And I can not rotate the map. As you can see, the middle is always zero. > Besides, I can not define a range which could let me plot a part sky map. > > Anybody knows a convenient way via EPD or Mayavi? > > Thanks. > hang -------------- next part -------------- An HTML attachment was scrubbed... URL: From ricardogando at gmail.com Sat Apr 5 18:45:05 2014 From: ricardogando at gmail.com (Ricardo Ogando) Date: Sat, 5 Apr 2014 19:45:05 -0300 Subject: [AstroPy] Fwd: how to make a sky plot References: Message-ID: <615BCE30-8D94-4708-9864-87CEB0C82D17@gmail.com> Hi astropy folks, I think this message from Molly bounced so I am forwarding it to you. Thanks, Ricardo Begin forwarded message: > From: Molly Swanson > Subject: Fwd: Re: [AstroPy] how to make a sky plot > Date: 5 de abril de 2014 17:58:04 BRT > To: astropy at scipy.org, ricardogando at gmail.com > > Hi Ricardo and astropy folks, > > I developed an extension from the python map-making package basemap called skymap, which I use to plot mangle masks. It uses all of basemap's machinery for managing spherical projections but does things in a sky-plotting-appropriate way. I do use degrees for labeling RA though - might be hard to get basemap to do otherwise. Anyway, check out figure 1 in http://arxiv.org/pdf/1312.4877.pdf for an example usage. > > It's not packaged up very cleanly or anything since it's embedded in my mangle plotting stuff, but if anyone wants to use it or work on including it in astropy, it's up on github within https://github.com/mollyswanson/manglepy > It's in the graphmask.py file. > > Thanks, > Molly Swanson > > ---------- Forwarded message ---------- > From: Ricardo Ogando > Date: Wed, Apr 2, 2014 at 10:42 AM > Subject: Fwd: Re: [AstroPy] how to make a sky plot > To: Molly Swanson , Molly Swanson > > > Hi Molly, > > since I saw that you developed Skymap from Basemap > but I am not sure if it is public, > I am bringing this discussion to your attention: > people trying to plot parts of the sky in the right projection, > which I do not think matplotlib currently do. > > Thanks, > Ricardo > > > > -------- Original Message -------- > Subject: Re: [AstroPy] how to make a sky plot > Date: Wed, 2 Apr 2014 10:31:44 -0400 > From: Eric Jensen > Reply-To: Astronomical Python mailing list > To: Astronomical Python mailing list > > > > > On Apr 2, 2014, at 10:10 AM, Jonathan T. Niehof wrote: > > (Don't know if it's possible to label RA in hours > instead of degrees longitude.) > > If it isn't possible to do this directly in the plotting routine, you > could do something like this to manipulate the x-axis tick labels > directly. (But if you do this, don't forget when looking at your plot > and modifying your plot code that you are really still plotting a > variable in degrees even if your label is in hours! e.g. your limits > would still have to be degrees ) > > fig = plt.figure() > ax = fig.add_subplot(111) > > [ Code in here to plot your data and set axis limits. ] > > # Need to draw the canvas in order for ticklabels to be set: > fig.canvas.draw() > ticklist= ax.get_xticklabels() > new_label_list = [] > for label in ticklist: > # Get rid of dollar signs if using Latex labels: > string= label.get_text().replace('$', '') > # Some labels may be blank, leave as-is: > if string == '': > new_label = string > else: > # Get numeric equivalent, change to hours: > tick_num = float(string) > tick_num = tick_num/15. > # Note that this rounds to integer, might not be what you want: > tick_string = "%d" % tick_num > # Add a raised "h" to denote hours: > new_label = "$" + tick_string + "^h$" > new_label_list.append(new_label) > new = ax.set_xticklabels(new_label_list) > > (Based on code from > http://stackoverflow.com/questions/11244514/matplotlib-modify-tick-label-text > ) > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Attached.txt URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From hoangthuong.hust at gmail.com Tue Apr 8 09:57:26 2014 From: hoangthuong.hust at gmail.com (=?UTF-8?B?VEjGr+G7nE5HIEhvw6BuZyDEkOG7qWM=?=) Date: Tue, 8 Apr 2014 15:57:26 +0200 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? Message-ID: Dear AstroPyer, I have problem with ideals ! Firstly, I have two array. "ek" (one dimension - value in logspace) and "gE0[]" (two dimension - value in logspace). After that I scan value ek in array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due to the numerical that in logspace, it can not equal zeros(There are some point near the 0), and then I put the error for example err < 0.08 >>>> abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to take is True but it has several value < 0.08 also true, then how can i take smallest if have several True. In [53]: abs(ek-gE0[:,0]) < 0.08 Out[53]: array([False, True, False, False, False, False, True, True, True, True], dtype=bool) ek = 0.1 In [52]: gE0[:,0] Out[52]: array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, 0.51306049, 0.15479754, 0.06105322, 0.04410808, 0.04849499]) How can i take only the value: i = 1, value = 0.04641589 and i = 9, value = 0.04410808 Thankyou very muck Merci beaucoup, Thuong ================================================ THUONG Hoang Duc Universit? des Sciences et des Technologies de Hanoi(USTH) University of Science and Technology of Hanoi(USTH) Hanoi University of Science and Technology (HUST) Email: hoangthuong.hust at gmail.com Tel: +33 06 52 92 00 96 Tel: +84 01692887738 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tvw2pu at virginia.edu Tue Apr 8 10:09:33 2014 From: tvw2pu at virginia.edu (Trey Wenger) Date: Tue, 8 Apr 2014 10:09:33 -0400 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? In-Reply-To: References: Message-ID: Hi Thuong, I would do this index = abs(gE0[:,0] - ek).argmin() .argmin() returns the index at which the previous argument is smallest. Now, gE0[;,0][index] will be the value of gE0[;,0] closest to ek. For example, IPy> x = np.array([1.1, 2.3, 4.4]) IPy> y = 2.2 IPy> index = np.abs(x-y).argmin() IPy> index Out> 1 IPy> x[index] Out> 2.3 IPy> # this is the value in x closest to y Cheers, Trey On Tue, Apr 8, 2014 at 9:57 AM, TH??NG Ho?ng ??c wrote: > Dear AstroPyer, > > I have problem with ideals ! > Firstly, I have two array. "ek" (one dimension - value in logspace) and > "gE0[]" (two dimension - value in logspace). After that I scan value ek in > array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due > to the numerical that in logspace, it can not equal zeros(There are some > point near the 0), and then I put the error for example err < 0.08 >>>> > abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to > take is True but it has several value < 0.08 also true, then how can i take > smallest if have several True. > > > In [53]: abs(ek-gE0[:,0]) < 0.08 > Out[53]: array([False, True, False, False, False, False, True, True, > True, True], dtype=bool) > > ek = 0.1 > In [52]: gE0[:,0] > Out[52]: > array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, > 0.51306049, 0.15479754, 0.06105322, 0.04410808, 0.04849499]) > > How can i take only the value: i = 1, value = 0.04641589 and i = 9, value > = 0.04410808 > > > Thankyou very muck > > Merci beaucoup, > > Thuong > > ================================================ > THUONG Hoang Duc > > Universit? des Sciences et des Technologies de Hanoi(USTH) > University of Science and Technology of Hanoi(USTH) > Hanoi University of Science and Technology (HUST) > > Email: hoangthuong.hust at gmail.com > Tel: +33 06 52 92 00 96 > Tel: +84 01692887738 > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- Trey V. Wenger Department of Astronomy University of Virginia http://www.astro.virginia.edu/~tvw2pu/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hoangthuong.hust at gmail.com Tue Apr 8 12:20:12 2014 From: hoangthuong.hust at gmail.com (=?UTF-8?B?VEjGr+G7nE5HIEhvw6BuZyDEkOG7qWM=?=) Date: Tue, 8 Apr 2014 18:20:12 +0200 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? In-Reply-To: References: Message-ID: thank you Trey, How can i find the minimum value for different location in the list. Let me show you more detail: (I am sorry, it is long ) I have: In [15]: E Out[15]: array([ 1.00000000e-03, 2.78255940e-03, 7.74263683e-03, 2.15443469e-02, 5.99484250e-02, 1.66810054e-01, 4.64158883e-01, 1.29154967e+00, 3.59381366e+00, 1.00000000e+01]) In [16]: gE0 Out[16]: array([[ 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, 1.00000000e-03], [ 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, 5.99484250e-03], [ 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, 3.59381366e-02], [ 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, 2.15443469e-01], [ 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, 1.29154967e+00], [ 1.18292276e+00, 1.20239338e+00, 1.26419499e+00, 1.38016526e+00, 1.57688572e+00, 1.91417885e+00, 2.55149610e+00, 4.10977947e+00, 7.74263683e+00, 7.74263683e+00], [ 2.77831168e-01, 2.82126806e-01, 2.95703802e-01, 3.20921794e-01, 3.62928377e-01, 4.32761236e-01, 5.56895376e-01, 8.15796501e-01, 1.61701932e+00, 4.64158883e+01], [ 7.88832931e-02, 8.01002871e-02, 8.39462486e-02, 9.10876310e-02, 1.02977169e-01, 1.22725700e-01, 1.57778342e-01, 2.30672383e-01, 4.54431889e-01, 2.78255940e+02], [ 4.46767553e-02, 4.53659668e-02, 4.75440123e-02, 5.15882797e-02, 5.83213761e-02, 6.95047231e-02, 8.93535809e-02, 1.30626292e-01, 2.57284143e-01, 1.66810054e+03], [ 4.84949885e-02, 4.92431017e-02, 5.16072881e-02, 5.59971873e-02, 6.33057070e-02, 7.54447993e-02, 9.69899542e-02, 1.41789797e-01, 2.79271195e-01, 1.00000000e+04]]) In [25]: (abs(E - gE0) < 0.02) Out[25]: array([[ True, True, True, False, False, False, False, False, False, False], [ True, True, True, True, False, False, False, False, False, False], [False, False, False, True, False, False, False, False, False, False], [False, False, False, False, False, False, False, False, False, False], [False, False, False, False, False, False, False, True, False, False], [False, False, False, False, False, False, False, False, False, False], [False, False, False, False, False, False, False, False, False, False], [False, False, False, False, False, False, False, False, False, False], [False, False, False, False, True, False, False, False, False, False], [False, False, False, False, True, False, False, False, False, False]], dtype=bool) In [26]: abs(E - gE0) Out[26]: array([[ 0.00000000e+00, 1.78255940e-03, 6.74263683e-03, 2.05443469e-02, 5.89484250e-02, 1.65810054e-01, 4.63158883e-01, 1.29054967e+00, 3.59281366e+00, 9.99900000e+00], [ 4.99484250e-03, 3.21228310e-03, 1.74779432e-03, 1.55495044e-02, 5.39535825e-02, 1.60815211e-01, 4.58164041e-01, 1.28555482e+00, 3.58781882e+00, 9.99400516e+00], [ 3.49381366e-02, 3.31555772e-02, 2.81954998e-02, 1.43937897e-02, 2.40102884e-02, 1.30871917e-01, 4.28220747e-01, 1.25561153e+00, 3.55787553e+00, 9.96406186e+00], [ 2.14443469e-01, 2.12660910e-01, 2.07700832e-01, 1.93899122e-01, 1.55495044e-01, 4.86334153e-02, 2.48715414e-01, 1.07610620e+00, 3.37837019e+00, 9.78455653e+00], [ 1.29054967e+00, 1.28876711e+00, 1.28380703e+00, 1.27000532e+00, 1.23160124e+00, 1.12473961e+00, 8.27390782e-01, 1.33226763e-15, 2.30226400e+00, 8.70845033e+00], [ 1.18192276e+00, 1.19961082e+00, 1.25645235e+00, 1.35862091e+00, 1.51693729e+00, 1.74736880e+00, 2.08733721e+00, 2.81822980e+00, 4.14882316e+00, 2.25736317e+00], [ 2.76831168e-01, 2.79344246e-01, 2.87961166e-01, 2.99377447e-01, 3.02979952e-01, 2.65951182e-01, 9.27364927e-02, 4.75753164e-01, 1.97679434e+00, 3.64158883e+01], [ 7.78832931e-02, 7.73177277e-02, 7.62036117e-02, 6.95432841e-02, 4.30287441e-02, 4.40843535e-02, 3.06380541e-01, 1.06087728e+00, 3.13938177e+00, 2.68255940e+02], [ 4.36767553e-02, 4.25834074e-02, 3.98013755e-02, 3.00439328e-02, 1.62704897e-03, 9.73053306e-02, 3.74805302e-01, 1.16092337e+00, 3.33652952e+00, 1.65810054e+03], [ 4.74949885e-02, 4.64605423e-02, 4.38646513e-02, 3.44528404e-02, 3.35728195e-03, 9.13652544e-02, 3.67168929e-01, 1.14975987e+00, 3.31454247e+00, 9.99000000e+03]]) and Finaly: At the first red line. I would to take the index[2] of value 1.78255940e-03(minimum) At the second line. I would to take the index of value 1.74779432e-03 (minimum) . . . May you try to help me Thuong, 2014-04-08 16:09 GMT+02:00 Trey Wenger : > Hi Thuong, > > I would do this > > index = abs(gE0[:,0] - ek).argmin() > > .argmin() returns the index at which the previous argument is smallest. > Now, gE0[;,0][index] will be the value of gE0[;,0] closest to ek. > > For example, > > IPy> x = np.array([1.1, 2.3, 4.4]) > IPy> y = 2.2 > IPy> index = np.abs(x-y).argmin() > IPy> index > Out> 1 > IPy> x[index] > Out> 2.3 > IPy> # this is the value in x closest to y > > Cheers, > Trey > > > On Tue, Apr 8, 2014 at 9:57 AM, TH??NG Ho?ng ??c < > hoangthuong.hust at gmail.com> wrote: > >> Dear AstroPyer, >> >> I have problem with ideals ! >> Firstly, I have two array. "ek" (one dimension - value in logspace) and >> "gE0[]" (two dimension - value in logspace). After that I scan value ek in >> array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due >> to the numerical that in logspace, it can not equal zeros(There are some >> point near the 0), and then I put the error for example err < 0.08 >>>> >> abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to >> take is True but it has several value < 0.08 also true, then how can i take >> smallest if have several True. >> >> >> In [53]: abs(ek-gE0[:,0]) < 0.08 >> Out[53]: array([False, True, False, False, False, False, True, True, >> True, True], dtype=bool) >> >> ek = 0.1 >> In [52]: gE0[:,0] >> Out[52]: >> array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, >> 0.51306049, 0.15479754, 0.06105322, 0.04410808, 0.04849499]) >> >> How can i take only the value: i = 1, value = 0.04641589 and i = 9, value >> = 0.04410808 >> >> >> Thankyou very muck >> >> Merci beaucoup, >> >> Thuong >> >> ================================================ >> THUONG Hoang Duc >> >> Universit? des Sciences et des Technologies de Hanoi(USTH) >> University of Science and Technology of Hanoi(USTH) >> Hanoi University of Science and Technology (HUST) >> >> Email: hoangthuong.hust at gmail.com >> Tel: +33 06 52 92 00 96 >> Tel: +84 01692887738 >> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > > -- > Trey V. Wenger > Department of Astronomy > University of Virginia > http://www.astro.virginia.edu/~tvw2pu/ > -- ================================================ THUONG Hoang Duc Universit? des Sciences et des Technologies de Hanoi(USTH) University of Science and Technology of Hanoi(USTH) Hanoi University of Science and Technology (HUST) Email: hoangthuong.hust at gmail.com Tel: +33 06 52 92 00 96 Tel: +84 01692887738 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tvw2pu at virginia.edu Tue Apr 8 12:45:53 2014 From: tvw2pu at virginia.edu (Trey Wenger) Date: Tue, 8 Apr 2014 12:45:53 -0400 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? In-Reply-To: References: Message-ID: Hi again, Thuong. I think I understand what you are tying to do. You are tying to find the minimum of abs(E - gE0) for every sub-array in gE0. This is what I would do: min_indicies = [abs(E - my_gE0).argmin() for my_gE0 in gE0] So, min_indicies[0] is the index of the minimum of abs(E-gE0[0]), min_indicies[1] is the index of the minimum of abs(E - gE0[1]), etc. Hope this helps, Trey On Tue, Apr 8, 2014 at 12:20 PM, TH??NG Ho?ng ??c < hoangthuong.hust at gmail.com> wrote: > thank you Trey, > > How can i find the minimum value for different location in the list. Let > me show you more detail: (I am sorry, it is long ) > > I have: > In [15]: E > Out[15]: > array([ 1.00000000e-03, 2.78255940e-03, 7.74263683e-03, > 2.15443469e-02, 5.99484250e-02, 1.66810054e-01, > 4.64158883e-01, 1.29154967e+00, 3.59381366e+00, > 1.00000000e+01]) > > In [16]: gE0 > Out[16]: > array([[ 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, > 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, > 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, > 1.00000000e-03], > [ 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, > 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, > 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, > 5.99484250e-03], > [ 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, > 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, > 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, > 3.59381366e-02], > [ 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, > 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, > 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, > 2.15443469e-01], > [ 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, > 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, > 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, > 1.29154967e+00], > [ 1.18292276e+00, 1.20239338e+00, 1.26419499e+00, > 1.38016526e+00, 1.57688572e+00, 1.91417885e+00, > 2.55149610e+00, 4.10977947e+00, 7.74263683e+00, > 7.74263683e+00], > [ 2.77831168e-01, 2.82126806e-01, 2.95703802e-01, > 3.20921794e-01, 3.62928377e-01, 4.32761236e-01, > 5.56895376e-01, 8.15796501e-01, 1.61701932e+00, > 4.64158883e+01], > [ 7.88832931e-02, 8.01002871e-02, 8.39462486e-02, > 9.10876310e-02, 1.02977169e-01, 1.22725700e-01, > 1.57778342e-01, 2.30672383e-01, 4.54431889e-01, > 2.78255940e+02], > [ 4.46767553e-02, 4.53659668e-02, 4.75440123e-02, > 5.15882797e-02, 5.83213761e-02, 6.95047231e-02, > 8.93535809e-02, 1.30626292e-01, 2.57284143e-01, > 1.66810054e+03], > [ 4.84949885e-02, 4.92431017e-02, 5.16072881e-02, > 5.59971873e-02, 6.33057070e-02, 7.54447993e-02, > 9.69899542e-02, 1.41789797e-01, 2.79271195e-01, > 1.00000000e+04]]) > > In [25]: (abs(E - gE0) < 0.02) > Out[25]: > array([[ True, True, True, False, False, False, False, False, False, > False], > [ True, True, True, True, False, False, False, False, False, > False], > [False, False, False, True, False, False, False, False, False, > False], > [False, False, False, False, False, False, False, False, False, > False], > [False, False, False, False, False, False, False, True, False, > False], > [False, False, False, False, False, False, False, False, False, > False], > [False, False, False, False, False, False, False, False, False, > False], > [False, False, False, False, False, False, False, False, False, > False], > [False, False, False, False, True, False, False, False, False, > False], > [False, False, False, False, True, False, False, False, False, > False]], dtype=bool) > > In [26]: abs(E - gE0) > Out[26]: > array([[ 0.00000000e+00, 1.78255940e-03, 6.74263683e-03, > 2.05443469e-02, 5.89484250e-02, 1.65810054e-01, > 4.63158883e-01, 1.29054967e+00, 3.59281366e+00, > 9.99900000e+00], > [ 4.99484250e-03, 3.21228310e-03, 1.74779432e-03, > 1.55495044e-02, 5.39535825e-02, 1.60815211e-01, > 4.58164041e-01, 1.28555482e+00, 3.58781882e+00, > 9.99400516e+00], > [ 3.49381366e-02, 3.31555772e-02, 2.81954998e-02, > 1.43937897e-02, 2.40102884e-02, 1.30871917e-01, > 4.28220747e-01, 1.25561153e+00, 3.55787553e+00, > 9.96406186e+00], > [ 2.14443469e-01, 2.12660910e-01, 2.07700832e-01, > 1.93899122e-01, 1.55495044e-01, 4.86334153e-02, > 2.48715414e-01, 1.07610620e+00, 3.37837019e+00, > 9.78455653e+00], > [ 1.29054967e+00, 1.28876711e+00, 1.28380703e+00, > 1.27000532e+00, 1.23160124e+00, 1.12473961e+00, > 8.27390782e-01, 1.33226763e-15, 2.30226400e+00, > 8.70845033e+00], > [ 1.18192276e+00, 1.19961082e+00, 1.25645235e+00, > 1.35862091e+00, 1.51693729e+00, 1.74736880e+00, > 2.08733721e+00, 2.81822980e+00, 4.14882316e+00, > 2.25736317e+00], > [ 2.76831168e-01, 2.79344246e-01, 2.87961166e-01, > 2.99377447e-01, 3.02979952e-01, 2.65951182e-01, > 9.27364927e-02, 4.75753164e-01, 1.97679434e+00, > 3.64158883e+01], > [ 7.78832931e-02, 7.73177277e-02, 7.62036117e-02, > 6.95432841e-02, 4.30287441e-02, 4.40843535e-02, > 3.06380541e-01, 1.06087728e+00, 3.13938177e+00, > 2.68255940e+02], > [ 4.36767553e-02, 4.25834074e-02, 3.98013755e-02, > 3.00439328e-02, 1.62704897e-03, 9.73053306e-02, > 3.74805302e-01, 1.16092337e+00, 3.33652952e+00, > 1.65810054e+03], > [ 4.74949885e-02, 4.64605423e-02, 4.38646513e-02, > 3.44528404e-02, 3.35728195e-03, 9.13652544e-02, > 3.67168929e-01, 1.14975987e+00, 3.31454247e+00, > 9.99000000e+03]]) > > and Finaly: > At the first red line. I would to take the index[2] of value > 1.78255940e-03 (minimum) > At the second line. I would to take the index of value 1.74779432e-03 > (minimum) > . > . > . > > May you try to help me > > Thuong, > > > 2014-04-08 16:09 GMT+02:00 Trey Wenger : > >> Hi Thuong, >> >> I would do this >> >> index = abs(gE0[:,0] - ek).argmin() >> >> .argmin() returns the index at which the previous argument is smallest. >> Now, gE0[;,0][index] will be the value of gE0[;,0] closest to ek. >> >> For example, >> >> IPy> x = np.array([1.1, 2.3, 4.4]) >> IPy> y = 2.2 >> IPy> index = np.abs(x-y).argmin() >> IPy> index >> Out> 1 >> IPy> x[index] >> Out> 2.3 >> IPy> # this is the value in x closest to y >> >> Cheers, >> Trey >> >> >> On Tue, Apr 8, 2014 at 9:57 AM, TH??NG Ho?ng ??c < >> hoangthuong.hust at gmail.com> wrote: >> >>> Dear AstroPyer, >>> >>> I have problem with ideals ! >>> Firstly, I have two array. "ek" (one dimension - value in logspace) and >>> "gE0[]" (two dimension - value in logspace). After that I scan value ek in >>> array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due >>> to the numerical that in logspace, it can not equal zeros(There are some >>> point near the 0), and then I put the error for example err < 0.08 >>>> >>> abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to >>> take is True but it has several value < 0.08 also true, then how can i take >>> smallest if have several True. >>> >>> >>> In [53]: abs(ek-gE0[:,0]) < 0.08 >>> Out[53]: array([False, True, False, False, False, False, True, True, >>> True, True], dtype=bool) >>> >>> ek = 0.1 >>> In [52]: gE0[:,0] >>> Out[52]: >>> array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, >>> 0.51306049, 0.15479754, 0.06105322, 0.04410808, 0.04849499]) >>> >>> How can i take only the value: i = 1, value = 0.04641589 and i = 9, >>> value = 0.04410808 >>> >>> >>> Thankyou very muck >>> >>> Merci beaucoup, >>> >>> Thuong >>> >>> ================================================ >>> THUONG Hoang Duc >>> >>> Universit? des Sciences et des Technologies de Hanoi(USTH) >>> University of Science and Technology of Hanoi(USTH) >>> Hanoi University of Science and Technology (HUST) >>> >>> Email: hoangthuong.hust at gmail.com >>> Tel: +33 06 52 92 00 96 >>> Tel: +84 01692887738 >>> >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >>> >>> >> >> >> -- >> Trey V. Wenger >> Department of Astronomy >> University of Virginia >> http://www.astro.virginia.edu/~tvw2pu/ >> > > > > -- > > ================================================ > THUONG Hoang Duc > > Universit? des Sciences et des Technologies de Hanoi(USTH) > University of Science and Technology of Hanoi(USTH) > Hanoi University of Science and Technology (HUST) > > Email: hoangthuong.hust at gmail.com > Tel: +33 06 52 92 00 96 > Tel: +84 01692887738 > > -- Trey V. Wenger Department of Astronomy University of Virginia http://www.astro.virginia.edu/~tvw2pu/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hoangthuong.hust at gmail.com Tue Apr 8 17:31:11 2014 From: hoangthuong.hust at gmail.com (=?UTF-8?B?VEjGr+G7nE5HIEhvw6BuZyDEkOG7qWM=?=) Date: Tue, 8 Apr 2014 23:31:11 +0200 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? In-Reply-To: References: Message-ID: HI Trey, I wish you may understand. "You are tying to find the minimum of abs(E - gE0) for every sub-array in gE0 ". It is not for every sub_array(for diferent location in array). Firstly it have condition : abs(E - gE0) < 0.02. And after that I am typing to take the closest value E-gE0 == 0 (It also is minimum) therefor maybe some sub_arrays have not value. I am sorry, It is complicate to understand. Hopefully you can help me. I will show you a simple example:(The main ideal of my problem) I have array ar = [1,8,9,10,100,101,102,1000,1001,1002,1003,5000] I want to take I = [1,8,100,1000,5000] because 1 is alone and non value follow. 8 is minimum of [8,9,10] and 8,9,10 is follow together..... Thank you - Merci Thuong 2014-04-08 18:45 GMT+02:00 Trey Wenger : > Hi again, Thuong. > > I think I understand what you are tying to do. You are tying to find the > minimum of abs(E - gE0) for every sub-array in gE0. This is what I would do: > > min_indicies = [abs(E - my_gE0).argmin() for my_gE0 in gE0] > > So, min_indicies[0] is the index of the minimum of abs(E-gE0[0]), > min_indicies[1] is the index of the minimum of abs(E - gE0[1]), etc. > > Hope this helps, > Trey > > > > On Tue, Apr 8, 2014 at 12:20 PM, TH??NG Ho?ng ??c < > hoangthuong.hust at gmail.com> wrote: > >> thank you Trey, >> >> How can i find the minimum value for different location in the list. Let >> me show you more detail: (I am sorry, it is long ) >> >> I have: >> In [15]: E >> Out[15]: >> array([ 1.00000000e-03, 2.78255940e-03, 7.74263683e-03, >> 2.15443469e-02, 5.99484250e-02, 1.66810054e-01, >> 4.64158883e-01, 1.29154967e+00, 3.59381366e+00, >> 1.00000000e+01]) >> >> In [16]: gE0 >> Out[16]: >> array([[ 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >> 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >> 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >> 1.00000000e-03], >> [ 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >> 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >> 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >> 5.99484250e-03], >> [ 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >> 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >> 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >> 3.59381366e-02], >> [ 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >> 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >> 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >> 2.15443469e-01], >> [ 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >> 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >> 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >> 1.29154967e+00], >> [ 1.18292276e+00, 1.20239338e+00, 1.26419499e+00, >> 1.38016526e+00, 1.57688572e+00, 1.91417885e+00, >> 2.55149610e+00, 4.10977947e+00, 7.74263683e+00, >> 7.74263683e+00], >> [ 2.77831168e-01, 2.82126806e-01, 2.95703802e-01, >> 3.20921794e-01, 3.62928377e-01, 4.32761236e-01, >> 5.56895376e-01, 8.15796501e-01, 1.61701932e+00, >> 4.64158883e+01], >> [ 7.88832931e-02, 8.01002871e-02, 8.39462486e-02, >> 9.10876310e-02, 1.02977169e-01, 1.22725700e-01, >> 1.57778342e-01, 2.30672383e-01, 4.54431889e-01, >> 2.78255940e+02], >> [ 4.46767553e-02, 4.53659668e-02, 4.75440123e-02, >> 5.15882797e-02, 5.83213761e-02, 6.95047231e-02, >> 8.93535809e-02, 1.30626292e-01, 2.57284143e-01, >> 1.66810054e+03], >> [ 4.84949885e-02, 4.92431017e-02, 5.16072881e-02, >> 5.59971873e-02, 6.33057070e-02, 7.54447993e-02, >> 9.69899542e-02, 1.41789797e-01, 2.79271195e-01, >> 1.00000000e+04]]) >> >> In [25]: (abs(E - gE0) < 0.02) >> Out[25]: >> array([[ True, True, True, False, False, False, False, False, False, >> False], >> [ True, True, True, True, False, False, False, False, False, >> False], >> [False, False, False, True, False, False, False, False, False, >> False], >> [False, False, False, False, False, False, False, False, False, >> False], >> [False, False, False, False, False, False, False, True, False, >> False], >> [False, False, False, False, False, False, False, False, False, >> False], >> [False, False, False, False, False, False, False, False, False, >> False], >> [False, False, False, False, False, False, False, False, False, >> False], >> [False, False, False, False, True, False, False, False, False, >> False], >> [False, False, False, False, True, False, False, False, False, >> False]], dtype=bool) >> >> In [26]: abs(E - gE0) >> Out[26]: >> array([[ 0.00000000e+00, 1.78255940e-03, 6.74263683e-03, >> 2.05443469e-02, 5.89484250e-02, 1.65810054e-01, >> 4.63158883e-01, 1.29054967e+00, 3.59281366e+00, >> 9.99900000e+00], >> [ 4.99484250e-03, 3.21228310e-03, 1.74779432e-03, >> 1.55495044e-02, 5.39535825e-02, 1.60815211e-01, >> 4.58164041e-01, 1.28555482e+00, 3.58781882e+00, >> 9.99400516e+00], >> [ 3.49381366e-02, 3.31555772e-02, 2.81954998e-02, >> 1.43937897e-02, 2.40102884e-02, 1.30871917e-01, >> 4.28220747e-01, 1.25561153e+00, 3.55787553e+00, >> 9.96406186e+00], >> [ 2.14443469e-01, 2.12660910e-01, 2.07700832e-01, >> 1.93899122e-01, 1.55495044e-01, 4.86334153e-02, >> 2.48715414e-01, 1.07610620e+00, 3.37837019e+00, >> 9.78455653e+00], >> [ 1.29054967e+00, 1.28876711e+00, 1.28380703e+00, >> 1.27000532e+00, 1.23160124e+00, 1.12473961e+00, >> 8.27390782e-01, 1.33226763e-15, 2.30226400e+00, >> 8.70845033e+00], >> [ 1.18192276e+00, 1.19961082e+00, 1.25645235e+00, >> 1.35862091e+00, 1.51693729e+00, 1.74736880e+00, >> 2.08733721e+00, 2.81822980e+00, 4.14882316e+00, >> 2.25736317e+00], >> [ 2.76831168e-01, 2.79344246e-01, 2.87961166e-01, >> 2.99377447e-01, 3.02979952e-01, 2.65951182e-01, >> 9.27364927e-02, 4.75753164e-01, 1.97679434e+00, >> 3.64158883e+01], >> [ 7.78832931e-02, 7.73177277e-02, 7.62036117e-02, >> 6.95432841e-02, 4.30287441e-02, 4.40843535e-02, >> 3.06380541e-01, 1.06087728e+00, 3.13938177e+00, >> 2.68255940e+02], >> [ 4.36767553e-02, 4.25834074e-02, 3.98013755e-02, >> 3.00439328e-02, 1.62704897e-03, 9.73053306e-02, >> 3.74805302e-01, 1.16092337e+00, 3.33652952e+00, >> 1.65810054e+03], >> [ 4.74949885e-02, 4.64605423e-02, 4.38646513e-02, >> 3.44528404e-02, 3.35728195e-03, 9.13652544e-02, >> 3.67168929e-01, 1.14975987e+00, 3.31454247e+00, >> 9.99000000e+03]]) >> >> and Finaly: >> At the first red line. I would to take the index[2] of value >> 1.78255940e-03 (minimum) >> At the second line. I would to take the index of value 1.74779432e-03 >> (minimum) >> . >> . >> . >> >> May you try to help me >> >> Thuong, >> >> >> 2014-04-08 16:09 GMT+02:00 Trey Wenger : >> >>> Hi Thuong, >>> >>> I would do this >>> >>> index = abs(gE0[:,0] - ek).argmin() >>> >>> .argmin() returns the index at which the previous argument is smallest. >>> Now, gE0[;,0][index] will be the value of gE0[;,0] closest to ek. >>> >>> For example, >>> >>> IPy> x = np.array([1.1, 2.3, 4.4]) >>> IPy> y = 2.2 >>> IPy> index = np.abs(x-y).argmin() >>> IPy> index >>> Out> 1 >>> IPy> x[index] >>> Out> 2.3 >>> IPy> # this is the value in x closest to y >>> >>> Cheers, >>> Trey >>> >>> >>> On Tue, Apr 8, 2014 at 9:57 AM, TH??NG Ho?ng ??c < >>> hoangthuong.hust at gmail.com> wrote: >>> >>>> Dear AstroPyer, >>>> >>>> I have problem with ideals ! >>>> Firstly, I have two array. "ek" (one dimension - value in logspace) and >>>> "gE0[]" (two dimension - value in logspace). After that I scan value ek in >>>> array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. Due >>>> to the numerical that in logspace, it can not equal zeros(There are some >>>> point near the 0), and then I put the error for example err < 0.08 >>>> >>>> abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I would to >>>> take is True but it has several value < 0.08 also true, then how can i take >>>> smallest if have several True. >>>> >>>> >>>> In [53]: abs(ek-gE0[:,0]) < 0.08 >>>> Out[53]: array([False, True, False, False, False, False, True, >>>> True, True, True], dtype=bool) >>>> >>>> ek = 0.1 >>>> In [52]: gE0[:,0] >>>> Out[52]: >>>> array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, >>>> 0.51306049, 0.15479754, 0.06105322, 0.04410808, 0.04849499]) >>>> >>>> How can i take only the value: i = 1, value = 0.04641589 and i = 9, >>>> value = 0.04410808 >>>> >>>> >>>> Thankyou very muck >>>> >>>> Merci beaucoup, >>>> >>>> Thuong >>>> >>>> ================================================ >>>> THUONG Hoang Duc >>>> >>>> Universit? des Sciences et des Technologies de Hanoi(USTH) >>>> University of Science and Technology of Hanoi(USTH) >>>> Hanoi University of Science and Technology (HUST) >>>> >>>> Email: hoangthuong.hust at gmail.com >>>> Tel: +33 06 52 92 00 96 >>>> Tel: +84 01692887738 >>>> >>>> >>>> _______________________________________________ >>>> AstroPy mailing list >>>> AstroPy at scipy.org >>>> http://mail.scipy.org/mailman/listinfo/astropy >>>> >>>> >>> >>> >>> -- >>> Trey V. Wenger >>> Department of Astronomy >>> University of Virginia >>> http://www.astro.virginia.edu/~tvw2pu/ >>> >> >> >> >> -- >> >> ================================================ >> THUONG Hoang Duc >> >> Universit? des Sciences et des Technologies de Hanoi(USTH) >> University of Science and Technology of Hanoi(USTH) >> Hanoi University of Science and Technology (HUST) >> >> Email: hoangthuong.hust at gmail.com >> Tel: +33 06 52 92 00 96 >> Tel: +84 01692887738 >> >> > > > -- > Trey V. Wenger > Department of Astronomy > University of Virginia > http://www.astro.virginia.edu/~tvw2pu/ > -- ================================================ THUONG Hoang Duc Universit? des Sciences et des Technologies de Hanoi(USTH) University of Science and Technology of Hanoi(USTH) Hanoi University of Science and Technology (HUST) Email: hoangthuong.hust at gmail.com Tel: +33 06 52 92 00 96 Tel: +84 01692887738 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tvw2pu at virginia.edu Tue Apr 8 18:12:14 2014 From: tvw2pu at virginia.edu (Trey Wenger) Date: Tue, 8 Apr 2014 18:12:14 -0400 Subject: [AstroPy] How can I take the index of "True" value and minimum "True" in list with python ? In-Reply-To: References: Message-ID: Hi again, Third time is the charm! You can do this to mask out the array where the difference is greater than 0.02: IPy> diff = abs(E - gE0)*(abs(E - gE0) < 0.02) IPy> diff Out> array([[ 0. , 0.00178256, 0.00674264, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0.00499484, 0.00321228, 0.00174779, 0.0155495 , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0.01439379, 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.00162705, 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.00335728, 0. , 0. , 0. , 0. , 0. ]]) Now, to get the minima that fulfill this criterion, get the minimum from the non-zero values in this diff array: IPy> min_values = [(-1 if len(d.nonzero()[0]) == 0 else min(d[d.nonzero()[0]])) for d in diff] IPy> min_values Out> [0.0017825594000000001, 0.00174779433, 0.014393789699999996, -1, -1, -1, -1, -1, 0.0016270488999999971, 0.0033572820000000031] So, the min_values list is filled with -1 if there is difference below 0.2, otherwise it is filled with the minimum difference. Hope this helps! Trey On Tue, Apr 8, 2014 at 5:31 PM, TH??NG Ho?ng ??c wrote: > HI Trey, > > I wish you may understand. "You are tying to find the minimum of abs(E - > gE0) for every sub-array in gE0 ". It is not for every sub_array(for > diferent location in array). > Firstly it have condition : abs(E - gE0) < 0.02. And after that I am > typing to take the closest value E-gE0 == 0 (It also is minimum) therefor > maybe some sub_arrays have not value. I am sorry, It is complicate to > understand. Hopefully you can help me. > > I will show you a simple example:(The main ideal of my problem) > > I have array ar = [1,8,9,10,100,101,102,1000,1001,1002,1003,5000] > > I want to take I = [1,8,100,1000,5000] because 1 is alone and non value > follow. 8 is minimum of [8,9,10] and 8,9,10 is follow together..... > > Thank you - Merci > Thuong > > > 2014-04-08 18:45 GMT+02:00 Trey Wenger : > >> Hi again, Thuong. >> >> I think I understand what you are tying to do. You are tying to find the >> minimum of abs(E - gE0) for every sub-array in gE0. This is what I would do: >> >> min_indicies = [abs(E - my_gE0).argmin() for my_gE0 in gE0] >> >> So, min_indicies[0] is the index of the minimum of abs(E-gE0[0]), >> min_indicies[1] is the index of the minimum of abs(E - gE0[1]), etc. >> >> Hope this helps, >> Trey >> >> >> >> On Tue, Apr 8, 2014 at 12:20 PM, TH??NG Ho?ng ??c < >> hoangthuong.hust at gmail.com> wrote: >> >>> thank you Trey, >>> >>> How can i find the minimum value for different location in the list. Let >>> me show you more detail: (I am sorry, it is long ) >>> >>> I have: >>> In [15]: E >>> Out[15]: >>> array([ 1.00000000e-03, 2.78255940e-03, 7.74263683e-03, >>> 2.15443469e-02, 5.99484250e-02, 1.66810054e-01, >>> 4.64158883e-01, 1.29154967e+00, 3.59381366e+00, >>> 1.00000000e+01]) >>> >>> In [16]: gE0 >>> Out[16]: >>> array([[ 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >>> 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >>> 1.00000000e-03, 1.00000000e-03, 1.00000000e-03, >>> 1.00000000e-03], >>> [ 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >>> 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >>> 5.99484250e-03, 5.99484250e-03, 5.99484250e-03, >>> 5.99484250e-03], >>> [ 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >>> 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >>> 3.59381366e-02, 3.59381366e-02, 3.59381366e-02, >>> 3.59381366e-02], >>> [ 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >>> 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >>> 2.15443469e-01, 2.15443469e-01, 2.15443469e-01, >>> 2.15443469e-01], >>> [ 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >>> 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >>> 1.29154967e+00, 1.29154967e+00, 1.29154967e+00, >>> 1.29154967e+00], >>> [ 1.18292276e+00, 1.20239338e+00, 1.26419499e+00, >>> 1.38016526e+00, 1.57688572e+00, 1.91417885e+00, >>> 2.55149610e+00, 4.10977947e+00, 7.74263683e+00, >>> 7.74263683e+00], >>> [ 2.77831168e-01, 2.82126806e-01, 2.95703802e-01, >>> 3.20921794e-01, 3.62928377e-01, 4.32761236e-01, >>> 5.56895376e-01, 8.15796501e-01, 1.61701932e+00, >>> 4.64158883e+01], >>> [ 7.88832931e-02, 8.01002871e-02, 8.39462486e-02, >>> 9.10876310e-02, 1.02977169e-01, 1.22725700e-01, >>> 1.57778342e-01, 2.30672383e-01, 4.54431889e-01, >>> 2.78255940e+02], >>> [ 4.46767553e-02, 4.53659668e-02, 4.75440123e-02, >>> 5.15882797e-02, 5.83213761e-02, 6.95047231e-02, >>> 8.93535809e-02, 1.30626292e-01, 2.57284143e-01, >>> 1.66810054e+03], >>> [ 4.84949885e-02, 4.92431017e-02, 5.16072881e-02, >>> 5.59971873e-02, 6.33057070e-02, 7.54447993e-02, >>> 9.69899542e-02, 1.41789797e-01, 2.79271195e-01, >>> 1.00000000e+04]]) >>> >>> In [25]: (abs(E - gE0) < 0.02) >>> Out[25]: >>> array([[ True, True, True, False, False, False, False, False, False, >>> False], >>> [ True, True, True, True, False, False, False, False, False, >>> False], >>> [False, False, False, True, False, False, False, False, False, >>> False], >>> [False, False, False, False, False, False, False, False, False, >>> False], >>> [False, False, False, False, False, False, False, True, False, >>> False], >>> [False, False, False, False, False, False, False, False, False, >>> False], >>> [False, False, False, False, False, False, False, False, False, >>> False], >>> [False, False, False, False, False, False, False, False, False, >>> False], >>> [False, False, False, False, True, False, False, False, False, >>> False], >>> [False, False, False, False, True, False, False, False, False, >>> False]], dtype=bool) >>> >>> In [26]: abs(E - gE0) >>> Out[26]: >>> array([[ 0.00000000e+00, 1.78255940e-03, 6.74263683e-03, >>> 2.05443469e-02, 5.89484250e-02, 1.65810054e-01, >>> 4.63158883e-01, 1.29054967e+00, 3.59281366e+00, >>> 9.99900000e+00], >>> [ 4.99484250e-03, 3.21228310e-03, 1.74779432e-03, >>> 1.55495044e-02, 5.39535825e-02, 1.60815211e-01, >>> 4.58164041e-01, 1.28555482e+00, 3.58781882e+00, >>> 9.99400516e+00], >>> [ 3.49381366e-02, 3.31555772e-02, 2.81954998e-02, >>> 1.43937897e-02, 2.40102884e-02, 1.30871917e-01, >>> 4.28220747e-01, 1.25561153e+00, 3.55787553e+00, >>> 9.96406186e+00], >>> [ 2.14443469e-01, 2.12660910e-01, 2.07700832e-01, >>> 1.93899122e-01, 1.55495044e-01, 4.86334153e-02, >>> 2.48715414e-01, 1.07610620e+00, 3.37837019e+00, >>> 9.78455653e+00], >>> [ 1.29054967e+00, 1.28876711e+00, 1.28380703e+00, >>> 1.27000532e+00, 1.23160124e+00, 1.12473961e+00, >>> 8.27390782e-01, 1.33226763e-15, 2.30226400e+00, >>> 8.70845033e+00], >>> [ 1.18192276e+00, 1.19961082e+00, 1.25645235e+00, >>> 1.35862091e+00, 1.51693729e+00, 1.74736880e+00, >>> 2.08733721e+00, 2.81822980e+00, 4.14882316e+00, >>> 2.25736317e+00], >>> [ 2.76831168e-01, 2.79344246e-01, 2.87961166e-01, >>> 2.99377447e-01, 3.02979952e-01, 2.65951182e-01, >>> 9.27364927e-02, 4.75753164e-01, 1.97679434e+00, >>> 3.64158883e+01], >>> [ 7.78832931e-02, 7.73177277e-02, 7.62036117e-02, >>> 6.95432841e-02, 4.30287441e-02, 4.40843535e-02, >>> 3.06380541e-01, 1.06087728e+00, 3.13938177e+00, >>> 2.68255940e+02], >>> [ 4.36767553e-02, 4.25834074e-02, 3.98013755e-02, >>> 3.00439328e-02, 1.62704897e-03, 9.73053306e-02, >>> 3.74805302e-01, 1.16092337e+00, 3.33652952e+00, >>> 1.65810054e+03], >>> [ 4.74949885e-02, 4.64605423e-02, 4.38646513e-02, >>> 3.44528404e-02, 3.35728195e-03, 9.13652544e-02, >>> 3.67168929e-01, 1.14975987e+00, 3.31454247e+00, >>> 9.99000000e+03]]) >>> >>> and Finaly: >>> At the first red line. I would to take the index[2] of value >>> 1.78255940e-03 (minimum) >>> At the second line. I would to take the index of value 1.74779432e-03 >>> (minimum) >>> . >>> . >>> . >>> >>> May you try to help me >>> >>> Thuong, >>> >>> >>> 2014-04-08 16:09 GMT+02:00 Trey Wenger : >>> >>>> Hi Thuong, >>>> >>>> I would do this >>>> >>>> index = abs(gE0[:,0] - ek).argmin() >>>> >>>> .argmin() returns the index at which the previous argument is smallest. >>>> Now, gE0[;,0][index] will be the value of gE0[;,0] closest to ek. >>>> >>>> For example, >>>> >>>> IPy> x = np.array([1.1, 2.3, 4.4]) >>>> IPy> y = 2.2 >>>> IPy> index = np.abs(x-y).argmin() >>>> IPy> index >>>> Out> 1 >>>> IPy> x[index] >>>> Out> 2.3 >>>> IPy> # this is the value in x closest to y >>>> >>>> Cheers, >>>> Trey >>>> >>>> >>>> On Tue, Apr 8, 2014 at 9:57 AM, TH??NG Ho?ng ??c < >>>> hoangthuong.hust at gmail.com> wrote: >>>> >>>>> Dear AstroPyer, >>>>> >>>>> I have problem with ideals ! >>>>> Firstly, I have two array. "ek" (one dimension - value in logspace) >>>>> and "gE0[]" (two dimension - value in logspace). After that I scan value ek >>>>> in array gE0 to find the equal value, It mean that abs(ek-gE0[:,0]) = 0. >>>>> Due to the numerical that in logspace, it can not equal zeros(There are >>>>> some point near the 0), and then I put the error for example err < 0.08 >>>>> >>>> abs(ek-gE0[:,0]) < 0.08. You can see the value below. The result I >>>>> would to take is True but it has several value < 0.08 also true, then how >>>>> can i take smallest if have several True. >>>>> >>>>> >>>>> In [53]: abs(ek-gE0[:,0]) < 0.08 >>>>> Out[53]: array([False, True, False, False, False, False, True, >>>>> True, True, True], dtype=bool) >>>>> >>>>> ek = 0.1 >>>>> In [52]: gE0[:,0] >>>>> Out[52]: >>>>> array([ 0.01 , 0.04641589, 0.21544347, 1. , 1.93593016, >>>>> 0.51306049, 0.15479754, 0.06105322, 0.04410808, >>>>> 0.04849499]) >>>>> >>>>> How can i take only the value: i = 1, value = 0.04641589 and i = 9, >>>>> value = 0.04410808 >>>>> >>>>> >>>>> Thankyou very muck >>>>> >>>>> Merci beaucoup, >>>>> >>>>> Thuong >>>>> >>>>> ================================================ >>>>> THUONG Hoang Duc >>>>> >>>>> Universit? des Sciences et des Technologies de Hanoi(USTH) >>>>> University of Science and Technology of Hanoi(USTH) >>>>> Hanoi University of Science and Technology (HUST) >>>>> >>>>> Email: hoangthuong.hust at gmail.com >>>>> Tel: +33 06 52 92 00 96 >>>>> Tel: +84 01692887738 >>>>> >>>>> >>>>> _______________________________________________ >>>>> AstroPy mailing list >>>>> AstroPy at scipy.org >>>>> http://mail.scipy.org/mailman/listinfo/astropy >>>>> >>>>> >>>> >>>> >>>> -- >>>> Trey V. Wenger >>>> Department of Astronomy >>>> University of Virginia >>>> http://www.astro.virginia.edu/~tvw2pu/ >>>> >>> >>> >>> >>> -- >>> >>> ================================================ >>> THUONG Hoang Duc >>> >>> Universit? des Sciences et des Technologies de Hanoi(USTH) >>> University of Science and Technology of Hanoi(USTH) >>> Hanoi University of Science and Technology (HUST) >>> >>> Email: hoangthuong.hust at gmail.com >>> Tel: +33 06 52 92 00 96 >>> Tel: +84 01692887738 >>> >>> >> >> >> -- >> Trey V. Wenger >> Department of Astronomy >> University of Virginia >> http://www.astro.virginia.edu/~tvw2pu/ >> > > > > -- > > ================================================ > THUONG Hoang Duc > > Universit? des Sciences et des Technologies de Hanoi(USTH) > University of Science and Technology of Hanoi(USTH) > Hanoi University of Science and Technology (HUST) > > Email: hoangthuong.hust at gmail.com > Tel: +33 06 52 92 00 96 > Tel: +84 01692887738 > > -- Trey V. Wenger Department of Astronomy University of Virginia http://www.astro.virginia.edu/~tvw2pu/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lsinger at caltech.edu Thu Apr 10 18:21:24 2014 From: lsinger at caltech.edu (Leo Singer) Date: Thu, 10 Apr 2014 15:21:24 -0700 Subject: [AstroPy] Write machine readable tables in Python? Message-ID: Hi, Does anyone know of a tool for writing Machine Readable Tables (CDS format) in Python? I know that astropy.table and asciitable can read them, but I need to write one. Thanks, Leo Singer Graduate Student @ LIGO-Caltech From derek at astro.physik.uni-goettingen.de Thu Apr 10 18:57:44 2014 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Fri, 11 Apr 2014 00:57:44 +0200 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: Message-ID: <360F7B0A-BC1A-425B-AA06-DF9FA0818F79@astro.physik.uni-goettingen.de> On 11 Apr 2014, at 12:21 am, Leo Singer wrote: > Does anyone know of a tool for writing Machine Readable Tables (CDS format) in Python? I know that astropy.table and asciitable can read them, but I need to write one. ATpy came with write support various ascii formats: http://atpy.readthedocs.org/en/stable/format_ascii.html The core of this has made it afaik into astropy.table; a quick look at the Table.write documentation did not show any explicit mention of CDS, but I?d think it should not be too difficult to reproduce the functionality. Cheers, Derek From aldcroft at head.cfa.harvard.edu Thu Apr 10 19:10:57 2014 From: aldcroft at head.cfa.harvard.edu (Aldcroft, Thomas) Date: Thu, 10 Apr 2014 19:10:57 -0400 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: <360F7B0A-BC1A-425B-AA06-DF9FA0818F79@astro.physik.uni-goettingen.de> References: <360F7B0A-BC1A-425B-AA06-DF9FA0818F79@astro.physik.uni-goettingen.de> Message-ID: On Thu, Apr 10, 2014 at 6:57 PM, Derek Homeier < derek at astro.physik.uni-goettingen.de> wrote: > On 11 Apr 2014, at 12:21 am, Leo Singer wrote: > > > Does anyone know of a tool for writing Machine Readable Tables (CDS > format) in Python? I know that astropy.table and asciitable can read them, > but I need to write one. > Sorry, there is no support for writing CDS in astropy, asciitable or ATpy. If anybody knows of any code for doing this we could hopefully adapt for astropy.io.ascii. Otherwise this is an opportunity to contribute to astropy! :-) Cheers, Tom > > ATpy came with write support various ascii formats: > > http://atpy.readthedocs.org/en/stable/format_ascii.html > > The core of this has made it afaik into astropy.table; a quick look at the > Table.write documentation > did not show any explicit mention of CDS, but I'd think it should not be > too difficult to > reproduce the functionality. > > Cheers, > Derek > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From npkuin at gmail.com Thu Apr 10 19:28:22 2014 From: npkuin at gmail.com (Paul Kuin) Date: Fri, 11 Apr 2014 00:28:22 +0100 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: Message-ID: Hi Leo, Do you mean that you need to generate the ascii tables as well as the format tables for the ReadMe file? Paul On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: > Hi, > > Does anyone know of a tool for writing Machine Readable Tables (CDS > format) in Python? I know that astropy.table and asciitable can read them, > but I need to write one. > > Thanks, > Leo Singer > Graduate Student @ LIGO-Caltech > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) phone +44-(0)1483 (prefix) -204927 (work) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory - University College London - Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From demitri.muna at gmail.com Thu Apr 10 20:31:57 2014 From: demitri.muna at gmail.com (Demitri Muna) Date: Thu, 10 Apr 2014 20:31:57 -0400 Subject: [AstroPy] SciCoder Workshop 2014 Announcement, NYC Message-ID: Hello, I would like to announce the fifth SciCoder workshop being held in NYC. This workshop may be of interest to young researchers (graduate students and postdocs), and it is designed to introduce modern programming practices, languages, and tools as specifically applicable to scientific research. The workshop includes hands-on coding and data analysis. A limited number of seats are available to ensure a personalized experience. This program has been very successful over the past four years and we've received a lot of positive feedback; we look forward to seeing this year's participants! This year the workshop is being held from 23-27 July in New York City. Applications are now being accepted through 4 May 2014. Further details about the workshop can be found here: http://scicoder.org/workshop A poster is available for download here; I would appreciate it if you could post it in your departments. http://scicoder.org/workshop/Poster.html Cheers, Demitri _________________________________________ Demitri Muna Department of Astronomy Ohio State University http://scicoder.org/ From demitri.muna at gmail.com Fri Apr 11 09:57:25 2014 From: demitri.muna at gmail.com (Demitri Muna) Date: Fri, 11 Apr 2014 09:57:25 -0400 Subject: [AstroPy] SciCoder Workshop 2014 Announcement, NYC - correction In-Reply-To: References: Message-ID: <2CB0727F-ED9E-4C89-A89B-E513F27EE1AC@gmail.com> Hello, Apologies for the noise, but in the announcement for the SciCoder workshop, I noted in the email that the dates were in July. Instead, the workshop will be held from 23-27 JUNE. Thanks! Demitri --- On 10 Apr 2014, at 8:31 PM, Demitri Muna wrote: > Hello, > > I would like to announce the fifth SciCoder workshop being held in NYC. This workshop may be of interest to young researchers (graduate students and postdocs), and it is designed to introduce modern programming practices, languages, and tools as specifically applicable to scientific research. The workshop includes hands-on coding and data analysis. A limited number of seats are available to ensure a personalized experience. This program has been very successful over the past four years and we've received a lot of positive feedback; we look forward to seeing this year's participants! > > This year the workshop is being held from 23-27 July in New York City. Applications are now being accepted through 4 May 2014. Further details about the workshop can be found here: > > http://scicoder.org/workshop > > A poster is available for download here; I would appreciate it if you could post it in your departments. > > http://scicoder.org/workshop/Poster.html > > Cheers, > Demitri _________________________________________ Demitri Muna Department of Astronomy Il Ohio State University http://scicoder.org/ From lsinger at caltech.edu Fri Apr 11 14:34:44 2014 From: lsinger at caltech.edu (Leo Singer) Date: Fri, 11 Apr 2014 11:34:44 -0700 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: Message-ID: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Hi Paul, I think that I need to write both the ASCII table and the ReadMe header section. I am preparing some Machine Readable Tables for inclusion in an an ApJ submission, following the guidelines here: https://aas.org/authors/online-only-materials-guidelines I wrote a little script to send an astropy.table.Table instance to the AAS machine readable table converter form. That form is here: http://authortools.aas.org/MRT/upload.html And the script is here: https://gist.github.com/lpsinger/10489886 As far as implementing a writer in Astropy, the trickiest part would be writing the Fortran-style format strings. Probably the most reliable method would be to write the table data using the existing fixed-width formatter, then read it back to deduce the format string. Leo On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: > Do you mean that you need to generate the ascii tables as well as the format tables for the ReadMe file? > > On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: > > Does anyone know of a tool for writing Machine Readable Tables (CDS format) in Python? I know that astropy.table and asciitable can read them, but I need to write one. -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam.g.ginsburg at gmail.com Fri Apr 11 14:51:24 2014 From: adam.g.ginsburg at gmail.com (Adam Ginsburg) Date: Fri, 11 Apr 2014 14:51:24 -0400 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Message-ID: FYI, if anyone wants to try to build a CDS writer, there was an aborted attempt a few years ago: https://github.com/taldcroft/asciitable/pull/16 On Fri, Apr 11, 2014 at 2:34 PM, Leo Singer wrote: > Hi Paul, > > I think that I need to write both the ASCII table and the ReadMe header > section. I am preparing some Machine Readable Tables for inclusion in an an > ApJ submission, following the guidelines here: > https://aas.org/authors/online-only-materials-guidelines > > I wrote a little script to send an astropy.table.Table instance to the AAS > machine readable table converter form. That form is here: > http://authortools.aas.org/MRT/upload.html > > And the script is here: > https://gist.github.com/lpsinger/10489886 > > As far as implementing a writer in Astropy, the trickiest part would be > writing the Fortran-style format strings. Probably the most reliable method > would be to write the table data using the existing fixed-width formatter, > then read it back to deduce the format string. > > Leo > > On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: > > Do you mean that you need to generate the ascii tables as well as the format > tables for the ReadMe file? > > On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >> >> >> Does anyone know of a tool for writing Machine Readable Tables (CDS >> format) in Python? I know that astropy.table and asciitable can read them, >> but I need to write one. > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Adam Ginsburg Fellow, European Southern Observatory http://www.adamgginsburg.com/ From kevin.gullikson at gmail.com Fri Apr 11 14:54:11 2014 From: kevin.gullikson at gmail.com (Kevin Gullikson) Date: Fri, 11 Apr 2014 13:54:11 -0500 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Message-ID: Leo, As far as implementing a writer in Astropy, the trickiest part would be writing the Fortran-style format strings. Probably the most reliable method would be to write the table data using the existing fixed-width formatter, then read it back to deduce the format string. I have used the fortranformat package for fortran-format strings in the past. I've found that the string formatting in python has a really hard time getting everything right for input to fortran programs. Kevin Gullikson On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: > Hi Paul, > > I think that I need to write both the ASCII table and the ReadMe header > section. I am preparing some Machine Readable Tables for inclusion in an an > ApJ submission, following the guidelines here: > https://aas.org/authors/online-only-materials-guidelines > > I wrote a little script to send an astropy.table.Table instance to the AAS > machine readable table converter form. That form is here: > http://authortools.aas.org/MRT/upload.html > > And the script is here: > https://gist.github.com/lpsinger/10489886 > > As far as implementing a writer in Astropy, the trickiest part would be > writing the Fortran-style format strings. Probably the most reliable method > would be to write the table data using the existing fixed-width formatter, > then read it back to deduce the format string. > > Leo > > On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: > > Do you mean that you need to generate the ascii tables as well as the > format tables for the ReadMe file? > > On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: > >> >> Does anyone know of a tool for writing Machine Readable Tables (CDS >> format) in Python? I know that astropy.table and asciitable can read them, >> but I need to write one. >> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From npkuin at gmail.com Fri Apr 11 15:09:44 2014 From: npkuin at gmail.com (Paul Kuin) Date: Fri, 11 Apr 2014 20:09:44 +0100 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Message-ID: .I worked in with francois Ochsenbein of the CDS to pin down the original format. He developed some tools in C that are useful. One will build a format table for the data file. So the following scenario would seem to make sense. I will need to look all this up as it has been nearly 20 years ago. But basically we we built then the tools to do automatic reformatting, verification and ingest of the ascii tables in the archive. 1. write ascii tables using astropy; keep a list of header names. 2. reformat the tables to a standard form (I think there's a C script to do that. 3. run the format table generator; perhaps the barebones ReadMe file is better. (C script) Then you have the ascii tables, and Readme which will need some editing by hand to fill in the abstract and add notes and such. I'll have to look into this and email Francois, since he wrote the stuff 20 years ago. Should be no big deal. I think that this may take a few days ... On Fri, Apr 11, 2014 at 7:54 PM, Kevin Gullikson wrote: > Leo, > > As far as implementing a writer in Astropy, the trickiest part would be > writing the Fortran-style format strings. Probably the most reliable method > would be to write the table data using the existing fixed-width formatter, > then read it back to deduce the format string. > > I have used the fortranformat package for fortran-format strings in the past. I've found that the string > formatting in python has a really hard time getting everything right for > input to fortran programs. > > > Kevin Gullikson > > > On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: > >> Hi Paul, >> >> I think that I need to write both the ASCII table and the ReadMe header >> section. I am preparing some Machine Readable Tables for inclusion in an an >> ApJ submission, following the guidelines here: >> https://aas.org/authors/online-only-materials-guidelines >> >> I wrote a little script to send an astropy.table.Table instance to the >> AAS machine readable table converter form. That form is here: >> http://authortools.aas.org/MRT/upload.html >> >> And the script is here: >> https://gist.github.com/lpsinger/10489886 >> >> As far as implementing a writer in Astropy, the trickiest part would be >> writing the Fortran-style format strings. Probably the most reliable method >> would be to write the table data using the existing fixed-width formatter, >> then read it back to deduce the format string. >> >> Leo >> >> On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: >> >> Do you mean that you need to generate the ascii tables as well as the >> format tables for the ReadMe file? >> >> On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >> >>> >>> Does anyone know of a tool for writing Machine Readable Tables (CDS >>> format) in Python? I know that astropy.table and asciitable can read them, >>> but I need to write one. >>> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) phone +44-(0)1483 (prefix) -204927 (work) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory - University College London - Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From npkuin at gmail.com Fri Apr 11 15:20:37 2014 From: npkuin at gmail.com (Paul Kuin) Date: Fri, 11 Apr 2014 20:20:37 +0100 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Message-ID: Are you sure that you can't just send it as (a) FITS file(s) + a readme - then you should not need the format tables at all? On Fri, Apr 11, 2014 at 8:09 PM, Paul Kuin wrote: > .I worked in with francois Ochsenbein of the CDS to pin down the original > format. He developed some tools in C that are useful. One will build a > format table for the data file. So the following scenario would seem to > make sense. I will need to look all this up as it has been nearly 20 years > ago. But basically we we built then the tools to do automatic reformatting, > verification and ingest of the ascii tables in the archive. > 1. write ascii tables using astropy; keep a list of header names. > 2. reformat the tables to a standard form (I think there's a C script to > do that. > 3. run the format table generator; perhaps the barebones ReadMe file is > better. (C script) > Then you have the ascii tables, and Readme which will need some editing by > hand to fill in the abstract and add notes and such. > > I'll have to look into this and email Francois, since he wrote the stuff > 20 years ago. Should be no big deal. > > I think that this may take a few days ... > > > > > > On Fri, Apr 11, 2014 at 7:54 PM, Kevin Gullikson < > kevin.gullikson at gmail.com> wrote: > >> Leo, >> >> As far as implementing a writer in Astropy, the trickiest part would be >> writing the Fortran-style format strings. Probably the most reliable method >> would be to write the table data using the existing fixed-width formatter, >> then read it back to deduce the format string. >> >> I have used the fortranformatpackage for fortran-format strings in the past. I've found that the string >> formatting in python has a really hard time getting everything right for >> input to fortran programs. >> >> >> Kevin Gullikson >> >> >> On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: >> >>> Hi Paul, >>> >>> I think that I need to write both the ASCII table and the ReadMe header >>> section. I am preparing some Machine Readable Tables for inclusion in an an >>> ApJ submission, following the guidelines here: >>> https://aas.org/authors/online-only-materials-guidelines >>> >>> I wrote a little script to send an astropy.table.Table instance to the >>> AAS machine readable table converter form. That form is here: >>> http://authortools.aas.org/MRT/upload.html >>> >>> And the script is here: >>> https://gist.github.com/lpsinger/10489886 >>> >>> As far as implementing a writer in Astropy, the trickiest part would be >>> writing the Fortran-style format strings. Probably the most reliable method >>> would be to write the table data using the existing fixed-width formatter, >>> then read it back to deduce the format string. >>> >>> Leo >>> >>> On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: >>> >>> Do you mean that you need to generate the ascii tables as well as the >>> format tables for the ReadMe file? >>> >>> On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >>> >>>> >>>> Does anyone know of a tool for writing Machine Readable Tables (CDS >>>> format) in Python? I know that astropy.table and asciitable can read them, >>>> but I need to write one. >>>> >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >>> >>> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > > -- > > * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * > Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) > phone +44-(0)1483 (prefix) -204927 (work) > mobile +44(0)7806985366 skype ID: npkuin > Mullard Space Science Laboratory - University College London - > Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. > -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) phone +44-(0)1483 (prefix) -204927 (work) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory - University College London - Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lsinger at caltech.edu Fri Apr 11 15:50:25 2014 From: lsinger at caltech.edu (Leo Singer) Date: Fri, 11 Apr 2014 12:50:25 -0700 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> Message-ID: <3B1AE468-FB14-4842-97AF-63AA3D2D0B4D@caltech.edu> Hi Paul, Well, that's another question: what format is easiest to use for most readers to ingest published data into their own work? MRT can be read as either fixed-width or whitespace-delimited ASCII, so it seems fine as a least common denominator. This particular dataset is a catalog of ~1000 simulated binary neutron star mergers from a Monte Carlo study of sky localization accuracy with Advanced LIGO and Virgo. Each row contains the parameters of the simulated binary including component masses and spins, sky location, inclination, luminosity distance, as well as parameters about the recovered signal, such as the SNR in each detector, and area of the 90% credible region. Leo On Apr 11, 2014, at 12:20 PM, Paul Kuin wrote: > Are you sure that you can't just send it as (a) FITS file(s) + a readme - then you should not need the format tables at all? > > > On Fri, Apr 11, 2014 at 8:09 PM, Paul Kuin wrote: > .I worked in with francois Ochsenbein of the CDS to pin down the original format. He developed some tools in C that are useful. One will build a format table for the data file. So the following scenario would seem to make sense. I will need to look all this up as it has been nearly 20 years ago. But basically we we built then the tools to do automatic reformatting, verification and ingest of the ascii tables in the archive. > 1. write ascii tables using astropy; keep a list of header names. > 2. reformat the tables to a standard form (I think there's a C script to do that. > 3. run the format table generator; perhaps the barebones ReadMe file is better. (C script) > Then you have the ascii tables, and Readme which will need some editing by hand to fill in the abstract and add notes and such. > > I'll have to look into this and email Francois, since he wrote the stuff 20 years ago. Should be no big deal. > > I think that this may take a few days ... > > > > > > On Fri, Apr 11, 2014 at 7:54 PM, Kevin Gullikson wrote: > Leo, > > As far as implementing a writer in Astropy, the trickiest part would be writing the Fortran-style format strings. Probably the most reliable method would be to write the table data using the existing fixed-width formatter, then read it back to deduce the format string. > > I have used the fortranformat package for fortran-format strings in the past. I've found that the string formatting in python has a really hard time getting everything right for input to fortran programs. > > > Kevin Gullikson > > > On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: > Hi Paul, > > I think that I need to write both the ASCII table and the ReadMe header section. I am preparing some Machine Readable Tables for inclusion in an an ApJ submission, following the guidelines here: > https://aas.org/authors/online-only-materials-guidelines > > I wrote a little script to send an astropy.table.Table instance to the AAS machine readable table converter form. That form is here: > http://authortools.aas.org/MRT/upload.html > > And the script is here: > https://gist.github.com/lpsinger/10489886 > > As far as implementing a writer in Astropy, the trickiest part would be writing the Fortran-style format strings. Probably the most reliable method would be to write the table data using the existing fixed-width formatter, then read it back to deduce the format string. > > Leo > > On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: > >> Do you mean that you need to generate the ascii tables as well as the format tables for the ReadMe file? >> >> On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >> >> Does anyone know of a tool for writing Machine Readable Tables (CDS format) in Python? I know that astropy.table and asciitable can read them, but I need to write one. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aldcroft at head.cfa.harvard.edu Fri Apr 11 16:25:44 2014 From: aldcroft at head.cfa.harvard.edu (Aldcroft, Thomas) Date: Fri, 11 Apr 2014 16:25:44 -0400 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: <3B1AE468-FB14-4842-97AF-63AA3D2D0B4D@caltech.edu> References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> <3B1AE468-FB14-4842-97AF-63AA3D2D0B4D@caltech.edu> Message-ID: On Fri, Apr 11, 2014 at 3:50 PM, Leo Singer wrote: > Hi Paul, > > Well, that's another question: what format is easiest to use for most > readers to ingest published data into their own work? MRT can be read as > either fixed-width or whitespace-delimited ASCII, so it seems fine as a > least common denominator. > If you don't have need for the full metadata capabilities of MRT (aka CDS) then simple CSV or other character-delimited formats are much easier for reading. Despite the name, machine readable tables are not especially easy to read for machines since the header format has a lot of flexibility and intricacy. For datasets with required keyword metadata and other unstructured comments you might consider IPAC for an ASCII table based interchange format. It's fairly simple but does the job, and `io.ascii` can write this format. And of course FITS is pretty much universally accessible even though you lose the human-readability aspect. - Tom > > This particular dataset is a catalog of ~1000 simulated binary neutron > star mergers from a Monte Carlo study of sky localization accuracy with > Advanced LIGO and Virgo. Each row contains the parameters of the simulated > binary including component masses and spins, sky location, inclination, > luminosity distance, as well as parameters about the recovered signal, such > as the SNR in each detector, and area of the 90% credible region. > > Leo > > On Apr 11, 2014, at 12:20 PM, Paul Kuin wrote: > > Are you sure that you can't just send it as (a) FITS file(s) + a readme - > then you should not need the format tables at all? > > > On Fri, Apr 11, 2014 at 8:09 PM, Paul Kuin wrote: > >> .I worked in with francois Ochsenbein of the CDS to pin down the original >> format. He developed some tools in C that are useful. One will build a >> format table for the data file. So the following scenario would seem to >> make sense. I will need to look all this up as it has been nearly 20 years >> ago. But basically we we built then the tools to do automatic reformatting, >> verification and ingest of the ascii tables in the archive. >> 1. write ascii tables using astropy; keep a list of header names. >> 2. reformat the tables to a standard form (I think there's a C script to >> do that. >> 3. run the format table generator; perhaps the barebones ReadMe file is >> better. (C script) >> Then you have the ascii tables, and Readme which will need some editing >> by hand to fill in the abstract and add notes and such. >> >> I'll have to look into this and email Francois, since he wrote the stuff >> 20 years ago. Should be no big deal. >> >> I think that this may take a few days ... >> >> >> >> >> >> On Fri, Apr 11, 2014 at 7:54 PM, Kevin Gullikson < >> kevin.gullikson at gmail.com> wrote: >> >>> Leo, >>> >>> As far as implementing a writer in Astropy, the trickiest part would be >>> writing the Fortran-style format strings. Probably the most reliable method >>> would be to write the table data using the existing fixed-width formatter, >>> then read it back to deduce the format string. >>> >>> I have used the fortranformatpackage for fortran-format strings in the past. I've found that the string >>> formatting in python has a really hard time getting everything right for >>> input to fortran programs. >>> >>> >>> Kevin Gullikson >>> >>> >>> On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: >>> >>>> Hi Paul, >>>> >>>> I think that I need to write both the ASCII table and the ReadMe header >>>> section. I am preparing some Machine Readable Tables for inclusion in an an >>>> ApJ submission, following the guidelines here: >>>> https://aas.org/authors/online-only-materials-guidelines >>>> >>>> I wrote a little script to send an astropy.table.Table instance to the >>>> AAS machine readable table converter form. That form is here: >>>> http://authortools.aas.org/MRT/upload.html >>>> >>>> And the script is here: >>>> https://gist.github.com/lpsinger/10489886 >>>> >>>> As far as implementing a writer in Astropy, the trickiest part would be >>>> writing the Fortran-style format strings. Probably the most reliable method >>>> would be to write the table data using the existing fixed-width formatter, >>>> then read it back to deduce the format string. >>>> >>>> Leo >>>> >>>> On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: >>>> >>>> Do you mean that you need to generate the ascii tables as well as the >>>> format tables for the ReadMe file? >>>> >>>> On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >>>> >>>>> >>>>> Does anyone know of a tool for writing Machine Readable Tables (CDS >>>>> format) in Python? I know that astropy.table and asciitable can read them, >>>>> but I need to write one. >>>>> >>>> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From npkuin at gmail.com Fri Apr 11 17:39:31 2014 From: npkuin at gmail.com (Paul Kuin) Date: Fri, 11 Apr 2014 22:39:31 +0100 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: <5884ACC7-E840-4E9B-9F35-3EADEB637D1C@caltech.edu> <3B1AE468-FB14-4842-97AF-63AA3D2D0B4D@caltech.edu> Message-ID: Hi Leo, I see that the APJ instructions only seem to refer the the machine readable ascii format. Originally the intention was to support both fits format and ASCII. Fits data files would be listed in the 'file summary' but not need a format section. CDS always has preferred ASCII only. With the demise of the NASA Astronomical Data Center some ten years ago it seems that CDS has pushed this through as a requirement to ApJ. Anyway, I''ll see what can be done to improve things. It may be easier to get the formatting solved in astropy then add a few extra C scripts from CDS. - Paul On Fri, Apr 11, 2014 at 9:25 PM, Aldcroft, Thomas < aldcroft at head.cfa.harvard.edu> wrote: > > > On Fri, Apr 11, 2014 at 3:50 PM, Leo Singer wrote: > >> Hi Paul, >> >> Well, that's another question: what format is easiest to use for most >> readers to ingest published data into their own work? MRT can be read as >> either fixed-width or whitespace-delimited ASCII, so it seems fine as a >> least common denominator. >> > > If you don't have need for the full metadata capabilities of MRT (aka CDS) > then simple CSV or other character-delimited formats are much easier for > reading. Despite the name, machine readable tables are not especially > easy to read for machines since the header format has a lot of flexibility > and intricacy. > > For datasets with required keyword metadata and other unstructured > comments you might consider IPAC for an ASCII table based interchange > format. It's fairly simple but does the job, and `io.ascii` can write this > format. > > And of course FITS is pretty much universally accessible even though you > lose the human-readability aspect. > > - Tom > > > >> >> This particular dataset is a catalog of ~1000 simulated binary neutron >> star mergers from a Monte Carlo study of sky localization accuracy with >> Advanced LIGO and Virgo. Each row contains the parameters of the simulated >> binary including component masses and spins, sky location, inclination, >> luminosity distance, as well as parameters about the recovered signal, such >> as the SNR in each detector, and area of the 90% credible region. >> >> Leo >> >> On Apr 11, 2014, at 12:20 PM, Paul Kuin wrote: >> >> Are you sure that you can't just send it as (a) FITS file(s) + a readme - >> then you should not need the format tables at all? >> >> >> On Fri, Apr 11, 2014 at 8:09 PM, Paul Kuin wrote: >> >>> .I worked in with francois Ochsenbein of the CDS to pin down the >>> original format. He developed some tools in C that are useful. One will >>> build a format table for the data file. So the following scenario would >>> seem to make sense. I will need to look all this up as it has been nearly >>> 20 years ago. But basically we we built then the tools to do automatic >>> reformatting, verification and ingest of the ascii tables in the archive. >>> 1. write ascii tables using astropy; keep a list of header names. >>> 2. reformat the tables to a standard form (I think there's a C script to >>> do that. >>> 3. run the format table generator; perhaps the barebones ReadMe file is >>> better. (C script) >>> Then you have the ascii tables, and Readme which will need some editing >>> by hand to fill in the abstract and add notes and such. >>> >>> I'll have to look into this and email Francois, since he wrote the stuff >>> 20 years ago. Should be no big deal. >>> >>> I think that this may take a few days ... >>> >>> >>> >>> >>> >>> On Fri, Apr 11, 2014 at 7:54 PM, Kevin Gullikson < >>> kevin.gullikson at gmail.com> wrote: >>> >>>> Leo, >>>> >>>> As far as implementing a writer in Astropy, the trickiest part would be >>>> writing the Fortran-style format strings. Probably the most reliable method >>>> would be to write the table data using the existing fixed-width formatter, >>>> then read it back to deduce the format string. >>>> >>>> I have used the fortranformatpackage for fortran-format strings in the past. I've found that the string >>>> formatting in python has a really hard time getting everything right for >>>> input to fortran programs. >>>> >>>> >>>> Kevin Gullikson >>>> >>>> >>>> On Fri, Apr 11, 2014 at 1:34 PM, Leo Singer wrote: >>>> >>>>> Hi Paul, >>>>> >>>>> I think that I need to write both the ASCII table and the ReadMe >>>>> header section. I am preparing some Machine Readable Tables for inclusion >>>>> in an an ApJ submission, following the guidelines here: >>>>> https://aas.org/authors/online-only-materials-guidelines >>>>> >>>>> I wrote a little script to send an astropy.table.Table instance to the >>>>> AAS machine readable table converter form. That form is here: >>>>> http://authortools.aas.org/MRT/upload.html >>>>> >>>>> And the script is here: >>>>> https://gist.github.com/lpsinger/10489886 >>>>> >>>>> As far as implementing a writer in Astropy, the trickiest part would >>>>> be writing the Fortran-style format strings. Probably the most reliable >>>>> method would be to write the table data using the existing fixed-width >>>>> formatter, then read it back to deduce the format string. >>>>> >>>>> Leo >>>>> >>>>> On Apr 10, 2014, at 4:28 PM, Paul Kuin wrote: >>>>> >>>>> Do you mean that you need to generate the ascii tables as well as the >>>>> format tables for the ReadMe file? >>>>> >>>>> On Thu, Apr 10, 2014 at 11:21 PM, Leo Singer wrote: >>>>> >>>>>> >>>>>> Does anyone know of a tool for writing Machine Readable Tables (CDS >>>>>> format) in Python? I know that astropy.table and asciitable can read them, >>>>>> but I need to write one. >>>>>> >>>>> >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> >> > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) phone +44-(0)1483 (prefix) -204927 (work) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory - University College London - Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From moritz.guenther at gmx.de Sat Apr 12 13:16:46 2014 From: moritz.guenther at gmx.de (=?ISO-8859-1?Q?Moritz_G=FCnther?=) Date: Sat, 12 Apr 2014 13:16:46 -0400 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: References: Message-ID: <534974FE.1040702@gmx.de> Hi Paul, if you implement (parts of) a CDS format writer in astropy, that would be great. I should point out though, that ApJ will format any reasonable data you send them (e.g. fits or some plain ascii) into the appropriate format. I am sure they will appreciate if the file you send them is already close to a the final format, but they have to do some manual editing anyway, e.g. add the page number etc. that your paper will have when published. (Unless I misunderstand your email and you are working for ApJ and trying to improve the software used on their end - I don't know how exactly they do it. My understanding is that they use some combination of their own tools and manual editing.) Moritz From npkuin at gmail.com Sat Apr 12 14:52:37 2014 From: npkuin at gmail.com (Paul Kuin) Date: Sat, 12 Apr 2014 19:52:37 +0100 Subject: [AstroPy] Write machine readable tables in Python? In-Reply-To: <534974FE.1040702@gmx.de> References: <534974FE.1040702@gmx.de> Message-ID: The tables in ApJ ar archived by the astronomical data centers using the CDS format since 1994. That is separate from the printed edition. The archived tables can be found via the Vizier service. On Sat, Apr 12, 2014 at 6:16 PM, Moritz G?nther wrote: > Hi Paul, > > if you implement (parts of) a CDS format writer in astropy, that would > be great. > I should point out though, that ApJ will format any reasonable data you > send them (e.g. fits or some plain ascii) into the appropriate format. > I am sure they will appreciate if the file you send them is already > close to a the final format, but they have to do some manual editing > anyway, e.g. add the page number etc. that your paper will have when > published. > > (Unless I misunderstand your email and you are working for ApJ and > trying to improve the software used on their end - I don't know how > exactly they do it. My understanding is that they use some combination > of their own tools and manual editing.) > > Moritz > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (n.kuin at ucl.ac.uk) phone +44-(0)1483 (prefix) -204927 (work) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory - University College London - Holmbury St Mary - Dorking - Surrey RH5 6NT- U.K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From moritz.guenther at gmx.de Wed Apr 16 08:37:30 2014 From: moritz.guenther at gmx.de (=?ISO-8859-1?Q?Moritz_G=FCnther?=) Date: Wed, 16 Apr 2014 08:37:30 -0400 Subject: [AstroPy] Write machine readable tables in Python? Message-ID: <534E798A.9080501@gmx.de> Hi Paul, yes, I am fully aware that the archived tables can be found via Vizier and are separate from the online edition. For an example see one of my recent papers where I used this feature: http://adsabs.harvard.edu/abs/2012AJ....144..101G It has data in the text (pdf or html), but it also has two data tables that are available in CDS machine-readable tables: http://vizier.cfa.harvard.edu/viz-bin/VizieR?-source=J/AJ/144/101 at an astronomical data center. These tables are -as you say- separate from the printed edition. They contain data that is not part of the pdf and they can be found using vizier. Since I work in python, how did my data get from an astropy.table into vizier format? I send it to the AJ editorial office as a fits table and a plain asciitable. The AJ editorial staff did the formating and the publishing. However, if we had an CDSWriter tool in astropy, that would be even better... Moritz From leo.huckvale at postgrad.manchester.ac.uk Wed Apr 16 11:11:40 2014 From: leo.huckvale at postgrad.manchester.ac.uk (Leo Huckvale) Date: Wed, 16 Apr 2014 16:11:40 +0100 Subject: [AstroPy] Heliocentric/Barycentric JD corrections In-Reply-To: References: Message-ID: <534E9DAC.2030704@postgrad.manchester.ac.uk> Hi all, Following recent discussion about implementing HJD on astropy-dev and github, I thought I might offer up one solution to correct timestamps to HJD/BJD. It seemed more appropriate here than on the dev mailing list. The code below defines the function "jd_corr" which takes Modified Julian Dates (on UTC scale), source RA and Dec and a correction type "bjd" or "hjd". This returns "new_jd", which is the corrected set of time stamps in an astropy.time.Time object. The delta-t corrections are obtained from barycentric ephemerides via jplephem, as recommended in the discussion on github, and a corresponding data package (in this case, de423). Hopefully this might help someone. I'd appreciate any feedback - especially if I've overlooked something vital, which is entirely possible! I have relied in a large part on astropy.time to work its magic on time-standard conversions. Best regards, Leo ---- import numpy as np import astropy.time as time import astropy.coordinates as coords import astropy.units as u import astropy.constants as const import jplephem import de423 VISTA_LAT = -24.6157 # Geographic coordinates of observatory VISTA_LON = -70.3976 def jd_corr(mjd, ra, dec, jd_type='bjd'): """Return BJD or HJD for input MJD(UTC).""" # Initialise ephemeris from jplephem eph = jplephem.Ephemeris(de423) # Source unit-vector ## Assume coordinates in ICRS ## Set distance to unit (kilometers) src_vec = coords.ICRS(ra=ra, dec=dec, unit=(u.degree, u.degree), distance=coords.Distance(1, u.km)) # Convert epochs to astropy.time.Time ## Assume MJD(UTC) t = time.Time(mjd, scale='utc', format='mjd', lat=VISTA_LAT, lon=VISTA_LON) # Get Earth-Moon barycenter position ## NB: jplephem uses Barycentric Dynamical Time, e.g. JD(TDB) ## and gives positions relative to solar system barycenter barycenter_earthmoon = eph.position('earthmoon', t.tdb.jd) # Get Moon position vectors moonvector = eph.position('moon', t.tdb.jd) # Compute Earth position vectors pos_earth = (barycenter_earthmoon - moonvector * eph.earth_share)*u.km if jd_type == 'bjd': # Compute BJD correction ## Assume source vectors parallel at Earth and Solar System Barycenter ## i.e. source is at infinity corr = np.dot(pos_earth.T, src_vec.cartesian.value)/const.c elif jd_type == 'hjd': # Compute HJD correction via Sun ephemeris pos_sun = eph.position('sun', t.tdb.jd)*u.km sun_earth_vec = pos_earth - pos_sun corr = np.dot(sun_earth_vec.T, src_vec.cartesian.value)/const.c # TDB is the appropriate time scale for these ephemerides dt = time.TimeDelta(corr, scale='tdb', format='jd') # Compute and return HJD/BJD as astropy.time.Time new_jd = t + dt return new_jd From erik.tollerud at gmail.com Mon Apr 21 17:22:42 2014 From: erik.tollerud at gmail.com (Erik Tollerud) Date: Mon, 21 Apr 2014 17:22:42 -0400 Subject: [AstroPy] Heliocentric/Barycentric JD corrections In-Reply-To: <534E9DAC.2030704@postgrad.manchester.ac.uk> References: <534E9DAC.2030704@postgrad.manchester.ac.uk> Message-ID: For those who aren't monitoring astropy-dev and github, the plan is that astropy.time will probably support these eventually, but it requires some additional work to get it to operate smoothly in the existing architecture. So this is a good interim solution - thanks, Leo! On Wed, Apr 16, 2014 at 11:11 AM, Leo Huckvale wrote: > Hi all, > > Following recent discussion about implementing HJD on astropy-dev and > github, I thought I might offer up one solution to correct timestamps to > HJD/BJD. It seemed more appropriate here than on the dev mailing list. > > The code below defines the function "jd_corr" which takes Modified > Julian Dates (on UTC scale), source RA and Dec and a correction type > "bjd" or "hjd". This returns "new_jd", which is the corrected set of > time stamps in an astropy.time.Time object. The delta-t corrections are > obtained from barycentric ephemerides via jplephem, as recommended in > the discussion on github, and a corresponding data package (in this > case, de423). > > Hopefully this might help someone. I'd appreciate any feedback - > especially if I've overlooked something vital, which is entirely > possible! I have relied in a large part on astropy.time to work its > magic on time-standard conversions. > > Best regards, > Leo > > ---- > > import numpy as np > > import astropy.time as time > import astropy.coordinates as coords > import astropy.units as u > import astropy.constants as const > > import jplephem > import de423 > > VISTA_LAT = -24.6157 # Geographic coordinates of observatory > VISTA_LON = -70.3976 > > def jd_corr(mjd, ra, dec, jd_type='bjd'): > """Return BJD or HJD for input MJD(UTC).""" > > # Initialise ephemeris from jplephem > eph = jplephem.Ephemeris(de423) > > # Source unit-vector > ## Assume coordinates in ICRS > ## Set distance to unit (kilometers) > src_vec = coords.ICRS(ra=ra, dec=dec, > unit=(u.degree, u.degree), > distance=coords.Distance(1, u.km)) > > # Convert epochs to astropy.time.Time > ## Assume MJD(UTC) > t = time.Time(mjd, scale='utc', format='mjd', lat=VISTA_LAT, > lon=VISTA_LON) > > # Get Earth-Moon barycenter position > ## NB: jplephem uses Barycentric Dynamical Time, e.g. JD(TDB) > ## and gives positions relative to solar system barycenter > barycenter_earthmoon = eph.position('earthmoon', t.tdb.jd) > > # Get Moon position vectors > moonvector = eph.position('moon', t.tdb.jd) > > # Compute Earth position vectors > pos_earth = (barycenter_earthmoon - moonvector * eph.earth_share)*u.km > > if jd_type == 'bjd': > # Compute BJD correction > ## Assume source vectors parallel at Earth and Solar System > Barycenter > ## i.e. source is at infinity > corr = np.dot(pos_earth.T, src_vec.cartesian.value)/const.c > elif jd_type == 'hjd': > # Compute HJD correction via Sun ephemeris > pos_sun = eph.position('sun', t.tdb.jd)*u.km > sun_earth_vec = pos_earth - pos_sun > corr = np.dot(sun_earth_vec.T, src_vec.cartesian.value)/const.c > > # TDB is the appropriate time scale for these ephemerides > dt = time.TimeDelta(corr, scale='tdb', format='jd') > > # Compute and return HJD/BJD as astropy.time.Time > new_jd = t + dt > > return new_jd > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Erik T From wbpython at gmail.com Tue Apr 22 22:45:31 2014 From: wbpython at gmail.com (wbpython) Date: Tue, 22 Apr 2014 22:45:31 -0400 Subject: [AstroPy] Using astropy.time for 'deep time'? Message-ID: Hello, I'm doing plots of planetary and spacecraft positions using a modern ephemeris. However, as part of these plots, I want to show planet trails going back 100 years or more for outer planets and Kuiper Belt objects. I've tried using astropy.time to define dates going back 100 years or more but it seems to not work, or at least not match the documentation. In the documentation, it states that time has sufficient precision for nano-second accuracy over the age of the universe. It seems like it should be adequate for these types of 'deep time' computations, unless this full range is not implemented. Has anyone used astropy.time as a time-keeper for extremely long time computations that need connection to modern time systems? Thanks, Tom From aldcroft at head.cfa.harvard.edu Wed Apr 23 06:50:09 2014 From: aldcroft at head.cfa.harvard.edu (Aldcroft, Thomas) Date: Wed, 23 Apr 2014 06:50:09 -0400 Subject: [AstroPy] Using astropy.time for 'deep time'? In-Reply-To: References: Message-ID: On Tue, Apr 22, 2014 at 10:45 PM, wbpython wrote: > Hello, > > I'm doing plots of planetary and spacecraft positions using a modern > ephemeris. However, as part of these plots, I want to show planet trails > going back 100 years or more for outer planets and Kuiper Belt objects. > > I've tried using astropy.time to define dates going back 100 years or more > but it seems to not work, or at least not match the documentation. > Can you provide examples of what you tried, how it didn't work, and the documentation that doesn't seem to match your experience? Thanks, Tom > In the documentation, it states that time has sufficient precision for > nano-second accuracy over the age of the universe. It seems like it should > be adequate for these types of 'deep time' computations, unless this full > range is not implemented. > > Has anyone used astropy.time as a time-keeper for extremely long time > computations that need connection to modern time systems? > > Thanks, > Tom > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wbpython at gmail.com Wed Apr 23 19:34:56 2014 From: wbpython at gmail.com (wbpython) Date: Wed, 23 Apr 2014 19:34:56 -0400 Subject: [AstroPy] Using astropy.time for 'deep time'? In-Reply-To: References: Message-ID: Some of the confusion is clearly between my keyboard and chair ;^) I'm trying to switch to the astropy module, away from some of my own module which I've been using for about 10 years but which does not support some of the other time-systems. I think the one that threw me the most was >>> jdorigin = time.Time(0.0,0.0,format='jd') which returns an error ERROR: ScaleValueError: No scale value supplied but it is required for class TimeJD [astropy.time.core] But which scale value, as I don't think any of the ones listed were technically defined at JD=0? It seems to work for any of the defined systems. >>> jdorigin = time.Time(0.0,0.0,format='jd',scale='utc') >>> jdorigin.isot Once I understood this, things became a little clearer. It appears I can do *really* old dates by defining everything in Julian Days >>> earthbirth = time.Time(-4.5e9*365,0.0,format='jd',scale='tai') but some things aren't supported: >>> earthbirth.iso ERROR: ValueError: eraD2dtf: unacceptable date [unknown] It's a little kludgy for deep time use, but I do need something reliable with 128-bit precision. I could probably write a wrapper that gives more convenient I/O options, unless there is an existing better option. Thanks for your attention, Tom From avarlotta at cfa.harvard.edu Tue Apr 29 13:20:39 2014 From: avarlotta at cfa.harvard.edu (Angelo Varlotta) Date: Tue, 29 Apr 2014 13:20:39 -0400 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: <535FDE95.4000707@cfa.harvard.edu> References: <535FDE95.4000707@cfa.harvard.edu> Message-ID: <535FDF67.3010802@cfa.harvard.edu> Hello, I need to convert a list of sources from pixel coordinates to sky coordinates for some PAIRITel data,using astropy (0.3.1) and using the following code: from __future__ import division import numpy from astropy import wcs from astropy.io import fits import sys hdulist = fits.open(sys.argv[-1]) w = wcs.WCS(hdulist[0].header) pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_) world = w.wcs_pix2world(pixcrd, 1) print world (the fits file is at h_long_CYGX3.1.11_coadd.fits , the code is in a file I called pix2sky.py) The code derives from the first example in the documentation for astropy.wcs at: http://docs.astropy.org/en/stable/wcs/index.html. While I can do this sucessfully with a fits file generated from Fermi analysis (so I know that astropy is installed properly and works), with the PAIRITel data I get the following error message, after running from the terminal prompt python pix2sky.py h_long_CYGX3.1.11_coadd.fits: WARNING: FITSFixedWarning: RADECSYS= 'ICRS ' / Astrometric system RADECSYS is non-standard, use RADESYSa. [astropy.wcs.wcs] WARNING: FITSFixedWarning: 'datfix' made the change 'Invalid parameter value: invalid date '2010/5/14 09:23:52''. [astropy.wcs.wcs] WARNING: FITSFixedWarning: 'celfix' made the change 'PV1_5 : Unrecognized coordinate transformation parameter'. [astropy.wcs.wcs] Traceback (most recent call last): File "pix2sky.py", line 49, in load_wcs_from_file(sys.argv[-1]) File "pix2sky.py", line 36, in load_wcs_from_file world = w.wcs_pix2world(pixcrd, 1) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", line 1159, in wcs_pix2world 'output', *args, **kwargs) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", line 1060, in _array_converter return _return_single_array(xy, origin) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", line 1044, in _return_single_array result = func(xy, origin) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", line 1158, in lambda xy, o: self.wcs.p2s(xy, o)['world'], astropy.wcs._wcs.InvalidTransformError: ERROR 6 in wcsset() at line 1562 of file cextern/wcslib/C/wcs.c: PV1_5 : Unrecognized coordinate transformation parameter. How do I proceed? Cheers, Angelo Angelo Varlotta Smithsonian Astrophysical Observatory 60 Garden St. MS-06, Cambridge, MA 02138, USA Phone: +1-617-495-7138 Office: B-226 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim.jenness at gmail.com Tue Apr 29 13:38:54 2014 From: tim.jenness at gmail.com (Tim Jenness) Date: Tue, 29 Apr 2014 10:38:54 -0700 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: <535FDF67.3010802@cfa.harvard.edu> References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> Message-ID: I'm not sure what this telescope is intending but the DATE-OBS header is not at all compliant with the FITS standard so astropy is within its rights to complain. DATE-OBS must be in ISO date format if HH:MM::SS is being specified. Slashes are only used for pre Y2K format headers that just specified the day. I looked at the file with pyast and get the following warnings so it does manage to read it (and ignores the broken DATE-OBS so guesses the date: Reading your image produced the following messages: Result of attempt to read WCS encoded as: FITS-IRAF Succeeded ASTWARN = ' ' ASTWARN = 'The original FITS header did not specify the longitude of ' ASTWARN = 'the native north pole. A default value of 180 degrees was ' ASTWARN = 'assumed.' ASTWARN = ' ' ASTWARN = ' ' ASTWARN = 'The original FITS header did not specify the date of ' ASTWARN = 'observation. A default value of J2000 was assumed.' ASTWARN = ' ' On Tue, Apr 29, 2014 at 10:20 AM, Angelo Varlotta wrote: > Hello, > I need to convert a list of sources from pixel coordinates to sky > coordinates for some PAIRITel data, using astropy (0.3.1) and using the > following code: > > from __future__ import division > import numpy > from astropy import wcs > from astropy.io import fits > import sys > > hdulist = fits.open(sys.argv[-1]) > w = wcs.WCS(hdulist[0].header) > pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_) > world = w.wcs_pix2world(pixcrd, 1) > print world > > (the fits file is at h_long_CYGX3.1.11_coadd.fits , > the code is in a file I called pix2sky.py) > > The code derives from the first example in the documentation for > astropy.wcs at: http://docs.astropy.org/en/stable/wcs/index.html. While I > can do this sucessfully with a fits file generated from Fermi analysis (so > I know that astropy is installed properly and works), with the PAIRITel > data I get the following error message, after running from the terminal > prompt python pix2sky.py h_long_CYGX3.1.11_coadd.fits: > > > WARNING: FITSFixedWarning: RADECSYS= 'ICRS ' / Astrometric system > RADECSYS is non-standard, use RADESYSa. [astropy.wcs.wcs] > WARNING: FITSFixedWarning: 'datfix' made the change 'Invalid parameter > value: invalid date '2010/5/14 09:23:52''. [astropy.wcs.wcs] > WARNING: FITSFixedWarning: 'celfix' made the change 'PV1_5 : Unrecognized > coordinate transformation parameter'. [astropy.wcs.wcs] > > Traceback (most recent call last): > File "pix2sky.py", line 49, in > load_wcs_from_file(sys.argv[-1]) > File "pix2sky.py", line 36, in load_wcs_from_file > world = w.wcs_pix2world(pixcrd, 1) > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", > line 1159, in wcs_pix2world > 'output', *args, **kwargs) > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", > line 1060, in _array_converter > return _return_single_array(xy, origin) > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", > line 1044, in _return_single_array > result = func(xy, origin) > File > "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", > line 1158, in > lambda xy, o: self.wcs.p2s(xy, o)['world'], > astropy.wcs._wcs.InvalidTransformError: ERROR 6 in wcsset() at line 1562 > of file cextern/wcslib/C/wcs.c: > PV1_5 : Unrecognized coordinate transformation parameter. > > > How do I proceed? > > Cheers, > Angelo > > Angelo Varlotta > Smithsonian Astrophysical Observatory > 60 Garden St. MS-06, Cambridge, MA 02138, USA > Phone: +1-617-495-7138 > Office: B-226 > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.berry at jach.hawaii.edu Tue Apr 29 15:08:37 2014 From: d.berry at jach.hawaii.edu (David Berry) Date: Tue, 29 Apr 2014 20:08:37 +0100 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> Message-ID: That FITS file looks like it has a SCAMP header, that includes distortion. SCAMP uses a basic TAN projection code but includes lots of PVi_j keywords to specify the distortion terms. It uses the distortion scheme described in an early draft of FITS-WCS paper2. AST (and therefore pyast) support it, but I'm not sure if astropy.wcs supports it. David On 29 April 2014 18:38, Tim Jenness wrote: > I'm not sure what this telescope is intending but the DATE-OBS header is not > at all compliant with the FITS standard so astropy is within its rights to > complain. DATE-OBS must be in ISO date format if HH:MM::SS is being > specified. Slashes are only used for pre Y2K format headers that just > specified the day. > > I looked at the file with pyast and get the following warnings so it does > manage to read it (and ignores the broken DATE-OBS so guesses the date: > > Reading your image produced the following messages: > > Result of attempt to read WCS encoded as: FITS-IRAF > > Succeeded > > ASTWARN = ' ' > ASTWARN = 'The original FITS header did not specify the longitude of ' > ASTWARN = 'the native north pole. A default value of 180 degrees was ' > ASTWARN = 'assumed.' > ASTWARN = ' ' > ASTWARN = ' ' > ASTWARN = 'The original FITS header did not specify the date of ' > ASTWARN = 'observation. A default value of J2000 was assumed.' > ASTWARN = ' ' > > > > On Tue, Apr 29, 2014 at 10:20 AM, Angelo Varlotta > wrote: >> >> Hello, >> I need to convert a list of sources from pixel coordinates to sky >> coordinates for some PAIRITel data, using astropy (0.3.1) and using the >> following code: >> >> from __future__ import division >> import numpy >> from astropy import wcs >> from astropy.io import fits >> import sys >> >> hdulist = fits.open(sys.argv[-1]) >> w = wcs.WCS(hdulist[0].header) >> pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_) >> world = w.wcs_pix2world(pixcrd, 1) >> print world >> >> (the fits file is at h_long_CYGX3.1.11_coadd.fits, the code is in a file I >> called pix2sky.py) >> >> The code derives from the first example in the documentation for >> astropy.wcs at: http://docs.astropy.org/en/stable/wcs/index.html. While I >> can do this sucessfully with a fits file generated from Fermi analysis (so I >> know that astropy is installed properly and works), with the PAIRITel data I >> get the following error message, after running from the terminal prompt >> python pix2sky.py h_long_CYGX3.1.11_coadd.fits: >> >> >> WARNING: FITSFixedWarning: RADECSYS= 'ICRS ' / Astrometric system >> RADECSYS is non-standard, use RADESYSa. [astropy.wcs.wcs] >> WARNING: FITSFixedWarning: 'datfix' made the change 'Invalid parameter >> value: invalid date '2010/5/14 09:23:52''. [astropy.wcs.wcs] >> WARNING: FITSFixedWarning: 'celfix' made the change 'PV1_5 : Unrecognized >> coordinate transformation parameter'. [astropy.wcs.wcs] >> >> Traceback (most recent call last): >> File "pix2sky.py", line 49, in >> load_wcs_from_file(sys.argv[-1]) >> File "pix2sky.py", line 36, in load_wcs_from_file >> world = w.wcs_pix2world(pixcrd, 1) >> File >> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", >> line 1159, in wcs_pix2world >> 'output', *args, **kwargs) >> File >> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", >> line 1060, in _array_converter >> return _return_single_array(xy, origin) >> File >> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", >> line 1044, in _return_single_array >> result = func(xy, origin) >> File >> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.1-py2.7-macosx-10.9-x86_64.egg/astropy/wcs/wcs.py", >> line 1158, in >> lambda xy, o: self.wcs.p2s(xy, o)['world'], >> astropy.wcs._wcs.InvalidTransformError: ERROR 6 in wcsset() at line 1562 >> of file cextern/wcslib/C/wcs.c: >> PV1_5 : Unrecognized coordinate transformation parameter. >> >> >> How do I proceed? >> >> Cheers, >> Angelo >> >> Angelo Varlotta >> Smithsonian Astrophysical Observatory >> 60 Garden St. MS-06, Cambridge, MA 02138, USA >> Phone: +1-617-495-7138 >> Office: B-226 >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From kyle at anl.gov Tue Apr 29 17:38:57 2014 From: kyle at anl.gov (Kyle Barbary) Date: Tue, 29 Apr 2014 16:38:57 -0500 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> Message-ID: Here's more information that you'd probably want to know: https://github.com/astropy/astropy/issues/299 The short answer is that the PVi_j keywords used by SCAMP are not supported by astropy.wcs, so there's not much you can do except to use a different tool. - Kyle -------------- next part -------------- An HTML attachment was scrubbed... URL: From avarlotta at cfa.harvard.edu Tue Apr 29 17:44:00 2014 From: avarlotta at cfa.harvard.edu (Angelo Varlotta) Date: Tue, 29 Apr 2014 17:44:00 -0400 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> Message-ID: <53601D20.2070308@cfa.harvard.edu> Hello, Thanks a lot for the help. I've installed PyAST on my computer and I'm now trying to understand how to implement the coordinate transformation I need. Is anyone familar with PyAST and if so, can anyone suggest the code to transform from pixel to sky coordinates and viceversa? Cheers, Angelo Kyle Barbary wrote: > Here's more information that you'd probably want to know: > > https://github.com/astropy/astropy/issues/299 > > The short answer is that the PVi_j keywords used by SCAMP are not > supported by astropy.wcs, so there's not much you can do except to use > a different tool. > - Kyle > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmwalawender at gmail.com Tue Apr 29 22:21:34 2014 From: jmwalawender at gmail.com (Josh Walawender) Date: Tue, 29 Apr 2014 16:21:34 -1000 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: <53601D20.2070308@cfa.harvard.edu> References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> <53601D20.2070308@cfa.harvard.edu> Message-ID: <340E0A4E-87B1-4FCA-AB18-7D942A1BFC0F@gmail.com> Hi Angelo, I ran in to the same problem in some python code I?m writing (needing to work with SCAMP generated distortion info). The easiest way to deal with it that I found was to rectify the image with SWarp (also from Emmanuel Bertin author of SCAMP, so they work together seamlessly). After that what?s left is an image with a simple CDn_m matrix which any software can handle. http://www.astromatic.net/software/swarp cheers, Josh On Apr 29, 2014, at 11:44 AM, Angelo Varlotta wrote: > Hello, > Thanks a lot for the help. I've installed PyAST on my computer and I'm now trying to understand how to implement the coordinate transformation I need. Is anyone familar with PyAST and if so, can anyone suggest the code to transform from pixel to sky coordinates and viceversa? > > Cheers, > Angelo > > Kyle Barbary wrote: >> >> Here's more information that you'd probably want to know: >> >> https://github.com/astropy/astropy/issues/299 >> >> The short answer is that the PVi_j keywords used by SCAMP are not supported by astropy.wcs, so there's not much you can do except to use a different tool. >> - Kyle >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From marquett at iap.fr Wed Apr 30 00:18:46 2014 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Wed, 30 Apr 2014 06:18:46 +0200 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: <53601D20.2070308@cfa.harvard.edu> References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> <53601D20.2070308@cfa.harvard.edu> Message-ID: Hi Angelo, > Thanks a lot for the help. I've installed PyAST on my computer and I'm now trying to understand how to implement the coordinate transformation I need. Is anyone familar with PyAST and if so, can anyone suggest the code to transform from pixel to sky coordinates and viceversa? astLib dos the job as well, the docs are pretty simple to deal with, see http://astlib.sourceforge.net/ and more specifically http://astlib.sourceforge.net/docs/astLib/astLib.astWCS.WCS-class.html Cheers, JB -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.berry at jach.hawaii.edu Wed Apr 30 02:32:00 2014 From: d.berry at jach.hawaii.edu (David Berry) Date: Wed, 30 Apr 2014 07:32:00 +0100 Subject: [AstroPy] Error in pixel to sky coordinate conversion with astropy.wcs In-Reply-To: <53601D20.2070308@cfa.harvard.edu> References: <535FDE95.4000707@cfa.harvard.edu> <535FDF67.3010802@cfa.harvard.edu> <53601D20.2070308@cfa.harvard.edu> Message-ID: Hi Angelo, There are examples of how to use pyast at http://dsberry.github.io/starlink/node4.html The two sections "Read a WCS Calibration from a Dataset" and "Convert Between Pixel and World Coordinates" may be the ones of most interest to you. David On 29 April 2014 22:44, Angelo Varlotta wrote: > Hello, > Thanks a lot for the help. I've installed PyAST on my computer and I'm now > trying to understand how to implement the coordinate transformation I need. > Is anyone familar with PyAST and if so, can anyone suggest the code to > transform from pixel to sky coordinates and viceversa? > > Cheers, > Angelo > > Kyle Barbary wrote: > > Here's more information that you'd probably want to know: > > https://github.com/astropy/astropy/issues/299 > > The short answer is that the PVi_j keywords used by SCAMP are not supported > by astropy.wcs, so there's not much you can do except to use a different > tool. > - Kyle > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy >