[yt-svn] commit/yt: 4 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Mar 14 14:40:54 PDT 2012


4 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/a7fccea22f08/
changeset:   a7fccea22f08
branch:      yt
user:        jzuhone
date:        2012-03-14 18:30:54
summary:     Some refinements to writing FITS files from fixed resolution buffers.

1) Allows multiple fields to be written to the same file.
2) Allows file to be optionally GZIP'ed.
3) Updates header with physical coordinates and other keywords.

Still need to see if other keywords need to be added.
affected #:  1 file

diff -r 306640bd4e4a37f9756d8c4a3e5b3ba7e1087bb9 -r a7fccea22f083ce18ceef4b7040e4f80489af395 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -214,7 +214,9 @@
             output.create_dataset(field,data=self[field])
         output.close()
 
-    def export_fits(self, filename_prefix, fields = None, clobber=False):
+    def export_fits(self, filename_prefix, fields = None, clobber=False,
+                    other_keys=None, gzip_file=False, units="1"):
+
         """
         This will export a set of FITS images of either the fields specified
         or all the fields already in the object.  The output filenames are
@@ -238,21 +240,89 @@
             These fields will be pixelized and output.
         clobber : boolean
             If the file exists, this governs whether we will overwrite.
+        other_keys : dictionary, optional
+            A set of header keys and values to write into the FITS header.
+        gzip_file : boolean, optional
+            gzip the file after writing, default False
+        units : string, optional
+            the length units that the coordinates are written in, default '1'
         """
+        
         import pyfits
         extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
         if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
         if fields is None: 
             fields = [field for field in self.data_source.fields 
                       if field not in extra_fields]
+
+        nx, ny = self.buff_size
+        dx = (self.bounds[1]-self.bounds[0])/nx*self.pf[units]
+        dy = (self.bounds[3]-self.bounds[2])/ny*self.pf[units]
+        xmin = self.bounds[0]*self.pf[units]
+        ymin = self.bounds[2]*self.pf[units]
+        simtime = self.pf.current_time
+
+        hdus = []
+
+        first = True
+        
         for field in fields:
-            hdu = pyfits.PrimaryHDU(self[field])
+
+            if (first) :
+                hdu = pyfits.PrimaryHDU(self[field])
+            else :
+                hdu = pyfits.ImageHDU(self[field])
+                first = False
+                
             if self.data_source.has_key('weight_field'):
                 weightname = self.data_source._weight
                 if weightname is None: weightname = 'None'
                 field = field +'_'+weightname
-            hdu.writeto("%s_%s.fits" % (filename_prefix, field),clobber=clobber)
 
+            hdu.header.update("Field", field)
+            hdu.header.update("Time", simtime)
+
+            """
+            hdu.header.update('WCSNAMEP', 'PHYSICAL')
+            hdu.header.update('MFORM1', 'X,Y')
+            hdu.header.update('MFORM2', 'X,Y')
+            hdu.header.update('CTYPE1P', "X")
+            hdu.header.update('CTYPE2P', "Y")
+            hdu.header.update('CRPIX1P', 0.5)
+            hdu.header.update('CRPIX2P', 0.5)
+            hdu.header.update('CRVAL1P', xmin)
+            hdu.header.update('CRVAL2P', ymin)
+            hdu.header.update('CDELT1P', dx)
+            hdu.header.update('CDELT2P', dy)
+            """
+            
+            hdu.header.update('CTYPE1', "LINEAR")
+            hdu.header.update('CTYPE2', "LINEAR")                                
+            hdu.header.update('CUNIT1', units)
+            hdu.header.update('CUNIT2', units)
+            hdu.header.update('CRPIX1', 0.5)
+            hdu.header.update('CRPIX2', 0.5)
+            hdu.header.update('CRVAL1', xmin)
+            hdu.header.update('CRVAL2', ymin)
+            hdu.header.update('CDELT1', dx)
+            hdu.header.update('CDELT2', dy)
+
+            if (other_keys is not None) :
+
+                for k,v in other_keys.items() :
+
+                    hdu.header.update(k,v)
+
+            hdus.append(hdu)
+
+            del hdu
+            
+        hdulist = pyfits.HDUList(hdus)
+
+        hdulist.writeto("%s.fits" % (filename_prefix), clobber=clobber)
+        
+        if (gzip_file) : system("gzip -f %s.fits" % (filename_prefix))
+        
     def open_in_ds9(self, field, take_log=True):
         """
         This will open a given field in the DS9 viewer.



https://bitbucket.org/yt_analysis/yt/changeset/c88553bbf3dc/
changeset:   c88553bbf3dc
branch:      yt
user:        jzuhone
date:        2012-03-14 21:50:38
summary:     More enhancements regarding writing FITS files in yt.

1) Cleaned up the "export_fits" method of FixedResolutionBuffer from
my last commit. The new enhancements allow the user to write multiple fields
to one file, add a coordinate system to the file, and add other keywords.
Files may also be optionally gzipped.
2) Added a "write_fits" function with similar functionality as "write_image",
except that it writes a floating-point array to a FITS image.
3) Improved the export of rgba FITS images by writing all image blocks
to one file.
affected #:  3 files

diff -r a7fccea22f083ce18ceef4b7040e4f80489af395 -r c88553bbf3dcd8f3beb74f7ab43a0bfeb32ad41b yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -219,18 +219,18 @@
 
         """
         This will export a set of FITS images of either the fields specified
