Git Product home page Git Product logo

sumo2gral's Introduction

SUMO2GRAL (S2G) License: MIT

S2G is a project aimed at simplifying the process of estimating pollutant concentrations in urban areas by automating the preparation of necessary files for simulation in GRAL (Graz Lagrangian Model). By providing geographic area specifications, SUMO (Simulation of Urban MObility) emissions files, and weather data for the desired area, users can effortlessly generate the required files for conducting GRAL simulations. The weather data format aligns with the format provided by the monitor stations of Valencian Environmental Agency.

Features

  • Automated Data Processing: Simplifies the preparation of input files for GRAL by automatically processing building, weather, highway, and map data.
  • Georeferenced Map Generation: Creates georeferenced maps based on specified geographic bounds.
  • Shapefile Generation: Generates shapefiles for buildings and highways which are essential for GRAL simulations.
  • Weather Data Processing: Processes weather data to match the requirements of GRAL simulations.
  • GRAL Files Generation: Automates the creation of required GRAL simulation files through a dedicated module.
  • GRAL Simulation: Executes the GRAL simulation and outputs the reuslts in a .txt file.

Prerequisites

You must have installed the Dotnet >= 6.0 SDK installed. Please visit the Windows .NET 8.0 downloading page.

If you are a Linux user you can simply do:

sudo apt-get install -y dotnet-sdk-8.0

Dependencies

  • pandas
  • osmnx
  • sumolib
  • numpy
  • geopandas
  • cartopy
  • pyproj
  • osmium

Setup

Clone the repository:

git clone https://github.com/seniel98/SUMO2GRAL.git
cd SUMO2GRAL

Install the required dependencies:

pip install -r requirements.txt

Usage

Run the command line interface (CLI) script with the desired arguments to process the data and generate the required files:

Offline mode (default):

  • Parameters mode

    python cli.py --base-directory /path/to/base/directory --process all --osm-file /path/to/osm/file/file.osm  --net-file /path/to/net/file/file.net.xml --emissions-file /path/to/edge/emissions/file/edges-emissions-file.xml --gral-dll /path/to/gral/dll/file/GRAL.dll
  • Configuration file mode (here you can take a look at the structure of the config file)

    python cli.py -c configuration.sumo2gral.cfg --process all

Online mode (This is in case you want to retrieve the data using the osmnx library):

python cli.py --base-directory /path/to/base/directory --north 39.49 --south 39.47 --east -0.37 --west -0.39 --process all  --net-file /path/to/net/file/file.net.xml --emissions-file /path/to/edge/emissions/file/edges-emissions-file.xml --online --gral-dll /path/to/gral/dll/file/GRAL.dll

Documentation

Modules

CLI Arguments

  • --base-directory: The base directory for the project.
  • --north, --south, --east, --west: The coordinates of the bounding box. (Default: None)
  • --epsg: The EPSG code for the coordinate system to reproject the map to. (Must be different than EPSG:4326. This is because GRAL does not support EPSG:4326.) (Default:EPSG:3857)
  • --process: Specify the process to run. Choices are: all, map, buildings, weather, highway, gral. (All does not include map, since the GRAL GUI is not used.)
  • --online: Specify if the data is to be retrieved using the osmnx library. (Default: False)
  • --map-name: The name of the map file to be saved.
  • --buildings-shp-file: The name of the shapefile to be saved.
  • --highways-shp-file: The name of the shapefile to be saved.
  • --net-file: The name of the SUMO network file.
  • --emissions-file: The name of the SUMO emissions file.
  • --weather-file: The name of the weather data file.
  • --weather-day: The day of the weather data to extract, format (dd.mm.yyyy).
  • --weather-hour: The hour of the weather data to extract, format (hh:mm).
  • --met-file: The name of the met file. (Default: weather.met)
  • --gral-dll: The name of the GRAL dll file. (Required for GRAL simulations)
  • --pollutant: The pollutant to be simulated. (Default: NOx)
  • --hor-layers: The horizontal layers to be simulated (m.). (Default: 3,6,9)
  • --particles-ps: The number of particles per second. (Default: 100)
  • --dispertion-time: The dispertion time (s.). (Default: 3600)
  • --n-cores: The number of CPU cores used for the simulation (Default: 4)
  • --osm-file: The name of the OSM file.

