From mcraig at mnstate.edu Tue Mar 16 09:38:27 2021 From: mcraig at mnstate.edu (Craig, Matthew W) Date: Tue, 16 Mar 2021 13:38:27 +0000 Subject: [AstroPy] ccdproc 2.1.1 release Message-ID: Greetings, It is my pleasure to announce the release of ccdproc 2.1.1, which contains several bug fixes, including some based on feedback from the astropy workshop at the AAS. The release summary, including a list of the new contributors, is at https://github.com/astropy/ccdproc/releases/tag/2.1.1 Install with `pip install ccdproc` (or upgrade with `pip install -U ccdproc`) or with `conda install -c conda-forge ccdproc`. Thanks, Matt Craig, on behalf of the ccdproc coordinators --- Professor, Department of Physics and Astronomy MSUM -------------- next part -------------- An HTML attachment was scrubbed... URL: From elenc at me.com Fri Mar 26 03:44:34 2021 From: elenc at me.com (Emil Lenc) Date: Fri, 26 Mar 2021 18:44:34 +1100 Subject: [AstroPy] Use of separation Message-ID: <6D89F4A2-DBAE-4EA4-BFA0-791F1F7C9E7F@me.com> Hi All, I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: from astropy import units as u from astropy.time import Time from astropy.coordinates import EarthLocation, Angle, SkyCoord from astropy.coordinates import get_moon # Where are we observing from? latitude = Angle("-26:41:46.0", unit=u.deg) longitude = Angle("116:38:13.0", unit=u.deg) observing_location = EarthLocation(lat=latitude, lon=longitude) # When are we observing? t = Time("2021-03-04 21:51:58", format='iso', scale='utc') # Where is the moon? moon = get_moon(t, observing_location) pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) # Print out the location of the moon dir_str = moon.to_string(style='hmsdms') print("Moon (at specified location) is at: %s" %(dir_str)) # Print out the location of the pointing dir_str = pointing.to_string(style='hmsdms') print("Pointing is at: %s" %(dir_str)) # Determine the separation between the moon and the pointing sep = moon.separation(pointing).deg print("Moon separation from pointing = %0.1f deg" %(sep)) # Determine the separation between the pointing and the moon sep = pointing.separation(moon).deg print("Pointing separation from Moon = %0.1f deg\n" %(sep)) The result of running this script producing the following result: Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s Pointing is at: 15h33m45s -18d40m03.793s Moon separation from pointing = 3.5 deg Pointing separation from Moon = 71.5 deg Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. Best regards, Emil. From s.littlefair at sheffield.ac.uk Fri Mar 26 03:50:49 2021 From: s.littlefair at sheffield.ac.uk (Stuart P Littlefair) Date: Fri, 26 Mar 2021 07:50:49 +0000 Subject: [AstroPy] Use of separation In-Reply-To: <6D89F4A2-DBAE-4EA4-BFA0-791F1F7C9E7F@me.com> References: <6D89F4A2-DBAE-4EA4-BFA0-791F1F7C9E7F@me.com> Message-ID: <76068623-A813-45E1-A827-94CB01A68E35@sheffield.ac.uk> Hi Emil The documentation for separation has an explanation of this. https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? Stuart Littlefair Dept. of Physics & Astronomy Univ. of Sheffield, Sheffield, S3 7RH email: s.littlefair at shef.ac.uk Phone: +44 114 2224525 Sent from my iPhone > On 26 Mar 2021, at 07:45, Emil Lenc wrote: > > ?Hi All, > > I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: > > from astropy import units as u > from astropy.time import Time > from astropy.coordinates import EarthLocation, Angle, SkyCoord > from astropy.coordinates import get_moon > > # Where are we observing from? > latitude = Angle("-26:41:46.0", unit=u.deg) > longitude = Angle("116:38:13.0", unit=u.deg) > observing_location = EarthLocation(lat=latitude, lon=longitude) > > # When are we observing? > t = Time("2021-03-04 21:51:58", format='iso', scale='utc') > > # Where is the moon? > moon = get_moon(t, observing_location) > pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) > > # Print out the location of the moon > dir_str = moon.to_string(style='hmsdms') > print("Moon (at specified location) is at: %s" %(dir_str)) > > # Print out the location of the pointing > dir_str = pointing.to_string(style='hmsdms') > print("Pointing is at: %s" %(dir_str)) > > # Determine the separation between the moon and the pointing > sep = moon.separation(pointing).deg > print("Moon separation from pointing = %0.1f deg" %(sep)) > > # Determine the separation between the pointing and the moon > sep = pointing.separation(moon).deg > print("Pointing separation from Moon = %0.1f deg\n" %(sep)) > > The result of running this script producing the following result: > > Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s > Pointing is at: 15h33m45s -18d40m03.793s > Moon separation from pointing = 3.5 deg > Pointing separation from Moon = 71.5 deg > > Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. > > Best regards, > > Emil. > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From elenc at me.com Fri Mar 26 04:35:01 2021 From: elenc at me.com (Emil Lenc) Date: Fri, 26 Mar 2021 19:35:01 +1100 Subject: [AstroPy] Use of separation In-Reply-To: <76068623-A813-45E1-A827-94CB01A68E35@sheffield.ac.uk> References: <6D89F4A2-DBAE-4EA4-BFA0-791F1F7C9E7F@me.com> <76068623-A813-45E1-A827-94CB01A68E35@sheffield.ac.uk> Message-ID: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> Hi Stuart, Oh, thanks, I had completely overlooked this in the documentation. I?d have to admit that this is indeed unintuitive behaviour! So much so that I?m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state > Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently. Is it just that because the frame used to determine the moon?s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent ? though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)? Cheers, Emil. > On 26 Mar 2021, at 18:50, Stuart P Littlefair wrote: > > Hi Emil > > The documentation for separation has an explanation of this. > > https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation > > ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? > > Stuart Littlefair > Dept. of Physics & Astronomy > Univ. of Sheffield, Sheffield, S3 7RH > > email: s.littlefair at shef.ac.uk > Phone: +44 114 2224525 > Sent from my iPhone > >> On 26 Mar 2021, at 07:45, Emil Lenc wrote: >> >> ?Hi All, >> >> I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: >> >> from astropy import units as u >> from astropy.time import Time >> from astropy.coordinates import EarthLocation, Angle, SkyCoord >> from astropy.coordinates import get_moon >> >> # Where are we observing from? >> latitude = Angle("-26:41:46.0", unit=u.deg) >> longitude = Angle("116:38:13.0", unit=u.deg) >> observing_location = EarthLocation(lat=latitude, lon=longitude) >> >> # When are we observing? >> t = Time("2021-03-04 21:51:58", format='iso', scale='utc') >> >> # Where is the moon? >> moon = get_moon(t, observing_location) >> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) >> >> # Print out the location of the moon >> dir_str = moon.to_string(style='hmsdms') >> print("Moon (at specified location) is at: %s" %(dir_str)) >> >> # Print out the location of the pointing >> dir_str = pointing.to_string(style='hmsdms') >> print("Pointing is at: %s" %(dir_str)) >> >> # Determine the separation between the moon and the pointing >> sep = moon.separation(pointing).deg >> print("Moon separation from pointing = %0.1f deg" %(sep)) >> >> # Determine the separation between the pointing and the moon >> sep = pointing.separation(moon).deg >> print("Pointing separation from Moon = %0.1f deg\n" %(sep)) >> >> The result of running this script producing the following result: >> >> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s >> Pointing is at: 15h33m45s -18d40m03.793s >> Moon separation from pointing = 3.5 deg >> Pointing separation from Moon = 71.5 deg >> >> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. >> >> Best regards, >> >> Emil. >> >> _______________________________________________ >> 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 s.littlefair at sheffield.ac.uk Fri Mar 26 05:00:56 2021 From: s.littlefair at sheffield.ac.uk (Stuart P Littlefair) Date: Fri, 26 Mar 2021 09:00:56 +0000 Subject: [AstroPy] Use of separation In-Reply-To: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> Message-ID: It is counterintuitive. The point is that the separation of two objects doesn?t make sense without a coordinate frame in which that separation is measured. A celestial object may be in the same direction as the moon when viewed from the earth (a GCRS frame), but the two will not line up for an observer at the centre of the solar system (an ICRS frame). So when you calculate the separation between two coordinates that are measured in different frames, you *have* to choose one or the other frames to measure the separation in. The unintuitive nature of this code comes from the assumption of the user that ?get_sun? or ?get_moon? will return a coordinate in the same frame as ?pointing?, which is not true. Stuart Littlefair Dept. of Physics & Astronomy Univ. of Sheffield, Sheffield, S3 7RH email: s.littlefair at shef.ac.uk Phone: +44 114 2224525 Sent from my iPhone > On 26 Mar 2021, at 08:35, Emil Lenc wrote: > > ?Hi Stuart, > > Oh, thanks, I had completely overlooked this in the documentation. I?d have to admit that this is indeed unintuitive behaviour! So much so that I?m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state > >> Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently. > > Is it just that because the frame used to determine the moon?s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent ? though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)? > > Cheers, > > Emil. > >> On 26 Mar 2021, at 18:50, Stuart P Littlefair wrote: >> >> Hi Emil >> >> The documentation for separation has an explanation of this. >> >> https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation >> >> ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? >> >> Stuart Littlefair >> Dept. of Physics & Astronomy >> Univ. of Sheffield, Sheffield, S3 7RH >> >> email: s.littlefair at shef.ac.uk >> Phone: +44 114 2224525 >> Sent from my iPhone >> >>> On 26 Mar 2021, at 07:45, Emil Lenc wrote: >>> >>> ?Hi All, >>> >>> I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: >>> >>> from astropy import units as u >>> from astropy.time import Time >>> from astropy.coordinates import EarthLocation, Angle, SkyCoord >>> from astropy.coordinates import get_moon >>> >>> # Where are we observing from? >>> latitude = Angle("-26:41:46.0", unit=u.deg) >>> longitude = Angle("116:38:13.0", unit=u.deg) >>> observing_location = EarthLocation(lat=latitude, lon=longitude) >>> >>> # When are we observing? >>> t = Time("2021-03-04 21:51:58", format='iso', scale='utc') >>> >>> # Where is the moon? >>> moon = get_moon(t, observing_location) >>> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) >>> >>> # Print out the location of the moon >>> dir_str = moon.to_string(style='hmsdms') >>> print("Moon (at specified location) is at: %s" %(dir_str)) >>> >>> # Print out the location of the pointing >>> dir_str = pointing.to_string(style='hmsdms') >>> print("Pointing is at: %s" %(dir_str)) >>> >>> # Determine the separation between the moon and the pointing >>> sep = moon.separation(pointing).deg >>> print("Moon separation from pointing = %0.1f deg" %(sep)) >>> >>> # Determine the separation between the pointing and the moon >>> sep = pointing.separation(moon).deg >>> print("Pointing separation from Moon = %0.1f deg\n" %(sep)) >>> >>> The result of running this script producing the following result: >>> >>> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s >>> Pointing is at: 15h33m45s -18d40m03.793s >>> Moon separation from pointing = 3.5 deg >>> Pointing separation from Moon = 71.5 deg >>> >>> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. >>> >>> Best regards, >>> >>> Emil. >>> >>> _______________________________________________ >>> 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 > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From pdzwig at summaventures.com Fri Mar 26 05:29:36 2021 From: pdzwig at summaventures.com (Peter Dzwig) Date: Fri, 26 Mar 2021 09:29:36 +0000 Subject: [AstroPy] Use of separation In-Reply-To: References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> Message-ID: <8e72bd58-70d5-7f40-072a-0acc0d7809be@summaventures.com> >From Emil's mail: "Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently." This isn't very clear if the manual doesn't state which way the conversion goes (ie assigns a priority). Preferably the user should be allowed to specify. Peter Dzwig -- Dr. Peter Dzwig From elenc at me.com Fri Mar 26 05:42:58 2021 From: elenc at me.com (Emil Lenc) Date: Fri, 26 Mar 2021 20:42:58 +1100 Subject: [AstroPy] Use of separation In-Reply-To: References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> Message-ID: <96A18ACC-A619-4943-B8BB-FFE78E4A543C@me.com> Hi Stuart, So that?s the bit I don?t get, I did provide a location in get_moon so shouldn?t both be as viewed from the Earth? Cheers, Emil. > On 26 Mar 2021, at 20:00, Stuart P Littlefair wrote: > > It is counterintuitive. The point is that the separation of two objects doesn?t make sense without a coordinate frame in which that separation is measured. > > A celestial object may be in the same direction as the moon when viewed from the earth (a GCRS frame), but the two will not line up for an observer at the centre of the solar system (an ICRS frame). > > So when you calculate the separation between two coordinates that are measured in different frames, you *have* to choose one or the other frames to measure the separation in. > > The unintuitive nature of this code comes from the assumption of the user that ?get_sun? or ?get_moon? will return a coordinate in the same frame as ?pointing?, which is not true. > > Stuart Littlefair > Dept. of Physics & Astronomy > Univ. of Sheffield, Sheffield, S3 7RH > > email: s.littlefair at shef.ac.uk > Phone: +44 114 2224525 > Sent from my iPhone > >> On 26 Mar 2021, at 08:35, Emil Lenc wrote: >> >> ?Hi Stuart, >> >> Oh, thanks, I had completely overlooked this in the documentation. I?d have to admit that this is indeed unintuitive behaviour! So much so that I?m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state >> >>> Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently. >> >> Is it just that because the frame used to determine the moon?s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent ? though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)? >> >> Cheers, >> >> Emil. >> >>> On 26 Mar 2021, at 18:50, Stuart P Littlefair > wrote: >>> >>> Hi Emil >>> >>> The documentation for separation has an explanation of this. >>> >>> https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation >>> >>> ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? >>> >>> Stuart Littlefair >>> Dept. of Physics & Astronomy >>> Univ. of Sheffield, Sheffield, S3 7RH >>> >>> email: s.littlefair at shef.ac.uk >>> Phone: +44 114 2224525 >>> Sent from my iPhone >>> >>>> On 26 Mar 2021, at 07:45, Emil Lenc > wrote: >>>> >>>> ?Hi All, >>>> >>>> I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: >>>> >>>> from astropy import units as u >>>> from astropy.time import Time >>>> from astropy.coordinates import EarthLocation, Angle, SkyCoord >>>> from astropy.coordinates import get_moon >>>> >>>> # Where are we observing from? >>>> latitude = Angle("-26:41:46.0", unit=u.deg) >>>> longitude = Angle("116:38:13.0", unit=u.deg) >>>> observing_location = EarthLocation(lat=latitude, lon=longitude) >>>> >>>> # When are we observing? >>>> t = Time("2021-03-04 21:51:58", format='iso', scale='utc') >>>> >>>> # Where is the moon? >>>> moon = get_moon(t, observing_location) >>>> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) >>>> >>>> # Print out the location of the moon >>>> dir_str = moon.to_string(style='hmsdms') >>>> print("Moon (at specified location) is at: %s" %(dir_str)) >>>> >>>> # Print out the location of the pointing >>>> dir_str = pointing.to_string(style='hmsdms') >>>> print("Pointing is at: %s" %(dir_str)) >>>> >>>> # Determine the separation between the moon and the pointing >>>> sep = moon.separation(pointing).deg >>>> print("Moon separation from pointing = %0.1f deg" %(sep)) >>>> >>>> # Determine the separation between the pointing and the moon >>>> sep = pointing.separation(moon).deg >>>> print("Pointing separation from Moon = %0.1f deg\n" %(sep)) >>>> >>>> The result of running this script producing the following result: >>>> >>>> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s >>>> Pointing is at: 15h33m45s -18d40m03.793s >>>> Moon separation from pointing = 3.5 deg >>>> Pointing separation from Moon = 71.5 deg >>>> >>>> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. >>>> >>>> Best regards, >>>> >>>> Emil. >>>> >>>> _______________________________________________ >>>> 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 >> >> _______________________________________________ >> 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 s.littlefair at sheffield.ac.uk Fri Mar 26 05:48:37 2021 From: s.littlefair at sheffield.ac.uk (Stuart P Littlefair) Date: Fri, 26 Mar 2021 09:48:37 +0000 Subject: [AstroPy] Use of separation In-Reply-To: <96A18ACC-A619-4943-B8BB-FFE78E4A543C@me.com> References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> <96A18ACC-A619-4943-B8BB-FFE78E4A543C@me.com> Message-ID: It's your "pointing" coordinate that's not Earth-centred. FK5 has an origin at the barycenter IIRC. On Fri, 26 Mar 2021 at 09:43, Emil Lenc wrote: > Hi Stuart, > > So that?s the bit I don?t get, I did provide a location in get_moon so > shouldn?t both be as viewed from the Earth? > > Cheers, > > Emil. > > On 26 Mar 2021, at 20:00, Stuart P Littlefair < > s.littlefair at sheffield.ac.uk> wrote: > > It is counterintuitive. The point is that the separation of two objects > doesn?t make sense without a coordinate frame in which that separation is > measured. > > A celestial object may be in the same direction as the moon when viewed > from the earth (a GCRS frame), but the two will not line up for an observer > at the centre of the solar system (an ICRS frame). > > So when you calculate the separation between two coordinates that are > measured in different frames, you *have* to choose one or the other frames > to measure the separation in. > > The unintuitive nature of this code comes from the assumption of the user > that ?get_sun? or ?get_moon? will return a coordinate in the same frame as > ?pointing?, which is not true. > > Stuart Littlefair > Dept. of Physics & Astronomy > Univ. of Sheffield, Sheffield, S3 7RH > > email: s.littlefair at shef.ac.uk > Phone: +44 114 2224525 > Sent from my iPhone > > On 26 Mar 2021, at 08:35, Emil Lenc wrote: > > ?Hi Stuart, > > Oh, thanks, I had completely overlooked this in the documentation. I?d > have to admit that this is indeed unintuitive behaviour! So much so that > I?m actually not sure how to reliably determine the separation in this > instance? It also seems to be at odds with their example where they state > > Also note that the two input coordinates were not in the same frame ? one > is automatically converted to match the other, ensuring that even though > they are in different frames, the separation is determined consistently. > > > Is it just that because the frame used to determine the moon?s coordinates > is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to > another SkyCoord (with the same frame as my pointing coordinate) to ensure > that the result is consistent ? though perhaps I am just doing this wrong > (sorry, coordinates and frames are not my strong point)? > > Cheers, > > Emil. > > On 26 Mar 2021, at 18:50, Stuart P Littlefair < > s.littlefair at sheffield.ac.uk> wrote: > > Hi Emil > > The documentation for separation has an explanation of this. > > > https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation > > ? If the other coordinate object is in a different frame, it is first > transformed to the frame of this object. This can lead to unintuitive > behavior if not accounted for. Particularly of note is that > self.separation(other) and other.separation(self) may not give the same > answer in this case.? > > Stuart Littlefair > Dept. of Physics & Astronomy > Univ. of Sheffield, Sheffield, S3 7RH > > email: s.littlefair at shef.ac.uk > Phone: +44 114 2224525 > Sent from my iPhone > > On 26 Mar 2021, at 07:45, Emil Lenc wrote: > > ?Hi All, > > I?ve been trying to determine the separation between a point in the sky > and the moon and I?ve come across a strange situation that I don?t quite > understand. Depending on how I determine the separation I get two very > different results i.e. if I determine the separation between the moon and > the sky location as opposed to the separation between the sky location and > the moon. I expected that these should give the same result but they don't. > Here is a simple script to demonstrate what I mean: > > from astropy import units as u > from astropy.time import Time > from astropy.coordinates import EarthLocation, Angle, SkyCoord > from astropy.coordinates import get_moon > > # Where are we observing from? > latitude = Angle("-26:41:46.0", unit=u.deg) > longitude = Angle("116:38:13.0", unit=u.deg) > observing_location = EarthLocation(lat=latitude, lon=longitude) > > # When are we observing? > t = Time("2021-03-04 21:51:58", format='iso', scale='utc') > > # Where is the moon? > moon = get_moon(t, observing_location) > pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) > > # Print out the location of the moon > dir_str = moon.to_string(style='hmsdms') > print("Moon (at specified location) is at: %s" %(dir_str)) > > # Print out the location of the pointing > dir_str = pointing.to_string(style='hmsdms') > print("Pointing is at: %s" %(dir_str)) > > # Determine the separation between the moon and the pointing > sep = moon.separation(pointing).deg > print("Moon separation from pointing = %0.1f deg" %(sep)) > > # Determine the separation between the pointing and the moon > sep = pointing.separation(moon).deg > print("Pointing separation from Moon = %0.1f deg\n" %(sep)) > > The result of running this script producing the following result: > > Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s > Pointing is at: 15h33m45s -18d40m03.793s > Moon separation from pointing = 3.5 deg > Pointing separation from Moon = 71.5 deg > > Does anyone understand why the second case giving a result of 71.5 > degrees? Any help would be greatly appreciated. > > Best regards, > > Emil. > > _______________________________________________ > 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 > > > _______________________________________________ > 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 > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > -- Stuart Littlefair ------------------------------------------------------- *I don't expect you to respond to my email outside your working hours. * *At the University of Sheffield we value and encourage flexible working patterns, so please be assured that I respect your working pattern and I am looking forward to your response when you are next working. * ------------------------------------------------------- Dept. of Physics & Astronomy, Univ. of Sheffield, Sheffield, S3 7RH. email: S.Littlefair at sheffield.ac.uk phone: +44 114 2224525 -------------- next part -------------- An HTML attachment was scrubbed... URL: From erik.m.bray at gmail.com Fri Mar 26 08:05:33 2021 From: erik.m.bray at gmail.com (E. Madison Bray) Date: Fri, 26 Mar 2021 13:05:33 +0100 Subject: [AstroPy] Use of separation In-Reply-To: <8e72bd58-70d5-7f40-072a-0acc0d7809be@summaventures.com> References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> <8e72bd58-70d5-7f40-072a-0acc0d7809be@summaventures.com> Message-ID: On Fri, Mar 26, 2021 at 10:37 AM Peter Dzwig wrote: > > > From Emil's mail: > > "Also note that the two input coordinates were not in the same frame ? > one is automatically converted to match the other, ensuring that even > though they are in different frames, the separation is determined > consistently." > > This isn't very clear if the manual doesn't state which way the > conversion goes (ie assigns a priority). Preferably the user should be > allowed to specify. This question also came up a few days ago on the Astropy GitHub: https://github.com/astropy/astropy/issues/11388 The response is the same, though on the issue I proposed modifying the documentation to make this point more prominent in the documentation on separations and offsets. I also proposed maybe adding an optional frame= argument to separation() in order to explicitly provide the frame, but I'm not sure if that's really useful. From elenc at me.com Fri Mar 26 08:58:35 2021 From: elenc at me.com (Emil Lenc) Date: Fri, 26 Mar 2021 23:58:35 +1100 Subject: [AstroPy] Use of separation In-Reply-To: References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> <8e72bd58-70d5-7f40-072a-0acc0d7809be@summaventures.com> Message-ID: <76CA300C-B4E8-4FA4-9C2D-6296361F46CC@me.com> > On 26 Mar 2021, at 23:05, E. Madison Bray wrote: > > On Fri, Mar 26, 2021 at 10:37 AM Peter Dzwig wrote: >> >> >> From Emil's mail: >> >> "Also note that the two input coordinates were not in the same frame ? >> one is automatically converted to match the other, ensuring that even >> though they are in different frames, the separation is determined >> consistently." >> >> This isn't very clear if the manual doesn't state which way the >> conversion goes (ie assigns a priority). Preferably the user should be >> allowed to specify. > > This question also came up a few days ago on the Astropy GitHub: > https://github.com/astropy/astropy/issues/11388 > > The response is the same, though on the issue I proposed modifying the > documentation to make this point more prominent in the documentation > on separations and offsets. > > I also proposed maybe adding an optional frame= argument to > separation() in order to explicitly provide the frame, but I'm not > sure if that's really useful. > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy I think if the documentation on this point were clearer then that would help tremendously. Cheers, Emil. From elenc at me.com Fri Mar 26 09:15:25 2021 From: elenc at me.com (Emil Lenc) Date: Sat, 27 Mar 2021 00:15:25 +1100 Subject: [AstroPy] Use of separation In-Reply-To: References: <8E1BC489-BB59-42C7-8296-44E6E339AE2C@me.com> <96A18ACC-A619-4943-B8BB-FFE78E4A543C@me.com> Message-ID: <2B251F7F-DAD4-4881-BCF1-039C07BBFB76@me.com> Hi Stuart, Ah, right - I think I understand now (famous last words?). I guess that explains why moon.separation(pointing) gave the answer that was closer to what I was expecting. What I didn?t realise is which frame was being converted to which. So in the moon.separation(pointing) it will convert the FK5 pointing frame to the same frame used for the moon SkyCoord (in which case pointing would, for the most part, still be pointing in the same direction in the sky from our point of view). Presumably in the other case, pointing.separation(moon), it is converting the moon SkyCoord frame to fk5 which would be (for the most part) in a direction towards the Earth (well, the location of the moon in its orbit around the Earth at that time) with respect to the centre of the Solar System. Cheers, Emil. > On 26 Mar 2021, at 20:48, Stuart P Littlefair wrote: > > It's your "pointing" coordinate that's not Earth-centred. FK5 has an origin at the barycenter IIRC. > > On Fri, 26 Mar 2021 at 09:43, Emil Lenc > wrote: > Hi Stuart, > > So that?s the bit I don?t get, I did provide a location in get_moon so shouldn?t both be as viewed from the Earth? > > Cheers, > > Emil. > >> On 26 Mar 2021, at 20:00, Stuart P Littlefair > wrote: >> >> It is counterintuitive. The point is that the separation of two objects doesn?t make sense without a coordinate frame in which that separation is measured. >> >> A celestial object may be in the same direction as the moon when viewed from the earth (a GCRS frame), but the two will not line up for an observer at the centre of the solar system (an ICRS frame). >> >> So when you calculate the separation between two coordinates that are measured in different frames, you *have* to choose one or the other frames to measure the separation in. >> >> The unintuitive nature of this code comes from the assumption of the user that ?get_sun? or ?get_moon? will return a coordinate in the same frame as ?pointing?, which is not true. >> >> Stuart Littlefair >> Dept. of Physics & Astronomy >> Univ. of Sheffield, Sheffield, S3 7RH >> >> email: s.littlefair at shef.ac.uk >> Phone: +44 114 2224525 >> Sent from my iPhone >> >>> On 26 Mar 2021, at 08:35, Emil Lenc > wrote: >>> >>> ?Hi Stuart, >>> >>> Oh, thanks, I had completely overlooked this in the documentation. I?d have to admit that this is indeed unintuitive behaviour! So much so that I?m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state >>> >>>> Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently. >>> >>> Is it just that because the frame used to determine the moon?s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent ? though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)? >>> >>> Cheers, >>> >>> Emil. >>> >>>> On 26 Mar 2021, at 18:50, Stuart P Littlefair > wrote: >>>> >>>> Hi Emil >>>> >>>> The documentation for separation has an explanation of this. >>>> >>>> https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation >>>> >>>> ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? >>>> >>>> Stuart Littlefair >>>> Dept. of Physics & Astronomy >>>> Univ. of Sheffield, Sheffield, S3 7RH >>>> >>>> email: s.littlefair at shef.ac.uk >>>> Phone: +44 114 2224525 >>>> Sent from my iPhone >>>> >>>>> On 26 Mar 2021, at 07:45, Emil Lenc > wrote: >>>>> >>>>> ?Hi All, >>>>> >>>>> I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: >>>>> >>>>> from astropy import units as u >>>>> from astropy.time import Time >>>>> from astropy.coordinates import EarthLocation, Angle, SkyCoord >>>>> from astropy.coordinates import get_moon >>>>> >>>>> # Where are we observing from? >>>>> latitude = Angle("-26:41:46.0", unit=u.deg) >>>>> longitude = Angle("116:38:13.0", unit=u.deg) >>>>> observing_location = EarthLocation(lat=latitude, lon=longitude) >>>>> >>>>> # When are we observing? >>>>> t = Time("2021-03-04 21:51:58", format='iso', scale='utc') >>>>> >>>>> # Where is the moon? >>>>> moon = get_moon(t, observing_location) >>>>> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) >>>>> >>>>> # Print out the location of the moon >>>>> dir_str = moon.to_string(style='hmsdms') >>>>> print("Moon (at specified location) is at: %s" %(dir_str)) >>>>> >>>>> # Print out the location of the pointing >>>>> dir_str = pointing.to_string(style='hmsdms') >>>>> print("Pointing is at: %s" %(dir_str)) >>>>> >>>>> # Determine the separation between the moon and the pointing >>>>> sep = moon.separation(pointing).deg >>>>> print("Moon separation from pointing = %0.1f deg" %(sep)) >>>>> >>>>> # Determine the separation between the pointing and the moon >>>>> sep = pointing.separation(moon).deg >>>>> print("Pointing separation from Moon = %0.1f deg\n" %(sep)) >>>>> >>>>> The result of running this script producing the following result: >>>>> >>>>> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s >>>>> Pointing is at: 15h33m45s -18d40m03.793s >>>>> Moon separation from pointing = 3.5 deg >>>>> Pointing separation from Moon = 71.5 deg >>>>> >>>>> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. >>>>> >>>>> Best regards, >>>>> >>>>> Emil. >>>>> >>>>> _______________________________________________ >>>>> 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 >>> >>> _______________________________________________ >>> 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 > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy > > > -- > Stuart Littlefair > > ------------------------------------------------------- > > I don't expect you to respond to my email outside your working hours. > > At the University of Sheffield we value and encourage flexible working patterns, so please be assured that I respect your working pattern and I am looking forward to your response when you are next working. > > ------------------------------------------------------- > > Dept. of Physics & Astronomy, > Univ. of Sheffield, Sheffield, S3 7RH. > > email: S.Littlefair at sheffield.ac.uk > phone: +44 114 2224525 > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.littlefair at sheffield.ac.uk Fri Mar 26 09:26:39 2021 From: s.littlefair at sheffield.ac.uk (Stuart P Littlefair) Date: Fri, 26 Mar 2021 13:26:39 +0000 Subject: [AstroPy] Use of separation In-Reply-To: References: Message-ID: <81D7FF6A-601F-45A9-8163-AF9470F7F394@sheffield.ac.uk> Exactly. Stuart Littlefair Dept. of Physics & Astronomy Univ. of Sheffield, Sheffield, S3 7RH email: s.littlefair at shef.ac.uk Phone: +44 114 2224525 Sent from my iPhone > On 26 Mar 2021, at 09:00, Stuart P Littlefair wrote: > > ?It is counterintuitive. The point is that the separation of two objects doesn?t make sense without a coordinate frame in which that separation is measured. > > A celestial object may be in the same direction as the moon when viewed from the earth (a GCRS frame), but the two will not line up for an observer at the centre of the solar system (an ICRS frame). > > So when you calculate the separation between two coordinates that are measured in different frames, you *have* to choose one or the other frames to measure the separation in. > > The unintuitive nature of this code comes from the assumption of the user that ?get_sun? or ?get_moon? will return a coordinate in the same frame as ?pointing?, which is not true. > > Stuart Littlefair > Dept. of Physics & Astronomy > Univ. of Sheffield, Sheffield, S3 7RH > > email: s.littlefair at shef.ac.uk > Phone: +44 114 2224525 > Sent from my iPhone > >> On 26 Mar 2021, at 08:35, Emil Lenc wrote: >> >> ?Hi Stuart, >> >> Oh, thanks, I had completely overlooked this in the documentation. I?d have to admit that this is indeed unintuitive behaviour! So much so that I?m actually not sure how to reliably determine the separation in this instance? It also seems to be at odds with their example where they state >> >>> Also note that the two input coordinates were not in the same frame ? one is automatically converted to match the other, ensuring that even though they are in different frames, the separation is determined consistently. >> >> Is it just that because the frame used to determine the moon?s coordinates is a bit odd? It seems a bit odd to convert the RA/Dec of the moon to another SkyCoord (with the same frame as my pointing coordinate) to ensure that the result is consistent ? though perhaps I am just doing this wrong (sorry, coordinates and frames are not my strong point)? >> >> Cheers, >> >> Emil. >> >>> On 26 Mar 2021, at 18:50, Stuart P Littlefair wrote: >>> >>> Hi Emil >>> >>> The documentation for separation has an explanation of this. >>> >>> https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord.separation >>> >>> ? If the other coordinate object is in a different frame, it is first transformed to the frame of this object. This can lead to unintuitive behavior if not accounted for. Particularly of note is that self.separation(other) and other.separation(self) may not give the same answer in this case.? >>> >>> Stuart Littlefair >>> Dept. of Physics & Astronomy >>> Univ. of Sheffield, Sheffield, S3 7RH >>> >>> email: s.littlefair at shef.ac.uk >>> Phone: +44 114 2224525 >>> Sent from my iPhone >>> >>>> On 26 Mar 2021, at 07:45, Emil Lenc wrote: >>>> >>>> ?Hi All, >>>> >>>> I?ve been trying to determine the separation between a point in the sky and the moon and I?ve come across a strange situation that I don?t quite understand. Depending on how I determine the separation I get two very different results i.e. if I determine the separation between the moon and the sky location as opposed to the separation between the sky location and the moon. I expected that these should give the same result but they don't. Here is a simple script to demonstrate what I mean: >>>> >>>> from astropy import units as u >>>> from astropy.time import Time >>>> from astropy.coordinates import EarthLocation, Angle, SkyCoord >>>> from astropy.coordinates import get_moon >>>> >>>> # Where are we observing from? >>>> latitude = Angle("-26:41:46.0", unit=u.deg) >>>> longitude = Angle("116:38:13.0", unit=u.deg) >>>> observing_location = EarthLocation(lat=latitude, lon=longitude) >>>> >>>> # When are we observing? >>>> t = Time("2021-03-04 21:51:58", format='iso', scale='utc') >>>> >>>> # Where is the moon? >>>> moon = get_moon(t, observing_location) >>>> pointing = SkyCoord("15h33m45.000s -18d40m3.793s", frame='fk5?) >>>> >>>> # Print out the location of the moon >>>> dir_str = moon.to_string(style='hmsdms') >>>> print("Moon (at specified location) is at: %s" %(dir_str)) >>>> >>>> # Print out the location of the pointing >>>> dir_str = pointing.to_string(style='hmsdms') >>>> print("Pointing is at: %s" %(dir_str)) >>>> >>>> # Determine the separation between the moon and the pointing >>>> sep = moon.separation(pointing).deg >>>> print("Moon separation from pointing = %0.1f deg" %(sep)) >>>> >>>> # Determine the separation between the pointing and the moon >>>> sep = pointing.separation(moon).deg >>>> print("Pointing separation from Moon = %0.1f deg\n" %(sep)) >>>> >>>> The result of running this script producing the following result: >>>> >>>> Moon (at specified location) is at: 15h48m35.4296s -18d29m19.3018s >>>> Pointing is at: 15h33m45s -18d40m03.793s >>>> Moon separation from pointing = 3.5 deg >>>> Pointing separation from Moon = 71.5 deg >>>> >>>> Does anyone understand why the second case giving a result of 71.5 degrees? Any help would be greatly appreciated. >>>> >>>> Best regards, >>>> >>>> Emil. >>>> >>>> _______________________________________________ >>>> 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 >> >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- An HTML attachment was scrubbed... URL: From hg.dude.hg at gmail.com Thu Mar 25 11:44:48 2021 From: hg.dude.hg at gmail.com (Dominik Rhiem) Date: Thu, 25 Mar 2021 16:44:48 +0100 Subject: [AstroPy] Cutout2D with weird formatting Message-ID: Dear all, I am using FITS maps produced by a program called PyBDSF used for source detection and removal, and I want to make cutouts from these maps. However, the formatting of these maps is a bit weird and I am having trouble with making Cutout2D work with it. I have attached the fits file. Some sample code: hdul = fits.open('test.fits') the_map = hdul[0].data the_header = hdul[0].header position = (the_header['CRPIX1'], the_header['CRPIX2']) #I want the cutout to be centred on the map size = 400 * u.arcsec #the cutout should have a total extent of 400 arcsec in x and y direction wcs = WCS(header=the_header) cutout = Cutout2D(the_map, position, size, wcs) Which results in: ValueError: "large_array_shape" and "small_array_shape" must have the same number of dimensions. Importantly, the array has a shape of (1, 1, 600, 600), i.e. the actual 2D data array is found via: the_map = the_map[0][0] which is reflected in the wcs. If I try to use that definition of the array for the cutout, I get this error: ValueError: operands could not be broadcast together with shapes (4,) (2,) (4,) How can I solve either of these issues? Sincerely, Dominik -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.fits Type: application/octet-stream Size: 1442880 bytes Desc: not available URL: From ejensen1 at swarthmore.edu Mon Mar 29 21:32:06 2021 From: ejensen1 at swarthmore.edu (Eric Jensen) Date: Mon, 29 Mar 2021 21:32:06 -0400 Subject: [AstroPy] Cutout2D with weird formatting In-Reply-To: References: Message-ID: <17561408-47D6-4282-9949-F96632D89E7B@swarthmore.edu> Hi Dominik, You should be able to do this by modifying the FITS header to remove the references to the third and fourth dimensions. Adding these lines to your code should do the trick, before you create the WCS from the header: # Remove length-1 dimensions: the_map = np.squeeze(hdul[0].data) # Get rid of references to third and fourth # dimensions in the FITS header: the_header['NAXIS'] = 2 for f in (['CTYPE', 'CRVAL', 'CDELT', 'CRPIX', 'CUNIT', 'NAXIS']): for i in ['3', '4']: del(the_header[f + i]) wcs = WCS(header=the_header) Eric > On Mar 25, 2021, at 11:44 AM, Dominik Rhiem wrote: > > Dear all, > > I am using FITS maps produced by a program called PyBDSF used for source detection and removal, and I want to make cutouts from these maps. However, the formatting of these maps is a bit weird and I am having trouble with making Cutout2D work with it. I have attached the fits file. Some sample code: > hdul = fits.open('test.fits') > the_map = hdul[0].data > the_header = hdul[0].header > position = (the_header['CRPIX1'], the_header['CRPIX2']) #I want the cutout to be centred on the map > size = 400 * u.arcsec #the cutout should have a total extent of 400 arcsec in x and y direction > wcs = WCS(header=the_header) > cutout = Cutout2D(the_map, position, size, wcs) > > Which results in: > ValueError: "large_array_shape" and "small_array_shape" must have the same number of dimensions. > Importantly, the array has a shape of (1, 1, 600, 600), i.e. the actual 2D data array is found via: > the_map = the_map[0][0] > which is reflected in the wcs. If I try to use that definition of the array for the cutout, I get this error: > ValueError: operands could not be broadcast together with shapes (4,) (2,) (4,) > > How can I solve either of these issues? > > Sincerely, > Dominik > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4388 bytes Desc: not available URL: From adam.g.ginsburg at gmail.com Mon Mar 29 21:41:00 2021 From: adam.g.ginsburg at gmail.com (Adam Ginsburg) Date: Mon, 29 Mar 2021 21:41:00 -0400 Subject: [AstroPy] Cutout2D with weird formatting In-Reply-To: <17561408-47D6-4282-9949-F96632D89E7B@swarthmore.edu> References: <17561408-47D6-4282-9949-F96632D89E7B@swarthmore.edu> Message-ID: There is also a convenience function built into astropy.wcs for this purpose: wcs = WCS(the_header).celestial will take the subset of the WCS that corresponds to celestial coordinates using the wcs.sub functionality provided by wcstools internally. On Mon, Mar 29, 2021 at 9:32 PM Eric Jensen wrote: > Hi Dominik, > > You should be able to do this by modifying the FITS header to remove the > references to the third and fourth dimensions. > > Adding these lines to your code should do the trick, before you create the > WCS from the header: > > # Remove length-1 dimensions: > the_map = np.squeeze(hdul[0].data) > > # Get rid of references to third and fourth > # dimensions in the FITS header: > the_header['NAXIS'] = 2 > for f in (['CTYPE', 'CRVAL', 'CDELT', > 'CRPIX', 'CUNIT', 'NAXIS']): > for i in ['3', '4']: > del(the_header[f + i]) > wcs = WCS(header=the_header) > > > Eric > > > > On Mar 25, 2021, at 11:44 AM, Dominik Rhiem > wrote: > > > > Dear all, > > > > I am using FITS maps produced by a program called PyBDSF used for source > detection and removal, and I want to make cutouts from these maps. However, > the formatting of these maps is a bit weird and I am having trouble with > making Cutout2D work with it. I have attached the fits file. Some sample > code: > > hdul = fits.open('test.fits') > > the_map = hdul[0].data > > the_header = hdul[0].header > > position = (the_header['CRPIX1'], the_header['CRPIX2']) #I want the > cutout to be centred on the map > > size = 400 * u.arcsec #the cutout should have a total extent of 400 > arcsec in x and y direction > > wcs = WCS(header=the_header) > > cutout = Cutout2D(the_map, position, size, wcs) > > > > Which results in: > > ValueError: "large_array_shape" and "small_array_shape" must have the > same number of dimensions. > > Importantly, the array has a shape of (1, 1, 600, 600), i.e. the actual > 2D data array is found via: > > the_map = the_map[0][0] > > which is reflected in the wcs. If I try to use that definition of the > array for the cutout, I get this error: > > ValueError: operands could not be broadcast together with shapes (4,) > (2,) (4,) > > > > How can I solve either of these issues? > > > > Sincerely, > > Dominik > > > > _______________________________________________ > > 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: