Commit f25d99f2 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'cinema-import-update'

dcab4b3a cinemasci: update file listing
575a9325 Merge branch 'upstream-cinemasci' into HEAD
0a14a389 cinemasci 2020-09-29 (79c3cdbb)
05944da5 cinemasci: import with submodules
9dca1d4d

 update-common: support importing projects with submodules
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !4420
parents a73aa75d dcab4b3a
set(files
paraview/tpl/cinemasci/cis/colormap.py
paraview/tpl/cinemasci/cdb/__init__.py
paraview/tpl/cinemasci/cis/channel.py
paraview/tpl/cinemasci/cis/write/file.py
paraview/tpl/cinemasci/cis/write/hdf5.py
paraview/tpl/cinemasci/cis/write/__init__.py
paraview/tpl/cinemasci/cis/colormap.py
paraview/tpl/cinemasci/cis/image.py
paraview/tpl/cinemasci/cis/render.py
paraview/tpl/cinemasci/cis/__init__.py
paraview/tpl/cinemasci/cis/layer.py
paraview/tpl/cinemasci/cis/read/file.py
paraview/tpl/cinemasci/cis/read/hdf5.py
paraview/tpl/cinemasci/cis/read/__init__.py
paraview/tpl/cinemasci/cis/__init__.py
paraview/tpl/cinemasci/cis/layer.py
paraview/tpl/cinemasci/cview/cinema_view.html
paraview/tpl/cinemasci/cview/cinema_explorer.html
paraview/tpl/cinemasci/cview/__main__.py
paraview/tpl/cinemasci/cview/__init__.py
paraview/tpl/cinemasci/cview/cinema/databases.js
paraview/tpl/cinemasci/cview/cinema/lib/d3.v4.min.js
paraview/tpl/cinemasci/cview/cinema/explorer/1.11/css/viewer.css
paraview/tpl/cinemasci/cview/cinema/explorer/1.11/databases.json
paraview/tpl/cinemasci/cview/cinema/explorer/1.11/js/main.js
paraview/tpl/cinemasci/cview/cinema/view/1.2/css/common.css
paraview/tpl/cinemasci/cview/cinema/view/1.2/css/select-css.css
paraview/tpl/cinemasci/cview/cinema/view/1.2/css/range-css.textClipping
paraview/tpl/cinemasci/cview/cinema/view/1.2/css/view.css
paraview/tpl/cinemasci/cview/cinema/view/1.2/css/range-css.css
paraview/tpl/cinemasci/cview/cinema/view/1.2/version.md
paraview/tpl/cinemasci/cdb/__init__.py
paraview/tpl/cinemasci/cview/cinema/view/1.2/copyright.md
paraview/tpl/cinemasci/cview/cinema/view/1.2/databases.json
paraview/tpl/cinemasci/cview/cinema/view/1.2/images/empty.png
paraview/tpl/cinemasci/cview/cinema/view/1.2/license.md
paraview/tpl/cinemasci/cis/render.py
paraview/tpl/cinemasci/cis/write/file.py
paraview/tpl/cinemasci/cis/write/hdf5.py
paraview/tpl/cinemasci/cis/write/__init__.py
paraview/tpl/cinemasci/__init__.py
paraview/tpl/cinemasci/pynb/__init__.py)
paraview/tpl/cinemasci/pynb/__init__.py
paraview/tpl/cinemasci/server/__init__.py
paraview/tpl/cinemasci/server/__main__.py
paraview/tpl/cinemasci/viewers/cinema/explorer/2.0/css/viewer.css
paraview/tpl/cinemasci/viewers/cinema/explorer/2.0/databases.json
paraview/tpl/cinemasci/viewers/cinema/explorer/2.0/js/main.js
paraview/tpl/cinemasci/viewers/cinema_explorer.html
paraview/tpl/cinemasci/viewers/cinema/lib/d3.v4.min.js
paraview/tpl/cinemasci/viewers/cinema/lib/databases.js
paraview/tpl/cinemasci/viewers/cinema/view/2.0/copyright.md
paraview/tpl/cinemasci/viewers/cinema/view/2.0/css/common.css
paraview/tpl/cinemasci/viewers/cinema/view/2.0/css/range-css.css
paraview/tpl/cinemasci/viewers/cinema/view/2.0/css/range-css.textClipping
paraview/tpl/cinemasci/viewers/cinema/view/2.0/css/select-css.css
paraview/tpl/cinemasci/viewers/cinema/view/2.0/css/view.css
paraview/tpl/cinemasci/viewers/cinema/view/2.0/databases.json
paraview/tpl/cinemasci/viewers/cinema/view/2.0/images/empty.png
paraview/tpl/cinemasci/viewers/cinema/view/2.0/license.md
paraview/tpl/cinemasci/viewers/cinema/view/2.0/version.md
paraview/tpl/cinemasci/viewers/cinema_view.html
paraview/tpl/cinemasci/viewers/citation.md
paraview/tpl/cinemasci/viewers/__init__.py
paraview/tpl/cinemasci/viewers/license.md
paraview/tpl/cinemasci/viewers/readme.md
paraview/tpl/cinemasci/viewers/test_explorer.html
paraview/tpl/cinemasci/viewers/test_view.html)
vtk_module_add_python_package(ParaView::CinemaSci
FILES ${files}
......
......@@ -5,3 +5,4 @@ testing/scratch
html/
build/
*.egg-info/
dist/
__all__ = ["cis", "cdb", "cview", "pynb"]
__all__ = ["cis", "cdb", "viewers", "pynb"]
Version = "0.1"
Version = "0.4"
#
# new factory function
......
......@@ -54,6 +54,57 @@ class cdb:
return result
def checkNumericColumns(self):
"""Based on the first row of entries, determines which columns are numeric and non-numeric
Returns a list of True/False
"""
indexisNumeric = []
cur = self.con.cursor()
query = "SELECT * from {} ORDER BY ROWID ASC LIMIT 1".format(self.tablename)
result = cur.execute(query)
for item in result:
for value in item:
try:
valueAsNumber = float(value)
indexisNumeric.append(True)
except ValueError:
indexisNumeric.append(False)
return indexisNumeric
def getParameterValues(self, parameter):
"""Given a parameter, return a sorted list of unique values of the parameter
"""
parameterValues = []
if parameter in self.parameternames:
cur = self.con.cursor()
query = "SELECT {} from {}".format(parameter, self.tablename)
vals = [float(entry[0]) for entry in cur.execute(query)]
parameterValues = set(vals)
return parameterValues
def getFilepathMap(self, selectedParameters, selectedFilepaths):
mapping = []
indexisNumeric = self.checkNumericColumns()
cur = self.con.cursor()
query = "SELECT * from {}".format(self.tablename)
cur.execute(query)
for row in cur:
filepaths = []
parameterKey = ""
for i in selectedParameters:
value = row[i]
if indexisNumeric[i]:
value = str(float(value))
parameterKey += value+"_"
for i in selectedFilepaths:
filepaths.append(row[i])
mapping.append((parameterKey, filepaths))
return mapping
def parameter_exists(self, parameter):
"""Check if a parameter exists
"""
......
import csv
import ipywidgets
import os
import cinemasci
from IPython.display import display
class CinemaViewer():
......@@ -31,13 +32,16 @@ class CinemaViewer():
self.parameterKey2filepathMap = dict() # the key-value map that maps parameter combinations to filepaths
def setLayoutToVertical(self):
self.layout = CinemaViewer.LayoutVertical
self.layout = CinemaViewer.LayoutVertical
self.updateImages('',True)
def setLayoutToHorizontal(self):
self.layout = CinemaViewer.LayoutHorizontal
def setHeight(self, height):
self.height = height
self.layout = CinemaViewer.LayoutHorizontal
self.updateImages('',True)
# def setHeight(self, height):
# self.height = height
# self.updateImages('')
def displayControls(self):
with self.parameterValuesOutput:
......@@ -101,7 +105,6 @@ class CinemaViewer():
else:
print(str(valuesDict[w.description]) + " is not an value of " + w.description)
def hideParameterControl(self, name):
for w in self.parameterValueWidgets:
if (name == w.description):
......@@ -164,107 +167,44 @@ class CinemaViewer():
return cdatabases
def readDataBaseHeader(self, path):
index2ParameterNameMap = []
with open(path+"/data.csv") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
# parse header
for row in csv_reader:
i = 0
index2ParameterNameMap = [j for j in range(len(row))]
for value in row:
if value=="FILE":
fileColumnIndex = i
index2ParameterNameMap[i] = value
i+=1
break
return index2ParameterNameMap
cdb = cinemasci.new("cdb", {"path": path})
cdb.read_data_from_file()
return cdb.parameternames
# =====================================================================================
# determines for each column if it contains numeric values
def determineNumericColumns(self, path):
index2isNumeric = []
with open(path+"/data.csv") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
# skip header
for row in csv_reader:
break
# determine type
for row in csv_reader:
for value in row:
try:
valueAsNumber = float(value)
index2isNumeric.append(True)
except ValueError:
index2isNumeric.append(False)
break
return index2isNumeric
cdb = cinemasci.new("cdb", {"path": path})
cdb.read_data_from_file()
return cdb.checkNumericColumns()
# =====================================================================================
# determines the set of possible parameter values for each column
def readParameterValues(self, path, selectedParameters):
cdb = cinemasci.new("cdb", {"path": path})
cdb.read_data_from_file()
index2isNumeric = self.determineNumericColumns(path)
parameterValues = dict()
for i in selectedParameters:
parameterValues[i] = set()
with open(path+"/data.csv") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
# skip header
for row in csv_reader:
break;
# read content
for row in csv_reader:
for i in selectedParameters:
value = row[i]
if index2isNumeric[i]:
value = float(value)
parameterValues[i].add(value)
if index2isNumeric[i]:
parameterValues[i] = cdb.getParameterValues(selectedParameters[i])
return parameterValues
# =====================================================================================
# builds the a map that maps a combination of parameter values to a set of filepaths
def buildParameterKey2FilepathMap(self, path, selectedParameters, selectedFilepaths):
self.parameterKey2filepathMap.clear()
cdb = cinemasci.new("cdb", {"path": path})
cdb.read_data_from_file()
mapping = cdb.getFilepathMap(selectedParameters, selectedFilepaths)
index2isNumeric = self.determineNumericColumns(path)
with open(path+"/data.csv") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
# skip header
for row in csv_reader:
break;
# read content
for row in csv_reader:
filepaths = []
parameterKey = ""
for i in selectedParameters:
value = row[i]
if index2isNumeric[i]:
value = str(float(value))
parameterKey += value+"_"
for i in selectedFilepaths:
filepaths.append(row[i])
if self.parameterKey2filepathMap.get(parameterKey)==None:
self.parameterKey2filepathMap[parameterKey] = []
self.parameterKey2filepathMap[parameterKey] += filepaths
return
for element in mapping:
parameterKey = element[0]
if self.parameterKey2filepathMap.get(parameterKey)==None:
self.parameterKey2filepathMap[parameterKey] = []
self.parameterKey2filepathMap[parameterKey] += element[1]
return
# =====================================================================================
# builds a parameter key based on widget values
......@@ -422,21 +362,21 @@ class CinemaViewer():
display(w)
else:
for i in range(0,len(files)):
self.imageWidgets[i].layout.max_height = str(imgsize)+"px"
self.imageWidgets[i].layout.max_width = str(imgsize)+"px"
if (changeLayout):
if self.layout == CinemaViewer.LayoutVertical:
with self.imagesOutput:
self.imagesOutput.clear_output()
temp = ipywidgets.VBox(self.imageWidgets)
display(temp)
else:
with self.imagesOutput:
self.imagesOutput.clear_output()
temp = ipywidgets.HBox(self.imageWidgets)
display(temp)
for i in range(0,len(files)):
self.imageWidgets[i].layout.max_height = str(imgsize)+"px"
self.imageWidgets[i].layout.max_width = str(imgsize)+"px"
if (changeLayout):
if self.layout == CinemaViewer.LayoutVertical:
with self.imagesOutput:
self.imagesOutput.clear_output()
temp = ipywidgets.VBox(self.imageWidgets)
display(temp)
else:
with self.imagesOutput:
self.imagesOutput.clear_output()
temp = ipywidgets.HBox(self.imageWidgets)
display(temp)
for i in range(0,len(files)):
self.imageWidgets[i].value = files[i]
......
......@@ -20,6 +20,10 @@ def set_install_path():
global CinemaInstallPath
CinemaInstallPath = str(pathlib.Path(__file__).parent.absolute())
# edit the path to get the correct installation path
CinemaInstallPath = CinemaInstallPath.strip("/server")
CinemaInstallPath = "/" + CinemaInstallPath + "/viewers"
print("CinemaInstallPath: {}".format(CinemaInstallPath))
def get_relative_install_path( initpath ):
global CinemaInstallPath
......@@ -37,7 +41,7 @@ def get_relative_install_path( initpath ):
class CinemaRequestHandler(http.server.SimpleHTTPRequestHandler):
def log(self, message):
if False:
if True:
print(message)
def do_GET(self):
......@@ -62,13 +66,13 @@ class CinemaRequestHandler(http.server.SimpleHTTPRequestHandler):
if viewer == "explorer":
# handle a request for the Cinema:Explorer viewer
self.log("EXPLORER")
self.path = get_relative_install_path("/cinema_explorer.html")
self.path = get_relative_install_path("../viewers/cinema_explorer.html")
return http.server.SimpleHTTPRequestHandler.do_GET(self)
elif viewer == "view":
# handle a request for the Cinema:View viewer
self.log("VIEW")
self.path = get_relative_install_path("/cinema_view.html")
self.path = get_relative_install_path("../viewers/cinema_view.html")
return http.server.SimpleHTTPRequestHandler.do_GET(self)
else:
......
......@@ -15,7 +15,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="run a Cinema Viewer")
parser.add_argument("--data", required=True, default=None, help="database to view (required)")
parser.add_argument("--viewer", required=True, default='explorer', help="viewer type to use (required)")
parser.add_argument("--viewer", required=True, default='explorer', help="viewer type to use. One of [explorer, view] (required)")
parser.add_argument("--port", type=int, default=8000, help="port to use (optional)")
parser.add_argument("--assetname", default=None, help="asset name to use (optional)")
args = parser.parse_args()
......
.DS_Store
data/GF-HP.cdb/
data/test.cdb
databases_toIgnore.json
getBuild.sh
copyCSS.sh
test/
# __init__.py file for cinema_viewers
# DO NOT REMOVE THIS FILE
#
# this file is included in the repository so that this repository can
# be included as a submodule of a python module
#
# it does nothing but report the version number
Version = "2.0"
[
{
"name" : "sphere",
"directory" : "data/sphere.cdb"
},
{
"name" : "Sphere Multi-Image",
"directory" : "data/sphere_multi-image.cdb"
},
{
"name" : "Many File Types",
"directory" : "data/file_types.cdb"
},
{
"name" : "Bogus 1",
"directory" : "data/bogus/bogus_1.cdb",
"filter" : "(^FILE)|(5$)",
"query": {
"Float_6" : [20, 70],
"Integer_2": [40, 60]
},
"selection": {
"Integer_3": [20, 50]
}
},
{
"name" : "Bogus 2",
"directory" : "data/bogus/bogus_2.cdb"
},
{
"name" : "Bogus 3",
"directory" : "data/bogus/bogus_3.cdb"
},
{
"name" : "Bogus 4",
"directory" : "data/bogus/bogus_4.cdb"
},
{
"name" : "Big Bogus 1",
"directory" : "data/bogus/big_bogus_1.cdb"
},
{
"name" : "Big Bogus 2",
"directory" : "data/bogus/big_bogus_2.cdb"
},
{
"name" : "Big Bogus 3",
"directory" : "data/bogus/big_bogus_3.cdb"
},
{
"name" : "Big Bogus 4",
"directory" : "data/bogus/big_bogus_4.cdb"
},
{
"name" : "Example Uncertainty Bubbles",
"directory" : "data/uncertainty_bubbles.cdb",
"image_measures" : ["u_min_","u_avg_","u_max_"]
},
{
"name" : "Example Uncertainty Bubbles excluding min and max",
"directory" : "data/uncertainty_bubbles.cdb",
"image_measures" : ["u_avg_"],
"exclude_dimension" : ["u_min_","u_max_"]
}
]
......@@ -39,7 +39,7 @@ var currentDb;
//whether or not the currentDb has extra axis ordering data
var hasAxisOrdering = false;
//this can be overriden with HTTP params
var databaseList = 'cinema/explorer/1.11/databases.json';
var databaseList = 'cinema/explorer/2.0/databases.json';
var databaseListType = 'json';
var loaded = false;
......@@ -122,7 +122,7 @@ if (databaseListType == "json") {
jsonRequest.send(null);
} else {
// if there is a single DB set, pass that on
cinemaDatabases = db_create_explorer_database_list( databaseList )
cinemaDatabases = create_database_list( databaseList )
// JSON.parse(`[ { "name" : "test", "directory" : "${databaseList}" } ]`)
load_databases()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment