ngiab-data-preprocess 3.0.1__py3-none-any.whl → 3.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -169,7 +169,7 @@ def configure_troute(
169
169
  time_step_size=time_step_size,
170
170
  # troute seems to be ok with setting this to your cpu_count
171
171
  cpu_pool=multiprocessing.cpu_count(),
172
- geo_file_path=f"/ngen/ngen/data/config/{cat_id}_subset.gpkg",
172
+ geo_file_path=f"./config/{cat_id}_subset.gpkg",
173
173
  start_datetime=start_time.strftime("%Y-%m-%d %H:%M:%S"),
174
174
  nts=nts,
175
175
  max_loop_size=nts,
@@ -219,7 +219,8 @@ def write_outputs(forcings_dir, variables):
219
219
  # add the catchment ids as a 1d data var
220
220
  final_ds["ids"] = final_ds["catchment"].astype(str)
221
221
  # time needs to be a 2d array of the same time array as unix timestamps for every catchment
222
- with warnings.catch_warnings(action="ignore"):
222
+ with warnings.catch_warnings():
223
+ warnings.simplefilter("ignore")
223
224
  time_array = (
224
225
  final_ds.time.astype("datetime64[s]").astype(np.int64).values // 10**9
225
226
  ) ## convert from ns to s
@@ -376,9 +376,6 @@ def get_cat_from_gage_id(gage_id: str, gpkg: Path = file_paths.conus_hydrofabric
376
376
 
377
377
  logger.info(f"Getting catid for {gage_id}, in {gpkg}")
378
378
 
379
- # the hydrolocations table seems to have a bunch of errors in it
380
- # use flowpath_attributes instead
381
- # both have errors, cross reference them
382
379
  with sqlite3.connect(gpkg) as con:
383
380
  sql_query = f"SELECT id FROM 'flowpath-attributes' WHERE gage = '{gage_id}'"
384
381
  result = con.execute(sql_query).fetchall()
@@ -91,8 +91,8 @@
91
91
  "output_interval": 3600
92
92
  },
93
93
  "routing": {
94
- "t_route_config_file_with_path": "/ngen/ngen/data/config/troute.yaml"
94
+ "t_route_config_file_with_path": "./config/troute.yaml"
95
95
  },
96
96
  "remotes_enabled": false,
97
- "output_root": "/ngen/ngen/data/outputs/ngen"
97
+ "output_root": "./outputs/ngen"
98
98
  }
@@ -6,5 +6,5 @@ initial_state: zero
6
6
  lat: {lat} # needs calulating
7
7
  lon: {lon} # needs calulating
8
8
  slope_mean: {slope_mean} # mean.slope
9
- train_cfg_file: /ngen/ngen/data/config/dd-config.yml
9
+ train_cfg_file: ./config/dd-config.yml
10
10
  verbose: 0
@@ -42,8 +42,8 @@
42
42
  "output_interval": 3600
43
43
  },
44
44
  "routing": {
45
- "t_route_config_file_with_path": "/ngen/ngen/data/config/troute.yaml"
45
+ "t_route_config_file_with_path": "./config/troute.yaml"
46
46
  },
47
47
  "remotes_enabled": false,
48
- "output_root": "/ngen/ngen/data/outputs/ngen"
48
+ "output_root": "./outputs/ngen"
49
49
  }
@@ -1,276 +1,297 @@
1
1
  /* Modern CSS Reset and Base Styles */
