Create ld2dap package

This commit is contained in:
Florent Guiotte 2018-04-12 19:15:50 +02:00
parent 3d13e1c1df
commit f633ca0a64
9 changed files with 111 additions and 16 deletions

View File

@ -6,7 +6,16 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from pathlib import Path" "import sys\n",
"from pathlib import Path\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import collections\n",
"\n",
"ld2dap_path = Path('../')\n",
"sys.path.append(str(ld2dap_path.resolve()))\n",
"import ld2dap\n",
"from ld2dap.core import Filter"
] ]
}, },
{ {
@ -15,7 +24,47 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"url = '../Data/test.tiff'" "load = ld2dap.LoadTIFF('../Data/test.tiff')\n",
"trsh = ld2dap.Treshold(1e3)\n",
"disp = ld2dap.ShowFig(fname=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"disp.input = trsh\n",
"trsh.input = load"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"disp.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"load.files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"A = 'est'\n",
"isinstance(A, collections.Iterable)"
] ]
}, },
{ {

View File

@ -0,0 +1,31 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -8,7 +8,7 @@
# #
# TODO details # TODO details
from core import Filter, Stack from .core import Filter, Stack
## TODO: dep ## TODO: dep
import sys import sys

View File

@ -8,7 +8,7 @@
# #
# TODO details # TODO details
from core import Input, Stack from ld2dap.core import Input, Stack
import numpy as np import numpy as np
## TODO: dep ## TODO: dep
@ -19,7 +19,7 @@ import triskele
class LoadTIFF(Input): class LoadTIFF(Input):
def __init__(self, tiffFiles): def __init__(self, tiffFiles):
super().__init__(self.__class__.__name__) super().__init__(self.__class__.__name__)
self.files = tiffFiles self.files = tiffFiles if isinstance(tiffFiles, list) else [tiffFiles]
def _process(self, data, metadata): def _process(self, data, metadata):
layers = list() layers = list()

View File

@ -8,7 +8,7 @@
# #
# TODO details # TODO details
from core import Output from ld2dap.core import Output
import matplotlib.pyplot as plt import matplotlib.pyplot as plt

View File

@ -8,7 +8,7 @@
# #
# TODO details # TODO details
from core import Output from ld2dap.core import Output
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
@ -26,6 +26,7 @@ class ShowFig(Output):
img = f1.imshow(data[:,:,-1]) img = f1.imshow(data[:,:,-1])
plt.colorbar(img) plt.colorbar(img)
if metadata is not None: if metadata is not None:
f1.set_title(metadata[-1].desc) print (metadata[0].desc)
f1.set_title(' > '.join(metadata[0].desc[-1]))
plt.show() plt.show()
plt.close(fig) plt.close(fig)

View File

@ -8,7 +8,7 @@
# #
# TODO details # TODO details
from core import Filter from ld2dap.core import Filter
class Treshold(Filter): class Treshold(Filter):
def __init__(self, treshold, max_value=None): def __init__(self, treshold, max_value=None):
@ -21,6 +21,8 @@ class Treshold(Filter):
self.max_value = data[data < self.treshold].max() self.max_value = data[data < self.treshold].max()
for stack in metadata: for stack in metadata:
stack.desc.append('treshold {}'.format(self.treshold)) for d, s in zip(stack.desc, stack.symb):
d.append('treshold {}'.format(self.treshold))
s.append('T_{{{}}}'.format(self.treshold))
return data * (data < self.treshold) + self.max_value * (data >= self.treshold), metadata return data * (data < self.treshold) + self.max_value * (data >= self.treshold), metadata

15
ld2dap/__init__.py Normal file
View File

@ -0,0 +1,15 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# \file __init__.py
# \brief TODO
# \author Florent Guiotte <florent.guiotte@gmail.com>
# \version 0.1
# \date 12 avril 2018
#
# TODO details
from .AttributeProfiles import AttributeProfiles
from .Treshold import Treshold
from .LoadTIFF import LoadTIFF
from .SaveFig import SaveFig
from .ShowFig import ShowFig

View File

@ -9,16 +9,13 @@
# TODO details # TODO details
#from core import Input, Output, Filter #from core import Input, Output, Filter
from LoadTIFF import LoadTIFF from ld2dap import LoadTIFF, SaveFig, Treshold, ShowFig
from AttributeProfiles import AttributeProfiles as APs from ld2dap import AttributeProfiles as APs
from SaveFig import SaveFig
from Treshold import Treshold
from ShowFig import ShowFig
import numpy as np import numpy as np
def main(): def main():
i = LoadTIFF(['../Data/test.tiff', '../Data/test.tiff']) i = LoadTIFF(['Data/test.tiff', 'Data/test2.tiff'])
t = Treshold(1e4) t = Treshold(1e4)
ap = APs(np.array([100,1e3,1e4])) ap = APs(np.array([100,1e3,1e4]))
o = SaveFig('test.png') o = SaveFig('test.png')