iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📈

Smoothing Data in SORACOM Lagoon

に公開
2023/04/12

What I want to achieve

When visualizing data from SORACOM Harvest Data in SORACOM Lagoon,
turning noisy data like this

into smoothed data using a moving average

However, I want to achieve this using only Lagoon's features without modifying the data source.

Preparation (Prerequisites)

  1. Store data in SORACOM Harvest Data
    https://users.soracom.io/ja-jp/docs/harvest/send-data/
    *If you don't have data yet, demo data is available, so this is not strictly required.

  2. Start using SORACOM Lagoon "v2"
    https://users.soracom.io/ja-jp/docs/lagoon-v2/getting-started/
    *The Free plan is fine.

Steps

  1. Add a panel

  2. Select "Add an empty panel" (top left)

  3. Set Visualization in the Panel tab to Graph (default)

  4. Select the (noisy) data you want to smooth in the Query tab

    The demo "temperature" data is moderately noisy and looks like this:

  5. Add an Expression

    *As the warning states: "Experimental feature: queries could stop working in next version."

  6. In Operation, add Resample.

  7. Select "A" (the noisy data added earlier) for the input.

  8. Select the smoothing parameters.
     Resample to: This sets the time interval for the moving average.
      ex.) 3m (3-minute moving average), 10m (10-minute moving average)
     Downsample: Select "Mean" since we want to calculate a moving average.
     Upsample: Select "backfilling" to ensure continuous rendering (this handles how to process edges where data is insufficient for the moving average window).

Setting example:

After editing, click the eye button twice to reflect the changes.

It will look like this:

Finishing touches (Extras)

  1. The series name on the graph has become "B", so we will overwrite it.
    Click the pencil button

    and edit it directly (change it to "smoothed").

    After editing, click the eye button twice to reflect the changes.

  2. For the smoothed graph, you don't need to fill the area under the line with a semi-transparent color, so let's remove it (optional).
    Scroll down in the Panel tab

    ↓
    ↓
    Find and open "Series overrides".

  3. Once opened, select "smoothed" (the added Expression) for Alias or regex.

  4. Click "+"

  5. Set Line fill to 0

The semi-transparent orange fill on the smoothed graph will disappear.

  1. The line is a bit thin like this, so let's make it thicker.
    Adjust the Line Width in addition to the previous settings.

It's now thicker.

  1. If you want to change the color of the thickened line, do it here.

Using a similar color looks stylish.

QA

Can I export the smoothed data as a CSV?

Yes, it can be exported.
Click the downward caret next to the panel title and select "Inspect" -> "Data".

Open "Data options", select "smoothed" from the "Show data frame" dropdown, and click the light blue "Download CSV" button.

GitHubで編集を提案

Discussion