HmsDssGrid¶
DSS grid writing operations for gridded precipitation workflows.
hms_commander.HmsDssGrid
¶
Static class for DSS grid operations using HEC Monolith.
Provides methods for writing gridded precipitation data to DSS format, mirroring the implementation pattern found in HEC-Vortex.
All methods are static - do not instantiate this class.
Technical Background
HMS requires gridded precipitation data in DSS format with specific grid metadata (SpecifiedGridInfo for WGS84). This class uses the same HEC Monolith Java classes as HEC-Vortex, accessed via pyjnius.
Example
from hms_commander import HmsDssGrid import numpy as np
Write AORC data to DSS¶
HmsDssGrid.write_grid_timeseries( ... dss_file="aorc.dss", ... pathname="/AORC/STORM/PRECIP////", ... grid_data=precip_array, ... lat_coords=lat_array, ... lon_coords=lon_array, ... timestamps=time_list ... )
Source code in hms_commander/dss/hms_dss_grid.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
write_grid_timeseries(dss_file, pathname, grid_data, lat_coords, lon_coords, timestamps, units='MM', data_type='PER-CUM')
staticmethod
¶
Write gridded precipitation time series to DSS file.
Converts NumPy grid arrays to DSS grid format using HEC Monolith, following the pattern from HEC-Vortex's DssDataWriter.
Parameters¶
dss_file : str or Path
Output DSS file path. Created if it doesn't exist.
pathname : str
DSS pathname for the grid data.
Format: /A/B/C/D/E/F/ where typically:
- A: Source identifier (e.g., "AORC")
- B: Location/grid name
- C: Parameter (e.g., "PRECIP")
- D-F: Time/version (handled internally)
grid_data : np.ndarray
Precipitation data as 3D array with shape (time, lat, lon).
Values should be in units specified by units parameter.
lat_coords : np.ndarray
1D array of latitude values in decimal degrees (WGS84).
Must match grid_data.shape[1].
lon_coords : np.ndarray
1D array of longitude values in decimal degrees (WGS84).
Must match grid_data.shape[2].
timestamps : List[datetime]
List of datetime objects for each timestep.
Must match grid_data.shape[0].
units : str, default "MM"
Data units string. Common values:
- "MM" - millimeters
- "IN" - inches
data_type : str, default "PER-CUM"
DSS data type. Options:
- "PER-CUM" - Period cumulative (for precipitation)
- "PER-AVER" - Period average (for temperature)
- "INST-VAL" - Instantaneous value
Returns¶
Path Path to the output DSS file.
Raises¶
ImportError If pyjnius not installed. ValueError If array dimensions don't match. RuntimeError If DSS write operation fails.
Examples¶
from hms_commander import HmsDssGrid import numpy as np from datetime import datetime, timedelta
Create synthetic grid (hourly data for 24 hours)¶
grid = np.random.rand(24, 10, 10) * 5.0 # 0-5 mm per hour lat = np.linspace(40.0, 41.0, 10) lon = np.linspace(-78.0, -77.0, 10) times = [datetime(2020, 5, 1) + timedelta(hours=i) for i in range(24)]
Write to DSS¶
HmsDssGrid.write_grid_timeseries( ... dss_file="precip.dss", ... pathname="/AORC/WATERSHED/PRECIP////", ... grid_data=grid, ... lat_coords=lat, ... lon_coords=lon, ... timestamps=times, ... units="MM" ... )
Notes¶
- Data is written in WGS84 (lat/lon) coordinate system
- Cell size is calculated as average of lat/lon spacing
- Grid origin is set to lower-left corner
- Uses SpecifiedGridInfo (not AlbersInfo) for lat/lon grids
- Implementation mirrors HEC-Vortex DssDataWriter.java
See Also¶
HmsAorc.convert_to_dss_grid : Convenience method for AORC conversion
Source code in hms_commander/dss/hms_dss_grid.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
get_info()
staticmethod
¶
Get information about DSS grid format and requirements.
Returns¶
dict Information about DSS grid format including: - format: Description of DSS grid format - requirements: HMS requirements for gridded precip - classes: HEC Monolith classes used - references: Links to documentation
Examples¶
from hms_commander import HmsDssGrid info = HmsDssGrid.get_info() print(info['format']) 'HEC-DSS grid format with SpecifiedGridInfo for WGS84 lat/lon grids'