CRBASIC提示以简化数据后处理

by倒钩ra Utley|更新:2015年8月12日|评论:3

搜索博客


Subscribe to the Blog

Set up your preferences for receiving email notifications when new blog articles are posted that match your areas of interest.


Area / Application

Product Category

Activity

Corporate / News

Enter your email address:



建议一篇文章

您想了解更多有关有关的话题吗?让我们知道。请尽可能具体。

Leave this field empty

电子表格和饼图

您已经收集了测量数据,但是如何轻松地从中有意义?如何简化数据的后处理并开始更快地进行分析?在本文中,我将解释如何在您的CRBASIC程序中添加一些代码,可以使您免于稍后的后处理头痛。

As a graduate student, I remember my colleagues often talking about the headache of post-processing data before they could even begin analyzing their data.

  1. For post-processing, some of us had learned how to write macros in Excel.
  2. 其他同事则选择使用Python,Matlab或R脚本等资源来格式化其数据进行分析。
  3. 我们一群人就在低谷徘徊,copying and pasting data into a new worksheet in Excel until all of the information was available in one spreadsheet—complete with extra columns of categorical labels.

您可能想象的,我和我的同事发现所有这些后处理方法都很麻烦。

For our experiments in graduate school, we were encouraged to keep detailed notes on dates and times, as well as when an experiment moved from one treatment to the next. I understood the importance of keeping good notes, but I wondered if there was a way to save the information in the data table defined in CRBasic.

Most statistical software packages rely on data frames or input files that have a minimum number of columns and large quantities of rows or records.Too often, however, we format our raw data tables without considering the analysis we hope to complete after the data is collected.

数据表通常包括默认时间戳记加记录号,然后我们开始添加传感器测量和系统电压。但通常,一个实验包括更多的治疗方法,具有相同传感器倍数的更多重复,只是用于将数据分组的更多信息进行分组以进行探索性数据分析以及t检验,方差分析(方差分析)或回归。。

So, how can you store information like this in your data table for easy reference? I’ll step you through an example of how to create and manipulate categorical variables in CRBasic. The variables can be edited while the data is collected and stored in the data table.

例子

Note:Even if you’re not familiar with water quality and turbidity measurements, I think you’ll see in this example how easy it is to improve the helpfulness of your data table.

Background

In this example, the following question was posed: How does optical turbidity vary at six known concentrations (0, 10, 50, 100, 250, and 1000 mg/L)? To answer this question, data were collected using threeOBS500 turbidity meters。实验的细节如下:

  • Two hundred measurements were collected from each turbidity meter at each concentration.
  • 对于平均值,中值和标准偏差计算,将测量结果折叠成100组。
  • Different minerals were used to create sediment suspensions (quartz, kaolinite, bentonite, feldspar, mica, and coal). Natural river sediment was also collected, dried, sieved, and weighed to create natural sediment suspensions.
  • The categorical variables included concentration (0, 10, 50, 100, 250, and 1000), sensor name (A, B, and C), and mineral (quartz, kaolinite, bentonite, feldspar, mica, coal, and natural sediment).

Original Data Table

The first round of data collection produced data tables similar to the one shown in Table 1. The reported values included the time stamp, record number, raw backscatter and sidescatter in millivolts, and backscatter and sidescatter readings in FBU (Formazin Backscatter Unit) and FTU (Formazin Turbidity Unit).

Raw data collected during the sediment study

Table 1. Raw data collected during the sediment study.

For this experiment, the time stamp was not important because the measurements were not changing relative to time but to known treatments of sediment (concentration and mineral). Using the current data table setup in the CRBasic program running on my data logger, I had to rely on my detailed notes to post-process the data and figure out which sensor was used, what concentration was measured, and what mineral was used to create the suspension.

改进的数据表

After making a few changes to the CRBasic program, I was able to generate a more detailed data table (Table 2) that includes categorical information defined as the following:

  • obs500_meas(1) is backscatter (FBU).
  • obs500_meas(2) is sidescatter (FTU).
  • obs500_meas(5) is raw backscatter (mV).
  • obs500_meas(6)是原始的侧猫(MV)。

Data collected for the natural sediment from sensor A at a concentration of 0 mg/L

表2.从传感器A收集的数据以0 mg/L的浓度为0。

怎么做

To transform my data table from Table 1 to Table 2, I only needed to add a few lines of code to the CRBasic program. Here’s how you can do it too:

  1. Define a few new variables for sensor and concentration. The sensor variables are defined as a 16-character string. The sensors are not public variables because they do not change. Concentration, however, is a public variable, so you can enter the known concentration into the public table.
    Dim Sensora作为字符串 * 16 DIM SensorB为字符串 * 16 DIM Sensorc作为字符串 * 16公共集中度
  2. 定义这样的新数据表:
    DataTable(Samplesa,1,10000)样品(9,obs500_measa(),IEEE4)样品(1,Sensora,String)样品(1,浓度,FP2)端底数据表(SamplesB,1,10000,IEEE4)样品(1,SensorB,字符串)样品(1,浓度,FP2)端尾数据(Samplesc,1,10000)样品(9,obs500_measc(),IEEEE4),样品(1,Sensorc,Sensorc,String)样品(1,1,1,)浓度,fp2)终结
  3. 定义程序中的传感器名称。因为我们将传感器宣布为我们程序中的“昏暗”,所以它们不会出现在公共表中。因此,在您的“ BeginProg”语句之后,您需要为三个传感器中的每个传感器定义所需的名称。

    提示:Remember that the sensors were defined as a 16-character-long string, so the name for each must be less than 16 characters.

    在我们的示例中,使用了a,b和c。但是,您可以包括传感器的序列号或型号。这些不是公共变量,因为它们没有随着治疗而改变。我在每种处理中收集了每个传感器的200次测量。

    BeginprogSensorA="A" SensorB="B" SensorC="C"

