[AstroPy] Parse DETSEC etc..

Timothy Pickering te.pickering at gmail.com
Thu Jul 5 11:14:28 EDT 2018


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 <petr at kubanek.net> 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                |
+-----------------------------+




More information about the AstroPy mailing list