Hi Tazkera,

Sorry for the delayed reply. You can annotate circles on slice plots like this:

http://yt-project.org/doc/visualizing/callbacks.html#overplot-a-circle-on-a-plot

Best,

John

On Sep 11, 2017, at 6:03 PM, tazkera haque <h.tazkera@gmail.com> wrote:

HI John, 

Just a little update from my part. I could do the same thing with creating a sphere of 400 arcmin and separating out the  desired value and and drawing a circle around it with some numpy and matplotlib functions. I am basically interested to see what function in yt can do these same things for me. I have also attached the resulted plot.

My code looks like the following:

from astropy.io import fits
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib.image as mpimg
import numpy as np

hdulist = fits.open('signal_wfilt_sn.fits')
scidata = hdulist[0].data
scidata

h = 1629
w = 1629
center = [815, 815]
radius = 400
def createCircularMask(h, w, center=center, radius=radius):

    Y, X = np.ogrid[:h, :w]
    dist_from_center = np.sqrt((X - center[0])**2 + (Y-center[1])**2)

    mask = dist_from_center <= radius
    return mask

img = scidata
h, w = img.shape[:2]
mask = createCircularMask(h, w)
masked_img = img.copy()
masked_img[~mask] = 0

imgplot = plt.imshow(masked_img)
hot = np.where(masked_img>4.5)
imgplot
c=plt.colorbar()
c.set_label('s/n')


plt.scatter(hot[0], hot[1],alpha=0.05, facecolor = "none", edgecolor='yellow')
plt.show()

Best
Tazkera 

On Sun, Sep 10, 2017 at 8:46 PM, tazkera haque <h.tazkera@gmail.com> wrote:
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.5
print('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 <jzuhone@gmail.com> wrote:
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:


Specifically, since you have a 2D fits file, it’d probably be simplest to use plot_2d:


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 <h.tazkera@gmail.com> 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:

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



<image.png>_______________________________________________
yt-users mailing list
yt-users@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org