GithubHelp home page GithubHelp logo

sr-gen's Introduction

Segmental environment generator for inland waterways

Description

This generator constructs arbitrary-looking rivers to be used as training and testing environments for simulation-based maritime applications. The generator alternates between straight and curved segments to construct the river. Several construction parameters can be changed by supplying a configuration file.

Installation

You can install the package via

$ pip install git+https://github.com/nikpau/sr-gen.git

Usage

This generator can be called as a Python module from the command line for standalone use or can be part of a script.

CLI

$ rivergen -c /path/to/config.yaml

You can run the module with the default configuration file at ./configs/example.yaml to see an example of the building process.

Upon running, the generator will create a folder at the specified location from the configuration. For every new generation, a new folder is created, named by a random hexadecimal UUID. This was done to avoid duplicate names when calling the generator rapidly e.g. during training. This behavior can be changed under src/rivergen/export.py:84.

Options

In case you want to test a configuration without saving it permanently to disk, consider using the -tc flag, which temporarily constructs a river from the given configuration and plots it for visual inspection. After closing the plot window, the constructed river is deleted.

If the visual inspection is desired but the result shall be kept, use the -vc flag, which keeps the files after inspection.

Script

The generator can be included in any script by first registering a configuration and then exporting rivers generated from it to a file. For example:

import rivergen

# Register configuration file
config = rivergen.ConfigFile("/path/to/config.yaml").export()

# Generate 10 random rivers from this configuration
# and plot them for inspection
for _ in range(10):
    exportpath = rivergen.export_to_file(config)
    rivergen.tests.visualize(exportpath,config)

Configuration files

The building behavior can be altered via several parameters to be specified inside a yaml configuration file. A possible configuration could look like this:

NSEGMENTS: 10 # Total number of segements
CANAL: False # If true, the river will be a straight canal (ANGLES and RADII will be ignored)
GP: 50 #  No. of grid points per segment width
BPD: 20 # distance between gridpoints [m]
LENGTHS: # Range for straight segments [m] (ξ)
  LOW: 400
  HIGH: 2000
RADII: # Range of circle radii [m] (r)
  LOW: 500
  HIGH: 2000
ANGLES: # Range of angles along the circles [deg] (ϕ)
  LOW: 60
  HIGH: 80
MAX_DEPTH: 7 # River depth at deepest point [m] (κ)
MAX_VEL: 1 # Maximum current velocity [ms⁻¹] (ν)
VARIANCE: 2 # Variance for current and depth rng

# Path to the directory where the
# generated files will be saved.
# Absolute paths are recommended.
SAVEPATH: "/path/to/save/"

# Print information about the generation 
# process to stdout
VERBOSE: True

The configuration file must contain all fields from the example for the generator to work.

sr-gen's People

Contributors

nikpau avatar gggchen avatar

Watchers

 avatar

Forkers

gggchen

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.