-        or all the fields already in the object.  The output filenames are
-        *filename_prefix* plus an underscore plus the name of the field. If 
-        clobber is set to True, this will overwrite any existing FITS file.
+        or all the fields already in the object.  The output filename is
+        *filename_prefix*. If clobber is set to True, this will overwrite any
+        existing FITS file.
 
         This requires the *pyfits* module, which is a standalone module
         provided by STSci to interface with FITS-format files.
         """
-        r"""Export a set of pixelized fields to a set of fits files.
+        r"""Export a set of pixelized fields to a FITS file.
 
         This will export a set of FITS images of either the fields specified
-        or all the fields already in the object.  The output filenames are
-        the specified prefix plus an underscore plus the name of the field.
+        or all the fields already in the object.  The output filename is the
+        the specified prefix.
 
         Parameters
         ----------
@@ -249,6 +249,8 @@
         """
         
         import pyfits
+        from os import system
+        
         extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
         if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
         if fields is None: 
@@ -270,9 +272,9 @@
 
             if (first) :
                 hdu = pyfits.PrimaryHDU(self[field])
+                first = False
             else :
                 hdu = pyfits.ImageHDU(self[field])
-                first = False
                 
             if self.data_source.has_key('weight_field'):
                 weightname = self.data_source._weight
@@ -282,20 +284,16 @@
             hdu.header.update("Field", field)
             hdu.header.update("Time", simtime)
 
-            """
-            hdu.header.update('WCSNAMEP', 'PHYSICAL')
-            hdu.header.update('MFORM1', 'X,Y')
-            hdu.header.update('MFORM2', 'X,Y')
-            hdu.header.update('CTYPE1P', "X")
-            hdu.header.update('CTYPE2P', "Y")
+            hdu.header.update('WCSNAMEP', "PHYSICAL")            
+            hdu.header.update('CTYPE1P', "LINEAR")
+            hdu.header.update('CTYPE2P', "LINEAR")
             hdu.header.update('CRPIX1P', 0.5)
             hdu.header.update('CRPIX2P', 0.5)
             hdu.header.update('CRVAL1P', xmin)
             hdu.header.update('CRVAL2P', ymin)
             hdu.header.update('CDELT1P', dx)
             hdu.header.update('CDELT2P', dy)
-            """
-            
+                    
             hdu.header.update('CTYPE1', "LINEAR")
             hdu.header.update('CTYPE2', "LINEAR")                                
             hdu.header.update('CUNIT1', units)
@@ -321,7 +319,10 @@
 
         hdulist.writeto("%s.fits" % (filename_prefix), clobber=clobber)
         
