Group¶
SWAN group commands
BaseGroupComponent ¶
Bases: BaseComponent
Base group component.
Base class for SWAN group components. This base class modifies the render()
method to allow rendering of a list of components. It is not intended to be used
directly but to be subclassed by other group components.
Source code in src/rompy_swan/components/group.py
STARTUP ¶
Bases: BaseGroupComponent
Startup group component.
.. code-block:: text
PROJECT ...
SET ...
MODE ...
COORDINATES ...
This group component is used to group individual startup components. Only fields that are explicitly prescribed are rendered by this group component.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.startup import PROJECT, SET, MODE, COORDINATES
from rompy_swan.components.group import STARTUP
proj = PROJECT(nr="01")
set = SET(level=0.5, direction_convention="nautical")
mode = MODE(kind="nonstationary", dim="twodimensional")
coords = COORDINATES(kind=dict(model_type="spherical", projection="ccm"))
startup = STARTUP(
project=proj,
set=set,
mode=mode,
coordinates=coords,
)
print(startup.render())
Source code in src/rompy_swan/components/group.py
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['startup', 'STARTUP'] = Field(default='startup', description='Model type discriminator')
coordinates
class-attribute
instance-attribute
¶
Functions¶
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/group.py
INPGRIDS ¶
Bases: BaseGroupComponent
SWAN input grids group component.
.. code-block:: text
INPGRID ...
READGRID ...
INPGRID ...
READGRID ...
...
This group component is a convenience to allow defining and rendering a list of input grid components.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.inpgrid import REGULAR, ICE
from rompy_swan.components.group import INPGRIDS
inpgrid_bottom = REGULAR(
grid_type="bottom",
excval=-99.0,
xpinp=172.0,
ypinp=-41.0,
alpinp=0.0,
mxinp=99,
myinp=99,
dxinp=0.005,
dyinp=0.005,
readinp=dict(fname1="bottom.txt"),
)
inpgrid_wind = REGULAR(
grid_type="wind",
excval=-99.0,
xpinp=172.0,
ypinp=-41.0,
alpinp=0.0,
mxinp=99,
myinp=99,
dxinp=0.005,
dyinp=0.005,
readinp=dict(fname1="wind.txt"),
nonstationary=dict(
tbeg="2019-01-01T00:00:00",
tend="2019-01-07 00:00:00",
delt=3600,
dfmt="hr",
),
)
inpgrid_ice_cte = ICE(aice=0.8, hice=2.0)
inpgrids = INPGRIDS(inpgrids=[inpgrid_bottom, inpgrid_wind, inpgrid_ice_cte])
print(inpgrids.render())
Source code in src/rompy_swan/components/group.py
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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
inpgrids
class-attribute
instance-attribute
¶
Functions¶
ensure_unique_grid_type
classmethod
¶
Ensure that each grid type is unique.
Source code in src/rompy_swan/components/group.py
PHYSICS ¶
Bases: BaseGroupComponent
Physics group component.
The physics group component is a convenience to allow specifying several individual components in a single command and check for consistency between them.
Exemples¶
.. ipython:: python :okwarning:
from rompy_swan.components.group import PHYSICS
gen = {"model_type": "gen3", "source_terms": {"model_type": "komen"}}
phys = PHYSICS(gen=gen)
print(phys.render())
phys = PHYSICS(
gen=dict(model_type="gen3", source_terms={"model_type": "st6c1"}),
negatinp={"model_type": "negatinp", "rdcoef": 0.04},
sswell={"model_type": "zieger"},
breaking={"model_type": "constant", "alpha": 1.0, "gamma": 0.73},
friction={"model_type": "jonswap", "cfjon": 0.038},
)
print(phys.render())
Source code in src/rompy_swan/components/group.py
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 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['physics', 'PHYSICS'] = Field(default='physics', description='Model type discriminator')
negatinp
class-attribute
instance-attribute
¶
wcapping
class-attribute
instance-attribute
¶
quadrupl
class-attribute
instance-attribute
¶
breaking
class-attribute
instance-attribute
¶
friction
class-attribute
instance-attribute
¶
vegetation
class-attribute
instance-attribute
¶
turbulence
class-attribute
instance-attribute
¶
obstacle
class-attribute
instance-attribute
¶
diffraction
class-attribute
instance-attribute
¶
surfbeat
class-attribute
instance-attribute
¶
deactivate
class-attribute
instance-attribute
¶
Functions¶
deactivate_physics
classmethod
¶
Convert OFF to OFFS so list is rendered.
negatinp_only_with_zieger ¶
negatinp_only_with_zieger() -> PHYSICS
Log a warning if NEGATINP is used with a non-ZIEGER SSWELL.
Source code in src/rompy_swan/components/group.py
cmd ¶
Source code in src/rompy_swan/components/group.py
OUTPUT ¶
Bases: BaseGroupComponent
Output group component.
.. code-block:: text
FRAME 'sname' ...
GROUP 'sname' ...
CURVE 'sname' ...
RAY 'rname' ...
ISOLINE 'sname' 'rname' ...
POINTS 'sname ...
NGRID 'sname' ...
QUANTITY ...
OUTPUT OPTIONS ...
BLOCK 'sname' ...
TABLE 'sname' ...
SPECOUT 'sname' ...
NESTOUT 'sname ...
This group component is used to define multiple types of output locations and write components in a single model. Only fields that are explicitly prescribed are rendered by this group component.
Note¶
The components prescribed are validated according to some constraints as defined in the SWAN manual:
- The name
'sname'of each Locations component must be unique. - The Locations
'sname'assigned to each write component must be defined. - The BLOCK component must be associated with either a
FRAMEorGROUP. - The ISOLINE write component must be associated with a
RAYcomponent. - The NGRID and NESTOUT components must be defined together.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.output import POINTS, BLOCK, QUANTITIES, TABLE
from rompy_swan.components.group import OUTPUT
points = POINTS(sname="outpts", xp=[172.3, 172.4], yp=[-39, -39])
quantity = QUANTITIES(
quantities=[
dict(output=["depth", "hsign", "tps", "dir", "tm01"], excv=-9),
]
)
times = dict(tbeg="2012-01-01T00:00:00", delt="PT30M", tfmt=1, dfmt="min")
block = BLOCK(
model_type="block",
sname="COMPGRID",
fname="./swangrid.nc",
output=["depth", "hsign", "tps", "dir"],
times=times,
)
table = TABLE(
sname="outpts",
format="noheader",
fname="./swantable.nc",
output=["hsign", "hswell", "dir", "tps", "tm01", "watlev", "qp"],
times=times,
)
out = OUTPUT(
points=points,
quantity=quantity,
block=block,
table=table,
)
print(out.render())
Source code in src/rompy_swan/components/group.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
Attributes¶
model_type
class-attribute
instance-attribute
¶
model_type: Literal['output', 'OUTPUT'] = Field(default='output', description='Model type discriminator')
quantity
class-attribute
instance-attribute
¶
output_options
class-attribute
instance-attribute
¶
Functions¶
write_locations_exists ¶
write_locations_exists() -> OUTPUT
Ensure the location component requested by a write component exists.
Source code in src/rompy_swan/components/group.py
locations_sname_unique ¶
locations_sname_unique() -> OUTPUT
Ensure same sname isn't used in more than one set of output locations.
Source code in src/rompy_swan/components/group.py
block_with_frame_or_group ¶
block_with_frame_or_group() -> OUTPUT
Ensure Block is only defined for FRAME or GROUP locations.
Source code in src/rompy_swan/components/group.py
isoline_ray_defined ¶
isoline_ray_defined() -> OUTPUT
Ensure the isoline ray has been defined.
Source code in src/rompy_swan/components/group.py
ngrid_and_nestout ¶
ngrid_and_nestout() -> OUTPUT
Ensure NGRID and NESTOUT are specified together.
Source code in src/rompy_swan/components/group.py
cmd ¶
Command file string for this component.
Source code in src/rompy_swan/components/group.py
LOCKUP ¶
Bases: BaseComponent
Lockup group component.
.. code-block:: text
COMPUTE ...
HOTFILE ...
COMPUTE ...
HOTFILE ...
...
STOP
This is a group component to specify SWAN "Lockup" commands including multiple
COMPUTE commands that may or may not be interleaved with HOTFILE commands,
and a final STOP command.
Examples¶
.. ipython:: python :okwarning:
from rompy_swan.components.group import LOCKUP
lockup = LOCKUP(
compute=dict(
model_type="stat",
times=dict(
model_type="nonstationary",
tbeg="1990-01-01T00:00:00",
tend="1990-01-01T03:00:00",
delt="PT1H",
dfmt="hr",
),
hotfile=dict(fname="hotfile"),
hottimes=[-1],
),
)
print(lockup.render())