05-14-2009 04:46 PM
If I am loading a signal from an LVM file, is there a way to extract a random portion of the signal? Just some background, I will be loading multiple files in through a for loop/case structure, and each of the files may be of different lengths, so I won't know ahead of time how long the signal is.
thanks,
George
Solved! Go to Solution.
05-14-2009 04:54 PM - edited 05-14-2009 04:55 PM
05-14-2009 04:59 PM
05-14-2009 05:04 PM
05-14-2009 05:06 PM
LVM includes the number of points in each segment header. You can get this by reading and parsing the header yourself. The spec is located here. The Express VIs presume that, being an ASCII file, LVM files are relatively small. As such, the entire file is read into memory by the Express VI. You can use the array or waveform VIs to easily extract a portion of this.
If you have huge files and this creates a memory issue, you can parse the file yourself. Look for the ***End_of_Header*** line. The next line is the column headers, followed by the data, one item per line. The bad news is that lines can be a variable number of characters long. This can make searching a long file for lines a very slow process. One option is to read the file in 65,000 byte chunks and process these serially to get the data you want (this is what LVM does internally to convert from ASCII to data).
05-14-2009 05:09 PM
05-14-2009 05:43 PM
05-15-2009 12:29 AM
LVM comes under the class of ASCII file and hence random access of the files content is not possible. Just switch to tdms which offers you bundle of facilities and you can accompolish the tasks very easily without pain.
Look into tdms examples shipped with LabVIEW to get an idea of tdms.
Post back for queries.
05-15-2009 08:35 AM
I am not sure I understand what you are trying to do. Do you only want to read part of the file? Or can you read all of the file and then extract part of the signal?
From reading this thread I would suggest reading the entire file and convert your signal(s) to waveform or array datatypes. Then search for the threshold you mentioned in your last post. Then apply the random extraction to the portion of the signal after the threshold. Is the start position or the length of the segment or both random?
Selecting random portions of a signal seems unusual. Can you tell us what you are trying to achieve? Perhaps someone can suggest a better way.
Lynn
05-15-2009 08:40 AM
The easiest way to do what you want to do is the following: