Skip to main content

functions - FunctionInterpolation Errors / Question re Evaluation Order and Options


I have using Mathematica functions that takes a Cartesian coordinate relative to the Earth (xyz) and converts it to a latitude, longitude, and altitude (lla). And here it is:


xyz2lla = First@GeoPosition@GeoPositionXYZ[#, "WGS84"] &

I'm using it to convert a satellite viewing line (line of sight or los) from xyz to lla. For instance, if I have a satellite at the following observation point (obs, meters) looking in the direction of look:


obs = {2.560453600382259, 5.245110323032143, -3.819772142191310} 1*^6;
look = {-0.233218833096895, -0.814561997858160, -0.531128729720249};


It has the line of sight:


obs+d look

The transformation xyz2lla is smooth, so I was hoping to use function interpolation:


f = FunctionInterpolation[{xyz2lla[obs + # look]} &[d], 
{d, 2000000, 3700000}
]

And while this works, and I get the following lat, lon, alt functions from it:


enter image description here:



enter image description here


enter image description here


I also get the following errors that I'm wondering why I get:


GeoPositionXYZ::invcoord: "\!\(\"{2.560453600382259*^6 - 0.233218833096895*d, 5.245110323032143*^6 - 0.81456199785816*d, -3.81977214219131*^6 - 0.531128729720249*d}\"\) is not a valid coordinate specification."

Thread::tdlen: Objects of unequal length in {-212500.,-70833.3,70833.3,212500.}^{} cannot be combined. >>

Thread::tdlen: "Objects of unequal length in {12.2667 +3.14159\ I,11.1681 +3.14159\ I,11.1681,12.2667}\ {}\\n cannot be combined."

FunctionInterpolation::nreal: Near d = 2.2125`*^6, the function did not evaluate to a real number.


Does anyone have any insight into these errors?


Also, how can I adjust the quality of the interpolation / how many points are investigated?



Answer



I don't think InterpolatingFunction is intended to work on vector functions. The doc page doesn't say anything about it. Try for instance


f = FunctionInterpolation[{x, x}, {x, 0, 6}]


Mathematica graphics


And


Table[f[x], {x, 0, 6, 1}]


returns


(*
==> {0., 0.9999652778, 1.998576389, 3., 4.004131944, \
4.994409722, 6.}
*)

So, no two dimensional output.


It's probably better to come up with three separate interpolating functions for each of the three components of the output.




Having said that, it doesn't look like this is the end of the problems.



xyz2llaPhi = GeoPosition[GeoPositionXYZ[obs + # look, "WGS84"]][[1, 1]] &;
fPhi = FunctionInterpolation[xyz2llaPhi[d], {d, 2000000, 3700000}]

yields


Mathematica graphics


Whereas


xyz2llaPhi[200000]

yields a nice numerical result:


(*

==> -34.86629487
*)

It looks like the combination of FunctionInterpolation and GeoPosition isn't a healthy one. Somehow, the index d is held unevaluated.


A workaround would be to generate a table of values and then use ListInterpolation.


Comments

Popular posts from this blog

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...