[yt-users] Creating image from FITS data

tazkera haque h.tazkera at gmail.com
Fri Sep 8 16:28:59 PDT 2017


Hi People,

I am trying to play around with FITS file format. I want to create an image
from this file which will include data from center to 20 arc minutes. each
pixel is 3x3 arc sec.

*import yt*
*ds = yt.load("signal_wfilt_sn.fits")*
*ds.print_stats()*

*ds.field_list*

*ds.domain_width*

*ds.derived_field_list*
*dd = ds.all_data()*
*dd*

*sp = ds.sphere(ds.domain_center, (400, 'code_length'))  # create sphere of
20 arcminutes with 3x3 pixel size*

*sp[("fits", "image_0")]
     # check array of data within the sphere*
*#plot 1D histogram of data over pixel*
*pplot = yt.ProfilePlot(sp, "image_0", ["pixel"], weight_field=None,
n_bins=1024, *
*plot_spec=dict(color='red', linestyle="--"), y_log={'pixel':False})*
*pplot.show()*
*# convert data to numpy array*
*import numpy as np*
*image = np.array(sp['image_0'])*

*# create image?*
*imgplot = plt.imshow(image)*

*imgplot*
*plt.show()*
*image*

*The code is failing at this point with error:*

---------------------------------------------------------------------------TypeError
                                Traceback (most recent call
last)<ipython-input-21-6a83e68fbbf2> in <module>()----> 1 imgplot =
plt.imshow(image)      2       3 imgplot      4 plt.show()
/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc
in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax,
origin, extent, shape, filternorm, filterrad, imlim, resample, url,
hold, data, **kwargs)   3155
filternorm=filternorm, filterrad=filterrad,   3156
    imlim=imlim, resample=resample, url=url, data=data,-> 3157
                **kwargs)   3158     finally:   3159         ax._hold
= washold
/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc
in inner(ax, *args, **kwargs)   1896
warnings.warn(msg % (label_namer, func.__name__),   1897
                    RuntimeWarning, stacklevel=2)-> 1898
return func(ax, *args, **kwargs)   1899         pre_doc =
inner.__doc__   1900         if pre_doc is None:
/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc
in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin,
vmax, origin, extent, shape, filternorm, filterrad, imlim, resample,
url, **kwargs)   5122                               resample=resample,
**kwargs)   5123 -> 5124         im.set_data(X)   5125
im.set_alpha(alpha)   5126         if im.get_clip_path() is None:
/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/image.pyc
in set_data(self, A)    598         if (self._A.ndim not in (2, 3) or
  599                 (self._A.ndim == 3 and self._A.shape[-1] not in
(3, 4))):--> 600             raise TypeError("Invalid dimensions for
image data")    601     602         self._imcache = None
TypeError: Invalid dimensions for image data


I am completely new to image processing, so I am interested to know how you
create image for this type of data in yt. Your help is very appreciated. I
have also attached the jupyter notebook and the actual data I am using for
the processing.

Thanks a lot
Tazkera Haque
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170908/5c4fb3b5/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signal_wfilt_sn.fits
Type: image/fits
Size: 21234240 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170908/5c4fb3b5/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FITS data to image.ipynb
Type: application/octet-stream
Size: 73266 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170908/5c4fb3b5/attachment-0001.obj>


More information about the yt-users mailing list