SDAPs finished 🤞
This commit is contained in:
parent
db34096353
commit
1e04ac54cb
@ -50,12 +50,14 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"l = ld2dap.LoadTIFF(layers_files[5:7])\n",
|
"l = ld2dap.LoadTIFF(layers_files[5:7])\n",
|
||||||
"t = ld2dap.Treshold(1e4)\n",
|
"t = ld2dap.Treshold(1e4)\n",
|
||||||
"a = ld2dap.SelfDualAttributeProfiles(area = [1e3, 1e6], sd = [.5])\n",
|
"a = ld2dap.SelfDualAttributeProfiles(area = [1e3, 1e6], sd=[.4,.6,.8], moi=[.5,.9])\n",
|
||||||
|
"f = ld2dap.Differential()\n",
|
||||||
"d = ld2dap.ShowFig(stack_id='all', symb=True)\n",
|
"d = ld2dap.ShowFig(stack_id='all', symb=True)\n",
|
||||||
"o = ld2dap.RawOutput()\n",
|
"o = ld2dap.RawOutput()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"o.input = a\n",
|
"o.input = f\n",
|
||||||
"d.input = a\n",
|
"d.input = f\n",
|
||||||
|
"f.input = a\n",
|
||||||
"a.input = t\n",
|
"a.input = t\n",
|
||||||
"t.input = l\n",
|
"t.input = l\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -161,7 +163,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"nstack = np.insert(stack, (3), raster_broadcast, axis=2)\n",
|
"nstack = np.insert(stack, (3,5), raster_broadcast, axis=2)\n",
|
||||||
"nstack.shape"
|
"nstack.shape"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -181,43 +183,6 @@
|
|||||||
"(stack[:,:,3] == nstack[:,:,4]).all()"
|
"(stack[:,:,3] == nstack[:,:,4]).all()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"#### Repeat multiple origins"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"raster_count = 2\n",
|
|
||||||
"att_len = {'area': 3, 'sd': 0, 'moi': 0}\n",
|
|
||||||
"# Ignore\n",
|
|
||||||
"where = np.array(list(att_len.values()))\n",
|
|
||||||
"where = where[where != 0] - 1\n",
|
|
||||||
"where[0] += 1\n",
|
|
||||||
"count = sum(where)\n",
|
|
||||||
"# /Ignore\n",
|
|
||||||
"origins_index = np.arange(raster_count) * count\n",
|
|
||||||
"display(origins_index)\n",
|
|
||||||
"origins = stack[:,:,origins_index]\n",
|
|
||||||
"origins.shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"A = np.arange(16*9*4).reshape((16,9,4))\n",
|
|
||||||
"A[:,:,[0,1]].shape"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -231,9 +196,9 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"raster_count = 4\n",
|
"raster_count = 2\n",
|
||||||
"\n",
|
"\n",
|
||||||
"att_len = {'area': 3, 'sd': 2, 'moi': 0}\n",
|
"att_len = {'area': 3, 'sd': 4, 'moi': 3}\n",
|
||||||
"where = np.array(list(att_len.values()))\n",
|
"where = np.array(list(att_len.values()))\n",
|
||||||
"where = where[where != 0] - 1\n",
|
"where = where[where != 0] - 1\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -243,6 +208,7 @@
|
|||||||
"display(count)\n",
|
"display(count)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"where = np.cumsum(where[:-1])\n",
|
"where = np.cumsum(where[:-1])\n",
|
||||||
|
"origins_dcount = where.size\n",
|
||||||
"display(where)\n",
|
"display(where)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"offset = np.repeat(np.arange(raster_count) * count, where.size)\n",
|
"offset = np.repeat(np.arange(raster_count) * count, where.size)\n",
|
||||||
@ -251,14 +217,35 @@
|
|||||||
"where"
|
"where"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### Repeat multiple origins"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"A = list()\n",
|
"origins_index = np.arange(raster_count) * count\n",
|
||||||
"A.size"
|
"display(origins_index)\n",
|
||||||
|
"origins = stack[:,:,origins_index]\n",
|
||||||
|
"origins.shape, (origins[:,:,0] == stack[:,:,0]).all(), (origins[:,:,1] == stack[:,:,8]).all()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"rorigins = np.repeat(origins, 2, axis=2)\n",
|
||||||
|
"rorigins.shape, \\\n",
|
||||||
|
"(rorigins[:,:,0] == rorigins[:,:,1]).all() and (origins[:,:,0] == rorigins[:,:,1]).all(), \\\n",
|
||||||
|
"(rorigins[:,:,2] == rorigins[:,:,3]).all() and (origins[:,:,1] == rorigins[:,:,2]).all()"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -77,6 +77,7 @@ class SelfDualAttributeProfiles(Filter):
|
|||||||
att_len, att_len_cs = self._process_len()
|
att_len, att_len_cs = self._process_len()
|
||||||
raster_offset = sum(att_len.values())
|
raster_offset = sum(att_len.values())
|
||||||
|
|
||||||
|
# Data
|
||||||
# Duplicate origin in data to respect Stack structure
|
# Duplicate origin in data to respect Stack structure
|
||||||
# Compute insert index in where
|
# Compute insert index in where
|
||||||
where = np.array(list(att_len.values()))
|
where = np.array(list(att_len.values()))
|
||||||
@ -84,17 +85,21 @@ class SelfDualAttributeProfiles(Filter):
|
|||||||
where[0] += 1
|
where[0] += 1
|
||||||
count = sum(where)
|
count = sum(where)
|
||||||
where = np.cumsum(where[:-1])
|
where = np.cumsum(where[:-1])
|
||||||
|
origins_dcount = where.size
|
||||||
offset = np.repeat(np.arange(len(metadata)) * count,
|
offset = np.repeat(np.arange(len(metadata)) * count,
|
||||||
where.size) # Can't nest this
|
where.size) # Can't nest this
|
||||||
where = np.tile(where, (len(metadata)) + offset
|
where = np.tile(where, len(metadata)) + offset
|
||||||
|
# Find origins
|
||||||
|
origins_index = np.arange(len(metadata)) * count
|
||||||
|
self.logger.debug('origins_index: {}'.format(origins_index))
|
||||||
|
origins = attributes[:, :, origins_index]
|
||||||
|
# Unfold origins to match insert pattern
|
||||||
|
origins = np.repeat(origins, origins_dcount, axis=2)
|
||||||
|
|
||||||
# TODO:
|
# Insert origins in data
|
||||||
# - Repeat multiple origins
|
data_new = np.insert(attributes, where, origins, axis=2)
|
||||||
# - Duplicate origins to match where
|
|
||||||
# - Insert origins where
|
|
||||||
|
|
||||||
data_new = None
|
|
||||||
|
|
||||||
|
# Metadata
|
||||||
for stack in metadata:
|
for stack in metadata:
|
||||||
if stack.end - stack.begin > 1:
|
if stack.end - stack.begin > 1:
|
||||||
self.logger.err('Nested filtering, raising error')
|
self.logger.err('Nested filtering, raising error')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user