The InaSAFE documentation files are written using the RST format (quickreference guide) and stored with the source code in github:
https://github.com/AIFDR/inasafe/tree/master/docs/source
To replace string layer_type, say, with layertype across all python files in project, do:
find . -name "*.py" -print | xargs sed -i 's/layer_type/layertype/g'
Alternative you can install the ‘rpl’ command line tool:
sudo apt-get install rpl
Using rpl is much simpler, just do:
rpl "oldstring" "newstring" *.py
For details on the find command see this article.
The format was derived using the git log format tag. It is stored in the source of each python as:
__revision__ = '$Format:%H$'
‘%H’ being the format tag for the SHA1. The __revision__ is not updated with each commit. Rather is is registered with git for replacement when using git-archive by doing this:
echo "*.py export-subst" > .gitattributes
git add .gitattributes
The above only needs to be done once and then all python files with format substitutions will be replaced when running git-archive. The actual substition takes place at the time that a git archive is generated (git archive creates a copy of the repo with all repository metadata stripped out). For example:
git archive version-0_3 | tar -x -C /tmp/inasafe-0.3.0
You can verify SHA1 replacement has been made by doing:
cat /tmp/inasafe/gui/is_plugin.py | grep revision
__revision__ = 'a515345e43b25d065e1ae0d73687c13531ea4c9c'
The deployment of version tagged files is automated by using the scriptsrelease.sh script.
sudo apt-get install python-profiler python -m cProfile -s time safe/common/test_polygon.py
and
sudo easy_install pycallgraph sudo apt-get install graphviz pycallgraph safe/common/test_polygon.py
See also http://stackoverflow.com/questions/582336/how-can-you-profile-a-python-script
InaSAFE needs to convert NaN to 1e+24 or more specifically 24 digits of 9 because NaN is not intepreted correclty on Windows. You can read more information about it on http://trac.osgeo.org/gdal/ticket/4799 or in Github issue #269.
But don’t worry, when InaSAFE read vector file, it will convert the 1e+24 back to NaN. So, any computation inside InaSAFE will treat NaN as NaN in numpy.
Note
You’ll need to convert the 1e+24 to NaN value manually if you want to use it without InaSAFE.