-        if (gzip_file) : system("gzip -f %s.fits" % (filename_prefix))
+        if (gzip_file) :
+            clob = ""
+            if (clobber) : clob = "-f"
+            system("gzip "+clob+" %s.fits" % (filename_prefix))
         
     def open_in_ds9(self, field, take_log=True):
         """


diff -r a7fccea22f083ce18ceef4b7040e4f80489af395 -r c88553bbf3dcd8f3beb74f7ab43a0bfeb32ad41b yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -411,3 +411,70 @@
 
     pl.clf()
     pl.close()
+
+def write_fits(image, filename_prefix, clobber=True, coords=None, gzip_file=False) :
+
+    """
+    This will export a FITS image of a floating point array. The output filename is
+    *filename_prefix*. If clobber is set to True, this will overwrite any existing
+    FITS file.
+    
+    This requires the *pyfits* module, which is a standalone module
+    provided by STSci to interface with FITS-format files.
+    """
+    r"""Write out a floating point array directly to a FITS file, optionally
+    adding coordinates. 
+        
+    Parameters
+    ----------
+    image : array_like
+        This is an (unscaled) array of floating point values, shape (N,N,) to save
+        in a FITS file.
+    filename_prefix : string
+        This prefix will be prepended to every FITS file name.
+    clobber : boolean
+        If the file exists, this governs whether we will overwrite.
+    coords : dictionary, optional
+        A set of header keys and values to write to the FITS header to set up
+        a coordinate system. 
+    gzip_file : boolean, optional
+        gzip the file after writing, default False
+    """
+    
+    import pyfits
+    from os import system
+    
+    if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
+    
+    hdu = pyfits.PrimaryHDU(image)
+
+    if (coords is not None) :
+
+        hdu.header.update('WCSNAMEP', "PHYSICAL")
+        hdu.header.update('CTYPE1P', "LINEAR")
+        hdu.header.update('CTYPE2P', "LINEAR")
+        hdu.header.update('CRPIX1P', 0.5)
+        hdu.header.update('CRPIX2P', 0.5)
+        hdu.header.update('CRVAL1P', coords["xmin"])
+        hdu.header.update('CRVAL2P', coords["ymin"])
+        hdu.header.update('CDELT1P', coords["dx"])
+        hdu.header.update('CDELT2P', coords["dy"])
+        
+        hdu.header.update('CTYPE1', "LINEAR")
+        hdu.header.update('CTYPE2', "LINEAR")
+        hdu.header.update('CUNIT1', coords["units"])
+        hdu.header.update('CUNIT2', coords["units"])
+        hdu.header.update('CRPIX1', 0.5)
+        hdu.header.update('CRPIX2', 0.5)
+        hdu.header.update('CRVAL1', coords["xmin"])
+        hdu.header.update('CRVAL2', coords["ymin"])
+        hdu.header.update('CDELT1', coords["dx"])
+        hdu.header.update('CDELT2', coords["dy"])
+
+    hdu.writeto("%s.fits" % (filename_prefix), clobber=clobber)
+
+    if (gzip_file) :
+        clob = ""
+        if (clobber) : clob="-f"
+        system("gzip "+clob+" %s.fits" % (filename_prefix))
+    


diff -r a7fccea22f083ce18ceef4b7040e4f80489af395 -r c88553bbf3dcd8f3beb74f7ab43a0bfeb32ad41b yt/visualization/volume_rendering/image_handling.py
--- a/yt/visualization/volume_rendering/image_handling.py
+++ b/yt/visualization/volume_rendering/image_handling.py
@@ -45,18 +45,12 @@
         f.close()
     if fits:
         try:
-            hdu = pyfits.PrimaryHDU(image[:,:,0])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_r.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,1])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_g.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,2])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_b.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,3])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_a.fits'%fn,clobber=True)
+            hdur = pyfits.PrimaryHDU(image[:,:,0])
+            hdug = pyfits.ImageHDU(image[:,:,1])
+            hdub = pyfits.ImageHDU(image[:,:,2])
+            hdua = pyfits.ImageHDU(image[:,:,3])
+            hdulist = pyfits.HDUList([hdur,hdug,hdub,hdua])
+            hdulist.writeto('%s.fits'%fn,clobber=True)
         except: print 'You do not have pyfits, install before attempting to use fits exporter'
 
 def import_rgba(name, h5=True):



https://bitbucket.org/yt_analysis/yt/changeset/b6ac05ef1a07/
changeset:   b6ac05ef1a07
branch:      yt
user:        jzuhone
date:        2012-03-14 22:06:27
summary:     Need to get write_fits into api
affected #:  2 files

diff -r c88553bbf3dcd8f3beb74f7ab43a0bfeb32ad41b -r b6ac05ef1a0787dfce2890040c0fdf174e7cf410 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -116,7 +116,7 @@
     PlotCollection, PlotCollectionInteractive, \
     get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
     callback_registry, write_bitmap, write_image, annotate_image, \
-    apply_colormap, scale_image, write_projection
+    apply_colormap, scale_image, write_projection, write_fits
 
 from yt.visualization.volume_rendering.api import \
     ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \


diff -r c88553bbf3dcd8f3beb74f7ab43a0bfeb32ad41b -r b6ac05ef1a0787dfce2890040c0fdf174e7cf410 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -50,7 +50,8 @@
     annotate_image, \
     apply_colormap, \
     scale_image, \
-    write_projection
+    write_projection, \
+    write_fits
 
 from plot_modifications import \
     PlotCallback, \



https://bitbucket.org/yt_analysis/yt/changeset/c604391a0808/
changeset:   c604391a0808
branch:      yt
user:        jzuhone
date:        2012-03-14 22:24:01
summary:     Changes to the way that yt writes FITS files.

1) FixedResolutionBuffer.export_fits:

a) Write more than one field from the frb to a single file instead of
multiple files.
b) Optionally gzip the file.
c) Write header keywords for the coordinate system and for the field names
and simulation time. Accepts an optional dict for other keywords.

2) A "write_fits" function for writing floating-point arrays on the fly,
similar to "write_image" for PNGs. Can take a dictionary for writing the
coordinate system to the file. Also can be optionally gzipped.

3) For volume rendering, export a single FITS file with the r,g,b,a images
rather than 4.
affected #:  5 files

diff -r dbc3109b9cff7706c6866a6b38a74414c44f00c3 -r c604391a080887d0fb9d573ab685b2f28a0f984e yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -116,7 +116,7 @@
     PlotCollection, PlotCollectionInteractive, \
     get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
     callback_registry, write_bitmap, write_image, annotate_image, \
-    apply_colormap, scale_image, write_projection
+    apply_colormap, scale_image, write_projection, write_fits
 
 from yt.visualization.volume_rendering.api import \
     ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \


diff -r dbc3109b9cff7706c6866a6b38a74414c44f00c3 -r c604391a080887d0fb9d573ab685b2f28a0f984e yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -50,7 +50,8 @@
     annotate_image, \
     apply_colormap, \
     scale_image, \
-    write_projection
+    write_projection, \
+    write_fits
 
 from plot_modifications import \
     PlotCallback, \


diff -r dbc3109b9cff7706c6866a6b38a74414c44f00c3 -r c604391a080887d0fb9d573ab685b2f28a0f984e yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -214,21 +214,23 @@
             output.create_dataset(field,data=self[field])
         output.close()
 
-    def export_fits(self, filename_prefix, fields = None, clobber=False):
+    def export_fits(self, filename_prefix, fields = None, clobber=False,
+                    other_keys=None, gzip_file=False, units="1"):
+
         """
         This will export a set of FITS images of either the fields specified
