From petr at kubanek.net Wed Jul 4 21:21:56 2018 From: petr at kubanek.net (Petr =?ISO-8859-1?Q?Kub=E1nek?=) Date: Wed, 04 Jul 2018 18:21:56 -0700 Subject: [AstroPy] Parse DETSEC etc.. Message-ID: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> Hi Astropy, I might be stupid, but I don't see any way how to parse DETSEC and similar FITS header you can encounter in (multiframe) FITS files. I of course know how to parse that with e.g. re and mapping result to float array, but is there a better way? See for the code (yes, that will become a function..unless I know about better way): from astropy.io import fits import re ff=fits.open('file.fits') r = re.compile('\[(\d+):(\d+),(\d+):(\d+)\]') g = r.match(ff[1].header['DETSEC']) # DETSEC is '[20:30,40:50]' b=map(float, g.groups()) print(b) [20,30,40,50] Thanks Petr Kub?nek http://rts2.org From erwin at mpe.mpg.de Thu Jul 5 02:51:35 2018 From: erwin at mpe.mpg.de (Peter Erwin) Date: Thu, 5 Jul 2018 08:51:35 +0200 Subject: [AstroPy] Parse DETSEC etc.. In-Reply-To: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> References: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> Message-ID: <3F38B7B1-268C-4274-B481-0369AB1F8E49@mpe.mpg.de> If you know the names of the headers to parse and you know they will always have the format ?[x1:x2,y1:y2]?, then a slightly shorter (and possibly more idiomatic) way, which avoids regex and mapping, would be: ff=fits.open('file.fits') h = ff[1].header[?DETSEC?] b = [int(x2) for x1 in h[1:-1].split(",") for x2 in a.split(":?)] (Substitute ?float? for ?int? if you really want floating-point values; I?m assuming that you might want to use the values from DETSEC to index the data array, in which case they should be integers.) But that may not be as flexible as what you want. cheers, Peter > On Jul 5, 2018, at 3:21 AM, Petr Kub?nek wrote: > > Hi Astropy, > > I might be stupid, but I don't see any way how to parse DETSEC and > similar FITS header you can encounter in (multiframe) FITS files. I of > course know how to parse that with e.g. re and mapping result to float > array, but is there a better way? See for the code (yes, that will > become a function..unless I know about better way): > > from astropy.io import fits > import re > > ff=fits.open('file.fits') > r = re.compile('\[(\d+):(\d+),(\d+):(\d+)\]') > g = r.match(ff[1].header['DETSEC']) # DETSEC is '[20:30,40:50]' > b=map(float, g.groups()) > print(b) > [20,30,40,50] > > > Thanks > > Petr Kub?nek > http://rts2.org > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)176 2481 7713 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From erwin at mpe.mpg.de Thu Jul 5 03:41:12 2018 From: erwin at mpe.mpg.de (Peter Erwin) Date: Thu, 5 Jul 2018 09:41:12 +0200 Subject: [AstroPy] Parse DETSEC etc.. In-Reply-To: <3F38B7B1-268C-4274-B481-0369AB1F8E49@mpe.mpg.de> References: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> <3F38B7B1-268C-4274-B481-0369AB1F8E49@mpe.mpg.de> Message-ID: <49A7423A-DFB9-447A-B37E-5C6A0811A414@mpe.mpg.de> And, of course, the list comprehension line should look something more like this: b = [int(q) for p in h[1:-1].split(',') for q in p.split(':?)] (that?ll teach me to change the intermediate variable names halfway through writing the post?) ? Peter > On Jul 5, 2018, at 8:51 AM, Peter Erwin wrote: > > If you know the names of the headers to parse and you know they will always > have the format ?[x1:x2,y1:y2]?, then a slightly shorter (and possibly more > idiomatic) way, which avoids regex and mapping, would be: > > ff=fits.open('file.fits') > h = ff[1].header[?DETSEC?] > b = [int(x2) for x1 in h[1:-1].split(",") for x2 in a.split(":?)] > > (Substitute ?float? for ?int? if you really want floating-point values; I?m > assuming that you might want to use the values from DETSEC to index > the data array, in which case they should be integers.) > > But that may not be as flexible as what you want. > > > cheers, > > Peter > >> On Jul 5, 2018, at 3:21 AM, Petr Kub?nek wrote: >> >> Hi Astropy, >> >> I might be stupid, but I don't see any way how to parse DETSEC and >> similar FITS header you can encounter in (multiframe) FITS files. I of >> course know how to parse that with e.g. re and mapping result to float >> array, but is there a better way? See for the code (yes, that will >> become a function..unless I know about better way): >> >> from astropy.io import fits >> import re >> >> ff=fits.open('file.fits') >> r = re.compile('\[(\d+):(\d+),(\d+):(\d+)\]') >> g = r.match(ff[1].header['DETSEC']) # DETSEC is '[20:30,40:50]' >> b=map(float, g.groups()) >> print(b) >> [20,30,40,50] >> >> >> Thanks >> >> Petr Kub?nek >> http://rts2.org >> _______________________________________________ >> AstroPy mailing list >> AstroPy at python.org >> https://mail.python.org/mailman/listinfo/astropy > > ============================================================= > Peter Erwin Max-Planck-Insitute for Extraterrestrial > erwin at mpe.mpg.de Physics, Giessenbachstrasse > tel. +49 (0)176 2481 7713 85748 Garching, Germany > fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin > > > > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy ============================================================= Peter Erwin Max-Planck-Insitute for Extraterrestrial erwin at mpe.mpg.de Physics, Giessenbachstrasse tel. +49 (0)176 2481 7713 85748 Garching, Germany fax +49 (0)89 30000 3495 http://www.mpe.mpg.de/~erwin From te.pickering at gmail.com Thu Jul 5 11:14:28 2018 From: te.pickering at gmail.com (Timothy Pickering) Date: Thu, 5 Jul 2018 11:14:28 -0400 Subject: [AstroPy] Parse DETSEC etc.. In-Reply-To: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> References: <250df15ff0ed43383d0ac4c9fe8b43dafddabc6f.camel@kubanek.net> Message-ID: <3705E546-C398-4482-ADA2-45CBE7217C61@gmail.com> the ccdproc package has a utility for doing this: http://ccdproc.readthedocs.io/en/latest/api/ccdproc.utils.slices.slice_from_string.html#ccdproc.utils.slices.slice_from_string it even accounts for FITS-style numbering that starts at index 1. tim > On Jul 4, 2018, at 21:21, Petr Kub?nek wrote: > > Hi Astropy, > > I might be stupid, but I don't see any way how to parse DETSEC and > similar FITS header you can encounter in (multiframe) FITS files. I of > course know how to parse that with e.g. re and mapping result to float > array, but is there a better way? See for the code (yes, that will > become a function..unless I know about better way): > > from astropy.io import fits > import re > > ff=fits.open('file.fits') > r = re.compile('\[(\d+):(\d+),(\d+):(\d+)\]') > g = r.match(ff[1].header['DETSEC']) # DETSEC is '[20:30,40:50]' > b=map(float, g.groups()) > print(b) > [20,30,40,50] > > > Thanks > > Petr Kub?nek > http://rts2.org > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy ? +-----------------------------+ | T. E. Pickering, Ph.D. | | Asst. Staff Scientist | | MMT Observatory | | +1-520-305-9823 | | te.pickering at gmail.com | | tim at mmto.org | +-----------------------------+ From hack at stsci.edu Thu Jul 5 13:49:40 2018 From: hack at stsci.edu (Warren Hack) Date: Thu, 5 Jul 2018 13:49:40 -0400 Subject: [AstroPy] Inverting SkyCoord spherical offset transformations Message-ID: Hello, The astropy documentation provides a very useful example of how to compute the offset between 2 SkyCoord positions at http://docs.astropy.org/en/stable/coordinates/matchsep.html?highlight=spherical_offsets#separations. Specifically, the example for "spherical_offsets_to" in that section of documentation shows how to derive a delta RA and delta Dec for those source positions.? In my case, though, I already have the delta RA and delta Dec from an astrometric solution for that observation and want to apply those deltas to the source positions to reproduce the astrometric catalog positions.? So, the operation I am really interested in would be the inverse of this example where those deltas would be applied to the "bright_star" SkyCoord position to reproduce (within machine precision) the "faint_galaxy" position in RA and Dec. It could be that some other functionality in Astropy would be more suited to providing the right answer to this problem, but the documentation does not provide any indication of how to do this (at least not where I could find it).? Any pointers would be appreciated. Thanks, Warren Hack From shupe at ipac.caltech.edu Thu Jul 5 16:47:06 2018 From: shupe at ipac.caltech.edu (David Shupe) Date: Thu, 5 Jul 2018 13:47:06 -0700 Subject: [AstroPy] Inverting SkyCoord spherical offset transformations In-Reply-To: References: Message-ID: <75C2B7ED-2962-42C6-AA0B-6A0B8E2E0BFD@ipac.caltech.edu> Hi Warren, Here?s a potential solution using a SkyOffsetFrame, building on the spherical_offsets example you linked to: >>> from astropy.coordinates import SkyCoord, SkyOffsetFrame, ICRS >>> bright_star = SkyCoord('8h50m59.75s', '+11d39m22.15s', frame='icrs') >>> faint_galaxy = SkyCoord('8h50m47.92s', '+11d39m32.74s', frame='icrs') >>> dra, ddec = bright_star.spherical_offsets_to(faint_galaxy) >>> star_frame = SkyOffsetFrame(origin=bright_star) >>> my_galaxy = SkyCoord(lon=dra, lat=ddec, frame=star_frame) >>> galaxy_coord = my_galaxy.transform_to(ICRS) >>> galaxy_coord.separation(faint_galaxy) >>> galaxy_coord.to_string('hmsdms') '08h50m47.92s +11d39m32.74s? although with limitations, e.g. ?galaxy_coord.spherical_offsets_to(faint_galaxy)? raises an exception about two non-matching frames. Regards, David Shupe > On Jul 5, 2018, at 10:49 AM, Warren Hack wrote: > > Hello, > > The astropy documentation provides a very useful example of how to compute the offset between 2 SkyCoord positions at http://docs.astropy.org/en/stable/coordinates/matchsep.html?highlight=spherical_offsets#separations. > Specifically, the example for "spherical_offsets_to" in that section of documentation shows how to derive a delta RA and delta Dec for those source positions. In my case, though, I already have the delta RA and delta Dec from an astrometric solution for that observation and want to apply those deltas to the source positions to reproduce the astrometric catalog positions. So, the operation I am really interested in would be the inverse of this example where those deltas would be applied to the "bright_star" SkyCoord position to reproduce (within machine precision) the "faint_galaxy" position in RA and Dec. > > It could be that some other functionality in Astropy would be more suited to providing the right answer to this problem, but the documentation does not provide any indication of how to do this (at least not where I could find it). Any pointers would be appreciated. > > Thanks, > Warren Hack > _______________________________________________ > AstroPy mailing list > AstroPy at python.org > https://mail.python.org/mailman/listinfo/astropy From hack at stsci.edu Fri Jul 6 14:09:05 2018 From: hack at stsci.edu (Warren Hack) Date: Fri, 6 Jul 2018 14:09:05 -0400 Subject: [AstroPy] Inverting SkyCoord spherical offset, transformations Message-ID: <461d84e9-f167-76ba-7d3b-0d1e7446a5a5@stsci.edu> David, Thank you!? That solution allowed me to apply the offsets I have to the test images and align them (better) to the astrometric catalog positions. The real issue in my opinion would be the non-intuitive nature of the required solution, especially for someone not actively developing the astropy coordinates code.? I would suggest to the astropy developers that they therefore include this solution, or whatever may improve upon it (if possible), in the documentation. It would serve as a follow-up to the example already in the docs which served as the starting point for this question, and show how to 'round-trip' the information being computed. For now, though, my problem has been solved. Thanks again! Warren From bkent at nrao.edu Mon Jul 9 17:07:26 2018 From: bkent at nrao.edu (Brian R. Kent) Date: Mon, 9 Jul 2018 17:07:26 -0400 Subject: [AstroPy] Invitation to submit to the PASP data visualization issue Message-ID: <4f1beb3d-4368-a8e2-fc21-1f79c1ac51b2@nrao.edu> The Publications of the Astronomical Society of the Pacific (PASP) is producing a **second** focus issue concerning the topic of Data Visualization in Astronomy.? Submissions will be handled through the normal PASP referee process with regular page charges.? You can read our first well-received focus issue and its intro video here: http://iopscience.iop.org/journal/1538-3873/page/Techniques-and-Methods-for-Astrophysical-Data-Visualization The editors feel that this focus issue would provide a great practical benefit in continuing the success of tool/technique/code sharing generated from the publication of our first focus issue on data visualization.? This new focus issue will publish science results or methods discovered with innovative tool/package descriptions.? All articles will have a shared theme under the focus of data visualization.? Submissions could address one or more of the following topics and/or questions: - What useful tool have you built/utilized for astronomy? - What science problem has your tool/package/software/technique solved? - What data visualization technique can be shared with the astronomical community? If your submission would benefit from popular visualization tools like Oculus Rift, HTC Vive, or Google Cardboard, tell us - we would enjoy having those types of articles.? We also strongly encourage authors to share their code via repositories including GitHub and the Astrophysics Source Code Library (ASCL).? In addition, we would like to have authors create video abstracts showcasing their visualization work. We would like to receive all submissions by the end of the calendar year 2018. If you are interested in submitting a paper, please let use know in the next few weeks.? We're happy to discuss your submission ideas. If you know of other members of the astronomical community whose recent work would be appropriate for this focus issue, please send us their name/contact information so that we may extend the invitation to them as well. Sincerely, Brian R. Kent, NRAO PASP Focus Issue Guest Editor bkent at nrao.edu Jeff Mangum, NRAO PASP Editor-in-chief jmangum at nrao.edu