2
2
  :root {
3
- --primary-color: #2563eb;
4
- --primary-hover: #1d4ed8;
5
- --background-color: #f8fafc;
6
- --surface-color: #ffffff;
7
- --text-color: #1e293b;
8
- --border-radius: 8px;
9
- --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
10
- --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
11
- }
12
-
13
- main {
14
- width: 80vw;
15
- margin: 0 auto;
16
- display: grid;
17
- gap: 24px;
18
- }
19
-
20
- /* Ensure padding doesn't interfere with width calculations */
21
- body {
22
- font-family: 'Inter', system-ui, -apple-system, sans-serif;
23
- margin: 0;
24
- padding: 0;
25
- background-color: var(--background-color);
26
- color: var(--text-color);
27
- line-height: 1.5;
28
- min-height: 100vh;
29
- display: flex;
30
- flex-direction: column;
31
- align-items: center;
32
- }
33
-
34
- /* Add padding to header instead */
35
- header {
36
- width: 100%;
37
- padding: 24px 0;
38
- text-align: center;
39
- }
40
-
41
- /* Responsive adjustments */
42
- @media (max-width: 1750px) {
43
- main {
44
- width: 90vw;
45
- }
46
- }
47
-
48
- @media (max-width: 768px) {
49
- main {
50
- width: 90vw; /* Slightly wider on mobile for better readability */
51
- }
52
- }
53
-
54
- /* Header Styles */
55
- h1 {
56
- font-size: 2rem;
57
- font-weight: 700;
58
- text-align: center;
59
- color: var(--text-color);
60
- margin: 24px 0;
61
- }
62
-
63
- h2 {
64
- font-size: 1.5rem;
65
- font-weight: 600;
66
- color: var(--text-color);
67
- margin: 16px 0;
68
- }
69
-
70
- /* Map Container */
71
- #map-container {
72
- background: var(--surface-color);
73
- border-radius: var(--border-radius);
74
- padding: 16px;
75
- box-shadow: var(--shadow-md);
76
- }
77
-
78
- #map {
79
- height: 65vh;
80
- min-height: 450px;
81
- max-height: max(55vh, 500px);
82
- width: 100%;
83
- border-radius: var(--border-radius);
84
- overflow: hidden;
85
- }
86
-
87
- /* Selected Basins Section */
88
- #basins-container {
89
- background: var(--surface-color);
90
- border-radius: var(--border-radius);
91
- padding: 20px;
92
- box-shadow: var(--shadow-md);
93
- }
94
-
95
- #selected-basins,
96
- #cli-command {
97
- background: var(--background-color);
98
- padding: 16px;
99
- border-radius: var(--border-radius);
100
- margin: 16px 0;
101
- font-family: 'Monaco', 'Consolas', monospace;
102
- font-size: 0.9rem;
103
- }
104
-
105
- /* Button Styles */
106
- button {
107
- background-color: var(--primary-color);
108
- color: white;
109
- padding: 12px 20px;
110
- border: none;
111
- border-radius: var(--border-radius);
112
- font-weight: 500;
113
- cursor: pointer;
114
- transition: background-color 0.2s ease;
115
- }
116
-
117
- button:hover {
118
- background-color: var(--primary-hover);
119
- }
120
-
121
- /* Time Settings */
122
- #time-settings {
123
- background: var(--surface-color);
124
- padding: 20px;
125
- border-radius: var(--border-radius);
126
- box-shadow: var(--shadow-md);
127
- }
128
-
129
- .time-input {
130
- display: flex;
131
- align-items: center;
132
- gap: 12px;
133
- margin: 12px 0;
134
- }
135
-
136
- input[type="datetime-local"] {
137
- padding: 8px 12px;
138
- border: 1px solid #e2e8f0;
139
- border-radius: var(--border-radius);
140
- font-size: 0.9rem;
141
- }
142
-
143
- /* Warning and Info Boxes */
144
- #forcings-warning,
145
- #time-warning,
146
- #output-info {
147
- padding: 16px;
148
- border-radius: var(--border-radius);
149
- margin: 16px 0;
150
- }
151
-
152
- #forcings-warning,
153
- #time-warning {
154
- background: #fee2e2;
155
- border-left: 4px solid #ef4444;
156
- }
157
-
158
- #output-info {
159
- background: #fef9c3;
160
- border-left: 4px solid #eab308;
161
- }
162
-
163
- /* Output Paths */
164
- #output-path,
165
- #forcings-output-path,
166
- #realization-output-path {
167
- background: var(--background-color);
168
- padding: 12px;
169
- border-radius: var(--border-radius);
170
- font-family: 'Monaco', 'Consolas', monospace;
171
- font-size: 0.9rem;
172
- margin: 12px 0;
173
- word-break: break-all;
174
- }
175
-
176
- /* Loading Animation */
177
- .loading {
178
- display: none;
179
- width: 24px;
180
- height: 24px;
181
- vertical-align: middle;
182
- }
183
-
184
- .loading.visible {
185
- display: inline-block;
186
- }
187
-
188
- /* Responsive Design */
189
- @media (max-width: 768px) {
190
- body {
191
- padding: 16px;
192
- }
193
-
194
- .time-input {
195
- flex-direction: column;
196
- align-items: flex-start;
197
- }
198
-
199
- input[type="datetime-local"] {
200
- width: 100%;
201
- }
202
- }
3
+ color-scheme: light dark;
4
+ /* Define both light and dark mode colors directly in properties */
5
+ --primary-color: #2563eb;
6
+ --primary-hover: #1d4ed8;
7
+ --background-color: light-dark(#f8fafc, #0f172a);
8
+ --surface-color: light-dark(#ffffff, #1e293b);
9
+ --text-color: light-dark(#1e293b, #f1f5f9);
10
+ --secondary-text: light-dark(#64748b, #94a3b8);
11
+ --border-color: light-dark(#e2e8f0, #334155);
12
+ --warning-bg: light-dark(#fee2e2, #7f1d1d);
13
+ --warning-border: light-dark(#ef4444, #b91c1c);
14
+ --info-bg: light-dark(#fef9c3, #713f12);
15
+ --info-border: light-dark(#eab308, #ca8a04);
16
+ --code-bg: light-dark(#f8fafc, #1e293b);
17
+ --border-radius: 8px;
18
+ --shadow-sm: light-dark(0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.5));
19
+ --shadow-md: light-dark(0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.5));
20
+ }
203
21
 
204
- .command-container {
205
- background: var(--surface-color);
206
- border: 1px solid #e2e8f0;
207
- border-radius: var(--border-radius);
208
- margin: 16px 0;
22
+ main {
23
+ width: 80vw;
24
+ margin: 0 auto;
25
+ display: grid;
26
+ gap: 24px;
27
+ }
28
+
29
+ .maplibregl-popup-content {
30
+ background: var(--surface-color) !important;
31
+
32
+ }
33
+
34
+ #toggle-button {
35
+ position: relative;
36
+ top: 20px;
37
+ left: 20px;
38
+ background-color: light-dark(rgb(87, 27, 98), rgb(147, 51, 164));
39
+ color: light-dark(#f0ead6, #ffffff);
40
+ font-size: 1.2rem;
41
+ min-width: 70px;
42
+ border-radius: 5px;
43
+ border: none;
44
+ padding: 5px 10px;
45
+ transition: 0.3s;
46
+ z-index: 1;
47
+ }
48
+
49
+ #toggle-button:hover {
50
+ scale: 1.1;
51
+ box-shadow: var(--shadow-md);
52
+ }
53
+
54
+ body {
55
+ font-family: 'Inter', system-ui, -apple-system, sans-serif;
56
+ margin: 0;
57
+ padding: 0;
58
+ background-color: var(--background-color);
59
+ color: var(--text-color);
60
+ line-height: 1.5;
61
+ min-height: 100vh;
62
+ display: flex;
63
+ flex-direction: column;
64
+ align-items: center;
65
+ }
66
+
67
+ header {
68
+ width: 100%;
69
+ padding: 24px 0;
70
+ text-align: center;
71
+ }
72
+
73
+ h1 {
74
+ font-size: 2rem;
75
+ font-weight: 700;
76
+ text-align: center;
77
+ color: var(--text-color);
78
+ margin: 24px 0;
79
+ }
80
+
81
+ h2 {
82
+ font-size: 1.5rem;
83
+ font-weight: 600;
84
+ color: var(--text-color);
85
+ margin: 16px 0;
86
+ }
87
+
88
+ #map-container {
89
+ background: var(--surface-color);
90
+ border-radius: var(--border-radius);
91
+ padding: 16px;
92
+ box-shadow: var(--shadow-md);
93
+ }
94
+
95
+ #map {
96
+ height: 65vh;
97
+ min-height: 450px;
98
+ max-height: max(55vh, 500px);
99
+ width: 100%;
100
+ border-radius: var(--border-radius);
101
+ overflow: hidden;
102
+ }
103
+
104
+ #basins-container {
105
+ background: var(--surface-color);
106
+ border-radius: var(--border-radius);
107
+ padding: 20px;
108
+ box-shadow: var(--shadow-md);
109
+ }
110
+
111
+ #selected-basins,
112
+ #cli-command {
113
+ background: var(--code-bg);
114
+ padding: 16px;
115
+ border-radius: var(--border-radius);
116
+ margin: 16px 0;
117
+ font-family: 'Monaco', 'Consolas', monospace;
118
+ font-size: 0.9rem;
119
+ color: var(--text-color);
120
+ }
121
+
122
+ button {
123
+ background-color: var(--primary-color);
124
+ color: light-dark(white, #f1f5f9);
125
+ padding: 12px 20px;
126
+ border: none;
127
+ border-radius: var(--border-radius);
128
+ font-weight: 500;
129
+ cursor: pointer;
130
+ transition: background-color 0.2s ease;
131
+ }
132
+
133
+ button:hover {
134
+ background-color: var(--primary-hover);
135
+ }
136
+
137
+ #time-settings {
138
+ background: var(--surface-color);
139
+ padding: 20px;
140
+ border-radius: var(--border-radius);
141
+ box-shadow: var(--shadow-md);
142
+ }
143
+
144
+ .time-input {
145
+ display: flex;
146
+ align-items: center;
147
+ gap: 12px;
148
+ margin: 12px 0;
149
+ }
150
+
151
+ input[type="datetime-local"] {
152
+ padding: 8px 12px;
153
+ border: 1px solid var(--border-color);
154
+ border-radius: var(--border-radius);
155
+ font-size: 0.9rem;
156
+ background-color: var(--surface-color);
157
+ color: var(--text-color);
158
+ }
159
+
160
+ #forcings-warning,
161
+ #time-warning,
162
+ #output-info {
163
+ padding: 16px;
164
+ border-radius: var(--border-radius);
165
+ margin: 16px 0;
166
+ }
167
+
168
+ #forcings-warning,
169
+ #time-warning {
170
+ background: var(--warning-bg);
171
+ border-left: 4px solid var(--warning-border);
172
+ }
173
+
174
+ #output-info {
175
+ background: var(--info-bg);
176
+ border-left: 4px solid var(--info-border);
177
+ }
178
+
179
+ #output-path,
180
+ #forcings-output-path,
181
+ #realization-output-path {
182
+ background: var(--code-bg);
183
+ padding: 12px;
184
+ border-radius: var(--border-radius);
185
+ font-family: 'Monaco', 'Consolas', monospace;
186
+ font-size: 0.9rem;
187
+ margin: 12px 0;
188
+ word-break: break-all;
189
+ color: var(--text-color);
190
+ }
191
+
192
+ #realization {
193
+ padding-bottom: 40px;
194
+ }
195
+
196
+ .loading {
197
+ display: none;
198
+ width: 24px;
199
+ height: 24px;
200
+ vertical-align: middle;
201
+ }
202
+
203
+ .loading.visible {
204
+ display: inline-block;
205
+ }
206
+
207
+ .command-container {
208
+ background: var(--surface-color);
209
+ border: 1px solid var(--border-color);
210
+ border-radius: var(--border-radius);
211
+ margin: 16px 0;
209
212
  }
