简体   繁体   English

scipy.interpolate.interp1d 折叠 map

[英]scipy.interpolate.interp1d folding map

I am plotting the result of an interpolation in a periodic domain, namely, the earth mercator projection map, [0,2*pi] or [0,360] is the domain for longitude.我正在绘制周期域中的插值结果,即地球墨卡托投影 map,[0,2*pi] 或 [0,360] 是经度域。 As you can see on the picture below, I'm plotting a groundtrack.正如您在下图中看到的那样,我正在绘制一个地面轨迹。

在此处输入图像描述

I am getting first r , ie position, and then I'm projecting that right onto earth.我得到第一个r ,即 position,然后我将它投射到地球上。 Since the coordinate transformations involves trigonometric functions, the results that I obtain are certainly restricted to a domain, where the inverse is bijective.由于坐标变换涉及三角函数,因此我获得的结果肯定限于一个域,其中逆是双射的。 To obtain this plot I've used atan2 in order to obtain a non bijective inverse function, as well as manipulating arccos in order to extend the domain of the inverse function.为了获得这个 plot,我使用了atan2来获得非双射逆 function,以及操纵arccos以扩展逆 ZC1C425268E67385D1AB570 的域。

All good up to now.到目前为止一切都很好。 The fact is that when I interpolate the resulting points, naturally, the function that returns does not interpret the domain folding property.事实是,当我对结果点进行插值时,返回的 function 自然不会解释域折叠属性。

I just wanted to know if there is any way around this, apart from manipulating my data and representing it in a non periodic domain, interpolate it, and after that applying %(2*np.pi) .我只是想知道是否有任何方法可以解决这个问题,除了操纵我的数据并在非周期性域中表示它,插入它,然后应用%(2*np.pi) These option, even if is doable, implies touching even more those inverse functions.这些选项,即使是可行的,也意味着更多地涉及那些反函数。 The other option I thought was interpolating in chunks of only increasing values, ie and concatenating them.我认为的另一个选择是在仅增加值的块中进行插值,即并将它们连接起来。

Nothing found on the scipy documentation.在 scipy 文档中找不到任何内容。

Solved the issue implementing something like the following.解决了实施类似以下内容的问题。 Notice that I am using astropy units module.请注意,我正在使用astropy units 模块。

adder = 2*np.pi*u.rad
for i in range(1,len(lons)):
    if lons[i].value-lons[i-1].value > 1:
        sgn=np.sign(lons[i].value-lons[i-1].value)
        lons[i:] -= sgn*adder

after doing this, apply the %完成此操作后,应用%

f_lons = interp1d(t,lons)
lons = f_lons(new_t) % (2*np.pi)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM