首页 > 解决方案 > 如何在 R 中使用 Python 函数 neighbours(healpix_index, nside, order='ring')?

问题描述

我尝试使用 R“reticulate”包在 R 中使用 python 函数 neighbours(healpix_index, nside, order='ring'),但未能评估它的实例,例如,

neighbours(healpix_index=23404309, nside=2048, order='nested')

这应该给我以下答案:

#Output=array([23404308, 23404310, 23404311, 23404354, 23404352, 23404010, 23403967, 23403966])

我失败的一段代码如下:

library(reticulate)
use_python("c:/python/python39")
py_install("numpy")
py_install("astropy")
py_install("astropy_healpix", pip = TRUE) 

numpy <- import("numpy")

astropy_healpix <- import("astropy_healpix")

import_main(convert = TRUE)

import_builtins(convert = TRUE)

astropy_healpix$neighbours(23404309,2048,order='ring')

我需要评估 R 中的 Python 邻居函数,非常感谢您对这个问题的帮助。

太感谢了。

标签: pythonrfunctionimport

解决方案


推荐阅读