| Author |
Topic  |
|
|
mkoetse
Netherlands
Posts |
Posted - 12/30/2003 : 04:58:07 AM
|
Hello all, Yesterday I came across some wierd behavior of some origin C lines: --------------------------------- Curve crv5(wks,0,4); //L-V double dVon = Curve_xfromY(&crv5, 0.1); // Get turn on value at Y=0.1 printf( "X from Y=0.1:\t%f\n", dVon); Curve crv7(wks,4,5); //Ecd-L Curve crv8(wks,4,6); //Elm-L ---------------------------------
The thing is that 1: Curve_xfromY returns a bogus value and 2: crv7 and 8 are plotted as 5 vs. 0 and 6 vs. 0 respectively.
Anyone have an idea what might be wrong?
Regards,
Marc
|
|
|
easwar
USA
1965 Posts |
Posted - 12/30/2003 : 3:42:21 PM
|
Hi Marc,
I could reproduce your second problem in version 7: curve 7 being plotted as col 5 vs col 0 instead of col 5 vs col 4. This is fixed in version 7.5 - if you don't have 7.5, you can first try it with the demo.
As for the first problem of Curve_xfromY() returning incorrect values, I could not reproduce - I get correct values. Can you try with a simple curve such as row numbers for x and y? Perhaps something specific to your data set or data ordering - maybe you can paste a sample data set here, that leads to wrong numbers.
Easwar OriginLab.
|
 |
|
|
mkoetse
Netherlands
Posts |
Posted - 12/30/2003 : 4:03:26 PM
|
It is solved in version 7.5..... Now that does help me, since my boss is not going to pay for yet another version. Not.... what kind a costummer service is that?
I now understand why I told my colegues to quit with origin and use wavemetrics Igor pro insteat. (where I got everything working within half a day, whithout updating!)
Originlabs simply should first get their scripting language working and not oblige costumers to buy new versions one after the other.
A happy Igor pro user....
Marc
|
 |
|
|
easwar
USA
1965 Posts |
Posted - 12/31/2003 : 09:47:22 AM
|
Hi Marc,
We understand your concerns. One solution to make this work in version 7 is to have the column type set to X for those columns that you want to use as X in your curve objects. The problem in version 7 was that if the column used for X in the curve object is not set to type X, it looks for the left most X column in the worksheet.
You can programmatically set the type of a column by using code such as:
wks.Columns(4).SetType(OKDATAOBJ_DESIGNATION_X); Curve crv7(wks,4,5); //Ecd-L
Thanks,
Easwar OriginLab.
|
 |
|
|
mkoetse
Netherlands
Posts |
Posted - 01/02/2004 : 10:12:12 AM
|
Cheers,
But wont this mess up the other layers, where I use column 4 as Y?
As for the: Curve_xfromY(&crv5, 0.1); is there any work around? Could I e.g. put the data in an array (or even better treat the collumn as an array) and then loop through untill it finds the value I want (interpolation is not of any importance here)?
And ehhm, sorry for the somewhat gros answer before.... Regards,
Marc
|
 |
|
|
cpyang
USA
1406 Posts |
Posted - 01/02/2004 : 6:23:31 PM
|
If you know exactly which is X and which is Y column, then use the Data_table function.
CP
|
 |
|
|
ftalbot
France
Posts |
Posted - 04/26/2005 : 09:16:25 AM
|
Hi, I have the same problem as Marc regarding Curve_xfromY(): I get silly values! I'm using a network version of Origin 7.5 so that problem does not seem to have been dealt with. I'll try to use Data_table in conjonction with Curve_x to replace that function but I just wanted to report that BUG and confirm Marc's troubles. Please, let me know if there is a bug-fix or update for that problem. |
 |
|
|
cpyang
USA
1406 Posts |
Posted - 04/27/2005 : 03:59:23 AM
|
Can you show the code that you are having trouble with? Without seeing the code, it is hard to tell what was wrong. Did you get correct result from the Data_Table function?
CP
|
 |
|
|
ftalbot
France
Posts |
Posted - 04/27/2005 : 08:41:39 AM
|
Hi CP, Here is a part of the code: "... dp = gl.DataPlots(0); Curve crv(dp); double ymax = max( crv ); printf("Ymax=%f\n", ymax); double xmax = xatymax(crv); double y2=ymax/2; printf("Xmax=%f\n", xmax); printf("Y2=%f\n", y2); double xz = Curve_xfromY( &crv, 123.500 ); printf("Xmax2=%f\n", xz); ..." I wrote that very simple code when I started to have doubts about the function, just to try it. The curve I tested it on had a max of 247 at x~600, hence the "123.50" value I used (half maximum). According to the data, the "Curve_xfromY()" function should give me a value around 530 but gives me 12500 and the such (my data do go that far; it is an exponential decay). I changed that "123.5" value and it did change the resulting x value but it was still around 12000 were y values are around 0!! I also checked if these silly values were related the the data index but they are not. Because my data goes twice through the y value I check (rise + decay), I wonder if that couldn't be the source of the problem? It would be dumb if the function couldn't handle that but...
I had some other, more urgent programming to do, so I dropped that problem yesterday; just to run into new ones, of course.
Now, I also doubt the "GetRectPoints()" function. Working on it... Thank you for investigating my case.
Francis. (I had forgotten my name on my first message...) |
 |
|
|
cpyang
USA
1406 Posts |
Posted - 04/27/2005 : 4:01:56 PM
|
I see your problem, the Curve_xfromY function is rather simple function, so it won't know how to handle cases with one Y multiple X. What will be needed is to find your peak and then create a copy of the curve and do Curve_xfromY from this new copy that will have unique X for given Y. If your data is noisy, then some simple smoothing might also be needed.
I have worked out some code below,
// function similar to minmax in internal.c we need this // to find index of curve at Y max static int IndexAtYMax(Dataset &aa) { BasicStats stat; stat.iMin =0; stat.iMax =0; Data_sum(&aa, &stat); return stat.iMax; }
double x_from_y_after_peak(DataPlot& dp, double y) { Curve crv(dp); // first make a copy so we can sort and smooth it int nMissing; int nSrcOffset; // this is a copy constructor to scan and skip all missing values in both X and Y Curve cvcpy(crv, nMissing, nSrcOffset, CURVECOPY_SKIP_MISSING_INSIDE); cvcpy.Sort(); // just incase data not monotonically increasing in X smooth(cvcpy, 0 , 3, 3);// apply simple adj ave with 3 pts on left and right int nYmax = IndexAtYMax(cvcpy); // index of Peak // now make a new curve starting from the peak Curve cvcpy2(cvcpy, nMissing, nSrcOffset, CURVECOPY_SKIP_MISSING_INSIDE, nYmax);
return Curve_xfromY( &cvcpy2, y ); }
// now you can try this by plotting some data with a single peak // and enter a y value and get x after the peak void test(double y) { GraphLayer gl = Project.ActiveLayer(); DataPlot dp = gl.DataPlots(0); double x = x_from_y_after_peak(dp, y); printf("for y = %g, x = %g\n", y, x); }
CP
Edited by - cpyang on 04/27/2005 4:36:42 PM |
 |
|
| |
Topic  |
|
|
|