Message Boards Message Boards

0
|
1416 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

What does Interpolation take into account as an argument?

Posted 1 year ago

I am trying to convert a code from Mathemtica to Python and I am trying to understand what the following expression does: I have df.txt that has the following structure:
{0.01, 0.01, 0.} 1.00000000002e-10
{0.01, 0.01, 0.05} 2.6020872669e-10
{0.01, 0.01, 0.1} 6.2612393705e-10
{0.01, 0.01, 0.15} 1.40324498972e-9

Clear[df, iJDP]
df = ToExpression[Import[NotebookDirectory[] <> "df.txt", "TSV"]];
iJDP = Interpolation[Map[{#[[1]], #[[2]]} &, df], 
   InterpolationOrder -> {1, 1, 1}, Method -> "Spline"];

I don't understand if 1 and 2 correspond to the first cluster and the second value, or something else. Furthermore I have this step
x,y,z are the columns of the df dataset

a = If[rho < 1, 
   z /. FindRoot[iJDP[x, y, z] == rhs, {R2, 0.5, 0, 1}], 1];

In this case what is looking for iJDP?

Thanks

POSTED BY: Daniela Tortora
3 Replies

Sorry, I know nothing about Python.

POSTED BY: Gianluca Gorni

I am not sure what exactly you are getting for df, but what I get is useless. This works for me:

df0 = Import[NotebookDirectory[] <> "df.txt", "Lines"]
StringReplace[
  xyz__ ~~ "}" ~~ f__ ~~ "e" ~~ exp__ :> 
   "{" <> xyz <> "}," <> f <> "*10^" <> exp <> "}"] /@ df0
df = ToExpression[%]

This df should be ready for Interpolation.

POSTED BY: Gianluca Gorni

Hi GIanluca thank you, and would you know which would be the function that allows me to do the same interpolation from Mathematica to Python? I need to interpolate the first cluster in the parenthesis and the array but I am getting some issues because I think that Mathematica does automatically an extrapolation while Python no

POSTED BY: Daniela Tortora
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract