Skip to content

Commit

Permalink
Parse building and face IDs #30
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierCladellas committed Oct 1, 2024
1 parent bd6ca0e commit 788b501
Showing 1 changed file with 75 additions and 4 deletions.
79 changes: 75 additions & 4 deletions src/notebooks/reader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"\n",
"# Setup the reader\n",
"# We suppose that the necessary files are in the same directory as the notebook\n",
"case_file = \"strasbourg_sm_lod1/City_Energy_Modeling.case\"\n",
"case_file = \"strasbourg_sm_lod1/exports/City_Energy_Modeling.case\"\n",
"# Setup the reader\n",
"reader = vtk.vtkEnSightGoldBinaryReader()\n",
"reader.SetCaseFileName(case_file)\n",
Expand All @@ -57,6 +57,59 @@
"print(\"Number of scalar points?: \", reader.GetOutput().GetBlock(0).GetCellData().GetArray(\"solar_shading_coeff\").GetNumberOfTuples())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "837d2acc",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd8125e0",
"metadata": {},
"outputs": [],
"source": [
"id_reader = vtk.vtkEnSightGoldBinaryReader()\n",
"id_reader.SetCaseFileName(\"strasbourg_sm_lod1/export_ids/City_Energy_Modeling.case\")\n",
"id_reader.ReadAllVariablesOn()\n",
"id_reader.Update()\n",
"\n",
"id_reader.SetTimeValue(id_reader.GetTimeSets().GetItem(0).GetValue(0))\n",
"id_reader.Update()\n",
"output = id_reader.GetOutput().GetBlock(0)\n",
"cell_data = output.GetCellData()\n",
"building_ids = cell_data.GetArray(\"building_id\")\n",
"building_element_ids = cell_data.GetArray(\"building_element_id\")\n",
"\n",
"bids = []\n",
"beids = []\n",
"\n",
"for i in range(output.GetNumberOfCells()):\n",
" bid_part1, bid_part2, bid_part3 = building_ids.GetTuple(i)\n",
" bid_part1 = np.int64(bid_part1)\n",
" bid_part2 = np.int64(bid_part2) << 22\n",
" bid_part3 = np.int64(bid_part3) << 44\n",
" bids.append(bid_part1+bid_part2+bid_part3)\n",
"\n",
" beids.append(int(building_element_ids.GetTuple(i)[0]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4520ecd8",
"metadata": {},
"outputs": [],
"source": [
"print(f\"# Building IDs : {np.unique(bids).shape[0]}\")\n",
"print(f\"# Unique building face ids : {np.unique(beids).shape[0]} -- from {min(beids)} to {max(beids)}\")"
]
},
{
"cell_type": "markdown",
"id": "15d2113f",
Expand Down Expand Up @@ -122,9 +175,27 @@
" gis = json.load(f)\n",
"\n",
"reference_coordinates = gis[\"referenceCoordinates\"]\n",
"print(\"Reference coordinates: \", reference_coordinates)\n",
"\n",
"del gis"
"print(\"Reference coordinates: \", reference_coordinates)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c4ef203",
"metadata": {},
"outputs": [],
"source": [
"true_ids = np.array([building[\"id\"] for building in gis[\"building\"]])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1452221e",
"metadata": {},
"outputs": [],
"source": [
"len(np.setdiff1d(np.unique(bids),true_ids)), len(np.setdiff1d(true_ids,np.unique(bids)))"
]
},
{
Expand Down

0 comments on commit 788b501

Please sign in to comment.