From perry at stsci.edu Thu Jul 14 10:56:14 2005 From: perry at stsci.edu (Perry Greenfield) Date: Thu, 14 Jul 2005 10:56:14 -0400 Subject: [AstroPy] Re: [SciPy-user] pyfits question: handling gzipped fits files In-Reply-To: References: Message-ID: Hi Russell, The astropy list is probably a better forum for this. On Jul 14, 2005, at 10:38 AM, Russell E. Owen wrote: > Is there some reasonable way to get pyfits to read a gzipped fits file > (in a way that works on Windows and unix)? > > I realize I can unzip the file first, but I was hoping to have it > directly read (unzipped on the fly). > > I can't see any command that takes a file-like object (instead of a > file > path), so I can't see how to take advantage of Python's gzip module. > > I realize I can just edit the code and add this in, but, well...if > there's a better way I'd love to know about it and if there isn't, I'd > like to request that it be modified to handle gzipped files > automatically. Not yet, but after version 1 is out, it's one of the first things we'd like to add (as well as support for the compression conventions that CFITSIO supports). We don't have time right now to do it (though it shouldn't be hard at all). If you or someone would like to add it, we would welcome such a patch. Perry From mpfitz at berkeley.edu Fri Jul 15 07:41:33 2005 From: mpfitz at berkeley.edu (Michael Fitzgerald) Date: Fri, 15 Jul 2005 04:41:33 -0700 Subject: [AstroPy] Re: [SciPy-user] pyfits question: handling gzipped fits files In-Reply-To: References: Message-ID: <200507150441.37510.mpfitz@berkeley.edu> On Thursday 14 July 2005 07:56, Perry Greenfield wrote: > On Jul 14, 2005, at 10:38 AM, Russell E. Owen wrote: > > Is there some reasonable way to get pyfits to read a gzipped fits file > > (in a way that works on Windows and unix)? > Not yet, but after version 1 is out, it's one of the first things we'd > like to add (as well as support for the compression conventions that > CFITSIO supports). We don't have time right now to do it (though it > shouldn't be hard at all). If you or someone would like to add it, we > would welcome such a patch. Hello, Here is a patch against pyfits 0.9 that does the trick for me on unix. It simply uses the gzip.open() function to open the file instead of __builtin__.open() if the filename ends in .gz. Unfortunately, the patch is broken in the most recent version of pyfits (0.9.8.2). I don't know in what version the break first occurs, but the problem must've started when pyfits began using the two-argument form of File objects' seek() method. The (optional) second argument is the 'whence' direction flag. In short, the gzip.GzipFile class does not share the interface of the File class, and can't be used as a drop-in replacement in the most recent version of pyfits. For the sake of consistency, it would be ideal if the File/GzipFile interfaces were compatible, which means this should be fixed in Python's library. I haven't poked around much for the best way to achieve this. I did notice, however, the bz2 module's BZ2File class does implement the two-argument seek() method. Perhaps the update to the gzip module can be modeled off the bz2 module's implementation. Finally, since I can't readily find pyfits 0.9 on the web, I've temporarily put the patched 0.9 version here: http://astron.berkeley.edu/~fitz/pyfits.py Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: pyfits.py.diff Type: text/x-diff Size: 966 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From stephen.walton at csun.edu Sun Jul 17 15:20:22 2005 From: stephen.walton at csun.edu (Stephen Walton) Date: Sun, 17 Jul 2005 12:20:22 -0700 Subject: [AstroPy] Re: [SciPy-user] pyfits question: handling gzipped fits files In-Reply-To: <200507150441.37510.mpfitz@berkeley.edu> References: <200507150441.37510.mpfitz@berkeley.edu> Message-ID: <42DAAF76.4030503@csun.edu> Does Pyfits support the internally compressed FITS files described in this link http://ledas-www.star.le.ac.uk/lheasoft/fitsio/compression/compress_image.html of which I see Perry is a co-author? Of course, reading such files is one thing, having software to write them quite another. CFITSIO can do it, I think. From perry at stsci.edu Mon Jul 18 09:18:32 2005 From: perry at stsci.edu (Perry Greenfield) Date: Mon, 18 Jul 2005 09:18:32 -0400 Subject: [AstroPy] Re: [SciPy-user] pyfits question: handling gzipped fits files In-Reply-To: <42DAAF76.4030503@csun.edu> References: <200507150441.37510.mpfitz@berkeley.edu> <42DAAF76.4030503@csun.edu> Message-ID: On Jul 17, 2005, at 3:20 PM, Stephen Walton wrote: > Does Pyfits support the internally compressed FITS files described in > this link > > http://ledas-www.star.le.ac.uk/lheasoft/fitsio/compression/ > compress_image.html > > of which I see Perry is a co-author? Of course, reading such files is > one thing, having software to write them quite another. CFITSIO can > do it, I think. > Not yet, but should be within a 2-3 months (resources permitting). Perry From rowen at u.washington.edu Fri Jul 22 17:14:21 2005 From: rowen at u.washington.edu (Russell E Owen) Date: Fri, 22 Jul 2005 14:14:21 -0700 Subject: [AstroPy] PyGuide 2.0 released Message-ID: PyGuide 2.0 is now available from . PyGuide offers image analysis routines for telescope guiding, including a star finder, centroider and star shape fitter. The algorithms are designed to work well with partial images, e.g. where much of the image of a star is lost down a spectrograph slit or off the edge of a coherent fiber optic bundle. Version 2.0 is a major overhaul based on use at Apache Point Observatory. In particular, centroid and starShape have been much improved. StarShape still does not measure ellipticity. If anyone has a reliable algorithm for measuring ellipticity even on heavily masked data, I would like to know about it. By reliable I mean that it includes an error estimate so I know when not to trust the results. -- Russell P.S. Future plans: - Add a measure of ellipticity - Replace satLevel with a saturation mask - Work with Float32 images instead of UInt16 the last two changes will make PyGuide easier to use with flat-fielded images. From perry at stsci.edu Tue Jul 26 17:52:02 2005 From: perry at stsci.edu (Perry Greenfield) Date: Tue, 26 Jul 2005 17:52:02 -0400 Subject: [AstroPy] "Using Python for Interactive Data Analysis" tutorial available Message-ID: <6f83e4841620a3e3466ad71c5084076f@stsci.edu> A tutorial that illustrates how Python can be used to analyze and visualize astronomical data (much like one can do in IDL) has been written and now is available at: http://www.scipy.org/wikis/topical_software/Tutorial