Bug 227235 - data files in dirfile format not recognized
Summary: data files in dirfile format not recognized
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-16 18:47 UTC by freebody.kst
Modified: 2010-02-17 02:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to GetData-0.6.1 to fix ASCII get_n_frames. (503 bytes, application/octet-stream)
2010-02-17 00:18 UTC, D. V. Wiebe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description freebody.kst 2010-02-16 18:47:55 UTC
Version:           1.9.0_devel (using Devel)
OS:                Linux
Installed from:    Compiled sources

PROBLEM:
data files in dirfile format (Dirfile Standards version 7) cannot be recognized by kst 1.9_devel

STEPS TO REPRODUCE:
1)use the following code to generate data files:

#include <getdata.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
/* dirfile name */
const char *dirfile_name = "/home/freebody/test_dirfile";
/* field code */
const char *field_code = "datafield";

gd_type_t data_type = GD_FLOAT64;
gd_spf_t spf = 5;
int fragment_index = 0;
off_t first_frame = 0;
off_t first_sample = 0;
size_t num_frames = 100;


/* Open the dirfile */
DIRFILE *dirfile = dirfile_open(dirfile_name, GD_RDWR|GD_CREAT|GD_TEXT_ENCODED);
/**/
if (get_error(dirfile)) {
    printf("GetData error: failed to create a datafile\n");
    dirfile_close(dirfile);
    exit(1);
}



/* Add a raw field*/
dirfile_add_raw(dirfile, field_code, data_type, spf, fragment_index); 


/* Allocate a buffer */
double *data_buffer = malloc(sizeof(double) * spf * (num_frames - first_frame));

/* Fill up the buffer */
int i = 0;
int count = 0;
for (i=0; i<spf * (num_frames - first_frame); i++)
{
    data_buffer[i] = count - 25.0;
    count++;   
}

/* Write the dirfile*/

putdata(dirfile, field_code, first_frame, 0, num_frames - first_frame, 0, data_type, data_buffer); 

if (get_error(dirfile)) {
    printf("GetData error: failed to write the datafile\n");
    dirfile_close(dirfile);
    exit(1);
}
/* Clean up */
free(data_buffer);


dirfile_close(dirfile);

return 0;
}

2)open data wizard in kst. 


RESULTS:
Files created by the above code are not recognized as dirfiles.
I also tried other encodings; not working either.

EXPECTED RESULTS:
kst should load dirfiles properly.
Comment 1 Matthew Truch 2010-02-16 19:18:19 UTC
Sounds like your kst is using the (old, deprecated) internal dirfile reader, rather than using libgetdata.  Can you confirm that configure (or cmake) properly located libgetdata so that it was used during compile time?
Comment 2 Andrew Walker 2010-02-16 19:46:21 UTC
Matt, are you saying that you've tried this and found it to work okay with kst and the external getdata?

On my machine with kst 1.9.0_devel and getdata 0.6.0 the data cannot be read in.

Andrew
Comment 3 Matthew Truch 2010-02-16 19:53:15 UTC
Whoops.  No.  I've only tried this with 1.8.0.
Comment 4 Andrew Walker 2010-02-16 20:26:59 UTC
Although I think if it works in 1.8.0 then it should also work in 1.9.0_devel, as I don't think that the dirfile has changed between the two versions (other than to insist on at least version 0.6.0 of getdata because of other problems with earlier versions). We'll investigate further.
Comment 5 freebody.kst 2010-02-16 20:34:11 UTC
with kst1.9.0_devel and external getdata(0.6.1):
in the data wizard, after the data folder is selected, kst recognized it as
"Directory of Binary Files". When hitting "finish", kst displays an error message
"Sorry, unable to load the data file '/home/freebody/test_dirfile/'."

with kst1.9.0_devel and internal dirfile reader:
in the data wizard, after the data folder is selected, the "next" button is
greyed out.
Comment 6 freebody.kst 2010-02-16 22:33:09 UTC
with kst1.9.0_devel and external getdata(0.6.1):
if replace GD_TEXT_ENCODED with GD_UNENCODED(or just simply delete GD_TEXT_ENCODED),
kst can successfully plot files genereated by the code.
It seems kst cannot recognize encoded dirfiles.
Comment 7 Andrew Walker 2010-02-16 23:31:37 UTC
This appears to be a problem exclusively with the getdata library and/or its
interaction with the dirfile datasource.

After some simple testing it seems that the first call to GetNFrames returns
100 (indicating support for the data) but all subsequent calls return 0.
Comment 8 D. V. Wiebe 2010-02-16 23:44:46 UTC
There appears to be some memory corruption somewhere in the GetData legacy API.  I'm looking into it.
Comment 9 D. V. Wiebe 2010-02-17 00:16:20 UTC
Yeah, the GetData developer should be flogged.  He was overwriting the name of the ASCII data file with the data IN the file.  I'll see if I can't put out a 0.6.2 later today or tomorrow that fixes the problem.
Comment 10 D. V. Wiebe 2010-02-17 00:18:33 UTC
Created attachment 40866 [details]
Patch to GetData-0.6.1 to fix ASCII get_n_frames.

Although, if you really don't want to wait, here's a patch to GetData-0.6.1.
Comment 11 Andrew Walker 2010-02-17 02:55:37 UTC
The problem is the result of memory corruption in the getdata library.
This is being addressed in getdata 0.6.2