Hello!
I have been trying to run a function available in the Julia module “GeoStats” from Python with PyJulia. However, I can’t manage to do it. Is there any tutorial showing how to make PyJulia work with the most recent versions of Julia and Python? So far I have been using this website to learn. However, despite loading the package it is not able to find the functions inside. For example, if I run jl.using("TextAnalysis") it works, but after when I try to use the function TokenDocument by running this line jl.eval("tokens_data = TokenDocument(data)") it fails.
It worked! In case someone in the future has the same problem, I just installed JuliaCall following the instructions on this website. Then to test it with the Julia module I need, I just ran this code:
import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage
from juliacall import Main as jl, convert as jlconvert
# Importing necessary modules
jl.seval("using GeoStats")
jl.seval("using GeoStatsPlots")
jl.seval("using ImageQuilting")
jl.seval("using GeoStatsImages")
jl.seval("using Plots")
jl.seval("using ImageFiltering")
jl.seval("using ImageView")
# Example code to test
jl.seval('trainimg = geostatsimage("WalkerLake")')
jl.seval('function forward(data); img = asarray(data, :Z); krn = KernelFactors.IIRGaussian([10,10]); fwd = imfilter(img, krn); georef((fwd=fwd,), domain(data)); end')
jl.seval('dataTI = forward(trainimg)')
jl.seval('problem = SimulationProblem(domain(trainimg), :Z => Float64, 2)')
jl.seval('solver = IQ(:Z => (trainimg = trainimg,tilesize = (27,27),soft = (dataTI,dataTI)))')
jl.seval('ensemble = solve(problem, solver)')
# Recovering the Julia output from JuliaCall
m = jl.seval('ensemble.reals[1][2]')
a = np.array(m)
output = a.reshape((400,400))
plt.imshow(output)