SDAPs finished 🤞
This commit is contained in:
parent
db34096353
commit
1e04ac54cb
@ -50,12 +50,14 @@
|
||||
"source": [
|
||||
"l = ld2dap.LoadTIFF(layers_files[5:7])\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",
|
||||
"o = ld2dap.RawOutput()\n",
|
||||
"\n",
|
||||
"o.input = a\n",
|
||||
"d.input = a\n",
|
||||
"o.input = f\n",
|
||||
"d.input = f\n",
|
||||
"f.input = a\n",
|
||||
"a.input = t\n",
|
||||
"t.input = l\n",
|
||||
"\n",
|
||||
@ -161,7 +163,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"nstack = np.insert(stack, (3), raster_broadcast, axis=2)\n",
|
||||
"nstack = np.insert(stack, (3,5), raster_broadcast, axis=2)\n",
|
||||
"nstack.shape"
|
||||
]
|
||||
},
|
||||
@ -181,43 +183,6 @@
|
||||
"(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",
|
||||
"metadata": {},
|
||||
@ -231,9 +196,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"raster_count = 4\n",
|
||||
"raster_count = 2\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 = where[where != 0] - 1\n",
|
||||
"\n",
|
||||
@ -243,6 +208,7 @@
|
||||
"display(count)\n",
|
||||
"\n",
|
||||
"where = np.cumsum(where[:-1])\n",
|
||||
"origins_dcount = where.size\n",
|
||||
"display(where)\n",
|
||||
"\n",
|
||||
"offset = np.repeat(np.arange(raster_count) * count, where.size)\n",
|
||||
@ -251,14 +217,35 @@
|
||||
"where"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### Repeat multiple origins"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"A = list()\n",
|
||||
"A.size"
|
||||
"origins_index = np.arange(raster_count) * count\n",
|
||||
"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()
|
||||
raster_offset = sum(att_len.values())
|
||||
|
||||
# Data
|
||||
# Duplicate origin in data to respect Stack structure
|
||||
# Compute insert index in where
|
||||
where = np.array(list(att_len.values()))
|
||||
@ -84,17 +85,21 @@ class SelfDualAttributeProfiles(Filter):
|
||||
where[0] += 1
|
||||
count = sum(where)
|
||||
where = np.cumsum(where[:-1])
|
||||
origins_dcount = where.size
|
||||
offset = np.repeat(np.arange(len(metadata)) * count,
|
||||
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:
|
||||
# - Repeat multiple origins
|
||||
# - Duplicate origins to match where
|
||||
# - Insert origins where
|
||||
|
||||
data_new = None
|
||||
# Insert origins in data
|
||||
data_new = np.insert(attributes, where, origins, axis=2)
|
||||
|
||||
# Metadata
|
||||
for stack in metadata:
|
||||
if stack.end - stack.begin > 1:
|
||||
self.logger.err('Nested filtering, raising error')
|
||||
|
Loading…
Reference in New Issue
Block a user