The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Threshold analysis using set column values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

MLaverty

2 Posts

Posted - 08/05/2014 :  12:01:19 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System: Windows 7

Hello all,

Some background: I'm modeling contaminant transport in a lake. The contaminant arrives at the point of interest, peaks, and then washes out of the system. I'm looking at time and concentration.

I'm defining the arrival time of the contaminant as when the concentration first exceeds a particular value. Following the suggestions in an old forum thread (http://www.originlab.com/forum/topic.asp?TOPIC_ID=1720), I was able to have success using the following in the Set Column Values dialog:

range r1 = 1!Col(1); // time
range r2 = 1!Col(2); // concentration

THRESH = 0.1; // threshold value for arrival of contaminant
temp = (r2>THRESH)?1:0;
irel=list(1,temp); del temp;

rdays = r1[irel];

My problem: I've decided to characterize the peak by looking at how quickly the contaminant reaches certain percentages of the peak value. I want "fraction of the peak" (o.1, 0.2, ... 0.9, 1.0) in the first column of a new sheet and the time in the second column. I'm guessing that I can modify the above code to do this, but I have been unsuccessful so far. Here is what I have:

range r1 = 1!Col(1); //time
range r2 = 1!Col(2); //concentration
range r3 = Col(1); //fraction of peak (0.1 to 1.0)

limit r2;
peak = limit.ymax;
peaki = limit.imax;

rTHRESH = (peak * r3);
temp = (r2>rTHRESH)?1:0;
irel=list(1,temp); del temp;

rdays = r1[irel];

So, can I do this in the Set Column Values dialog and, if so, how? If needed, I could use the first code and have one column for each fraction of the peak, but that's rather brute force would not be very efficient.

Thanks much for your help,
-M

lkb0221

China
497 Posts

Posted - 08/05/2014 :  4:02:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Notice that in your 2nd script, you actually want to output a dataset, instead of a single value as in the 1st script.
So you need to loop through all values in rTHRESH and assign each rdays value to a output dataset.

Zheng
OriginLab
Go to Top of Page

lkb0221

China
497 Posts

Posted - 08/05/2014 :  4:12:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For example, in SCV dialog:

Function body:
result

Before Formula Scripts:
range r1 = 1!Col(1); //time
range r2 = 1!Col(2); //concentration
range r3 = Col(1); //fraction of peak (0.1 to 1.0)

limit r2;
peak = limit.ymax;
peaki = limit.imax;

dataset result;
dataset rTHRESH;
rTHRESH = peak * r3;

for (int ii = 1; ii <= r3.GetSize(); ii++)
{
double CurrentTH = rTHRESH[ii];
dataset temp = (r2 >= CurrentTH)? 1:0;
int irel = list(1,temp);
result[ii] = r1[irel];
}
Go to Top of Page

MLaverty

2 Posts

Posted - 08/07/2014 :  9:20:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much for your help. It seems to work just as I need it to (my household has been knocked flat on its back by a stomach bug that's passing through the family, so I haven't had a chance to do more than copy-paste and say, "Yay! That seems to work!" before shutting off the computer).
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000