voxcity 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of voxcity might be problematic. Click here for more details.

@@ -147,56 +147,37 @@ def group_and_label_cells(array):
147
147
 
148
148
  def process_grid_optimized(grid_bi, dem_grid):
149
149
  """
150
- Optimized version using numpy's bincount for fast averaging.
151
- This is much faster than iterating through unique IDs.
150
+ Optimized version that computes per-building averages without allocating
151
+ huge arrays when building IDs are large and sparse.
152
152
  """
153
153
  result = dem_grid.copy()
154
-
154
+
155
155
  # Only process if there are non-zero values
156
156
  if np.any(grid_bi != 0):
157
- # Handle float IDs by converting to integers
158
- # First check if we have float values
157
+ # Convert to integer IDs (handle NaN for float arrays)
159
158
  if grid_bi.dtype.kind == 'f':
160
- # Convert to int, handling NaN values
161
159
  grid_bi_int = np.nan_to_num(grid_bi, nan=0).astype(np.int64)
162
160
  else:
163
161
  grid_bi_int = grid_bi.astype(np.int64)
164
-
165
- # Flatten arrays for processing
166
- flat_bi = grid_bi_int.ravel()
162
+
163
+ # Work only on non-zero cells
164
+ flat_ids = grid_bi_int.ravel()
167
165
  flat_dem = dem_grid.ravel()
168
-
169
- # Filter out zero values
170
- mask = flat_bi != 0
171
- ids = flat_bi[mask]
172
- values = flat_dem[mask]
173
-
174
- # Check if we have any valid IDs
175
- if len(ids) > 0:
176
- # Use bincount to sum values for each ID
177
- sums = np.bincount(ids, weights=values)
178
- counts = np.bincount(ids)
179
-
180
- # Avoid division by zero
166
+ nz_mask = flat_ids != 0
167
+ if np.any(nz_mask):
168
+ ids_nz = flat_ids[nz_mask]
169
+ vals_nz = flat_dem[nz_mask]
170
+
171
+ # Densify IDs via inverse indices to avoid np.bincount on large max(id)
172
+ unique_ids, inverse_idx = np.unique(ids_nz, return_inverse=True)
173
+ sums = np.bincount(inverse_idx, weights=vals_nz)
174
+ counts = np.bincount(inverse_idx)
181
175
  counts[counts == 0] = 1
182
-
183
- # Calculate means
184
176
  means = sums / counts
185
-
186
- # Apply means back to result
187
- # Use the integer version for indexing
188
- mask_nonzero = grid_bi_int != 0
189
- # Ensure indices are within bounds
190
- valid_ids = grid_bi_int[mask_nonzero]
191
- valid_mask = valid_ids < len(means)
192
-
193
- # Apply only to valid indices
194
- result_mask = np.zeros_like(mask_nonzero)
195
- result_mask[mask_nonzero] = valid_mask
196
-
197
- # Set values
198
- result[result_mask] = means[grid_bi_int[result_mask]]
199
-
177
+
178
+ # Scatter means back to result for non-zero cells
179
+ result.ravel()[nz_mask] = means[inverse_idx]
180
+
200
181
  return result - np.min(result)
201
182
 
202
183
  def process_grid(grid_bi, dem_grid):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voxcity
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: voxcity is an easy and one-stop tool to output 3d city models for microclimate simulation by integrating multiple geospatial open-data
5
5
  Author-email: Kunihiko Fujiwara <kunihiko@nus.edu.sg>
6
6
  Maintainer-email: Kunihiko Fujiwara <kunihiko@nus.edu.sg>
@@ -1,5 +1,5 @@
1
1
  voxcity/__init__.py,sha256=el9v3gfybHOF_GUYPeSOqN0-vCrTW0eU1mcvi0sEfeU,252
2
- voxcity/generator.py,sha256=mnwlmfFr-23_ZytPSeU-5SpHklO30w5b8NbNOQLemik,54983
2
+ voxcity/generator.py,sha256=9jZuhkcK0yJI347LETUDjd_SsxsMcvbx3DUF-uIyp98,54683
3
3
  voxcity/downloader/__init__.py,sha256=o_T_EU7hZLGyXxX9wVWn1x-OAa3ThGYdnpgB1_2v3AE,151
