From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-07-2023 11:04 AM
Hi,
I am new to this forum and hopefully this thread is compiled with the rules.
I used ChnMapLinCalc function to interpolate a curve in DIAdem like this.
Set MeanCellCapacity = ChnMapLinCalc("[1]/Temp", "[1]/Capacity", "[1]/AveragedTemp", "[1]/TempCapacity", True, "const. value", NOVALUE, "analogue", 0)
When I ran the function on DIAdem, it threw me an error saying "[1]/AveragedTemp" channel is not monotonic increasing from line 330 onwards.
What I would like to do is to create the resultant channel ("[1]/TempCapacity") based on the input temperature ("[1]/AveragedTemp") via the interpolation from the curves ("[1]/Temp" & "[1]/Capacity"). Not sure if this is the only way to do, but currently being stuck at that.
Just wondering if anyone has ideas to workaround or come across this issue? Many thanks in advance.
Solved! Go to Solution.
02-07-2023 02:22 PM
If you mean linear interpolation you could do
ChnRegrXYCalc("[1]/Temp", "[1]/Capacity", "/RegressionX", "/RegressionY", "linear", "Partition complete area", 100, 1)
Then use "RegressionX" to find the closest "AveragedTemp" value and the corresponding "RegressionY" would be your "TempCapacity"
It will also have the mx+b values in the "RegressionY" properties along with precision
02-09-2023 04:49 AM
Thanks for the quick reply and contribution to my issue gsklyr.
Could you elaborate a bit more how to use your method to achieve my goal?
Let me explain a bit more about what I am trying to do by using the screenshot below.
I have the averaged temperature channel called "AveragedTemp" which goes up and down in values. I have got a table that converts the temperature to capacity and the table is loaded on to Data Portal as two channels, "Temp" and "Capacity". So I would like to use the conversion table to obtain the interpolated capacity, which will be generated as a new curve so that I can plot the curve on "VIEW", according to the averaged temperature as shown in the screenshot.
Just wondering if your method above is able to do it or I need another approach? Please let me know and many thanks in advance.
02-09-2023 09:36 AM
These are the value I got using linear regression:
However, your data is not linear
The green line is the one that gave me the interpolated capacity values but looks like the blue one fits better (that's a 4th order polynomial).
The blue curve gave me better values
But still not quite like your so I am not sure how you do it manually
02-09-2023 09:41 AM
I actually get it now sorry for confusing. You do not need to make a model, you can just do your interpolation. Simply go to channel functions in analysis tab and use 'sort channel values' to sort you averaged temp channel. You can then proceed with the in terpolation function with the desired results.
02-09-2023 06:18 PM
Specifically, run:
ChnMultipleSortExt("[1]/AveragedTemp", "", "Up", "UpperCase", True)
(The 'True' in the end is to avoid creating additional channels and will sort 'AveragedTemp' in place)
and then
Set MeanCellCapacity = ChnMapLinCalc("[1]/Temp", "[1]/Capacity", "[1]/AveragedTemp", "[1]/TempCapacity", True, "const. value", NOVALUE, "analogue", 0)
02-10-2023 03:44 AM
Hi gsklyr,
My task needs the averaged temperature (AveragedTemp) and interpolated capacity (TempCapacity) plotted out on VIEW. Not sure if I follow your suggestion correctly. Do you mean that I firstly sorted AveragedTemp in an ascending order by ChnMultipleSortExt, then do the interpolation by using ChnMapLinCalc to get the interpolated capacity values, then use a reverse functional (not sure what function it will be) to convert ascended AveragedTemp back to the original curve?
Sorry I am still new to DIAdem so not sure of my understanding is correct. Thanks for your advice and patience.
02-10-2023 09:21 AM
Yes, to sort, interpolate, then sort back, this will do the job:
Dim temp_length: temp_length = Data.Root.ChannelGroups(1).Channels("AveragedTemp").Properties("length").Value
Call ChnLinGen("/LinearGenerated", 1, temp_length, temp_length, "")
Call ChnMultipleSortExt("[1]/AveragedTemp", "[1]/LinearGenerated", "Up", "UpperCase", True)
Call ChnMapLinCalc("[1]/Temp", "[1]/Capacity", "[1]/AveragedTemp", "[1]/TempCapacity", True, "const. value", NOVALUE, "analogue", 0)
Call ChnMultipleSortExt("[1]/LinearGenerated", "[1]/AveragedTemp", "Up", "UpperCase", True)
Call Data.Root.ChannelGroups(1).Channels.Remove("LinearGenerated")
02-10-2023 10:27 AM
I forgot to add the resulting capacity channel to be sorted back. Here is the full script:
Dim temp_length: temp_length = Data.Root.ChannelGroups(1).Channels("AveragedTemp").Properties("length").Value
Call ChnLinGen("[1]/LinearGenerated", 1, temp_length, temp_length, "")
Call ChnMultipleSortExt("[1]/AveragedTemp", "[1]/LinearGenerated", "Up", "UpperCase", True)
Call ChnMapLinCalc("[1]/Temp", "[1]/Capacity", "[1]/AveragedTemp", "[1]/TempCapacity", True, "const. value", NOVALUE, "analogue", 0)
Call ChnMultipleSortExt("[1]/LinearGenerated", "'[1]/AveragedTemp','[1]/TempCapacity'", "Up", "UpperCase", True)
Call Data.Root.ChannelGroups(1).Channels.Remove("LinearGenerated")
02-14-2023 09:48 AM
It works perfectly in my application. Many thanks gsklyr.