DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ChnMapLinCalc function

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(1,658 Views)

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

0 Kudos
Message 2 of 10
(1,635 Views)

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.

 

Kane_Lok_0-1675939378989.png

 

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.

0 Kudos
Message 3 of 10
(1,590 Views)

These are the value I got using linear regression:

gsklyr_0-1675956466424.png

However, your data is not linear

gsklyr_1-1675956539054.png

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

gsklyr_2-1675956960143.png

 

But still not quite like your so I am not sure how you do it manually

0 Kudos
Message 4 of 10
(1,576 Views)

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.

0 Kudos
Message 5 of 10
(1,570 Views)

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)

 

0 Kudos
Message 6 of 10
(1,551 Views)

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.

0 Kudos
Message 7 of 10
(1,520 Views)

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")
0 Kudos
Message 8 of 10
(1,503 Views)
Solution
Accepted by topic author Kane_Lok

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")
0 Kudos
Message 9 of 10
(1,495 Views)

It works perfectly in my application.  Many thanks gsklyr.

0 Kudos
Message 10 of 10
(1,365 Views)