📄 feasd.tme
字号:
It is permissible for all samples to be smaller\*(--that is,.i max_valueis an upper bound rather than an exact maximum.For example, if the data are from an A/D converter,.i max_valuemay be used to indicate the maximum valuethat can be represented by the converter.In multichannel files,.i max_valuemay have one component for each channelor may be a single value applying to all channels..lpThe header of a FEA_SD file also contains a definition for one fieldgiven by the following table:.pp.TScenter, box, tab(;);c | c | c | c | c | c c | c | c | c | c | c.Name;Size;Rank;Dimen;Type;Enums=samples;no. of channels;1;NULL or {size};any numeric;NULL.TE.lpThe field can be created by calling.i init_feasd_hd (3-ESPSu)..sh 2 "External Record Format".ppWhen the size of the field "samples" is 1, there is a single channel;if no additional fields are present, each record is a single sample ofthe given type, and the part of the file after the header is just asequence of such samples. That is, the non-header part of the file isidentical to that of an SD file of the same data type and containingthe same data. When the size is greater than 1, the file containsmulti-channel data. The data portion of the file is still just asequence of samples when no additional fields are present. However,the samples are conceptually grouped into vectors, each containing onesample from each channel. In general, each record in the filecontains such a vector..ppEach complex item is represented externally by a consecutive pair ofreal items with the real part first..sh 2 "Internal Record Format\*(--The Support Structure".ppMost programs that deal with FEA_SD files will use the supportroutines in the ESPS library and will not directly use the informationin the tables above. (These routines are discussed in the nextsubsection.) For example programs will usually define the "samples"field in a file header by calling the support function.i init_feasd_hd (3-ESPSu)rather than by calling.i add_fea_field (3-ESPSu)directly..ppPrograms that deal with FEA_SD files do so in terms of C structures of aparticular type (struct feasd). A structure of this type contains thelocation of a data array together with other information that providesconvenient access to the data or is used by the FEA_SD supportfunctions. For example the read and write functions,.i get_feasd_recs (3-ESPSu),.i get_feasd_orecs (3-ESPSu),and.i put_feasd_recs (3-ESPSu),take pointers to such structures as parametersand either read data into the associated data array or write data from it..ppHere is the definition of the.i feasdstructure as given in.i <esps/feasd.h>:.nf.ta .5i 1i 1.75i struct feasd { short data_type; long num_records, num_channels; char *data, *ptrs; };.fi.lpThe structure members have the following meanings..ip data_typeAn integer code indicating the data type of the samples as stored in memory.Legal values are give by the ten type-code constantsDOUBLE, FLOAT, etc. shown in the table in Subsection 2.2.They are defined in the include file.i esps/esps.h.This type need not match the data typeof a FEA_SD file used for input or output;if the types are different,automatic type conversion takes place upon input or output..ip num_recordsThe number of consecutive records that may be stored in the data partof this.i feasdstructure (see below)..ip num_channelsThe number of channels of sampled data..ip dataA pointer to the beginning of a data array for storing the sampled data from.i num_recordselements of the type indicated by.i data_type.For single-channel data, the pointer.i datacan simply be cast to an appropriate type and regarded as pointing to thebeginning of a one-dimensional array of samples.The appropriate types are (char *) for BYTE data, (short *) for SHORT data,(double_cplx *) for DOUBLE_CPLX data, etc.For example, with declarations.ip.istruct feasd *rec;.brshort *s_data;.r.ipsuppose.i recpoints to a.i feasdstructure initialized to hold SHORT data.(So.i rec \->\c.i data_type ==\c.i SHORT .)Then, after the assignment.ip.i "s_data = (short *) rec\->data;".ipsample number.i smay be accessed as.i s_data [\c.i s ].For multi-channel files,the storage is conceptually a 2-dimensional array with.i num_recordsrows and as many columns as there are channels.It is the purpose of the structure member.i ptrs,discussed next,to make access to the dataas convenient as indexing an actual two-dimensional array..ip ptrsWhen appropriately cast,.i ptrs,if not NULL, points to the first element of an array of.i num_recordspointers,each of which points to the first element of a row of the data array.Appropriate types for the cast are (char **) for BYTE data, (short **) forSHORT data, etc.To continue the example begun above under.i data,suppose a declaration.ip.i short **s_ptr;.ipand a cast.ip.i "s_ptr = (short **) rec\->ptrs;".ipthen sample number.i sof channel.i ccan be accessed as.i s_ptr [\c.i s ][\c.i c ].The function.i allo_feasd_recs (3-ESPSu),which creates.i feasdstructures, has a parameter that determines whether to set up the pointerarray or to make the.i ptrsstructure member NULL..sh 2 "FEA_SD Support Functions".ppThere are five FEA_SD support functions:.ip.nf.i "init_feasd_hd " " \*(--\ initialize a FEA file header for subtype FEA_SD".i "allo_feasd_recs" " \*(--\ allocate memory for FEA_SD file records".i "get_feasd_recs " " \*(--\ get data records from an ESPS FEA_SD data file".i "get_feasd_orecs" " \*(--\ get overlapping data from an ESPS FEA_SD data file".i "put_feasd_recs " " \*(--\ write data records to an ESPS FEA_SD file".fi.lpSee the.i feasd_recs (3-ESPSu)manual entry for full documentation..sh 3 "init_feasd_hd".ppBefore a newly created FEA file header (\c.i i.e.one obtained from.i new_header (3-ESPSu))can be used as a FEA_SD header, it must be initialized, preferably by.i init_feasd_hd.A call of this function has the form.ipinit_feasd_hd(hd, data_type, num_channels, start_time, mult_st_t, record_freq).lpThe function takes a pointer.i hdto an ESPS FEA header and sets the item.i hd\->hd.fea\->fea_typein the FEA-specific part of the header equal to FEA_SD.(This is an integer code, defined in.i esps/fea.h,that identifies the file as a FEA_SD file).The function also initializes the header to define the field "samples".The argument.i data_typedeterminesthe data type of the field;legal values are given by the ten data-type constantsBYTE, SHORT, LONG, etc.The integer argument.i num_channelsgivesthe size of the field.The arguments.i start_timeand.i record_freqinitialize the required generic header items(see Subsection 4.1).The argument.i mult_st_tis a flag indicating whether there is a starting time for each channel or just one for the entire file.If the value is YES,.i start_timepoints to the beginning of an array containing the values.If the value is NO,.i start_timeis a pointer to a single element.By contrast,.i record_freqholds the actual value, not a pointer to it.The function returns a value 0 upon successful completionand a nonzero error code otherwise..sh 3 "allo_feasd_recs".ppBefore a FEA_SD file can be read or written by the support functions,a.i feasdstructure must be created.This is done by the function.i allo_feasd_recs.A call has the form.ipallo_feasd_recs(hd, data_type, num_records, data, make_ptrs).lp.ppThe function allocates memory for a .i feasdstructure and fills in values for the structure members.If requested, it will also allocate storage for the associated data array,the pointer array, or both.(See.i dataand.i ptrsin the previous subsection.)The function allocates the data array if the argument.i datais (char *) NULL.If the argument is non-NULL,it should point to the beginning of a suitable block of storage,and the pointer value is simply copied into the.i datamember of the structure.When the value of the argument.i make_ptrsis YES, the function createsthe pointer array.When.i make_ptrsis NO,.i ptrsis made NULL.The dimensions of the array are determined by the argument.i num_recordsand the size of the "samples" field defined in the header.i *hd,which gives the number of channels.The.i data_typeargument determines the data type of the array.Legal values are given by the ten data-type constantsBYTE, SHORT, LONG, etc.The.i data_typeand.i num_recordsmembers of the structure are filled inwith the values of the corresponding function arguments.The returned value is a pointer to the structure upon successful completion,or NULL in case of failure.When the data area is supplied by the programmer, its size should be at least.i num_records*.i num_channels*.i typesiz (\c.i data_type ),where.i num_channelsmay be obtained as the value of.i get_fea_siz (\c"samples",.i hd, (\c.i short " *).i NULL, (\c.i long " **).i NULL )..sh 3 "get_feasd_recs.ppWith a.i feasdstructure and a FEA_SD header in hand and a file open for reading,it is possible to read some data.The FEA_SD function analogous to the SD support functions.i get_sd_rec {\c.i dfs }is.i get_feasd_recs.A call has the form.ipget_feasd_recs(rec, start, num_records, hd, file).lp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -