idies / pyJHTDB

Python wrapper for the Johns Hopkins turbulence database library
Apache License 2.0
96 stars 47 forks source link

Kernel dies during retrieving #29

Open fujiisoup opened 4 years ago

fujiisoup commented 4 years ago

Hi. Thank you for developing and maintaining this repo. I've started using this but found that some examples are outdated and I couldn't find a proper usage. With the script (see the bottom), I got a kernel shutdown. When I run the script in Ipython, I got the following stack trace,

0: SOAP 1.2 fault: SOAP-ENV:Receiver [no subcode]
"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: JHTDB started using 1-based indexing from Sept 16. Please update your JHTDB library if you have not done so.
   at TurbulenceService.TurbulenceService.GetAnyCutoutWeb(String authToken, String dataset, String field, Int32 T, Int32 x_start, Int32 y_start, Int32 z_start, Int32 x_end, Int32 y_end, Int32 z_end, Int32 x_step, Int32 y_step, Int32 z_step, Int32 filter_width, String addr) in H:\Repos\Turbulence\Turbulence\WebSite\App_Code\WebService.cs:line 4860
   --- End of inner exception stack trace ---"
Detail: [no detail]

The script I use is as follows,

import numpy as np
from pyJHTDB import libJHTDB
from pyJHTDB.dbinfo import interpolation_code

auth_token  = "edu.jhu.pha.turbulence.testing-201311"  #Replace with your own token here
xstart, ystart, zstart = 1, 1, 1
xend, yend, zend = 8, 8, 8
xstep, ystep, zstep = 1, 1, 1
Filter_Width = 1
time_step = 1
field = 'u'
data_set = "isotropic1024coarse"

VarName="Velocity"
dim = 3

idx_x=np.arange(xstart, xend + 1, xstep)
idx_y=np.arange(ystart, yend + 1, ystep)
idx_z=np.arange(zstart, zend + 1, zstep)
nnx=np.size(idx_x)
nny=np.size(idx_y)
nnz=np.size(idx_z)

npoints=nnx*nny*nnz
split_no=int(np.ceil(npoints/(192000000/dim)))
result=np.zeros((nnz,nny,nnx,dim),dtype='float32')
tmp=np.array_split(np.arange(npoints).reshape(nnx,nny,nnz), split_no)

print(result.shape)

lJHTDB = libJHTDB()
lJHTDB.initialize()
lJHTDB.add_token(auth_token)

for t in range(split_no):
    xyzs0 = np.unravel_index(tmp[t][0,0,0], (nnx,nny,nnz))
    xyze0 = np.unravel_index(tmp[t][-1,-1,-1], (nnx,nny,nnz))
    xyzs1 = (idx_x[xyzs0[0]], idx_y[xyzs0[1]], idx_z[xyzs0[2]])
    xyze1 = (idx_x[xyze0[0]], idx_y[xyze0[1]], idx_z[xyze0[2]])

    temp = lJHTDB.getCutout(
        data_set=data_set, field=field,
        start=np.array([xyzs1[0], xyzs1[1], xyzs1[2]], dtype = np.int),
        # size=np.array([xyze1[0]-xyzs1[0]+1, xyze1[1]-xyzs1[1]+1, xyze1[2]-xyzs1[2]+1], dtype = np.int),
        step=np.array([xstep, ystep, zstep], dtype = np.int),
        filter_width=Filter_Width)

    result[xyzs0[2]:xyze0[2]+1, xyzs0[1]:xyze0[1]+1, xyzs0[0]:xyze0[0]+1,:] = temp

lJHTDB.finalize()
print(result.shape)

This is borrowed from DEMO_getCutout.ipynb, but some particular arguments, time and size are removed as it says they are (no longer) supported.

It would be appreciated if you could point me the proper usage. Thank you in advance:)

fujiisoup commented 4 years ago

Note: I ran this script both in sciserver and my local, but I got the same result.