> For the complete documentation index, see [llms.txt](https://water-strategy.gitbook.io/waterstrategy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://water-strategy.gitbook.io/waterstrategy/tutorials/pywr-scenarios-reading-external-dataframe-and-adding-custom-rules.md).

# Pywr-scenarios reading external DataFrame and adding Custom Rules

In this tutorial, we will be working with the **Thames Network**, which you receive a copy of automatically when you create a WaterStrategy account.

The steps covered include:

1. **Updating Lee Valley Demand**: We will read and update the Lee Valley Demand data from an external CSV file containing a time series.
2. **Applying Climate Change Uncertainty**: Climate change uncertainties will be introduced by activating **pywr-scenarios**. These uncertainties will be applied to two catchment nodes (inflows), adjusting the inflow conditions based on specified scenarios.
3. **Adding a Custom Rule**: You will learn how to create a Custom Rule, a powerful tool that allows for the expansion and integration of WaterStrategy functionality. In this example, a new parameter will be created to dynamically increase the maximum volume of a reservoir on a specific date, as defined by the user.

By the end of this tutorial, you will be equipped to manage and customize various aspects of the Thames network within WaterStrategy, utilizing time series data, uncertainty scenarios, and custom rules.

You will manually upload the required files, so make sure to save them on your computer for easy access during the tutorial

* [Thames\_Lee\_Valley\_demand](https://nexsysanalytics-my.sharepoint.com/:x:/g/personal/jgonzalez_nexsys-analytics_com/ERY5QXJtGQtFpo7PKUUykJEBI9g6adLvCwxG90xhZqgySQ?e=b4brjW)
* [Thames\_inflows\_pywrScenarios.h5](https://nexsysanalytics-my.sharepoint.com/:u:/g/personal/jgonzalez_nexsys-analytics_com/EV7TBf9J_WZDpF3Oy6HyNmoBj3F4Ew216OE9ltOCC1P8pw?e=YV1A3q)

To get started, in **Project Training Material**, open **Thames** network

<figure><img src="/files/dMk7giGK4biCbfyOaSS2" alt=""><figcaption></figcaption></figure>

Clone **Scenario 1**

<figure><img src="/files/EikoOXCJbjnRN5MvzYvb" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="/files/wZRN7sXokTSfWWKNhA1C" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://water-strategy.gitbook.io/waterstrategy/tutorials/pywr-scenarios-reading-external-dataframe-and-adding-custom-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
