Skip to content

Commit

Permalink
added interactive sar change cell to Chapter9 notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mortcanty committed Jun 22, 2018
1 parent 6fcff8c commit 3062ecd
Show file tree
Hide file tree
Showing 31 changed files with 1,391 additions and 1,001 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.so

src/imagery
src/myimagery

# Distribution / packaging
.Python
Expand Down
332 changes: 156 additions & 176 deletions src/.ipynb_checkpoints/Chapter9-checkpoint.ipynb

Large diffs are not rendered by default.

101 changes: 43 additions & 58 deletions src/Chapter5_2.ipynb

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions src/Chapter6.ipynb

Large diffs are not rendered by default.

321 changes: 145 additions & 176 deletions src/Chapter9.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ auxil/congrid.py
auxil/eeMad.py
auxil/eeWishart.py
auxil/eepca.py
auxil/eesar_seq.py
auxil/header.py
auxil/lookup.py
auxil/png.py
Expand Down
20 changes: 15 additions & 5 deletions src/SequentialOmnibus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -27,7 +27,7 @@
" [6.30154, 50.948329]])\n",
"center = list(reversed(poly.centroid().coordinates().getInfo()))\n",
"\n",
"def get_vvvh(image): \n",
"def get_vvvh(image):\n",
" ''' get 'VV' and 'VH' bands from sentinel-1 imageCollection and restore linear signal from db-values '''\n",
" return image.select('VV','VH').multiply(ee.Image.constant(math.log(10.0)/10.0)).exp()\n",
"\n",
Expand Down Expand Up @@ -210,13 +210,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3dba94223bbc4391a98fa94c8642c268",
"model_id": "c615afdaac6d43cba6b531bed97c6f9e",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -230,7 +230,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d2410698900487f8de4dad048e899d9",
"model_id": "7e8b15c6864644b889c3552fd0432882",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -245,6 +245,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Images found: 69\n",
"Acquistion dates\n",
"['T20170404', 'T20170405', 'T20170410', 'T20170411', 'T20170416', 'T20170417', 'T20170422', 'T20170423', 'T20170428', 'T20170429', 'T20170504', 'T20170505', 'T20170510', 'T20170511', 'T20170516', 'T20170517', 'T20170522', 'T20170523', 'T20170523', 'T20170528', 'T20170529', 'T20170603', 'T20170604', 'T20170604', 'T20170609', 'T20170610', 'T20170615', 'T20170616', 'T20170616', 'T20170622', 'T20170627', 'T20170628', 'T20170628', 'T20170703', 'T20170704', 'T20170709', 'T20170710', 'T20170710', 'T20170715', 'T20170716', 'T20170721', 'T20170722', 'T20170722', 'T20170727', 'T20170728', 'T20170803', 'T20170803', 'T20170808', 'T20170809', 'T20170814', 'T20170815', 'T20170815', 'T20170820', 'T20170821', 'T20170826', 'T20170827', 'T20170827', 'T20170901', 'T20170902', 'T20170907', 'T20170908', 'T20170908', 'T20170913', 'T20170914', 'T20170919', 'T20170920', 'T20170920', 'T20170925', 'T20170926']\n",
"Relative orbit numbers\n",
"[88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15]\n",
"Images found: 69\n",
"Acquistion dates\n",
"['T20170404', 'T20170405', 'T20170410', 'T20170411', 'T20170416', 'T20170417', 'T20170422', 'T20170423', 'T20170428', 'T20170429', 'T20170504', 'T20170505', 'T20170510', 'T20170511', 'T20170516', 'T20170517', 'T20170522', 'T20170523', 'T20170523', 'T20170528', 'T20170529', 'T20170603', 'T20170604', 'T20170604', 'T20170609', 'T20170610', 'T20170615', 'T20170616', 'T20170616', 'T20170622', 'T20170627', 'T20170628', 'T20170628', 'T20170703', 'T20170704', 'T20170709', 'T20170710', 'T20170710', 'T20170715', 'T20170716', 'T20170721', 'T20170722', 'T20170722', 'T20170727', 'T20170728', 'T20170803', 'T20170803', 'T20170808', 'T20170809', 'T20170814', 'T20170815', 'T20170815', 'T20170820', 'T20170821', 'T20170826', 'T20170827', 'T20170827', 'T20170901', 'T20170902', 'T20170907', 'T20170908', 'T20170908', 'T20170913', 'T20170914', 'T20170919', 'T20170920', 'T20170920', 'T20170925', 'T20170926']\n",
"Relative orbit numbers\n",
"[88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15, 88, 15, 15, 88, 15]\n",
"Images found: 28\n",
"Acquistion dates\n",
"['T20170404', 'T20170410', 'T20170416', 'T20170422', 'T20170428', 'T20170504', 'T20170510', 'T20170516', 'T20170522', 'T20170528', 'T20170603', 'T20170609', 'T20170615', 'T20170627', 'T20170703', 'T20170709', 'T20170715', 'T20170721', 'T20170727', 'T20170808', 'T20170814', 'T20170820', 'T20170826', 'T20170901', 'T20170907', 'T20170913', 'T20170919', 'T20170925']\n",
Expand Down
109 changes: 60 additions & 49 deletions src/Untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,84 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import ee\n",
"ee.Initialize()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"import ipyleaflet"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"adaboost.py em.py ex9_1.py meanshift.py rx.py\r\n",
"atwt.py em.pyc gamma_filter.py mmse_filter.py sar_seq.py\r\n",
"c-correction.sh enlml.py hcl.py mnf.py \u001b[0m\u001b[01;32msar_seq.sh\u001b[0m*\r\n",
"c_corr.py ex1_1.py iMadmap.py normalize.sh scatterplot.py\r\n",
"\u001b[01;32mclassify.py\u001b[0m* ex1_2.py iMad.py pca.py som.py\r\n",
"crossvalidate.py ex3_1.py kkmeans.py plr.py subset.py\r\n",
"ct.py ex3_2.py kmeans.py registerms.py subset.pyc\r\n",
"dispms.py ex5_1.py kpca.py registerms.pyc test.py\r\n",
"dwt.py ex5_2.py krx.py registersar.py\r\n",
"ekmeans.py ex5_3.py mcnemar.py run_sar_seq.sh\r\n"
]
}
],
"source": [
"def GetTileLayerUrl(ee_image_object):\n",
" map_id = ee.Image(ee_image_object).getMapId()\n",
" tile_url_template = \"https://earthengine.googleapis.com/map/{mapid}/{{z}}/{{x}}/{{y}}?token={token}\"\n",
" return tile_url_template.format(**map_id)"
"ls scripts"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"s2 = ee.ImageCollection('COPERNICUS/S2').filterDate('2018-01-01', '2018-01-02')"
"!chmod +x scripts/run_sar_seq.sh"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "05d27b12eb7f4d6099214cd8f771aaba",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"TWFwKGJhc2VtYXA9eyd1cmwnOiAnaHR0cHM6Ly97c30udGlsZS5vcGVuc3RyZWV0bWFwLm9yZy97en0ve3h9L3t5fS5wbmcnLCAnbWF4X3pvb20nOiAxOSwgJ2F0dHJpYnV0aW9uJzogJ01hcCDigKY=\n"
]
},
"metadata": {},
"output_type": "display_data"
"name": "stdout",
"output_type": "stream",
"text": [
"***** Multitemporal PolSAR Change Detection **********\n",
"***** Sentinel-1 or Radarsat-2 imagery **************\n",
"******************************************************\n",
"imagery/S1A_IW_SLC__1SDV_20141108T054351_20141108T054421_003186_003AB4_B367_sub.tif\n",
"imagery/S1A_IW_SLC__1SDV_20141202T054350_20141202T054420_003536_004299_33DA_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20150131T054348_20150131T054418_004411_005642_4935_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20150224T054348_20150224T054418_004761_005E71_4E6C_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20150401T054349_20150401T054416_005286_006AFC_1D4E_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20150507T054353_20150507T054421_005811_00778F_5C61_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20150612T054355_20150612T054423_006336_008554_0214_warp.tif\n",
"imagery/S1A_IW_SLC__1SDV_20151010T054400_20151010T054428_008086_00B55D_4185_warp.tif\n",
"===============================================\n",
" Multi-temporal SAR Change Detection\n",
"===============================================\n",
"Tue Jun 19 17:10:44 2018\n",
"First (reference) filename: imagery/S1A_IW_SLC__1SDV_20141108T054351_20141108T054421_003186_003AB4_B367_sub.tif\n",
"number of images: 8\n",
"equivalent number of looks: 12.000000\n",
"significance level: 0.010000\n",
"pre-calculating Rj and p-values ...\n",
"attempting parallel calculation ...\n",
"Waiting for connection file: ~/.ipython/profile_default/security/ipcontroller-client.json\n",
"Connection file '~/.ipython/profile_default/security/ipcontroller-client.json' not found.\n",
"You have attempted to connect to an IPython Cluster but no Controller could be found.\n",
"Please double-check your configuration and ensure that a cluster is running. \n",
"failed, so running sequential calculation ...\n",
"ell= 1 2 3 4 5 6 7 \n",
"elapsed time for p-value calculation: 31.5866880417\n",
"most recent change map written to: /home/mort/python/CRC4Docker/src/imagery/sarseq_cmap.tif\n",
"frequency map written to: /home/mort/python/CRC4Docker/src/imagery/sarseq_fmap.tif\n",
"bitemporal map image written to: /home/mort/python/CRC4Docker/src/imagery/sarseq_bmap.tif\n",
"first change map written to: /home/mort/python/CRC4Docker/src/imagery/sarseq_smap.tif\n",
"total elapsed time: 31.7328760624\n"
]
}
],
"source": [
"map1 = ipyleaflet.Map(\n",
" center=(48.2082, 16.3779), zoom=4,\n",
" layout={'height':'400px'}\n",
")\n",
"map1.add_layer(\n",
" ipyleaflet.TileLayer(url=GetTileLayerUrl(\n",
" s2.mosaic().visualize(min=0, max=3000, gamma=1.5, bands= ['B4', 'B3', 'B2'])\n",
" )\n",
"))\n",
"map1"
"!scripts/run_sar_seq.sh S1A imagery/ 12 0.01"
]
},
{
Expand Down
56 changes: 2 additions & 54 deletions src/Untitled1.ipynb
Original file line number Diff line number Diff line change
@@ -1,58 +1,6 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/bin/sh: 1: ipycluster: not found\r\n"
]
}
],
"source": [
"!ipycluster start -n 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import ipyparallel"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
}
},
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
122 changes: 2 additions & 120 deletions src/Untitled2.ipynb
Original file line number Diff line number Diff line change
@@ -1,124 +1,6 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Stop a running IPython cluster\r\n",
"\r\n",
"Stop a running ipython cluster by its profile name or cluster directory. Cluster\r\n",
"directories are named using the convention 'profile_<name>'. If your cluster\r\n",
"directory is in the cwd or the ipython directory, you can simply refer to it\r\n",
"using its profile name, 'ipcluster stop --profile=<profile>`, otherwise use the\r\n",
"'--profile-dir' option.\r\n",
"\r\n",
"Options\r\n",
"-------\r\n",
"\r\n",
"Arguments that take values are actually convenience aliases to full\r\n",
"Configurables, whose aliases are listed on the help line. For more information\r\n",
"on full configurables, see '--help-all'.\r\n",
"\r\n",
"--debug\r\n",
" set log level to logging.DEBUG (maximize logging output)\r\n",
"--init\r\n",
" Initialize profile with default config files. This is equivalent\r\n",
" to running `ipython profile create <profile>` prior to startup.\r\n",
"--log-to-file\r\n",
" send log output to a file\r\n",
"--quiet\r\n",
" set log level to logging.CRITICAL (minimize logging output)\r\n",
"--profile=<Unicode> (BaseIPythonApplication.profile)\r\n",
" Default: u'default'\r\n",
" The IPython profile to use.\r\n",
"--cluster-id=<Unicode> (BaseParallelApplication.cluster_id)\r\n",
" Default: ''\r\n",
" String id to add to runtime files, to prevent name collisions when using\r\n",
" multiple clusters with a single profile simultaneously.\r\n",
" When set, files will be named like: 'ipcontroller-<cluster_id>-engine.json'\r\n",
" Since this is text inserted into filenames, typical recommendations apply:\r\n",
" Simple character strings are ideal, and spaces are not recommended (but\r\n",
" should generally work).\r\n",
"--log-to-file=<Bool> (BaseParallelApplication.log_to_file)\r\n",
" Default: False\r\n",
" whether to log to a file\r\n",
"--ipython-dir=<Unicode> (BaseIPythonApplication.ipython_dir)\r\n",
" Default: u''\r\n",
" The name of the IPython directory. This directory is used for logging\r\n",
" configuration (through profiles), history storage, etc. The default is\r\n",
" usually $HOME/.ipython. This option can also be specified through the\r\n",
" environment variable IPYTHONDIR.\r\n",
"--signal=<Integer> (IPClusterStop.signal)\r\n",
" Default: 2\r\n",
" signal to use for stopping processes.\r\n",
"--log-level=<Enum> (Application.log_level)\r\n",
" Default: 30\r\n",
" Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')\r\n",
" Set the log level by value or name.\r\n",
"--log-url=<Unicode> (BaseParallelApplication.log_url)\r\n",
" Default: ''\r\n",
" The ZMQ URL of the iplogger to aggregate logging.\r\n",
"--clean-logs=<Bool> (BaseParallelApplication.clean_logs)\r\n",
" Default: False\r\n",
" whether to cleanup old logfiles before starting\r\n",
"--config=<Unicode> (BaseIPythonApplication.extra_config_file)\r\n",
" Default: u''\r\n",
" Path to an extra config file to load.\r\n",
" If specified, load this config file in addition to any other IPython config.\r\n",
"--profile-dir=<Unicode> (ProfileDir.location)\r\n",
" Default: u''\r\n",
" Set the profile location directly. This overrides the logic used by the\r\n",
" `profile` option.\r\n",
"--work-dir=<Unicode> (BaseParallelApplication.work_dir)\r\n",
" Default: u'/home/mort/python/CRC4Docker/src'\r\n",
" Set the working dir for the process.\r\n",
"\r\n",
"To see all available configurables, use `--help-all`\r\n",
"\r\n",
"Examples\r\n",
"--------\r\n",
"\r\n",
" ipcluster stop --profile=mycluster # stop a running cluster by profile name\r\n",
"\r\n"
]
}
],
"source": [
"!ipcluster stop -h"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
}
},
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 3062ecd

Please sign in to comment.