Examples

  • Generate a georeferenced map from the OSM file:
python cli.py --base-directory /path/to/base/directory  --process map --osm-file /path/to/osm/file/file.osm 
  • Generate shapefile for buildings:

    • Retrieve data using the osmnx library

      python cli.py --base-directory /path/to/base/directory --north 39.49 --south 39.47 --east -0.37 --west -0.39 --process buildings --online
    • Retrieve data using the local OSM file

      python cli.py --base-directory /path/to/base/directory --process buildings --osm-file /path/to/osm/file/file.osm
  • Generate shapefile for line emission sources:

    • Retrieve data using the osmnx library

      python cli.py --base-directory /path/to/base/directory --north 39.50154 --south 39.4235 --east -0.30981 --west -0.44166 --process highway --net-file /path/to/net/file/file.net.xml --emissions-file /path/to/edge/emissions/file/edges-emissions-file.xml --online
    • Retrieve data using the local OSM file

      python cli.py --base-directory /path/to/base/directory --north 39.50154 --south 39.4235 --east -0.30981 --west -0.44166 --process highway --net-file /path/to/net/file/file.net.xml --emissions-file /path/to/edge/emissions/file/edges-emissions-file.xml --osm-file /path/to/osm/file/file.osm
  • Generate the GRAL inputs and execute the simulation:

    • Without inputting the osm file

      python cli.py --base-directory /path/to/base/directory --north 39.50154 --south 39.4235 --east -0.30981 --west -0.44166 --process gral --met-file /path/to/met/file/metfile.met --online --gral-dll /path/to/gral/dll/file/GRAL.dll
    • Inputting the osm file

      python cli.py --base-directory /path/to/base/directory --process gral --met-file /path/to/met/file/metfile.met --osm-file /path/to/osm/file/file.osm --gral-dll /path/to/gral/dll/file/GRAL.dll

GRAL Module Documentation

The GRAL class within the gral/gral_processor.py module serves to automate the creation of required files for GRAL simulation based on user inputs and predefined values. Below is an outline of its structure and functionalities:

class GRAL:
    """
    A class used to represent the GRAL module.

    Attributes:
        base_directory (str): The base directory for the project.
        met_file (str): The name of the met file.
        buildings_file (str): The name of the buildings file.
        line_file (str): The name of the line file.

    Methods:
        create_greb_file(bbox, horizontal_slices): Creates a GREB file with predefined values.
        create_in_dat_file(particles_ps, dispertion_time, latitude, horizontal_slices): Creates a in.dat file with predefined values.
        create_meteopgt_file(): Creates a meteopgt.all file with predefined values.
        create_pollutant_txt_file(pollutant): Creates a pollutant.txt file with predefined values.
        create_percent_file(): Creates a Percent.txt file with predefined values.
        create_max_proc_file(n_cores): Creates a Max_Proc.txt file with predefined values.
        create_other_txt_requiered_files(pollutant, n_cores): Creates the other txt requiered files with predefined values.
        create_buildings_file(): Creates a buildings.dat file with predefined values.
        create_line_emissions_file(pollutant): Creates a line.dat file with predefined values.
        create_met_time_series_data_file(meteo_file): Creates a mettimeseries.dat file with predefined values.
        create_dispersion_number_file(): Creates a DispNr.txt file with predefined values.
        create_other_optional_files(): Creates the other optional files with predefined values.
        get_number_of_weather_conditions(): Gets the number of weather conditions.
        rename_results(pollutant, horizontal_layers, n_meteo_conditions): Rename the results files.
        check_pollutant(pollutant): Checks if the pollutant is valid.
        check_horizontal_layers(horizontal_layers): Checks if the horizontal layers are valid.
    """
    ...

Contributing

Contributions are welcome! Create a new issue to discuss a feature or bug, or create a pull request to propose changes.

License

This project is licensed under the MIT License.

sumo2gral's People

Contributors

seniel98 avatar behrisch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.