210
213
 
211
214
  .command-header {
212
- display: flex;
213
- justify-content: space-between;
214
- align-items: center;
215
- padding: 8px 16px;
216
- background: #f8fafc;
217
- border-bottom: 1px solid #e2e8f0;
218
- border-top-left-radius: var(--border-radius);
219
- border-top-right-radius: var(--border-radius);
215
+ display: flex;
216
+ justify-content: space-between;
217
+ align-items: center;
218
+ padding: 8px 16px;
219
+ background: var(--code-bg);
220
+ border-bottom: 1px solid var(--border-color);
221
+ border-top-left-radius: var(--border-radius);
222
+ border-top-right-radius: var(--border-radius);
220
223
  }
221
224
 
222
225
  .command-header span {
223
- font-size: 0.875rem;
224
- color: #64748b;
225
- font-weight: 500;
226
+ font-size: 0.875rem;
227
+ color: var(--secondary-text);
228
+ font-weight: 500;
226
229
  }
227
230
 
228
231
  .copy-button {
229
- display: inline-flex;
230
- align-items: center;
231
- gap: 6px;
232
- padding: 4px 12px;
233
- background: transparent;
234
- border: 1px solid #e2e8f0;
235
- border-radius: 6px;
236
- color: #64748b;
237
- font-size: 0.875rem;
238
- font-weight: 500;
239
- cursor: pointer;
240
- transition: all 0.2s ease;
232
+ display: inline-flex;
233
+ align-items: center;
234
+ gap: 6px;
235
+ padding: 4px 12px;
236
+ background: transparent;
237
+ border: 1px solid var(--border-color);
238
+ border-radius: 6px;
239
+ color: var(--secondary-text);
240
+ font-size: 0.875rem;
241
+ font-weight: 500;
242
+ cursor: pointer;
243
+ transition: all 0.2s ease;
241
244
  }
