[Kst] Getdata library

Adam D. Hincks ahincks at Princeton.EDU
Wed Aug 22 23:41:26 CEST 2007


> On Wed, Aug 22, 2007 at 03:52:12PM -0400, Adam D. Hincks wrote:
>>> This is a bug.  If applications using getdata (viz. kst) want to subtract
>>> two from the number of available frames, they need to do that themselves.
>>> It shouldn't happen in the library.
>>
>> It is a pretty deliberate bug, it looks like.  Here's the source:
>>
>>   nf -= 2;
>>   if (nf < 0)
>>     nf = 0;
>>   return(nf);
>>
>> Who is in charge of the library -- shall I consider this bug "submitted"?
>
> It's a "bug by design".  From kst's point of view, it's the right thing
> to do, so when Barth wrote getdata, it went in there so kst would
> function properly.  Since so much other analysis software now uses the getdata
> library, it should be moved out of getdata and into the kst's dirfile
> datasource wrapper.
>
> I can do it.  I'm nominally in charge of keeping getdata.

Great.

>>> Are you asking for a GetNSamples, which would take a field name?
>>
>> Essentially yes.  Something like:
>>
>> int GetNSamples(const char *filename_in, const char *field, int frame_num,
>>                 int *error_code);
>>
>> But recall, these are _extra_ samples after the last frame.  So it would
>> have to be able handle something like this:
>>
>> n_extra = GetNSamples("/data/dirfile",
>>                       "My_Field",
>>                       GetNFrames("/data/dirfile", &err, "My_Field"),
>>                       &err2);
>>
>> An alternative would be something that always checks past the last frame
>> and doesn't have frame_num as an input:
>>
>> int GetExtraSamples(const char *filename_in, const char *field, int
>>                     *error_code);
>
> I was thinking of something as simple as:
>
>  int GetNSamples(const char* filename_in, const char *field,
>      int *error_code)
>  {
>      /* ... */
>
>      stat(field);
>
>      /* ... */
>
>      return (size_on_disk / sizeof(type_on_disk));
>  }
>
> which would tell you the total number of samples available for a
> given field.  Then, to get the extra samples, you can do
>
>  n_extra = GetNSamples - GetNFrames * GetSamplesPerFrame;
>
> This is the most generically useful function that returns a number of
> samples for a supplied frame, so this is the one I'd prefer to implement.

That would work well.

And what about the byte-swapping?

Adam

> Cheers,
> -dvw
> -- 
> Don Wiebe                                       dwiebe at physics.utoronto.ca
> Department of Physics
> University of Toronto                           Office: ES4150
> 60 St. George St.                               Tele: +1-416-946-0946
> Toronto ON  M5S 1A7                             Lab:  +1-416-946-0516
>


More information about the Kst mailing list