From BRTT
Why can't I use trapply_calib on the results of trgetwf?
See also
</noinclude> {{answer| This use of trapply_calib shown above is not working because you are applying it to the wrong kind of data structure. Also, applying trapply_calib right after you open the wfdisc table won't quite work because, again, it will be applied to the wrong data structure.
In order to be successful with this command, you will need to study the Matlab examples to understand what the relevant data structures are and how to use them. For example, try the matlab commands
See also
</noinclude> and print out the little scripts. Basically you need to do something similar to the dbexample_trextract_data script, but with an additional call to trapply_calib.
There are three types of entities to know about:
1) Database pointers to waveforms on disk. These are what you get back from the command
See also
</noinclude> This variable points to a relational database that has the waveforms still stored in their files.
2) Database pointers to waveforms in memory. These are called "trace objects". They are variables that are similar to the database pointers above, except that instead of pointing to a relational database with waveforms on disk, they point to a relational database with waveforms that have been transferred to working memory. The way to create a trace object is with the trload_css() command. This command reads in a database pointer to waveforms on disk (i.e. the result of the dblookup_table command above) and creates a database pointer to waveforms in memory, i.e. a "trace-object". Most of the other trace-object commands, including trapply_calib, work on these trace objects. ` 3) Time series of waveform data, i.e. 1xN matrices of values for the data at each discrete sample time. These time-series arrays are, of course, what is most interesting to seismologists and others working with waveform data. In order to get time-series arrays out of a trace-object, you need to use the trextract_data() command, as shown in the example called dbexample_trextract_data.
The trgetwf command is something of a shortcut around this--it goes straight from items of type 1 to items of type 3. The name of the command is somewhat confusing since it implies it works on trace objects when it does not, however once you get used to that little glitch it's a great tool. Because trgetwf bypasses trace-objects and trapply_calib works on trace objects, the two are not very compatible in the same section of code. You should choose either the trgetwf approach or the trload_css approach. If you need to use trapply_calib, you'll need to choose the latter.