-        or all the fields already in the object.  The output filenames are
-        *filename_prefix* plus an underscore plus the name of the field. If 
-        clobber is set to True, this will overwrite any existing FITS file.
+        or all the fields already in the object.  The output filename is
+        *filename_prefix*. If clobber is set to True, this will overwrite any
+        existing FITS file.
 
         This requires the *pyfits* module, which is a standalone module
         provided by STSci to interface with FITS-format files.
         """
-        r"""Export a set of pixelized fields to a set of fits files.
+        r"""Export a set of pixelized fields to a FITS file.
 
         This will export a set of FITS images of either the fields specified
-        or all the fields already in the object.  The output filenames are
-        the specified prefix plus an underscore plus the name of the field.
+        or all the fields already in the object.  The output filename is the
+        the specified prefix.
 
         Parameters
         ----------
@@ -238,21 +240,90 @@
             These fields will be pixelized and output.
         clobber : boolean
             If the file exists, this governs whether we will overwrite.
+        other_keys : dictionary, optional
+            A set of header keys and values to write into the FITS header.
+        gzip_file : boolean, optional
+            gzip the file after writing, default False
+        units : string, optional
+            the length units that the coordinates are written in, default '1'
         """
+        
         import pyfits
+        from os import system
+        
         extra_fields = ['x','y','z','px','py','pz','pdx','pdy','pdz','weight_field']
         if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
         if fields is None: 
             fields = [field for field in self.data_source.fields 
                       if field not in extra_fields]
