Skip to content

Commit

Permalink
Merge pull request #74 from mit-jp/timeslices-data-upload
Browse files Browse the repository at this point in the history
Timeslices data upload
  • Loading branch information
ethanrdsch authored Oct 23, 2024
2 parents f60fc2e + dc0274b commit 02cfc50
Show file tree
Hide file tree
Showing 31 changed files with 8,584 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
frontend/public/gridded-world.json filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"webRoot": "${workspaceFolder}"
}
]
}
}
2 changes: 1 addition & 1 deletion backend/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
"cwd": "${workspaceFolder}"
}
]
}
}
61 changes: 61 additions & 0 deletions backend/migrations/20230920100538_add_future_data_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
-- setup table for models, as each dataset can have multiple models
CREATE TABLE future_model (
id SERIAL NOT NULL,
name TEXT NOT NULL,
dataset INT NOT NULL,
source SMALLINT NOT NULL,
domain float8 [] NOT NULL DEFAULT '{}',
PRIMARY KEY(id),
FOREIGN KEY(dataset) REFERENCES dataset(id),
FOREIGN KEY(source) REFERENCES data_source(id)
);

-- each year will have a different confidence interval, so setup tables to store that information
-- stores upper ci for a county/country
CREATE TABLE ci_above (
id SERIAL NOT NULL,
model INT NOT NULL,
geo_id SMALLINT NOT NULL,
PRIMARY KEY (id)
);

-- stores lower ci for a county/country
CREATE TABLE ci_below (
id SERIAL NOT NULL,
model INT NOT NULL,
geo_id SMALLINT NOT NULL,
PRIMARY KEY (id)
);

-- setup table for future/predictive data
CREATE TABLE future_data (
model INT NOT NULL,
ci_above INT,
ci_below INT,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
interval SMALLINT NOT NULL,
id SMALLINT NOT NULL,
geography_type INT NOT NULL,
PRIMARY KEY (
model,
start_date,
end_date,
id
),
FOREIGN KEY (model) REFERENCES future_model(id),
FOREIGN KEY (ci_above) REFERENCES ci_above(id),
FOREIGN KEY (ci_below) REFERENCES ci_below(id),
CONSTRAINT data_geo_ids_fkey FOREIGN KEY (geography_type, id) REFERENCES geo_id (geography_type, id)
);

-- add columns for years up to 2200
DO $$
DECLARE
cur_year INT := 2024;
BEGIN
WHILE cur_year <2201 LOOP
EXECUTE 'ALTER TABLE future_data ADD value_' || cur_year || ' FLOAT';
cur_year := cur_year+1;
END LOOP;
END$$;
3 changes: 3 additions & 0 deletions backend/migrations/20230921144639_remove-model-domain.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Remove domain from future model table, as future data already has a start and end date
ALTER TABLE
future_model DROP COLUMN domain;
5 changes: 5 additions & 0 deletions backend/migrations/20230921145028_description-for-model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Add column for a description
ALTER TABLE
future_model
ADD
COLUMN description TEXT;
5 changes: 5 additions & 0 deletions backend/migrations/20240810112520_drop-future-tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- future data visualization is not ready yet, so no need for the tables currently
DROP TABLE IF EXISTS future_data;
DROP TABLE IF EXISTS ci_above;
DROP TABLE IF EXISTS ci_below;
DROP TABLE IF EXISTS future_model;
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
INSERT INTO
dataset (
short_name,
name,
description,
units,
geography_type
)
VALUES
(
'cmi_MERRA2_ERA5',
'cmi_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'dry_MERRA2_ERA5',
'dry_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'gw_MERRA2_ERA5',
'gw_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'ht_MERRA2_ERA5',
'ht_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'pet_MERRA2_ERA5',
'pet_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'prc_MERRA2_ERA5',
'prc_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'ro_MERRA2_ERA5',
'ro_MERRA2_ERA5',
'placeholder',
'',
2
),
(
'wet_MERRA2_ERA5',
'wet_MERRA2_ERA5',
'placeholder',
'',
2
);
Loading

0 comments on commit 02cfc50

Please sign in to comment.