Skip to content

Working with Activities

Anna Petrasova edited this page Sep 10, 2017 · 7 revisions

Working with Activities

"Activities" is a way to prepare many different tasks (for example for teaching, or doing experiments) and they allow you to easily switch between them.

Activities have several components:

  • Python files with prepared analyses
  • configuration file
  • dataset
  • optionally slides (for designing an experiment)

Features:

  • automatic loading of predefined layers
  • allows different reference raster and scanning parameters for different activities
  • allows simple filtering of hands
  • adding profiles, simple dashboard
  • limiting time for each activity (for experiments)
  • support logging and postprocessing (for experiments, needs to be scripted specifically based on the activity)
  • slides with automatic progress (for experiments)

Python files with prepared analyses

The Python files are described in Running analyses and developing workflows.

Documentation of JSON config file for designing activities

General settings

The following settings do not depend on the activities.

Path to workflow files

Specification of directory where to find Python files with activity workflow for all activities. This is required.

"taskDir": "/path/to/my/activities/",

Logging and postprocessing

Specification of directory where to write log files after each activity ends (useful for running experiments). This postprocessing is done inside the Python files describing the activity workflow in Python function starting with post_.... This is optional.

"logDir": "/path/to/logs/",

Slides

Specifies whether HTML (specifically reveal.js) slides should be used during the activity (useful for running experiments). This has 2 items, one specifies directory where html slides are to be found, and the second determines the position where the window with slides will be opened. This is optional.

"slides":
  {
    "dir": "/home/tangible/Rogers_experiment/experiment_slides2/",
    "position": [2000, 300]
  },

Show sign to remove hands

Specifies whether to show a sign after completing each activity to indicate that users need to remove hands so that the scanner can capture final result (useful for experiments). Color, font size, position (within Map Display) and text can be specified. This is optional.

"handsoff": [
              "d.text", 
              "at=6,45",
              "size=20",
              "color=red",
              "text='HANDS OFF'"
    ],

Specifies how much time the sign stays displayed to ensure completing each activity. Color, font size, position and text can be specified. This is optional, if not specified it's 0 seconds, units are milliseconds.

"duration_handsoff": 6000,
"duration_handsoff_after": 5000,

Key bindings

Key bindings for specific actions. In wxPython, for example, wx.WXK_F5 is 344 and so on. You can find a list of key event names here. Available actions are stopTask (user can stop activity this way, for example using a button), and scanOnce which is used in cases when we don't need to run analysis continuously during the activity, but need to capture and analyze the scan just when the user needs it. This is optional, you can specify one or both.

"keyboard_events": {"stopTask": 344, "scanOnce": 370},

Activity description

This describes the activities (explained further below):

  "tasks": [
    {      
      "title": "Freeplay",
      "layers": [
        [
          "d.rast", 
          "map=freeplay_scan"
        ],
        [
          "d.vect", 
          "map=freeplay_contours"
        ],
      ],
      "layers_opacity": [1.0, 0.5],
      "calibration": false,
      "base": "cutfill1_dem1",
      "time_limit": 300, 
      "scanning_params": {"smooth": 10, "numscans": 2, "zexag": 1},
      "analyses": "experiment_freeplay.py", 
      "filter" : {"threshold": 200, "debug": true},
      "slides": {"switch": [93, 174], "file": "freeplay.html"},
      "profile": {"size": [400, 140], "position": [4272, 660],
                  "limitx": [0, 350], "limity": [90, 190], "ticks": 10, "raster": "freeplay_scan"}
    }
   ]

Title

Specifies title of the activity visible in the GUI, it's required:

 "title": "Freeplay"

Loading layers

Specification of GIS layers which should be loaded when the activity starts. The display will automatically zoom to capture all these layers. The specification of the symbology is given using d.rast and d.vect GRASS GIS modules. Note that the specified raster or vector maps must be present when the activity starts, otherwise the loading will fail. This is required, however the layer list can be empty if needed.

      "layers": [
        [
          "d.rast", 
          "map=freeplay_scan"
        ],
        [
          "d.vect", 
          "map=freeplay_contours"
        ],
      ],

This specifies the semitransparency of the layers (1 is opaque). The length of the list should be the same as the number of loaded layers. This is optional.

"layers_opacity": [1.0, 0.5], 

Calibration scan

Sometimes it's necessary to capture the topography shape before the start of the activity, for example for detection of markers. Specifying true will result in creating a 'Calibrate' button for the activity. When you press the Calibrate button, it will save the raster under name scan_saved. This is optional.

"calibration": false,

Reference DEM

Specifies a raster map used for georeferencing. This is required.

"base": "cutfill1_dem1",

Time limit

Specifies time limit for each activity (useful for experiments). After the specified time is up, the activity is ended, useful for experiments. This is optional, units are seconds.

"time_limit": 300,

Scanning parameters

Specifies scanning parameters, overwrites whatever is set in Scanning tab. This is optional, however the settings stay for next activities unless other settings are specified there:

"scanning_params": {"smooth": 10, "numscans": 2, "zexag": 1},

File with Python workflow file for the activity (and postprocessing if desired). The directory is specified in 'taskDir' above. This is required.

"analyses": "experiment_freeplay.py", 

Filter scans

Specifies filtering of scans to avoid scans with captured hands based on the range of elevation values of each scan. "debug": true outputs the elevation range in normal case without hands and allows in this way to pick the right threshold.

"filter" : {"threshold": 200, "debug": true},

Continuous vs. one time processing

Allows to have activities which use continuous scanning (false) or just single scan. This is optional, by default it's continuous:

"single_scan": true,

Slides

Specifies details of the slides for each activity (when to switch slides and which html file to use). 'Switch' is a list of numbers telling the application when to switch to next slide, in this case next slide is switched after 93s and 174 s (from the beginning of the activity). When the last slide comes, the activity is started and the last slide stays on screen.

"slides": {"switch": [93, 174], "file": "freeplay.html"},

Profile display

Specifies whether profile widget should be displayed, what is its size, position on the screen, limit on axes, and raster used for computing the profile:

"profile": {"size": [400, 140], "position": [4272, 660],
            "limitx": [0, 350], "limity": [90, 190], "ticks": 10, "raster": "freeplay_scan"},

This is how the profile gets updated from a Python workflow file:

from activities import updateProfile

def run_freeplay(scanned_elev, eventHandler, env, **kwargs):
    event = updateProfile(points=[(640026, 223986), (640334, 223986)])
    eventHandler.postEvent(receiver=eventHandler.activities_panel, event=event)

TODO: Example Activities