honeybee-radiance-postprocess 0.4.335__py2.py3-none-any.whl → 0.4.337__py2.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.
@@ -949,3 +949,127 @@ def annual_irradiance_metrics(
949
949
  sys.exit(1)
950
950
  else:
951
951
  sys.exit(0)
952
+
953
+
954
+ @post_process.command('convert-to-binary')
955
+ @click.argument(
956
+ 'input-matrix', type=click.Path(exists=True, file_okay=True, resolve_path=True)
957
+ )
958
+ @click.option(
959
+ '--minimum', type=float, default='-inf', help='Minimum range for values to be '
960
+ 'converted to 1.'
961
+ )
962
+ @click.option(
963
+ '--maximum', type=float, default='+inf', help='Maximum range for values to be '
964
+ 'converted to 1.'
965
+ )
966
+ @click.option(
967
+ '--include-max/--exclude-max', is_flag=True, help='A flag to include the maximum '
968
+ 'threshold itself. By default the threshold value will be included.', default=True
969
+ )
970
+ @click.option(
971
+ '--include-min/--exclude-min', is_flag=True, help='A flag to include the minimum '
972
+ 'threshold itself. By default the threshold value will be included.', default=True
973
+ )
974
+ @click.option(
975
+ '--comply/--reverse', is_flag=True, help='A flag to reverse the selection logic. '
976
+ 'This is useful for cases that you want to all the values outside a certain range '
977
+ 'to be converted to 1. By default the input logic will be used as is.', default=True
978
+ )
979
+ @click.option(
980
+ '--name', '-n', help='Name of output file.', default='binary',
981
+ show_default=True
982
+ )
983
+ @click.option(
984
+ '--output-folder', '-of', help='Output folder.', default='.',
985
+ type=click.Path(exists=False, file_okay=False, dir_okay=True, resolve_path=True)
986
+ )
987
+ def convert_matrix_to_binary(
988
+ input_matrix, minimum, maximum, include_max, include_min, comply, name, output_folder
989
+ ):
990
+ """Postprocess a Radiance matrix and convert it to 0-1 values.
991
+
992
+ \b
993
+ This command is useful for translating Radiance results to outputs like
994
+ sunlight hours. Input matrix must be in ASCII or binary format. The input
995
+ Radiance file must have a header.
996
+
997
+ Args:
998
+ input-matrix: A Radiance matrix file.
999
+ """
1000
+ array = binary_to_array(input_matrix)
1001
+ minimum = float(minimum)
1002
+ maximum = float(maximum)
1003
+ try:
1004
+ if include_max and include_min:
1005
+ boolean_array = (array >= minimum) & (array <= maximum)
1006
+ elif not include_max and not include_min:
1007
+ boolean_array = (array > minimum) & (array < maximum)
1008
+ elif include_max and not include_min:
1009
+ boolean_array = (array > minimum) & (array <= maximum)
1010
+ elif not include_max and include_min:
1011
+ boolean_array = (array >= minimum) & (array < maximum)
1012
+
1013
+ if not comply:
1014
+ # this will invert the boolean array
1015
+ boolean_array = ~boolean_array
1016
+
1017
+ binary_array = boolean_array.astype(int)
1018
+ output_file = Path(output_folder, name)
1019
+ output_file.parent.mkdir(parents=True, exist_ok=True)
1020
+ np.save(output_file, binary_array)
1021
+ except Exception:
1022
+ _logger.exception('Failed to convert the input file to binary format.')
1023
+ sys.exit(1)
1024
+ else:
1025
+ sys.exit(0)
1026
+
1027
+
1028
+ @post_process.command('direct-sun-hours')
1029
+ @click.argument(
1030
+ 'input-matrix', type=click.Path(exists=True, file_okay=True, resolve_path=True)
1031
+ )
1032
+ @click.option(
1033
+ '--divisor', type=float, default=1, help='An optional number, that the summed '
1034
+ 'row will be divided by. For example, this can be a timestep, which can be used '
1035
+ 'to ensure that a summed row of irradiance yields cumulative radiation over '
1036
+ 'the entire time period of the matrix.'
1037
+ )
1038
+ @click.option(
1039
+ '--output-folder', '-of', help='Output folder.', default='.',
1040
+ type=click.Path(exists=False, file_okay=False, dir_okay=True, resolve_path=True)
1041
+ )
1042
+ def direct_sun_hours(
1043
+ input_matrix, divisor, output_folder
1044
+ ):
1045
+ """Postprocess a Radiance matrix to direct sun hours and cumulative direct
1046
+ sun hours.
1047
+
1048
+ \b
1049
+ This command will convert values in the Radiance matrix file to 0-1 values.
1050
+ The output will be a direct sun hours file, and a cumulative direct sun hours
1051
+ file where the values are the summed values for each row.
1052
+
1053
+ Args:
1054
+ input-matrix: A Radiance matrix file.
1055
+ """
1056
+ array = binary_to_array(input_matrix)
1057
+
1058
+ try:
1059
+ boolean_array = (array > 0) & (array <= np.inf)
1060
+
1061
+ direct_sun_hours_array = boolean_array.astype(int)
1062
+ cumulative_array = direct_sun_hours_array.sum(axis=1) / divisor
1063
+
1064
+ direct_sun_hours_file = Path(output_folder, 'direct_sun_hours')
1065
+ direct_sun_hours_file.parent.mkdir(parents=True, exist_ok=True)
1066
+ np.save(direct_sun_hours_file, direct_sun_hours_array)
1067
+
1068
+ cumulative_file = Path(output_folder, 'cumulative')
1069
+ cumulative_file.parent.mkdir(parents=True, exist_ok=True)
1070
+ np.save(cumulative_file, cumulative_array)
1071
+ except Exception:
1072
+ _logger.exception('Failed to convert the input file to direct sun hours.')
1073
+ sys.exit(1)
1074
+ else:
1075
+ sys.exit(0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: honeybee-radiance-postprocess
3
- Version: 0.4.335
3
+ Version: 0.4.337
4
4
  Summary: Postprocessing of Radiance results and matrices
5
5
  Home-page: https://github.com/ladybug-tools/honeybee-radiance-postprocess
6
6
  Author: Ladybug Tools
@@ -13,7 +13,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
13
  Classifier: Operating System :: OS Independent
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: honeybee-radiance (==1.66.27)
16
+ Requires-Dist: honeybee-radiance (==1.66.28)
17
17
  Requires-Dist: numpy (>=1.21.6)
18
18
 
19
19
  [![Build Status](https://github.com/ladybug-tools/honeybee-radiance-postprocess/workflows/CI/badge.svg)](https://github.com/ladybug-tools/honeybee-radiance-postprocess/actions)
@@ -16,7 +16,7 @@ honeybee_radiance_postprocess/cli/__init__.py,sha256=4RkpR91GPXWatDE4I_27ce-N4Fw
16
16
  honeybee_radiance_postprocess/cli/grid.py,sha256=35MwXzL7xRfV5LgDicEEYSyDAZ7Qjlvd-cA3YDA7JAw,8984
17
17
  honeybee_radiance_postprocess/cli/leed.py,sha256=QBR6AMJJWuZ0TevyMi2tXCWMLdS-ZSqtVTZDgqxwa7M,3112
18
18
  honeybee_radiance_postprocess/cli/mtxop.py,sha256=UZJnjNpPjDmShy1-Mxos4H2vTUqk_yP3ZyaC1_LLFeI,5015
19
- honeybee_radiance_postprocess/cli/postprocess.py,sha256=Ypz0RBLNY4N5GpOhzrMjGiAymr-uOA-P3G3F8PGxwUU,34215
19
+ honeybee_radiance_postprocess/cli/postprocess.py,sha256=6lSQuaLEDXRkVXeTdzEgJy5mMQeWrc8K06n9SRUc948,38905
20
20
  honeybee_radiance_postprocess/cli/schedule.py,sha256=6uIy98Co4zm-ZRcELo4Lfx_aN3lNiqPe-BSimXwt1F8,3877
21
21
  honeybee_radiance_postprocess/cli/translate.py,sha256=18zkcGeRZALJ5Z82NEB3XZ-iEX2cHyneobGWV-IXWE0,6789
22
22
  honeybee_radiance_postprocess/cli/two_phase.py,sha256=1nZF4jyZ_C7CAfiHCz1UUOEwDaB4yOXr9ga0HIrhOB0,7033
@@ -25,9 +25,9 @@ honeybee_radiance_postprocess/results/__init__.py,sha256=1agBQbfT4Tf8KqSZzlfKYX8
25
25
  honeybee_radiance_postprocess/results/annual_daylight.py,sha256=o4Y5kbD3a4X4KRfsbOlWzgrnNKU365GcivM6qQGUGXU,31605
26
26
  honeybee_radiance_postprocess/results/annual_irradiance.py,sha256=5zwrr4MNeHUebbSRpSBbscPOZUs2AHmYCQfIIbdYImY,8298
27
27
  honeybee_radiance_postprocess/results/results.py,sha256=t9tr-WHt-XpALIwClLb-xOZcWUZthnvfGED5g3NGDu8,53589
28
- honeybee_radiance_postprocess-0.4.335.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
29
- honeybee_radiance_postprocess-0.4.335.dist-info/METADATA,sha256=H5u9UfHUb-Wd1tAHNU0N4-fUFhONnwNKFMX6jfL-lz4,2228
30
- honeybee_radiance_postprocess-0.4.335.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
31
- honeybee_radiance_postprocess-0.4.335.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
32
- honeybee_radiance_postprocess-0.4.335.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
33
- honeybee_radiance_postprocess-0.4.335.dist-info/RECORD,,
28
+ honeybee_radiance_postprocess-0.4.337.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
29
+ honeybee_radiance_postprocess-0.4.337.dist-info/METADATA,sha256=mRGcxz_CozPU9zfnbk7tw-sTae1y35JtpUzkhwNjZko,2228
30
+ honeybee_radiance_postprocess-0.4.337.dist-info/WHEEL,sha256=unfA4MOaH0icIyIA5oH6E2sn2Hq5zKtLlHsWapZGwes,110
31
+ honeybee_radiance_postprocess-0.4.337.dist-info/entry_points.txt,sha256=gFtVPx6UItXt27GfEZZO00eOZChJJEL6JwGSAB_O3rs,96
32
+ honeybee_radiance_postprocess-0.4.337.dist-info/top_level.txt,sha256=4-sFbzy7ewP2EDqJV3jeFlAFx7SuxtoBBELWaKAnLdA,30
33
+ honeybee_radiance_postprocess-0.4.337.dist-info/RECORD,,