voxcity 0.3.1__tar.gz → 0.3.2__tar.gz

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.

Files changed (50) hide show
  1. {voxcity-0.3.1 → voxcity-0.3.2}/PKG-INFO +1 -1
  2. {voxcity-0.3.1 → voxcity-0.3.2}/pyproject.toml +1 -1
  3. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/sim/solar.py +125 -35
  4. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/sim/view.py +1 -1
  5. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity.egg-info/PKG-INFO +1 -1
  6. {voxcity-0.3.1 → voxcity-0.3.2}/AUTHORS.rst +0 -0
  7. {voxcity-0.3.1 → voxcity-0.3.2}/CONTRIBUTING.rst +0 -0
  8. {voxcity-0.3.1 → voxcity-0.3.2}/HISTORY.rst +0 -0
  9. {voxcity-0.3.1 → voxcity-0.3.2}/LICENSE +0 -0
  10. {voxcity-0.3.1 → voxcity-0.3.2}/MANIFEST.in +0 -0
  11. {voxcity-0.3.1 → voxcity-0.3.2}/README.md +0 -0
  12. {voxcity-0.3.1 → voxcity-0.3.2}/docs/Makefile +0 -0
  13. {voxcity-0.3.1 → voxcity-0.3.2}/docs/archive/README.rst +0 -0
  14. {voxcity-0.3.1 → voxcity-0.3.2}/docs/authors.rst +0 -0
  15. {voxcity-0.3.1 → voxcity-0.3.2}/docs/conf.py +0 -0
  16. {voxcity-0.3.1 → voxcity-0.3.2}/docs/index.rst +0 -0
  17. {voxcity-0.3.1 → voxcity-0.3.2}/docs/make.bat +0 -0
  18. {voxcity-0.3.1 → voxcity-0.3.2}/setup.cfg +0 -0
  19. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/__init__.py +0 -0
  20. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/__init__.py +0 -0
  21. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/eubucco.py +0 -0
  22. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/gee.py +0 -0
  23. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/mbfp.py +0 -0
  24. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/oemj.py +0 -0
  25. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/omt.py +0 -0
  26. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/osm.py +0 -0
  27. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/overture.py +0 -0
  28. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/download/utils.py +0 -0
  29. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/file/__init_.py +0 -0
  30. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/file/envimet.py +0 -0
  31. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/file/geojson.py +0 -0
  32. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/file/magicavoxel.py +0 -0
  33. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/file/obj.py +0 -0
  34. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/geo/__init_.py +0 -0
  35. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/geo/draw.py +0 -0
  36. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/geo/grid.py +0 -0
  37. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/geo/utils.py +0 -0
  38. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/sim/__init_.py +0 -0
  39. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/sim/utils.py +0 -0
  40. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/utils/__init_.py +0 -0
  41. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/utils/lc.py +0 -0
  42. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/utils/visualization.py +0 -0
  43. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/utils/weather.py +0 -0
  44. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity/voxcity.py +0 -0
  45. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity.egg-info/SOURCES.txt +0 -0
  46. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity.egg-info/dependency_links.txt +0 -0
  47. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity.egg-info/requires.txt +0 -0
  48. {voxcity-0.3.1 → voxcity-0.3.2}/src/voxcity.egg-info/top_level.txt +0 -0
  49. {voxcity-0.3.1 → voxcity-0.3.2}/tests/__init__.py +0 -0
  50. {voxcity-0.3.1 → voxcity-0.3.2}/tests/voxelcity.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: voxcity
3
- Version: 0.3.1
3
+ Version: 0.3.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,6 +1,6 @@
1
1
  [project]
2
2
  name = "voxcity"
3
- version = "0.3.1"
3
+ version = "0.3.2"
4
4
  requires-python = ">=3.10,<3.13"
