-
Notifications
You must be signed in to change notification settings - Fork 1
ForecastPage
Warning
Project undergoing migration to Google Cloud Platform, content subject to frequent change
The Forecasts page (/forecasts
) is a core page component of the Epistorm Dashboard, responsible for visualizing and analyzing flu-related hospitalization predictions from various models.
Child Components include Forecast Components and Nowcast Components
The page is structured as a client-side rendered component with the following main sections:
- Selected State & Nowcast Info Header
- Nowcast US-Map + Thermometer + Activity Level Information
- Nowcast Gauge (General Trend)
- Settings Panel
- Forecast Chart Header
- Forecast Graph (Weekly Hospitalization Forecast)
The component uses a custom CSS Grid layout system with the following structure:
+------------------+-----------------+------------------+|
| Nowcast Header | |
+------------------+-----------------+ |
| Nowcast Thermo | Nowcast Gauge | |
+------------------+-----------------+ |
| Forecast Header | Settings Panel |
+------------------+-----------------+ |
| Forecast Chart | |
+------------------+-----------------+------------------+|
The component interfaces with several data sources:
-
Ground Truth Data: Historical hospitalization data
- Source:
/data/ground-truth/target-hospital-admissions.csv
- Format: Weekly hospitalization rates by state
- Source:
-
Prediction Data: Model forecasts from multiple teams
- Source:
/data/processed/{model_name}/predictions.csv
- Models: *See Data Pipeline for list of models
- Source:
-
Location Data: State/location information
- Source:
/data/locations.csv
- Contains: State codes, full names, and population data
- Source:
-
Nowcast Trends: Current trend analysis
- Source:
/data/processed/{model_name}/nowcast_trends.csv
- Format: Trend indicators (increase/decrease/stable) by location
- Source:
-
Thresholds Data: Risk level thresholds
- Source:
/data/thresholds.csv
- Defines: Medium, High, and Very High risk thresholds data
- Source:
-
Historical Ground Truth: Historical surveillance data
- Source:
/data/ground-truth/historical-data/
- Format: Surveillance data of hospitalization, snapshot at given date
- Source:
The component utilizes Redux for state management with the following slices:
-
groundTruthSlice
: Surveillance data -
predictionsSlice
: Model predictions -
locationSlice
: Geographic data -
nowcastTrendsSlice
: Trend analysis -
filterSlice
: User interface filters -
stateThresholdsSlice
: Risk thresholds -
historicalGroundTruthSlice
: Historical data
- Implements sophisticated date handling for flu seasons
- Automatically fills gaps in surveillance data (date that not yet exist in surveillance, but referred in prediction data)
- Handles UTC date comparisons
The component automatically generates season options based on available data:
- Seasons run from August 1st to July 31st
- Handles partial and ongoing seasons
- Provides clear labeling for current and historical seasons
The component implements robust error handling:
- Safe CSV fetching with fallback mechanisms
- Graceful handling of missing data files
- Loading state management for all data sources
Several optimizations are implemented:
- Conditional rendering based on loading states
- Efficient data processing using Map data structures
- Optimized date calculations and comparisons
The component uses several TypeScript interfaces (see Forecast Interfaces) including:
-
DataPoint
: Ground truth data structure -
PredictionDataPoint
: Model prediction structure -
LocationData
: Geographic information -
ModelPrediction
: Model output structure -
SeasonOption
: Season selection options
- ForecastChart: Main visualization component
- SettingsPanel: User interface controls
- NowcastStateThermo: State-level risk visualization
- NowcastGauge: National risk visualization
- NowcastHeader: Contextual information
- ForecastChartHeader: Chart context and controls
To use this component:
- Ensure all required data files are present in the correct locations
- Set up Redux store with required slices
- Import and mount the component in your Next.js application
import ForecastPage from './forecasts/page';
// Mount within your app
<ForecastPage />
- Component uses Client-Side Rendering
- Requires proper setup of data pipeline for CSV files
- Depends on specific date-fns functionality for date handling
Main Pages
Data Pipeline
- Data Pipeline
- Data Transformation Script
- Custom data interface for wrapping processed csv into React Components
- Data Fetching API
Static Components
Visualizations
-
- WIP
Styling