Hi John,
Thanks so much for all the help. I just need one more clarification from
you. I needed to identify values greater than 4.5 and draw a circle around
them. I used the masking function in yt to figure out the array which
contains those certain values. But Can you please show me how do I draw
circles around them in the same 2d plot?
*hot = dd["image_0"].in_units('dimensionless') > 4.5print('Temperature of
all data: dd["image_0"] = \n%s' % dd["image_0"])print("Boolean Mask: hot =
\n%s" % hot)print('Temperature of "hot" data: dd["image_0"][hot] = \n%s'
% dd['image_0'][hot])q = dd['image_0'][hot]print q*
Thanks a lot
Tazkera
On Sun, Sep 10, 2017 at 12:22 PM, John ZuHone
Hi Tazkera,
The issue here is that sp[“image_0”] is a 1-D array of the points in the sphere. If you want to make plots using yt, I would suggest checking out the plotting documentation:
http://yt-project.org/doc/visualizing/plots.html
Specifically, since you have a 2D fits file, it’d probably be simplest to use plot_2d:
http://yt-project.org/doc/visualizing/plots.html#plots-of-2d-datasets
If you want to cut out the data that isn’t in your sphere object, you can try passing the sphere object in as the data_source argument to plot_2d:
p = yt.plot_2d(ds, “image_0”, data_source=sp) p.save()
That should give you a head start.
Best,
John
On Sep 9, 2017, at 8:02 PM, tazkera haque
wrote: 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 also provided a link to the dataset:
https://www.dropbox.com/s/bftuihqcoun8tny/signal_wfilt_sn.fits?dl=0 Thanks a lot Tazkera haque _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org