On Sat, Apr 13, 2013 at 09:18:39AM -0700, Zubin Huang wrote:
> Also, I would like to use 1D fft to filter horizontal and vertical
> direction automatically. Would you please provide me an example on how to
> use fft_filter_1d(result_field, weights, orientation, interpolation)?

You can use it as follows (written as a standalone script run outside
Gwyddion):

import gwy, glob, re

for filename in glob.glob('*.gwy'):
    c = gwy.gwy_file_load(filename, gwy.RUN_NONINTERACTIVE)
    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//2, 1.0, True)
            weights.part_fill(0, xres//6, 1.0)
            filtered = gwy.DataField.new_alike(field, False)
            field.fft_filter_1d(filtered, weights,
                                gwy.ORIENTATION_HORIZONTAL,
                                gwy.INTERPOLATION_LINEAR)

            c[key] = filtered

    # Save the result somewhere, overwriting original isn't a good idea...
    #gwy.gwy_file_save(c, 'the-result.gwy', gwy.RUN_NONINTERACTIVE)

> How shall I write the script if I want to use horizontal direction,
> mark frequency domain from 0 to 1 and use linear interpolation to achieve
> the same result like the interactive module under GUI?

In general, you may want to pass weights of length of half the FFT size.
But they are interpolated to the correct size so you don't have to.  I'm
not sure what ‘from 0 to 1’ means but just fill part of the DataLine
with 1s (keep) and part with 0s (remove).

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

Reply via email to