From hg.dude.hg at gmail.com Thu Jan 7 13:33:56 2021 From: hg.dude.hg at gmail.com (Dominik Rhiem) Date: Thu, 7 Jan 2021 19:33:56 +0100 Subject: [AstroPy] Image reprojection and counts Message-ID: Dear all, I am planning to use the reproject_interp function to rescale several fits images of different clusters in such a way that after the reprojection, the maps have the same number of pixels and the same size in terms of R500/Theta500 for the specific cluster; this means that the pixel size in arcsec will depend on the cluster after the rescaling. However, the flux information contained in the maps is scaled by the pixel size; before the rescaling, each pixel contains counts with the units mJy per pixel area [arcsec**2]. Does the function reproject_interp take this into account or should I multiply the maps with the pixel area before rescaling? If anything about this is unclear, please let me know. Sincerely, Dominik Rhiem -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivvv68 at gmail.com Fri Jan 8 03:58:17 2021 From: ivvv68 at gmail.com (Ivan Valtchanov) Date: Fri, 8 Jan 2021 09:58:17 +0100 Subject: [AstroPy] Image reprojection and counts In-Reply-To: References: Message-ID: Hi Dominik, I would suggest you to do generate some toy models and test the behaviour. You can generate images with e.g. Gaussian clusters and then reproject and check the counts after reprojection. Additionally you could also check the radial profile, just to be sure the reprojection does not introduce any undesired side effects. Just an idea. Cheers, Ivan V On Thu, 7 Jan 2021 at 19:34, Dominik Rhiem wrote: > > Dear all, > > I am planning to use the reproject_interp function to rescale several fits images of different clusters in such a way that after the reprojection, the maps have the same number of pixels and the same size in terms of R500/Theta500 for the specific cluster; this means that the pixel size in arcsec will depend on the cluster after the rescaling. > However, the flux information contained in the maps is scaled by the pixel size; before the rescaling, each pixel contains counts with the units mJy per pixel area [arcsec**2]. Does the function reproject_interp take this into account or should I multiply the maps with the pixel area before rescaling? > If anything about this is unclear, please let me know. > > Sincerely, > Dominik Rhiem > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From adam.g.ginsburg at gmail.com Fri Jan 8 08:57:33 2021 From: adam.g.ginsburg at gmail.com (Adam Ginsburg) Date: Fri, 8 Jan 2021 08:57:33 -0500 Subject: [AstroPy] Image reprojection and counts In-Reply-To: References: Message-ID: Hi Dominik, You will need to rescale when you change the pixel size, since changing the pixel size is changing the (implicit) unit. This is a tricky problem that always gets me when I work with Jy/pixel (when interpolating) or Jy/beam (when smoothing) units. If you convert to Jy/arcsec^2 or MJy/sr, making the unit explicit, then no additional scaling should be needed. On Fri, Jan 8, 2021 at 3:58 AM Ivan Valtchanov wrote: > Hi Dominik, > > I would suggest you to do generate some toy models and test the > behaviour. You can generate images with e.g. Gaussian clusters and > then reproject and check the counts after reprojection. Additionally > you could also check the radial profile, just to be sure the > reprojection does not introduce any undesired side effects. Just an > idea. > > Cheers, > Ivan V > > On Thu, 7 Jan 2021 at 19:34, Dominik Rhiem wrote: > > > > Dear all, > > > > I am planning to use the reproject_interp function to rescale several > fits images of different clusters in such a way that after the > reprojection, the maps have the same number of pixels and the same size in > terms of R500/Theta500 for the specific cluster; this means that the pixel > size in arcsec will depend on the cluster after the rescaling. > > However, the flux information contained in the maps is scaled by the > pixel size; before the rescaling, each pixel contains counts with the units > mJy per pixel area [arcsec**2]. Does the function reproject_interp take > this into account or should I multiply the maps with the pixel area before > rescaling? > > If anything about this is unclear, please let me know. > > > > Sincerely, > > Dominik Rhiem > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -- Adam Ginsburg Assistant Professor, Department of Astronomy University of Florida, Gainesville http://www.adamgginsburg.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From alberto.manfreda at pi.infn.it Fri Jan 15 11:45:41 2021 From: alberto.manfreda at pi.infn.it (Alberto) Date: Fri, 15 Jan 2021 17:45:41 +0100 Subject: [AstroPy] Adding a column to a FITS binary HDU Message-ID: <2839e613-6491-91df-a75b-365ae62c851a@pi.infn.it> Hi, despite I have been using astropy.io for a few years now, this is my first message to the list (which speaks highly of the quality of the module and of the documentation - great job, really!). Recently, however, I found myself stuck doing an apparently simple task. I have a FITS file containing a bunch of binary HDU tables, which I open with the: hdu_list = open_event_file('/file_path/') command. I need to add a new column to one of the HDU tables, then write the entire hdu_list to a different file location. What is the simplest way to do this? The methods for adding columns that I found in the online FAQs work for Table objects, but what I can get from my hdu_list is a BinTableHDU object, which doesn't support dictionary-like assignment or the add_column() method. I know I can get a Table object from the hdu_list like this: table = Table(hdu_list[1].data) but this is a copy, so the changes to the table does not apply to the original hdu_list. Any help is appreciated. Kind Regards Alberto -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Sat Jan 16 13:04:19 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Sat, 16 Jan 2021 19:04:19 +0100 Subject: [AstroPy] Adding a column to a FITS binary HDU In-Reply-To: <2839e613-6491-91df-a75b-365ae62c851a@pi.infn.it> References: <2839e613-6491-91df-a75b-365ae62c851a@pi.infn.it> Message-ID: On Fri, Jan 15, 2021 at 5:55 PM Alberto wrote: > > Hi, > > despite I have been using astropy.io for a few years now, this is my first message to the list (which speaks highly of the quality of the module and of the documentation - great job, really!). Recently, however, I found myself stuck doing an apparently simple task. I have a FITS file containing a bunch of binary HDU tables, which I open with the: > > hdu_list = open_event_file('file_path') > > command. I need to add a new column to one of the HDU tables, then write the entire hdu_list to a different file location. > > What is the simplest way to do this? The methods for adding columns that I found in the online FAQs work for Table objects, but what I can get from my hdu_list is a BinTableHDU object, which doesn't support dictionary-like assignment or the add_column() method. I know I can get a Table object from the hdu_list like this: > > table = Table(hdu_list[1].data) > > but this is a copy, so the changes to the table does not apply to the original hdu_list. > > Any help is appreciated. Hi Alberto, The `data` arrays accessible on the HDU objects are basically Numpy structured arrays, so techniques and utilities for adding a column to a structured array apply here, though unfortunately it's not as easy as one would like. Fortunately, newer versions of Numpy have added a few utility functions for this; in this case in particular numpy.lib.recfunctions.append_fields: https://numpy.org/doc/stable/user/basics.rec.html#numpy.lib.recfunctions.append_fields So you should be able to add a column like: >>> from numpy.lib.recfunctions import append_fields >>> hdu = hdu_list[1] >>> hdu.data = append_fields(hdu.data, 'NAME_OF_COLUMN', column_data, usemask=False) I tested that this works (it's a bit annoying that it returns a masked array by default so you need to give usemask=False) for this to work. In principle you should also be able to use Table.add_column with the Table class as you mentioned. Then you can do: >>> hdul_list[1].data = table.as_array() Unfortunately this has a bug related to string columns that I just discovered in testing this. I'm sorry that even now this is not as easy to do as it should be. For the most part the Table class has obviated the need for anything like this in the "lower-level" interface, but I agree it's not obvious how to do if you want to manipulate existing FITS files. Madison From alberto.manfreda at pi.infn.it Sat Jan 16 16:38:38 2021 From: alberto.manfreda at pi.infn.it (Alberto) Date: Sat, 16 Jan 2021 22:38:38 +0100 Subject: [AstroPy] Adding a column to a FITS binary HDU In-Reply-To: References: <2839e613-6491-91df-a75b-365ae62c851a@pi.infn.it> Message-ID: <237a6cfa-c221-9336-d6ff-420c34d1005e@pi.infn.it> Worked like a charm. Thank you very much! Alberto On 16/01/21 19:04, E. Madison Bray wrote: > On Fri, Jan 15, 2021 at 5:55 PM Alberto wrote: >> Hi, >> >> despite I have been using astropy.io for a few years now, this is my first message to the list (which speaks highly of the quality of the module and of the documentation - great job, really!). Recently, however, I found myself stuck doing an apparently simple task. I have a FITS file containing a bunch of binary HDU tables, which I open with the: >> >> hdu_list = open_event_file('file_path') >> >> command. I need to add a new column to one of the HDU tables, then write the entire hdu_list to a different file location. >> >> What is the simplest way to do this? The methods for adding columns that I found in the online FAQs work for Table objects, but what I can get from my hdu_list is a BinTableHDU object, which doesn't support dictionary-like assignment or the add_column() method. I know I can get a Table object from the hdu_list like this: >> >> table = Table(hdu_list[1].data) >> >> but this is a copy, so the changes to the table does not apply to the original hdu_list. >> >> Any help is appreciated. > Hi Alberto, > > The `data` arrays accessible on the HDU objects are basically Numpy > structured arrays, so techniques and utilities for adding a column to > a structured array apply here, though unfortunately it's not as easy > as one would like. Fortunately, newer versions of Numpy have added a > few utility functions for this; in this case in particular > numpy.lib.recfunctions.append_fields: > https://numpy.org/doc/stable/user/basics.rec.html#numpy.lib.recfunctions.append_fields > > So you should be able to add a column like: > >>>> from numpy.lib.recfunctions import append_fields >>>> hdu = hdu_list[1] >>>> hdu.data = append_fields(hdu.data, 'NAME_OF_COLUMN', column_data, usemask=False) > I tested that this works (it's a bit annoying that it returns a masked > array by default so you need to give usemask=False) for this to work. > > In principle you should also be able to use Table.add_column with the > Table class as you mentioned. Then you can do: > >>>> hdul_list[1].data = table.as_array() > Unfortunately this has a bug related to string columns that I just > discovered in testing this. > > I'm sorry that even now this is not as easy to do as it should be. > For the most part the Table class has obviated the need for anything > like this in the "lower-level" interface, but I agree it's not obvious > how to do if you want to manipulate existing FITS files. > > Madison > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From manupu08 at gmail.com Wed Jan 20 13:11:36 2021 From: manupu08 at gmail.com (Emanuella Puddu) Date: Wed, 20 Jan 2021 19:11:36 +0100 Subject: [AstroPy] help with SkyCoord Message-ID: Hi everyone! I have to draw a circle around an object's center, a circle made of points which have the same distance from the object. This all in spherical projection on the sky (package SkyCoord). Does anyone have an idea about how this can be done? Many thanks in advance for the help ... -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivvv68 at gmail.com Wed Jan 20 17:27:54 2021 From: ivvv68 at gmail.com (Ivan Valtchanov) Date: Wed, 20 Jan 2021 23:27:54 +0100 Subject: [AstroPy] help with SkyCoord In-Reply-To: References: Message-ID: Hi Emmanuella, Have a look at astropy regions package: https://astropy-regions.readthedocs.io/en/latest/ hope this helps, Ivan On Wed, 20 Jan 2021 at 19:11, Emanuella Puddu wrote: > > Hi everyone! > I have to draw a circle around an object's center, a circle made of points which have the same distance from the object. This all in spherical projection on the sky (package SkyCoord). Does anyone have an idea about how this can be done? > Many thanks in advance for the help ... > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From m.shemuni at gmail.com Thu Jan 21 02:22:24 2021 From: m.shemuni at gmail.com (Mohammad Shameoni Niaei) Date: Thu, 21 Jan 2021 10:22:24 +0300 Subject: [AstroPy] help with SkyCoord In-Reply-To: References: Message-ID: Hello Emmanuella. Thank you for sending this question. I found it challenging. As Ivan suggested, I tried to understand regions, CircleSkyRegion and find the boundaries to no avail. I even tried to solve the angular distance equation for known one coordinates and distance. That failed too. But I think I have a solution. We can use Vectors for this problem. Let's say we have a vector (v1) pointed to x, y, z (Spherical form would be r, theta, phi. Where theta and phi is our reference point and r can be anything but better to be 1.) We can create another vector (v2) with angular distance of your R (Where R is your radius) and rotate the v2 about v1. see: stackexchange I once created a simple Vector library, which is installable with pip, named v3d . You can easily do the same calculations with numpy if v3d is bugged or is not trustable enough for you. An example is in attachment Links: angular distance equation: https://en.wikipedia.org/wiki/Angular_distance#Equation stackexchange: https://math.stackexchange.com/questions/511370/how-to-rotate-one-vector-about-another v3d: https://pypi.org/project/v3d/ On Thu, Jan 21, 2021 at 1:28 AM Ivan Valtchanov wrote: > Hi Emmanuella, > > Have a look at astropy regions package: > https://astropy-regions.readthedocs.io/en/latest/ > > hope this helps, > Ivan > > On Wed, 20 Jan 2021 at 19:11, Emanuella Puddu wrote: > > > > Hi everyone! > > I have to draw a circle around an object's center, a circle made of > points which have the same distance from the object. This all in spherical > projection on the sky (package SkyCoord). Does anyone have an idea about > how this can be done? > > Many thanks in advance for the help ... > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -- Mohammad Shameoni Niaei Astronomer Atat?rk University, Astrophysics Research and Application Center. ERZURUM-TURKEY -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sky_circle.py Type: text/x-python Size: 731 bytes Desc: not available URL: From ivvv68 at gmail.com Thu Jan 21 03:03:03 2021 From: ivvv68 at gmail.com (Ivan Valtchanov) Date: Thu, 21 Jan 2021 09:03:03 +0100 Subject: [AstroPy] help with SkyCoord In-Reply-To: References: Message-ID: I may have misunderstood what was the goal. So, in this case you may try with centre.directional_offset_by(phi,theta) method in SkyCoord. You fix the centre and the offset and calculate the SkyCoord for points in a range of azimuth angles phi. At each phi yu will have a new SkyCoord. Cheers, Ivan On Thu, 21 Jan 2021 at 08:22, Mohammad Shameoni Niaei wrote: > > Hello Emmanuella. > > Thank you for sending this question. I found it challenging. > > As Ivan suggested, I tried to understand regions, CircleSkyRegion and find the boundaries to no avail. > I even tried to solve the angular distance equation for known one coordinates and distance. That failed too. > > But I think I have a solution. We can use Vectors for this problem. Let's say we have a vector (v1) pointed to x, y, z (Spherical form would be r, theta, phi. Where theta and phi is our reference point and r can be anything but better to be 1.) We can create another vector (v2) with angular distance of your R (Where R is your radius) and rotate the v2 about v1. see: stackexchange > > I once created a simple Vector library, which is installable with pip, named v3d . > > You can easily do the same calculations with numpy if v3d is bugged or is not trustable enough for you. > > An example is in attachment > > Links: > angular distance equation: https://en.wikipedia.org/wiki/Angular_distance#Equation > stackexchange: https://math.stackexchange.com/questions/511370/how-to-rotate-one-vector-about-another > v3d: https://pypi.org/project/v3d/ > > On Thu, Jan 21, 2021 at 1:28 AM Ivan Valtchanov wrote: >> >> Hi Emmanuella, >> >> Have a look at astropy regions package: >> https://astropy-regions.readthedocs.io/en/latest/ >> >> hope this helps, >> Ivan >> >> On Wed, 20 Jan 2021 at 19:11, Emanuella Puddu wrote: >> > >> > Hi everyone! >> > I have to draw a circle around an object's center, a circle made of points which have the same distance from the object. This all in spherical projection on the sky (package SkyCoord). Does anyone have an idea about how this can be done? >> > Many thanks in advance for the help ... >> > _______________________________________________ >> > AstroPy mailing list >> > AstroPy at python.org >> > https://mail.python.org/mailman/listinfo/astropy >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy > > > > -- > Mohammad Shameoni Niaei > Astronomer > Atat?rk University, Astrophysics Research and Application Center. > ERZURUM-TURKEY > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From evangelia.sam at gmail.com Fri Jan 22 11:04:08 2021 From: evangelia.sam at gmail.com (Evangelia Samara) Date: Fri, 22 Jan 2021 17:04:08 +0100 Subject: [AstroPy] question about coordinate transformation Message-ID: Dear, I am writing this email because I deal with a very peculiar problem (at least, peculiar for me!). I want to transform my coordinates from heliographic_stonyhurst to heliographic_carrington in python 3, as follows: import astropy.units as u from astropy.coordinates import SkyCoord from sunpy.coordinates import frames c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00', frame=frames.HeliographicStonyhurst ) d = c.transform_to(frames.HeliographicCarrington) But I get the error: ConvertError: This transformation cannot be performed because the HeliographicCarrington frame has observer=None. The observer should not be "None" since I define the "obstime" parameter above. Could you please explain me why this happens and how it should be fixed? BTW, it runs fine with Python 2 if i change "obstime" to "dateobs". Thank you in advance, Evangelia -------------- next part -------------- An HTML attachment was scrubbed... URL: From manupu08 at gmail.com Fri Jan 22 17:56:20 2021 From: manupu08 at gmail.com (Emanuella Puddu) Date: Fri, 22 Jan 2021 23:56:20 +0100 Subject: [AstroPy] help with SkyCoord In-Reply-To: References: Message-ID: Thank you Ivan, your last suggestion should work, but I don't have the "directional_offset_by()" method of SkyCoord in my astropy version (2.0.2). Therefore, I build a grid of SkyCoord objects, I compute the "separation" between the centre and each point of the grid, and then I only select and plot the points with separation equal to the radius (within a tolerance range). E. Il giorno gio 21 gen 2021 alle ore 09:03 Ivan Valtchanov ha scritto: > I may have misunderstood what was the goal. > > So, in this case you may try with > centre.directional_offset_by(phi,theta) method in SkyCoord. You fix > the centre and the offset and calculate the SkyCoord for points in a > range of azimuth angles phi. At each phi yu will have a new SkyCoord. > > Cheers, > Ivan > > On Thu, 21 Jan 2021 at 08:22, Mohammad Shameoni Niaei > wrote: > > > > Hello Emmanuella. > > > > Thank you for sending this question. I found it challenging. > > > > As Ivan suggested, I tried to understand regions, CircleSkyRegion and > find the boundaries to no avail. > > I even tried to solve the angular distance equation for known one > coordinates and distance. That failed too. > > > > But I think I have a solution. We can use Vectors for this problem. > Let's say we have a vector (v1) pointed to x, y, z (Spherical form would be > r, theta, phi. Where theta and phi is our reference point and r can be > anything but better to be 1.) We can create another vector (v2) with > angular distance of your R (Where R is your radius) and rotate the v2 about > v1. see: stackexchange > > > > I once created a simple Vector library, which is installable with pip, > named v3d . > > > > You can easily do the same calculations with numpy if v3d is bugged or > is not trustable enough for you. > > > > An example is in attachment > > > > Links: > > angular distance equation: > https://en.wikipedia.org/wiki/Angular_distance#Equation > > stackexchange: > https://math.stackexchange.com/questions/511370/how-to-rotate-one-vector-about-another > > v3d: https://pypi.org/project/v3d/ > > > > On Thu, Jan 21, 2021 at 1:28 AM Ivan Valtchanov > wrote: > >> > >> Hi Emmanuella, > >> > >> Have a look at astropy regions package: > >> https://astropy-regions.readthedocs.io/en/latest/ > >> > >> hope this helps, > >> Ivan > >> > >> On Wed, 20 Jan 2021 at 19:11, Emanuella Puddu > wrote: > >> > > >> > Hi everyone! > >> > I have to draw a circle around an object's center, a circle made of > points which have the same distance from the object. This all in spherical > projection on the sky (package SkyCoord). Does anyone have an idea about > how this can be done? > >> > Many thanks in advance for the help ... > >> > _______________________________________________ > >> > AstroPy mailing list > >> > AstroPy at python.org > >> > https://mail.python.org/mailman/listinfo/astropy > >> _______________________________________________ > >> AstroPy mailing list > >> AstroPy at python.org > >> https://mail.python.org/mailman/listinfo/astropy > > > > > > > > -- > > Mohammad Shameoni Niaei > > Astronomer > > Atat?rk University, Astrophysics Research and Application Center. > > ERZURUM-TURKEY > > _______________________________________________ > > AstroPy mailing list > > AstroPy at python.org > > https://mail.python.org/mailman/listinfo/astropy > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From osleandra at hotmail.com Fri Jan 22 18:33:39 2021 From: osleandra at hotmail.com (Osmara Leandra) Date: Fri, 22 Jan 2021 23:33:39 +0000 Subject: [AstroPy] Collaborate to OpenAstronomy Message-ID: Hi! My name is Osmara, I'm from Brazil, I started studying Big Data and Artificial Intelligence and I would like to contribute in some way to OpenAstronomy. I am initially interested in Python and Documentation. How can I get started? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Mon Jan 25 04:48:51 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Mon, 25 Jan 2021 10:48:51 +0100 Subject: [AstroPy] question about coordinate transformation In-Reply-To: References: Message-ID: On Fri, Jan 22, 2021 at 5:04 PM Evangelia Samara wrote: > > Dear, > > I am writing this email because I deal with a very peculiar problem (at least, peculiar for me!). > I want to transform my coordinates from heliographic_stonyhurst to heliographic_carrington in python 3, as follows: > > import astropy.units as u > from astropy.coordinates import SkyCoord > from sunpy.coordinates import frames > > c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00', frame=frames.HeliographicStonyhurst ) > d = c.transform_to(frames.HeliographicCarrington) > > But I get the error: > > ConvertError: This transformation cannot be performed because the HeliographicCarrington frame has observer=None. > > The observer should not be "None" since I define the "obstime" parameter above. Could you please explain me why this happens and how it should be fixed? Hi Evangelina, I'm not a SunPy expert so hopefully someone else can chime in with more details, but I read in the changelog for SunPy 2.0 [1] : > ~sunpy.coordinates.frames.HeliographicCarrington is now an observer-based frame, where the observer location (specifically, the distance from the Sun) is used to account for light travel time when determining apparent Carrington longitudes. Coordinate transformations using this frame now require an observer to be specified. (#3782) If you look up issue #3782 there are more details too, as well as additions to the documentation about this. But in short, something like this seems to work: >>> c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00', frame=frames.HeliographicStonyhurst, observer='earth') >>> d = c.transform_to(frames.HeliographicCarrington) >>> d ): (lon, lat, radius) in (deg, deg, km) (23.09482023, 0., 695700.)> > BTW, it runs fine with Python 2 if i change "obstime" to "dateobs". As a general note (since it may help you in finding solutions in the future) you will usually find it more useful to think of this not as a Python 2 vs Python 3 comparison, but rather check the versions of the libraries you're using. Although neither Astropy nor SunPy still support Python 2 in newer versions, when they did they strove to keep the code compatible between 2 and 3, so you would not see radical API differences depending on which Python version you're using *if* you're using the same version of SunPy. More likely, your Python 2 installation had an older version of SunPy. Probably pre-v0.8 since the changelog for v0.8 [2] says: > The time attribute for SunPy coordinate frames has been renamed from dateobs to obstime. TL;DR you can check the version like >>> import sunpy >>> sunpy.__version__ '2.0.7' and likewise for Astropy. This will usually be more interesting to compare. Then if there are apparently differences you can try to look up in the changelog why something appears to work differently between versions (which admittedly is not always clear even from the changelog, but sometimes it can help). Best, Madison [1] https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#backwards-incompatible-changes [2] https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#new-features-1 From evangelia.sam at gmail.com Tue Jan 26 10:21:03 2021 From: evangelia.sam at gmail.com (Evangelia Samara) Date: Tue, 26 Jan 2021 16:21:03 +0100 Subject: [AstroPy] question about coordinate transformation In-Reply-To: References: Message-ID: Dear Madison, Thank you very much for your detailed answer! I really appreciate it :) Everything is clear now and make more sense! Cheers, Evangelia On Mon, Jan 25, 2021 at 10:49 AM E. Madison Bray wrote: > On Fri, Jan 22, 2021 at 5:04 PM Evangelia Samara > wrote: > > > > Dear, > > > > I am writing this email because I deal with a very peculiar problem (at > least, peculiar for me!). > > I want to transform my coordinates from heliographic_stonyhurst to > heliographic_carrington in python 3, as follows: > > > > import astropy.units as u > > from astropy.coordinates import SkyCoord > > from sunpy.coordinates import frames > > > > c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00', > frame=frames.HeliographicStonyhurst ) > > d = c.transform_to(frames.HeliographicCarrington) > > > > But I get the error: > > > > ConvertError: This transformation cannot be performed because the > HeliographicCarrington frame has observer=None. > > > > The observer should not be "None" since I define the "obstime" parameter > above. Could you please explain me why this happens and how it should be > fixed? > > > Hi Evangelina, > > I'm not a SunPy expert so hopefully someone else can chime in with > more details, but I read in the changelog for SunPy 2.0 [1] : > > > ~sunpy.coordinates.frames.HeliographicCarrington is now an > observer-based frame, where the observer location (specifically, the > distance from the Sun) is used to account for light travel time when > determining apparent Carrington longitudes. Coordinate transformations > using this frame now require an observer to be specified. (#3782) > > If you look up issue #3782 there are more details too, as well as > additions to the documentation about this. But in short, something > like this seems to work: > > >>> c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00', > frame=frames.HeliographicStonyhurst, observer='earth') > >>> d = c.transform_to(frames.HeliographicCarrington) > >>> d > observer=): (lon, lat, > radius) in (deg, deg, km) > (23.09482023, 0., 695700.)> > > > > BTW, it runs fine with Python 2 if i change "obstime" to "dateobs". > > As a general note (since it may help you in finding solutions in the > future) you will usually find it more useful to think of this not as a > Python 2 vs Python 3 comparison, but rather check the versions of the > libraries you're using. Although neither Astropy nor SunPy still > support Python 2 in newer versions, when they did they strove to keep > the code compatible between 2 and 3, so you would not see radical API > differences depending on which Python version you're using *if* you're > using the same version of SunPy. More likely, your Python 2 > installation had an older version of SunPy. Probably pre-v0.8 since > the changelog for v0.8 [2] says: > > > The time attribute for SunPy coordinate frames has been renamed from > dateobs to obstime. > > TL;DR you can check the version like > > >>> import sunpy > >>> sunpy.__version__ > '2.0.7' > > and likewise for Astropy. This will usually be more interesting to > compare. Then if there are apparently differences you can try to look > up in the changelog why something appears to work differently between > versions (which admittedly is not always clear even from the > changelog, but sometimes it can help). > > Best, > Madison > > > [1] > https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#backwards-incompatible-changes > [2] > https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#new-features-1 > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hjyanghj at gmail.com Wed Jan 27 09:05:40 2021 From: hjyanghj at gmail.com (Yang Hon-Jang) Date: Wed, 27 Jan 2021 22:05:40 +0800 Subject: [AstroPy] consistency of reference frames between SkyCoord and JPL Horizons In-Reply-To: References: Message-ID: I think your problem is nothing to do with astropy, nothing to do with coordinate transform, GCRS, ICRS.... Explained below, if following paragraphs are hard for reading, please see attached notebook. ## section 1 In astronomy, we see object/star at where it WAS not now it IS due to light travel time. Given $f(t), g(t)$, cartesian coordinate position functions of observer, target respectively in some coordinate system, then $h(t)=g(t)-f(t)$ is target's relative position. When observer observe target, observer see target at target's previous position(at $t-\delta_t$ due to light travel time). $t$ and $\delta_t$ satisfy equation $$ \frac{||h(t-\delta_t)||}{c}=\delta_t$$ where c is speed of light. If $t$ is fixed, we can solve $\delta_t$, then observer(at time $t$) observe target at $h(t-\delta_t)$ location. ## section 2 Suppose given only $g(t_0)$ at fixed $t_0$, even we know whole $f(t)$ function, we can't compute which direction we can see the target at $t_0$. ## section 3 In your senario, the task(using [position of an asteroid **at one epoch**] to compute its astrometric position) is impossible as stated above. Nothing to do with coordinate transform. On Fri, Apr 24, 2020 at 9:09 PM Paolo Tanga wrote: > > Hi all > > I am trying to plug the results by JPL Horizons into the appropriate > reference system of a SkyCoord object, but it looks very trick. (bewore > long message, I hope the explanation is clear for the specialists of > reference systems) > > The Horizons server returns two types of equatorial coordinates: > "astrometric" (1) and (2) "apparent". > > Their description is the following: > > - (1): astrometric RA and Dec with respect to the observing site > (coordinate origin) in the reference frame of > the planetary ephemeris (ICRF). Compensated for down-leg light-time > delay aberration. > > - (2): Airless apparent RA and Dec of the target with respect to an > instantaneous reference frame defined by the Earth equator of-date > (z-axis) and meridian containing the Earth equinox of-date (x-axis, > IAU76/80). Compensated for down-leg light-time delay, gravitational > deflection of light, stellar aberration, precession & nutation. Note: > equinox (RA origin) is offset -53 mas from the of-date frame defined by > the IAU06/00a P & N system. > > My guess is none of these two systems correspond to either ICRS or GCRS > as defined in astropy. The simplest possibility for me, would have been > to assimilate (1), computed for the Solar System barycenter, to ICRS. > But definitely (2) is not GCRS and the test below easily proves that. > > Verification (see the attached notebook if you want to play with) : > > - I queried for Solar System barycentric coordinates (1) of an asteroid > at one epoch. I inserted them in a SkyCoord object as ICRS and use the > transform_to(GCRS) towards geocentric, at the given epoch. > > - I queried again JPL Horizons for the apparent coordinates (2) from the > geocenter, directly. > > As expected, by comparing the results I get the patent confirmation that > GCRS is not the frame of (2), with a discrepancy of 16 arcmin in my > case. SO, IT DOES NOT WORK, AS EXPECTED. Let's put apparent coordinates > (2) aside for the moment. > > Second possibility (see notebook again). > > I take coordinates (1), for the geocentric observer. I insert them as > GCRS in a SkyCoord object. I trasform_to(ICRS) (barycentric observer) > and compare the result to a query of (1) directly for the barycentric > observer. > > Again this SHOULD NOT WORK accurately. In fact the definition of (1) > does not contain annual aberration and light deflection that are part of > GCRS. A difference of several arcsec (mostly due to annual aberration) > SHOULD show up. And in fact IT DOES, ~8 arcsec of difference. > > The conclusions if that using SkyCoord with the output of JPL Horizons > is far from obvious to the end user... > > ---- > > So, my final questions/remarks are: > > - How to get a fully accurate consistency between a SkyCoord frame and > JPL Horizons output, in the case of a barycentric, geocentric or > topocentric observer, for both "astrometric" and "apparent" coordinates > as provided by JPL? Which reference SkyCoord should use and how? > > - Does astropy implement GCRS correctly in the case of Solar System > objects, by taking into account aberration and light deflection in the > relativistic form, for an object at finite distance (different than for > the stars!) ? > > - ...or... Am I missing something fundamental in my interpretation? > > - Eventually, this query to Horizons turns our to be tricky to manage as > SkyCoord for the final user. I think it would be useful to provide the > correct recipe and/or directly a SkyCoord as output of the query... > > Best regards > > Paolo > > > -- > --------------------------------------------------------------------- > Paolo Tanga Astronomer > Deputy director of Laboratoire Langrange / UMR 7293 > Observatoire de la C?te d'Azur Tel +33(0)492003042 > Bv de l'Observatoire - CS 34229 Fax +33(0)492003121 > 06304 Nice Cedex 4 - France http://www.oca.eu/tanga > https://twitter.com/ziggypao > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- A non-text attachment was scrubbed... Name: astrometric-question.ipynb Type: application/octet-stream Size: 1917 bytes Desc: not available URL: From evangelia.sam at gmail.com Fri Jan 29 03:30:13 2021 From: evangelia.sam at gmail.com (Evangelia Samara) Date: Fri, 29 Jan 2021 09:30:13 +0100 Subject: [AstroPy] problem with composed maps and fits files Message-ID: Dear, I would very much appreciate your help in the following, I am stuck to this problem for a long time. I want to composite two sunpy Maps together,* obtain the composited data* in a new fits file and save them. I have tried everything but i cannot obtain somehow the *composited data togethe*r (there is no such function as comp_map.data, for example). Using get.data() function will only give me the data of the one or the other map, separately, while I want the new overplotted data all together. Do you maybe have a solution on this? Thank you very much in advance! Cheers, Evangelia -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Sat Jan 30 12:20:11 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Sat, 30 Jan 2021 18:20:11 +0100 Subject: [AstroPy] problem with composed maps and fits files In-Reply-To: References: Message-ID: On Fri, Jan 29, 2021 at 9:30 AM Evangelia Samara wrote: > > Dear, > > I would very much appreciate your help in the following, I am stuck to this problem for a long time. > > I want to composite two sunpy Maps together, obtain the composited data in a new fits file and save them. I have tried everything but i cannot obtain somehow the composited data together (there is no such function as comp_map.data, for example). Using get.data() function will only give me the data of the one or the other map, separately, while I want the new overplotted data all together. > > Do you maybe have a solution on this? > > Thank you very much in advance! Hi Evangelina, What exactly do you mean by "obtain the composited data in a new FITS file"? As I understand it, from both the documentation and looking at the code, the CompositeMap just saves a list of multiple maps, and when plotting them overlays one on the other depending on their relative z-order. Do you just want the rasterized pixels of the resulting RGB image? From evangelia.sam at gmail.com Sat Jan 30 13:02:17 2021 From: evangelia.sam at gmail.com (Evangelia Samara) Date: Sat, 30 Jan 2021 19:02:17 +0100 Subject: [AstroPy] problem with composed maps and fits files In-Reply-To: References: Message-ID: Hi Madison, I want to take the data I see in the composited map. Is that what you mean by rasterizing? Namely, If I have an initial black image (full of zeros) and I overplot it with an image which is *half* in size containing a white (full of 1s) rectangle, I want to obtain the data of the final image which is a black background (the initial image) with a white rectangle (the second image). In this final image, the originally black pixels have been replaced with white pixels where appropriate. I hope its more clear now! Thanks! Evangelia On Sat, Jan 30, 2021 at 6:20 PM E. Madison Bray wrote: > On Fri, Jan 29, 2021 at 9:30 AM Evangelia Samara > wrote: > > > > Dear, > > > > I would very much appreciate your help in the following, I am stuck to > this problem for a long time. > > > > I want to composite two sunpy Maps together, obtain the composited data > in a new fits file and save them. I have tried everything but i cannot > obtain somehow the composited data together (there is no such function as > comp_map.data, for example). Using get.data() function will only give me > the data of the one or the other map, separately, while I want the new > overplotted data all together. > > > > Do you maybe have a solution on this? > > > > Thank you very much in advance! > > Hi Evangelina, > > What exactly do you mean by "obtain the composited data in a new FITS > file"? As I understand it, from both the documentation and looking at > the code, the CompositeMap just saves a list of multiple maps, and > when plotting them overlays one on the other depending on their > relative z-order. > > Do you just want the rasterized pixels of the resulting RGB image? > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rfinn at siena.edu Sun Jan 31 21:03:40 2021 From: rfinn at siena.edu (Finn, Rose) Date: Sun, 31 Jan 2021 21:03:40 -0500 Subject: [AstroPy] reprojecting images without trimming/cropping Message-ID: Hi all, I am looking for some help with combining dithered images. I have tried two different approaches. (1) I can use reproject.mosaicking.reproject_and_coadd, and this preserves the full footprint of the images (not just the area that all images cover). The down side of reproject_and_coadd is that I can't figure out how to pass parameters to the combine function, for example to do sigma clipping. (2) Alternatively, I can reproject each image using reproject.reproject_interp (or exact), and then combine the images with ccdproc.Combiner. This gives me lots of options for controlling how the images are combined, but the resulting combined image is trimmed to include only the region covered by all the input images. Ideally, I would like to use method (2) with the trimming shut off. Any suggestions would be greatly appreciated! Thanks, Rose PS - I found some discussion of this here but can't find anything more recent https://github.com/astropy/ccdproc/issues/499 -- Rose A. Finn, PhD Department of Physics & Astronomy Siena College Loudonville, NY 12211 -------------- next part -------------- An HTML attachment was scrubbed... URL: