Please keep the discussion on the mailing list.
On Mon, Apr 15, 2013 at 03:42:43PM -0700, Zubin Huang wrote:
> I am now stuck with another problem.
>
> I tried to save the datafield to a tiff file by the following
> script. But it always freezes when I run through pygwy console.
>
> gwyutils.save_dfield_to_png(c, key, "_fixed.tiff", gwy.RUN_NONINTERACTIVE)
>
> Would you please help me resolve the frozen problem? Do I need to
> open the file in gwyddion GUI to use gwyutils? Seems like that would
> defeat the purpose of using pygwy for multiple files processing.
It does not freeze for me but running scripts pygwy console is not a
good way to batch-process all files in a directory anyway because it
will open them all in the running Gwyddion.
Rendering images is tricky because it depends, for historical reasons,
on running GUI (at least in some rudimentary form). I would do
something like this in a standalone script
----------------------------------------------------------------
import gwy, gwyutils, os, glob, re
settings = gwy.gwy_app_settings_get()
# Set options in settings...
for filename in glob.glob('*.gwy'):
c = gwy.gwy_file_load(filename, gwy.RUN_NONINTERACTIVE)
gwy.gwy_app_data_browser_add(c)
for key in c.keys_by_name():
if re.match(r'^/\d+/data$', key):
field = c[key]
xres = field.get_xres()
weights = gwy.DataLine(xres, 1.0, True)
weights.part_fill(0, xres//3, 1.0)
filtered = gwy.DataField.new_alike(field, False)
field.fft_filter_1d(filtered, weights,
gwy.ORIENTATION_HORIZONTAL,
gwy.INTERPOLATION_ROUND)
c[key] = filtered
newname = os.path.splitext(filename)[0] + '_fixed.tiff'
gwyutils.save_dfield_to_png(c, key, newname, gwy.RUN_NONINTERACTIVE)
gwy.gwy_app_data_browser_remove(c)
----------------------------------------------------------------
Except that it crashes with 2.31. I fixed it already so you can try
development snapshot 2.31.20130417 or later where this should work.
Regards,
Yeti
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Gwyddion-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gwyddion-users