现在,每次调用数据表时,传感器字符串和浓度都会在数据表中的独立列中添加到记录中。很简单!

Conclusion

I hope this example helps you understand how some simple additions to your CRBasic program code can save you from a post-processing headache later. Feel free to post your questions or comments below.


分享这篇文章



About the Author

barbra utleyBarbra Utley博士是Campbell Scientific,Inc。环境集团的应用研究科学家。万博matex网页登录感兴趣的领域包括淡水系统中的水质和替代沉积物测量以及统计分析。Barbra拥有生物系统工程的博士学位,重点是水资源。

View all articles by this author.


Comments

Juanchit|2017年8月16日下午12:48

Hi Dr Barbra Utley.

We have 2 OBS501 Turbidimeters in our lab, and are deployig them both at the same time. As we don't use them at fix stations (but rather 1 minute stations at different locations), we have defined 3 Public Variables to i) open, ii) measure and iii) close the wiper from the PC400 software (we take the laptop to measure at all stations, just to check the instruments are measuring correctly).

But now we would like to add an extra variable in our table where we can store the name of the different stations, and we want to be able to set these names from the PC400, just as we can set the "open", "measure" and "close" variables.

有什么办法可以做到吗?

我向您发送了我们现在使用的.cr8文件,以防万一提供更清晰。

Thanks a lot!

朱乔

'CR800系列
'Created by Short Cut (3.0)

'声明变量和单位
公共battv
公共PTEMP_C
Public OBS500(4) 'direccion del sensor es O
Public OBS500_2(4) 'direccion del sensor es B

Public StationNames As String
公开开放为布尔值
Public measure As Boolean
Public close As Boolean

别名obs500(1)= BS_I2016
Alias OBS500(2)=SS_I2016
Alias OBS500(3)=Temp_I2016
别名obs500(4)= WD_I2016

别名obs500_2(1)= BS_I2017
别名obs500_2(2)= SS_I2017
Alias OBS500_2(3)=Temp_I2017
别名obs500_2(4)= WD_I2017

单位battv =伏特
Units PTemp_C=Deg C
Units BS_I2016=FBU
Units SS_I2016=FNU
单位temp_i2016 = deg c
Units WD_I2016=unitless
Units BS_I2017=FBU
单位SS_I2017 = FNU
Units Temp_I2017=Deg C
单位WD_I2017 =无单位

'Define Data Tables
DataTable(OBSs_501,measure,-1)
样品(1,Battv,FP2)
Sample(1,PTemp_C,FP2)
Sample(1,BS_I2016,FP2)
Sample(1,SS_I2016,FP2)
样本(1,temp_i2016,fp2)
Sample(1,WD_I2016,FP2)
样本(1,BS_I2017,FP2)
样本(1,SS_I2017,FP2)
Sample(1,Temp_I2017,FP2)
样本(1,WD_I2017,FP2)
EndTable

'主要程序
Beginprog
'Main Scan
扫描(5,SEC,1,0)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
“默认接线面板温度测量'ptemp_c'
paneltemp(ptemp_c,_60Hz)

If open Then
sdi12recorder(obs500_2(),1,“ b”,“ m3!”,1,0)
SDI12RECORDER(obs500(),3,“ o”,“ m3!”,1,0)

open = false
measure = false
关闭= false
万一

If close Then
sdi12recorder(obs500_2(),1,“ b”,“ m7!”,1,0)
SDI12RECORDER(obs500(),3,“ o”,“ m7!”,1,0)

open = false
measure = false
关闭= false
万一


If measure Then
'OBS500 Smart Turbidity Meter (SDI-12) measurements 'BS_I2016', 'SS_I2016', 'Temp_I2016', and 'WD_I2016'
SDI12Recorder(OBS500(),3,"O","M4!",1,0)
'OBS500 Smart Turbidity Meter (SDI-12) measurements 'BS_I2017', 'SS_I2017', 'Temp_I2017', and 'WD_I2017'
SDI12Recorder(OBS500_2(),1,"B","M4!",1,0)
万一

'调用数据表和存储数据
CallTable(OBSs_501)
NextScan
EndProg

倒钩U|2017年8月23日上午11:22

朱乔乔(Juancho),

我很抱歉我的反应迟缓,但你感到兴奋re using this approach. You are almost there in your code. You need to add a line to the data table definition telling the data table to grab the StationNames variable. See below.

'Define Data Tables
DataTable(OBSs_501,measure,-1)
样品(1,Battv,FP2)
Sample(1,PTemp_C,FP2)
Sample (1,StationNames,String)
Sample(1,BS_I2016,FP2)
Sample(1,SS_I2016,FP2)
样本(1,temp_i2016,fp2)
Sample(1,WD_I2016,FP2)
样本(1,BS_I2017,FP2)
样本(1,SS_I2017,FP2)
Sample(1,Temp_I2017,FP2)
样本(1,WD_I2017,FP2)
'EndTable

The default size for your string variable is 24 bytes. You can make this smaller inside the variable definition to optimize storage space. If your station names are long you can make this bigger but it will eat into the available data table storage memory.

每次将OBS501数据写入表中时,您都会存储站点名称。

我希望这对浊度监测有所帮助。

倒钩

Juanchit|09/11/2017 at 06:09 AM

你好!

Sorry for my late response as well! I don't know why my user account didn't announce me your reply.

It was so easy! I though I had to make something special that would allow me to change table values from the PC400 software, but was not the case.

Thanks Barb!

朱乔

Pleaselog in or registerto comment.

我们活跃于社交媒体上!
Stay informed with our latest updates by following us on these platforms:

Baidu