Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeseries types and statistics #1251

Merged
merged 6 commits into from
Nov 19, 2024
Merged

Timeseries types and statistics #1251

merged 6 commits into from
Nov 19, 2024

Conversation

abkfenris
Copy link
Member

@abkfenris abkfenris commented Nov 16, 2024

  1. Initial Model Changes:

    • Implemented foundational modifications to support various timeseries data types, particularly focusing on tidal data.
  2. Min/Max and Tide Extrema Calculation:

    • Added functionality to calculate minimum and maximum values for all timeseries. For tidal data types, the system now identifies high and low tide extrema within the requested dataset.
  3. Forecast Data Retrieval:

    • Updated the logic to pull the next week's worth of forecast or prediction data instead of relying on the last few days. This change allows for a more accurate assessment of extrema over a broader time window. Additionally, the next value is now retrieved to ensure it is closer to the current time, enhancing the relevance of the data.
  4. Nearest Forecast Utilization:

    • Ensured that the system utilizes the nearest available forecast data to improve accuracy in predictions.

These changes aim to enhance the functionality and accuracy of the timeseries data handling, providing better insights for users working with flooding and tidal data. Further adjustments may be needed to optimize the data window for forecasts.

{
            "id": "Chebeague Island tide gauge",
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -70.12649307518743,
                    43.71613636966065
                ]
            },
            "properties": {
                "id": 160,
                "readings": [
                    {
                        "value": -0.252,
                        "time": "2024-11-16T23:12:00Z",
                        "depth": null,
                        "data_type": {
                            "standard_name": "predicted_sea_water_level",
                            "short_name": "PWL",
                            "long_name": "Predicted level of sea water",
                            "units": "m"
                        },
                        "server": "https://data.neracoos.org/erddap/",
                        "variable": "predictedWL",
                        "constraints": {
                            "shefID=": "CASM1"
                        },
                        "dataset": "nosCoopsWLTP6",
                        "start_time": "2024-11-16T14:49:54.295100Z",
                        "cors_proxy_url": "/api/servers/6/proxy/",
                        "datum_offsets": {},
                        "flood_levels": [],
                        "highlighted": "No",
                        "type": "Prediction",
                        "extrema": false,
                        "extrema_values": {
                            "max": {
                                "time": "2024-11-17T16:30:00+00:00",
                                "value": 3.508
                            },
                            "min": {
                                "time": "2024-11-17T22:54:00+00:00",
                                "value": -0.485
                            },
                            "tides": [
                                {
                                    "tide": "low",
                                    "time": "2024-11-16T23:06:00+00:00",
                                    "value": -0.299
                                },
                                {
                                    "tide": "high",
                                    "time": "2024-11-17T00:48:00+00:00",
                                    "value": 0.961
                                },

Adds the ability to calculate the mix and max values for all timeseries, and for tidal data types it will try to figure out the highs and lows in the requested data.
For forecast or prediction timeseries, the next weeks worth of data is pulled instead of the last days, so we can get the extrema from that window. Additionally we also grab the next value, rather than the last one, so it's closer to the current time.

We probably want to change that to a shorter window though.
@abkfenris abkfenris changed the title timeseries-types Timeseries types and statistics Nov 16, 2024
@abkfenris abkfenris marked this pull request as ready for review November 19, 2024 17:11
@abkfenris
Copy link
Member Author

This now uses the more reliable algorithm for finding high/low tides recommended by Hannah.

@abkfenris abkfenris merged commit 6cf91a0 into main Nov 19, 2024
8 of 9 checks passed
abkfenris added a commit that referenced this pull request Nov 19, 2024
Additions:

- Timeseries types and extrema in [#1251](#1251)
  - Timeseries can now be classified into different types (observation, forecast, prediction) which will alter how we fetch data for them. For observations we will continue to use the last 24 hours and the latest value from that, while forecasts and predictions we will fetch the next 7 days and use the first value.
  - We're calculating the min and max of each timeseries, and for tidal timeseries we are calculating the high and low tides over the fetched data.

Changes:

- Added 'Overland Flood' as a platform type  in [#1251]

Fixes:

- Take care of some N+1 queries in `refresh_dataset` [#1245](#1245)
- Adjusteda few commands that needed `uv run` to be prefixed.

Dependency Updates:

- Pre-commit
  - Pyproject Format from 2.4.3 to 2.5.0
  - Ruff from 0.7.1 to 0.7.4
- Dockerfile from 1.10 to 1.11
- Python
  - Sentry SDK from 2.17.0 to 2.18.0
  - Py.test Coverage from 5.0 to 6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants