From lee.j.joon at gmail.com Thu Dec 1 00:42:36 2011 From: lee.j.joon at gmail.com (Jae-Joon Lee) Date: Thu, 1 Dec 2011 14:42:36 +0900 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: <9631592B-1798-4FED-877A-1C9219754ECD@astro.physik.uni-goettingen.de> References: <4ED65927.3030006@astro.washington.edu> <4ED6C751.6030909@gmail.com> <9631592B-1798-4FED-877A-1C9219754ECD@astro.physik.uni-goettingen.de> Message-ID: To improve the visibility of the text, you may use patheffect module, instead of changing the coloring. a = pie([1,2,4,3], labels=["1", "2", "4", "3"], autopct="%d") from matplotlib.patheffects import withStrokeeffect_whiteborder = withStroke(foreground="w", linewidth=3) for txt in a[2]:? ? txt.set_path_effects([effect_whiteborder]) Regards, -JJ On Thu, Dec 1, 2011 at 10:38 AM, Derek Homeier wrote: > On 01.12.2011, at 1:16AM, Grigoris Maravelias wrote: > >> Thanks Jake, but I know that I can set the colors but I would like it to >> happen without me specifying the colors like this. Another approach >> would be to create a list of colors according to the objects >> automatically somehow by using #hex codes but it is getting too much >> without really a purpose. >> >> Thanks for you answer! >> >> Grigoris >> >> On 11/30/2011 06:26 PM, Jacob VanderPlas wrote: >>> Try the following: >>> >>>>>> ax = pylab.axes() >>>>>> ax.set_color_cycle(['green', 'orange', 'blue', 'red','brown','pink']) >>>>>> ax.plot(x1, y1) >>>>>> ax.plot(x2, y2) >>>>>> >> > Thanks everyone, that's a very useful pointer - I have been wondering as well how > to best set the default sequence of colours. > Constructing a sequence is actually not that different using the *range() functions; > e.g. you could apply them on rgb tuples, or even more comfortable, directly access > any of the default colourmaps like > > ax.set_color_cycle(pylab.cm.coolwarm(xrange(8,256,16))) > > and just pick your favourite from > http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html > > - now there'd only have to be a wider choice of maps that would all print well as > lines on white bg ;-) but for pie charts etc. a lot of them should work well. > > Cheers, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Derek > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From johann.cohentanugi at gmail.com Thu Dec 1 02:31:01 2011 From: johann.cohentanugi at gmail.com (Johann Cohen-Tanugi) Date: Thu, 01 Dec 2011 08:31:01 +0100 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: References: <4ED65927.3030006@astro.washington.edu> <4ED6C751.6030909@gmail.com> <9631592B-1798-4FED-877A-1C9219754ECD@astro.physik.uni-goettingen.de> Message-ID: <4ED72D35.9020303@gmail.com> carriage return missing, obviously : from matplotlib.patheffects import withStroke effect_whiteborder =... Thanks for tip JJ, it is a nice trick to know. JCT On 12/01/2011 06:42 AM, Jae-Joon Lee wrote: > from matplotlib.patheffects import withStrokeeffect_whiteborder = From lee.j.joon at gmail.com Fri Dec 2 01:24:28 2011 From: lee.j.joon at gmail.com (Jae-Joon Lee) Date: Fri, 2 Dec 2011 15:24:28 +0900 Subject: [AstroPy] matplotlib's pie colors In-Reply-To: <4ED72D35.9020303@gmail.com> References: <4ED65927.3030006@astro.washington.edu> <4ED6C751.6030909@gmail.com> <9631592B-1798-4FED-877A-1C9219754ECD@astro.physik.uni-goettingen.de> <4ED72D35.9020303@gmail.com> Message-ID: Thanks, Johann. I'm not sure what happened. a = pie([1,2,4,3], labels=["1", "2", "4", "3"], autopct="%d") from matplotlib.patheffects import withStroke effect_whiteborder = withStroke(foreground="w", linewidth=3) for txt in a[2]: ? ? txt.set_path_effects([effect_whiteborder]) Also, here are some screenshots that uses patheffects. http://matplotlib.sourceforge.net/examples/pylab_examples/patheffect_demo.html Regards, -JJ On Thu, Dec 1, 2011 at 4:31 PM, Johann Cohen-Tanugi wrote: > carriage return missing, obviously : > > from matplotlib.patheffects import withStroke > effect_whiteborder =... > > Thanks for tip JJ, it is a nice trick to know. > JCT > > > > On 12/01/2011 06:42 AM, Jae-Joon Lee wrote: >> >> from matplotlib.patheffects import withStrokeeffect_whiteborder = From taro at ap.smu.ca Fri Dec 2 13:35:09 2011 From: taro at ap.smu.ca (Taro Sato) Date: Fri, 2 Dec 2011 14:35:09 -0400 Subject: [AstroPy] Table join with fits tables (or something else) Message-ID: Hi there. Sorry for a lazy question.. but is anyone here aware of any Python utility that makes it easy to do table join operations (as in SQL) with FITS tables? I'm primarily using PyFITS to store data now and wish to avoid substantial reconstruction of data structures just to accommodate such operations, but if that means moving on to a different package, I'd like to consider if the transition is worth it... Thank you for your time, Taro From embray at stsci.edu Fri Dec 2 15:53:48 2011 From: embray at stsci.edu (Erik Bray) Date: Fri, 2 Dec 2011 15:53:48 -0500 Subject: [AstroPy] Table join with fits tables (or something else) In-Reply-To: References: Message-ID: <4ED93ADC.10303@stsci.edu> Hi Taro, Is there some reason your data has to be in FITS tables? The FITS format is not inherently well-suited for high-performance manipulation/analysis of large data sets. You might want to look into PyTables. Erik On 12/02/2011 01:35 PM, Taro Sato wrote: > Hi there. Sorry for a lazy question.. but is anyone here aware of any > Python utility that makes it easy to do table join operations (as in > SQL) with FITS tables? > > I'm primarily using PyFITS to store data now and wish to avoid > substantial reconstruction of data structures just to accommodate such > operations, but if that means moving on to a different package, I'd > like to consider if the transition is worth it... > > Thank you for your time, > Taro > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From taro at ap.smu.ca Fri Dec 2 16:43:04 2011 From: taro at ap.smu.ca (Taro Sato) Date: Fri, 2 Dec 2011 17:43:04 -0400 Subject: [AstroPy] Table join with fits tables (or something else) In-Reply-To: <4ED93ADC.10303@stsci.edu> References: <4ED93ADC.10303@stsci.edu> Message-ID: On Fri, Dec 2, 2011 at 4:53 PM, Erik Bray wrote: > Hi Taro, > > Is there some reason your data has to be in FITS tables? ?The FITS > format is not inherently well-suited for high-performance > manipulation/analysis of large data sets. ?You might want to look into > PyTables. > > Erik Thank you everyone for suggestions. I'm using FITS tables out of habit for the relative ease of interfacing with NumPy via PyFITS. Still better than those who insisted that I keep all survey data in text files................ yes they still exist!! Many science-oriented people are averse to new technology regardless of merit, so colleagues' apparent familiarity with the FITS format was also the reason... some still don't learn how to read binary tables..................... don't get me started!! I guess there really is no way out unless the data are stored with RDB in mind from the outset. I'll try join() to see if it has any performance advantage, but for personal stuff I'll consider using HDF5 or PyTables in future. Thanks again, Taro From moritz.guenther at gmx.de Sat Dec 3 13:24:29 2011 From: moritz.guenther at gmx.de (Hans Moritz Guenther) Date: Sat, 03 Dec 2011 13:24:29 -0500 Subject: [AstroPy] Table join with fits tables (or something else) In-Reply-To: References: Message-ID: <4EDA695D.9020500@gmx.de> Hi, how big are your tables? I had a similar problem and I have extended atpy (atpy.github.com) to do it. atpy handles all the input and output, thus any format that is supported by atpy should work. Joining tables works fine for <1e5 entries in your tables but becomes a bit slow for larger sets. See: https://github.com/hamogu/atpy-extensions It's called a catalog, because I had join with cross-matching of sources in different catalogs in mind, but any other field is possible: e.g. to join catalogs according to the field "name": import catalog def match_source_name(self, pos, data): return np.where(self['name'] == pos)[0] mycatalog1 = catalog.BaseCatalog('myfile1.fits') mycatalog2 = catalog.BaseCatalog('myfile2.fits') mycatalog1.match_source = match_source_name mycatalog1.add_catalog(mycatalog2, auto_add_columns = True) However, documentation is not quite done, because I decided to publish that modul once the astropy table format is defined (and I will change it use the astropy table format instead of atpy). If you want to use it, feel free to send my some more details and I'll make an example that works for you. I would welcome that as a test for this module. Moritz From Christoph.Deil at mpi-hd.mpg.de Sat Dec 3 17:33:08 2011 From: Christoph.Deil at mpi-hd.mpg.de (Christoph Deil) Date: Sat, 3 Dec 2011 23:33:08 +0100 Subject: [AstroPy] Table join with fits tables (or something else) In-Reply-To: References: Message-ID: On Dec 2, 2011, at 7:35 PM, Taro Sato wrote: > Hi there. Sorry for a lazy question.. but is anyone here aware of any > Python utility that makes it easy to do table join operations (as in > SQL) with FITS tables? > > I'm primarily using PyFITS to store data now and wish to avoid > substantial reconstruction of data structures just to accommodate such > operations, but if that means moving on to a different package, I'd > like to consider if the transition is worth it... > > Thank you for your time, > Taro Hi Taro, maybe it is possible to convert your FITS tables to sqlite, perform the join operations there using SQL and then convert back to FITS? sqlite3 is in the python standard library and with ATpy you just need a few commands for the conversions: http://docs.python.org/library/sqlite3.html http://atpy.github.com/format_sql.html I'm not sure it is possible to convert FITS to sqlite and back easily in memory without temp files, so possibly this approach could be too slow for you. There is also a very nice Java library / command line tool / GUI called STIL / STILTS / TOPCAT that can perform join and many other operations on FITS tables: http://www.star.bristol.ac.uk/~mbt/stil/ http://www.star.bristol.ac.uk/~mbt/stilts/ http://www.star.bristol.ac.uk/~mbt/topcat/ It has a Jython interface, but unfortunately can't be used from CPython. As far as I know there is no equivalent (feature-rich, fast, well-tested) CPython package for FITS astronomy tables. Christoph -------------- next part -------------- An HTML attachment was scrubbed... URL: From erin.sheldon at gmail.com Sat Dec 3 23:37:41 2011 From: erin.sheldon at gmail.com (Erin Sheldon) Date: Sat, 3 Dec 2011 23:37:41 -0500 Subject: [AstroPy] Table join with fits tables (or something else) In-Reply-To: References: Message-ID: The fitsio package supports querying a FITS file without reading the data into memory. https://github.com/esheldon/fitsio You could use this functionality to perform a "join" by writing some wrapper functions. I would be interested in this if you did, and maybe we could work it into the main package if it is general enough -e On Fri, Dec 2, 2011 at 1:35 PM, Taro Sato wrote: > Hi there. ?Sorry for a lazy question.. but is anyone here aware of any > Python utility that makes it easy to do table join operations (as in > SQL) with FITS tables? > > I'm primarily using PyFITS to store data now and wish to avoid > substantial reconstruction of data structures just to accommodate such > operations, but if that means moving on to a different package, I'd > like to consider if the transition is worth it... > > Thank you for your time, > Taro > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Erin Scott Sheldon Brookhaven National Laboratory From wkerzendorf at gmail.com Mon Dec 5 15:36:06 2011 From: wkerzendorf at gmail.com (Wolfgang Kerzendorf) Date: Mon, 5 Dec 2011 12:36:06 -0800 Subject: [AstroPy] reading fixed format tables Message-ID: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> Hello, I'm looking for a fixed format table reader. Fixed format like in the fortran definition(no spaces, just a prescribed formatting). e.g. FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) Does atpy do that? Is there any other package that does that or do I need to role my own? Cheers W -------------- next part -------------- An HTML attachment was scrubbed... URL: From aldcroft at head.cfa.harvard.edu Mon Dec 5 15:41:38 2011 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Mon, 5 Dec 2011 15:41:38 -0500 Subject: [AstroPy] reading fixed format tables In-Reply-To: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> References: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> Message-ID: Asciitable of course :). See the second example here: http://cxc.harvard.edu/contrib/asciitable/fixed_width_gallery.html#fixedwidthnoheader You'll have to calculate the column start and stop indexes. - Tom On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf wrote: > Hello, > > I'm looking for a fixed format table reader. Fixed format like in the > fortran definition(no spaces, just a prescribed formatting). > > e.g.?FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, > > 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) > > > Does atpy do that? Is there any other package that does that or do I need to > role my own? > > Cheers > ? W > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From erin.sheldon at gmail.com Mon Dec 5 15:42:27 2011 From: erin.sheldon at gmail.com (Erin Sheldon) Date: Mon, 5 Dec 2011 15:42:27 -0500 Subject: [AstroPy] reading fixed format tables In-Reply-To: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> References: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> Message-ID: The recfile packages is designed to do that. Files can be binary, as I think you are specifying, or ascii. You specify the dtype for each row as when constructing an array with fields. http://code.google.com/p/recfile/ This is C++ code linked to python, so it's fast. You can also specify arbitrary subsets of the data to read based on column name and row number, and only those data are read. I recommend checking out from trunk; I've had some bug fixes that haven't been released yet. -e On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf wrote: > Hello, > > I'm looking for a fixed format table reader. Fixed format like in the > fortran definition(no spaces, just a prescribed formatting). > > e.g.?FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, > > 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) > > > Does atpy do that? Is there any other package that does that or do I need to > role my own? > > Cheers > ? W > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Erin Scott Sheldon Brookhaven National Laboratory From mrdavis at stsci.edu Mon Dec 5 15:43:36 2011 From: mrdavis at stsci.edu (Matt Davis) Date: Mon, 5 Dec 2011 15:43:36 -0500 Subject: [AstroPy] reading fixed format tables In-Reply-To: References: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> Message-ID: <8228E058-5C42-4F51-B66E-DDCBA2444764@stsci.edu> It looks like numpy.genfromtxt can also do this, see the last example: http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html - Matt On Dec 5, 2011, at 3:41 PM, Tom Aldcroft wrote: > Asciitable of course :). See the second example here: > > http://cxc.harvard.edu/contrib/asciitable/fixed_width_gallery.html#fixedwidthnoheader > > You'll have to calculate the column start and stop indexes. > > - Tom > > On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf > wrote: >> Hello, >> >> I'm looking for a fixed format table reader. Fixed format like in the >> fortran definition(no spaces, just a prescribed formatting). >> >> e.g. FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, >> >> 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) >> >> >> Does atpy do that? Is there any other package that does that or do I need to >> role my own? >> >> Cheers >> W >> >> _______________________________________________ >> 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 derek at astro.physik.uni-goettingen.de Mon Dec 5 17:33:53 2011 From: derek at astro.physik.uni-goettingen.de (Derek Homeier) Date: Mon, 5 Dec 2011 23:33:53 +0100 Subject: [AstroPy] reading fixed format tables In-Reply-To: <8228E058-5C42-4F51-B66E-DDCBA2444764@stsci.edu> References: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> <8228E058-5C42-4F51-B66E-DDCBA2444764@stsci.edu> Message-ID: On 05.12.2011, at 9:43PM, Matt Davis wrote: > It looks like numpy.genfromtxt can also do this, see the last example: http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html > Yes, using delimiter=[11,7,6,12,5?] will do this; you'd also have to calculate the widths from the Fortran specifiers and provide the necessary dtypes for int or string. There also has been a FortranFormat package around for a long time which still seems to be alive here http://pypi.python.org/pypi/fortranformat and directly understands the Fortran specifiers. Last time I've used it it was very slow, but that may have improved (if it is even the same package). Cheers, Derek > - Matt > > On Dec 5, 2011, at 3:41 PM, Tom Aldcroft wrote: > >> Asciitable of course :). See the second example here: >> >> http://cxc.harvard.edu/contrib/asciitable/fixed_width_gallery.html#fixedwidthnoheader >> >> You'll have to calculate the column start and stop indexes. >> >> - Tom >> >> On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf >> wrote: >>> Hello, >>> >>> I'm looking for a fixed format table reader. Fixed format like in the >>> fortran definition(no spaces, just a prescribed formatting). >>> >>> e.g. FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, >>> >>> 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) >>> >>> >>> Does atpy do that? Is there any other package that does that or do I need to >>> role my own? >> From embray at stsci.edu Mon Dec 5 18:25:36 2011 From: embray at stsci.edu (Erik Bray) Date: Mon, 5 Dec 2011 18:25:36 -0500 Subject: [AstroPy] reading fixed format tables In-Reply-To: <8228E058-5C42-4F51-B66E-DDCBA2444764@stsci.edu> References: <41A3E2AA-5E90-4355-B9F0-C1C901D951B1@gmail.com> <8228E058-5C42-4F51-B66E-DDCBA2444764@stsci.edu> Message-ID: <4EDD52F0.3030306@stsci.edu> On 12/05/2011 03:43 PM, Matt Davis wrote: > It looks like numpy.genfromtxt can also do this, see the last example: > http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html Wow, I didn't even know about this function. I'll have to take a closer look later, but I suspect it might be able to replace a bunch of code in pyfits. > > - Matt > > On Dec 5, 2011, at 3:41 PM, Tom Aldcroft wrote: > >> Asciitable of course :). See the second example here: >> >> http://cxc.harvard.edu/contrib/asciitable/fixed_width_gallery.html#fixedwidthnoheader >> >> You'll have to calculate the column start and stop indexes. >> >> - Tom >> >> On Mon, Dec 5, 2011 at 3:36 PM, Wolfgang Kerzendorf >> wrote: >>> Hello, >>> >>> I'm looking for a fixed format table reader. Fixed format like in the >>> fortran definition(no spaces, just a prescribed formatting). >>> >>> e.g. FORMAT(F11.4,F7.3,F6.2,F12.3,F5.2,1X,A10,F12.3,F5.2,1X,A10, >>> >>> 3F6.2,A4,2I2,I3,F6.3,I3,F6.3,2I5,1X,A1,A1,1X,A1,A1,i1,A3.2I5,I6) >>> >>> >>> Does atpy do that? Is there any other package that does that or do I >>> need to >>> role my own? >>> >>> Cheers >>> W >>> >>> _______________________________________________ >>> 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 > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From thomas.robitaille at gmail.com Wed Dec 7 06:19:06 2011 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Wed, 7 Dec 2011 12:19:06 +0100 Subject: [AstroPy] arbitrary coordinate systems and data cube slicing in APLpy In-Reply-To: References: Message-ID: Hi, I just wanted to check whether anyone has had a chance to try the new functionality in APLpy relating to multi-dimensional data cubes? (see below) If so, please let me know whether it worked for you, or whether you have any issues or requests. If there are no issues, we will start moving towards a stable release. Cheers, Tom On 18 November 2011 17:59, Thomas Robitaille wrote: > Hi everyone, > > Over the last couple of months, I've made extensive changes to the > core APLpy code to allow us to support plotting of FITS files with > arbitrary coordinates rather than just sky coordinates, and to also > allow slicing of multi-dimensional data cubes. It is now very easy for > example to make position-velocity plots from a 3D FITS cube. > > Due to the extensive nature of the changes, and before releasing a > stable release (0.9.7), I would like to request beta testers to try > installing the latest developer version of APLpy and try out the new > functionality. Since the under-the-hood changes even affect plotting > of normal 2D 'sky' images, I would also welcome volunteers to try > using the latest developer version of APLpy with your current scripts > to help diagnose any issues. > > To install the latest developer version: > > git clone git://github.com/aplpy/aplpy.git > cd aplpy > python setup.py install > > I have written up a documentation page regarding arbitrary coordinate systems: > > http://aplpy.github.com/documentation/arbitrary_coordinate_systems.html > > as well as regarding slicing (in particular, check out the example): > > http://aplpy.github.com/documentation/slicing.html > > Please report any issues via GitHub: > > https://github.com/aplpy/aplpy/issues > > and if you need to send me any example files to reproduce issues, you > can send them to me at thomas.robitaille at gmail.com (data will be > treated as confidential). > > Note that these updates supersede the userwcs branch of APLpy that was > created by Adam Ginsburg to support non-coordinate axes. > > Please let me know if you have any comments or suggestions regarding > this functionality, or suggestions for improving the documentation! > > Cheers, > Tom From jerome_caron_astro at ymail.com Wed Dec 7 17:07:38 2011 From: jerome_caron_astro at ymail.com (Jerome Caron) Date: Wed, 7 Dec 2011 22:07:38 +0000 (GMT) Subject: [AstroPy] error reading Vizier votable with atpy In-Reply-To: References: Message-ID: <1323295658.8398.YahooMailNeo@web24604.mail.ird.yahoo.com> Dear list, I am trying to write a simple script to send queries to Vizier and retrieve star positions and magnitudes. At the moment my script works well for all catalogs except for USNO-B1. I get the following error message: numpy.dtype size changed, may indicate binary incompatibility numpy.dtype size changed, may indicate binary incompatibility out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1.? Ignoring out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1.? Ignoring Traceback (most recent call last): ? File "C:\Documents and Settings\jerome caron\Desktop\test4.py", line 17, in ??? data = atpy.Table(op.name,type='vo',pedantic=False) ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 167, in __init__ ??? self.read(*args, **kwargs) ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 213, in read ??? atpy._readers[table_type](self, *args, **kwargs) ? File "C:\Python26\lib\site-packages\atpy\votable.py", line 115, in read ??? self.add_column(colname, table.array[colname], \ ? File "C:\Python26\lib\site-packages\numpy\core\records.py", line 455, in __getitem__ ??? obj = ndarray.__getitem__(self, indx) ValueError: field named USNO_B1_0 not found. Press any key to continue . . . Can anyone give some help ? My script is at the end of the email, and the votable attached. Thank very much ! Cheers Jerome Caron ----------------------------------- The script: # -*- coding: iso_8859_1 -*- import atpy, urllib fp = urllib.urlopen("http://webviz.u-strasbg.fr/viz-bin/votable/?-source=2MASS-PSC&-c=IC458&-c.rm=5&-out.max=unlimited") op = open("out.xml", "wb") while 1: ??? s = fp.read(8192) ??? if not s: ??????? break ??? op.write(s) fp.close() op.close() data = atpy.Table(op.name,type='vo',pedantic=False) print data.describe() print data.columns raw_input("done!") -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: usno-b1.vot Type: application/octet-stream Size: 26260 bytes Desc: not available URL: From thomas.robitaille at gmail.com Wed Dec 7 18:28:15 2011 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Thu, 8 Dec 2011 00:28:15 +0100 Subject: [AstroPy] error reading Vizier votable with atpy In-Reply-To: <1323295658.8398.YahooMailNeo@web24604.mail.ird.yahoo.com> References: <1323295658.8398.YahooMailNeo@web24604.mail.ird.yahoo.com> Message-ID: Hi Jerome, What version of ATpy are you using? Do you get the same error with the latest developer version of ATpy? You can get it with: git clone git://github.com/atpy/atpy.git cd atpy python setup.py install Let me know if it still fails with this version. Cheers, Tom On 7 December 2011 23:07, Jerome Caron wrote: > Dear list, > > I am trying to write a simple script to send queries to Vizier and retrieve > star positions and magnitudes. > At the moment my script works well for all catalogs except for USNO-B1. > I get the following error message: > > numpy.dtype size changed, may indicate binary incompatibility > numpy.dtype size changed, may indicate binary incompatibility > out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1. > Ignoring > out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1. > Ignoring > Traceback (most recent call last): > ? File "C:\Documents and Settings\jerome caron\Desktop\test4.py", line 17, > in > ??? data = atpy.Table(op.name,type='vo',pedantic=False) > ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 167, in > __init__ > ??? self.read(*args, **kwargs) > ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 213, in read > ??? atpy._readers[table_type](self, *args, **kwargs) > ? File "C:\Python26\lib\site-packages\atpy\votable.py", line 115, in read > ??? self.add_column(colname, table.array[colname], \ > ? File "C:\Python26\lib\site-packages\numpy\core\records.py", line 455, in > __getitem__ > ??? obj = ndarray.__getitem__(self, indx) > ValueError: field named USNO_B1_0 not found. > Press any key to continue . . . > Can anyone give some help ? > My script is at the end of the email, and the votable attached. > Thank very much ! > Cheers > > Jerome Caron > ----------------------------------- > The script: > # -*- coding: iso_8859_1 -*- > import atpy, urllib > fp = > urllib.urlopen("http://webviz.u-strasbg.fr/viz-bin/votable/?-source=2MASS-PSC&-c=IC458&-c.rm=5&-out.max=unlimited") > op = open("out.xml", "wb") > while 1: > ??? s = fp.read(8192) > ??? if not s: > ??????? break > ??? op.write(s) > fp.close() > op.close() > data = atpy.Table(op.name,type='vo',pedantic=False) > print data.describe() > print data.columns > raw_input("done!") > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From jerome_caron_astro at ymail.com Thu Dec 8 14:09:35 2011 From: jerome_caron_astro at ymail.com (Jerome Caron) Date: Thu, 8 Dec 2011 19:09:35 +0000 (GMT) Subject: [AstroPy] Tr : Re : error reading Vizier votable with atpy In-Reply-To: <1323341858.86064.YahooMailNeo@web24615.mail.ird.yahoo.com> References: <1323295658.8398.YahooMailNeo@web24604.mail.ird.yahoo.com> <1323302409.17621.YahooMailNeo@web24615.mail.ird.yahoo.com> <4133137612446113905@unknownmsgid> <1323341858.86064.YahooMailNeo@web24615.mail.ird.yahoo.com> Message-ID: <1323371375.62827.YahooMailNeo@web24614.mail.ird.yahoo.com> Sorry I pressed "reply" and forgot to put the list address.. See my message below. Cheers Jerome ----- Mail transf?r? ----- De?: Jerome Caron ??: Thomas Robitaille Envoy? le : Jeudi 8 D?cembre 2011 11h57 Objet?: Re : Re : [AstroPy] error reading Vizier votable with atpy Dear Thomas, ? I installed version 0.9.5.3, now it works fine with USNO-B1 ! But I have problems with other catalogs which were ok initially (2MASS-PSC). Do you know what is happening ? It looks like the initial field names are modified at some point, and then not recognized later. I copy the error message below. ? In the meantime I solved the issue with a different script that is using the vo module (I also post it) and that works fine for all cases. ? Cheers The error message with atpy 0.9.5.3 ? numpy.dtype size changed, may indicate binary incompatibility numpy.dtype size changed, may indicate binary incompatibility out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1.? Ignori ng out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1.? Ignori ng out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' Traceback (most recent call last): ? File "C:\Documents and Settings\jerome caron\Desktop\vizier\test5.py", line 12 , in ??? data = atpy.Table(op.name,type='vo',pedantic=False) ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 167, in __init__ ??? self.read(*args, **kwargs) ? File "C:\Python26\lib\site-packages\atpy\basetable.py", line 213, in read ??? atpy._readers[table_type](self, *args, **kwargs) ? File "C:\Python26\lib\site-packages\atpy\votable.py", line 106, in read ??? data = table.array[colname] ? File "C:\Python26\lib\site-packages\numpy\core\records.py", line 455, in __get item__ ??? obj = ndarray.__getitem__(self, indx) ValueError: field named 2MASS not found. Press any key to continue . . . The script based on vo, which works fine # -*- coding: iso_8859_1 -*- import matplotlib.pyplot as plt import urllib import numpy as np fp = urllib.urlopen("http://webviz.u-strasbg.fr/viz-bin/votable/?-source=USNO-B1&-c=M45&-c.bm=600/600&B1mag=%3C13&-out.max=unlimited") op = open("out.xml", "wb") while 1: ??? s = fp.read(8192) ??? if not s: ??????? break ??? op.write(s) fp.close() op.close() from vo.table import parse_single_table votable = parse_single_table("out.xml", pedantic=False) data = votable.arrayraw_input("done!") Jerome -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.robitaille at gmail.com Fri Dec 9 08:22:31 2011 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Fri, 9 Dec 2011 14:22:31 +0100 Subject: [AstroPy] Tr : Re : error reading Vizier votable with atpy In-Reply-To: <1323371375.62827.YahooMailNeo@web24614.mail.ird.yahoo.com> References: <1323295658.8398.YahooMailNeo@web24604.mail.ird.yahoo.com> <1323302409.17621.YahooMailNeo@web24615.mail.ird.yahoo.com> <4133137612446113905@unknownmsgid> <1323341858.86064.YahooMailNeo@web24615.mail.ird.yahoo.com> <1323371375.62827.YahooMailNeo@web24614.mail.ird.yahoo.com> Message-ID: Hi Jerome, Try reading this file (and the initial one you had issues with) using the latest version of ATpy: git clone git://github.com/atpy/atpy.git ATpy cd ATpy python setup.py install I fixed how column names are defined for VO tables. Cheers, Tom On Thursday, 8 December 2011 at 20:09, Jerome Caron wrote: > Sorry > I pressed "reply" and forgot to put the list address.. See my message below. > Cheers > Jerome > > ----- Mail transf?r? ----- > De : Jerome Caron > ? : Thomas Robitaille > Envoy? le : Jeudi 8 D?cembre 2011 11h57 > Objet : Re : Re : [AstroPy] error reading Vizier votable with atpy > > Dear Thomas, > > I installed version 0.9.5.3, now it works fine with USNO-B1 ! > But I have problems with other catalogs which were ok initially (2MASS-PSC). Do you know what is happening ? It looks like the initial field names are modified at some point, and then not recognized later. > I copy the error message below. > > In the meantime I solved the issue with a different script that is using the vo module (I also post it) and that works fine for all cases. > > Cheers > Jerome > > The error message with atpy 0.9.5.3 > > numpy.dtype size changed, may indicate binary incompatibility > numpy.dtype size changed, may indicate binary incompatibility > out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1. Ignori > ng > out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' > out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' > out.xml:12:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1. Ignori > ng > out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' > out.xml:41:4: W03: Implictly generating an ID from a name '2MASS' -> '_2MASS' > Traceback (most recent call last): > File "C:\Documents and Settings\jerome caron\Desktop\vizier\test5.py", line 12 > , in > data = atpy.Table(op.name (http://op.name),type='vo',pedantic=False) > File "C:\Python26\lib\site-packages\atpy\basetable.py", line 167, in __init__ > self.read(*args, **kwargs) > File "C:\Python26\lib\site-packages\atpy\basetable.py", line 213, in read > atpy._readers[table_type](self, *args, **kwargs) > File "C:\Python26\lib\site-packages\atpy\votable.py", line 106, in read > data = table.array[colname] > File "C:\Python26\lib\site-packages\numpy\core\records.py", line 455, in __get > item__ > obj = ndarray.__getitem__(self, indx) > ValueError: field named 2MASS not found. > Press any key to continue . . . > > > The script based on vo, which works fine > > # -*- coding: iso_8859_1 -*- > import matplotlib.pyplot as plt > import urllib > import numpy as np > fp = urllib.urlopen("http://webviz.u-strasbg.fr/viz-bin/votable/?-source=USNO-B1&-c=M45&-c.bm=600/600&B1mag=%3C13&-out.max=unlimited") > op = open("out.xml", "wb") > while 1: > s = fp.read(8192) > if not s: > break > op.write(s) > fp.close() > op.close() > from vo.table import parse_single_table > votable = parse_single_table("out.xml", pedantic=False) > data = votable.arrayraw_input("done!") > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org (mailto:AstroPy at scipy.org) > http://mail.scipy.org/mailman/listinfo/astropy From s at skory.us Thu Dec 15 14:44:13 2011 From: s at skory.us (Stephen Skory) Date: Thu, 15 Dec 2011 12:44:13 -0700 Subject: [AstroPy] yt 2.3 Release Announcement Message-ID: (We encourage you to forward this message to any other interested parties.) Hello, Just in time for the New Year, we?re happy to announce the release of yt version 2.3! ?( http://yt-project.org/ ) ?The new version includes many new modules and enhancements, and the usual set of bug fixes over the last point release. We encourage all users to upgrade to take advantage of the changes. yt is a community-developed analysis and visualization toolkit for astrophysical simulation data. yt provides full support for Enzo, Orion, Nyx, and FLASH codes, with preliminary support for the RAMSES code (and a handful of others.) ?It can be used to create many common types of data products, as well as serving as a library for developing your own data reductions and processes. Below is a non-comprehensive list of new features and enhancements: * Improved and expanded documentation located at http://yt-project.org/doc/.* Boolean logic data containers (joins, intersections and nots) to select arbitrary data regions.* Multi-level parallelism for subgroups of MPI tasks.* Extensive answer tests.* Isocontouring and flux-over-surface calculations, with WebGL interface.* A reorganized field system.* Adaptive resolution HEALpix-based all-sky volume rendering.* Radial column density calculations.* Memory usage, performance enhancements and bug fixes throughout the code. Everything, from installation, to development, to a cookbook, can be found on the homepage: http://yt-project.org/ We have updated the libraries installed with the install script; for more information, see the ?Dependencies? section of the yt docs at http://yt-project.org/doc/advanced/installing.html. Development has been sponsored by the NSF, DOE, and various University funding. We invite you to get involved with developing and using yt! We?re also holding the FIRST YT WORKSHOP from January 24-26 at the FLASH center in Chicago. ?See the workshop homepage for more information! ?http://yt-project.org/workshop2012/ Please forward this announcement to interested parties. Sincerely,? ? The yt development team From jerome_caron_astro at ymail.com Sat Dec 17 02:54:10 2011 From: jerome_caron_astro at ymail.com (Jerome Caron) Date: Sat, 17 Dec 2011 07:54:10 +0000 (GMT) Subject: [AstroPy] problem with vo.table reading SkyBoT xml file In-Reply-To: References: Message-ID: <1324108450.19402.YahooMailNeo@web24611.mail.ird.yahoo.com> Dear list ? I try to use the SkyBoT service to retrieve asteroid positions, but I have some difficulties to read the VOtable with the vo.table python module. SkyBoT is described here http://vo.imcce.fr/webservices/skybot/?conesearch ? If I get the file with the following request (search radius - 100 arcmin) and save it under skybot.xmlhttp://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-rm=100&-mime=votable&-output=object&-loc=500 ? from vo.table import parse_single_table votable = parse_single_table("skybot.xml", pedantic=False) ? But if I make a search in a square box http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-bm=100x100&-mime=votable&-output=object&-loc=500 Then the same instruction creates an error. Does anyone have an idea ? The syntax of my request seems fine and I got a proper response from SkyBoT. It looks like there is a problem with vo.table. I am using vo-0.7.2. ? Thanks for your help Cheers Jerome ? The xml file is attached, and error message is below. skybot.xml:2:0: W42: No XML namespace specified skybot.xml:26:0: W06: Invalid UCD 'instr.fov': Secondary word 'instr.fov' is not ?valid as a primary word skybot.xml:26:0: W30: Invalid literal for float '6000x6000'.? Treating as empty. Traceback (most recent call last): ? File "C:\Documents and Settings\jerome caron\Desktop\test.py", line 10, in ??? votable = parse_single_table("skybot.xml", pedantic=False) ? File "C:\Python26\lib\site-packages\vo\table.py", line 117, in parse_single_ta ble ??? votable = parse(source, **kwargs) ? File "C:\Python26\lib\site-packages\vo\table.py", line 103, in parse ??? return tree.VOTableFile(config=config, pos=(1, 1)).parse(iterator, config) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 2872, in parse ??? iterator, tag, data, config, pos) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 2810, in _add_resource ??? resource.parse(self, iterator, config) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 2654, in parse ??? tag_mapping.get(tag, self._add_unknown_tag)(iterator, tag, data, config, pos ) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 2622, in _add_param ??? param.parse(iterator, config) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 1134, in parse ??? self._setup(config, pos) ? File "C:\Python26\lib\site-packages\vo\tree.py", line 1187, in _setup ??? self.value = self._value ? File "C:\Python26\lib\site-packages\vo\tree.py", line 1173, in _set_value ??? vo_raise(E14, (), self._config, self._pos) ? File "C:\Python26\lib\site-packages\vo\voexceptions.py", line 79, in vo_raise ??? raise exception_class(args, config, pos) vo.voexceptions.E14: skybot.xml:26:0: E14: value attribute is required for all P ARAM elements Press any key to continue . . .Then I can read it with the following code -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: skybot.xml Type: application/octet-stream Size: 63173 bytes Desc: not available URL: From fred.grollier at gmail.com Sat Dec 17 06:17:43 2011 From: fred.grollier at gmail.com (=?ISO-8859-1?Q?Fr=E9d=E9ric_Grollier?=) Date: Sat, 17 Dec 2011 12:17:43 +0100 Subject: [AstroPy] problem with vo.table reading SkyBoT xml file In-Reply-To: <1324108450.19402.YahooMailNeo@web24611.mail.ird.yahoo.com> References: <1324108450.19402.YahooMailNeo@web24611.mail.ird.yahoo.com> Message-ID: <4EEC7A57.80307@gmail.com> Le 17/12/2011 08:54, Jerome Caron a ?crit : > Dear list > I try to use the SkyBoT service to retrieve asteroid positions, but I > have some difficulties to read the VOtable with the vo.table python module. > SkyBoT is described here > http://vo.imcce.fr/webservices/skybot/?conesearch > If I get the file with the following request (search radius - 100 > arcmin) and save it under skybot.xml > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-rm=100&-mime=votable&-output=object&-loc=500 > Then I can read it with the following code > from vo.table import parse_single_table > votable = parse_single_table("skybot.xml", pedantic=False) > But if I make a search in a square box > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-bm=100x100&-mime=votable&-output=object&-loc=500 > Then the same instruction creates an error. > Does anyone have an idea ? The syntax of my request seems fine and I got > a proper response from SkyBoT. > It looks like there is a problem with vo.table. I am using vo-0.7.2. Well, as the traceback suggests, the problem in fact lies in the xml file. In the line 26 of your second file, "fovSR" is said to be of datatype 'double' with a value of "6000x6000", which is indeed inconsistent. With your first request this value is "12000", which is a valid value for a double. You can for example manually change "6000x6000" by eg. "6000" to validate this explanation, and everything should go well. So as far as I can tell the problem is with the SkyBoT code which generates invalid xml output, and you should probably warn the IMCCE about it. Fred. From jerome_caron_astro at ymail.com Sat Dec 17 14:30:41 2011 From: jerome_caron_astro at ymail.com (Jerome Caron) Date: Sat, 17 Dec 2011 19:30:41 +0000 (GMT) Subject: [AstroPy] Re : problem with vo.table reading SkyBoT xml file In-Reply-To: <4EEC7A57.80307@gmail.com> References: <1324108450.19402.YahooMailNeo@web24611.mail.ird.yahoo.com> <4EEC7A57.80307@gmail.com> Message-ID: <1324150241.93077.YahooMailNeo@web24605.mail.ird.yahoo.com> Dear Fred, ? Many thanks for your reply. You are right, it looks like an error ! I edited the file manually and replaced "double" with "char" and now the Python code works perfectly. I have sent a message to IMCCE to mention the issue. I hope it will be fixed soon. ? Cheers Jerome ? ________________________________ De?: Fr?d?ric Grollier ??: astropy at scipy.org Envoy? le : Samedi 17 D?cembre 2011 12h17 Objet?: Re: [AstroPy] problem with vo.table reading SkyBoT xml file Le 17/12/2011 08:54, Jerome Caron a ?crit : > Dear list > I try to use the SkyBoT service to retrieve asteroid positions, but I > have some difficulties to read the VOtable with the vo.table python module. > SkyBoT is described here > http://vo.imcce.fr/webservices/skybot/?conesearch > If I get the file with the following request (search radius - 100 > arcmin) and save it under skybot.xml > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-rm=100&-mime=votable&-output=object&-loc=500 > Then I can read it with the following code > from vo.table import parse_single_table > votable = parse_single_table("skybot.xml", pedantic=False) > But if I make a search in a square box > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-bm=100x100&-mime=votable&-output=object&-loc=500 > Then the same instruction creates an error. > Does anyone have an idea ? The syntax of my request seems fine and I got > a proper response from SkyBoT. > It looks like there is a problem with vo.table. I am using vo-0.7.2. Well, as the traceback suggests, the problem in fact lies in the xml file. In the line 26 of your second file, "fovSR" is said to be of datatype 'double' with a value of "6000x6000", which is indeed inconsistent. With your first request this value is "12000", which is a valid value for a double. You can for example manually change "6000x6000" by eg. "6000" to validate this explanation, and everything should go well. So as far as I can tell the problem is with the SkyBoT code which generates invalid xml output, and you should probably warn the IMCCE about it. Fred. _______________________________________________ AstroPy mailing list AstroPy at scipy.org http://mail.scipy.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerome_caron_astro at ymail.com Sun Dec 18 03:26:13 2011 From: jerome_caron_astro at ymail.com (Jerome Caron) Date: Sun, 18 Dec 2011 08:26:13 +0000 (GMT) Subject: [AstroPy] Re : Re : problem with vo.table reading SkyBoT xml file In-Reply-To: <1324150241.93077.YahooMailNeo@web24605.mail.ird.yahoo.com> References: <1324108450.19402.YahooMailNeo@web24611.mail.ird.yahoo.com> <4EEC7A57.80307@gmail.com> <1324150241.93077.YahooMailNeo@web24605.mail.ird.yahoo.com> Message-ID: <1324196773.91301.YahooMailNeo@web24603.mail.ird.yahoo.com> Dear list, ? I received a mail from IMCCE, the problem was fixed this morning. Now the python code works perfectly on square boxes ! ? Cheers Jerome ________________________________ De?: Jerome Caron ??: "astropy at scipy.org" Envoy? le : Samedi 17 D?cembre 2011 20h30 Objet?: [AstroPy] Re : problem with vo.table reading SkyBoT xml file Dear Fred, ? Many thanks for your reply. You are right, it looks like an error ! I edited the file manually and replaced "double" with "char" and now the Python code works perfectly. I have sent a message to IMCCE to mention the issue. I hope it will be fixed soon. Cheers Jerome ________________________________ De?: Fr?d?ric Grollier ??: astropy at scipy.org Envoy? le : Samedi 17 D?cembre 2011 12h17 Objet?: Re: [AstroPy] problem with vo.table reading SkyBoT xml file Le 17/12/2011 08:54, Jerome Caron a ?crit : > Dear list > I try to use the SkyBoT service to retrieve asteroid positions, but I > have some difficulties to read the VOtable with the vo.table python module. > SkyBoT is described here > http://vo.imcce.fr/webservices/skybot/?conesearch > If I get the file with the following request (search radius - 100 > arcmin) and save it under skybot.xml > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-rm=100&-mime=votable&-output=object&-loc=500 > Then I can read it with the following code > from vo.table import parse_single_table > votable = parse_single_table("skybot.xml", pedantic=False) > But if I make a search in a square box > http://vo.imcce.fr/webservices/skybot/skybotconesearch_query.php?-ep=2455911.0&-ra=0.0&-dec=0.0&-bm=100x100&-mime=votable&-output=object&-loc=500 > Then the same instruction creates an error. > Does anyone have an idea ? The syntax of my request seems fine and I got > a proper response from SkyBoT. > It looks like there is a problem with vo.table. I am using vo-0.7.2. Well, as the traceback suggests, the problem in fact lies in the xml file. In the line 26 of your second file, "fovSR" is said to be of datatype 'double' with a value of "6000x6000", which is indeed inconsistent. With your first request this value is "12000", which is a valid value for a double. You can for example manually change "6000x6000" by eg. "6000" to validate this explanation, and everything should go well. So as far as I can tell the problem is with the SkyBoT code which generates invalid xml output, and you should probably warn the IMCCE about it. Fred. _______________________________________________ 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 jim.vickroy at noaa.gov Thu Dec 22 18:34:59 2011 From: jim.vickroy at noaa.gov (Jim Vickroy) Date: Thu, 22 Dec 2011 16:34:59 -0700 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows Message-ID: My Python version is: '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]' and numpy.__version__ is: '1.6.1' Here is the output from my installation attempt: C:\Documents and Settings\jim.vickroy\My Documents\$downloads\languages\Python\pywcs\pywcs-1.10-4.7>setup.py install running install running build running build_py creating build creating build\lib.win32-2.6 creating build\lib.win32-2.6\pywcs copying lib\pywcs.py -> build\lib.win32-2.6\pywcs copying lib\svn_version.py -> build\lib.win32-2.6\pywcs copying lib\_docutil.py -> build\lib.win32-2.6\pywcs copying lib\__init__.py -> build\lib.win32-2.6\pywcs creating build\lib.win32-2.6\pywcs\tests copying lib\tests\test.py -> build\lib.win32-2.6\pywcs\tests copying lib\tests\__init__.py -> build\lib.win32-2.6\pywcs\tests running build_ext building 'pywcs._pywcs' extension creating build\temp.win32-2.6 creating build\temp.win32-2.6\Release creating build\temp.win32-2.6\Release\wcslib creating build\temp.win32-2.6\Release\wcslib\C creating build\temp.win32-2.6\Release\wcslib\C\flexed creating build\temp.win32-2.6\Release\src c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DECHO -DWCSTRIG_MACRO -DPYWCS_BUILD -D_GNU_SOURCE -DNDEBUG -DYY_NO_UNISTD_H -D_CRT_SECURE_NO_WARNINGS -UDEBUG -IC:\Python26\lib\site- packages\numpy\core\include -I.\wcslib\C -Iwcslib\C -I.\src -IC:\Python26\include -IC:\Python26\PC /Tcwcslib\C\flexed/wcsbth.c /Fobuild\temp.win32-2.6\Release\wcslib\C\flexed/wcsbth.obj wcsbth.c .\wcslib\C\wcs.h(1396) : warning C4030: first formal parameter list longer than the second list .\wcslib\C\wcs.h(1396) : warning C4028: formal parameter 1 different from declaration .\wcslib\C\wcs.h(1396) : error C2040: 'wcsset' : 'int (wcsprm *)' differs in levels of indirection from 'int (wcsprm *)' error: command '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2 C:\Documents and Settings\jim.vickroy\My Documents\$downloads\languages\Python\pywcs-1.10-4.7> Thanks, -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: From rahpatel at ic.sunysb.edu Thu Dec 22 22:49:24 2011 From: rahpatel at ic.sunysb.edu (Rahul Patel) Date: Thu, 22 Dec 2011 22:49:24 -0500 Subject: [AstroPy] PyWCS build failure on Windows 7 EPD -Similar Message-ID: This is similar to a post back on Apr 4 2011, about problems with PyWCS failing to build on win 7 with EPD. The difference is I'm using Python 2.6.6 , EPD 6.3-2 (32-bit). I saw the patch you provided the previous user, but am unsure if that applies to my situation or how I would actually apply it. When I type and run "run setup.py install" in IPython, in the directory "C:\Python26\pywcs-1.10-4.7\" I get the following: run setup.py install running install running build running build_py copying lib\svn_version.py -> build\lib.win32-2.6\pywcs running build_ext building 'pywcs._pywcs' extension C:\Python26\Lib\Scripts\gcc.exe -mno-cygwin -mdll -O -Wall -DECHO -DWCSTRIG_MACRO -DPYWCS_BUILD -D_GNU_SOURCE -DNDEBUG -DYY_NO_UNISTD_H -D_CRT_SECURE_NO_WARNIN S -UDEBUG -IC:\Python26\Lib\lib\site-packages\numpy\core\include -I.\wcslib\C -Iwcslib\C -I.\src -IC:\Python26\Lib\include -IC:\Python26\Lib\PC -c wcslib\C\fle ed/wcsbth.c -o build\temp.win32-2.6\Release\wcslib\c\flexed\wcsbth.o In file included from wcsbth.l:118:0: .\wcslib\C/wcs.h:1396:5: error: conflicting types for 'wcsset' c:/python26/lib/egg-info/mingw/usr/lib/gcc/../../i686-w64-mingw32/include/string.h:161:20: note: previous declaration of 'wcsset' was here wcsbth.l: In function 'wcsbth': wcsbth.l:2081:1: warning: statement with no effect wcsbth.l: At top level: wcsbth.c:19886:16: warning: 'input' defined but not used BaseException.message has been deprecated as of Python 2.6 --------------------------------------------------------------------------- SystemExit Traceback (most recent call last) C:\Python26\pywcs-1.10-4.7\setup.py in () 23 pytools_version = None 24 ---> 25 H.run(pytools_version = pytools_version) 26 27 C:\Python26\pywcs-1.10-4.7\stsci_distutils_hack.pyc in run(pytools_version) 102 packages = pkg, 103 --> 104 **setupargs 105 106 ) C:\Python26\Lib\lib\distutils\core.pyc in setup(**attrs) 167 raise 168 else: --> 169 raise SystemExit, "error: " + str(msg) 170 171 return dist SystemExit: error: command 'gcc' failed with exit status 1 WARNING: Failure executing file: Thank you very much Rahul. -------------- next part -------------- An HTML attachment was scrubbed... URL: From J.P.Terlouw at astro.rug.nl Fri Dec 23 05:24:04 2011 From: J.P.Terlouw at astro.rug.nl (Hans Terlouw) Date: Fri, 23 Dec 2011 11:24:04 +0100 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: References: Message-ID: <4EF456C4.5000308@astro.rug.nl> On 12/23/2011 12:34 AM, Jim Vickroy wrote: > My Python version is: '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 > bit (Intel)]' and numpy.__version__ is: '1.6.1' > > Here is the output from my installation attempt: > > C:\Documents and Settings\jim.vickroy\My > Documents\$downloads\languages\Python\pywcs\pywcs-1.10-4.7>setup.py install > running install > running build > running build_py > creating build > creating build\lib.win32-2.6 > creating build\lib.win32-2.6\pywcs > copying lib\pywcs.py -> build\lib.win32-2.6\pywcs > copying lib\svn_version.py -> build\lib.win32-2.6\pywcs > copying lib\_docutil.py -> build\lib.win32-2.6\pywcs > copying lib\__init__.py -> build\lib.win32-2.6\pywcs > creating build\lib.win32-2.6\pywcs\tests > copying lib\tests\test.py -> build\lib.win32-2.6\pywcs\tests > copying lib\tests\__init__.py -> build\lib.win32-2.6\pywcs\tests > running build_ext > building 'pywcs._pywcs' extension > creating build\temp.win32-2.6 > creating build\temp.win32-2.6\Release > creating build\temp.win32-2.6\Release\wcslib > creating build\temp.win32-2.6\Release\wcslib\C > creating build\temp.win32-2.6\Release\wcslib\C\flexed > creating build\temp.win32-2.6\Release\src > c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD > /W3 /GS- /DNDEBUG -DECHO -DWCSTRIG_MACRO -DPYWCS_BUILD -D_GNU_SOURCE -DNDEBUG > -DYY_NO_UNISTD_H -D_CRT_SECURE_NO_WARNINGS -UDEBUG -IC:\Python26\lib\site- > packages\numpy\core\include -I.\wcslib\C -Iwcslib\C -I.\src > -IC:\Python26\include -IC:\Python26\PC /Tcwcslib\C\flexed/wcsbth.c > /Fobuild\temp.win32-2.6\Release\wcslib\C\flexed/wcsbth.obj > wcsbth.c > .\wcslib\C\wcs.h(1396) : warning C4030: first formal parameter list longer than > the second list > .\wcslib\C\wcs.h(1396) : warning C4028: formal parameter 1 different from > declaration > .\wcslib\C\wcs.h(1396) : error C2040: 'wcsset' : 'int (wcsprm *)' differs in > levels of indirection from 'int (wcsprm *)' > error: command '"c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' > failed with exit status 2 In a different context (the Kapteyn Package) I have also encountered this problem. It is caused by the declaration of the (since 2005 deprecated) POSIX function wcsset() in Visual Studio's string.h. In Unix and Linux environments this declaration is absent so there the problem doesn't occur. In my case I solved it by editing string.h in Notepad to change all strings "wcsset" into "XwcsXsetX". I am aware that others may dislike this (don't _ever_ change a "system" file!) but for me its works. Hans Terlouw From jim.vickroy at noaa.gov Fri Dec 23 11:48:39 2011 From: jim.vickroy at noaa.gov (Jim Vickroy) Date: Fri, 23 Dec 2011 09:48:39 -0700 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: <4EF456C4.5000308@astro.rug.nl> References: <4EF456C4.5000308@astro.rug.nl> Message-ID: On Fri, Dec 23, 2011 at 3:24 AM, Hans Terlouw wrote: > On 12/23/2011 12:34 AM, Jim Vickroy wrote: > > My Python version is: '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC > v.1500 32 > > bit (Intel)]' and numpy.__version__ is: '1.6.1' > > > > Here is the output from my installation attempt: > > > > C:\Documents and Settings\jim.vickroy\My > > Documents\$downloads\languages\Python\pywcs\pywcs-1.10-4.7>setup.py > install > > running install > > running build > > running build_py > > creating build > > creating build\lib.win32-2.6 > > creating build\lib.win32-2.6\pywcs > > copying lib\pywcs.py -> build\lib.win32-2.6\pywcs > > copying lib\svn_version.py -> build\lib.win32-2.6\pywcs > > copying lib\_docutil.py -> build\lib.win32-2.6\pywcs > > copying lib\__init__.py -> build\lib.win32-2.6\pywcs > > creating build\lib.win32-2.6\pywcs\tests > > copying lib\tests\test.py -> build\lib.win32-2.6\pywcs\tests > > copying lib\tests\__init__.py -> build\lib.win32-2.6\pywcs\tests > > running build_ext > > building 'pywcs._pywcs' extension > > creating build\temp.win32-2.6 > > creating build\temp.win32-2.6\Release > > creating build\temp.win32-2.6\Release\wcslib > > creating build\temp.win32-2.6\Release\wcslib\C > > creating build\temp.win32-2.6\Release\wcslib\C\flexed > > creating build\temp.win32-2.6\Release\src > > c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo > /Ox /MD > > /W3 /GS- /DNDEBUG -DECHO -DWCSTRIG_MACRO -DPYWCS_BUILD -D_GNU_SOURCE > -DNDEBUG > > -DYY_NO_UNISTD_H -D_CRT_SECURE_NO_WARNINGS -UDEBUG > -IC:\Python26\lib\site- > > packages\numpy\core\include -I.\wcslib\C -Iwcslib\C -I.\src > > -IC:\Python26\include -IC:\Python26\PC /Tcwcslib\C\flexed/wcsbth.c > > /Fobuild\temp.win32-2.6\Release\wcslib\C\flexed/wcsbth.obj > > wcsbth.c > > .\wcslib\C\wcs.h(1396) : warning C4030: first formal parameter list > longer than > > the second list > > .\wcslib\C\wcs.h(1396) : warning C4028: formal parameter 1 different from > > declaration > > .\wcslib\C\wcs.h(1396) : error C2040: 'wcsset' : 'int (wcsprm *)' > differs in > > levels of indirection from 'int (wcsprm *)' > > error: command '"c:\Program Files\Microsoft Visual Studio > 9.0\VC\BIN\cl.exe"' > > failed with exit status 2 > > In a different context (the Kapteyn Package) I have also encountered this > problem. It is caused by the declaration of the (since 2005 deprecated) > POSIX > function wcsset() in Visual Studio's string.h. In Unix and Linux > environments > this declaration is absent so there the problem doesn't occur. In my case I > solved it by editing string.h in Notepad to change all strings "wcsset" > into > "XwcsXsetX". I am aware that others may dislike this (don't _ever_ change a > "system" file!) but for me its works. > > Hans Terlouw > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > Thanks for this information. I did a search of my computer for string.h and there are 5 instances (all are associated with Visual Studio in some capacity ... mobile devices, etc.). I think I'll be conservative here and not change string.h. It would be nice if pywcs would work on MS Windows. It is advertised to, but I have never been able to get it to install. -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: From rahpatel at ic.sunysb.edu Sun Dec 25 11:29:01 2011 From: rahpatel at ic.sunysb.edu (Rahul Patel) Date: Sun, 25 Dec 2011 11:29:01 -0500 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: References: <4EF456C4.5000308@astro.rug.nl> Message-ID: Ya.... I'm not really comfortable with commenting or changing that out.I really wish there were some way for this to work. -Rahul On Fri, Dec 23, 2011 at 11:48 AM, Jim Vickroy wrote: > > > On Fri, Dec 23, 2011 at 3:24 AM, Hans Terlouw wrote: > >> On 12/23/2011 12:34 AM, Jim Vickroy wrote: >> > My Python version is: '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC >> v.1500 32 >> > bit (Intel)]' and numpy.__version__ is: '1.6.1' >> > >> > Here is the output from my installation attempt: >> > >> > C:\Documents and Settings\jim.vickroy\My >> > Documents\$downloads\languages\Python\pywcs\pywcs-1.10-4.7>setup.py >> install >> > running install >> > running build >> > running build_py >> > creating build >> > creating build\lib.win32-2.6 >> > creating build\lib.win32-2.6\pywcs >> > copying lib\pywcs.py -> build\lib.win32-2.6\pywcs >> > copying lib\svn_version.py -> build\lib.win32-2.6\pywcs >> > copying lib\_docutil.py -> build\lib.win32-2.6\pywcs >> > copying lib\__init__.py -> build\lib.win32-2.6\pywcs >> > creating build\lib.win32-2.6\pywcs\tests >> > copying lib\tests\test.py -> build\lib.win32-2.6\pywcs\tests >> > copying lib\tests\__init__.py -> build\lib.win32-2.6\pywcs\tests >> > running build_ext >> > building 'pywcs._pywcs' extension >> > creating build\temp.win32-2.6 >> > creating build\temp.win32-2.6\Release >> > creating build\temp.win32-2.6\Release\wcslib >> > creating build\temp.win32-2.6\Release\wcslib\C >> > creating build\temp.win32-2.6\Release\wcslib\C\flexed >> > creating build\temp.win32-2.6\Release\src >> > c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo >> /Ox /MD >> > /W3 /GS- /DNDEBUG -DECHO -DWCSTRIG_MACRO -DPYWCS_BUILD -D_GNU_SOURCE >> -DNDEBUG >> > -DYY_NO_UNISTD_H -D_CRT_SECURE_NO_WARNINGS -UDEBUG >> -IC:\Python26\lib\site- >> > packages\numpy\core\include -I.\wcslib\C -Iwcslib\C -I.\src >> > -IC:\Python26\include -IC:\Python26\PC /Tcwcslib\C\flexed/wcsbth.c >> > /Fobuild\temp.win32-2.6\Release\wcslib\C\flexed/wcsbth.obj >> > wcsbth.c >> > .\wcslib\C\wcs.h(1396) : warning C4030: first formal parameter list >> longer than >> > the second list >> > .\wcslib\C\wcs.h(1396) : warning C4028: formal parameter 1 different >> from >> > declaration >> > .\wcslib\C\wcs.h(1396) : error C2040: 'wcsset' : 'int (wcsprm *)' >> differs in >> > levels of indirection from 'int (wcsprm *)' >> > error: command '"c:\Program Files\Microsoft Visual Studio >> 9.0\VC\BIN\cl.exe"' >> > failed with exit status 2 >> >> In a different context (the Kapteyn Package) I have also encountered this >> problem. It is caused by the declaration of the (since 2005 deprecated) >> POSIX >> function wcsset() in Visual Studio's string.h. In Unix and Linux >> environments >> this declaration is absent so there the problem doesn't occur. In my case >> I >> solved it by editing string.h in Notepad to change all strings "wcsset" >> into >> "XwcsXsetX". I am aware that others may dislike this (don't _ever_ change >> a >> "system" file!) but for me its works. >> >> Hans Terlouw >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> > > > Thanks for this information. > > I did a search of my computer for string.h and there are 5 instances (all > are associated with > Visual Studio in some capacity ... mobile devices, etc.). > > I think I'll be conservative here and not change string.h. > > It would be nice if pywcs would work on MS Windows. It is advertised to, > but I have never been able to get it to install. > > -- jv > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim.jenness at gmail.com Sun Dec 25 16:25:14 2011 From: tim.jenness at gmail.com (Tim Jenness) Date: Sun, 25 Dec 2011 11:25:14 -1000 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: References: <4EF456C4.5000308@astro.rug.nl> Message-ID: On Sun, Dec 25, 2011 at 6:29 AM, Rahul Patel wrote: > Ya.... I'm not really comfortable with commenting or changing that out.I > really wish there were some way for this to work. > The real fix is for pywcs to be modified so that it does not use a fucntion called wcsset() otherwise this clash is going to continue. -- Tim Jenness From tim.jenness at gmail.com Mon Dec 26 15:01:17 2011 From: tim.jenness at gmail.com (Tim Jenness) Date: Mon, 26 Dec 2011 10:01:17 -1000 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: References: <4EF456C4.5000308@astro.rug.nl> Message-ID: So looking into this further wcsset was deprecated by Microsoft in Visual C++ 2005 and replaced by _wcsset. The question is whether there is some C preprocessor define that can hide them. What do people do when they try to build wcslib itself on these systems? -- Tim Jenness On Sun, Dec 25, 2011 at 11:25 AM, Tim Jenness wrote: > On Sun, Dec 25, 2011 at 6:29 AM, Rahul Patel wrote: >> Ya.... I'm not really comfortable with commenting or changing that out.I >> really wish there were some way for this to work. >> > > The real fix is for pywcs to be modified so that it does not use a > fucntion called wcsset() otherwise this clash is going to continue. > > -- > Tim Jenness From sienkiew at stsci.edu Wed Dec 28 13:36:40 2011 From: sienkiew at stsci.edu (Mark Sienkiewicz) Date: Wed, 28 Dec 2011 13:36:40 -0500 Subject: [AstroPy] pywcs 1.10-4.7 install failure on Microsoft Windows In-Reply-To: References: <4EF456C4.5000308@astro.rug.nl> Message-ID: <4EFB61B8.3030406@stsci.edu> On 12/25/11 16:25, Tim Jenness wrote: > On Sun, Dec 25, 2011 at 6:29 AM, Rahul Patel wrote: >> Ya.... I'm not really comfortable with commenting or changing that out.I >> really wish there were some way for this to work. >> > The real fix is for pywcs to be modified so that it does not use a > fucntion called wcsset() otherwise this clash is going to continue. > The problem is actually in the C code for wcslib, the library that pywcs is based on. wcslib defines a function named wcsset (see pywcs/wcslib/C/wcs.c). I seem to remember Mike Droettboom telling me that he has to patch wcslib every time he incorporates a new version into pywcs. If you are in a hurry to make pywcs work, I can suggest either a hack around the problem (as has been discussed) or use an earlier version of pywcs from before the integration of wcslib-4.8 began. I seem to remember that the pywcs that was include in STSCI_PYTHON 2.12 compiled on Windows. You can download source code for stsci_python from http://www.stsci.edu/resources/software_hardware/stsci_python/current/download and then install only the pywcs package instead of the entire distribution. Just "cd pywcs ; python setup.py install". If it is not urgent, Mike can probably give you a more satisfactory solution when he comes back from the holidays. Mark S. From kuiper at jpl.nasa.gov Thu Dec 29 13:16:07 2011 From: kuiper at jpl.nasa.gov (Tom Kuiper) Date: Thu, 29 Dec 2011 10:16:07 -0800 Subject: [AstroPy] Reading JPL ephemeris files on 64-bit architecture Message-ID: <4EFCAE67.8070703@jpl.nasa.gov> I'm trying to get pynovas to work under Linux-AMD64 and have run into a problem reading the JPL ephemeris file. I encountered this previously with Rick Fisher's jplephem but I think I have more of an insight now. The problem, I think, lies in this structure in ephem_types.h: struct recOneData { /* storage on disk: */ char label[3][84]; /* 3*84 = 252 bytes = 31.5 words */ char constName[400][6]; /* 400*6 = 2400 = 300 words */ double timeData[3]; /* 3*8 = 24 = 3 words */ int numConst; /* 1*4 = 4 = 0.5 words, 32-bit long */ double AU; /* 1*8 = 8 = 1 words */ double EMRAT; /* 1*8 = 8 = 1 words */ int coeffPtr[12][3]; /* 12*3*4 = 144 = 18 words, 32-bit longs */ int DENUM; /* 1*4 = 4 = 0.5 words, 32-bit long */ int libratPtr[3]; /* 3*4 = 12 = 1.5 words, 32-bit long */ /* = 2856 bytes = 357 words */ }; I've annotated the original code. Also, the original 32-bit code had longs instead of ints. Changing them to ints made no difference. The first int, numConst, comes out the same (wrong value) either way. I've verified this structure using the Python struct module. The question: is there a way in C to ignore the fact that this structure doesn't respect 64-bit word boundaries? I've considered using union but that would involve a lot of code changes, wherever this structure is used. One solution to all this is, I suppose, to use bin2asc (after downloading and re-compiling the JPL ephemeris C source code) and generate a new ASCII data file for 64-bit machines. I will if I have to but it seems more elegant to use the ephemeris binary files as they are given. Any suggestions? Thanks and regards, Tom -- I or me? http://www.oxforddictionaries.com/page/145 From sienkiew at stsci.edu Fri Dec 30 11:08:24 2011 From: sienkiew at stsci.edu (Mark Sienkiewicz) Date: Fri, 30 Dec 2011 11:08:24 -0500 Subject: [AstroPy] Reading JPL ephemeris files on 64-bit architecture In-Reply-To: <4EFCAE67.8070703@jpl.nasa.gov> References: <4EFCAE67.8070703@jpl.nasa.gov> Message-ID: <4EFDE1F8.9050004@stsci.edu> On 12/29/11 13:16, Tom Kuiper wrote: > The question: > is there a way in C to ignore the fact that this structure doesn't > respect 64-bit word boundaries? Many C compilers have some way to say how to pack structs. If you are using gcc, you might try #pragma pack to declare that you want the struct packed on a 4 byte boundary. Here is an example using the struct that I copied out of your email: /* * this pragma means that we should start aligning struct elements on a 4 byte boundary. */ #pragma pack(push,4) struct recOneData { /* storage on disk: */ char label[3][84]; /* 3*84 = 252 bytes = 31.5 words */ char constName[400][6]; /* 400*6 = 2400 = 300 words */ double timeData[3]; /* 3*8 = 24 = 3 words */ int numConst; /* 1*4 = 4 = 0.5 words, 32-bit long */ double AU; /* 1*8 = 8 = 1 words */ double EMRAT; /* 1*8 = 8 = 1 words */ int coeffPtr[12][3]; /* 12*3*4 = 144 = 18 words, 32-bit longs */ int DENUM; /* 1*4 = 4 = 0.5 words, 32-bit long */ int libratPtr[3]; /* 3*4 = 12 = 1.5 words, 32-bit long */ /* = 2856 bytes = 357 words */ }; /* * this means to go back to the previous alignment. This is important * in case there are other structs declared somewhere. Notably, if * you change the packing and then include another include file, you * might find that the structs are aligned one way in a.c and another * in b.c */ #pragma pack(pop) /* sample struct for demo purposes */ struct foo { char a[11]; double b; }; /* a main that prints the offsets of the fields in the structs */ #include int main (int argc, char *argv[]) { struct recOneData r; struct foo f; printf("\nr\nSIZE: %d\n",(int)sizeof(r)); #define OFF(r,x) printf("%-10s %d\n",#x,(int)(((void*)&r.x) - ((void*)&r)) ); OFF(r,label) OFF(r,constName) OFF(r,timeData) OFF(r,numConst) OFF(r,AU) OFF(r,EMRAT) OFF(r,coeffPtr) OFF(r,DENUM) OFF(r,libratPtr) printf("\nf\nSIZE: %d\n",(int)sizeof(f)); OFF(f,a) OFF(f,b) } Without the pragma pack, I get sizes of 2864 and 24. With the pragmas, I get 2856 and 24. So, I've made recOneData into a different size, without affecting foo. If I remove only the #pragma pack(pop), the remaining pack(4) affects the other struct, which you don't want. In this example, it looks harmless, but get dozens of source files, include files, system include files, and shared libraries involved, and you have plenty of opportunity to get something aligned inconsistently somewhere. If you use the example as I showed it above, it only affects the one struct that you intend to affect. I included this whole program so you can experiment with the pragmas. Also, try it with "gcc -m32 c.c" to compile a 32 bit executable. The 32 bit executable has the same struct alignments whether you use the pragma or not, because the default alignment is 4 bytes. Mark S.