242
245
 
243
246
  .copy-button:hover {
244
- background: #f1f5f9;
245
- border-color: #cbd5e1;
246
- color: #334155;
247
+ background: light-dark(#f1f5f9, #334155);
248
+ border-color: var(--border-color);
249
+ color: var(--text-color);
247
250
  }
248
251
 
249
252
  .copy-button:active {
250
- background: #e2e8f0;
251
- }
252
-
253
- .copy-icon {
254
- fill: currentColor;
253
+ background: light-dark(#e2e8f0, #475569);
255
254
  }
256
255
 
257
256
  .command-content {
258
- padding: 16px;
259
- background: #f8fafc;
260
- font-family: 'Monaco', 'Consolas', monospace;
261
- font-size: 0.875rem;
262
- line-height: 1.5;
263
- overflow-x: auto;
264
- border-bottom-left-radius: var(--border-radius);
265
- border-bottom-right-radius: var(--border-radius);
257
+ padding: 16px;
258
+ background: var(--code-bg);
259
+ font-family: 'Monaco', 'Consolas', monospace;
260
+ font-size: 0.875rem;
261
+ line-height: 1.5;
262
+ overflow-x: auto;
263
+ border-bottom-left-radius: var(--border-radius);
264
+ border-bottom-right-radius: var(--border-radius);
265
+ color: var(--text-color);
266
266
  }
267
267
 
268
- /* Animation for copy feedback */
269
268
  .copy-button.copied {
270
- color: #059669;
271
- border-color: #059669;
269
+ color: light-dark(#059669, #34d399);
270
+ border-color: light-dark(#059669, #34d399);
271
+ }
272
+
273
+ /* Responsive adjustments */
274
+ @media (max-width: 1750px) {
275
+ main {
276
+ width: 90vw;
277
+ }
272
278
  }
273
279
 
274
- .copy-button.copied .copy-text {
275
- content: "Copied!";
280
+ @media (max-width: 768px) {
281
+ body {
282
+ padding: 16px;
283
+ }
284
+
285
+ main {
286
+ width: 90vw;
287
+ }
288
+
289
+ .time-input {
290
+ flex-direction: column;
291
+ align-items: flex-start;
292
+ }
293
+
294
+ input[type="datetime-local"] {
295
+ width: 100%;
296
+ }
276
297
  }
@@ -1,11 +1,20 @@
1
1
  document.getElementById('toggleConsole').addEventListener('click', function () {
2
2
  var consoleElement = document.getElementById('console');
3
+ // this is the element at the bottom of the page we need to pad so it's not hidden by the console
4
+ var realizationElement = document.getElementById('realization');
3
5
  consoleElement.classList.toggle('minimized');
4
6
  if (consoleElement.classList.contains('minimized')) {
5
7
  this.textContent = 'Show Console';
6
- }
7
- else {
8
+ realizationElement.style.transition = 'padding-bottom 0.5s ease';
9
+ realizationElement.style.paddingBottom = '40px';
10
+ if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
11
+ window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
12
+ }
13
+ }
14
+ else {
8
15
  this.textContent = 'Hide Console';
16
+ realizationElement.style.transition = 'padding-bottom 0.5s ease';
17
+ realizationElement.style.paddingBottom = '20vh';
9
18
  }
10
19
  });
11
20
 
map_app/static/js/main.js CHANGED
@@ -32,9 +32,15 @@ document.getElementById('end-time').addEventListener('change', create_cli_comman
32
32
  let protocol = new pmtiles.Protocol({metadata: true});
33
33
  maplibregl.addProtocol("pmtiles", protocol.tile);
34
34
 
35
+ // select light-style if the browser is in light mode
36
+ // select dark-style if the browser is in dark mode
37
+ var style = 'static/resources/light-style.json';
38
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
39
+ style = 'static/resources/dark-style.json';
40
+ }
35
41
  var map = new maplibregl.Map({
36
42
  container: 'map', // container id
37
- style: 'static/resources/style.json', // style URL
43
+ style: style, // style URL
38
44
  center: [-96, 40], // starting position [lng, lat]
39
45
  zoom: 4 // starting zoom
40
46
  });
@@ -63,3 +69,53 @@ map.on('click', 'catchments', (e) => {
63
69
  cat_id = e.features[0].properties.divide_id;
64
70
  update_map(cat_id, e);
65
71
  });
72
+
73
+ // Create a popup, but don't add it to the map yet.
74
+ const popup = new maplibregl.Popup({
75
+ closeButton: false,
76
+ closeOnClick: false
77
+ });
78
+
79
+ map.on('mouseenter', 'conus_gages', (e) => {
80
+ // Change the cursor style as a UI indicator.
81
+ map.getCanvas().style.cursor = 'pointer';
82
+
83
+ const coordinates = e.features[0].geometry.coordinates.slice();
84
+ const description = e.features[0].properties.hl_uri + "<br> click for more info";
85
+
86
+ // Ensure that if the map is zoomed out such that multiple
87
+ // copies of the feature are visible, the popup appears
88
+ // over the copy being pointed to.
89
+ while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
90
+ coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
91
+ }
92
+
93
+ // Populate the popup and set its coordinates
94
+ // based on the feature found.
95
+ popup.setLngLat(coordinates).setHTML(description).addTo(map);
96
+ });
97
+
98
+ map.on('mouseleave', 'conus_gages', () => {
99
+ map.getCanvas().style.cursor = '';
100
+ popup.remove();
101
+ });
102
+
103
+ map.on('click', 'conus_gages', (e) => {
104
+ // https://waterdata.usgs.gov/monitoring-location/02465000
105
+ window.open("https://waterdata.usgs.gov/monitoring-location/" + e.features[0].properties.hl_link, '_blank');
106
+ }
107
+ );
108
+ show = false;
109
+ const toggleButton = document.querySelector('#toggle-button');
110
+ toggleButton.addEventListener('click', () => {
111
+ if (show) {
112
+ map.setFilter('conus_gages', ['any', ['==', 'hl_uri', ""]])
113
+ toggleButton.innerText = 'Show gages';
114
+ show = false;
115
+ } else {
116
+ map.setFilter('conus_gages', null)
117
+ toggleButton.innerText = 'Hide gages';
118
+ show = true;
119
+ }
120
+ });
121
+