From ddb89d5cab34700a0b9ec9434bd140b930987755 Mon Sep 17 00:00:00 2001 From: Christophe Prud'homme Date: Thu, 23 May 2024 12:32:01 +0200 Subject: [PATCH] start coding add code to read geometry #11 add code to read solar mask data #12 --- .github/workflows/ci.yml | 7 +++++++ README.adoc | 27 ++++++++++++++++++++++++++ pyproject.toml | 13 ++++++++----- requirements.txt | 2 +- src/feelpp/ktirio/hpdaml/read.py | 27 -------------------------- src/feelpp/ktirio/hpdaml/read_case.py | 21 ++++++++++++++++++++ src/notebooks/readEnsightExample.ipynb | 7 +++---- 7 files changed, 67 insertions(+), 37 deletions(-) delete mode 100644 src/feelpp/ktirio/hpdaml/read.py create mode 100644 src/feelpp/ktirio/hpdaml/read_case.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b099e48..759d95d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,13 @@ jobs: env: CXX: clang++ + - + name: Tests + run: | + source .venv/bin/activate + pytest + pytest --nbmake src/notebooks/**/*.ipynb + - name: Upload Artifact uses: actions/upload-artifact@v3 with: diff --git a/README.adoc b/README.adoc index 66a4d20..88602b0 100644 --- a/README.adoc +++ b/README.adoc @@ -6,6 +6,33 @@ ICCS and Cemosis team +== Setup Environment + +To start, you need to install the following tools: + +[.sh] +---- +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +---- + +== Visual Studio Code + +In order to use Visual Studio Code, you need to install the following extensions: + +- Python +- C/C++ +- CMake +- Docker + +Then you can open the project in Visual Studio Code and start coding: + +- open the notebook `src/notebooks/feelpp.ipynb` and run the cells + + + + = {feelpp} Template Project Christophe Prud'homme v2: diff --git a/pyproject.toml b/pyproject.toml index 8edd4c7..84548b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,11 +5,12 @@ build-backend = "scikit_build_core.build" [project] name = "kub-hpda-ml" -version = "3.0.1" -description="Kub Hpda Ml" +version = "0.1.0" +description="KTirio Urban Building HPDA and ML processing" readme = "README.md" authors = [ { name = "Christophe Prud'homme", email = "christophe.prudhomme@cemosis.fr" }, + { name = "Javier Cladellas", email = "javier.Cladellas@cemosis.fr"} ] requires-python = ">=3.7" classifiers = [ @@ -29,7 +30,9 @@ test = ["pytest"] [tool.scikit-build] wheel.expand-macos-universal-tags = true - +wheel.packages = ["src/feelpp/"] +cmake.verbose = true +logging.level = "INFO" [tool.pytest.ini_options] minversion = "6.0" @@ -39,8 +42,8 @@ filterwarnings = [ "error", "ignore:(ast.Str|Attribute s|ast.NameConstant|ast.Num) is deprecated:DeprecationWarning:_pytest", # Python 3.12 ] -# testpaths = ["tests"] - +testpaths = ["tests", "src/notebooks"] +pythonpath = ["src/feelpp"] # [tool.cibuildwheel] # test-command = "pytest {project}/tests" diff --git a/requirements.txt b/requirements.txt index d4e071b..84aff5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,4 @@ scipy pandas tabulate plotly - +. diff --git a/src/feelpp/ktirio/hpdaml/read.py b/src/feelpp/ktirio/hpdaml/read.py deleted file mode 100644 index d360442..0000000 --- a/src/feelpp/ktirio/hpdaml/read.py +++ /dev/null @@ -1,27 +0,0 @@ -import feelpp -from ._laplacian import * -import json - -_laps = { - 'laplacian(2,1)': Laplacian2DP1, - 'laplacian(2,2)': Laplacian2DP2, -} - - -def get(dim=2, order=1, worldComm=None): - """create a Laplacian operator - - """ - if worldComm is None: - worldComm = feelpp.Environment.worldCommPtr() - key = 'laplacian('+str(dim)+','+str(order)+')' - if key not in _laps: - raise RuntimeError('Laplacian'+key+' is not available') - return _laps[key]() - -def loadSpecs(jsonfile): - # Reading the JSON file - with open(jsonfile, 'r') as file: - data = json.load(file) - return data - diff --git a/src/feelpp/ktirio/hpdaml/read_case.py b/src/feelpp/ktirio/hpdaml/read_case.py new file mode 100644 index 0000000..6791fa7 --- /dev/null +++ b/src/feelpp/ktirio/hpdaml/read_case.py @@ -0,0 +1,21 @@ +from vtk import * +import numpy as np + +def read_case(filepath): + """ + Read the Ensight Gold case file and return the reader object + + Parameters + ---------- + filepath : str + The path to the Ensight Gold case file + + Returns + ------- + reader : vtkEnSightGoldBinaryReader + The reader object + """ + reader = vtkEnSightGoldBinaryReader() + reader.SetCaseFileName(filepath) + reader.Update() + return reader diff --git a/src/notebooks/readEnsightExample.ipynb b/src/notebooks/readEnsightExample.ipynb index 5dd684f..4da9dab 100644 --- a/src/notebooks/readEnsightExample.ipynb +++ b/src/notebooks/readEnsightExample.ipynb @@ -8,7 +8,8 @@ "source": [ "import pyvista as pv\n", "from vtk import *\n", - "import numpy as np" + "import numpy as np\n", + "from feelpp.ktirio.hpdaml.read_case import *" ] }, { @@ -21,9 +22,7 @@ "#NOTE: It can be directly fetched from CKAN via its REST API. ( can be slow depending on connection )\n", "filepath = \"./strasbourg_sm_lod1/City_Energy_Modeling.case\"\n", "\n", - "reader = vtkEnSightGoldBinaryReader()\n", - "reader.SetCaseFileName(filepath)\n", - "reader.Update()" + "reader = read_case(filepath)" ] }, {