Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

File post processing on CR6 : open/read/do calculation/store files


Otemohu Jun 17, 2016 12:46 PM

Hi all,

I'm sure we can process files through programming with CRBasic but I don't know how to proceed. Here is my objectives:

Context

- a CR6 is logging several variables at 10Hz (100ms)
- halfhourly, the datalogger creates a TOB1 file (header and timestamp enclosed) with name based on realtime and records it into the SD card (CRD)
- the CR6 is in an Ethernet network with several others dataloggers (IP address and Packbus address specified)

Issue

Once a file is wrotten on the SD card and once it is accessible, I want to open it with the CR6, extract a specific column (with 18000 values, cause 10Hz), get variable from another datalogger in the network, make calculation on the file extracted column and create a new file based on the first one plus the new column. At this stage, the old one may be deleted from SD card.

It is quite simple but I don't know how to extract a column from a TOB1 file. Maybe do I have to create first an ASCII file, theno open it, do calculation and finally create a new file in TOB1 saved in the SD card. Is it the good strategy?

I want to find the best and fast way to do this without skipped scan.

All the best,

Daniel


JDavis Jun 17, 2016 02:26 PM

I think the best way to do it would be to use the TableName.FieldName syntax for reading the old data. Just use Cardout with a limit on the number of records from the original table to keep. Referencing individual values will be more efficient than writing code to read through the entire file.

Here is a link to our blog article on the topic:

https://www.campbellsci.com/blog/programmatically-access-stored-data-values


Otemohu Jun 21, 2016 07:38 PM

Ok but I will have an enormous datatable if I dont cut it with creating files.

And if there is skipped scans, all my data will be time delayed and all the calculation afterwards will be wrong. So I think I cannot based on the recordnumber.

?!?


JDavis Jun 21, 2016 07:46 PM

It is possible to check the timestamp of the record number you are looking at.

The large data file already exists on the card. We are just going to reference values out of it directly.


Otemohu Jun 21, 2016 08:59 PM

Yes you're right. So I can put a

If Timeintointerval(1,1800,Sec)
Variable = DataTableName.WantedVar(1,18000)

And I will have the last 18000 values picked up from DataTable at the first second following and half an hour and recorded in the Variable.

For the timestamp, do I have to specify the first and end time of the wanted values in the dataset? i.e. 00:00:00.0 to 00:29.59.9 and 00:30:00.0 to 00:59:59.9 etc...

I know that values will be there, so just check for timestamp will serve only to know if the time facing the value is OK or not. I have to be sure to collect (with this way) the variable in the time interval I want. If there is skipped scan, I will lost some data (17992 instead of 18000 for example), but it does'nt matter. The importance is time.


Otemohu Jun 22, 2016 08:22 AM

Anyone else?

I realize that with this way to do, I dont know how I will record also all the other variables of the same table (all recorded at 10Hz).
After the calculation on the array extracted from the DataTable with TableName.FieldName instruction, I need to create file with all other variables of the original TableFile plus the recalculated array. But with CardOut instruction, after having made calulation, if I want to retrieve the other variables of the dataTabal to create a new one, I will have a delay.

I think need to fix the dataTable at the end of the half an hour (containing 18000 lines) cause the scan is running fast (10Hz) and all the time.


jra Jun 22, 2016 02:36 PM

Otemohu,

Are you doing flux calculations? If so, see https://www.campbellsci.com/easyflux-dl

You may be able to adapt that program to your CR6. 


Otemohu Jun 22, 2016 02:56 PM

Yes I do, but not in realtime with a datalogger (and not for this purpose, ie ozone). I do post processing.

I've downloaded the Easyflux-dl program but it is very long and complex. My task is, I think, more easy to do and I just want to know the way to do this.

Log in or register to post/reply in the forum.