Objective:
Design a scalable model and software tool that uses publicly available satellite data (e.g., Sentinel-2, Landsat, or MODIS) to derive the solar reflectance (albedo) of membrane roof systems on large buildings. This reflectance data should then be integrated into a dynamic component simulation model (e.g., WUFI, EnergyPlus, or OpenStudio) to calculate surface temperatures and thermal performance.
Map spectral bands to solar reflectance (e.g., ASTM E1918A for broadband albedo).
Address angular effects (BRDF), seasonal variations, and degradation over time.
Roof Segmentation & Validation:
Techniques to distinguish membrane roofs (e.g., material classification via spectral signatures).
Ground-truth validation (e.g., pairing with field spectroradiometer data or existing databases like CRRC).
Integration with Simulation Models:
Format reflectance outputs for EnergyPlus (e.g., Material:Roofing properties) or WUFI.
Dynamic coupling (e.g., time-resolved albedo for transient simulations).
Tool Architecture:
Modular pipeline (e.g., Python/GEE for satellite processing; PyEnergyPlus/OpenStudio API for simulation).
Scalability (batch processing for cities vs. single buildings).
Output Expectations:
A step-by-step technical workflow diagram.
Recommended libraries/tools (e.g., Google Earth Engine, rasterio, pandas, PySAM).
Strategies to address uncertainties (e.g., shadows, sensor limitations).
Example pseudocode for critical steps (e.g., albedo calculation from Sentinel-2).
Assistant
Scalable Solar Reflectance Model for Membrane Roofs & Building Energy Simulation
This document outlines a comprehensive design for a scalable model and software tool to derive solar reflectance (albedo) of membrane roof systems from publicly available satellite data and integrate it into dynamic building component simulation models.
I. Objective Overview
The primary objective is to create a robust, automated pipeline that leverages satellite imagery to:
Extract Solar Reflectance: Accurately calculate broadband solar reflectance (albedo) for membrane roof surfaces.
Characterize Roof Properties: Distinguish membrane roofs and track their albedo over time, accounting for degradation.
Inform Building Simulations: Provide dynamic, spatially-resolved albedo data to advanced building energy simulation tools (EnergyPlus, WUFI) for more accurate thermal performance calculations.
II. Technical Workflow Diagram
graph TD
A[Satellite Data Acquisition: Sentinel-2, Landsat] --> B{Pre-processing: Atmospheric Correction, Cloud/Shadow Masking, TOA to BOA Reflectance};
B --> C{Building Footprints: OpenStreetMap, Cadastral Data, GIS};
B --> D{Temporal Compositing: Medoid, QA band filtering};
C --> E[Rooftop Isolation: Intersection of Footprints & Spectral Masks];
D --> E;
E --> F[Membrane Roof Segmentation: Spectral Signature Analysis, ML Classification];
F --> G[Albedo Calculation: Broadband Conversion (e.g., Weighted Sum, Regression)];
G --> H{BRDF Correction (Optional but Recommended)};
G --> I[Time Series Analysis: Degradation, Seasonal Variations];
I --> J[Ground-Truth Validation: CRRC, Field Spectroradiometer];
J --> G;
G --> K[Output Formatting for Simulation Models];
K --> L[Integration with EnergyPlus/WUFI/OpenStudio];
L --> M[Dynamic Component Simulation: Surface Temperature, Thermal Performance];
M --> N[Analysis & Reporting];
subgraph Data & Preprocessing
A -- B -- C -- D
end
subgraph Core Processing
E -- F -- G
end
subgraph Refinement & Validation
H -- I -- J
end
subgraph Simulation & Output
K -- L -- M -- N
end
III. Detailed Methodology
A. Data Acquisition & Preprocessing
Optimal Satellite Datasets:
Sentinel-2 (Copernicus):Primary Choice.
Resolution: 10m (Visible, NIR), 20m (Red-edge, SWIR). Excellent for individual building roofs.
Spectral Bands: 13 bands, including Blue, Green, Red, NIR, SWIR (Bands 2, 3, 4, 8, 11, 12 are crucial for albedo and material classification).
Revisit Rate: 5 days (with two satellites, Sentinel-2A/B). Provides good temporal coverage for dynamic analysis.
Availability: Publicly available via Google Earth Engine (GEE), Copernicus Open Access Hub.
Landsat (USGS):
Resolution: 30m (Visible, NIR, SWIR). Useful for historical analysis or larger buildings.
Spectral Bands: Similar to Sentinel-2, but fewer and broader.
Revisit Rate: 16 days.
Availability: GEE, USGS Earth Explorer.
MODIS (NASA):
Resolution: 250m, 500m, 1km. Too coarse for individual building roofs, but valuable for
Broad-scale atmospheric correction parameters.
BRDF models (e.g., MODIS Albedo products MCD43A3 provide white-sky and black-sky albedo at 500m). Can inform BRDF correction for higher-resolution data.
Preprocessing Steps:
Atmospheric Corrections: Essential to convert Top-Of-Atmosphere (TOA) reflectance to Surface Reflectance (Bottom-Of-Atmosphere, BOA).
Sentinel-2: GEE's COPERNICUS/S2_SR collection is already atmospherically corrected (processed by sen2cor). If raw TOA data is used, external tools like sen2cor or radiative transfer models (e.g., 6S) would be needed.
Landsat: GEE's LANDSAT/LC08/C01/T1_SR (Surface Reflectance) is also pre-corrected using LaSRC.
Cloud & Shadow Masking:
Utilize Quality Assurance (QA) bands provided with Sentinel-2 (e.g., QA60 for cirrus, SCL for scene classification) and Landsat (pixel_qa).
GEE provides built-in functions for masking.
Fmask Algorithm: Robust for cloud, cloud shadow, water, and snow masking.
Temporal Compositing:
To reduce noise, fill gaps (due to clouds), and capture typical conditions, composite images over a defined period (e.g., monthly, quarterly, or seasonally).
Medoid Composite: Selects the pixel closest to the multi-dimensional median, minimizing outliers.
Pixel QA Filtering: Only select pixels with high confidence of clear-sky observations.
B. Reflectance Calculation
Rooftop Isolation:
GIS Building Footprints: The most accurate method.
Sources: OpenStreetMap (OSM) via Overpass API, local cadastral data (if available), or derived from high-resolution imagery using object detection (e.g., deep learning models like Mask R-CNN on satellite or aerial imagery).
Spectral Masks (Complementary):
NDVI (Normalized Difference Vegetation Index): Mask out vegetated areas (NDVI < 0.2, or specific thresholds for non-vegetation).
Combine GIS footprints with these masks to refine rooftop boundaries and remove non-roof pixels within the footprint (e.g., courtyards).
Mapping Spectral Bands to Solar Reflectance (Broadband Albedo):
Solar reflectance (albedo) is a broadband property (0.3-2.5 µm). Satellite sensors measure narrow spectral bands.
Method: Use empirical linear regression models or weighted sum approaches, derived from fitting satellite band reflectances to ground-measured broadband albedo.
Example (based on literature for Landsat/Sentinel-2):
Broadband Albedo (α) can be estimated as a weighted sum of individual band reflectances (ρi):
α=wB
For Sentinel-2 (simplified, illustrative weights derived from literature e.g., Liang 2005 for similar bands):α=0.25⋅ρB2+
(Actual weights vary by study and surface type; these are illustrative).
Address Angular Effects (BRDF - Bidirectional Reflectance Distribution Function):
Satellite sensors view surfaces from off-nadir angles, affecting observed reflectance. Albedo is ideally hemispherical reflectance.
Strategies:
Utilize MODIS BRDF Products (MCD43A1/MCD43A3): While coarse resolution, they provide BRDF parameters for various land covers, which can inform corrections or serve as a prior.
Empirical BRDF Models: Apply simple empirical models (e.g., Roujean's model) that use solar and viewing zenith angles, and relative azimuth angle, to normalize reflectance to a nadir-view equivalent or estimate hemispherical albedo.
Multi-temporal Averaging: Averaging multiple observations over time can mitigate some angular effects, especially if observations are from varying angles.
Focus on Nadir/Near-Nadir Observations: Prioritize images with minimal off-nadir viewing angles (low view zenith angle).
Seasonal Variations & Degradation:
Seasonal: Account for changes due to dust, moisture, or surrounding vegetation (though rooftops are generally less affected than ground surfaces). Use seasonal composites.
Degradation: Track albedo changes over multiple years for the same roof. A linear or non-linear decay model (e.g., simple linear degradation, or exponential decay) can be applied. This requires a time-series of clear-sky albedo observations for each roof.
C. Roof Segmentation & Validation
Techniques to Distinguish Membrane Roofs:
Membrane roofs (especially TPO, PVC, EPDM) often exhibit high reflectance across visible and near-infrared bands, particularly white membranes.
Spectral Signature Analysis:
High Reflectance: Look for roofs with consistently high albedo values (e.g., > 0.6) after initial calculation.
Flat Spectral Profile (relative to other materials): White membrane roofs tend to have a relatively flat spectral response in the visible and NIR, differing from asphalt (lower, more absorbing), concrete (distinct signature), or metal (specular effects).
Machine Learning Classification (Supervised):
Training Data: Collect samples of known membrane roofs, asphalt, gravel, vegetated roofs etc., from high-resolution imagery and ground truth.
Features: Use spectral band values (B2, B3, B4, B8, B11, B12), derived indices (e.g., Brightness Index), textural features (e.g., GLCM - Grey Level Co-occurrence Matrix), and contextual information (e.g., shape, size from GIS footprints).
Algorithms: Support Vector Machines (SVM), Random Forests, or Convolutional Neural Networks (CNNs) for pixel- or object-based classification.
Rule-Based Classification: Combine spectral thresholds with GIS data (e.g., "high reflectance + flat roof slope from Lidar data = potential membrane roof").
Ground-Truth Validation:
CRRC (Cool Roof Rating Council) Database: Provides laboratory-measured solar reflectance for many certified cool roof products. Can be used to benchmark derived satellite albedo values for specific roof types if building product information is known.
Field Spectroradiometer Data: The gold standard.
Acquire ground measurements using a spectroradiometer (e.g., ASD FieldSpec) on representative membrane roofs.
These measurements, when convolved with Sentinel-2 spectral response functions, provide accurate broadband albedo for direct comparison with satellite-derived values.
Crucial for calibrating the empirical broadband conversion models.
Visual Inspection/High-Resolution Aerial Imagery: Spot-check classified membrane roofs against very high-resolution imagery (e.g., Google Maps, Nearmap) to identify misclassifications.
D. Integration with Simulation Models
Format Reflectance Outputs for EnergyPlus/WUFI:
EnergyPlus:
Requires Solar Absorptance for Material:Roofing objects (where Solar Absorptance = 1 - Solar Reflectance).
For dynamic simulations, a time-series of solar absorptance can be input using Schedule:File or Schedule:Compact objects, or dynamically through EMS (Energy Management System) via Python API.
Output: For each identified roof segment (e.g., linked to a specific EnergyPlus Surface), provide a CSV or JSON file with building_id, surface_id, date, solar_absorptance.
WUFI:
WUFI typically accepts Solar Radiation Absorption Coefficient directly for material layers.
Similar to EnergyPlus, dynamic input is possible for transient simulations.
Dynamic Coupling (Time-Resolved Albedo):
Time-Series Generation: For each roof, generate a time-series of monthly or seasonal average albedo values, or a representative annual profile if only degradation is considered.
Annual Profile: Derive a "typical year" albedo profile for each roof based on multi-year satellite observations. This accounts for seasonal variations and degradation.
Direct API Integration:
OpenStudio API / PyEnergyPlus: Use the OpenStudio SDK or direct EnergyPlus Input Data File (IDF) manipulation in Python.
Workflow:
Run the satellite processing pipeline to generate the albedo time series for target roofs.
For each building, identify the corresponding roof surfaces in the IDF/OSM file.
Create or modify Material:Roofing objects, assigning the calculated Solar Absorptance values, potentially linked to a Schedule:File for dynamic input.
Modify the EnergyPlus IDF/OSM file programmatically and execute the simulation.
IV. Tool Architecture & Scalability
The tool will adopt a modular, cloud-first architecture to ensure scalability and efficient processing.
Modular Pipeline:
Module 1: Data Ingestion & Preprocessing (Core: Google Earth Engine)
Purpose: Query, filter, cloud mask, and atmospherically correct raw satellite imagery. Perform temporal compositing.
Purpose: Programmatically modify building energy models with derived albedo values and run simulations.
Tools:
openstudio (Python bindings for OpenStudio SDK) for modifying OSM files.
pyenergyplus (if direct IDF modification and EnergyPlus execution is preferred).
jinja2 (for templating IDF files for batch processing).
Output: EnergyPlus simulation results (.eso, .eplusout.sql) with updated roof properties.
Scalability Strategy:
Batch Processing for Cities/Regions:
Google Earth Engine (GEE): GEE is the backbone for large-scale geospatial processing. Its cloud-based, distributed computing capabilities handle petabytes of data efficiently.
GEE Capabilities:
Parallel processing of image collections over large geographical areas.
Built-in functions for atmospheric correction, cloud masking, compositing.
Ability to export results directly to Google Cloud Storage or Drive.
Containerization (Docker/Kubernetes): Package Python modules into Docker containers. Deploy on a cloud platform (e.g., Google Cloud Run, AWS Fargate, Azure Container Instances) for managing batch jobs for multiple cities or large building sets.
Workflow Orchestration: Use tools like Apache Airflow or Prefect to manage the dependencies and execution flow of the modular pipeline across many regions/buildings.
Single Building Processing:
While GEE is still efficient, for a single building, direct API calls and localized processing for roof segmentation and albedo calculation can be done on a standard workstation.
The same Python modules apply, but the ee.ImageCollection might be filtered to a very specific ee.Geometry.Point or ee.Geometry.Polygon representing the building's location.
V. Addressing Uncertainties
Uncertainty Source
Strategy for Mitigation
Clouds & Cloud Shadows
Robust Masking: Aggressive cloud/shadow masking (e.g., Fmask, QA bands, GEE's built-in functions like S2_SR_HARMONIZEDCLOUD_MASK property).Temporal Compositing: Use multi-temporal composites (e.g., medoid, median, percentile) over extended periods (e.g., 3-6 months) to get cloud-free pixels.
Atmospheric Correction
Pre-corrected Data: Utilize GEE's _SR (Surface Reflectance) collections (e.g., COPERNICUS/S2_SR, LANDSAT/LC08/C01/T1_SR) which are processed using validated algorithms (sen2cor, LaSRC).Ground Truth: Calibrate/validate derived albedo against field spectroradiometer data to identify systematic biases.
BRDF Effects
Angle Filtering: Prioritize images with low solar and view zenith angles.Empirical Models: Implement simple BRDF models to normalize observations to nadir. If coarser resolution is acceptable, leverage MODIS BRDF products.Multi-temporal Averaging: Averaging multiple observations from different angles can reduce the impact of individual view geometries.
Sensor Limitations
Spatial Resolution: Use Sentinel-2 (10m) for better roof detail. Acknowledge pixel mixing (spectral unmixing) on very small roofs or edges.Spectral Resolution: Acknowledge that broadband albedo is an estimate from narrow bands. Rely on well-established empirical conversion models.
Shadows (from adjacent structures/self-shadows)
Shadow Masking: Utilize shadow detection algorithms (e.g., based on geometric analysis from building height data or spectral properties).Temporal Compositing: Shadows move with the sun; compositing over time can provide clear-sky, shadow-free pixel values for some areas.
Roof Material Misclassification
Refined Training Data: Use comprehensive and diverse ground-truth samples for supervised classification.Feature Engineering: Incorporate additional features like texture, contextual information, and shape characteristics (from GIS footprints).Post-classification Refinement: Apply morphological operations or rule-based checks to correct common errors (e.g., "very small classified roof patches are likely noise").
Degradation Modeling
Sufficient Time Series: Require a minimum number of clear-sky observations over several years to establish a reliable degradation trend.Adaptive Models: Allow for different degradation models (linear, exponential, non-linear) and validate their fit to observed data.
GIS Building Footprint Accuracy
Data Source Validation: Use reliable, up-to-date sources (e.g., official cadastral data, regularly updated OSM).Buffer/Morphological Operations: Apply slight buffers or erosion/dilation to account for minor inaccuracies in footprint boundaries relative to satellite pixels.
VI. Example Pseudocode for Critical Steps
A. Pseudocode: Broadband Albedo Calculation from Sentinel-2 in GEE
This pseudocode demonstrates a GEE-based approach to calculate albedo for a given area, accounting for pre-processing.
import ee
import numpy as np
# Initialize Earth Engine
ee.Initialize()
# --- Configuration ---
AOI = ee.Geometry.Polygon([ # Example: A small polygon over a building
[[-122.086, 37.422],
[-122.086, 37.423],
[-122.085, 37.423],
[-122.085, 37.422],
[-122.086, 37.422]]
])
START_DATE = '2022-01-01'
END_DATE = '2022-12-31'
# Sentinel-2 Band Names for Albedo Calculation
# B2: Blue, B3: Green, B4: Red, B8: NIR, B11: SWIR1, B12: SWIR2
S2_BANDS = ['B2', 'B3', 'B4', 'B8', 'B11', 'B12']
# Example weights for broadband albedo (illustrative, derive from calibration)
# Based on literature converting Sentinel-2 to broadband albedo (e.g., from MODIS or ground measurements)
# Weights sum to 1.0
ALBEDO_WEIGHTS = {
'B2': 0.25, # Blue
'B3': 0.20, # Green
'B4': 0.20, # Red
'B8': 0.15, # NIR
'B11': 0.10, # SWIR1
'B12': 0.10 # SWIR2
}
# Function to mask clouds and shadows from Sentinel-2 SR data
def maskS2clouds(image):
qa = image.select('QA60') # QA60 contains cloud bits
# Bits 10 and 11 are clouds and cirrus
cloudBitMask = 1 << 10
cirrusBitMask = 1 << 11
# Both flags should be set to zero, indicating clear conditions.
mask = qa.bitwiseAnd(cloudBitMask).eq(0).And(
qa.bitwiseAnd(cirrusBitMask).eq(0))
# Apply SCL (Scene Classification Layer) for more robust masking
scl = image.select('SCL')
# Filter out cloud shadow (3), clouds low prob (7), clouds med prob (8), clouds high prob (9), cirrus (10), snow (11)
# Good pixels are typically 'vegetation' (4), 'not-vegetated' (5), 'water' (6)
clear_sky_mask = scl.neq(3).And(scl.neq(7)).And(scl.neq(8)).And(scl.neq(9)).And(scl.neq(10)).And(scl.neq(11))
return image.updateMask(mask.And(clear_sky_mask)).copyProperties(image, ['system:time_start'])
# Function to calculate broadband albedo for a Sentinel-2 image
def calculateBroadbandAlbedo(image):
# Scale factors for Sentinel-2 surface reflectance (divide by 10000)
scaled_image = image.select(S2_BANDS).divide(10000.0) # Convert to 0-1 range
# Calculate weighted sum
albedo = ee.Image(0).float() # Initialize with zero
for band_name, weight in ALBEDO_WEIGHTS.items():
albedo = albedo.add(scaled_image.select(band_name).multiply(weight))
return image.addBands(albedo.rename('Broadband_Albedo'))
# --- Main Workflow ---
# 1. Load Sentinel-2 Surface Reflectance Collection
s2_collection = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED') \
.filterDate(START_DATE, END_DATE) \
.filterBounds(AOI) \
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20)) # Filter out images with high cloud cover
# 2. Apply Cloud Masking
s2_clean = s2_collection.map(maskS2clouds)
# 3. Calculate Broadband Albedo for each image
s2_albedo_collection = s2_clean.map(calculateBroadbandAlbedo)
# 4. Temporal Compositing (e.g., median over the period)
# This will give a single image for the period, useful for static analysis
median_albedo_image = s2_albedo_collection.select('Broadband_Albedo').median().clip(AOI)
# 5. Extract albedo for specific rooftop polygons (assuming `building_footprints` is an ee.FeatureCollection)
# Example: If you have a FeatureCollection of building footprints:
# building_footprints = ee.FeatureCollection('your/path/to/building_footprints')
# or
# building_footprints = ee.FeatureCollection(AOI) # For this example, just use the AOI as a "building"
# Function to extract mean albedo for each feature
def extract_mean_albedo(feature):
# Get the mean albedo for the feature's geometry
mean_albedo = median_albedo_image.reduceRegion(
reducer=ee.Reducer.mean(),
geometry=feature.geometry(),
scale=10, # Resolution for reduction
maxPixels=1e9
).get('Broadband_Albedo') # Get the named band's value
return feature.set('mean_albedo', mean_albedo)
# Apply reduction to all features (buildings)
# albedo_per_building = building_footprints.map(extract_mean_albedo)
# print(albedo_per_building.getInfo()) # Print results (for small collections)
# For dynamic albedo, process image by image and store results with timestamp
# This would generate a time series for each roof polygon
def process_single_image_for_roofs(image):
# Extract image timestamp
timestamp = image.get('system:time_start')
# Calculate albedo for the image
albedo_image = image.select('Broadband_Albedo')
# Map over building footprints to get mean albedo for each
# This part would typically be handled outside GEE if many roofs and many images
# by exporting the image collection and processing locally using rasterio/geopandas
# For GEE processing large number of features, consider reduceRegions or export
# e.g., export the albedo image and use local tools to extract per-building data
# This approach processes data within GEE efficiently.
# For extracting individual building data for simulation, it's often best to export
# the relevant image (e.g., `s2_albedo_collection` or monthly composites) and process
# the zonal statistics using `rasterio` and `geopandas` locally.
B. Pseudocode: Local Data Extraction & EnergyPlus Integration (Python)
This pseudocode outlines the local processing of GEE-exported data and EnergyPlus IDF modification.
import geopandas as gpd
import rasterio
from rasterio.mask import mask
import pandas as pd
from datetime import datetime
import os
import shutil # For copying IDF
from bs4 import BeautifulSoup # For parsing EnergyPlus IDF XML (if using XML version)
# Or use custom parser/regex for plain IDF
# --- Configuration ---
GEE_EXPORT_DIR = './gee_exported_albedo_rasters/' # Directory where GEE exports TIFs (e.g., monthly)
BUILDING_FOOTPRINTS_PATH = './building_footprints.shp'
ENERGYPLUS_IDF_TEMPLATE = './template_building.idf'
OUTPUT_IDF_DIR = './sim_ready_idfs/'
# Mapping: roof_id (from shapefile) -> EnergyPlus Surface Name
ROOF_MAPPING = {
'roof_123': 'ROOF_SURFACE_SOUTH',
'roof_456': 'ROOF_SURFACE_NORTH',
# ... more mappings
}
# Function to extract zonal statistics (mean albedo) for each roof polygon
def get_roof_albedo(raster_path, building_footprints_gdf):
albedo_data = []
with rasterio.open(raster_path) as src:
# Iterate over each building footprint
for index, row in building_footprints_gdf.iterrows():
roof_id = row['roof_id'] # Assuming 'roof_id' is a column in your shapefile
geometry = [row.geometry.__geo_interface__] # GeoJSON-like dict
try:
# Mask the raster with the polygon geometry
out_image, out_transform = mask(src, geometry, crop=True)
# Calculate mean of valid (non-nan) pixels
mean_albedo = np.nanmean(out_image[out_image != src.nodata])
albedo_data.append({'roof_id': roof_id, 'albedo': mean_albedo})
except Exception as e:
print(f"Error processing {roof_id} in {raster_path}: {e}")
albedo_data.append({'roof_id': roof_id, 'albedo': np.nan})
return pd.DataFrame(albedo_data)
# Function to update EnergyPlus IDF file
def update_idf_solar_absorptance(idf_path, output_idf_path, roof_absorptance_data):
# This is a simplified example. Robust IDF modification often uses OpenStudio SDK.
# For direct IDF, string replacement or a dedicated parser is needed.
# Example: Simple string replacement (NOT ROBUST for complex IDFs!)
# Better: Use OpenStudio SDK or pyenergyplus for structured IDF modification.
with open(idf_path, 'r') as f:
idf_content = f.read()
modified_content = idf_content
for roof_id, avg_absorptance in roof_absorptance_data.items():
ep_surface_name = ROOF_MAPPING.get(roof_id)
if ep_surface_name:
# Find the Material:Roofing object associated with this surface
# This would typically involve finding the material name assigned to the surface,
# then finding the Material:Roofing object with that name.
# For simplicity, assume a direct mapping or a very simple IDF structure.
# Placeholder for the actual material name or unique ID in IDF
# e.g., Material:Roofing, Roof_Material_White_TPO_Default, ...
# This is highly simplified for demonstration:
# It assumes a pattern like "Material:Roofing, <Name>, ..., Solar Absorptance, <VALUE>;"
# A real parser would be much more complex.
# Example using a placeholder in IDF:
# Material:Roofing,
# Roof_TPO_Material, !- Name
# MediumRough, !- Roughness
# 0.019, !- Thickness {m}
# 0.140, !- Conductivity {W/m-K}
# 960.0, !- Density {kg/m3}
# 830.0, !- Specific Heat {J/kg-K}
# <PLACEHOLDER_SOLAR_ABSORPTANCE>, !- Solar Absorptance
# 0.80, !- Thermal Absorptance
# 0.80; !- Visible Absorptance
# Placeholder for the old absorptance value in the template IDF
old_absorptance_str = '<PLACEHOLDER_SOLAR_ABSORPTANCE>'
new_absorptance_str = f"{avg_absorptance:.3f}" # Format to 3 decimal places
# Replace *all* occurrences of the placeholder if it's a generic template,
# or specifically target the relevant material if using a parser.
if old_absorptance_str in modified_content:
modified_content = modified_content.replace(old_absorptance_str, new_absorptance_str)
else:
print(f"Warning: Could not find placeholder for {ep_surface_name} in IDF.")
os.makedirs(os.path.dirname(output_idf_path), exist_ok=True)
with open(output_idf_path, 'w') as f:
f.write(modified_content)
print(f"Updated IDF saved to: {output_idf_path}")
# --- Main Local Workflow ---
if __name__ == "__main__":
# Load building footprints (assuming it has a 'roof_id' column)
building_footprints = gpd.read_file(BUILDING_FOOTPRINTS_PATH)
# Dictionary to store time-series albedo for each roof
all_roof_albedo_series = {}
# Iterate through exported GEE albedo rasters (e.g., monthly albedo images)
# Each raster should ideally have a date in its filename
raster_files = sorted([f for f in os.listdir(GEE_EXPORT_DIR) if f.endswith('.tif')])
for raster_file in raster_files:
raster_path = os.path.join(GEE_EXPORT_DIR, raster_file)
# Extract date from filename (e.g., 'albedo_2022_07_01.tif')
try:
date_str = raster_file.split('_')[-1].replace('.tif', '') # Assumes 'YYYY_MM_DD.tif'
current_date = datetime.strptime(date_str, '%Y_%m_%d').date()
except ValueError:
current_date = None # Fallback if date cannot be parsed
print(f"Processing {raster_file} for {current_date}")
# Get albedo for all roofs in this raster
df_albedo = get_roof_albedo(raster_path, building_footprints)
# Store time-series data
for index, row in df_albedo.iterrows():
roof_id = row['roof_id']
albedo_value = row['albedo']
if roof_id not in all_roof_albedo_series:
all_roof_albedo_series[roof_id] = []
if pd.notna(albedo_value): # Only add if not NaN
all_roof_albedo_series[roof_id].append({'date': current_date, 'albedo': albedo_value})
print("\n--- Albedo Time Series Data (first few entries per roof) ---")
for roof_id, data_list in all_roof_albedo_series.items():
print(f"Roof ID: {roof_id}, Data Points: {len(data_list)}")
# print(data_list[:3]) # Show first 3 entries
# --- Prepare for EnergyPlus Integration ---
# For this simplified example, we'll just use the average albedo over the year for each roof
# For dynamic simulation, you'd create Schedule:File entries.
avg_roof_absorptance = {}
for roof_id, data_list in all_roof_albedo_series.items():
if data_list:
avg_albedo = np.nanmean([d['albedo'] for d in data_list])
avg_absorptance = 1 - avg_albedo
avg_roof_absorptance[roof_id] = avg_absorptance
print(f"Roof ID: {roof_id}, Average Albedo: {avg_albedo:.3f}, Avg Absorptance: {avg_absorptance:.3f}")
else:
print(f"No valid albedo data for Roof ID: {roof_id}")
avg_roof_absorptance[roof_id] = 0.7 # Default if no data
# Update EnergyPlus IDF for each building (assuming one IDF per building)
# In a real scenario, you'd map each roof_id to its specific building's IDF
# Here, we update a single template IDF for demonstration.
output_idf_path = os.path.join(OUTPUT_IDF_DIR, 'sim_building_with_updated_roof.idf')
update_idf_solar_absorptance(ENERGYPLUS_IDF_TEMPLATE, output_idf_path, avg_roof_absorptance)
print("\n--- Simulation Ready! ---")
print("Now run EnergyPlus with the modified IDF file.")
# Example command to run EnergyPlus (requires EnergyPlus installed and in PATH):
# import subprocess
# subprocess.run(['energyplus', '-i', output_idf_path, '-o', 'sim_output'])
⋅
ρBlue+
wG⋅
ρGreen+
wR⋅
ρRed+
wNIR⋅
ρNIR+
wSWIR1⋅
ρSWIR1+
wSWIR2⋅
ρSWIR2
0.20⋅
ρB3+
0.20⋅
ρB4+
0.15⋅
ρB8+
0.10⋅
ρB11+
0.10⋅
ρB12
ASTM E1918A: This standard describes laboratory or field measurements of solar reflectance. While not directly applicable to satellite bands, the principle of weighting spectral data by a standard solar spectrum to derive broadband reflectance is key. Satellite-to-broadband conversion models are calibrated against such ground measurements.