🔤
Advanced Berkeley Comfort (ABC) model
  • Advanced Berkeley Comfort (ABC) model
  • DOCUMENTATION
    • What is the ABC model?
      • Thermal phygiology model
      • Thermal comfort model
    • Input and output
      • Input parameters
      • Output parameters
    • ABC Model API
      • Example code in Python
      • Example code in R
    • Web interface
      • Edit input data
      • File import and export
      • Advanced settings
    • Excel interface
  • HELP & FAQs
    • FAQs
    • Questions / Help / Discussion
  • References
    • List of references
    • Past presentation
    • Useful tools
  • Changelog
    • Changelog
Powered by GitBook
On this page

Was this helpful?

  1. DOCUMENTATION
  2. ABC Model API

Example code in Python

Description about how to use ABC model API with Python

PreviousABC Model APINextExample code in R

Last updated 4 months ago

Was this helpful?

We provide abc_model_api_toolkit to easily use ABC model API and also give you an example Python script using this toolkit.

For more details, visit the and review the README file.

Installation

!git clone https://github.com/CenterForTheBuiltEnvironment/ABC_toolbox.git

Discrepancies

  • Python 3

  • Standard libraries:

    • json: Utilized for parsing JSON data.

  • requests: Used for making HTTP requests to the API.

Example code in a Python file (.py):

abc_model_api_toolkit GitHub repository
https://github.com/CenterForTheBuiltEnvironment/ABC_toolbox/blob/main/abc_model_api_toolkit/example/example.py
import os
from abc_model_api_toolkit.api_client import get_abc_model_api_results
from abc_model_api_toolkit.data_processor import output_json_to_csv


API_URL = "https://backend-384255928646.us-west1.run.app/abc"

# Set up file paths (Change these file path as you want)
current_dir = os.path.dirname(os.path.abspath(__file__))
input_json_file_path = os.path.join(current_dir, "example_input.json")
output_json_file_path = os.path.join(current_dir, "example_output.json")
output_csv_file_path = os.path.join(current_dir, "example_output.csv")

results = get_abc_model_api_results(input_file=input_json_file_path, output_file=output_json_file_path, api_url=API_URL)
output_json_to_csv(output_json_file_path=results, csv_file_path=output_csv_file_path)

# Check CSV data
import pandas as pd
example_csv = pd.read_csv(output_csv_file_path)
print(example_csv)