Skip to content

Instantly share code, notes, and snippets.

View akbargumbira's full-sized avatar

Akbar Gumbira akbargumbira

View GitHub Profile
/usr/local/bin/npm start --production
http://localhost:2368/ghost
~/dev/akbargumbira.com/buster$ ./publish.sh
ITB EQ Fatality Option:
1. ('x', 0.62275231), ('y', 8.03314466), # Model coefficients
2. # Rates of people displaced for each MMI level
'displacement_rate', {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 1.0, 7: 1.0, 8: 1.0, 9: 1.0, 10: 1.0}),
3. 'mmi_range', range(2, 10),
4. 'step', 0.5,
5. # Threshold below which layer should be transparent
'tolerance', 0.01,
6.'calculate_displaced_people', True),
7. Postprocessor (THIS IS SHOULDN'T BE AN IF OPTION)
# OLD ONE
'parameters': OrderedDict([
# This field of the exposure layer contains
# information about building types
('building_type_field', 'TYPE'),
# This field of the hazard layer contains information
# about inundated areas
('affected_field', 'affected'),
# This value in 'affected_field' of the hazard layer
# marks the areas as inundated
@akbargumbira
akbargumbira / gist:19bdeefde570bea4d6a1
Created February 6, 2015 09:47
Local Computer - Ubuntu 14.04 - QGIS 2.6
---------------------
Regression Test Suite
---------------------
QGraphicsScene::addItem: item has already been added to this scene
#1 Test the interaction with needs. ... ok
#2 Test the writing to files. ... ok
#3 Test reading from a file. ... ok
#4 Basic test of all properties. ... ok
#5 test_init (safe.common.test.test_resource_parameter_widget.TestResourceParameterWidget) ... ok
#6 Test we can make a cell as a <th> element ... ok
root@jenkins:/var/lib/jenkins/inasafe-dev# scripts/jenkins-linux.sh safe
Running tests in /usr/local/qgis-2.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.plugins.cover: INFO: Coverage report will include only packages: ['safe']
nose.plugins.cover: INFO: Coverage report will include only packages: ['safe']
QGraphicsScene::addItem: item has already been added to this scene
#1 Test the interaction with needs. ... ok
#2 Test the writing to files. ... ok
#3 Test reading from a file. ... ok
#4 Basic test of all properties. ... ok
@akbargumbira
akbargumbira / gist:35b3d03250b0d2d69d44
Created February 3, 2015 09:06
Center windows QDialog
self.setGeometry(
QStyle.alignedRect(
QtCore.Qt.LeftToRight,
QtCore.Qt.AlignCenter,
self.size(),
qApp.desktop().availableGeometry()))
class Foo():
def __init__(self, n):
self._n = 0
self._double_n = 0
# Call the setter to set other things properly
self.n = n
@property
def n(self):
return self._n
apt-get install -y qgis cmake-curses-gui build-essential \
     git gitg meld \
     qtcreator qt4-designer 
     flex bison libgeos-dev libgdal1-dev \
     pyqt4-dev-tools libgsl0-dev libexpat1-dev libproj-dev \
     libqwt-dev libspatialindex-dev libqscintilla2-dev\
     libqscintilla2-dev python-qscintilla2 python-dev python-sip-dev \
 python-qt4-dev postgresql-client-9.3 \
@akbargumbira
akbargumbira / gist:07dc51bcc3f70499db08
Last active August 29, 2015 14:08
Clipping workaround for 2.2
The main problem is that the impact layer (clipped layer) is not aligned with one of the input (either hazard or exposure).
There are 2 possibilities that this is happened in our clipping: the pixel size of the clipped layer is not equal to pixel size of the input layer, or the clipped layer is shifted even though it already has the same pixel size.
For the shifted layer, we found out that gdalwarp (we use gdalwarp to resample the input layers) does not clip properly if the extent (all the edges) to be clipped does not coincide with the pixel boundary of the input. So the solution for this is to adjust the clip extent before clipping to coincide with the target layer to be clipped.
See the picture below. The red extent is the input extent and the green extent is the adjusted extent ready for clipping process.
For other cases, you also might want to see ```safe_qgis.utilities.test.test_clipper.test_adjust_clip_extent```
Another problem that we had is that we lost precision on:
@akbargumbira
akbargumbira / gist:194f26a778ead48bda30
Last active August 29, 2015 14:07
Long Long Fish
Clipping using real polygon and point data from Maumere ... ok
#138 Rasters can be converted to points and clipped by polygons ...