From thomas.robitaille at gmail.com Thu Feb 2 08:09:15 2017 From: thomas.robitaille at gmail.com (Thomas Robitaille) Date: Thu, 2 Feb 2017 13:09:15 +0000 Subject: [AstroPy] Help with APLpy In-Reply-To: References: Message-ID: Hi Chika, The make_rgb_image function takes a number of arguments to control the brightness of each band: http://aplpy.readthedocs.io/en/stable/api/aplpy.make_rgb_image.html#aplpy.make_rgb_image e.g. vmin_r, vmax_r and so on. Cheers, Tom On 1 February 2017 at 08:51, Chika Chukwuemeka wrote: > Hello, > > I successfully made a composite-band image of a WISE YSO source using the > make-RGB command in APLpy. However, the source i needed to mark is barely > visible. How do I change the relative intensities of the different bands in > order to bring it out more clearly? I guess it's the blue band which needs > turning up a little. > > Reagards, > Chika > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hodge at stsci.edu Thu Feb 2 11:12:30 2017 From: hodge at stsci.edu (Phil Hodge) Date: Thu, 2 Feb 2017 11:12:30 -0500 Subject: [AstroPy] Help with APLpy In-Reply-To: References: Message-ID: <9817661b-472b-cf51-84a0-937e9e428bf2@stsci.edu> Just FYI, this looks like a typo in the docs: *pmin_r, pmin_r, pmin_g* : float, optional Phil On 02/02/2017 08:09 AM, Thomas Robitaille wrote: > Hi Chika, > > The make_rgb_image function takes a number of arguments to control the > brightness of each band: > > http://aplpy.readthedocs.io/en/stable/api/aplpy.make_rgb_image.html#aplpy.make_rgb_image > > e.g. vmin_r, vmax_r and so on. > > Cheers, > Tom > > > On 1 February 2017 at 08:51, Chika Chukwuemeka > > wrote: > > Hello, > > I successfully made a composite-band image of a WISE YSO source > using the make-RGB command in APLpy. However, the source i needed > to mark is barely visible. How do I change the relative > intensities of the different bands in order to bring it out more > clearly? I guess it's the blue band which needs turning up a little. > > Reagards, > Chika > > > > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy From parejkoj at uw.edu Thu Feb 2 12:47:44 2017 From: parejkoj at uw.edu (John K. Parejko) Date: Thu, 2 Feb 2017 09:47:44 -0800 Subject: [AstroPy] Help with APLpy In-Reply-To: References: Message-ID: <49225EA8-277D-47B7-BB24-F96914921A1B@uw.edu> Though it?s not APLpy, you could try astropy.visualization.make_lupton_rgb (just added in astropy v1.3): http://docs.astropy.org/en/stable/visualization/lupton_rgb.html If you increase the Q parameter, and play with stretch, you might get something that remains astrophysically consistent, while still showing your source of interest. Note that it requires the images be aligned, but you should be able to pass in the results from aplpy?s reprojection. John > On 2Feb 2017, at 05:09, Thomas Robitaille wrote: > > Hi Chika, > > The make_rgb_image function takes a number of arguments to control the brightness of each band: > > http://aplpy.readthedocs.io/en/stable/api/aplpy.make_rgb_image.html#aplpy.make_rgb_image > > e.g. vmin_r, vmax_r and so on. > > Cheers, > Tom > > > On 1 February 2017 at 08:51, Chika Chukwuemeka wrote: > Hello, > > I successfully made a composite-band image of a WISE YSO source using the make-RGB command in APLpy. However, the source i needed to mark is barely visible. How do I change the relative intensities of the different bands in order to bring it out more clearly? I guess it's the blue band which needs turning up a little. > > Reagards, > Chika > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy From boada at physics.rutgers.edu Thu Feb 2 15:52:50 2017 From: boada at physics.rutgers.edu (Steven Boada) Date: Thu, 2 Feb 2017 15:52:50 -0500 Subject: [AstroPy] Help with APLpy In-Reply-To: <49225EA8-277D-47B7-BB24-F96914921A1B@uw.edu> References: <49225EA8-277D-47B7-BB24-F96914921A1B@uw.edu> Message-ID: I'd like to mention that I had some images where making an RGB image particularly difficult. I played with APLpy and the make_lupton_rgb function in astropy withvery poor results. I ended up using STIFF to make some very good looking three color images. I would have much preferred to use python exclusively, but I just couldn't get something that I liked. Check out STIFF, if you are still having trouble. Cheers. steven On 02/02/2017 12:47 PM, John K. Parejko wrote: > Though it?s not APLpy, you could try astropy.visualization.make_lupton_rgb (just added in astropy v1.3): > > http://docs.astropy.org/en/stable/visualization/lupton_rgb.html > > If you increase the Q parameter, and play with stretch, you might get something that remains astrophysically consistent, while still showing your source of interest. Note that it requires the images be aligned, but you should be able to pass in the results from aplpy?s reprojection. > > John > >> On 2Feb 2017, at 05:09, Thomas Robitaille wrote: >> >> Hi Chika, >> >> The make_rgb_image function takes a number of arguments to control the brightness of each band: >> >> http://aplpy.readthedocs.io/en/stable/api/aplpy.make_rgb_image.html#aplpy.make_rgb_image >> >> e.g. vmin_r, vmax_r and so on. >> >> Cheers, >> Tom >> >> >> On 1 February 2017 at 08:51, Chika Chukwuemeka wrote: >> Hello, >> >> I successfully made a composite-band image of a WISE YSO source using the make-RGB command in APLpy. However, the source i needed to mark is barely visible. How do I change the relative intensities of the different bands in order to bring it out more clearly? I guess it's the blue band which needs turning up a little. >> >> Reagards, >> Chika >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> https://mail.scipy.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy -- Steven Boada Postdoctoral Researcher Rutgers University boada at physics.rutgers.edu From dburke.gw at gmail.com Mon Feb 6 08:50:03 2017 From: dburke.gw at gmail.com (Doug Burke) Date: Mon, 06 Feb 2017 13:50:03 +0000 Subject: [AstroPy] ANN: Sherpa v4.9.0 released Message-ID: Dear colleagues, We are very happy to announce the v4.9.0 release of Sherpa, a Python-based fitting and modelling system that has strong support for Astronomy data (in particular, X-ray data). Thanks to Zenodo and GitHub its DOI is http://dx.doi.org/10.5281/zenodo.260416 Thanks to members of the AstroPy community, both for the packages we use in Sherpa and for their investment in time reporting issues, suggesting fixes, and providing code improvements. Development continues at https://github.com/sherpa/sherpa/ and we welcome your continued interest. Release notes are available at https://github.com/sherpa/sherpa/releases/tag/4.9.0 and include improved Python 3.5 support, a significant refactoring of the Fit and Stat classes based on dicussions with our GammaPy colleagues, and a release to PyPi https://pypi.python.org/pypi/sherpa/4.9.0 We provide Linux and OS-X packages for users of the Anaconda Python Distribution, $ conda config --add channels https://conda.binstar.org/sherpa $ conda install sherpa Or source code can be downloaded from https://github.com/sherpa/sherpa/tags Further information can be found at http://cxc.harvard.edu/contrib/sherpa/ and we look forward to any input you have. Please feel free to forward this announcement to anyone who you feel would be interested in this release. For the Sherpa core development team, Doug Burke -------------- next part -------------- An HTML attachment was scrubbed... URL: From aszary at gmail.com Wed Feb 8 10:40:07 2017 From: aszary at gmail.com (Andrzej Szary) Date: Wed, 8 Feb 2017 16:40:07 +0100 Subject: [AstroPy] Ellipse2D fit Message-ID: Hello, I am struggling with fitting an ellipse using Ellipse2D model. The fitting procedure does not seem to have any effect on ellipse parameters (maybe except amplitude). Please find a test code at the end of this email. Best wishes, Andrzej Szary import numpy as np from astropy.modeling import models, fitting import matplotlib.pyplot as pl # data num = 100 x, y = np.meshgrid(np.linspace(-5., 5., num), np.linspace(-5, 5, num)) e0 = models.Ellipse2D(amplitude=1., x_0=0., y_0=0., a=2, b=1, theta=0.) z0 = e0(x, y) print 'DATA:\n', e0, '\n\n' # initial model ei = models.Ellipse2D(amplitude=1., x_0=0.1, y_0=0.1, a=3, b=2, theta=0.2) fi = fitting.LevMarLSQFitter() # fitted model? e1 = fi(ei, x, y, z0) z1 = e1(x, y) print 'MODEL:\n', e1, '\n\n' pl.imshow(z0, extent=[-5, 5, -5, 5], alpha=0.5) pl.imshow(z1, extent=[-5, 5, -5, 5], alpha=0.2) pl.show() -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabricio.ferrari at gmail.com Wed Feb 15 07:14:49 2017 From: fabricio.ferrari at gmail.com (Fabricio Ferrari) Date: Wed, 15 Feb 2017 10:14:49 -0200 Subject: [AstroPy] AstroPy Digest, Vol 125, Issue 4 In-Reply-To: References: Message-ID: Dear Andrzej here it seemed to work. Maybe the version you are using. Here I have: In [2]: np.__version__ Out[2]: '1.11.1' In [4]: astropy.__version__ Out[4]: u'1.2.1' My output: DATA: Model: Ellipse2D Inputs: (u'x', u'y') Outputs: (u'z',) Model set size: 1 Parameters: amplitude x_0 y_0 a b theta --------- --- --- --- --- ----- 1.0 0.0 0.0 2.0 1.0 0.0 MODEL: Model: Ellipse2D Inputs: (u'x', u'y') Outputs: (u'z',) Model set size: 1 Parameters: amplitude x_0 y_0 a b theta -------------- --- --- --- --- ----- 0.338211382114 0.1 0.1 3.0 2.0 0.2 p.s. thank you for letting me know about the Ellipse2D fit, that I indeed need and did not know about. Regards Fabricio ..-. ..-. Fabricio Ferrari [www.ferrari.pro.br] IMEF - FURG Rio Grande, RS Brasil 2017-02-09 10:00 GMT-02:00 : > Send AstroPy mailing list submissions to > astropy at scipy.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.scipy.org/mailman/listinfo/astropy > or, via email, send a message with subject or body 'help' to > astropy-request at scipy.org > > You can reach the person managing the list at > astropy-owner at scipy.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of AstroPy digest..." > > > Today's Topics: > > 1. Ellipse2D fit (Andrzej Szary) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 8 Feb 2017 16:40:07 +0100 > From: Andrzej Szary > To: astropy at scipy.org > Subject: [AstroPy] Ellipse2D fit > Message-ID: > mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hello, > > I am struggling with fitting an ellipse using Ellipse2D model. The fitting > procedure does not seem to have any effect on ellipse parameters (maybe > except amplitude). > > Please find a test code at the end of this email. > > Best wishes, > Andrzej Szary > > > import numpy as np > from astropy.modeling import models, fitting > import matplotlib.pyplot as pl > > # data > num = 100 > x, y = np.meshgrid(np.linspace(-5., 5., num), np.linspace(-5, 5, num)) > e0 = models.Ellipse2D(amplitude=1., x_0=0., y_0=0., a=2, b=1, theta=0.) > z0 = e0(x, y) > print 'DATA:\n', e0, '\n\n' > > # initial model > ei = models.Ellipse2D(amplitude=1., x_0=0.1, y_0=0.1, a=3, b=2, theta=0.2) > fi = fitting.LevMarLSQFitter() > > # fitted model? > e1 = fi(ei, x, y, z0) > z1 = e1(x, y) > print 'MODEL:\n', e1, '\n\n' > > pl.imshow(z0, extent=[-5, 5, -5, 5], alpha=0.5) > pl.imshow(z1, extent=[-5, 5, -5, 5], alpha=0.2) > pl.show() > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: 20170208/dd96824c/attachment-0001.html> > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy > > > ------------------------------ > > End of AstroPy Digest, Vol 125, Issue 4 > *************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aszary at gmail.com Wed Feb 15 07:47:39 2017 From: aszary at gmail.com (Andrzej Szary) Date: Wed, 15 Feb 2017 13:47:39 +0100 Subject: [AstroPy] Ellipse2D fit In-Reply-To: References: Message-ID: Dear Fabricio, Note that the DATA and MODEL parameters are different. For a good fit they should be similar. You can get better results using different fitter (*fi = fitting.SimplexLSQFitter()*), but it is still not good enough for my purpose (I need to find theta parameter). Best wishes Andrzej Szary >> On 15 February 2017 at 13:14, Fabricio Ferrari < fabricio.ferrari at gmail.com> wrote: >> >> Dear Andrzej >> >> here it seemed to work. Maybe the version you are using. >> >> Here I have: >> >>In [2]: np.__version__ >>Out[2]: '1.11.1' >> >>In [4]: astropy.__version__ >>Out[4]: u'1.2.1' >> >>My output: >> >>DATA: >>Model: Ellipse2D >>Inputs: (u'x', u'y') >>Outputs: (u'z',) >>Model set size: 1 >>Parameters: >> amplitude x_0 y_0 a b theta >> --------- --- --- --- --- ----- >> 1.0 0.0 0.0 2.0 1.0 0.0 >> >> >>MODEL: >>Model: Ellipse2D >>Inputs: (u'x', u'y') >>Outputs: (u'z',) >>Model set size: 1 >>Parameters: >> amplitude x_0 y_0 a b theta >> -------------- --- --- --- --- ----- >> 0.338211382114 0.1 0.1 3.0 2.0 0.2 >> >>p.s. thank you for letting me know about the Ellipse2D fit, that I indeed need and did not >>know about. >> >>Regards >>Fabricio On 8 February 2017 at 16:40, Andrzej Szary wrote: > Hello, > > I am struggling with fitting an ellipse using Ellipse2D model. The > fitting procedure does not seem to have any effect on ellipse parameters > (maybe except amplitude). > > Please find a test code at the end of this email. > > Best wishes, > Andrzej Szary > > > import numpy as np > from astropy.modeling import models, fitting > import matplotlib.pyplot as pl > > # data > num = 100 > x, y = np.meshgrid(np.linspace(-5., 5., num), np.linspace(-5, 5, num)) > e0 = models.Ellipse2D(amplitude=1., x_0=0., y_0=0., a=2, b=1, theta=0.) > z0 = e0(x, y) > print 'DATA:\n', e0, '\n\n' > > # initial model > ei = models.Ellipse2D(amplitude=1., x_0=0.1, y_0=0.1, a=3, b=2, theta=0.2) > fi = fitting.LevMarLSQFitter() > > # fitted model? > e1 = fi(ei, x, y, z0) > z1 = e1(x, y) > print 'MODEL:\n', e1, '\n\n' > > pl.imshow(z0, extent=[-5, 5, -5, 5], alpha=0.5) > pl.imshow(z1, extent=[-5, 5, -5, 5], alpha=0.2) > pl.show() > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabricio.ferrari at gmail.com Wed Feb 15 08:07:53 2017 From: fabricio.ferrari at gmail.com (Fabricio Ferrari) Date: Wed, 15 Feb 2017 11:07:53 -0200 Subject: [AstroPy] Ellipse2D fit In-Reply-To: References: Message-ID: yes of course, I did not paid attention. sorry :-D I have been using Fitzgibbon, Pilu and Fischer solution for fitting ellipses, which is states the problem such that it can be written as and eigenvalue equation (it is not iterative). Please, take a look for example at http://nicky.vanforeest.com/misc/fitEllipse/fitEllipse.html The original paper I think it is: http://cseweb.ucsd.edu/~mdailey/Face-Coord/ellipse-specific-fitting.pdf regards. F ..-. ..-. Fabricio Ferrari [www.ferrari.pro.br] IMEF - FURG Rio Grande, RS Brasil 2017-02-15 10:47 GMT-02:00 Andrzej Szary : > Dear Fabricio, > > Note that the DATA and MODEL parameters are different. For a good fit they > should be similar. You can get better results using different fitter (*fi > = fitting.SimplexLSQFitter()*), but it is still not good enough for my > purpose (I need to find theta parameter). > > Best wishes > Andrzej Szary > > > >> On 15 February 2017 at 13:14, Fabricio Ferrari < > fabricio.ferrari at gmail.com> wrote: > >> > >> Dear Andrzej > >> > >> here it seemed to work. Maybe the version you are using. > >> > >> Here I have: > >> > >>In [2]: np.__version__ > >>Out[2]: '1.11.1' > >> > >>In [4]: astropy.__version__ > >>Out[4]: u'1.2.1' > >> > >>My output: > >> > >>DATA: > >>Model: Ellipse2D > >>Inputs: (u'x', u'y') > >>Outputs: (u'z',) > >>Model set size: 1 > >>Parameters: > >> amplitude x_0 y_0 a b theta > >> --------- --- --- --- --- ----- > >> 1.0 0.0 0.0 2.0 1.0 0.0 > >> > >> > >>MODEL: > >>Model: Ellipse2D > >>Inputs: (u'x', u'y') > >>Outputs: (u'z',) > >>Model set size: 1 > >>Parameters: > >> amplitude x_0 y_0 a b theta > >> -------------- --- --- --- --- ----- > >> 0.338211382114 0.1 0.1 3.0 2.0 0.2 > >> > >>p.s. thank you for letting me know about the Ellipse2D fit, that I > indeed need and did not >>know about. > >> > >>Regards > >>Fabricio > > > On 8 February 2017 at 16:40, Andrzej Szary wrote: > >> Hello, >> >> I am struggling with fitting an ellipse using Ellipse2D model. The >> fitting procedure does not seem to have any effect on ellipse parameters >> (maybe except amplitude). >> >> Please find a test code at the end of this email. >> >> Best wishes, >> Andrzej Szary >> >> >> import numpy as np >> from astropy.modeling import models, fitting >> import matplotlib.pyplot as pl >> >> # data >> num = 100 >> x, y = np.meshgrid(np.linspace(-5., 5., num), np.linspace(-5, 5, num)) >> e0 = models.Ellipse2D(amplitude=1., x_0=0., y_0=0., a=2, b=1, theta=0.) >> z0 = e0(x, y) >> print 'DATA:\n', e0, '\n\n' >> >> # initial model >> ei = models.Ellipse2D(amplitude=1., x_0=0.1, y_0=0.1, a=3, b=2, theta=0.2) >> fi = fitting.LevMarLSQFitter() >> >> # fitted model? >> e1 = fi(ei, x, y, z0) >> z1 = e1(x, y) >> print 'MODEL:\n', e1, '\n\n' >> >> pl.imshow(z0, extent=[-5, 5, -5, 5], alpha=0.5) >> pl.imshow(z1, extent=[-5, 5, -5, 5], alpha=0.2) >> pl.show() >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexandre.beelen at ias.u-psud.fr Thu Feb 16 03:39:06 2017 From: alexandre.beelen at ias.u-psud.fr (Alexandre Beelen) Date: Thu, 16 Feb 2017 09:39:06 +0100 Subject: [AstroPy] VO cone-searches Message-ID: <8f7c30d6-74dd-c096-6e3d-d5869cb33f88@ias.u-psud.fr> Hi, Following the documentation [1], I was trying to use the ~astropy.vo.client.vos_catalog.call_vo_service routine to make a conesearch on a list of services which are not present in the default cone search services list, namely a bunch of CDS/Vizier cone search services. Using vos_catalog.VOSCatalog I created a custom database with 3 conesearch services, which I passed to vos_catalog.call_vo_service. However, only the first matching service result is returned, instead of the naively expected 3 results. It seems that this is a built-in feature of call_vo_service [2]. I was wondering if this was a wanted feature or if I could wrap-up a small PR to return a list of ~astropy.Table.table. Similarly ~astroquery returns a custom ~astroquery.utils.commons.TableList ordered list, but I wonder if the equivalent type exist or will exist in astropy.table. Thanks ! a. PS : BTW, would it be better to send an email here or to open an issue on github for this kind of problem ? 1 - http://docs.astropy.org/en/stable/vo/conesearch/client.html 2 - https://github.com/astropy/astropy/blob/master/astropy/vo/client/vos_catalog.py Line 871 From p3y1i4n at gmail.com Fri Feb 17 12:31:56 2017 From: p3y1i4n at gmail.com (Pey Lian Lim) Date: Fri, 17 Feb 2017 12:31:56 -0500 Subject: [AstroPy] VO cone-searches Message-ID: Hi Alexandre, Please open an issue on GitHub. Yes, it is indeed possible but maybe not well advertised. Posting the answer on GitHub will also benefit others in similar situation as yours. The reason that it stops after first successful query is to avoid getting too many unnecessary results, as theoretically you can give a list of hundreds of services to try at once. Thank you, Pey-Lian (conesearch maintainer) -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.sanchez.63 at gmail.com Tue Feb 21 13:52:47 2017 From: bruno.sanchez.63 at gmail.com (=?UTF-8?Q?Bruno_O=2E_S=C3=A1nchez?=) Date: Tue, 21 Feb 2017 18:52:47 +0000 Subject: [AstroPy] Fitting a 2D Gaussian Model Message-ID: Hello! I'm currently playing with the modeling module, using models and fitting, and I have encountered difficulties in how to understand the values of theta that the fit delivers. I'm looping through several ellipticities, and I obtain theta angle values that can bu up to a several hundred, even in negative values. This is the code snippet to fit the gaussians is on this link. http://dpaste.com/3HW8J4Y The output I've got is pasted here: http://dpaste.com/3SJ6DDP Could someone help me to understand why is this happening? As something intesting if I plot the true and fitted gaussian using pyplot.imshow() they look pretty similar. Thanks! -- Bruno -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.bradley at gmail.com Tue Feb 21 15:42:40 2017 From: larry.bradley at gmail.com (Larry Bradley) Date: Tue, 21 Feb 2017 15:42:40 -0500 Subject: [AstroPy] Fitting a 2D Gaussian Model In-Reply-To: References: Message-ID: Hi Bruno, The theta values in the model are not restricted to a particular range (e.g. [0, 179] or [0, 359]). What you are seeing are 180 degree degeneracies of the Gaussian2D model with theta, e.g. theta = -625 is identical to theta = 95 or theta = 275. Also note that there is a more subtle 90 degree degeneracy with theta where the x_stddev and y_stddev are flipped, e.g. x_stddev=10, y_stddev=5, theta=0 is identical to x_stddev=5, y_stddev=10, theta=90. Cheers, Larry On Tue, Feb 21, 2017 at 1:52 PM, Bruno O. S?nchez < bruno.sanchez.63 at gmail.com> wrote: > Hello! > > I'm currently playing with the modeling module, > using models and fitting, and I have encountered difficulties > in how to understand the values of theta that the fit delivers. > > I'm looping through several ellipticities, and I obtain theta angle values > that can bu up to a several hundred, even in negative values. > > This is the code snippet to fit the gaussians is on this link. > http://dpaste.com/3HW8J4Y > > The output I've got is pasted here: > http://dpaste.com/3SJ6DDP > > Could someone help me to understand why is this happening? > As something intesting if I plot the true and fitted gaussian using > pyplot.imshow() > they look pretty similar. > > Thanks! > -- > Bruno > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From parejkoj at uw.edu Thu Feb 23 14:44:13 2017 From: parejkoj at uw.edu (John K. Parejko) Date: Thu, 23 Feb 2017 12:44:13 -0700 Subject: [AstroPy] unit equivalency testing Message-ID: <0BA1EB84-203C-44A1-8BFD-4AAE2DD2DBFA@uw.edu> Hello astropy, I?m looking for a way to check whether astropy units are ?convertible? to each other. For now, asking if the two units have the same physical type is a good start for me (which might be a handy utility method on a quantity: `quantity1.convertible_to(quantity2)`): u.get_physical_type(quantity.unit) == u.get_physical_type(self.unit) but I see that there?s a rich unit equivalency system available. What I?d like is something like `quantity1.equivalent_to(quantity2)`, that returns True/False whether those units are equivalent, based on the defined equivalencies of that unit. Is there such a feature available? Thank you, John From adrianmpw at gmail.com Thu Feb 23 14:57:48 2017 From: adrianmpw at gmail.com (Adrian Price-Whelan) Date: Thu, 23 Feb 2017 14:57:48 -0500 Subject: [AstroPy] unit equivalency testing In-Reply-To: <0BA1EB84-203C-44A1-8BFD-4AAE2DD2DBFA@uw.edu> References: <0BA1EB84-203C-44A1-8BFD-4AAE2DD2DBFA@uw.edu> Message-ID: I think what you want is "is_equivalent()": >>> import astropy.units as u >>> a = 15*u.kpc >>> a.unit.is_equivalent(u.km) True >>> a = 15*u.Hz >>> a.unit.is_equivalent(u.Angstrom, equivalencies=u.spectral()) True Right now, it's just a method on UnitBase objects, but it might make sense to add a convenience method on Quantity as well... On Thu, Feb 23, 2017 at 2:44 PM, John K. Parejko wrote: > Hello astropy, > > I?m looking for a way to check whether astropy units are ?convertible? to each other. For now, asking if the two units have the same physical type is a good start for me (which might be a handy utility method on a quantity: `quantity1.convertible_to(quantity2)`): > > u.get_physical_type(quantity.unit) == u.get_physical_type(self.unit) > > but I see that there?s a rich unit equivalency system available. What I?d like is something like `quantity1.equivalent_to(quantity2)`, that returns True/False whether those units are equivalent, based on the defined equivalencies of that unit. Is there such a feature available? > > Thank you, > John > > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy -- Adrian M. Price-Whelan Lyman Spitzer, Jr. Postdoctoral Fellow Princeton University http://adrian.pw From parejkoj at uw.edu Thu Feb 23 16:48:36 2017 From: parejkoj at uw.edu (John K. Parejko) Date: Thu, 23 Feb 2017 14:48:36 -0700 Subject: [AstroPy] unit equivalency testing In-Reply-To: References: <0BA1EB84-203C-44A1-8BFD-4AAE2DD2DBFA@uw.edu> Message-ID: <976E574F-9CA4-4E97-A4C9-FF362BFE2A9A@uw.edu> Ah, perfect! I don?t know how I missed that. Thank you! Making a convenience method on Quantity would be helpful. Heck, here?s a hastily-written PR that implements it: https://github.com/astropy/astropy/pull/5836 John > On 23Feb 2017, at 12:57, Adrian Price-Whelan wrote: > > I think what you want is "is_equivalent()": > >>>> import astropy.units as u >>>> a = 15*u.kpc >>>> a.unit.is_equivalent(u.km) > True >>>> a = 15*u.Hz >>>> a.unit.is_equivalent(u.Angstrom, equivalencies=u.spectral()) > True > > Right now, it's just a method on UnitBase objects, but it might make > sense to add a convenience method on Quantity as well... > > On Thu, Feb 23, 2017 at 2:44 PM, John K. Parejko wrote: >> Hello astropy, >> >> I?m looking for a way to check whether astropy units are ?convertible? to each other. For now, asking if the two units have the same physical type is a good start for me (which might be a handy utility method on a quantity: `quantity1.convertible_to(quantity2)`): >> >> u.get_physical_type(quantity.unit) == u.get_physical_type(self.unit) >> >> but I see that there?s a rich unit equivalency system available. What I?d like is something like `quantity1.equivalent_to(quantity2)`, that returns True/False whether those units are equivalent, based on the defined equivalencies of that unit. Is there such a feature available? >> >> Thank you, >> John >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at scipy.org >> https://mail.scipy.org/mailman/listinfo/astropy > > > > -- > Adrian M. Price-Whelan > Lyman Spitzer, Jr. Postdoctoral Fellow > Princeton University > http://adrian.pw > _______________________________________________ > AstroPy mailing list > AstroPy at scipy.org > https://mail.scipy.org/mailman/listinfo/astropy