0

I have to convert ellipsoidal height to Mean sea level on 5 million points which only possible on GPU segments.

Below is my code

import cudf
import pandas as pd
import numpy as np
from laspy.file import File
import gdal 
import pyproj
from numba import cuda
from scipy.interpolate import RectBivariateSpline as Spline

infile=File("pointcloud.las",mode='r') lasfile_df = cudf.DataFrame() lasfile_df['X']=infile.x lasfile_df['Y']=infile.y lasfile_df['Z']=infile.z

http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/binary/binarygeoid.html

Download WW15MGH.DAC

egm=np.fromfile("/content/drive/MyDrive/WW15MGH.DAC",">i2").reshape(721,1440)/100

@cuda.jit def ellipsoid_to_msl(lon,lat,height,out): for i,(lon,lat,height) in enumerate(zip(lon,lat,height)): longs=np.arange(0,360,0.25) lats=np.arange(-90,90.1,0.25) interp=Spline(lats,longs,egm) lat*=-1 if lon<0: lon+=360 z=interp.ev(lat,lon) out[i]=height-z lasfile_df=lasfile_df.apply_rows(ellipsoid_to_msl, incols={'X':'lon','Y':'lat','Z':'height'}, outcols={'out': np.float64}, kwargs={})

In the lasfile_df, the apply_rows is not working properly.

Can anyone explain how to do it using a cuda dataframe because in a pandas dataframe it takes a lot of time?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
avinash
  • 43
  • 1
  • 1
  • 5
  • Correct me if I'm wrong but I doubt you can just chuck scipy code into a jjitted function and have it work. Beyond that there are some more basic problems, like the fact that you loop over a variable and also re-assign it (might technically work but bad practice) and the fact that you're re-creating arrays and re-instantiating the interpolator on every iteration unnecessarily. If you optimize your code you likely won't need to worry about using the GPU – mikewatt Jan 30 '21 at 01:43
  • Thank you for your suggestion. By the way, the speed of computation takes care of by the NumPy library and I correct it by removing it for a loop. – avinash Jan 30 '21 at 14:25

0 Answers0