4
4
  voxcity/downloader/citygml.py,sha256=jVeHCLlJTf7k55OQGX0lZGQAngz_DD2V5TldSqRFlvc,36024
5
5
  voxcity/downloader/eubucco.py,sha256=ln1YNaaOgJfxNfCtVbYaMm775-bUvpAA_LDv60_i22w,17875
@@ -16,7 +16,7 @@ voxcity/exporter/magicavoxel.py,sha256=SfGEgTZRlossKx3Xrv9d3iKSX-HmfQJEL9lZHgWMD
16
16
  voxcity/exporter/obj.py,sha256=h1_aInpemcsu96fSTwjKMqX2VZAFYbZbElWd4M1ogyI,27973
17
17
  voxcity/geoprocessor/__init__.py,sha256=JzPVhhttxBWvaZ0IGX2w7OWL5bCo_TIvpHefWeNXruA,133
18
18
  voxcity/geoprocessor/draw.py,sha256=avXQwbGQWG3ZPPI8mwy0YN0K_aG4NMBdXI0vDg7yad0,35837
19
- voxcity/geoprocessor/grid.py,sha256=uIfEE-2rfT274QKN9qnyXu3E2nCwaUHiuxHra2iclZM,71186
19
+ voxcity/geoprocessor/grid.py,sha256=wrlOsX8cD0W5xCnOS5IOHy8DNqDGTM1I2270eVs787c,70602
20
20
  voxcity/geoprocessor/mesh.py,sha256=-r_3EGL3PZr-QngMOXrwKllYA4o0moDj0-bZvU0mlOo,31237
21
21
  voxcity/geoprocessor/network.py,sha256=YynqR0nq_NUra_cQ3Z_56KxfRia1b6-hIzGCj3QT-wE,25137
22
22
  voxcity/geoprocessor/polygon.py,sha256=DfzXf6R-qoWXEZv1z1aHCVfr-DCuCFw6lieQT5cNHPA,61188
@@ -30,9 +30,9 @@ voxcity/utils/lc.py,sha256=722Gz3lPbgAp0mmTZ-g-QKBbAnbxrcgaYwb1sa7q8Sk,16189
30
30
  voxcity/utils/material.py,sha256=H8K8Lq4wBL6dQtgj7esUW2U6wLCOTeOtelkTDJoRgMo,10007
31
31
  voxcity/utils/visualization.py,sha256=Hk31pVOZ3q8K0QaudAMSqKUquF1Hd1Hug8626D4JJ74,115143
32
32
  voxcity/utils/weather.py,sha256=2Jtg-rIVJcsTtiKE-KuDnhIqS1-MSS16_zFRzj6zmu4,36435
33
- voxcity-0.6.0.dist-info/licenses/AUTHORS.rst,sha256=m82vkI5QokEGdcHof2OxK39lf81w1P58kG9ZNNAKS9U,175
34
- voxcity-0.6.0.dist-info/licenses/LICENSE,sha256=s_jE1Df1nTPL4A_5GCGic5Zwex0CVaPKcAmSilxJPPE,1089
35
- voxcity-0.6.0.dist-info/METADATA,sha256=C-1oyOYd7anMYVqYfTIH_zJWNDqpRL5v5bvcYgsYPkI,26723
36
- voxcity-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- voxcity-0.6.0.dist-info/top_level.txt,sha256=00b2U-LKfDllt6RL1R33MXie5MvxzUFye0NGD96t_8I,8
38
- voxcity-0.6.0.dist-info/RECORD,,
33
+ voxcity-0.6.2.dist-info/licenses/AUTHORS.rst,sha256=m82vkI5QokEGdcHof2OxK39lf81w1P58kG9ZNNAKS9U,175
34
+ voxcity-0.6.2.dist-info/licenses/LICENSE,sha256=s_jE1Df1nTPL4A_5GCGic5Zwex0CVaPKcAmSilxJPPE,1089
35
+ voxcity-0.6.2.dist-info/METADATA,sha256=zbCezoMlL37h_huSEIOhhIa9ax4rlgsJVgeZHhUTQAI,26723
36
+ voxcity-0.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ voxcity-0.6.2.dist-info/top_level.txt,sha256=00b2U-LKfDllt6RL1R33MXie5MvxzUFye0NGD96t_8I,8
38
+ voxcity-0.6.2.dist-info/RECORD,,