From dfb at mrao.cam.ac.uk Fri Mar 1 05:59:11 2013 From: dfb at mrao.cam.ac.uk (David Buscher) Date: Fri, 1 Mar 2013 10:59:11 +0000 Subject: [AstroPy] Indexing table rows Message-ID: It appears that the astropy.tables module does not accept the same row indexing syntax as the corresponding ndarray, particularly the syntax output by np.where(), which is a tuple containing an ndarray. Example below: Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 12 2012, 11:14:05) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "credits", "demo" or "enthought" for more information. >>> import numpy as np >>> from astropy.table import Table >>> t=Table(np.reshape(np.arange(12),(4,3))) >>> print t col0 col1 col2 ---- ---- ---- 0 1 2 3 4 5 6 7 8 9 10 11 >>> rows=np.where(t["col0"]>5) >>> print rows (array([2, 3]),) # ndarray version >>> print np.array(t)[rows] [(6, 7, 8) (9, 10, 11)] # Tables version >>> print t[rows[0]] col0 col1 col2 ---- ---- ---- 6 7 8 9 10 11 >>> print t[rows] ERROR: TypeError: unhashable type: 'numpy.ndarray' [astropy.table.table] Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", line 1282, in __getitem__ if any(x not in set(self.colnames) for x in item): File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", line 1282, in if any(x not in set(self.colnames) for x in item): TypeError: unhashable type: 'numpy.ndarray' I am using astropy version 0.2. Is this behaviour on purpose or a bug? It can be worked around by taking the first element of the indexing tuple as above, but it seems counterintuitive that the output of np.where() cannot be used directly to select table rows. David From aldcroft at head.cfa.harvard.edu Fri Mar 1 07:08:38 2013 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Fri, 1 Mar 2013 07:08:38 -0500 Subject: [AstroPy] Indexing table rows In-Reply-To: References: Message-ID: Hi David, Thanks for reporting this issue. This is a bug and is now tracked at https://github.com/astropy/astropy/issues/838 This should be fixed in the 0.2.1 release scheduled for early April. Cheers, Tom On Fri, Mar 1, 2013 at 5:59 AM, David Buscher wrote: > It appears that the astropy.tables module does not accept the same row > indexing syntax as the corresponding ndarray, particularly the syntax > output by np.where(), which is a tuple containing an ndarray. Example > below: > > Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 12 2012, 11:14:05) > [GCC 4.0.1 (Apple Inc. build 5493)] on darwin > Type "credits", "demo" or "enthought" for more information. >>>> import numpy as np >>>> from astropy.table import Table > >>>> t=Table(np.reshape(np.arange(12),(4,3))) >>>> print t > col0 col1 col2 > ---- ---- ---- > 0 1 2 > 3 4 5 > 6 7 8 > 9 10 11 > >>>> rows=np.where(t["col0"]>5) >>>> print rows > (array([2, 3]),) > > # ndarray version >>>> print np.array(t)[rows] > [(6, 7, 8) (9, 10, 11)] > > # Tables version >>>> print t[rows[0]] > col0 col1 col2 > ---- ---- ---- > 6 7 8 > 9 10 11 > >>>> print t[rows] > ERROR: TypeError: unhashable type: 'numpy.ndarray' [astropy.table.table] > Traceback (most recent call last): > File "", line 1, in > File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", > line 1282, in __getitem__ > if any(x not in set(self.colnames) for x in item): > File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", > line 1282, in > if any(x not in set(self.colnames) for x in item): > TypeError: unhashable type: 'numpy.ndarray' > > I am using astropy version 0.2. Is this behaviour on purpose or a bug? > It can be worked around by taking the first element of the indexing > tuple as above, but it seems counterintuitive that the output of > np.where() cannot be used directly to select table rows. > > David > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From aldcroft at head.cfa.harvard.edu Fri Mar 1 07:56:27 2013 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Fri, 1 Mar 2013 07:56:27 -0500 Subject: [AstroPy] Indexing table rows In-Reply-To: References: Message-ID: I forgot to mention that an alternate workaround is to use boolean masking: >>> t = Table(np.reshape(np.arange(12),(4,3))) >>> ok = t['col0'] > 5 >>> print t[ok] col0 col1 col2 ---- ---- ---- 6 7 8 9 10 11 Cheers, Tom On Fri, Mar 1, 2013 at 7:08 AM, Tom Aldcroft wrote: > Hi David, > > Thanks for reporting this issue. This is a bug and is now tracked at > https://github.com/astropy/astropy/issues/838 > > This should be fixed in the 0.2.1 release scheduled for early April. > > Cheers, > Tom > > On Fri, Mar 1, 2013 at 5:59 AM, David Buscher wrote: >> It appears that the astropy.tables module does not accept the same row >> indexing syntax as the corresponding ndarray, particularly the syntax >> output by np.where(), which is a tuple containing an ndarray. Example >> below: >> >> Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 12 2012, 11:14:05) >> [GCC 4.0.1 (Apple Inc. build 5493)] on darwin >> Type "credits", "demo" or "enthought" for more information. >>>>> import numpy as np >>>>> from astropy.table import Table >> >>>>> t=Table(np.reshape(np.arange(12),(4,3))) >>>>> print t >> col0 col1 col2 >> ---- ---- ---- >> 0 1 2 >> 3 4 5 >> 6 7 8 >> 9 10 11 >> >>>>> rows=np.where(t["col0"]>5) >>>>> print rows >> (array([2, 3]),) >> >> # ndarray version >>>>> print np.array(t)[rows] >> [(6, 7, 8) (9, 10, 11)] >> >> # Tables version >>>>> print t[rows[0]] >> col0 col1 col2 >> ---- ---- ---- >> 6 7 8 >> 9 10 11 >> >>>>> print t[rows] >> ERROR: TypeError: unhashable type: 'numpy.ndarray' [astropy.table.table] >> Traceback (most recent call last): >> File "", line 1, in >> File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", >> line 1282, in __getitem__ >> if any(x not in set(self.colnames) for x in item): >> File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", >> line 1282, in >> if any(x not in set(self.colnames) for x in item): >> TypeError: unhashable type: 'numpy.ndarray' >> >> I am using astropy version 0.2. Is this behaviour on purpose or a bug? >> It can be worked around by taking the first element of the indexing >> tuple as above, but it seems counterintuitive that the output of >> np.where() cannot be used directly to select table rows. >> >> David >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy >> From dfb at mrao.cam.ac.uk Fri Mar 1 09:06:45 2013 From: dfb at mrao.cam.ac.uk (David Buscher) Date: Fri, 1 Mar 2013 14:06:45 +0000 Subject: [AstroPy] Indexing table rows In-Reply-To: References: Message-ID: Thanks for the quick response. In fact boolean indexing is a better solution in my case, I just was not aware that I could do it... David On Fri, Mar 1, 2013 at 12:56 PM, Tom Aldcroft wrote: > I forgot to mention that an alternate workaround is to use boolean masking: > >>>> t = Table(np.reshape(np.arange(12),(4,3))) >>>> ok = t['col0'] > 5 >>>> print t[ok] > col0 col1 col2 > ---- ---- ---- > 6 7 8 > 9 10 11 > > Cheers, > Tom > > On Fri, Mar 1, 2013 at 7:08 AM, Tom Aldcroft > wrote: >> Hi David, >> >> Thanks for reporting this issue. This is a bug and is now tracked at >> https://github.com/astropy/astropy/issues/838 >> >> This should be fixed in the 0.2.1 release scheduled for early April. >> >> Cheers, >> Tom >> >> On Fri, Mar 1, 2013 at 5:59 AM, David Buscher wrote: >>> It appears that the astropy.tables module does not accept the same row >>> indexing syntax as the corresponding ndarray, particularly the syntax >>> output by np.where(), which is a tuple containing an ndarray. Example >>> below: >>> >>> Python 2.7.3 |EPD 7.3-1 (64-bit)| (default, Apr 12 2012, 11:14:05) >>> [GCC 4.0.1 (Apple Inc. build 5493)] on darwin >>> Type "credits", "demo" or "enthought" for more information. >>>>>> import numpy as np >>>>>> from astropy.table import Table >>> >>>>>> t=Table(np.reshape(np.arange(12),(4,3))) >>>>>> print t >>> col0 col1 col2 >>> ---- ---- ---- >>> 0 1 2 >>> 3 4 5 >>> 6 7 8 >>> 9 10 11 >>> >>>>>> rows=np.where(t["col0"]>5) >>>>>> print rows >>> (array([2, 3]),) >>> >>> # ndarray version >>>>>> print np.array(t)[rows] >>> [(6, 7, 8) (9, 10, 11)] >>> >>> # Tables version >>>>>> print t[rows[0]] >>> col0 col1 col2 >>> ---- ---- ---- >>> 6 7 8 >>> 9 10 11 >>> >>>>>> print t[rows] >>> ERROR: TypeError: unhashable type: 'numpy.ndarray' [astropy.table.table] >>> Traceback (most recent call last): >>> File "", line 1, in >>> File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", >>> line 1282, in __getitem__ >>> if any(x not in set(self.colnames) for x in item): >>> File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/astropy/table/table.py", >>> line 1282, in >>> if any(x not in set(self.colnames) for x in item): >>> TypeError: unhashable type: 'numpy.ndarray' >>> >>> I am using astropy version 0.2. Is this behaviour on purpose or a bug? >>> It can be worked around by taking the first element of the indexing >>> tuple as above, but it seems counterintuitive that the output of >>> np.where() cannot be used directly to select table rows. >>> >>> David >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >>> From jzuhone at gmail.com Fri Mar 1 12:18:35 2013 From: jzuhone at gmail.com (John ZuHone) Date: Fri, 1 Mar 2013 12:18:35 -0500 Subject: [AstroPy] Announcing the release of yt 2.5! Message-ID: <3ED3883B-7B8D-4E07-8EA1-82791A4ED040@gmail.com> Dear Colleagues, We?re proud to announce the release of version 2.5 of the yt Project, http://yt-project.org/. The new version includes many new features, refinements of existing features and numerous bugfixes. We encourage all users to upgrade to take advantage of the changes. yt is a community-developed analysis and visualization toolkit, primarily directed at astrophysical hydrodynamics simulations. It provides full support for output from the Enzo, FLASH, Orion, and Nyx codes, with preliminary support for several others. It provides access to simulation data using an intuitive python interface, can perform many common visualization tasks, and offers a framework for conducting data reductions and analysis of simulation data. The most visible changes with the 2.5 release include: * Testing has been greatly expanded, including unit tests and answer testing. * The capabilities of the ?Stream? frontend have been expanded. Uniform grid and AMR-based data can be read into memory, and particle fields can be initialized. * The install script now provides for the optional installation of SciPy and the Rockstar halo finder. * Surfaces can now be extracted and examined, as well as uploaded to Sketchfab.com for interactive visualization in a web browser. * Support for the Athena code has been added. * Many, many improvements to PlotWindow. * Coordinate transformations have been sped up and streamlined, as well as cylindrical and spherical fields. * Increased support for the IPython notebook. * Improved support for FLASH particle fields. * The volume rendering backend has been updated to use an alpha channel, fixing parallel opaque volume renderings. * The AMRKDTree has been rewritten, allowing parallelism with other than power-of-2 MPI processes, arbitrary sets of grids, and splitting of unigrids. For a complete list of changes in this release, please visit the Changelog (http://yt-project.org/docs/2.5/changelog.html). Information about the yt project, including installation instructions, can be found on the homepage: http://yt-project.org/ Development of yt has been sponsored by the NSF, the DOE, and various universities. We develop yt in the open and encourage contributions from users who extend and improve the code. We invite you to get involved with developing and using yt! Please forward this announcement to other interested parties. Sincerely, The yt development team From susanasanche at gmail.com Mon Mar 4 06:43:20 2013 From: susanasanche at gmail.com (Susana Sanchez) Date: Mon, 4 Mar 2013 12:43:20 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? Message-ID: Hello all, How can I create a VOtable from a list (a python list) of rows using astropy? Reading the documentation, I found the method "from_table" of the class VOTableFile, this method needs as argument an instance of the class astropy.table.table.Table, so I did the following: t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) votable = VOTableFile() votable.from_table(t) But here I got this error: /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, keep_mask, hard_mask, shrink, **options) 2692 # Or assume it's a sequence of bool/int 2693 except TypeError: -> 2694 mask = np.array([tuple([m] * len(mdtype)) for m in mask], 2695 dtype=mdtype) 2696 # Make sure the mask and the data have the same shape TypeError: 'NoneType' object is not iterable Reading the error message, I thought it could be related with the mask, so I tried to create the mask of the table t (with the method t.create_mask()), and then to build the VOTableFile from this table, but I got the same error. I would be very gratefully, If anyone can help me or give me any hint. Thanks, Susana. From mdroe at stsci.edu Wed Mar 6 09:08:41 2013 From: mdroe at stsci.edu (Michael Droettboom) Date: Wed, 6 Mar 2013 09:08:41 -0500 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: References: Message-ID: <51374DE9.5050006@stsci.edu> The general approach you're taking here -- to create a Table and then convert it to a VOTable -- is the right one here. The Table class has a much richer set of things it can convert to and from (it's sort of our "hub" class for everything that's table like). However, I don't believe it supports construction from a list in the way you're trying. There is a doc page about constructing a table here, that may be helpful: https://astropy.readthedocs.org/en/v0.2/table/construct_table.html That said, I tried to convert your example to the form where the Table is constructed from a Numpy structured array, and still ran into the same exception: from astropy import table from astropy.io import votable import numpy as np x = np.array( [("CIG12",1.2345,0,2,999,"COMMENT"), ("CIG122",1.23452,0,2,9992,"COMMENT2")], dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), ('f', str)]) print x.dtype t = table.Table(x) votable = votable.tree.VOTableFile.from_table(t) So maybe we're both still doing something wrong. I've Cc'd Tom Aldcroft, the primary author of the Table class, as he might have more insight. Mike On 03/04/2013 06:43 AM, Susana Sanchez wrote: > Hello all, > > How can I create a VOtable from a list (a python list) of rows using astropy? > > Reading the documentation, I found the method "from_table" of the > class VOTableFile, this method needs as argument an instance of the > class astropy.table.table.Table, so I did the following: > > t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) > votable = VOTableFile() > votable.from_table(t) > > > But here I got this error: > > /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in > __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, > keep_mask, hard_mask, shrink, **options) > 2692 # Or assume it's a sequence of bool/int > > 2693 except TypeError: > -> 2694 mask = np.array([tuple([m] * len(mdtype)) for > m in mask], > 2695 dtype=mdtype) > 2696 # Make sure the mask and the data have the same shape > > TypeError: 'NoneType' object is not iterable > > > Reading the error message, I thought it could be related with the > mask, so I tried to create the mask of the table t (with the method > t.create_mask()), and then to build the VOTableFile from this table, > but I got the same error. > > I would be very gratefully, If anyone can help me or give me any hint. > > Thanks, > Susana. > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From marquett at iap.fr Wed Mar 6 09:28:44 2013 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Wed, 6 Mar 2013 15:28:44 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: <51374DE9.5050006@stsci.edu> References: <51374DE9.5050006@stsci.edu> Message-ID: <1B5131CB-E186-4C5B-B5AF-29263BE54EC0@iap.fr> Hi all, May I suggest to have a look at ATpy, where VOTable are natively recognized: http://atpy.github.com/ ? BTW, I would be very grateful if both AstroPy and ATpy could merge? Cheers, Jean-Baptiste Le 6 mars 2013 ? 15:08, Michael Droettboom a ?crit : > The general approach you're taking here -- to create a Table and then > convert it to a VOTable -- is the right one here. The Table class has a > much richer set of things it can convert to and from (it's sort of our > "hub" class for everything that's table like). > > However, I don't believe it supports construction from a list in the way > you're trying. There is a doc page about constructing a table here, > that may be helpful: > > https://astropy.readthedocs.org/en/v0.2/table/construct_table.html > > That said, I tried to convert your example to the form where the Table > is constructed from a Numpy structured array, and still ran into the > same exception: > > from astropy import table > > from astropy.io import votable > > import numpy as np > > x = np.array( > > [("CIG12",1.2345,0,2,999,"COMMENT"), > > ("CIG122",1.23452,0,2,9992,"COMMENT2")], > > dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), ('f', str)]) > > print x.dtype > > t = table.Table(x) > > votable = votable.tree.VOTableFile.from_table(t) > > > So maybe we're both still doing something wrong. I've Cc'd Tom > Aldcroft, the primary author of the Table class, as he might have more > insight. > > Mike > > > On 03/04/2013 06:43 AM, Susana Sanchez wrote: >> Hello all, >> >> How can I create a VOtable from a list (a python list) of rows using astropy? >> >> Reading the documentation, I found the method "from_table" of the >> class VOTableFile, this method needs as argument an instance of the >> class astropy.table.table.Table, so I did the following: >> >> t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) >> votable = VOTableFile() >> votable.from_table(t) >> >> >> But here I got this error: >> >> /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in >> __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, >> keep_mask, hard_mask, shrink, **options) >> 2692 # Or assume it's a sequence of bool/int >> >> 2693 except TypeError: >> -> 2694 mask = np.array([tuple([m] * len(mdtype)) for >> m in mask], >> 2695 dtype=mdtype) >> 2696 # Make sure the mask and the data have the same shape >> >> TypeError: 'NoneType' object is not iterable >> >> >> Reading the error message, I thought it could be related with the >> mask, so I tried to create the mask of the table t (with the method >> t.create_mask()), and then to build the VOTableFile from this table, >> but I got the same error. >> >> I would be very gratefully, If anyone can help me or give me any hint. >> >> Thanks, >> Susana. >> _______________________________________________ >> 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 thomas.robitaille at gmail.com Wed Mar 6 10:57:10 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Wed, 6 Mar 2013 16:57:10 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: <1B5131CB-E186-4C5B-B5AF-29263BE54EC0@iap.fr> References: <51374DE9.5050006@stsci.edu> <1B5131CB-E186-4C5B-B5AF-29263BE54EC0@iap.fr> Message-ID: Hi Jean-Baptiste, Astropy actually already supports the same kind of file access to VO tables that ATpy does - if you have an Astropy Table object, you can do: t = Table(...) t.write('my_table.xml', format='votable') to read a VO table: t = Table.read('my_table.xml') (format should be auto-detected) We've been working on merging the ATpy functionality bit by bit (in fact astropy.table started from the base Table class in ATpy). Astropy can now be used as a full replacement to ATpy for VO tables, HDF5 tables, and ASCII tables. We will add support for FITS files, which leaves only the SQL as being ATpy-specific (whether this gets merged in future into Astropy remains to be decided). Cheers, Tom On 6 March 2013 15:28, Jean-Baptiste Marquette wrote: > Hi all, > > May I suggest to have a look at ATpy, where VOTable are natively recognized: > http://atpy.github.com/ ? > > BTW, I would be very grateful if both AstroPy and ATpy could merge? > > Cheers, > Jean-Baptiste > > Le 6 mars 2013 ? 15:08, Michael Droettboom a ?crit : > > The general approach you're taking here -- to create a Table and then > convert it to a VOTable -- is the right one here. The Table class has a > much richer set of things it can convert to and from (it's sort of our > "hub" class for everything that's table like). > > However, I don't believe it supports construction from a list in the way > you're trying. There is a doc page about constructing a table here, > that may be helpful: > > https://astropy.readthedocs.org/en/v0.2/table/construct_table.html > > That said, I tried to convert your example to the form where the Table > is constructed from a Numpy structured array, and still ran into the > same exception: > > from astropy import table > > from astropy.io import votable > > import numpy as np > > x = np.array( > > [("CIG12",1.2345,0,2,999,"COMMENT"), > > ("CIG122",1.23452,0,2,9992,"COMMENT2")], > > dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), > ('f', str)]) > > print x.dtype > > t = table.Table(x) > > votable = votable.tree.VOTableFile.from_table(t) > > > So maybe we're both still doing something wrong. I've Cc'd Tom > Aldcroft, the primary author of the Table class, as he might have more > insight. > > Mike > > > On 03/04/2013 06:43 AM, Susana Sanchez wrote: > > Hello all, > > > How can I create a VOtable from a list (a python list) of rows using > astropy? > > > Reading the documentation, I found the method "from_table" of the > > class VOTableFile, this method needs as argument an instance of the > > class astropy.table.table.Table, so I did the following: > > > t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) > > votable = VOTableFile() > > votable.from_table(t) > > > > But here I got this error: > > > /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in > > __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, > > keep_mask, hard_mask, shrink, **options) > > 2692 # Or assume it's a sequence of bool/int > > > 2693 except TypeError: > > -> 2694 mask = np.array([tuple([m] * len(mdtype)) for > > m in mask], > > 2695 dtype=mdtype) > > 2696 # Make sure the mask and the data have the same shape > > > TypeError: 'NoneType' object is not iterable > > > > Reading the error message, I thought it could be related with the > > mask, so I tried to create the mask of the table t (with the method > > t.create_mask()), and then to build the VOTableFile from this table, > > but I got the same error. > > > I would be very gratefully, If anyone can help me or give me any hint. > > > Thanks, > > Susana. > > _______________________________________________ > > 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 Mar 6 11:03:53 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Wed, 6 Mar 2013 17:03:53 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: <51374DE9.5050006@stsci.edu> References: <51374DE9.5050006@stsci.edu> Message-ID: Hi Susana and Mike, This looks like a bug to me - I've opened https://github.com/astropy/astropy/issues/849 Also, initializing from a list of tuples currently behaves the same as a list of lists: In [11]: t = Table([("CIG12",1.2345,0,2,999,"COMMENT"),("CIG122",1.23452,0,2,9992,"COMMENT2")]) In [12]: print(t) col0 col1 ------- -------- CIG12 CIG122 1.2345 1.23452 0 0 2 2 999 9992 COMMENT COMMENT2 but I think that to be consistent with Numpy, initializing from a list of tuples should create tables with each tuple being a row, which is what Susana wanted to do. Initializing from a list of lists should treat them as columns, as it does. Cheers, Tom On 6 March 2013 15:08, Michael Droettboom wrote: > The general approach you're taking here -- to create a Table and then > convert it to a VOTable -- is the right one here. The Table class has a > much richer set of things it can convert to and from (it's sort of our > "hub" class for everything that's table like). > > However, I don't believe it supports construction from a list in the way > you're trying. There is a doc page about constructing a table here, > that may be helpful: > > https://astropy.readthedocs.org/en/v0.2/table/construct_table.html > > That said, I tried to convert your example to the form where the Table > is constructed from a Numpy structured array, and still ran into the > same exception: > > from astropy import table > > from astropy.io import votable > > import numpy as np > > x = np.array( > > [("CIG12",1.2345,0,2,999,"COMMENT"), > > ("CIG122",1.23452,0,2,9992,"COMMENT2")], > > dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), ('f', str)]) > > print x.dtype > > t = table.Table(x) > > votable = votable.tree.VOTableFile.from_table(t) > > > So maybe we're both still doing something wrong. I've Cc'd Tom > Aldcroft, the primary author of the Table class, as he might have more > insight. > > Mike > > > On 03/04/2013 06:43 AM, Susana Sanchez wrote: >> Hello all, >> >> How can I create a VOtable from a list (a python list) of rows using astropy? >> >> Reading the documentation, I found the method "from_table" of the >> class VOTableFile, this method needs as argument an instance of the >> class astropy.table.table.Table, so I did the following: >> >> t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) >> votable = VOTableFile() >> votable.from_table(t) >> >> >> But here I got this error: >> >> /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in >> __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, >> keep_mask, hard_mask, shrink, **options) >> 2692 # Or assume it's a sequence of bool/int >> >> 2693 except TypeError: >> -> 2694 mask = np.array([tuple([m] * len(mdtype)) for >> m in mask], >> 2695 dtype=mdtype) >> 2696 # Make sure the mask and the data have the same shape >> >> TypeError: 'NoneType' object is not iterable >> >> >> Reading the error message, I thought it could be related with the >> mask, so I tried to create the mask of the table t (with the method >> t.create_mask()), and then to build the VOTableFile from this table, >> but I got the same error. >> >> I would be very gratefully, If anyone can help me or give me any hint. >> >> Thanks, >> Susana. >> _______________________________________________ >> 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 marquett at iap.fr Wed Mar 6 11:05:31 2013 From: marquett at iap.fr (Jean-Baptiste Marquette) Date: Wed, 6 Mar 2013 17:05:31 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: References: <51374DE9.5050006@stsci.edu> <1B5131CB-E186-4C5B-B5AF-29263BE54EC0@iap.fr> Message-ID: Hi Tom, > Astropy actually already supports the same kind of file access to VO > tables that ATpy does - if you have an Astropy Table object, you can > do: > > t = Table(...) > t.write('my_table.xml', format='votable') > > to read a VO table: > > t = Table.read('my_table.xml') > > (format should be auto-detected) > > We've been working on merging the ATpy functionality bit by bit (in > fact astropy.table started from the base Table class in ATpy). Astropy > can now be used as a full replacement to ATpy for VO tables, HDF5 > tables, and ASCII tables. We will add support for FITS files, which > leaves only the SQL as being ATpy-specific (whether this gets merged > in future into Astropy remains to be decided). Excellent news! I just implemented in my scripts some other functionalities from Astropy dealing with WCS and FITS, I must say this is really awesome? Cheers, JB -------------- next part -------------- An HTML attachment was scrubbed... URL: From aldcroft at head.cfa.harvard.edu Wed Mar 6 11:07:11 2013 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Wed, 6 Mar 2013 11:07:11 -0500 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: <51374DE9.5050006@stsci.edu> References: <51374DE9.5050006@stsci.edu> Message-ID: Sorry for the delay. For Susana, the hitch here is that you are supplying data as a list of data rows, but Table requires input as a list of data columns. The easiest way (I know) to get around this is to use np.rec.fromrecords: >>> dat_rows = [["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]] >>> dat_np = np.rec.fromrecords(dat_rows) # can also supply names=['col1', ...] for col names >>> dat = Table(dat_np) Referring to Tom Robitaille's later comment, I don't think this is a bug, but we can discuss in the new issue thread. More on that later. - Tom On Wed, Mar 6, 2013 at 9:08 AM, Michael Droettboom wrote: > The general approach you're taking here -- to create a Table and then > convert it to a VOTable -- is the right one here. The Table class has a > much richer set of things it can convert to and from (it's sort of our "hub" > class for everything that's table like). > > However, I don't believe it supports construction from a list in the way > you're trying. There is a doc page about constructing a table here, that > may be helpful: > > https://astropy.readthedocs.org/en/v0.2/table/construct_table.html > > That said, I tried to convert your example to the form where the Table is > constructed from a Numpy structured array, and still ran into the same > exception: > > from astropy import table > > from astropy.io import votable > > import numpy as np > > x = np.array( > > [("CIG12",1.2345,0,2,999,"COMMENT"), > > ("CIG122",1.23452,0,2,9992,"COMMENT2")], > > dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), > ('f', str)]) > > print x.dtype > > t = table.Table(x) > > votable = votable.tree.VOTableFile.from_table(t) > > > So maybe we're both still doing something wrong. I've Cc'd Tom Aldcroft, > the primary author of the Table class, as he might have more insight. > > Mike > > > > On 03/04/2013 06:43 AM, Susana Sanchez wrote: >> >> Hello all, >> >> How can I create a VOtable from a list (a python list) of rows using >> astropy? >> >> Reading the documentation, I found the method "from_table" of the >> class VOTableFile, this method needs as argument an instance of the >> class astropy.table.table.Table, so I did the following: >> >> >> t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) >> votable = VOTableFile() >> votable.from_table(t) >> >> >> But here I got this error: >> >> /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in >> __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, >> keep_mask, hard_mask, shrink, **options) >> 2692 # Or assume it's a sequence of bool/int >> >> 2693 except TypeError: >> -> 2694 mask = np.array([tuple([m] * len(mdtype)) for >> m in mask], >> 2695 dtype=mdtype) >> 2696 # Make sure the mask and the data have the same shape >> >> TypeError: 'NoneType' object is not iterable >> >> >> Reading the error message, I thought it could be related with the >> mask, so I tried to create the mask of the table t (with the method >> t.create_mask()), and then to build the VOTableFile from this table, >> but I got the same error. >> >> I would be very gratefully, If anyone can help me or give me any hint. >> >> Thanks, >> Susana. >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > > From sse at iaa.es Wed Mar 6 11:19:38 2013 From: sse at iaa.es (Susana Sanchez Exposito) Date: Wed, 6 Mar 2013 17:19:38 +0100 Subject: [AstroPy] How can I create a VOtable from a python list? In-Reply-To: <51374DE9.5050006@stsci.edu> References: <51374DE9.5050006@stsci.edu> Message-ID: Hi all and thanks for the answers, I realized in /usr/local/lib/python2.6/dist-packages/astropy/io/votable/tree.py the way to pass the mask in the line 2672 is : new_table.array = ma.array(np.asarray(table), mask=table.mask) If you change this line for this: new_table.array = ma.array(np.asarray(table), mask=ma.getmaskarray(table)) The error disappears. But then, when you try to save the table in a xml file with votable.to_xml("table.xml"), you get this error: /usr/local/lib/python2.6/dist-packages/astropy/utils/xml/writer.pyc in xml_escape_cdata(s) 14 Escapes &, < and > in an XML CDATA string. 15 """ ---> 16 s = s.replace(u"&", u"&") 17 s = s.replace(u"<", u"<") 18 s = s.replace(u">", u">") UnicodeDecodeError: 'ascii' codec can't decode byte 0x8d in position 0: ordinal not in range(128) Susana. 2013/3/6 Michael Droettboom : > The general approach you're taking here -- to create a Table and then > convert it to a VOTable -- is the right one here. The Table class has a > much richer set of things it can convert to and from (it's sort of our > "hub" class for everything that's table like). > > However, I don't believe it supports construction from a list in the way > you're trying. There is a doc page about constructing a table here, > that may be helpful: > > https://astropy.readthedocs.org/en/v0.2/table/construct_table.html > > That said, I tried to convert your example to the form where the Table > is constructed from a Numpy structured array, and still ran into the > same exception: > > from astropy import table > > from astropy.io import votable > > import numpy as np > > x = np.array( > > [("CIG12",1.2345,0,2,999,"COMMENT"), > > ("CIG122",1.23452,0,2,9992,"COMMENT2")], > > dtype=[('a', str), ('b', float), ('c', int), ('d', int), ('e', int), ('f', str)]) > > print x.dtype > > t = table.Table(x) > > votable = votable.tree.VOTableFile.from_table(t) > > > So maybe we're both still doing something wrong. I've Cc'd Tom > Aldcroft, the primary author of the Table class, as he might have more > insight. > > Mike > > > On 03/04/2013 06:43 AM, Susana Sanchez wrote: >> Hello all, >> >> How can I create a VOtable from a list (a python list) of rows using astropy? >> >> Reading the documentation, I found the method "from_table" of the >> class VOTableFile, this method needs as argument an instance of the >> class astropy.table.table.Table, so I did the following: >> >> t=astropy.table.table.Table([["CIG12",1.2345,0,2,999,"COMMENT"],["CIG122",1.23452,0,2,9992,"COMMENT2"]]) >> votable = VOTableFile() >> votable.from_table(t) >> >> >> But here I got this error: >> >> /usr/local/lib/python2.6/dist-packages/numpy/ma/core.pyc in >> __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, >> keep_mask, hard_mask, shrink, **options) >> 2692 # Or assume it's a sequence of bool/int >> >> 2693 except TypeError: >> -> 2694 mask = np.array([tuple([m] * len(mdtype)) for >> m in mask], >> 2695 dtype=mdtype) >> 2696 # Make sure the mask and the data have the same shape >> >> TypeError: 'NoneType' object is not iterable >> >> >> Reading the error message, I thought it could be related with the >> mask, so I tried to create the mask of the table t (with the method >> t.create_mask()), and then to build the VOTableFile from this table, >> but I got the same error. >> >> I would be very gratefully, If anyone can help me or give me any hint. >> >> Thanks, >> Susana. >> _______________________________________________ >> 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 -- Susana S?nchez Exp?sito Instituto de Astrof?sica de Andaluc?a IAA (CSIC) Camino Bajo de Hu?tor, 50. Granada E-18008 Tel:(+34) 958 121 311 / (+34) 958 230 618 Fax:(+34) 958 814 530 e-mail: sse at iaa.es From sse at iaa.es Thu Mar 7 06:33:08 2013 From: sse at iaa.es (Susana Sanchez Exposito) Date: Thu, 7 Mar 2013 12:33:08 +0100 Subject: [AstroPy] How can I preserve the precision of the data in the votable file? Message-ID: Hello again, I have followed the instructions given by Tom Aldcroft as answer of my previous mail (thanks for that!), and finally I get the xml file with the VOTable, but I realized the number are rounded when they are written in the xml file. For example, if I have a table like this: (I built this Table following the example in https://astropy.readthedocs.org/en/v0.2/io/votable/index.html, "Building a new table from scratch"): In [62]: table Out[62]: In [63]: table.array Out[63]: masked_rec.array(data = [(17.257360147629999, 18.999976544568401) (13.257360147629999, 78.999976544568398)], mask = [(False, False) (False, False)], fill_value = (1e+20, 1e+20), dtype = [('precision', ' 17.2574 19 13.2574 79 As you can see, the numbers have been rounded, but I would like to preserve the precision of these data. Is this possible? Thanks again for your useful help! Susana. -- Susana S?nchez Exp?sito Instituto de Astrof?sica de Andaluc?a IAA (CSIC) Camino Bajo de Hu?tor, 50. Granada E-18008 Tel:(+34) 958 121 311 / (+34) 958 230 618 Fax:(+34) 958 814 530 e-mail: sse at iaa.es From mdroe at stsci.edu Thu Mar 7 11:12:11 2013 From: mdroe at stsci.edu (Michael Droettboom) Date: Thu, 7 Mar 2013 11:12:11 -0500 Subject: [AstroPy] How can I preserve the precision of the data in the votable file? In-Reply-To: References: Message-ID: <5138BC5B.5080706@stsci.edu> By default, floating point values are output using 4 decimal points of precision. You can control the amount of precision using the "precision" attribute on the field. This is either "F" followed by a number of decimal places, or "E" followed by the number of significant digits. For example, when you define your fields, you can do: # Define some fields table.fields.extend([ Field(votable, name="float", datatype="double", precision="E8")) See also: http://www.ivoa.net/Documents/VOTable/20040811/REC-VOTable-1.1-20040811.html#ToC26 Mike On 03/07/2013 06:33 AM, Susana Sanchez Exposito wrote: > Hello again, > > I have followed the instructions given by Tom Aldcroft as answer of my > previous mail (thanks for that!), and finally I get the xml file with > the VOTable, but I realized the number are rounded when they are > written in the xml file. > > For example, if I have a table like this: > (I built this Table following the example in > https://astropy.readthedocs.org/en/v0.2/io/votable/index.html, > "Building a new table from scratch"): > > In [62]: table > Out[62]: > > In [63]: table.array > Out[63]: > masked_rec.array(data = [(17.257360147629999, 18.999976544568401) > (13.257360147629999, 78.999976544568398)], > mask = [(False, False) (False, False)], > fill_value = (1e+20, 1e+20), > dtype = [('precision', ' > > When I build the xml file with the comand votable.to_xml, the file > contains this data: > > > > 17.2574 > 19 > > > 13.2574 > 79 > > > > > As you can see, the numbers have been rounded, but I would like to > preserve the precision of these data. Is this possible? > > > Thanks again for your useful help! > > Susana. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sse at iaa.es Fri Mar 8 04:33:00 2013 From: sse at iaa.es (Susana Sanchez Exposito) Date: Fri, 8 Mar 2013 10:33:00 +0100 Subject: [AstroPy] How can I preserve the precision of the data in the votable file? In-Reply-To: <5138BC5B.5080706@stsci.edu> References: <5138BC5B.5080706@stsci.edu> Message-ID: Thanks Mike!! 2013/3/7 Michael Droettboom : > By default, floating point values are output using 4 decimal points of > precision. You can control the amount of precision using the "precision" > attribute on the field. This is either "F" followed by a number of decimal > places, or "E" followed by the number of significant digits. For example, > when you define your fields, you can do: > > # Define some fields > table.fields.extend([ > Field(votable, name="float", datatype="double", precision="E8")) > > See also: > > http://www.ivoa.net/Documents/VOTable/20040811/REC-VOTable-1.1-20040811.html#ToC26 > > Mike > > > On 03/07/2013 06:33 AM, Susana Sanchez Exposito wrote: > > Hello again, > > I have followed the instructions given by Tom Aldcroft as answer of my > previous mail (thanks for that!), and finally I get the xml file with > the VOTable, but I realized the number are rounded when they are > written in the xml file. > > For example, if I have a table like this: > (I built this Table following the example in > https://astropy.readthedocs.org/en/v0.2/io/votable/index.html, > "Building a new table from scratch"): > > In [62]: table > Out[62]: > > In [63]: table.array > Out[63]: > masked_rec.array(data = [(17.257360147629999, 18.999976544568401) > (13.257360147629999, 78.999976544568398)], > mask = [(False, False) (False, False)], > fill_value = (1e+20, 1e+20), > dtype = [('precision', ' > > When I build the xml file with the comand votable.to_xml, the file > contains this data: > > > > 17.2574 > 19 > > > 13.2574 > 79 > > > > > As you can see, the numbers have been rounded, but I would like to > preserve the precision of these data. Is this possible? > > > Thanks again for your useful help! > > Susana. > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > -- Susana S?nchez Exp?sito Instituto de Astrof?sica de Andaluc?a IAA (CSIC) Camino Bajo de Hu?tor, 50. Granada E-18008 Tel:(+34) 958 121 311 / (+34) 958 230 618 Fax:(+34) 958 814 530 e-mail: sse at iaa.es From mdroe at stsci.edu Fri Mar 8 09:31:33 2013 From: mdroe at stsci.edu (Michael Droettboom) Date: Fri, 8 Mar 2013 09:31:33 -0500 Subject: [AstroPy] Fwd: SciPy John Hunter Excellence in Plotting Contest In-Reply-To: <513928AF.7010201@stsci.edu> References: <513928AF.7010201@stsci.edu> Message-ID: <5139F645.3030505@stsci.edu> Apologies for any accidental cross-posting. Email not displaying correctly? View it in your browser. Scientific Computing with Python-Austin, Texas-June 24-29, 2013 SciPy John Hunter Excellence in Plotting Contest In memory of John Hunter, we are pleased to announce the first SciPy John Hunter Excellence in Plotting Competition. This open competition aims to highlight the importance of quality plotting to scientific progress and showcase the capabilities of the current generation of plotting software. Participants are invited to submit scientific plots to be judged by a panel. The winning entries will be announced and displayed at the conference. NumFOCUS is graciously sponsoring cash prizes for the winners in the following amounts: * 1st prize: $500 * 2nd prize: $200 * 3rd prize: $100 Instructions * Entries must be submitted by April 3 via e-mail . * Plots may be produced with any combination of Python-based tools (it is not required that they use matplotlib, for example). * Source code for the plot must be provided, along with a rendering of the plot in a vector format (PDF, PS, etc.). If the data can not be shared for reasons of size or licensing, "fake" data may be substituted, along with an image of the plot using real data. * Entries will be judged on their clarity, innovation and aesthetics, but most importantly for their effectiveness in illuminating real scientific work. Entrants are encouraged to submit plots that were used during the course of research, rather than merely being hypothetical. * SciPy reserves the right to display the entry at the conference, use in any materials or on its website, providing attribution to the original author(s). Important dates: * April 3rd: Plotting submissions due * Monday-Tuesday, June 24 - 25: SciPy 2013 Tutorials, Austin TX * Wednesday-Thursday, June 26 - 27: SciPy 2013 Conference, Austin TX * Winners will be announced during the conference days * Friday-Saturday, June 27 - 28: SciPy 2013 Sprints, Austin TX & remote We look forward to exciting submissions that push the boundaries of plotting, in this, our first attempt at this kind of competition. The SciPy Plotting Contest Organizer -Michael Droettboom, Space Telescope Science Institute You are receiving this email because you subscribed to the mailing list or registered for the SciPy 2010 or SciPy 2011 conference in Austin, TX. Unsubscribe mdboom at gmail.com from this list | Forward to a friend | Update your profile *Our mailing address is:* Enthought, Inc. 515 Congress Ave. Austin, TX 78701 Add us to your address book /Copyright (C) 2013 Enthought, Inc. All rights reserved./ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdroe at stsci.edu Thu Mar 7 18:54:23 2013 From: mdroe at stsci.edu (Michael Droettboom) Date: Thu, 7 Mar 2013 18:54:23 -0500 Subject: [AstroPy] SciPy John Hunter Excellence in Plotting Contest In-Reply-To: References: Message-ID: <513928AF.7010201@stsci.edu> Apologies for any accidental cross-posting. Email not displaying correctly? View it in your browser. Scientific Computing with Python-Austin, Texas-June 24-29, 2013 SciPy John Hunter Excellence in Plotting Contest In memory of John Hunter, we are pleased to announce the first SciPy John Hunter Excellence in Plotting Competition. This open competition aims to highlight the importance of quality plotting to scientific progress and showcase the capabilities of the current generation of plotting software. Participants are invited to submit scientific plots to be judged by a panel. The winning entries will be announced and displayed at the conference. NumFOCUS is graciously sponsoring cash prizes for the winners in the following amounts: * 1st prize: $500 * 2nd prize: $200 * 3rd prize: $100 Instructions * Entries must be submitted by April 3 via e-mail . * Plots may be produced with any combination of Python-based tools (it is not required that they use matplotlib, for example). * Source code for the plot must be provided, along with a rendering of the plot in a vector format (PDF, PS, etc.). If the data can not be shared for reasons of size or licensing, "fake" data may be substituted, along with an image of the plot using real data. * Entries will be judged on their clarity, innovation and aesthetics, but most importantly for their effectiveness in illuminating real scientific work. Entrants are encouraged to submit plots that were used during the course of research, rather than merely being hypothetical. * SciPy reserves the right to display the entry at the conference, use in any materials or on its website, providing attribution to the original author(s). Important dates: * April 3rd: Plotting submissions due * Monday-Tuesday, June 24 - 25: SciPy 2013 Tutorials, Austin TX * Wednesday-Thursday, June 26 - 27: SciPy 2013 Conference, Austin TX * Winners will be announced during the conference days * Friday-Saturday, June 27 - 28: SciPy 2013 Sprints, Austin TX & remote We look forward to exciting submissions that push the boundaries of plotting, in this, our first attempt at this kind of competition. The SciPy Plotting Contest Organizer -Michael Droettboom, Space Telescope Science Institute You are receiving this email because you subscribed to the mailing list or registered for the SciPy 2010 or SciPy 2011 conference in Austin, TX. Unsubscribe mdboom at gmail.com from this list | Forward to a friend | Update your profile *Our mailing address is:* Enthought, Inc. 515 Congress Ave. Austin, TX 78701 Add us to your address book /Copyright (C) 2013 Enthought, Inc. All rights reserved./ -- Michael Droettboom http://www.droettboom.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From npkuin at gmail.com Wed Mar 13 13:25:33 2013 From: npkuin at gmail.com (Paul Kuin) Date: Wed, 13 Mar 2013 17:25:33 +0000 Subject: [AstroPy] fits type of bintable extension Message-ID: Hi, Just looking at the type of one of my bintable extensions and see that it is astropy.io.fits.hdu.table.BinTableHDU I was thinking that this makes is a little more difficult to test the type between the pyfits and astropy.io.fits packages. Was this done on purpose or is this a 'feature' ? Cheers, Paul -- * * * * * * * * 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) -276110 (home) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory ? University College London ? Holmbury St Mary ? Dorking ? Surrey RH5 6NT? U.K. From arrudy at ucsc.edu Wed Mar 13 14:07:56 2013 From: arrudy at ucsc.edu (Alexander Rudy) Date: Wed, 13 Mar 2013 11:07:56 -0700 Subject: [AstroPy] fits type of bintable extension In-Reply-To: References: Message-ID: Hi Paul, What about using the 'isinstance()' built-in method in python? http://docs.python.org/2/library/functions.html#isinstance http://docs.python.org/2/library/functions.html#issubclass That checks the type at runtime, and easily differentiates between them. Try: >>> import astropy.io.fits.hdu.table >>> import pyfits.hdu.table >>> pyFITStable = pyfits.hdu.table.BinTableHDU() >>> apFITStable = astropy.io.fits.hdu.table.BinTableHDU() >>> isinstance(pyFITStable,astropy.io.fits.hdu.table.BinTableHDU) False >>> isinstance(apFITStable,pyfits.hdu.table.BinTableHDU) False >>> isinstance(pyFITStable,pyfits.hdu.table.BinTableHDU) True Or, if you want compatibility for both, just use >>> isinstance(pyFITStable,(pyfits.hdu.table.BinTableHDU,astropy.io.fits.hdu.table.BinTableHDU)) True I'm not sure what you are looking for here. How are you testing the class differences now? You could register pyfits.hdu.table.BinTableHDU as a subclass of astropy.io.fits.hdu.table.BinTableHDU, but that would only work if HDUs use python's abstract base class construct (which they don't right now). See http://docs.python.org/2/library/abc.html for fun registering subclasses to their superclass. I hope that helps. ~ Alex On Mar 13, 2013, at 10:25 , Paul Kuin wrote: > Hi, > > Just looking at the type of one of my bintable extensions and see that it is > astropy.io.fits.hdu.table.BinTableHDU > > I was thinking that this makes is a little more difficult to test the > type between the > pyfits and astropy.io.fits packages. > > Was this done on purpose or is this a 'feature' ? > > Cheers, > > Paul > > -- > > * * * * * * * * 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) -276110 (home) > mobile +44(0)7806985366 skype ID: npkuin > Mullard Space Science Laboratory ? University College London ? > Holmbury St Mary ? Dorking ? Surrey RH5 6NT? U.K. > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From thomas.robitaille at gmail.com Wed Mar 13 14:11:26 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Wed, 13 Mar 2013 19:11:26 +0100 Subject: [AstroPy] fits type of bintable extension In-Reply-To: References: Message-ID: Hi Paul, It isn't a feature or bug, it's more just to do with the fact that the pyfits package is now in astropy.io.fits, so the path to the classes has changed. As Alex pointed out, you can use isinstance(), but note that you can use pyfits.BinTableHDU and astropy.io.fits.BinTableHDU for conciseness (you don't need the .hdu.table. part) since the classes are imported into the top level of pyfits and astropy.io.fits. FYI, If you want to use Astropy instead of PyFITS with minimal changes to scripts, you can do: from astropy.io import fits as pyfits and the rest of the script will not need to be modified. Cheers, Tom On 13 March 2013 18:25, Paul Kuin wrote: > Hi, > > Just looking at the type of one of my bintable extensions and see that it is > astropy.io.fits.hdu.table.BinTableHDU > > I was thinking that this makes is a little more difficult to test the > type between the > pyfits and astropy.io.fits packages. > > Was this done on purpose or is this a 'feature' ? > > Cheers, > > Paul > > -- > > * * * * * * * * 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) -276110 (home) > mobile +44(0)7806985366 skype ID: npkuin > Mullard Space Science Laboratory ? University College London ? > Holmbury St Mary ? Dorking ? Surrey RH5 6NT? U.K. > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From abhijithrajan at asu.edu Wed Mar 13 16:53:33 2013 From: abhijithrajan at asu.edu (Abhijith Rajan) Date: Wed, 13 Mar 2013 13:53:33 -0700 Subject: [AstroPy] great circle? Message-ID: Hi, Just wondering if there is a convenient python module to compute the great circle distance similar to gcirc.pro in IDL? Thanks Abhi p.s: I realize its only ~10 lines of code and I plan to implement it for my immediate needs. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aldcroft at head.cfa.harvard.edu Wed Mar 13 17:11:40 2013 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Wed, 13 Mar 2013 17:11:40 -0400 Subject: [AstroPy] great circle? In-Reply-To: References: Message-ID: On Wed, Mar 13, 2013 at 4:53 PM, Abhijith Rajan wrote: > Hi, > > Just wondering if there is a convenient python module to compute the great > circle distance similar to gcirc.pro in IDL? Yes, use the separation() method in astropy.coordinates: http://docs.astropy.org/en/v0.2/coordinates/separations.html Cheers, Tom > > Thanks > Abhi > > p.s: I realize its only ~10 lines of code and I plan to implement it for my > immediate needs. > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy > From abhijithrajan at asu.edu Wed Mar 13 17:20:32 2013 From: abhijithrajan at asu.edu (Abhijith Rajan) Date: Wed, 13 Mar 2013 14:20:32 -0700 Subject: [AstroPy] great circle? In-Reply-To: References: Message-ID: Excellent. Thanks :). Abhi On Wed, Mar 13, 2013 at 2:11 PM, Tom Aldcroft wrote: > On Wed, Mar 13, 2013 at 4:53 PM, Abhijith Rajan > wrote: > > Hi, > > > > Just wondering if there is a convenient python module to compute the > great > > circle distance similar to gcirc.pro in IDL? > > Yes, use the separation() method in astropy.coordinates: > > http://docs.astropy.org/en/v0.2/coordinates/separations.html > > Cheers, > Tom > > > > > > Thanks > > Abhi > > > > p.s: I realize its only ~10 lines of code and I plan to implement it for > my > > immediate needs. > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.robitaille at gmail.com Mon Mar 18 12:59:54 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Mon, 18 Mar 2013 17:59:54 +0100 Subject: [AstroPy] montage-wrapper v0.9.5 release Message-ID: I am pleased to announce the release of montage-wrapper v0.9.5 (formerly python-montage). Montage-wrapper is a package that provides a way to run the Montage Astronomical Image Mosaic Engine from Python, including both functions to access individual Montage commands, and high-level functions to facilitate mosaicking and reprojecting. Montage-wrapper is now an Astropy-affiliated package, which means that it follows the Astropy guidelines for packages, and requires Astropy as a dependency. In addition, this release includes a number of bug fixes and stability/performance improvements. The homepage is now located at: http://www.astropy.org/montage-wrapper/ and the documentation can be found here: http://montage-wrapper.readthedocs.org/ Please note that due to the change in the name of the package, the module should now be imported with: import montage_wrapper In order to get old scripts to work, or generally for convenience, you can import the module with: import montage_wrapper as montage (the change in package name from 'montage' to 'montage_wrapper' is to avoid conflict with another package named 'montage') Please report any issues either via GitHub at: https://github.com/astropy/montage-wrapper/issues or directly to me by email. Cheers, Tom From jslavin at cfa.harvard.edu Thu Mar 21 14:20:37 2013 From: jslavin at cfa.harvard.edu (Jonathan Slavin) Date: Thu, 21 Mar 2013 14:20:37 -0400 Subject: [AstroPy] why the warning about Converting Quantity? Message-ID: <1363890037.4653.6.camel@shevek> Hi, I have just used the constants module in astropy for the first time and got 6 warnings from my code as a result: import astropy.constants as const AU = const.au.to('km') leads to WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] It seems that I get the warning every place I use the value of AU. Do I have to turn off warnings to prevent this? Is there some other way to deal with this? Jon -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ From adrianmpw at gmail.com Thu Mar 21 15:05:14 2013 From: adrianmpw at gmail.com (Adrian Price-Whelan) Date: Thu, 21 Mar 2013 15:05:14 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: <1363890037.4653.6.camel@shevek> References: <1363890037.4653.6.camel@shevek> Message-ID: <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> Hey Jonathan -- Are you sure that's the point in the code that's producing the warning? What operations are you doing with the AU object? When you use the .to() method, it still returns a Quantity object -- *not* the value of the original object in those units. If you then stick AU into any numpy function, it will work but will just extract the value from the object (hence the warning). See, for example: >>> import astropy.units as u >>> np.sqrt(15*u.km) WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] 3.872983346207417 To turn this off, you'll want to set: >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>> np.sqrt(15*u.km) 3.872983346207417 Note that this is documented in the astropy.units.quantity section of the astropy documentation: http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types Thanks, Adrian On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: > Hi, > > I have just used the constants module in astropy for the first time and > got 6 warnings from my code as a result: > > import astropy.constants as const > AU = const.au.to('km') > > leads to > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > > It seems that I get the warning every place I use the value of AU. Do I > have to turn off warnings to prevent this? Is there some other way to > deal with this? > > Jon > -- > ______________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ______________________________________________________________ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Adrian Price-Whelan Department of Astronomy Columbia University From wkerzendorf at gmail.com Thu Mar 21 15:15:26 2013 From: wkerzendorf at gmail.com (Wolfgang Kerzendorf) Date: Thu, 21 Mar 2013 15:15:26 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> Message-ID: <4C0F654A-D6CB-4093-BAC9-8D3F28A5C485@gmail.com> Hi Jonathan, I think, one should not turn this warning off. It warns you that the quantity you get after the operations does not necessarily have the same units as before - and rightly so. When doing things like np.sqrt(15* u.km), they can be replaced with np.sqrt((15 * u.km).value) which specifically tells it to convert to a float (and puts the onus on you to think about the units). Cheers Wolfgang Hope that helps On 2013-03-21, at 3:05 PM, Adrian Price-Whelan wrote: > Hey Jonathan -- > > Are you sure that's the point in the code that's producing the warning? What operations are you doing with the AU object? When you use the .to() method, it still returns a Quantity object -- *not* the value of the original object in those units. If you then stick AU into any numpy function, it will work but will just extract the value from the object (hence the warning). > > See, for example: > >>>> import astropy.units as u >>>> np.sqrt(15*u.km) > WARNING: Converting Quantity object in units 'km' to a Numpy array [astropy.units.quantity] > 3.872983346207417 > > To turn this off, you'll want to set: >>>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>>> np.sqrt(15*u.km) > 3.872983346207417 > > Note that this is documented in the astropy.units.quantity section of the astropy documentation: > http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types > > Thanks, > Adrian > > On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: > >> Hi, >> >> I have just used the constants module in astropy for the first time and >> got 6 warnings from my code as a result: >> >> import astropy.constants as const >> AU = const.au.to('km') >> >> leads to >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> >> It seems that I get the warning every place I use the value of AU. Do I >> have to turn off warnings to prevent this? Is there some other way to >> deal with this? >> >> Jon >> -- >> ______________________________________________________________ >> Jonathan D. Slavin Harvard-Smithsonian CfA >> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >> phone: (617) 496-7981 Cambridge, MA 02138-1516 >> cell: (781) 363-0035 USA >> ______________________________________________________________ >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > > -- > Adrian Price-Whelan > Department of Astronomy > Columbia University > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From jslavin at cfa.harvard.edu Thu Mar 21 15:22:50 2013 From: jslavin at cfa.harvard.edu (Jonathan Slavin) Date: Thu, 21 Mar 2013 15:22:50 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> Message-ID: <1363893770.8743.12.camel@shevek> Hi Adrian, Yes, as I mentioned farther down in my post, the warnings are generated when I use it in an expression -- with numpy arrays. It'd be nice to have a less cumbersome way of suppressing those warnings (yes it's just one line, but not so easy to remember). In fact, I would expect to use the constants mostly in expressions with numpy arrays, variables, etc. that don't have units, so my preference would be that by default those warnings are turned off -- at least for the constants. The constants are useful for their values alone, though clearly the value of the units module is to associate units with values. Maybe a simple method like value.asfloat() could be added that would allow conversion from a units object to a numpy float. Jon On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: > Hey Jonathan -- > > Are you sure that's the point in the code that's producing the > warning? What operations are you doing with the AU object? When you > use the .to() method, it still returns a Quantity object -- *not* the > value of the original object in those units. If you then stick AU into > any numpy function, it will work but will just extract the value from > the object (hence the warning). > > See, for example: > > >>> import astropy.units as u > >>> np.sqrt(15*u.km) > WARNING: Converting Quantity object in units 'km' to a Numpy array > [astropy.units.quantity] > 3.872983346207417 > > To turn this off, you'll want to set: > >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) > >>> np.sqrt(15*u.km) > 3.872983346207417 > > Note that this is documented in the astropy.units.quantity section of > the astropy documentation: > http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types > > Thanks, > Adrian > > On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: > > > Hi, > > > > I have just used the constants module in astropy for the first time and > > got 6 warnings from my code as a result: > > > > import astropy.constants as const > > AU = const.au.to('km') > > > > leads to > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > WARNING: Converting Quantity object in units 'km' to a Numpy array > > [astropy.units.quantity] > > > > It seems that I get the warning every place I use the value of AU. Do I > > have to turn off warnings to prevent this? Is there some other way to > > deal with this? > > > > Jon > > -- > > ______________________________________________________________ > > Jonathan D. Slavin Harvard-Smithsonian CfA > > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > > phone: (617) 496-7981 Cambridge, MA 02138-1516 > > cell: (781) 363-0035 USA > > ______________________________________________________________ > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > -- > Adrian Price-Whelan > Department of Astronomy > Columbia University > > > -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ From erik.tollerud at gmail.com Fri Mar 22 10:57:35 2013 From: erik.tollerud at gmail.com (Erik Tollerud) Date: Fri, 22 Mar 2013 10:57:35 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: <1363893770.8743.12.camel@shevek> References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: Hello Jonathan et al., I think some confusion here stems from the fact that ``AU`` is a bit of a special constant - in most cases, you're probably better off using the AU *unit*, rather than the constant. That is, if you were doing something like arrinau = arr * constants.au That gives exactly the warning you mentioned, whereas arrinau = arr * units.au won't give out a warning, because it creates a `Quantity` object with the units `AU`, rather than a regular array without any units. Does that make sense, or am I still misunderstanding how you're using this? If the latter, can you give an actual example of the line that actually produces this warning? That'll make it easier to understand exactly what you're suggesting. On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin wrote: > Hi Adrian, > > Yes, as I mentioned farther down in my post, the warnings are generated > when I use it in an expression -- with numpy arrays. It'd be nice to > have a less cumbersome way of suppressing those warnings (yes it's just > one line, but not so easy to remember). In fact, I would expect to use > the constants mostly in expressions with numpy arrays, variables, etc. > that don't have units, so my preference would be that by default those > warnings are turned off -- at least for the constants. The constants > are useful for their values alone, though clearly the value of the units > module is to associate units with values. Maybe a simple method like > value.asfloat() could be added that would allow conversion from a units > object to a numpy float. > > Jon > > On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >> Hey Jonathan -- >> >> Are you sure that's the point in the code that's producing the >> warning? What operations are you doing with the AU object? When you >> use the .to() method, it still returns a Quantity object -- *not* the >> value of the original object in those units. If you then stick AU into >> any numpy function, it will work but will just extract the value from >> the object (hence the warning). >> >> See, for example: >> >> >>> import astropy.units as u >> >>> np.sqrt(15*u.km) >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> 3.872983346207417 >> >> To turn this off, you'll want to set: >> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >> >>> np.sqrt(15*u.km) >> 3.872983346207417 >> >> Note that this is documented in the astropy.units.quantity section of >> the astropy documentation: >> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >> >> Thanks, >> Adrian >> >> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >> >> > Hi, >> > >> > I have just used the constants module in astropy for the first time and >> > got 6 warnings from my code as a result: >> > >> > import astropy.constants as const >> > AU = const.au.to('km') >> > >> > leads to >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > >> > It seems that I get the warning every place I use the value of AU. Do I >> > have to turn off warnings to prevent this? Is there some other way to >> > deal with this? >> > >> > Jon >> > -- >> > ______________________________________________________________ >> > Jonathan D. Slavin Harvard-Smithsonian CfA >> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >> > cell: (781) 363-0035 USA >> > ______________________________________________________________ >> > >> > _______________________________________________ >> > AstroPy mailing list >> > AstroPy at scipy.org >> > http://mail.scipy.org/mailman/listinfo/astropy >> >> -- >> Adrian Price-Whelan >> Department of Astronomy >> Columbia University >> >> >> > > -- > ______________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ______________________________________________________________ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Erik On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin wrote: > Hi Adrian, > > Yes, as I mentioned farther down in my post, the warnings are generated > when I use it in an expression -- with numpy arrays. It'd be nice to > have a less cumbersome way of suppressing those warnings (yes it's just > one line, but not so easy to remember). In fact, I would expect to use > the constants mostly in expressions with numpy arrays, variables, etc. > that don't have units, so my preference would be that by default those > warnings are turned off -- at least for the constants. The constants > are useful for their values alone, though clearly the value of the units > module is to associate units with values. Maybe a simple method like > value.asfloat() could be added that would allow conversion from a units > object to a numpy float. > > Jon > > On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >> Hey Jonathan -- >> >> Are you sure that's the point in the code that's producing the >> warning? What operations are you doing with the AU object? When you >> use the .to() method, it still returns a Quantity object -- *not* the >> value of the original object in those units. If you then stick AU into >> any numpy function, it will work but will just extract the value from >> the object (hence the warning). >> >> See, for example: >> >> >>> import astropy.units as u >> >>> np.sqrt(15*u.km) >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> 3.872983346207417 >> >> To turn this off, you'll want to set: >> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >> >>> np.sqrt(15*u.km) >> 3.872983346207417 >> >> Note that this is documented in the astropy.units.quantity section of >> the astropy documentation: >> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >> >> Thanks, >> Adrian >> >> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >> >> > Hi, >> > >> > I have just used the constants module in astropy for the first time and >> > got 6 warnings from my code as a result: >> > >> > import astropy.constants as const >> > AU = const.au.to('km') >> > >> > leads to >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > WARNING: Converting Quantity object in units 'km' to a Numpy array >> > [astropy.units.quantity] >> > >> > It seems that I get the warning every place I use the value of AU. Do I >> > have to turn off warnings to prevent this? Is there some other way to >> > deal with this? >> > >> > Jon >> > -- >> > ______________________________________________________________ >> > Jonathan D. Slavin Harvard-Smithsonian CfA >> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >> > cell: (781) 363-0035 USA >> > ______________________________________________________________ >> > >> > _______________________________________________ >> > AstroPy mailing list >> > AstroPy at scipy.org >> > http://mail.scipy.org/mailman/listinfo/astropy >> >> -- >> Adrian Price-Whelan >> Department of Astronomy >> Columbia University >> >> >> > > -- > ______________________________________________________________ > Jonathan D. Slavin Harvard-Smithsonian CfA > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > phone: (617) 496-7981 Cambridge, MA 02138-1516 > cell: (781) 363-0035 USA > ______________________________________________________________ > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy -- Erik Tollerud From thomas.robitaille at gmail.com Fri Mar 22 11:18:53 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Fri, 22 Mar 2013 16:18:53 +0100 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: I think that In [4]: np.array([1,2,3]) * constants.au WARNING: Converting Quantity object in units 'm' to a Numpy array [astropy.units.quantity] Out[4]: array([ 1.49597871e+11, 2.99195741e+11, 4.48793612e+11]) is actually a bug, as this should return a Quantity (like it does for scalars). I'll submit a PR shortly. Cheers, Tom On 22 March 2013 15:57, Erik Tollerud wrote: > Hello Jonathan et al., > > I think some confusion here stems from the fact that ``AU`` is a bit > of a special constant - in most cases, you're probably better off > using the AU *unit*, rather than the constant. That is, if you were > doing something like > > arrinau = arr * constants.au > > That gives exactly the warning you mentioned, whereas > > arrinau = arr * units.au > > won't give out a warning, because it creates a `Quantity` object with > the units `AU`, rather than a regular array without any units. > > > Does that make sense, or am I still misunderstanding how you're using > this? If the latter, can you give an actual example of the line that > actually produces this warning? That'll make it easier to understand > exactly what you're suggesting. > > > > > On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin > wrote: >> Hi Adrian, >> >> Yes, as I mentioned farther down in my post, the warnings are generated >> when I use it in an expression -- with numpy arrays. It'd be nice to >> have a less cumbersome way of suppressing those warnings (yes it's just >> one line, but not so easy to remember). In fact, I would expect to use >> the constants mostly in expressions with numpy arrays, variables, etc. >> that don't have units, so my preference would be that by default those >> warnings are turned off -- at least for the constants. The constants >> are useful for their values alone, though clearly the value of the units >> module is to associate units with values. Maybe a simple method like >> value.asfloat() could be added that would allow conversion from a units >> object to a numpy float. >> >> Jon >> >> On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >>> Hey Jonathan -- >>> >>> Are you sure that's the point in the code that's producing the >>> warning? What operations are you doing with the AU object? When you >>> use the .to() method, it still returns a Quantity object -- *not* the >>> value of the original object in those units. If you then stick AU into >>> any numpy function, it will work but will just extract the value from >>> the object (hence the warning). >>> >>> See, for example: >>> >>> >>> import astropy.units as u >>> >>> np.sqrt(15*u.km) >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> 3.872983346207417 >>> >>> To turn this off, you'll want to set: >>> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>> >>> np.sqrt(15*u.km) >>> 3.872983346207417 >>> >>> Note that this is documented in the astropy.units.quantity section of >>> the astropy documentation: >>> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >>> >>> Thanks, >>> Adrian >>> >>> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >>> >>> > Hi, >>> > >>> > I have just used the constants module in astropy for the first time and >>> > got 6 warnings from my code as a result: >>> > >>> > import astropy.constants as const >>> > AU = const.au.to('km') >>> > >>> > leads to >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > >>> > It seems that I get the warning every place I use the value of AU. Do I >>> > have to turn off warnings to prevent this? Is there some other way to >>> > deal with this? >>> > >>> > Jon >>> > -- >>> > ______________________________________________________________ >>> > Jonathan D. Slavin Harvard-Smithsonian CfA >>> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >>> > cell: (781) 363-0035 USA >>> > ______________________________________________________________ >>> > >>> > _______________________________________________ >>> > AstroPy mailing list >>> > AstroPy at scipy.org >>> > http://mail.scipy.org/mailman/listinfo/astropy >>> >>> -- >>> Adrian Price-Whelan >>> Department of Astronomy >>> Columbia University >>> >>> >>> >> >> -- >> ______________________________________________________________ >> Jonathan D. Slavin Harvard-Smithsonian CfA >> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >> phone: (617) 496-7981 Cambridge, MA 02138-1516 >> cell: (781) 363-0035 USA >> ______________________________________________________________ >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > > > > -- > Erik > > On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin > wrote: >> Hi Adrian, >> >> Yes, as I mentioned farther down in my post, the warnings are generated >> when I use it in an expression -- with numpy arrays. It'd be nice to >> have a less cumbersome way of suppressing those warnings (yes it's just >> one line, but not so easy to remember). In fact, I would expect to use >> the constants mostly in expressions with numpy arrays, variables, etc. >> that don't have units, so my preference would be that by default those >> warnings are turned off -- at least for the constants. The constants >> are useful for their values alone, though clearly the value of the units >> module is to associate units with values. Maybe a simple method like >> value.asfloat() could be added that would allow conversion from a units >> object to a numpy float. >> >> Jon >> >> On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >>> Hey Jonathan -- >>> >>> Are you sure that's the point in the code that's producing the >>> warning? What operations are you doing with the AU object? When you >>> use the .to() method, it still returns a Quantity object -- *not* the >>> value of the original object in those units. If you then stick AU into >>> any numpy function, it will work but will just extract the value from >>> the object (hence the warning). >>> >>> See, for example: >>> >>> >>> import astropy.units as u >>> >>> np.sqrt(15*u.km) >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> 3.872983346207417 >>> >>> To turn this off, you'll want to set: >>> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>> >>> np.sqrt(15*u.km) >>> 3.872983346207417 >>> >>> Note that this is documented in the astropy.units.quantity section of >>> the astropy documentation: >>> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >>> >>> Thanks, >>> Adrian >>> >>> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >>> >>> > Hi, >>> > >>> > I have just used the constants module in astropy for the first time and >>> > got 6 warnings from my code as a result: >>> > >>> > import astropy.constants as const >>> > AU = const.au.to('km') >>> > >>> > leads to >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>> > [astropy.units.quantity] >>> > >>> > It seems that I get the warning every place I use the value of AU. Do I >>> > have to turn off warnings to prevent this? Is there some other way to >>> > deal with this? >>> > >>> > Jon >>> > -- >>> > ______________________________________________________________ >>> > Jonathan D. Slavin Harvard-Smithsonian CfA >>> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >>> > cell: (781) 363-0035 USA >>> > ______________________________________________________________ >>> > >>> > _______________________________________________ >>> > AstroPy mailing list >>> > AstroPy at scipy.org >>> > http://mail.scipy.org/mailman/listinfo/astropy >>> >>> -- >>> Adrian Price-Whelan >>> Department of Astronomy >>> Columbia University >>> >>> >>> >> >> -- >> ______________________________________________________________ >> Jonathan D. Slavin Harvard-Smithsonian CfA >> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >> phone: (617) 496-7981 Cambridge, MA 02138-1516 >> cell: (781) 363-0035 USA >> ______________________________________________________________ >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy > > > > -- > Erik Tollerud > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > http://mail.scipy.org/mailman/listinfo/astropy From streetomon at gmail.com Fri Mar 22 11:30:07 2013 From: streetomon at gmail.com (=?ISO-8859-1?Q?Andr=E9_Luiz_de_Amorim?=) Date: Fri, 22 Mar 2013 16:30:07 +0100 Subject: [AstroPy] PyDev in danger of becoming unsupported Message-ID: Hi All, sorry to bother you in what may be regarded as spam, but I think this is an important issue. PyDev/eclipse is one of the most used IDEs for python development. It is maintained mostly by only one guy, Fabio Zadrozny, who used to be backed by some companies. The support by these companies has ended, and Fabio began a fund raising for PyDev: http://www.indiegogo.com/projects/pydev-and-liclipse-for-a-fast-sexy-and-dark-eclipse Please help keeping this great tool alive. :) Andr?. -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.robitaille at gmail.com Fri Mar 22 11:51:21 2013 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Fri, 22 Mar 2013 16:51:21 +0100 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: This is actually an issue with the Quantity class, not constants (Constant inherits the issue from Quantity). I've opened an issue to keep track of it: https://github.com/astropy/astropy/pull/899 with some initial code which *should* have fixed it, but doesn't, due to a Numpy issue. Cheers, Tom On 22 March 2013 16:18, Thomas Robitaille wrote: > I think that > > In [4]: np.array([1,2,3]) * constants.au > WARNING: Converting Quantity object in units 'm' to a Numpy array > [astropy.units.quantity] > Out[4]: array([ 1.49597871e+11, 2.99195741e+11, 4.48793612e+11]) > > is actually a bug, as this should return a Quantity (like it does for > scalars). I'll submit a PR shortly. > > Cheers, > Tom > > On 22 March 2013 15:57, Erik Tollerud wrote: >> Hello Jonathan et al., >> >> I think some confusion here stems from the fact that ``AU`` is a bit >> of a special constant - in most cases, you're probably better off >> using the AU *unit*, rather than the constant. That is, if you were >> doing something like >> >> arrinau = arr * constants.au >> >> That gives exactly the warning you mentioned, whereas >> >> arrinau = arr * units.au >> >> won't give out a warning, because it creates a `Quantity` object with >> the units `AU`, rather than a regular array without any units. >> >> >> Does that make sense, or am I still misunderstanding how you're using >> this? If the latter, can you give an actual example of the line that >> actually produces this warning? That'll make it easier to understand >> exactly what you're suggesting. >> >> >> >> >> On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin >> wrote: >>> Hi Adrian, >>> >>> Yes, as I mentioned farther down in my post, the warnings are generated >>> when I use it in an expression -- with numpy arrays. It'd be nice to >>> have a less cumbersome way of suppressing those warnings (yes it's just >>> one line, but not so easy to remember). In fact, I would expect to use >>> the constants mostly in expressions with numpy arrays, variables, etc. >>> that don't have units, so my preference would be that by default those >>> warnings are turned off -- at least for the constants. The constants >>> are useful for their values alone, though clearly the value of the units >>> module is to associate units with values. Maybe a simple method like >>> value.asfloat() could be added that would allow conversion from a units >>> object to a numpy float. >>> >>> Jon >>> >>> On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >>>> Hey Jonathan -- >>>> >>>> Are you sure that's the point in the code that's producing the >>>> warning? What operations are you doing with the AU object? When you >>>> use the .to() method, it still returns a Quantity object -- *not* the >>>> value of the original object in those units. If you then stick AU into >>>> any numpy function, it will work but will just extract the value from >>>> the object (hence the warning). >>>> >>>> See, for example: >>>> >>>> >>> import astropy.units as u >>>> >>> np.sqrt(15*u.km) >>>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> [astropy.units.quantity] >>>> 3.872983346207417 >>>> >>>> To turn this off, you'll want to set: >>>> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>>> >>> np.sqrt(15*u.km) >>>> 3.872983346207417 >>>> >>>> Note that this is documented in the astropy.units.quantity section of >>>> the astropy documentation: >>>> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >>>> >>>> Thanks, >>>> Adrian >>>> >>>> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >>>> >>>> > Hi, >>>> > >>>> > I have just used the constants module in astropy for the first time and >>>> > got 6 warnings from my code as a result: >>>> > >>>> > import astropy.constants as const >>>> > AU = const.au.to('km') >>>> > >>>> > leads to >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > >>>> > It seems that I get the warning every place I use the value of AU. Do I >>>> > have to turn off warnings to prevent this? Is there some other way to >>>> > deal with this? >>>> > >>>> > Jon >>>> > -- >>>> > ______________________________________________________________ >>>> > Jonathan D. Slavin Harvard-Smithsonian CfA >>>> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>>> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >>>> > cell: (781) 363-0035 USA >>>> > ______________________________________________________________ >>>> > >>>> > _______________________________________________ >>>> > AstroPy mailing list >>>> > AstroPy at scipy.org >>>> > http://mail.scipy.org/mailman/listinfo/astropy >>>> >>>> -- >>>> Adrian Price-Whelan >>>> Department of Astronomy >>>> Columbia University >>>> >>>> >>>> >>> >>> -- >>> ______________________________________________________________ >>> Jonathan D. Slavin Harvard-Smithsonian CfA >>> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>> phone: (617) 496-7981 Cambridge, MA 02138-1516 >>> cell: (781) 363-0035 USA >>> ______________________________________________________________ >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> -- >> Erik >> >> On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin >> wrote: >>> Hi Adrian, >>> >>> Yes, as I mentioned farther down in my post, the warnings are generated >>> when I use it in an expression -- with numpy arrays. It'd be nice to >>> have a less cumbersome way of suppressing those warnings (yes it's just >>> one line, but not so easy to remember). In fact, I would expect to use >>> the constants mostly in expressions with numpy arrays, variables, etc. >>> that don't have units, so my preference would be that by default those >>> warnings are turned off -- at least for the constants. The constants >>> are useful for their values alone, though clearly the value of the units >>> module is to associate units with values. Maybe a simple method like >>> value.asfloat() could be added that would allow conversion from a units >>> object to a numpy float. >>> >>> Jon >>> >>> On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >>>> Hey Jonathan -- >>>> >>>> Are you sure that's the point in the code that's producing the >>>> warning? What operations are you doing with the AU object? When you >>>> use the .to() method, it still returns a Quantity object -- *not* the >>>> value of the original object in those units. If you then stick AU into >>>> any numpy function, it will work but will just extract the value from >>>> the object (hence the warning). >>>> >>>> See, for example: >>>> >>>> >>> import astropy.units as u >>>> >>> np.sqrt(15*u.km) >>>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> [astropy.units.quantity] >>>> 3.872983346207417 >>>> >>>> To turn this off, you'll want to set: >>>> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>>> >>> np.sqrt(15*u.km) >>>> 3.872983346207417 >>>> >>>> Note that this is documented in the astropy.units.quantity section of >>>> the astropy documentation: >>>> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >>>> >>>> Thanks, >>>> Adrian >>>> >>>> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >>>> >>>> > Hi, >>>> > >>>> > I have just used the constants module in astropy for the first time and >>>> > got 6 warnings from my code as a result: >>>> > >>>> > import astropy.constants as const >>>> > AU = const.au.to('km') >>>> > >>>> > leads to >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > WARNING: Converting Quantity object in units 'km' to a Numpy array >>>> > [astropy.units.quantity] >>>> > >>>> > It seems that I get the warning every place I use the value of AU. Do I >>>> > have to turn off warnings to prevent this? Is there some other way to >>>> > deal with this? >>>> > >>>> > Jon >>>> > -- >>>> > ______________________________________________________________ >>>> > Jonathan D. Slavin Harvard-Smithsonian CfA >>>> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>>> > phone: (617) 496-7981 Cambridge, MA 02138-1516 >>>> > cell: (781) 363-0035 USA >>>> > ______________________________________________________________ >>>> > >>>> > _______________________________________________ >>>> > AstroPy mailing list >>>> > AstroPy at scipy.org >>>> > http://mail.scipy.org/mailman/listinfo/astropy >>>> >>>> -- >>>> Adrian Price-Whelan >>>> Department of Astronomy >>>> Columbia University >>>> >>>> >>>> >>> >>> -- >>> ______________________________________________________________ >>> Jonathan D. Slavin Harvard-Smithsonian CfA >>> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>> phone: (617) 496-7981 Cambridge, MA 02138-1516 >>> cell: (781) 363-0035 USA >>> ______________________________________________________________ >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> >> >> -- >> Erik Tollerud >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> http://mail.scipy.org/mailman/listinfo/astropy From jslavin at cfa.harvard.edu Fri Mar 22 12:32:59 2013 From: jslavin at cfa.harvard.edu (Jonathan Slavin) Date: Fri, 22 Mar 2013 12:32:59 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: <1363969979.10525.80.camel@shevek> Hi Erik, In my case I'm actually using AU to convert from data that was returned from another routine and has units of km to AU (the data are numpy arrays.) e.g. AU = constants.au.to('km') xe = xem/AU # xem is in km, I want xe in AU I could give xem the units of km in this example, though in fact the actual expressions are a bit more complicated, but I just wanted to use the constant value without bothering to look it up. So I'm not, in this instance, wanting to take advantage of the object's associated units checking. I think that that should not be so difficult. Often one will not want to bother to convert all one's data arrays to Quantity objects. As I said, the constants are convenient for their values as well as the units checking and it doesn't seem so unlikely that many would like to use those values in contexts in which they won't want to bother to define the units of all the other data. Jon On Fri, 2013-03-22 at 10:57 -0400, Erik Tollerud wrote: > Hello Jonathan et al., > > I think some confusion here stems from the fact that ``AU`` is a bit > of a special constant - in most cases, you're probably better off > using the AU *unit*, rather than the constant. That is, if you were > doing something like > > arrinau = arr * constants.au > > That gives exactly the warning you mentioned, whereas > > arrinau = arr * units.au > > won't give out a warning, because it creates a `Quantity` object with > the units `AU`, rather than a regular array without any units. > > > Does that make sense, or am I still misunderstanding how you're using > this? If the latter, can you give an actual example of the line that > actually produces this warning? That'll make it easier to understand > exactly what you're suggesting. -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ From jslavin at cfa.harvard.edu Fri Mar 22 12:37:51 2013 From: jslavin at cfa.harvard.edu (Jonathan Slavin) Date: Fri, 22 Mar 2013 12:37:51 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: <1363970271.10525.82.camel@shevek> Ah! Now I see. All I needed to do was: AU = constants.au.to('km').value xe = xem/AU By just using the value attribute I get what I want. Jon On Fri, 2013-03-22 at 10:57 -0400, Erik Tollerud wrote: > Hello Jonathan et al., > > I think some confusion here stems from the fact that ``AU`` is a bit > of a special constant - in most cases, you're probably better off > using the AU *unit*, rather than the constant. That is, if you were > doing something like > > arrinau = arr * constants.au > > That gives exactly the warning you mentioned, whereas > > arrinau = arr * units.au > > won't give out a warning, because it creates a `Quantity` object with > the units `AU`, rather than a regular array without any units. > > > Does that make sense, or am I still misunderstanding how you're using > this? If the latter, can you give an actual example of the line that > actually produces this warning? That'll make it easier to understand > exactly what you're suggesting. > > > > > On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin > wrote: > > Hi Adrian, > > > > Yes, as I mentioned farther down in my post, the warnings are generated > > when I use it in an expression -- with numpy arrays. It'd be nice to > > have a less cumbersome way of suppressing those warnings (yes it's just > > one line, but not so easy to remember). In fact, I would expect to use > > the constants mostly in expressions with numpy arrays, variables, etc. > > that don't have units, so my preference would be that by default those > > warnings are turned off -- at least for the constants. The constants > > are useful for their values alone, though clearly the value of the units > > module is to associate units with values. Maybe a simple method like > > value.asfloat() could be added that would allow conversion from a units > > object to a numpy float. > > > > Jon > > > > On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: > >> Hey Jonathan -- > >> > >> Are you sure that's the point in the code that's producing the > >> warning? What operations are you doing with the AU object? When you > >> use the .to() method, it still returns a Quantity object -- *not* the > >> value of the original object in those units. If you then stick AU into > >> any numpy function, it will work but will just extract the value from > >> the object (hence the warning). > >> > >> See, for example: > >> > >> >>> import astropy.units as u > >> >>> np.sqrt(15*u.km) > >> WARNING: Converting Quantity object in units 'km' to a Numpy array > >> [astropy.units.quantity] > >> 3.872983346207417 > >> > >> To turn this off, you'll want to set: > >> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) > >> >>> np.sqrt(15*u.km) > >> 3.872983346207417 > >> > >> Note that this is documented in the astropy.units.quantity section of > >> the astropy documentation: > >> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types > >> > >> Thanks, > >> Adrian > >> > >> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: > >> > >> > Hi, > >> > > >> > I have just used the constants module in astropy for the first time and > >> > got 6 warnings from my code as a result: > >> > > >> > import astropy.constants as const > >> > AU = const.au.to('km') > >> > > >> > leads to > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > > >> > It seems that I get the warning every place I use the value of AU. Do I > >> > have to turn off warnings to prevent this? Is there some other way to > >> > deal with this? > >> > > >> > Jon > >> > -- > >> > ______________________________________________________________ > >> > Jonathan D. Slavin Harvard-Smithsonian CfA > >> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > >> > phone: (617) 496-7981 Cambridge, MA 02138-1516 > >> > cell: (781) 363-0035 USA > >> > ______________________________________________________________ > >> > > >> > _______________________________________________ > >> > AstroPy mailing list > >> > AstroPy at scipy.org > >> > http://mail.scipy.org/mailman/listinfo/astropy > >> > >> -- > >> Adrian Price-Whelan > >> Department of Astronomy > >> Columbia University > >> > >> > >> > > > > -- > > ______________________________________________________________ > > Jonathan D. Slavin Harvard-Smithsonian CfA > > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > > phone: (617) 496-7981 Cambridge, MA 02138-1516 > > cell: (781) 363-0035 USA > > ______________________________________________________________ > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > > -- > Erik > > On Thu, Mar 21, 2013 at 3:22 PM, Jonathan Slavin > wrote: > > Hi Adrian, > > > > Yes, as I mentioned farther down in my post, the warnings are generated > > when I use it in an expression -- with numpy arrays. It'd be nice to > > have a less cumbersome way of suppressing those warnings (yes it's just > > one line, but not so easy to remember). In fact, I would expect to use > > the constants mostly in expressions with numpy arrays, variables, etc. > > that don't have units, so my preference would be that by default those > > warnings are turned off -- at least for the constants. The constants > > are useful for their values alone, though clearly the value of the units > > module is to associate units with values. Maybe a simple method like > > value.asfloat() could be added that would allow conversion from a units > > object to a numpy float. > > > > Jon > > > > On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: > >> Hey Jonathan -- > >> > >> Are you sure that's the point in the code that's producing the > >> warning? What operations are you doing with the AU object? When you > >> use the .to() method, it still returns a Quantity object -- *not* the > >> value of the original object in those units. If you then stick AU into > >> any numpy function, it will work but will just extract the value from > >> the object (hence the warning). > >> > >> See, for example: > >> > >> >>> import astropy.units as u > >> >>> np.sqrt(15*u.km) > >> WARNING: Converting Quantity object in units 'km' to a Numpy array > >> [astropy.units.quantity] > >> 3.872983346207417 > >> > >> To turn this off, you'll want to set: > >> >>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) > >> >>> np.sqrt(15*u.km) > >> 3.872983346207417 > >> > >> Note that this is documented in the astropy.units.quantity section of > >> the astropy documentation: > >> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types > >> > >> Thanks, > >> Adrian > >> > >> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: > >> > >> > Hi, > >> > > >> > I have just used the constants module in astropy for the first time and > >> > got 6 warnings from my code as a result: > >> > > >> > import astropy.constants as const > >> > AU = const.au.to('km') > >> > > >> > leads to > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > WARNING: Converting Quantity object in units 'km' to a Numpy array > >> > [astropy.units.quantity] > >> > > >> > It seems that I get the warning every place I use the value of AU. Do I > >> > have to turn off warnings to prevent this? Is there some other way to > >> > deal with this? > >> > > >> > Jon > >> > -- > >> > ______________________________________________________________ > >> > Jonathan D. Slavin Harvard-Smithsonian CfA > >> > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > >> > phone: (617) 496-7981 Cambridge, MA 02138-1516 > >> > cell: (781) 363-0035 USA > >> > ______________________________________________________________ > >> > > >> > _______________________________________________ > >> > AstroPy mailing list > >> > AstroPy at scipy.org > >> > http://mail.scipy.org/mailman/listinfo/astropy > >> > >> -- > >> Adrian Price-Whelan > >> Department of Astronomy > >> Columbia University > >> > >> > >> > > > > -- > > ______________________________________________________________ > > Jonathan D. Slavin Harvard-Smithsonian CfA > > jslavin at cfa.harvard.edu 60 Garden Street, MS 83 > > phone: (617) 496-7981 Cambridge, MA 02138-1516 > > cell: (781) 363-0035 USA > > ______________________________________________________________ > > > > _______________________________________________ > > AstroPy mailing list > > AstroPy at scipy.org > > http://mail.scipy.org/mailman/listinfo/astropy > > > > -- > Erik Tollerud -- ______________________________________________________________ Jonathan D. Slavin Harvard-Smithsonian CfA jslavin at cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA ______________________________________________________________ From embray at stsci.edu Fri Mar 22 13:54:41 2013 From: embray at stsci.edu (Erik Bray) Date: Fri, 22 Mar 2013 13:54:41 -0400 Subject: [AstroPy] why the warning about Converting Quantity? In-Reply-To: <1363893770.8743.12.camel@shevek> References: <1363890037.4653.6.camel@shevek> <1F835E06-111A-4D79-B703-D08CE549D665@gmail.com> <1363893770.8743.12.camel@shevek> Message-ID: <514C9AE1.6080704@stsci.edu> Hi Jon, Since nobody else mentioned this I'll chime in. You asked "it'd be nice to have a less cumbersome way of suppressing those warnings". The u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION flag that Adrian mentioned is a configuration option which can be set permanently in your astropy.cfg file. See http://astropy.readthedocs.org/en/latest/configs/index.html#using-config (although admittedly this is non-obvious; perhaps there's still room for improvement in the configuration docs for end-users). In short, find your ~/.astropy/config/astropy.cfg and add [units.quantity] warn_implicit_numeric_conversion = False to permanently disable this warning. But remember, that places the onus on you to be careful about units when converting to types that don't carry the units with them (such as Numpy arrays). Erik On 03/21/2013 03:22 PM, Jonathan Slavin wrote: > Hi Adrian, > > Yes, as I mentioned farther down in my post, the warnings are generated > when I use it in an expression -- with numpy arrays. It'd be nice to > have a less cumbersome way of suppressing those warnings (yes it's just > one line, but not so easy to remember). In fact, I would expect to use > the constants mostly in expressions with numpy arrays, variables, etc. > that don't have units, so my preference would be that by default those > warnings are turned off -- at least for the constants. The constants > are useful for their values alone, though clearly the value of the units > module is to associate units with values. Maybe a simple method like > value.asfloat() could be added that would allow conversion from a units > object to a numpy float. > > Jon > > On Thu, 2013-03-21 at 15:05 -0400, Adrian Price-Whelan wrote: >> Hey Jonathan -- >> >> Are you sure that's the point in the code that's producing the >> warning? What operations are you doing with the AU object? When you >> use the .to() method, it still returns a Quantity object -- *not* the >> value of the original object in those units. If you then stick AU into >> any numpy function, it will work but will just extract the value from >> the object (hence the warning). >> >> See, for example: >> >>>>> import astropy.units as u >>>>> np.sqrt(15*u.km) >> WARNING: Converting Quantity object in units 'km' to a Numpy array >> [astropy.units.quantity] >> 3.872983346207417 >> >> To turn this off, you'll want to set: >>>>> u.quantity.WARN_IMPLICIT_NUMERIC_CONVERSION.set(False) >>>>> np.sqrt(15*u.km) >> 3.872983346207417 >> >> Note that this is documented in the astropy.units.quantity section of >> the astropy documentation: >> http://docs.astropy.org/en/latest/units/quantity.html#converting-to-python-or-numpy-types >> >> Thanks, >> Adrian >> >> On Mar 21, 2013, at 2:20 PM, Jonathan Slavin wrote: >> >>> Hi, >>> >>> I have just used the constants module in astropy for the first time and >>> got 6 warnings from my code as a result: >>> >>> import astropy.constants as const >>> AU = const.au.to('km') >>> >>> leads to >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> WARNING: Converting Quantity object in units 'km' to a Numpy array >>> [astropy.units.quantity] >>> >>> It seems that I get the warning every place I use the value of AU. Do I >>> have to turn off warnings to prevent this? Is there some other way to >>> deal with this? >>> >>> Jon >>> -- >>> ______________________________________________________________ >>> Jonathan D. Slavin Harvard-Smithsonian CfA >>> jslavin at cfa.harvard.edu 60 Garden Street, MS 83 >>> phone: (617) 496-7981 Cambridge, MA 02138-1516 >>> cell: (781) 363-0035 USA >>> ______________________________________________________________ >>> >>> _______________________________________________ >>> AstroPy mailing list >>> AstroPy at scipy.org >>> http://mail.scipy.org/mailman/listinfo/astropy >> >> -- >> Adrian Price-Whelan >> Department of Astronomy >> Columbia University >> >> >> > From aldcroft at head.cfa.harvard.edu Mon Mar 25 12:46:51 2013 From: aldcroft at head.cfa.harvard.edu (Tom Aldcroft) Date: Mon, 25 Mar 2013 12:46:51 -0400 Subject: [AstroPy] Dropping support for Numpy 1.4 in astropy Message-ID: The Astropy project (http://astropy.org) is considering dropping support for Numpy 1.4 in the next (0.3) release. Drivers include: - Masked arrays in 1.4 have a number of issues so that the astropy Table class does not support missing values in numpy 1.4. - Travis-CI cannot build numpy 1.4, so testing this configuration is more difficult. - Numpy 1.4 doesn't build easily on new platforms like Fedora 18. - Numpy 1.7 (and soon 1.7.1) is out, so supporting the most recent 3 releases seems sufficient. If anyone has any objections please raise them now. Cheers, Tom A From ghang.naoc at gmail.com Sun Mar 31 09:43:14 2013 From: ghang.naoc at gmail.com (gonghang.naoc) Date: Sun, 31 Mar 2013 21:43:14 +0800 Subject: [AstroPy] HST photometry Message-ID: Hi guys, Maybe it is not very relevant to the subject here.I am wondering anybody ever done hst photometry here?I have read dolphot's manual but it is too terse.Could anybody give me some quick help on the questions below?I have downloaded c0m and c1m files from stsci. cosmic ray problem:There is a command crrej and it has parameters like dx and dy.The 2 parameters are powerful enough?We should align the images before cosmic ray rejection? If one filter has more than one exposures we can combine the images to do photometry.So it should be which step?After cosmic ray rejection? astrometry problem:It is the last step just before the workhorse of the DOLPHOT package dolphot?DOLPHOT can not deal with that,right?Is there any reliable python way to do that? Any method except dolphot is welcome. Thanks, Hang -------------- next part -------------- An HTML attachment was scrubbed... URL: