Skip to main content

A Python workflow manager for the FutureWeatherGenerator tool.

Project description

pyfwg: Python Future Weather Generator

PyPI version License: MIT Documentation Status

A robust, step-by-step Python workflow manager for the FutureWeatherGenerator command-line tool.

pyfwg provides a safe and intuitive way to automate the morphing of EnergyPlus Weather (EPW) files. It offers two main interfaces:

  • A simple, one-shot function for direct morphing.
  • A powerful MorphingWorkflow class for complex scenarios involving filename parsing, category mapping, and detailed process control.

Key Features

  • Simple and Advanced APIs: Use a single function for quick tasks or a full workflow class for complex projects.
  • Step-by-Step Control: Analyze, preview, configure, and then execute, preventing errors before they happen.
  • Flexible Filename Mapping: Handle both structured (regex-based) and unstructured (keyword-based) filenames with ease.
  • Built-in Validation: Automatically validates all FutureWeatherGenerator parameters before execution to catch typos and invalid values.
  • Clear and Organized Output: Automatically renames and organizes the final .epw and .stat files into a clean directory structure.

Requirements

Before using pyfwg, you need to have the following installed and configured:

  • Python 3.9+
  • Java: The java command must be accessible from your system's terminal (i.e., it must be in your system's PATH).
  • FutureWeatherGenerator: You must download the tool's .jar file. This library has been tested with FutureWeatherGenerator v3.0.0 and v3.0.1.

Installation

You can install pyfwg directly from PyPI:

pip install pyfwg

Quick Start: Simple Morphing

For direct morphing without complex renaming, use the morph_epw function. It provides full control over the FWG tool's parameters in a single call.

from pyfwg import morph_epw

# 1. Define paths
jar_path = r"D:\path\to\your\FutureWeatherGenerator_v3.0.0.jar"
epw_file = 'epws/sevilla_present.epw'

# 2. Run the morphing process
# The generated files will appear in './morphed_epws' by default.
created_files = morph_epw(
    epw_paths=epw_file,
    fwg_jar_path=jar_path,
    fwg_show_tool_output=True, # See the tool's progress
    fwg_gcms=['CanESM5', 'MIROC6'] # Use a specific set of GCMs
)

print("Successfully created files:")
for f in created_files:
    print(f)

Advanced Usage: The MorphingWorkflow Class

For complex projects with custom renaming rules, the MorphingWorkflow class gives you full control over each step.

from pyfwg import MorphingWorkflow

# --- STEP 0: Instantiate the workflow ---
workflow = MorphingWorkflow()

# --- STEP 1: Map categories from source filenames ---
# Use a regex pattern and normalization rules
workflow.map_categories(
    epw_files=['epws/SVQ_uhi-tipo-2.epw'],
    input_filename_pattern=r'(?P<city>.*?)_(?P<uhi_type>.*)',
    keyword_mapping={
        'city': {'seville': ['sevilla', 'svq']},
        'uhi_type': {'type_2': ['uhi-tipo-2']}
    }
)

# --- STEP 2: Define the output and preview the plan ---
workflow.preview_rename_plan(
    final_output_dir='./final_results',
    output_filename_pattern='{city}_{uhi_type}_{ssp}_{year}',
    scenario_mapping={'ssp585': 'SSP5-8.5'}
)

# --- STEP 3: Set and validate the execution configuration ---
workflow.set_morphing_config(
    fwg_jar_path=r"D:\path\to\your\FutureWeatherGenerator_v3.0.0.jar",
    fwg_interpolation_method_id=2, # Override a specific parameter
    fwg_show_tool_output=True
)

# --- STEP 4: Execute the morphing process ---
# This is only called after you are satisfied with the preview and config.
if workflow.is_config_valid:
    workflow.execute_morphing()

Acknowledgements

This library would not be possible without the foundational work of Eugénio Rodrigues (University of Coimbra), the creator of the FutureWeatherGenerator tool. pyfwg is essentially a Python wrapper designed to automate and streamline the use of his powerful command-line application.

License

This project is licensed under the GNU (GPLv3) License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfwg-0.1.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfwg-0.1.0-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfwg-0.1.0.tar.gz.

File metadata

  • Download URL: pyfwg-0.1.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pyfwg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 754ed8b9beafc7a48066ef6a7351726b947ad711832165633f0120c890b1046f
MD5 38df230f62c7dc38ff4b725fb1d523ee
BLAKE2b-256 1a1f00fc512f9ae5389fd9f19bebbaec588dd803ece8433d9e69372b01046329

See more details on using hashes here.

File details

Details for the file pyfwg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyfwg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pyfwg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44855c12066880f27560bc752fd85e2ce1f5387b4db6cbac710ded99cc4b21c5
MD5 3022624847bb4046c9772325ebd4c3da
BLAKE2b-256 dbebc4428180c53c9c2a4ebf80bfc7a660fb99ae3680b7bc5d51b42142f5680d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page