Skip to content

Commit

Permalink
docs: update watt-time readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Feb 22, 2024
1 parent a7b57e4 commit bdd27b7
Showing 1 changed file with 28 additions and 36 deletions.
64 changes: 28 additions & 36 deletions src/lib/watt-time/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# WattTime Grid Emissions Model
# WattTime Grid Emissions plugin

> [!NOTE] > `Watt-time` is a community model, not part of the IF standard library. This means the IF core team are not closely monitoring these models to keep them up to date. You should do your own research before implementing them!
> [!NOTE] > `Watt-time` is a community plugin, not part of the IF standard library. This means the IF core team are not closely monitoring these plugins to keep them up to date. You should do your own research before implementing them!
## Introduction

WattTime technology—based on real-time grid data, cutting-edge algorithms, and machine learning—provides first-of-its-kind insight into your local electricity grid’s marginal emissions rate. [Read More...](https://www.watttime.org/api-documentation/#introduction)

## Scope

WattTime Model provides a way to calculate emissions for a given time in a specific location.
WattTime plugin provides a way to calculate emissions for a given time in a specific geolocation.

The model is based on the WattTime API. The model uses the following inputs:
The plugin is based on the WattTime API. The plugin uses the following inputs:

- location: Location of the software system (latitude in decimal degrees, longitude in decimal degrees). "latitude,longitude"
- geolocation: Location of the software system (latitude in decimal degrees, longitude in decimal degrees). "latitude,longitude"
- timestamp: Timestamp of the recorded event (2021-01-01T00:00:00Z) RFC3339
- duration: Duration of the recorded event in seconds (3600)

Expand All @@ -30,7 +30,7 @@ WattTime API requires activation of subscription before usage. Please refer to t
**Required Parameters:**

```
# example environment variable config , prefix the environment variables with "ENV" to load them inside the model.
# example environment variable config , prefix the environment variables with "ENV" to load them inside the plugin.
# export WATT_TIME_USERNAME=test1
# export WATT_TIME_PASSWORD=test2
```
Expand All @@ -45,7 +45,7 @@ WattTime API requires activation of subscription before usage. Please refer to t
**Required Parameters:**

- timestamp: Timestamp of the recorded event (2021-01-01T00:00:00Z) RFC3339
- location: Location of the software system (latitude in decimal degrees, longitude in decimal degrees). "latitude,longitude"
- geolocation: Location of the software system (latitude in decimal degrees, longitude in decimal degrees). "latitude,longitude"
- duration: Duration of the recorded event in seconds (3600)

### Typescript Usage
Expand All @@ -54,47 +54,40 @@ WattTime API requires activation of subscription before usage. Please refer to t
// environment variable configuration
// export WATT_TIME_USERNAME=test1
// export WATT_TIME_PASSWORD=test2
// use environment variables to configure the model
const env_model = await new WattTimeGridEmissions().configure('watt-time', {
// use environment variables to configure the plugin
const output = await WattTimeGridEmissions({
username: process.env.WATT_TIME_USERNAME,
password: process.env.WATT_TIME_PASSWORD,
});
const inputs = [
{
timestamp: '2021-01-01T00:00:00Z',
location: '43.22,-80.22',
geolocation: '43.22,-80.22',
duration: 3600,
},
];
const results = env_model.calculateEmissions(inputs);
const results = output.execute(inputs);
```

### IMPL Usage

#### Environment Variable based configuration for IMPL

```yaml
# environment variable config , prefix the environment variables with "ENV" to load them inside the model.
# environment variable config , prefix the environment variables with "ENV" to load them inside the plugin.
# export WATT_TIME_USERNAME=test1
# export WATT_TIME_PASSWORD=test2
config:
global-config:
username: ENV_WATT_TIME_USERNAME
password: ENV_WATT_TIME_PASSWORD
inputs:
- timestamp: 2021-01-01T00:00:00Z
location: '43.22,-80.21'
duration: 3600
```

#### Static configuration for IMPL

```yaml
config:
username: username
password: password
inputs:
- timestamp: 2021-01-01T00:00:00Z
location: '43.22,-80.22'
geolocation: '43.22,-80.22'
duration: 3600
```

Expand All @@ -105,34 +98,33 @@ name: watt-time
description: simple demo invoking watt-time
tags:
initialize:
models:
- name: watt-time
model: WattTimeGridEmissions
path: '@grnsft/if-unofficial-models'
graph:
plugins:
watt-time:
plugin: WattTimeGridEmissions
path: '@grnsft/if-unofficial-plugins'
global-config:
username: username
password: password
tree:
children:
child:
pipeline:
- watt-time
config:
watt-time:
username: username
password: password
inputs:
- timestamp: 2023-07-06T00:00
duration: 3600
location: 37.7749,-122.4194
geolocation: 37.7749,-122.4194
```

You can run this by passing it to `impact-engine`. Run impact using the following command run from the project root:
You can run this by passing it to `if`. Run impact using the following command run from the project root:

```sh
npm i -g @grnsft/if
npm i -g @grnsft/if-unofficial-models
impact-engine --impl ./examples/impls/test/watt-time.yml --ompl ./examples/ompls/watt-time.yml
npm i -g @grnsft/if-unofficial-plugins
if --impl ./examples/impls/test/watt-time.yml --ompl ./examples/ompls/watt-time.yml
```
## Position and effects in the impl:
- Technically, WattTime model sets (or overwrites any preconfigured value of) the _grid-carbon-intensity_ attribute.
- As such, it should be positioned before the _sci-o_ model, if such a model is used.
- Technically, WattTime plugin sets (or overwrites any preconfigured value of) the _grid/carbon-intensity_ attribute.
- As such, it should be positioned before the _sci-o_ plugin, if such a plugin is used.

0 comments on commit bdd27b7

Please sign in to comment.