+
+        nx, ny = self.buff_size
+        dx = (self.bounds[1]-self.bounds[0])/nx*self.pf[units]
+        dy = (self.bounds[3]-self.bounds[2])/ny*self.pf[units]
+        xmin = self.bounds[0]*self.pf[units]
+        ymin = self.bounds[2]*self.pf[units]
+        simtime = self.pf.current_time
+
+        hdus = []
+
+        first = True
+        
         for field in fields:
-            hdu = pyfits.PrimaryHDU(self[field])
+
+            if (first) :
+                hdu = pyfits.PrimaryHDU(self[field])
+                first = False
+            else :
+                hdu = pyfits.ImageHDU(self[field])
+                
             if self.data_source.has_key('weight_field'):
                 weightname = self.data_source._weight
                 if weightname is None: weightname = 'None'
                 field = field +'_'+weightname
-            hdu.writeto("%s_%s.fits" % (filename_prefix, field),clobber=clobber)
 
+            hdu.header.update("Field", field)
+            hdu.header.update("Time", simtime)
+
+            hdu.header.update('WCSNAMEP', "PHYSICAL")            
+            hdu.header.update('CTYPE1P', "LINEAR")
+            hdu.header.update('CTYPE2P', "LINEAR")
+            hdu.header.update('CRPIX1P', 0.5)
+            hdu.header.update('CRPIX2P', 0.5)
+            hdu.header.update('CRVAL1P', xmin)
+            hdu.header.update('CRVAL2P', ymin)
+            hdu.header.update('CDELT1P', dx)
+            hdu.header.update('CDELT2P', dy)
+                    
+            hdu.header.update('CTYPE1', "LINEAR")
+            hdu.header.update('CTYPE2', "LINEAR")                                
+            hdu.header.update('CUNIT1', units)
+            hdu.header.update('CUNIT2', units)
+            hdu.header.update('CRPIX1', 0.5)
+            hdu.header.update('CRPIX2', 0.5)
+            hdu.header.update('CRVAL1', xmin)
+            hdu.header.update('CRVAL2', ymin)
+            hdu.header.update('CDELT1', dx)
+            hdu.header.update('CDELT2', dy)
+
+            if (other_keys is not None) :
+
+                for k,v in other_keys.items() :
+
+                    hdu.header.update(k,v)
+
+            hdus.append(hdu)
+
+            del hdu
+            
+        hdulist = pyfits.HDUList(hdus)
+
+        hdulist.writeto("%s.fits" % (filename_prefix), clobber=clobber)
+        
+        if (gzip_file) :
+            clob = ""
+            if (clobber) : clob = "-f"
+            system("gzip "+clob+" %s.fits" % (filename_prefix))
+        
     def open_in_ds9(self, field, take_log=True):
         """
         This will open a given field in the DS9 viewer.


diff -r dbc3109b9cff7706c6866a6b38a74414c44f00c3 -r c604391a080887d0fb9d573ab685b2f28a0f984e yt/visualization/image_writer.py
--- a/yt/visualization/image_writer.py
+++ b/yt/visualization/image_writer.py
@@ -411,3 +411,70 @@
 
     pl.clf()
     pl.close()
+
+def write_fits(image, filename_prefix, clobber=True, coords=None, gzip_file=False) :
+
+    """
+    This will export a FITS image of a floating point array. The output filename is
+    *filename_prefix*. If clobber is set to True, this will overwrite any existing
+    FITS file.
+    
+    This requires the *pyfits* module, which is a standalone module
+    provided by STSci to interface with FITS-format files.
+    """
+    r"""Write out a floating point array directly to a FITS file, optionally
+    adding coordinates. 
+        
+    Parameters
+    ----------
+    image : array_like
+        This is an (unscaled) array of floating point values, shape (N,N,) to save
+        in a FITS file.
+    filename_prefix : string
+        This prefix will be prepended to every FITS file name.
+    clobber : boolean
+        If the file exists, this governs whether we will overwrite.
+    coords : dictionary, optional
+        A set of header keys and values to write to the FITS header to set up
+        a coordinate system. 
+    gzip_file : boolean, optional
+        gzip the file after writing, default False
+    """
+    
+    import pyfits
+    from os import system
+    
+    if filename_prefix.endswith('.fits'): filename_prefix=filename_prefix[:-5]
+    
+    hdu = pyfits.PrimaryHDU(image)
+
+    if (coords is not None) :
+
+        hdu.header.update('WCSNAMEP', "PHYSICAL")
+        hdu.header.update('CTYPE1P', "LINEAR")
+        hdu.header.update('CTYPE2P', "LINEAR")
+        hdu.header.update('CRPIX1P', 0.5)
+        hdu.header.update('CRPIX2P', 0.5)
+        hdu.header.update('CRVAL1P', coords["xmin"])
+        hdu.header.update('CRVAL2P', coords["ymin"])
+        hdu.header.update('CDELT1P', coords["dx"])
+        hdu.header.update('CDELT2P', coords["dy"])
+        
+        hdu.header.update('CTYPE1', "LINEAR")
+        hdu.header.update('CTYPE2', "LINEAR")
+        hdu.header.update('CUNIT1', coords["units"])
+        hdu.header.update('CUNIT2', coords["units"])
+        hdu.header.update('CRPIX1', 0.5)
+        hdu.header.update('CRPIX2', 0.5)
+        hdu.header.update('CRVAL1', coords["xmin"])
+        hdu.header.update('CRVAL2', coords["ymin"])
+        hdu.header.update('CDELT1', coords["dx"])
+        hdu.header.update('CDELT2', coords["dy"])
+
+    hdu.writeto("%s.fits" % (filename_prefix), clobber=clobber)
+
+    if (gzip_file) :
+        clob = ""
+        if (clobber) : clob="-f"
+        system("gzip "+clob+" %s.fits" % (filename_prefix))
+    


diff -r dbc3109b9cff7706c6866a6b38a74414c44f00c3 -r c604391a080887d0fb9d573ab685b2f28a0f984e yt/visualization/volume_rendering/image_handling.py
--- a/yt/visualization/volume_rendering/image_handling.py
+++ b/yt/visualization/volume_rendering/image_handling.py
@@ -45,18 +45,12 @@
         f.close()
     if fits:
         try:
-            hdu = pyfits.PrimaryHDU(image[:,:,0])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_r.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,1])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_g.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,2])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_b.fits'%fn,clobber=True)
-            hdu = pyfits.PrimaryHDU(image[:,:,3])
-            hdulist = pyfits.HDUList([hdu])
-            hdulist.writeto('%s_a.fits'%fn,clobber=True)
+            hdur = pyfits.PrimaryHDU(image[:,:,0])
+            hdug = pyfits.ImageHDU(image[:,:,1])
+            hdub = pyfits.ImageHDU(image[:,:,2])
+            hdua = pyfits.ImageHDU(image[:,:,3])
+            hdulist = pyfits.HDUList([hdur,hdug,hdub,hdua])
+            hdulist.writeto('%s.fits'%fn,clobber=True)
         except: print 'You do not have pyfits, install before attempting to use fits exporter'
 
 def import_rgba(name, h5=True):

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list