Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/adaptive subsampling #120

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion kite/ext/covariance.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ uint32_t finished_combinations = 0;
typedef npy_float32 float32_t;
typedef npy_float64 float64_t;

#ifndef max
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#endif

typedef enum {
SUCCESS = 0,
SAUBSAMPLING_SPARSE_ERROR
Expand Down Expand Up @@ -127,7 +134,7 @@ static state_covariance calc_covariance_matrix(
for (il1=0; il1<nleaves; il1++) {
if (adaptive_subsampling) {
l_length = map[il1*4+1] - map[il1*4+0];
subsampling[il1] = ceil(LOG2(l_length));
subsampling[il1] = max(ceil(LOG2(l_length)), 1);
} else {
subsampling[il1] = 1;
}
Expand Down
3 changes: 2 additions & 1 deletion kite/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numpy as np
import utm
from pyrocko.dataset.topo import srtmgl3
from pyrocko.dataset import topo
from pyrocko.guts import Dict, Float, Object, String, StringChoice, Timestamp, load
from pyrocko.orthodrome import latlon_to_ne, latlon_to_ne_numpy, ne_to_latlon # noqa
from scipy import interpolate
Expand Down Expand Up @@ -643,6 +643,7 @@ def los_rotation_factors(self):
return self._los_factors

def get_elevation(self, interpolation="nearest_neighbor"):
srtmgl3 = topo.dem("SRTMGL3")
assert interpolation in ("nearest_neighbor", "bivariate")

if self._elevation.get(interpolation, None) is None:
Expand Down
16 changes: 11 additions & 5 deletions kite/spool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pyqtgraph as pg
import pyqtgraph.parametertree.parameterTypes as pTypes
from PyQt5 import QtCore
from PyQt5 import QtCore, QtGui
from pyqtgraph import dockarea

from kite.qt_utils import _viridis_data
Expand All @@ -19,6 +19,12 @@ def get_resource(filename):
return path.join(path.dirname(path.realpath(__file__)), "res", filename)


def set_scale(image, width, height):
tr = QtGui.QTransform()
tr.scale(width, height)
image.setTransform(tr)


class KiteView(dockarea.DockArea):
title = "View Prototype"

Expand Down Expand Up @@ -239,13 +245,13 @@ def enableHillshade(self):
None, autoDownsample=False, border=None, useOpenGL=False
)
hillshade.resetTransform()
hillshade.scale(frame.dE, frame.dN)
set_scale(hillshade, frame.dE, frame.dN)

elev_img = pg.ImageItem(
None, autoDownsample=False, border=None, useOpenGL=False
)
elev_img.resetTransform()
elev_img.scale(frame.dE, frame.dN)
set_scale(elev_img, frame.dE, frame.dN)

elev_img.updateImage(elevation.T, autoLevels=True)
hillshade.updateImage(shad.T, autoLevels=True)
Expand All @@ -269,7 +275,7 @@ def transFromFrame(self):
frame = self.model.frame

self.image.resetTransform()
self.image.scale(frame.dE, frame.dN)
set_scale(self.image, frame.dE, frame.dN)

def scalebar(self):
"""Not working"""
Expand Down Expand Up @@ -437,12 +443,12 @@ def __init__(self, model, model_attr=None, **kwargs):
self.model = model
self.model_attr = model_attr

pTypes.GroupParameter.__init__(self, **kwargs)
self.parameters = getattr(self, "parameters", [])

if isinstance(self.parameters, list):
self.parameters = dict.fromkeys(self.parameters)

pTypes.GroupParameter.__init__(self, **kwargs)
self.updateValues()

def updateValues(self):
Expand Down
2 changes: 1 addition & 1 deletion kite/spool/spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def progressStarted(self, args):

self.progress.setWindowTitle("Processing...")
self.progress.setLabelText(text)
self.progress.setMaximum(maximum)
self.progress.setMaximum(int(maximum))
self.progress.setValue(0)

@QtCore.pyqtSlot()
Expand Down
10 changes: 8 additions & 2 deletions kite/spool/tab_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pyqtgraph as pg
import pyqtgraph.parametertree.parameterTypes as pTypes
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from pyqtgraph import dockarea

from kite.covariance import CovarianceConfig
Expand All @@ -26,6 +26,12 @@
pen_roi_highlight = pg.mkPen((115, 210, 22), width=2, style=QtCore.Qt.DashLine)


def set_rotate(item, angle):
tr = QtGui.QTransform()
tr.rotate(angle)
item.setTransform(tr)


class KiteCovariance(KiteView):
title = "Scene.covariance"

Expand Down Expand Up @@ -477,7 +483,7 @@ def updateHistogram():
ge.hist_syn.setData(*h)

ge.hist_syn = pg.PlotDataItem(pen=hist_pen)
ge.hist_syn.rotate(90.0)
set_rotate(ge.hist_syn, 90.0)
ge.vb.addItem(ge.hist_syn)
updateHistogram()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"numpy>=1.17.3",
"scipy>=1.6.0",
"PyQt5>=5.15.0",
"pyqtgraph==0.11.0",
"pyqtgraph>=0.11.0",
"pyrocko>=2022.06.10",
"utm>=0.7.0",
"geojson>=2.5.0",
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def _have_openmp():
],
}
else:
metadata = {}
metadata = dict(
ext_package="kite",
)


setup(
Expand Down