5
5
  classifiers = [
6
6
  "Programming Language :: Python :: 3.10",
@@ -303,8 +303,7 @@ def get_solar_positions_astral(times, lat, lon):
303
303
  def get_cumulative_global_solar_irradiance(
304
304
  voxel_data,
305
305
  meshsize,
306
- start_time,
307
- end_time,
306
+ df, lat, lon, tz,
308
307
  direct_normal_irradiance_scaling=1.0,
309
308
  diffuse_irradiance_scaling=1.0,
310
309
  **kwargs
@@ -334,39 +333,9 @@ def get_cumulative_global_solar_irradiance(
334
333
  """
335
334
  view_point_height = kwargs.get("view_point_height", 1.5)
336
335
  colormap = kwargs.get("colormap", 'magma')
336
+ start_time = kwargs.get("start_time", "01-01 05:00:00")
337
+ end_time = kwargs.get("end_time", "01-01 20:00:00")
337
338
 
338
- # Get EPW file
339
- download_nearest_epw = kwargs.get("download_nearest_epw", False)
340
- rectangle_vertices = kwargs.get("rectangle_vertices", None)
341
- epw_file_path = kwargs.get("epw_file_path", None)
342
- if download_nearest_epw:
343
- if rectangle_vertices is None:
344
- print("rectangle_vertices is required to download nearest EPW file")
345
- return None
346
- else:
347
- # Calculate center point of rectangle
348
- lats = [coord[0] for coord in rectangle_vertices]
349
- lons = [coord[1] for coord in rectangle_vertices]
350
- center_lat = (min(lats) + max(lats)) / 2
351
- center_lon = (min(lons) + max(lons)) / 2
352
- target_point = (center_lat, center_lon)
353
-
354
- # Optional: specify maximum distance in kilometers
355
- max_distance = 100 # None for no limit
356
-
357
- output_dir = kwargs.get("output_dir", "output")
358
-
359
- epw_file_path, weather_data, metadata = get_nearest_epw_from_climate_onebuilding(
360
- latitude=center_lat,
361
- longitude=center_lon,
362
- output_dir=output_dir,
363
- max_distance=max_distance,
364
- extract_zip=True,
365
- load_data=True
366
- )
367
-
368
- # Read EPW data
369
- df, lat, lon, tz, elevation_m = read_epw_for_solar_simulation(epw_file_path)
370
339
  if df.empty:
371
340
  raise ValueError("No data in EPW file.")
372
341
 
@@ -526,4 +495,125 @@ def get_cumulative_global_solar_irradiance(
526
495
  vmax=vmax
527
496
  )
528
497
 
529
- return cumulative_map
498
+ return cumulative_map
499
+
500
+ def get_global_solar_irradiance_using_epw(
501
+ voxel_data,
502
+ meshsize,
503
+ calc_type='instantaneous',
504
+ direct_normal_irradiance_scaling=1.0,
505
+ diffuse_irradiance_scaling=1.0,
506
+ **kwargs
507
+ ):
508
+ """
509
+ Compute cumulative global solar irradiance over a specified period using data from an EPW file,
510
+ accounting for tree transmittance.
511
+
512
+ voxel_data, # 3D voxel grid representing the urban environment
513
+ meshsize, # Size of each grid cell in meters
514
+ azimuth_degrees, # Sun's azimuth angle
515
+ elevation_degrees, # Sun's elevation angle
516
+ direct_normal_irradiance, # Direct Normal Irradiance value
517
+ diffuse_irradiance, # Diffuse irradiance value
518
+ show_plot=True, # Display visualization of results
519
+ **kwargs
520
+ )
521
+ if type == 'cummulative':
522
+ - tree_lad (float): Leaf area density in m^-1 (default: 1.0)
523
+ - download_nearest_epw (bool): Whether to download nearest EPW file
524
+ - epw_file_path (str): Path to EPW file
525
+ - show_plot (bool): Whether to show final plot
526
+ - show_each_timestep (bool): Whether to show plots for each timestep
527
+
528
+ Returns:
529
+ ndarray: 2D array of cumulative global solar irradiance (W/m²·hour).
530
+ """
531
+ view_point_height = kwargs.get("view_point_height", 1.5)
532
+ colormap = kwargs.get("colormap", 'magma')
533
+
534
+ # Get EPW file
535
+ download_nearest_epw = kwargs.get("download_nearest_epw", False)
536
+ rectangle_vertices = kwargs.get("rectangle_vertices", None)
537
+ epw_file_path = kwargs.get("epw_file_path", None)
538
+ if download_nearest_epw:
539
+ if rectangle_vertices is None:
540
+ print("rectangle_vertices is required to download nearest EPW file")
541
+ return None
542
+ else:
543
+ # Calculate center point of rectangle
544
+ lats = [coord[0] for coord in rectangle_vertices]
545
+ lons = [coord[1] for coord in rectangle_vertices]
546
+ center_lat = (min(lats) + max(lats)) / 2
547
+ center_lon = (min(lons) + max(lons)) / 2
548
+ target_point = (center_lat, center_lon)
549
+
550
+ # Optional: specify maximum distance in kilometers
551
+ max_distance = 100 # None for no limit
552
+
553
+ output_dir = kwargs.get("output_dir", "output")
554
+
555
+ epw_file_path, weather_data, metadata = get_nearest_epw_from_climate_onebuilding(
556
+ latitude=center_lat,
557
+ longitude=center_lon,
558
+ output_dir=output_dir,
559
+ max_distance=max_distance,
560
+ extract_zip=True,
561
+ load_data=True
562
+ )
563
+
564
+ # Read EPW data
565
+ df, lat, lon, tz, elevation_m = read_epw_for_solar_simulation(epw_file_path)
566
+ if df.empty:
567
+ raise ValueError("No data in EPW file.")
568
+
569
+ if calc_type == 'instantaneous':
570
+ if df.empty:
571
+ raise ValueError("No data in EPW file.")
572
+
573
+ calc_time = kwargs.get("calc_time", "01-01 12:00:00")
574
+
575
+ # Parse start and end times without year
576
+ try:
577
+ calc_dt = datetime.strptime(calc_time, "%m-%d %H:%M:%S")
578
+ except ValueError as ve:
579
+ raise ValueError("calc_time must be in format 'MM-DD HH:MM:SS'") from ve
580
+
581
+ df_period = df[
582
+ (df.index.month == calc_dt.month) & (df.index.day == calc_dt.day) & (df.index.hour == calc_dt.hour)
583
+ ]
584
+
585
+ if df_period.empty:
586
+ raise ValueError("No EPW data at the specified time.")
587
+
588
+ # Prepare timezone conversion
589
+ offset_minutes = int(tz * 60)
590
+ local_tz = pytz.FixedOffset(offset_minutes)
591
+ df_period_local = df_period.copy()
592
+ df_period_local.index = df_period_local.index.tz_localize(local_tz)
593
+ df_period_utc = df_period_local.tz_convert(pytz.UTC)
594
+
595
+ # Compute solar positions
596
+ solar_positions = get_solar_positions_astral(df_period_utc.index, lat, lon)
597
+ direct_normal_irradiance = df_period_utc.iloc[0]['DNI']
598
+ diffuse_irradiance = df_period_utc.iloc[0]['DHI']
599
+ azimuth_degrees = solar_positions.iloc[0]['azimuth']
600
+ elevation_degrees = solar_positions.iloc[0]['elevation']
601
+ solar_map = get_global_solar_irradiance_map(
602
+ voxel_data, # 3D voxel grid representing the urban environment
603
+ meshsize, # Size of each grid cell in meters
604
+ azimuth_degrees, # Sun's azimuth angle
605
+ elevation_degrees, # Sun's elevation angle
606
+ direct_normal_irradiance, # Direct Normal Irradiance value
607
+ diffuse_irradiance, # Diffuse irradiance value
608
+ show_plot=True, # Display visualization of results
609
+ **kwargs
610
+ )
611
+ if calc_type == 'cumulative':
612
+ solar_map = get_cumulative_global_solar_irradiance(
613
+ voxel_data,
614
+ meshsize,
615
+ df, lat, lon, tz,
616
+ **kwargs
617
+ )
618
+
619
+ return solar_map
@@ -189,7 +189,7 @@ def compute_vi_map_generic(voxel_data, ray_directions, view_height_voxel, hit_va
189
189
  found_observer = False
190
190
  for z in range(1, nz):
191
191
  if voxel_data[x, y, z] in (0, -2) and voxel_data[x, y, z - 1] not in (0, -2):
192
- if voxel_data[x, y, z - 1] in (-3, -2):
192
+ if (voxel_data[x, y, z - 1] in (7, 8, 9)) or (voxel_data[x, y, z - 1] < 0):
193
193
  vi_map[x, y] = np.nan
194
194
  found_observer = True
195
195
  break
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: voxcity
3
- Version: 0.3.1
3
+ Version: 0.3.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>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes