pyrocko / kite

InSAR unwrapped surface displacement processing for earthquake modelling.
https://pyrocko.org/kite/
GNU General Public License v3.0
79 stars 34 forks source link

importing unwrapped displacement with spool #32

Open mahinjafari opened 5 years ago

mahinjafari commented 5 years ago

Hi I want to use kite and importing grd file and sent to spool, but the following error occurs:

In [5]: import gdal                                                             
In [6]: ds = gdal.Open('dataset',gdal.GA_ReadOnly)                              
ERROR 4: dataset: No such file or directory
In [7]: ds = gdal.Open('dataset.grd',gdal.GA_ReadOnly)                          
In [8]: ds_geo = ds.GetGeoTransform()                                           
In [9]: phs_band = ds.GetRasterBand(1)                                          
In [10]: los = phs_band.ReadAsArray(0, 0, ds.RasterXSize, ds.RasterYSize)       
In [11]: sc = Scene()                                                           
In [12]: sc.displacement = los                                                  
In [13]: sc.frame.llLat = ds_geo[3] + ds_geo[5] * ds.RasterYSize                
In [14]: sc.frame.llLon = ds_geo[0]                                             
In [15]: sc.frame.dN = -ds_geo[5]                                               
In [16]: sc.frame.dE = ds_geo[1]                                                
In [17]: sc.frame.spacing = 'degree'                                            
In [18]: sc.spool()                                                             
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in buildViews(self)
    148             return
    149         for v in self.views:
--> 150             self.addView(v)
    151         self.model.sigProcessingStarted.connect(
    152             self.processingStarted,

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in addView(self, view)
    155     def addView(self, view):
    156         self.sigLoadingModule.emit(view.title)
--> 157         view = view(self)
    158         QtCore.QCoreApplication.processEvents()
    159         self.tabs.addTab(view, view.title)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/tab_scene.py in __init__(self, spool)
     21         model = spool.model
     22 
---> 23         scene_plot = KiteScenePlot(model)
     24         self.main_widget = scene_plot
     25         self.tools = {

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/tab_scene.py in __init__(self, model)
     79         self._component = 'displacement'
     80 
---> 81         KitePlot.__init__(self, model=model, los_arrow=True)
     82 
     83         model.sigFrameChanged.connect(self.onFrameChange)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in __init__(self, model, los_arrow)
    173 
    174         if los_arrow:
--> 175             self.addLOSArrow()
    176 
    177         # self.addIsocurve()

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in addLOSArrow(self)
    179 
    180     def addLOSArrow(self):
--> 181         self.los_arrow = LOSArrow(self.model)
    182         self.los_arrow.setParentItem(self.graphicsItem())
    183         self.los_arrow.anchor(

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in __init__(self, model)
     70         #     "Helvetica", weight=QtGui.QFont.DemiBold))
     71 
---> 72         self.orientArrow()
     73         self.model.sigSceneChanged.connect(self.orientArrow)
     74         self.setFlag(self.ItemIgnoresTransformations)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in orientArrow(self)
     76     @QtCore.pyqtSlot()
     77     def orientArrow(self):
---> 78         phi = num.nanmedian(self.model.scene.phi)
     79         theta = num.nanmedian(self.model.scene.theta)
     80 

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in nanmedian(a, axis, out, overwrite_input, keepdims)
   1020 
   1021     r, k = function_base._ureduce(a, func=_nanmedian, axis=axis, out=out,
-> 1022                                   overwrite_input=overwrite_input)
   1023     if keepdims and keepdims is not np._NoValue:
   1024         return r.reshape(k)

/usr/local/lib/python3.5/dist-packages/numpy/lib/function_base.py in _ureduce(a, func, **kwargs)
   3248         keepdim = (1,) * a.ndim
   3249 
-> 3250     r = func(a, **kwargs)
   3251     return r, keepdim
   3252 

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _nanmedian(a, axis, out, overwrite_input)
    896         part = a.ravel()
    897         if out is None:
--> 898             return _nanmedian1d(part, overwrite_input)
    899         else:
    900             out[...] = _nanmedian1d(part, overwrite_input)

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _nanmedian1d(arr1d, overwrite_input)
    879     """
    880     arr1d, overwrite_input = _remove_nan_1d(arr1d,
--> 881         overwrite_input=overwrite_input)
    882     if arr1d.size == 0:
    883         return np.nan

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _remove_nan_1d(arr1d, overwrite_input)
    130     """
    131 
--> 132     c = np.isnan(arr1d)
    133     s = np.nonzero(c)[0]
    134     if s.size == arr1d.size:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-18-e85825dda3ba> in <module>
----> 1 sc.spool()

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/scene.py in spool(self)
    684 
    685         from kite.spool import spool
--> 686         spool(scene=self)
    687 
    688     def _testImport(self):

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in spool(*args, **kwargs)
    245 
    246 def spool(*args, **kwargs):
--> 247     spool_app = Spool(*args, **kwargs)
    248     spool_app.exec_()
    249     spool_app.quit()

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in __init__(self, scene, import_file, load_file)
     38 
     39         if scene is not None:
---> 40             self.addScene(scene)
     41         elif import_file is not None:
     42             self.importScene(import_file)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in addScene(self, scene)
     53 
     54     def addScene(self, scene):
---> 55         self.spool_win.addScene(scene)
     56 
     57     def importScene(self, filename):

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in addScene(self, scene)
    140     def addScene(self, scene):
    141         self.model.setScene(scene)
--> 142         self.buildViews()
    143 
    144     def buildViews(self):

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in buildViews(self)
    148             return
    149         for v in self.views:
--> 150             self.addView(v)
    151         self.model.sigProcessingStarted.connect(
    152             self.processingStarted,

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/spool.py in addView(self, view)
    155     def addView(self, view):
    156         self.sigLoadingModule.emit(view.title)
--> 157         view = view(self)
    158         QtCore.QCoreApplication.processEvents()
    159         self.tabs.addTab(view, view.title)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/tab_scene.py in __init__(self, spool)
     21         model = spool.model
     22 
---> 23         scene_plot = KiteScenePlot(model)
     24         self.main_widget = scene_plot
     25         self.tools = {

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/tab_scene.py in __init__(self, model)
     79         self._component = 'displacement'
     80 
---> 81         KitePlot.__init__(self, model=model, los_arrow=True)
     82 
     83         model.sigFrameChanged.connect(self.onFrameChange)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in __init__(self, model, los_arrow)
    173 
    174         if los_arrow:
--> 175             self.addLOSArrow()
    176 
    177         # self.addIsocurve()

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in addLOSArrow(self)
    179 
    180     def addLOSArrow(self):
--> 181         self.los_arrow = LOSArrow(self.model)
    182         self.los_arrow.setParentItem(self.graphicsItem())
    183         self.los_arrow.anchor(

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in __init__(self, model)
     70         #     "Helvetica", weight=QtGui.QFont.DemiBold))
     71 
---> 72         self.orientArrow()
     73         self.model.sigSceneChanged.connect(self.orientArrow)
     74         self.setFlag(self.ItemIgnoresTransformations)

/usr/local/lib/python3.5/dist-packages/kite-2018.2.26-py3.5-linux-x86_64.egg/kite/spool/base.py in orientArrow(self)
     76     @QtCore.pyqtSlot()
     77     def orientArrow(self):
---> 78         phi = num.nanmedian(self.model.scene.phi)
     79         theta = num.nanmedian(self.model.scene.theta)
     80 

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in nanmedian(a, axis, out, overwrite_input, keepdims)
   1020 
   1021     r, k = function_base._ureduce(a, func=_nanmedian, axis=axis, out=out,
-> 1022                                   overwrite_input=overwrite_input)
   1023     if keepdims and keepdims is not np._NoValue:
   1024         return r.reshape(k)

/usr/local/lib/python3.5/dist-packages/numpy/lib/function_base.py in _ureduce(a, func, **kwargs)
   3248         keepdim = (1,) * a.ndim
   3249 
-> 3250     r = func(a, **kwargs)
   3251     return r, keepdim
   3252 

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _nanmedian(a, axis, out, overwrite_input)
    896         part = a.ravel()
    897         if out is None:
--> 898             return _nanmedian1d(part, overwrite_input)
    899         else:
    900             out[...] = _nanmedian1d(part, overwrite_input)

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _nanmedian1d(arr1d, overwrite_input)
    879     """
    880     arr1d, overwrite_input = _remove_nan_1d(arr1d,
--> 881         overwrite_input=overwrite_input)
    882     if arr1d.size == 0:
    883         return np.nan

/usr/local/lib/python3.5/dist-packages/numpy/lib/nanfunctions.py in _remove_nan_1d(arr1d, overwrite_input)
    130     """
    131 
--> 132     c = np.isnan(arr1d)
    133     s = np.nonzero(c)[0]
    134     if s.size == arr1d.size:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
miili commented 5 years ago

Hi there,

looks like sc.phi and sc.theta are not set for the scene.