On Mon, Jan 10, 2011 at 06:08:01PM -0300, Francisco Balzarotti wrote:
> I'm working with a homemade afm, I'd like to export files from the
> acquisition software (that I wrote) to Gwyddion.
> I'd like to export topography and error images. No additional data.
> 
> I'm not quite sure which is the most suitable -and simple- file format to
> use. Any thoughts?

If you don't mind having each channel as a separate file then GSF

    http://gwyddion.net/documentation/user-guide-en/gsf.html

that was created for this purpose.  It can be saved by simple code such
as

static void
save_gsf(GwyDataField *field, const gchar *filename)
{
    const gchar header_template[] =
        "Gwyddion Simple Field 1.0\n"
        "XRes = %u\n"
        "YRes = %u\n"
        "XReal = %g\n"
        "YReal = %g\n"
        "XYUnits = m\n"
        "ZUnits = m\n"
        "Title = Topography\n";
    const gchar padding[4] = { 0, 0, 0, 0 };

    gchar *header = g_strdup_printf(header_template,
                                    field->xres, field->yres,
                                    field->xreal, field->yreal);
    gsize len = strlen(header);
    gsize npad = 4 - (len % 4);
    gsize i, n = field->xres * field->yres;
    gfloat *fltdata = g_new(gfloat, n);
    FILE *fh = fopen(filename, "wb");

    if (fh) {
        for (i = 0; i < n; i++)
            fltdata[i] = field->data[i];
        fwrite(header, len, 1, fh);
        fwrite(padding, npad, 1, fh);
        fwrite(fltdata, sizeof(gfloat), n, fh);
        fclose(fh);
    }
    else {
        fprintf(stderr, "Cannot open %s: %s\n", filename, strerror(errno));
    }
    g_free(fltdata);
    g_free(header);
}


Regards,

Yeti


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Gwyddion-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gwyddion-users

Reply via email to