diff --git a/data/wildfire/run_000baafc-fe1a-48a1-90c5-8edf2301ca8a_fuels-dens_2100_000.png b/data/wildfire/run_000baafc-fe1a-48a1-90c5-8edf2301ca8a_fuels-dens_2100_000.png new file mode 100644 index 00000000..de5c65dc Binary files /dev/null and b/data/wildfire/run_000baafc-fe1a-48a1-90c5-8edf2301ca8a_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_001a5aa3-1d00-473d-8e9c-56c6c217a025_fuels-dens_2100_000.png b/data/wildfire/run_001a5aa3-1d00-473d-8e9c-56c6c217a025_fuels-dens_2100_000.png new file mode 100644 index 00000000..2ea1f263 Binary files /dev/null and b/data/wildfire/run_001a5aa3-1d00-473d-8e9c-56c6c217a025_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_001d82e8-6447-4218-8a82-e5d66b3ee965_fuels-dens_2100_000.png b/data/wildfire/run_001d82e8-6447-4218-8a82-e5d66b3ee965_fuels-dens_2100_000.png new file mode 100644 index 00000000..b0254d61 Binary files /dev/null and b/data/wildfire/run_001d82e8-6447-4218-8a82-e5d66b3ee965_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_0027a212-2e4c-40a6-830a-e14de1495b29_fuels-dens_2100_000.png b/data/wildfire/run_0027a212-2e4c-40a6-830a-e14de1495b29_fuels-dens_2100_000.png new file mode 100644 index 00000000..763f3038 Binary files /dev/null and b/data/wildfire/run_0027a212-2e4c-40a6-830a-e14de1495b29_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_0027e586-0f94-4860-bf80-ca6b35c70155_fuels-dens_2100_000.png b/data/wildfire/run_0027e586-0f94-4860-bf80-ca6b35c70155_fuels-dens_2100_000.png new file mode 100644 index 00000000..fd859ff7 Binary files /dev/null and b/data/wildfire/run_0027e586-0f94-4860-bf80-ca6b35c70155_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_0028f006-ff57-4d09-9282-d9bf0ab92f44_fuels-dens_2100_000.png b/data/wildfire/run_0028f006-ff57-4d09-9282-d9bf0ab92f44_fuels-dens_2100_000.png new file mode 100644 index 00000000..eb9f72df Binary files /dev/null and b/data/wildfire/run_0028f006-ff57-4d09-9282-d9bf0ab92f44_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_002b1a99-ab6d-4afe-93cf-77196379c3a0_fuels-dens_2100_000.png b/data/wildfire/run_002b1a99-ab6d-4afe-93cf-77196379c3a0_fuels-dens_2100_000.png new file mode 100644 index 00000000..e375d39d Binary files /dev/null and b/data/wildfire/run_002b1a99-ab6d-4afe-93cf-77196379c3a0_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_004e4371-f3a9-42a3-9b0a-72299972116e_fuels-dens_2100_000.png b/data/wildfire/run_004e4371-f3a9-42a3-9b0a-72299972116e_fuels-dens_2100_000.png new file mode 100644 index 00000000..52138a75 Binary files /dev/null and b/data/wildfire/run_004e4371-f3a9-42a3-9b0a-72299972116e_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_008452dd-b2df-4ad9-8509-da9a99167bb1_fuels-dens_2100_000.png b/data/wildfire/run_008452dd-b2df-4ad9-8509-da9a99167bb1_fuels-dens_2100_000.png new file mode 100644 index 00000000..419dafb5 Binary files /dev/null and b/data/wildfire/run_008452dd-b2df-4ad9-8509-da9a99167bb1_fuels-dens_2100_000.png differ diff --git a/data/wildfire/run_00998da4-889e-4e9f-a47b-685b961bb028_fuels-dens_2100_000.png b/data/wildfire/run_00998da4-889e-4e9f-a47b-685b961bb028_fuels-dens_2100_000.png new file mode 100644 index 00000000..686c33ea Binary files /dev/null and b/data/wildfire/run_00998da4-889e-4e9f-a47b-685b961bb028_fuels-dens_2100_000.png differ diff --git a/data/wildfire/wildfire.sqlite3 b/data/wildfire/wildfire.sqlite3 new file mode 100644 index 00000000..d98bbd52 Binary files /dev/null and b/data/wildfire/wildfire.sqlite3 differ diff --git a/pycinema/filters/ImageReader.py b/pycinema/filters/ImageReader.py index 229c6be8..5f4307af 100644 --- a/pycinema/filters/ImageReader.py +++ b/pycinema/filters/ImageReader.py @@ -5,6 +5,7 @@ import h5py import os import re +import requests from pycinema import getTableExtent @@ -72,7 +73,11 @@ def _update(self): file.close() elif str.lower(extension) in ['png','jpg','jpeg']: - rawImage = PIL.Image.open(path) + if "https" in path: + rawImage = PIL.Image.open(requests.get(path, stream=True).raw) + else: + rawImage = PIL.Image.open(path) + if rawImage.mode == 'RGB': rawImage = rawImage.convert('RGBA') image = Image({ 'rgba': numpy.asarray(rawImage) }) diff --git a/pycinema/filters/SqliteDatabaseReader.py b/pycinema/filters/SqliteDatabaseReader.py new file mode 100644 index 00000000..c424a0b2 --- /dev/null +++ b/pycinema/filters/SqliteDatabaseReader.py @@ -0,0 +1,81 @@ +from pycinema import Filter + +import sqlite3 + +from os.path import exists +import re + +class SqliteDatabaseReader(Filter): + + def __init__(self): + super().__init__( + inputs={ + 'path': '', + 'table': '', + 'file_column': 'FILE' + }, + outputs={ + 'table': [[]] + } + ) + + def _update(self): + + table = [] + dbPath = self.inputs.path.get() + if not dbPath: + self.outputs.table.set([[]]) + return 0 + + if not exists(dbPath): + print('[ERROR] sqlite db not found:', dbPath) + self.outputs.table.set([[]]) + return 0 + + tname = self.inputs.table.get() + try: + conn = sqlite3.connect(dbPath) + cursor = conn.cursor() + + # capture the names of each column + cdata = cursor.execute(f'PRAGMA table_info({tname});').fetchall() + + cnames = [entry[1] for entry in cdata] + table.append(cnames) + + print(table) + # capture row data + data = cursor.execute("SELECT * FROM " + tname + "").fetchall() #LIMIT 10 + for row in data: + # tuple output convert to list + table.append(list(row)) + + print(table) + cursor.close() + except sqlite3.Error as error: + print("Error while connecting to sqlite", error) + self.outputs.table.set([[]]) + return 0 + finally: + if conn: + conn.close() + + # remove empty lines + table = list(filter(lambda row: len(row)>0, table)) + + # # force lower case header + # table[0] = list(map(str.lower,table[0])) + + try: + fileColumnIdx = [i for i, item in enumerate(table[0]) if re.search(self.inputs.file_column.get(), item, re.IGNORECASE)].pop() + except: + print('[ERROR] file column not found:',self.inputs.file_column.get()) + self.outputs.table.set([[]]) + return 0 + + for i in range(1,len(table)): + table[i][fileColumnIdx] = table[i][fileColumnIdx] + + self.outputs.table.set(table) + + return 1 diff --git a/pycinema/filters/__init__.py b/pycinema/filters/__init__.py index 221db627..d35df004 100644 --- a/pycinema/filters/__init__.py +++ b/pycinema/filters/__init__.py @@ -12,9 +12,6 @@ from .ImageFilterPIL import * from .ImageReader import * from .MaskCompositing import * -from .PlotItem import * -from .PlotBarItem import * -from .PlotLineItem import * from .ShaderDemoScene import * from .ShaderFXAA import * from .ShaderIBS import * @@ -24,5 +21,5 @@ from .ShaderSSAO import * from .ShaderLineAO import * from .ShaderPointAO import * -from .TextFileReader import * +from .SqliteDatabaseReader import * from .TableWriter import * diff --git a/setup.py b/setup.py index 7028d4ed..a73f73ea 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,8 @@ "ipywidgets==8.0.6", "PySide6>=6.0.0", "python-igraph>=0.10.5", - "pyqtgraph" + "pyqtgraph", + "requests" ], classifiers=[ "Programming Language :: Python :: 3",