
In the following code (c attachment also) import pylab as P from yt.mods import * pf = load("RD0002/RedshiftOutput0002") c = pf.h.find_max('Density')[1] proj = pf.h.proj(1, 'Density') width = 96/pf['mpc'] # we want a 1.5 mpc view res = [1000, 1000] # create an image with 1000x1000 pixels frb = proj.to_frb(width, res, center=[0.5,0.5,0.5]) P.imshow(frb['Density']) P.xlabel(r'$x\ \mathrm{kpc}$') P.ylabel(r'$x\ \mathrm{furlongs}$') P.savefig('Density_y.png') My problem is to develop a new code which automatically take `n' input files (RD0001/RedshiftOutput0001, RD0002/RedshiftOutput0002, RD0003 /RedshiftOutput0003, ....) and want to save each output files in a folder. Please help me..... -- Reju Sam John

Hi Reju, An easy way that comes to my mind first is that you could set up a double-loop of n1 and n2, in which you specify the path and file name, say: path = "RD%04d/RedshiftOutput%04d" % (n1,n2) where n1 and n2 loop over the number of your directories and files. Then you could load the files one by one: pf = load(path) Best wishes, Suoqing On Feb 20, 2013, at 11:25 AM, Reju Sam John <rejusamjohn@gmail.com> wrote:
In the following code (c attachment also)
import pylab as P from yt.mods import * pf = load("RD0002/RedshiftOutput0002")
c = pf.h.find_max('Density')[1] proj = pf.h.proj(1, 'Density')
width = 96/pf['mpc'] # we want a 1.5 mpc view res = [1000, 1000] # create an image with 1000x1000 pixels frb = proj.to_frb(width, res, center=[0.5,0.5,0.5])
P.imshow(frb['Density']) P.xlabel(r'$x\ \mathrm{kpc}$') P.ylabel(r'$x\ \mathrm{furlongs}$') P.savefig('Density_y.png')
My problem is to develop a new code which automatically take `n' input files (RD0001/RedshiftOutput0001, RD0002/RedshiftOutput0002, RD0003/RedshiftOutput0003, ....) and want to save each output files in a folder.
Please help me.....
-- Reju Sam John <simple-slice.py>_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

Hi Reju, Thanks for writing, and welcome to yt! Suoqing's suggestion will definitely work. We also have a simpler shorthand for this, where you can do this with data series: ts = TimeSeriesData.from_filenames("RD*/RedshiftOutput*") for pf in ts: c = pf.h.find_max('Density')[1] proj = pf.h.proj(1, 'Density') width = 96/pf['mpc'] # we want a 1.5 mpc view res = [1000, 1000] # create an image with 1000x1000 pixels frb = proj.to_frb(width, res, center=[0.5,0.5,0.5]) P.imshow(frb['Density']) P.savefig('Density_y.png') There's even a simpler way if you want to do some processing on the data: ts = TimeSeriesData.from_filenames("RD*/RedshiftOutput*") for pf in ts: p = ProjectionPlot(pf, "y", "Density", center="max", width=(96.0, "max")) p.save() -Matt On Wed, Feb 20, 2013 at 11:25 AM, Reju Sam John <rejusamjohn@gmail.com> wrote:
In the following code (c attachment also)
import pylab as P from yt.mods import * pf = load("RD0002/RedshiftOutput0002")
c = pf.h.find_max('Density')[1] proj = pf.h.proj(1, 'Density')
width = 96/pf['mpc'] # we want a 1.5 mpc view res = [1000, 1000] # create an image with 1000x1000 pixels frb = proj.to_frb(width, res, center=[0.5,0.5,0.5])
P.imshow(frb['Density']) P.xlabel(r'$x\ \mathrm{kpc}$') P.ylabel(r'$x\ \mathrm{furlongs}$') P.savefig('Density_y.png')
My problem is to develop a new code which automatically take `n' input files (RD0001/RedshiftOutput0001, RD0002/RedshiftOutput0002, RD0003/RedshiftOutput0003, ....) and want to save each output files in a folder.
Please help me.....
-- Reju Sam John
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
Ji Suoqing
-
Matthew Turk
-
Reju Sam John