
Does anyone know a way to convolve a yt image (preferably pc.add_projection) with a telescope psf? This would be useful for simulated observations. At the moment, the best I can do is make an image in yt and then convolve that image in pixel space, but this ends up blurring out things I do not want blurred (like particle markers, or velocity arrows). The psf does not need to be fancy, I just want a 2D gaussian with an adjustable width. Ideally, there would be a call pc.add_projection("Density", 0, psf_width = 1.5e13) #create a projection with a psf width of 1 AU at the observed distance Charles

Hi, Charles-- I think you want to write a new callback. Check out what's done in yt/visualizations/plot_modifications.py. (raven/PlotCallbacks if you're not o yt2.0) Basically, you: 1.) Subclass PlotCallback 2.) Give it a _type_name 3.) it needs an __init__ with whatever args you want 4.) it needs a __call__ that takes (self, plot). This does the work 5.) Most everything you need is hung off plot.image and plot._axis. There are a ton of good examples in the file I mentioned above 6.) You can add the callback by doing
ploot= pc.add_projection(whatevz) ploot.modify['ConvolveCharles']() (this might require registering your callback somewhere, I can't remember)
From there, make sure your convolution is done before other callbacks, and you're set.
The MarkerAnnotateCallback is a good one to look at for callback syntax. d. On Thu, Feb 24, 2011 at 4:02 PM, Charles Hansen <chansen@astro.berkeley.edu> wrote:
Does anyone know a way to convolve a yt image (preferably pc.add_projection) with a telescope psf? This would be useful for simulated observations. At the moment, the best I can do is make an image in yt and then convolve that image in pixel space, but this ends up blurring out things I do not want blurred (like particle markers, or velocity arrows). The psf does not need to be fancy, I just want a 2D gaussian with an adjustable width.
Ideally, there would be a call pc.add_projection("Density", 0, psf_width = 1.5e13) #create a projection with a psf width of 1 AU at the observed distance
Charles
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Sent from my Stone Tablet and carried by my Pterodactyl.

Hi Charles, I think Dave's right, you should subclass PlotCallback, add it to: yt/visualization/plot_modifications.py and then give it an appropriate name. I think this would be a great addition to the code base; I agree, it is important to have functions like this available. I'd recommend you fork the yt repo at http://hg.enzotools.org/yt/fork and then make these changes. Then you can issue a pull request, and we'll incorporate them into the main repository. The BitBucket site (which you can log into with a Google Account) has more info about how to set up your hg username, but if you have a yt install you already have mercurial, so it should be pretty easy. Thanks! Matt On Thu, Feb 24, 2011 at 7:28 PM, David Collins <dcollins@physics.ucsd.edu> wrote:
Hi, Charles--
I think you want to write a new callback. Check out what's done in yt/visualizations/plot_modifications.py. (raven/PlotCallbacks if you're not o yt2.0) Basically, you:
1.) Subclass PlotCallback 2.) Give it a _type_name 3.) it needs an __init__ with whatever args you want 4.) it needs a __call__ that takes (self, plot). This does the work 5.) Most everything you need is hung off plot.image and plot._axis. There are a ton of good examples in the file I mentioned above 6.) You can add the callback by doing
ploot= pc.add_projection(whatevz) ploot.modify['ConvolveCharles']() (this might require registering your callback somewhere, I can't remember)
From there, make sure your convolution is done before other callbacks, and you're set.
The MarkerAnnotateCallback is a good one to look at for callback syntax.
d.
On Thu, Feb 24, 2011 at 4:02 PM, Charles Hansen <chansen@astro.berkeley.edu> wrote:
Does anyone know a way to convolve a yt image (preferably pc.add_projection) with a telescope psf? This would be useful for simulated observations. At the moment, the best I can do is make an image in yt and then convolve that image in pixel space, but this ends up blurring out things I do not want blurred (like particle markers, or velocity arrows). The psf does not need to be fancy, I just want a 2D gaussian with an adjustable width.
Ideally, there would be a call pc.add_projection("Density", 0, psf_width = 1.5e13) #create a projection with a psf width of 1 AU at the observed distance
Charles
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Sent from my Stone Tablet and carried by my Pterodactyl. _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Thanks Dave and Matt, I got my convolution working without too much effort once I found the plot.image.set_data function. The general strategy is ConvolvedData = ConvolutionFunction(plot.image._A.data, psf stuff) plot.image.set_data(ConvolvedData) Finding the 2nd line was my problem. This way I can modify the data before it gets to pixel space. There are no examples in the documentation that modify the image data like this, but it seems pretty powerful. Charles On 2/24/2011 4:28 PM, David Collins wrote:
Hi, Charles--
I think you want to write a new callback. Check out what's done in yt/visualizations/plot_modifications.py. (raven/PlotCallbacks if you're not o yt2.0) Basically, you:
1.) Subclass PlotCallback 2.) Give it a _type_name 3.) it needs an __init__ with whatever args you want 4.) it needs a __call__ that takes (self, plot). This does the work 5.) Most everything you need is hung off plot.image and plot._axis. There are a ton of good examples in the file I mentioned above 6.) You can add the callback by doing
ploot= pc.add_projection(whatevz) ploot.modify['ConvolveCharles']() (this might require registering your callback somewhere, I can't remember)
From there, make sure your convolution is done before other callbacks, and you're set.
The MarkerAnnotateCallback is a good one to look at for callback syntax.
d.
On Thu, Feb 24, 2011 at 4:02 PM, Charles Hansen <chansen@astro.berkeley.edu> wrote:
Does anyone know a way to convolve a yt image (preferably pc.add_projection) with a telescope psf? This would be useful for simulated observations. At the moment, the best I can do is make an image in yt and then convolve that image in pixel space, but this ends up blurring out things I do not want blurred (like particle markers, or velocity arrows). The psf does not need to be fancy, I just want a 2D gaussian with an adjustable width.
Ideally, there would be a call pc.add_projection("Density", 0, psf_width = 1.5e13) #create a projection with a psf width of 1 AU at the observed distance
Charles
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Thanks, Charles, that looks super useful. d. On Fri, Feb 25, 2011 at 3:17 PM, Charles Hansen <chansen@astro.berkeley.edu> wrote:
Thanks Dave and Matt,
I got my convolution working without too much effort once I found the plot.image.set_data function. The general strategy is
ConvolvedData = ConvolutionFunction(plot.image._A.data, psf stuff) plot.image.set_data(ConvolvedData)
Finding the 2nd line was my problem. This way I can modify the data before it gets to pixel space. There are no examples in the documentation that modify the image data like this, but it seems pretty powerful.
Charles
On 2/24/2011 4:28 PM, David Collins wrote:
Hi, Charles--
I think you want to write a new callback. Check out what's done in yt/visualizations/plot_modifications.py. (raven/PlotCallbacks if you're not o yt2.0) Basically, you:
1.) Subclass PlotCallback 2.) Give it a _type_name 3.) it needs an __init__ with whatever args you want 4.) it needs a __call__ that takes (self, plot). This does the work 5.) Most everything you need is hung off plot.image and plot._axis. There are a ton of good examples in the file I mentioned above 6.) You can add the callback by doing
ploot= pc.add_projection(whatevz) ploot.modify['ConvolveCharles']()
(this might require registering your callback somewhere, I can't remember)
From there, make sure your convolution is done before other callbacks, and you're set.
The MarkerAnnotateCallback is a good one to look at for callback syntax.
d.
On Thu, Feb 24, 2011 at 4:02 PM, Charles Hansen <chansen@astro.berkeley.edu> wrote:
Does anyone know a way to convolve a yt image (preferably pc.add_projection) with a telescope psf? This would be useful for simulated observations. At the moment, the best I can do is make an image in yt and then convolve that image in pixel space, but this ends up blurring out things I do not want blurred (like particle markers, or velocity arrows). The psf does not need to be fancy, I just want a 2D gaussian with an adjustable width.
Ideally, there would be a call pc.add_projection("Density", 0, psf_width = 1.5e13) #create a projection with a psf width of 1 AU at the observed distance
Charles
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Sent from my Stone Tablet and carried by my Pterodactyl.
participants (3)
-
Charles Hansen
-
David Collins
-
Matthew Turk