### Run Miniconda Installer Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Executes the Miniconda installer script. ```bash ./Miniconda3-latest-Linux-x86_64.sh ``` -------------------------------- ### Install and Run Pylint Source: https://github.com/gitea/cerc/hub/blob/main/hub/CONTRIBUTING_EXTERNALS.md Commands to install the pylint tool and verify Python files against the project's custom style configuration. ```bash pip install pylint pylint --rcfile=pylintrc myfile.py ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/gitea/cerc/hub/blob/main/hub/WINDOWS_INSTALL.md Install all required Python packages listed in the requirements file. ```bash pip install -r .\requirements.txt ``` -------------------------------- ### Download Miniconda Installer Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Downloads the latest Miniconda installer script for Linux. ```bash wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh ``` -------------------------------- ### Make Miniconda Installer Executable Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Sets the execution permission for the downloaded installer script. ```bash chmod +x ./Miniconda3-latest-Linux-x86_64.sh ``` -------------------------------- ### Use Dictionaries for Function and Usage Mappings Source: https://context7.com/gitea/cerc/llms.txt Demonstrates using the Dictionaries helper class to map external building function codes and usage types to Hub's internal system. Shows examples for Montreal, PLUTO, and COMNET mappings. ```python from hub.helpers.dictionaries import Dictionaries # Get dictionary instance d = Dictionaries() # Montreal building functions to Hub functions montreal_map = d.montreal_function_to_hub_function print("Montreal Function Mapping:") for code, hub_func in list(montreal_map.items())[:5]: print(f" {code} -> {hub_func}") # PLUTO (NYC) building functions to Hub functions pluto_map = d.pluto_function_to_hub_function print("\nPLUTO Function Mapping:") for code, hub_func in list(pluto_map.items())[:5]: print(f" {code} -> {hub_func}") # Hub usage to COMNET usage comnet_map = d.hub_usage_to_comnet_usage print("\nHub to COMNET Usage Mapping:") for hub_usage, comnet_usage in list(comnet_map.items())[:5]: print(f" {hub_usage} -> {comnet_usage}") # Hub function to construction function mappings nrel_map = d.hub_function_to_nrel_construction_function canada_map = d.hub_function_to_canada_construction_function # Energy system mappings energy_gen_map = d.montreal_system_to_hub_energy_generation_system fuel_map = d.montreal_custom_fuel_to_hub_fuel # Use in GeometryFactory for automatic function translation from hub.imports.geometry_factory import GeometryFactory city = GeometryFactory( 'geojson', path='./montreal_data.geojson', function_field='CODE_UTILI', function_to_hub=d.montreal_function_to_hub_function ).city ``` -------------------------------- ### Import and Initialize City Model in Python Source: https://github.com/gitea/cerc/hub/blob/main/hub/MACOS_INSTALL.md This snippet demonstrates how to import the GeometryFactory and initialize a city model from a GML file. Ensure all project dependencies are installed before running. ```python from imports.geometry_factory import GeometryFactory city = GeometryFactory('citygml', path='myfile.gml').city ``` -------------------------------- ### Class and Property Documentation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Document all public classes and properties with docstrings. Start comments with capital letters and end without a period. Specify return types for properties. ```python class MyClass """ MyClass class perform models class operations """ def __init__(cls): @property def object_attribute(cls): """ Get my class object attribute :return: int """ return cls._object_attribute ``` -------------------------------- ### Configure CLOCK for Time Series Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Sets up the start and end times, increment, and unit for time series data. Ensure all date and time components are correctly specified. ```config B 167 CLOCK P 167 $StartYear % Start year $StartMonth % Start month $StartDay % Start day $StartHour % Start hour $StartMinute % Start minute $StartSecond % Start second $EndYear % End year $EndMonth % End month $EndDay % End day $EndHour % End hour $EndMinute % End minute $EndSecond % End second 5 % Increment 'm' % Unit ``` -------------------------------- ### Import City Model in PyCharm Source: https://github.com/gitea/cerc/hub/blob/main/hub/WINDOWS_INSTALL.md Use the GeometryFactory to load a city model from a GML file. Ensure the 'hub' module is correctly set up and requirements are installed. ```python from hub.imports import GeometryFactory city = GeometryFactory('citygml', path='myfile.gml').city ``` -------------------------------- ### Load City Geometry and Get Location Info Source: https://context7.com/gitea/cerc/llms.txt Loads city geometry from a GeoJSON file and retrieves location details using coordinates. Ensure the GeoJSON file exists and has a 'height' field. ```python city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city location = GeometryHelper.get_location(45.5017, -73.5673) # Montreal print(f"City: {location.city}") print(f"Country: {location.country}") print(f"Region: {location.region_code}") ``` -------------------------------- ### Method Documentation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Document public methods with docstrings, including a brief description and parameter/return information. Ensure comments are concise and informative. ```python def operation(cls, first_param, second_param): """ Multiplies object_attribute by two :return: int """ return cls.object_attribute * 2 ``` -------------------------------- ### Complete Urban Energy Simulation Pipeline Source: https://context7.com/gitea/cerc/llms.txt Demonstrates a full workflow from data import to energy simulation export, combining multiple Hub components. Ensure all required data files (GeoJSON, EPW) and output directories are set up. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory from hub.imports.energy_systems_factory import EnergySystemsFactory from hub.exports.exports_factory import ExportsFactory from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory from hub.helpers.dictionaries import Dictionaries # Configuration input_file = Path('./data/montreal_block.geojson') output_dir = Path('./output') output_dir.mkdir(exist_ok=True) # Step 1: Import geometry with function mapping print("Loading city geometry...") city = GeometryFactory( 'geojson', path=input_file, height_field='height', year_of_construction_field='year_built', function_field='building_type', function_to_hub=Dictionaries().montreal_function_to_hub_function ).city print(f"Loaded {len(city.buildings)} buildings in {city.name}") # Step 2: Set construction year for buildings missing it for building in city.buildings: if building.year_of_construction is None: building.year_of_construction = 1980 # Step 3: Enrich with construction physics print("Enriching construction parameters...") ConstructionFactory('canada', city).enrich() # Step 4: Enrich with usage patterns print("Enriching usage parameters...") UsageFactory('comnet', city).enrich() # Step 5: Set weather file and enrich print("Loading weather data...") city.climate_file = Path('./weather/CAN_QC_Montreal.epw') WeatherFactory('epw', city).enrich() # Step 6: Assign energy systems print("Assigning energy systems...") EnergySystemsFactory('montreal_custom', city).enrich() # Step 7: Export for visualization print("Exporting geometry...") ExportsFactory('obj', city, output_dir).export() ExportsFactory('geojson', city, output_dir).export() # Step 8: Export for energy simulation print("Exporting to EnergyPlus...") EnergyBuildingsExportsFactory('idf', city, output_dir).export() # Step 9: Generate summary report print("\n=== City Summary ===") print(f"Name: {city.name}") print(f"Region: {city.region_code}") print(f"Total Buildings: {len(city.buildings)}") total_floor_area = sum(b.total_floor_area or 0 for b in city.buildings) print(f"Total Floor Area: {total_floor_area:,0f} m2") # Building type distribution functions = {} for building in city.buildings: func = building.function or 'Unknown' functions[func] = functions.get(func, 0) + 1 print("\nBuilding Types:") for func, count in sorted(functions.items(), key=lambda x: -x[1]): print(f" {func}: {count}") # Save city state for future use city.save(output_dir / 'city_model.pkl') print(f"\nCity model saved to {output_dir / 'city_model.pkl'}") ``` -------------------------------- ### File License Header Template Source: https://github.com/gitea/cerc/hub/blob/main/hub/CONTRIBUTING_EXTERNALS.md Include this header at the top of all new files to specify licensing and contact information. ```python """ Name module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder name mail@concordia.ca """ ``` -------------------------------- ### Module Header and Imports Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Standard module header including license, copyright, and author information, followed by necessary imports. Ensure all imports are used. ```python """ MyClass module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder name name@concordia.ca """ import sys ``` -------------------------------- ### Initialize Conda Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Initializes the conda environment for the current shell. ```bash conda init bash ``` -------------------------------- ### Getter and Setter Documentation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Document getter and setter methods clearly. Getters should indicate the return type, and setters should describe the accepted parameter value. ```python @property def object_attribute(cls): """ Get object attribute :return: int """ return cls._object_attribute @object_attribute.setter def object_attribute(cls, value): """ Set object attribute :param value: int """ cls._object_attribute = value ``` -------------------------------- ### Define the Class Documentation Source: https://github.com/gitea/cerc/hub/blob/main/hub/CONTRIBUTING_CENTRAL_DATA_MODEL.md Provide a brief explanation of the class's purpose and functionality immediately following the module header. ```python """ MyNewDataClass class This class models this and does that """ ``` -------------------------------- ### Write Data to File (WRITE) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Writes data to a specified file with a given mode and format. Ensure the file name variable is correctly defined. ```config B 186 WRITE P 186 2 % Mode 0 % Suppress FNQ inputs $fileOut8 % File name '*' % Fortran format ``` ```config B 187 WRITE P 187 2 % Mode 0 % Suppress FNQ inputs $fileOut5 % File name '*' % Fortran format ``` ```config B 188 WRITE P 188 2 % Mode 0 % Suppress FNQ inputs $fileOut7 % File name '*' % Fortran format ``` ```config B 189 WRITE P 189 2 % Mode 0 % Suppress FNQ inputs $fileOut2 % File name '*' % Fortran format ``` ```config B 190 WRITE P 190 2 % Mode 0 % Suppress FNQ inputs $fileOut4 % File name '*' % Fortran format ``` ```config B 191 WRITE P 191 2 % Mode 0 % Suppress FNQ inputs $fileOut3 % File name '*' % Fortran format ``` ```config B 192 WRITE P 192 2 % Mode 0 % Suppress FNQ inputs $fileOut6 % File name '*' % Fortran format ``` ```config B 193 WRITE P 193 2 % Mode 0 % Suppress FNQ inputs $fileOut1 % File name '*' % Fortran format ``` ```config B 194 WRITE P 194 2 % Mode 0 % Suppress FNQ inputs $fileOut9 % File name '*' % Fortran format ``` ```config B 195 WRITE P 195 2 % Mode 0 % Suppress FNQ inputs $fileOut10 % File name '*' % Fortran format ``` -------------------------------- ### Import and Access Weather Data Source: https://context7.com/gitea/cerc/llms.txt Load weather data from an EPW file using WeatherFactory. This provides hourly climate data like temperature and solar radiation for buildings and their surfaces. Ensure GeometryFactory, ConstructionFactory, and UsageFactory are enriched first. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.imports.weather_factory import WeatherFactory # Load and enrich city city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city for building in city.buildings: building.year_of_construction = 2000 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() # Set climate file path city.climate_file = Path('./weather/montreal.epw') # Enrich with EPW weather data WeatherFactory('epw', city).enrich() # Access weather data on buildings for building in city.buildings: if building.external_temperature: print(f"Building: {building.name}") print(f" External Temp (hourly): {len(building.external_temperature['hour'])} values") print(f" Min Temp: {min(building.external_temperature['hour'])} C") print(f" Max Temp: {max(building.external_temperature['hour'])} C") # Solar radiation on surfaces for surface in building.roofs: if surface.global_irradiance: print(f" Roof {surface.name} annual irradiance: {surface.global_irradiance['year'][0]} Wh/m2") ``` -------------------------------- ### Create SRA Binary Symlink Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Creates a symbolic link for the SRA binary in the system bin directory. ```bash sudo ln -s ~/sra /usr/local/bin/sra ``` -------------------------------- ### Enrich Building Physics with ConstructionFactory Source: https://context7.com/gitea/cerc/llms.txt Enriches buildings with construction physics using specified catalogs. Ensure the city geometry is loaded and building year of construction is set before enrichment. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory # Load city geometry city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city # Set year of construction for archetype matching for building in city.buildings: building.year_of_construction = 2000 # Enrich with NREL construction catalog (US buildings) ConstructionFactory('nrel', city).enrich() # Alternative catalogs: # ConstructionFactory('canada', city).enrich() # Canadian buildings # ConstructionFactory('eilat', city).enrich() # Israeli buildings # ConstructionFactory('palma', city).enrich() # Spanish buildings # ConstructionFactory('tmu', city).enrich() # TMU catalog # Check enrichment results for building in city.buildings: for internal_zone in building.internal_zones: archetype = internal_zone.thermal_archetype if archetype: print(f"Building: {building.name}") print(f" Archetype: {archetype.name}") print(f" Average Storey Height: {archetype.average_storey_height} m") for construction in archetype.constructions: print(f" {construction.type}: U-value = {construction.u_value} W/m2K") ``` -------------------------------- ### Create City Mapping and Access Neighbors Source: https://context7.com/gitea/cerc/llms.txt Creates a city mapping and then iterates through buildings to print their neighbors. This requires the city object to be previously mapped. ```python info = GeometryHelper.city_mapping(city, plot=False) print(f"Mapping Info: {info}") for building in city.buildings: if building.neighbours: print(f"Building {building.name} neighbors:") for neighbor in building.neighbours: print(f" - {neighbor.name}") ``` -------------------------------- ### Create SRA Library Symlink Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Creates a symbolic link for the SRA library in the system lib directory. ```bash sudo ln -s ~/libshortwave.so /usr/local/lib/libshortwave.so ``` -------------------------------- ### Define the Module Header Source: https://github.com/gitea/cerc/hub/blob/main/hub/CONTRIBUTING_CENTRAL_DATA_MODEL.md Include this standard header at the top of every new class file to specify licensing, copyright, and author information. ```python """ My New Data Class module SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Name of Project Coder name.project.coder@concordia.ca """ ``` -------------------------------- ### Access COMNET Usage Catalog Source: https://context7.com/gitea/cerc/llms.txt Accesses the COMNET usage catalog and lists all usage types, including occupancy, lighting, appliances, and thermal control details. Requires importing UsageCatalogFactory. ```python from hub.catalog_factories.usage_catalog_factory import UsageCatalogFactory # Access COMNET usage catalog catalog = UsageCatalogFactory('comnet').catalog # List all usage types print("Usage Types:") for usage in catalog.entries().usages: print(f" {usage.name}") print(f" Hours/Day: {usage.hours_day}") print(f" Days/Year: {usage.days_year}") # Occupancy if usage.occupancy: print(f" Occupancy Density: {usage.occupancy.occupancy_density} p/m2") print(f" Sensible Convective: {usage.occupancy.sensible_convective_internal_gain} W/p") # Lighting if usage.lighting: print(f" Lighting Density: {usage.lighting.density} W/m2") # Appliances if usage.appliances: print(f" Appliances Density: {usage.appliances.density} W/m2") # Thermal control if usage.thermal_control: print(f" Heating Setpoint: {usage.thermal_control.mean_heating_set_point} C") print(f" Cooling Setpoint: {usage.thermal_control.mean_cooling_set_point} C") # Access specific catalog by name # catalog.get_entry('office') -> Usage object # Alternative catalogs nrcan_catalog = UsageCatalogFactory('nrcan').catalog eilat_catalog = UsageCatalogFactory('eilat').catalog palma_catalog = UsageCatalogFactory('palma').catalog ``` -------------------------------- ### Access Montreal Custom Energy Systems Catalog Source: https://context7.com/gitea/cerc/llms.txt Accesses the Montreal custom energy systems catalog and lists system archetypes, including generator details and efficiencies. Requires importing EnergySystemsCatalogFactory. ```python from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCatalogFactory # Access Montreal custom energy systems catalog catalog = EnergySystemsCatalogFactory('montreal_custom').catalog # List system archetypes print("Energy System Archetypes:") for archetype in catalog.entries().archetypes: print(f" {archetype.name}") for system in archetype.systems: print(f" System: {system.name}") print(f" Demand Types: {system.demand_types}") for gen in system.generation_systems: print(f" Generator: {gen.name}") print(f" Type: {gen.system_type}") print(f" Fuel: {gen.fuel_type}") if gen.heat_efficiency: print(f" Heat Efficiency: {gen.heat_efficiency}") # Access generation system details print("\nGeneration Systems:") for gen_system in catalog.entries().generation_equipments: print(f" {gen_system.name}") print(f" Type: {gen_system.system_type}") print(f" Fuel: {gen_system.fuel_type}") # Alternative catalogs montreal_future = EnergySystemsCatalogFactory('montreal_future').catalog palma_catalog = EnergySystemsCatalogFactory('palma').catalog ``` -------------------------------- ### Access Building Properties and Demands Source: https://context7.com/gitea/cerc/llms.txt Iterate through buildings to access basic properties, geometry, surfaces, and calculated energy demands and peak loads. Ensure the city object is loaded first. ```python from hub.imports.geometry_factory import GeometryFactory city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city for building in city.buildings: # Basic properties print(f"Building: {building.name}") print(f" Year of Construction: {building.year_of_construction}") print(f" Function: {building.function}") print(f" Floor Area: {building.floor_area} m2") print(f" Total Floor Area: {building.total_floor_area} m2") print(f" Volume: {building.volume} m3") print(f" Storeys: {building.storeys_above_ground}") print(f" Average Storey Height: {building.average_storey_height} m") print(f" Eave Height: {building.eave_height} m") print(f" Roof Type: {building.roof_type}" ) # 'flat' or 'pitch' print(f" Is Conditioned: {building.is_conditioned}") # Geometry print(f" Walls: {len(building.walls)})") print(f" Roofs: {len(building.roofs)})") print(f" Grounds: {len(building.grounds)})") # Access surfaces for surface in building.surfaces: print(f" Surface: {surface.name}, Type: {surface.type}") print(f" Area: {surface.perimeter_area} m2") print(f" Azimuth: {surface.azimuth} rad") print(f" Inclination: {surface.inclination} rad") # Energy demands (after enrichment and simulation) if building.heating_demand: print(f" Annual Heating Demand: {building.heating_demand['year'][0]} J") if building.cooling_demand: print(f" Annual Cooling Demand: {building.cooling_demand['year'][0]} J") # Peak loads if building.heating_peak_load: print(f" Heating Peak Load: {building.heating_peak_load['year'][0]} W") if building.cooling_peak_load: print(f" Cooling Peak Load: {building.cooling_peak_load['year'][0]} W") ``` -------------------------------- ### Create Conda Environment Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Creates a new conda environment named 'hub' with Python 3.9.16. ```bash conda create --name hub python=3.9.16 ``` -------------------------------- ### Enrich Building Usage Patterns with UsageFactory Source: https://context7.com/gitea/cerc/llms.txt Enriches buildings with occupancy, lighting, appliance, HVAC, and DHW demands. Must be called after ConstructionFactory. Ensure city geometry is loaded and building year of construction is set. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.helpers.dictionaries import Dictionaries # Load and prepare city city = GeometryFactory( 'geojson', path='./buildings.geojson', height_field='height', function_field='usage_type', function_to_hub=Dictionaries().montreal_function_to_hub_function ).city for building in city.buildings: building.year_of_construction = 2005 # Enrich construction first (required before usage) ConstructionFactory('nrel', city).enrich() # Enrich with COMNET usage library (detailed schedules) UsageFactory('comnet', city).enrich() # Alternative catalogs: # UsageFactory('nrcan', city).enrich() # Canadian usage patterns # UsageFactory('eilat', city).enrich() # Israeli usage patterns ``` -------------------------------- ### Configure DELAY Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Sets a delay value. The 'P' line specifies the initial value for the delay. ```config B 164 DELAY P 164 0 % Initial value ``` ```config B 165 DELAY P 165 25 % Initial value ``` -------------------------------- ### View Supported SRS Transformations Source: https://context7.com/gitea/cerc/llms.txt Prints a list of supported Spatial Reference System (SRS) transformations. These transformations are handled automatically by the GeometryHelper. ```python print(f"Supported SRS transformations: {GeometryHelper.srs_transformations}") ``` -------------------------------- ### Access Construction Catalogs Source: https://context7.com/gitea/cerc/llms.txt The ConstructionCatalogFactory provides direct access to construction material and archetype catalogs for querying thermal properties. It supports various catalogs like NREL, Canada, Eilat, Palma, and TMU. ```python from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory # Access NREL construction catalog catalog = ConstructionCatalogFactory('nrel').catalog # Get catalog contents print("Archetypes:") for archetype in catalog.entries().archetypes: print(f" {archetype.name}") print(f" Function: {archetype.function}") print(f" Construction Period: {archetype.construction_period}") for construction in archetype.constructions: print(f" {construction.type}: U={construction.u_value} W/m2K") # Access specific entries print("\nMaterials:") for material in catalog.entries().materials: print(f" {material.name}") print(f" Conductivity: {material.conductivity} W/mK") print(f" Density: {material.density} kg/m3") print(f" Specific Heat: {material.specific_heat} J/kgK") print("\nWindows:") for window in catalog.entries().windows: print(f" {window.name}") print(f" Overall U-value: {window.overall_u_value} W/m2K") print(f" SHGC: {window.g_value}") # Alternative catalogs canada_catalog = ConstructionCatalogFactory('canada').catalog eilat_catalog = ConstructionCatalogFactory('eilat').catalog palma_catalog = ConstructionCatalogFactory('palma').catalog tmu_catalog = ConstructionCatalogFactory('tmu').catalog ``` -------------------------------- ### Perform Inverse (INV) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Calculates the inverse of the input value. The input value is provided on the line following the INV command. ```config B 203 INV 138.1 ``` ```config B 204 INV 212.1 ``` ```config B 205 INV 211.1 ``` -------------------------------- ### Source Bash Configuration Source: https://github.com/gitea/cerc/hub/blob/main/hub/LINUX_INSTALL.md Reloads the .bashrc file to apply changes. ```bash source ~/.bashrc ``` -------------------------------- ### Access Building Usage Data Source: https://context7.com/gitea/cerc/llms.txt Iterate through city, building, and thermal zone data to access and print detailed usage patterns including occupancy, lighting, appliances, and thermal control setpoints. Ensure UsageFactory has been enriched. ```python for building in city.buildings: for internal_zone in building.internal_zones: for thermal_zone in internal_zone.thermal_zones_from_internal_zones: print(f"Building: {building.name}") print(f" Usage: {thermal_zone.usage_name}") print(f" Hours/Day: {thermal_zone.hours_day}") print(f" Days/Year: {thermal_zone.days_year}") # Occupancy occupancy = thermal_zone.occupancy print(f" Occupancy Density: {occupancy.occupancy_density} p/m2") # Lighting lighting = thermal_zone.lighting print(f" Lighting Density: {lighting.density} W/m2") # Appliances appliances = thermal_zone.appliances print(f" Appliances Density: {appliances.density} W/m2") # Thermal control thermal_control = thermal_zone.thermal_control print(f" Heating Setpoint: {thermal_control.mean_heating_set_point} C") print(f" Cooling Setpoint: {thermal_control.mean_cooling_set_point} C") ``` -------------------------------- ### Export City Models for Energy Simulation Source: https://context7.com/gitea/cerc/llms.txt Utilize EnergyBuildingsExportsFactory to export enriched city models to EnergyPlus IDF and INSEL monthly energy balance formats. This factory can automatically download weather data and allows for specifying desired outputs. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory # Complete enrichment pipeline city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city for building in city.buildings: building.year_of_construction = 2000 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() output_path = Path('./simulation') output_path.mkdir(exist_ok=True) # Export to EnergyPlus IDF format idf_export = EnergyBuildingsExportsFactory( 'idf', city, output_path, target_buildings=None # Export all buildings, or specify list ).export() # Export with specific outputs requested outputs = ['Zone Ideal Loads Supply Air Total Heating Energy', 'Zone Ideal Loads Supply Air Total Cooling Energy'] EnergyBuildingsExportsFactory( 'idf', city, output_path, outputs=outputs ).export() # Export to INSEL monthly energy balance EnergyBuildingsExportsFactory( 'insel_monthly_energy_balance', city, output_path, custom_insel_block='d18599' ).export() # Export to CityGML Energy ADE EnergyBuildingsExportsFactory('energy_ade', city, output_path).export() ``` -------------------------------- ### Calculate Maximum Value (MAXX) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Calculates the maximum value from a set of inputs. The specific inputs are listed after the MAXX command. ```config B 166 MAXX 221.1 ``` -------------------------------- ### Method with Type Hinting Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Define methods with type hints for parameters and return values, especially when dealing with complex objects. This enhances clarity and aids static analysis. ```python def new_complex_object(cls, first_param, second_param) -> ComplexObject: other_needed_property = cls.other_needed_property return ComplexObject(first_param, second_param, other_needed_property) ``` -------------------------------- ### Property with Type Hinting Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Use type hints for properties that return complex objects to improve code readability and maintainability. Ensure the return type is clearly specified. ```python @property def complex_object(cls) -> ComplexObject: return cls._object_changeable_attribute ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/gitea/cerc/hub/blob/main/hub/WINDOWS_INSTALL.md Switch to the project-specific environment in the terminal if the base environment is active. ```bash conda activate hub ``` -------------------------------- ### Import City Geometry with GeometryFactory Source: https://context7.com/gitea/cerc/llms.txt Imports urban geometry from GeoJSON, CityGML, or OBJ files using the GeometryFactory. Supports custom field mapping for building properties and function types. Ensure the specified file paths are correct and the format is supported. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.helpers.dictionaries import Dictionaries # Import from GeoJSON with custom field mapping geojson_file = Path('./montreal_buildings.geojson') city = GeometryFactory( 'geojson', path=geojson_file, height_field='building_height', year_of_construction_field='ANNEE_CONS', function_field='CODE_UTILI', aliases_field=['ID_UEV', 'CIVIQUE_DE', 'NOM_RUE'], function_to_hub=Dictionaries().montreal_function_to_hub_function ).city # Import from CityGML citygml_file = Path('./city_model.gml') city = GeometryFactory('citygml', path=citygml_file).city # Import from OBJ obj_file = Path('./building_model.obj') city = GeometryFactory('obj', path=obj_file).city # Access city properties print(f"City: {city.name}") print(f"Location: {city.latitude}, {city.longitude}") print(f"Buildings: {len(city.buildings)}") for building in city.buildings: print(f" - {building.name}: {building.floor_area} m2, {building.volume} m3") ``` ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory # Import from CityGML citygml_file = Path('./city_model.gml') city = GeometryFactory('citygml', path=citygml_file).city ``` ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory # Import from OBJ obj_file = Path('./building_model.obj') city = GeometryFactory('obj', path=obj_file).city ``` ```python # Access city properties print(f"City: {city.name}") print(f"Location: {city.latitude}, {city.longitude}") print(f"Buildings: {len(city.buildings)}") for building in city.buildings: print(f" - {building.name}: {building.floor_area} m2, {building.volume} m3") ``` -------------------------------- ### Assign HVAC and Energy Systems Source: https://context7.com/gitea/cerc/llms.txt Enrich buildings with heating, cooling, and domestic hot water systems using EnergySystemsFactory. This process assigns generation equipment and distribution systems based on regional archetypes. Ensure prerequisite factories are enriched. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.imports.construction_factory import ConstructionFactory from hub.imports.usage_factory import UsageFactory from hub.imports.energy_systems_factory import EnergySystemsFactory # Complete enrichment pipeline city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city for building in city.buildings: building.year_of_construction = 2000 ConstructionFactory('nrel', city).enrich() UsageFactory('comnet', city).enrich() # Enrich with Montreal custom energy systems EnergySystemsFactory('montreal_custom', city).enrich() # Alternative catalogs: # EnergySystemsFactory('north_america', city).enrich() # EnergySystemsFactory('montreal_future', city).enrich() # EnergySystemsFactory('palma', city).enrich() # Access energy system data for building in city.buildings: if building.energy_systems: print(f"Building: {building.name}") for energy_system in building.energy_systems: print(f" Demand Types: {energy_system.demand_types}") for gen_system in energy_system.generation_systems: print(f" Generation: {gen_system.system_type}") print(f" Fuel: {gen_system.fuel_type}") if gen_system.heat_efficiency: print(f" Heat Efficiency: {gen_system.heat_efficiency}") if gen_system.cooling_efficiency: print(f" Cooling Efficiency: {gen_system.cooling_efficiency}") # Calculate energy consumption (after demands are calculated) for building in city.buildings: if building.heating_consumption: print(f" Heating Consumption: {building.heating_consumption['year'][0]} J") if building.cooling_consumption: print(f" Cooling Consumption: {building.cooling_consumption['year'][0]} J") ``` -------------------------------- ### Apply EXPG Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Applies the EXPG function. The operands are listed on the lines following the EXPG command. ```config B 168 EXPG 185.2 23.1 ``` ```config B 169 EXPG 20.1 26.1 ``` -------------------------------- ### Attribute with Units Documentation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md When an attribute has specific units, make this explicit in the method's comment. This provides crucial context for understanding the attribute's value. ```python @property def distance(cls): """ My class distance in meters :return: float """ return cls._distance ``` -------------------------------- ### Create and Manipulate City Data Model Source: https://context7.com/gitea/cerc/llms.txt Initializes a City object with geographic boundaries and SRS, and provides methods for accessing, querying, saving, and merging city data. Ensure the SRS name is valid for your geographic area. ```python from hub.city_model_structure.city import City # Create city from lower/upper corner coordinates and spatial reference system city = City( lower_corner=[299000, 5040000, 0], upper_corner=[300000, 5041000, 100], srs_name='EPSG:32618' # UTM zone 18N ) ``` ```python # Access geographic properties print(f"Country: {city.country_code}") print(f"Region: {city.region_code}") print(f"Climate Reference City: {city.climate_reference_city}") ``` ```python # Get building by name building = city.city_object('building_001') if building: print(f"Found: {building.name}, Function: {building.function}") ``` ```python # Get buildings by alias (e.g., street address) buildings = city.building_alias('123 Main Street') for b in buildings or []: print(f"Building at address: {b.name}") ``` ```python # Extract a circular region from the city center = [299500, 5040500, 50] radius = 200 # meters region = city.region(center, radius) print(f"Buildings in region: {len(region.buildings)}") ``` ```python # Save and load city state city.save('./city_model.pkl') loaded_city = City.load('./city_model.pkl') ``` ```python # Save compressed city.save_compressed('./city_model.pbz2') loaded_city = City.load_compressed('./city_model.pbz2', './temp.pkl') ``` ```python # Merge two cities (keeps building with less radiation in overlaps) merged_city = city.merge(other_city) ``` -------------------------------- ### Apply Attenuation Factor (ATT) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Applies an attenuation factor 'a' to a value. The factor can be a predefined variable like $FuelDensity or a constant. ```config B 206 ATT P 206 $FuelDensity % Attenuation factor a ``` ```config B 207 ATT P 207 1000 % Attenuation factor a ``` ```config B 208 ATT P 208 $FuelDensity % Attenuation factor a ``` ```config B 209 ATT P 209 1000 % Attenuation factor a ``` ```config B 210 ATT P 210 $FuelDensity % Attenuation factor a ``` -------------------------------- ### Read-Write Property Implementation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Implement read-write object attributes using @property and @.setter decorators. This allows controlled access and modification. ```python @property def object_changeable_attribute(cls): return cls._object_changeable_attribute @object_changeable_attribute.setter def object_changeable_attribute(cls, value): cls._object_changeable_attribute = value ``` -------------------------------- ### Perform Greater Than or Equal To (GE) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Compares two values to check if the first is greater than or equal to the second, within a specified error tolerance. ```config B 211 GE 217.1 41.1 P 211 0 % Error tolerance ``` -------------------------------- ### Perform Division (DIV) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Performs a division operation. The operands are specified on separate lines following the DIV command. ```config B 170 DIV 209.1 32.1 ``` ```config B 171 DIV 107.1 17.1 ``` ```config B 172 DIV 107.1 31.1 ``` ```config B 173 DIV 180.1 46.1 ``` ```config B 174 DIV 124.1 107.1 ``` ```config B 175 DIV 44.1 135.1 ``` ```config B 176 DIV 30.1 44.1 ``` ```config B 177 DIV 218.1 105.1 ``` ```config B 178 DIV 163.1 163.2 ``` ```config B 179 DIV 220.1 112.1 ``` ```config B 180 DIV 170.1 21.1 ``` -------------------------------- ### Read-Only Property Implementation Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Implement read-only object attributes using the @property decorator. Encapsulate attribute access to avoid recalculating values. ```python @property def object_attribute(cls): if cls._object_attribute is None: cls._object_attribute = ... ... return cls._object_attribute ``` -------------------------------- ### TODO Comment for Pending Operations Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Use TODO comments to indicate pending operations or missing functionality. This helps track development progress and highlights areas needing future implementation. ```python # todo: right now extracted at the city level, in the future should be extracted also at building level if exist ``` -------------------------------- ### Export City Geometry to Various Formats Source: https://context7.com/gitea/cerc/llms.txt Use ExportsFactory to export city geometry to formats like STL, OBJ, GLB, GeoJSON, SRA XML, and CesiumJS tilesets. You can specify target buildings and control export parameters like the height axis. ```python from pathlib import Path from hub.imports.geometry_factory import GeometryFactory from hub.exports.exports_factory import ExportsFactory # Load city city = GeometryFactory('geojson', path='./buildings.geojson', height_field='height').city output_path = Path('./exports') output_path.mkdir(exist_ok=True) # Export to STL (3D printing, visualization) ExportsFactory('stl', city, output_path).export() # Export to OBJ (3D modeling software) ExportsFactory('obj', city, output_path).export() # Export to GLB (web/game engines) ExportsFactory('glb', city, output_path).export() # Export to GeoJSON (GIS applications) ExportsFactory('geojson', city, output_path).export() # Export to SRA XML for solar radiation analysis ExportsFactory('sra', city, output_path).export() # Export to CesiumJS tileset for web visualization ExportsFactory( 'cesiumjs_tileset', city, output_path, base_uri='https://example.com/tiles/' ).export() # Export specific buildings only target_buildings = [city.city_object('building_1'), city.city_object('building_2')] ExportsFactory('stl', city, output_path, target_buildings=target_buildings).export() # Control height axis for STL export ExportsFactory('stl', city, output_path, height_axis='y').export() # Y-up instead of Z-up ``` -------------------------------- ### Generate GENGT Data Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Generates data using the GENGT function with specified geographical and temporal parameters. The initial random number generator seed is important for reproducibility. ```config B 185 GENGT P 185 45.5 % Latitude 73.62 % Longitude 5 % Time zone 1 % Variance factor of the Gordon Reddy correlation 0 % Year-to-year variability 0.3 % Autocorrelation coefficient lag one 0.171 % Autocorrelation coefficient lag two 4711 % Initialisation of random number generator 2 % Maximum allowed mean temperature deviation 100 % Maximum number of iterations ``` -------------------------------- ### Change Sign (CHS) Source: https://github.com/gitea/cerc/hub/blob/main/hub/data/energy_systems/heat_pumps/as_parallel.txt Negates the input value. This operation is applied to the value following the CHS command. ```config B 196 CHS 59.1 ``` ```config B 197 CHS 68.1 ``` ```config B 198 CHS 53.1 ``` ```config B 199 CHS 36.1 ``` ```config B 200 CHS 179.1 ``` ```config B 201 CHS 62.1 ``` ```config B 202 CHS 177.1 ``` -------------------------------- ### Accessing Object Attributes via Property Source: https://github.com/gitea/cerc/hub/blob/main/hub/PYGUIDE.md Access object attributes through their defined properties rather than directly accessing internal variables. This ensures encapsulation and allows for logic within the getter. ```python @property def object_attribute(cls): return cls._object_attribute def operation(cls, first_param, second_param): return cls.object_attribute * 2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.