Geometry Module¶
API reference for the geometry module.
geometry ¶
Module for handling geometry data from OWI metadatabase.
Classes¶
GeometryAPI ¶
Bases: API
Class to connect to the geometry data API with methods to retrieve data.
Create an instance of the GeometryAPI class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_subdir
|
str
|
Subdirectory of the API endpoint url for specific type of data. |
'/geometry/userroutes/'
|
**kwargs
|
Additional parameters to pass to the API (see the base class). |
{}
|
Examples:
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> api.api_root.endswith("/geometry/userroutes/")
True
Source code in src/owi/metadatabase/geometry/io.py
Functions¶
__eq__ ¶
Compare two instances of the API class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
object
|
Another instance of the API class or a dictionary. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the instances are equal, False otherwise. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If comparison is not possible due to incompatible types. |
Examples:
>>> api_1 = API(api_root="https://example", token="test")
>>> api_2 = API(api_root="https://example", token="test")
>>> api_1 == api_2
True
Source code in src/owi/metadatabase/io.py
send_request ¶
Handle sending appropriate request.
Handles sending appropriate request according to the type of authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
url_params
|
Mapping
|
Parameters to send with the request to the database. |
required |
Returns:
| Type | Description |
|---|---|
Response
|
An instance of the Response object. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If neither header nor username and password are defined. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> response = SimpleNamespace(status_code=200, reason="OK")
>>> with mock.patch("requests.get", return_value=response):
... api = API(api_root="https://example", token="test")
... resp = api.send_request("/projects", {})
>>> resp is response
True
Source code in src/owi/metadatabase/io.py
check_request_health
staticmethod
¶
Check status code of the response and provide details.
Checks status code of the response to request and provides details if unexpected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resp
|
Response
|
Instance of the Response object. |
required |
Raises:
| Type | Description |
|---|---|
APIConnectionError
|
If response status code is not 200. |
Examples:
>>> from types import SimpleNamespace
>>> ok = SimpleNamespace(status_code=200, reason="OK")
>>> API.check_request_health(ok)
Source code in src/owi/metadatabase/io.py
output_to_df
staticmethod
¶
Transform output to Pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
Raw output of the sent request. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Pandas dataframe of the data from the output. |
Raises:
| Type | Description |
|---|---|
DataProcessingError
|
If failed to decode JSON from API response. |
Examples:
>>> from types import SimpleNamespace
>>> resp = SimpleNamespace(text='[{"a": 1}]')
>>> int(API.output_to_df(resp)["a"].iloc[0])
1
Source code in src/owi/metadatabase/io.py
postprocess_data
staticmethod
¶
Process dataframe information to extract additional data.
Processes dataframe information to extract the necessary additional data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe of the output data. |
required |
output_type
|
str
|
Expected type (amount) of the data extracted. |
required |
Returns:
| Type | Description |
|---|---|
PostprocessData
|
Dictionary of the additional data extracted. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If more than one record was returned for 'single' output type, or if output type is not 'single' or 'list'. |
Examples:
Source code in src/owi/metadatabase/io.py
validate_data
staticmethod
¶
Validate the data extracted from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe of the output data. |
required |
data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with corrected data. |
Examples:
Source code in src/owi/metadatabase/io.py
process_data ¶
Process output data according to specified request parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
url_params
|
Mapping
|
Parameters to send with the request to the database. |
required |
output_type
|
str
|
Expected type (amount) of the data extracted. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple of dataframe with the requested data and additional data from postprocessing. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> response = SimpleNamespace(text="[]", status_code=200, reason="OK")
>>> api = API(api_root="https://example", token="test")
>>> with mock.patch.object(API, "send_request", return_value=response):
... df, info = api.process_data("projects", {}, "list")
>>> df.empty
True
>>> info["existance"]
False
Source code in src/owi/metadatabase/io.py
get_model_definitions ¶
Get all relevant model definitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_model_definitions(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
get_modeldefinition_id ¶
Get the ID of a model definition.
Either the asset location or the project site must be specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assetlocation
|
str
|
Title of the asset location. |
None
|
projectsite
|
str
|
Title of the projectsite. |
None
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If at least one of assetlocation or projectsite is not specified, if no location found, if no model definitions found, if multiple model definitions found without specification, or if specified model definition not found. |
Examples:
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> api.get_modeldefinition_id()
Traceback (most recent call last):
...
ValueError: At least either of the related ... must be specified!
Source code in src/owi/metadatabase/geometry/io.py
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 | |
get_subassemblies ¶
get_subassemblies(
projectsite=None,
assetlocation=None,
subassembly_type=None,
model_definition=None,
)
Get all relevant structure subassemblies.
If you specify a model definition, you also must specify either the projectsite or the asset location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
assetlocation
|
str
|
Title of the asset location. |
None
|
subassembly_type
|
str
|
Type of the subassembly. |
None
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If model definition specified without projectsite or assetlocation, or if specified model definition not found. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_subassemblies(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
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 | |
get_buildingblocks ¶
get_buildingblocks(
projectsite=None,
assetlocation=None,
subassembly_type=None,
subassembly_id=None,
)
Get all relevant building blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
assetlocation
|
str
|
Title of the asset location. |
None
|
subassembly_type
|
str
|
Type of the subassemblies (e.g. 'MP', 'TW', 'TP'). |
None
|
subassembly_id
|
int or int64
|
ID of the subassembly. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_buildingblocks(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
get_materials ¶
Get all the materials of building blocks.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_materials()
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
get_subassembly_objects ¶
Get all subassemblies for a given turbine, divided by type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbine
|
str
|
Turbine title. |
required |
subassembly
|
str
|
Sub-assembly type (e.g. 'MP', 'TW', 'TP'). |
None
|
model_definition_id
|
int or int64
|
ID of the model definition to filter the subassemblies. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no subassemblies found for the turbine or if no materials found in the database. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> materials = pd.DataFrame(
... [
... {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
... ]
... )
>>> item = {
... "id": np.int64(1),
... "title": "SA_1",
... "description": "",
... "slug": "sa",
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "subassembly_type": "TW",
... "source": "api",
... "asset": np.int64(1),
... "model_definition": np.int64(1),
... }
>>> response = SimpleNamespace(
... status_code=200,
... reason="OK",
... json=lambda: [item],
... )
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> with mock.patch.object(
... GeometryAPI,
... "send_request",
... return_value=response,
... ), mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ):
... out = api.get_subassembly_objects("T01")
>>> sorted(out.keys())
['TW']
Source code in src/owi/metadatabase/geometry/io.py
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 457 458 459 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 | |
get_owt_geometry_processor ¶
Return the required processing class.
Will return data even if some turbines have issues given that at least one is fully OK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
str or list of str
|
Title(s) of the turbines. |
required |
model_definition
|
str
|
Title of the model definition. |
None
|
tower_base
|
float or list of float
|
Height(s) of the tower base. |
None
|
monopile_head
|
float or list of float
|
Height(s) of the monopile head. |
None
|
Returns:
| Type | Description |
|---|---|
OWTs
|
Object containing information about all the requested turbines. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no materials found in the database or if all turbines encounter processing errors. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> materials = pd.DataFrame({"id": [1]})
>>> location = pd.DataFrame({"projectsite_name": ["Site"]})
>>> subassemblies = pd.DataFrame({"subassembly_type": ["TW"]})
>>> def _make_owt(*args, **kwargs):
... return "owt"
>>> def _make_owts(turbines, owts):
... return {"turbines": turbines, "owts": owts}
>>> with mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ), mock.patch.object(
... api.loc_api,
... "get_assetlocation_detail",
... return_value={"exists": True, "data": location},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": subassemblies},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch(
... "geometry.io.OWT",
... _make_owt,
... ), mock.patch(
... "geometry.io.OWTs",
... _make_owts,
... ):
... out = api.get_owt_geometry_processor("T01")
>>> out["turbines"]
['T01']
Source code in src/owi/metadatabase/geometry/io.py
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 | |
get_monopile_pyles ¶
Return a dataframe with the monopile geometry.
Uses the mudline as reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Name of the project site. |
required |
assetlocation
|
str
|
Name of the wind turbine location. |
required |
cutoff_point
|
float
|
Elevation of the load application point in (mLAT) above the mudline. |
nan
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the monopile geometry. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no subassemblies or location found for turbine. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> bbs = pd.DataFrame(
... [
... {
... "z_position": 0,
... "material_name": "Steel",
... "density": 7850.0,
... "wall_thickness": 20.0,
... "bottom_outer_diameter": 6.0,
... "top_outer_diameter": 6.0,
... "youngs_modulus": 210000.0,
... "poissons_ratio": 0.3,
... },
... {
... "z_position": -1000,
... "material_name": "Steel",
... "density": 7850.0,
... "wall_thickness": 20.0,
... "bottom_outer_diameter": 6.0,
... "top_outer_diameter": 6.0,
... "youngs_modulus": 210000.0,
... "poissons_ratio": 0.3,
... },
... ]
... )
>>> sas = pd.DataFrame({"z_position": [-50000]})
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> with mock.patch.object(
... GeometryAPI,
... "get_buildingblocks",
... return_value={"exists": True, "data": bbs},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": sas},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch.object(
... api.loc_api,
... "get_assetlocation_detail",
... return_value={"exists": True, "data": location},
... ):
... pile = api.get_monopile_pyles("Site", "T01")
>>> "Depth from [m]" in pile.columns
True
Source code in src/owi/metadatabase/geometry/io.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | |
plot_turbines ¶
Plot turbines' frontal geometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
str or list of str
|
Title(s) of the turbines. |
required |
figures_per_line
|
int
|
Number of figures per line, default is 5. |
5
|
return_fig
|
bool
|
Boolean indicating whether to return the figure, default is False. |
False
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
Figure or None
|
Plotly figure object with selected turbines front profiles (if requested) or nothing. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no materials or subassemblies found in the database. |
Examples:
>>> from unittest import mock
>>> class _StubSubassembly:
... def __init__(self, *args, **kwargs):
... self.building_blocks = []
... def plotly(self):
... layout = {
... "scene": {},
... "yaxis": {
... "title": {"text": "Height , mm"},
... "scaleanchor": "x",
... "scaleratio": 1,
... "type": "linear",
... },
... }
... return [], layout
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> materials = pd.DataFrame({"id": [1]})
>>> subassemblies = pd.DataFrame({"subassembly_type": ["TW"]})
>>> with mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": subassemblies},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch(
... "geometry.io.SubAssembly",
... _StubSubassembly,
... ):
... fig = api.plot_turbines(["T01"], return_fig=True)
>>> fig is not None
True
Source code in src/owi/metadatabase/geometry/io.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
OWT ¶
Class to process the geometry data of a single OWT.
:param api: API object used to call get_* methods. :param materials: Pandas dataframe with the materials data. :param sub_assemblies: Dictionary of the subassemblies. :param tw_sub_assemblies: Pandas dataframe with the tower subassemblies data for a given turbine. :param tp_sub_assemblies: Pandas dataframe with the transition piece subassemblies data for a given turbine. :param mp_sub_assemblies: Pandas dataframe with the monopile subassemblies data for a given turbine. :param tower_base: Elevation of the OWT tower base in mLAT. :param pile_head: Elevation of the pile head in mLAT. :param water_depth: Water depth in mLAT. :param pile_toe: Elevation of the pile toe in mLAT. :param rna: Pandas dataframe with the RNA data. :param tower: Pandas dataframe with the tower data. :param transition_piece: Pandas dataframe with the transition piece data. :param monopile: Pandas dataframe with the monopile data. :param tw_lumped_mass: Pandas dataframe with the lumped masses data for the tower. :param tp_lumped_mass: Pandas dataframe with the lumped masses data for the transition piece. :param mp_lumped_mass: Pandas dataframe with the lumped masses data for the monopile. :param tp_distributed_mass: Pandas dataframe with the distributed masses data for the transition piece. :param mp_distributed_mass: Pandas dataframe with the distributed masses data for the monopile. :param grout: Pandas dataframe with the grout data. :param full_structure: Pandas dataframe with the full structure data. :param tp_skirt: Pandas dataframe with the transition piece skirt data. :param substructure: Pandas dataframe with the substructure data.
Create an instance of the OWT class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
Any
|
API object used to call get_* methods. |
required |
materials
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the materials data. |
required |
subassemblies
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the subassemblies data for a given turbine. |
required |
location
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the location data for a given turbine. |
required |
tower_base
|
float64
|
Elevation of the OWT tower base in mLAT. |
None
|
pile_head
|
float64
|
Elevation of the pile head in mLAT. |
None
|
Examples:
>>> from contextlib import ExitStack
>>> from unittest import mock
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> def _set_subassemblies(self, subassemblies):
... self.sub_assemblies = {}
>>> def _set_members(self):
... return None
>>> with mock.patch.object(
... OWT,
... "_set_subassemblies",
... _set_subassemblies,
... ), mock.patch.object(OWT, "_set_members", _set_members):
... owt = OWT(
... api=object(),
... materials=pd.DataFrame(),
... subassemblies=pd.DataFrame(),
... location=location,
... )
>>> float(owt.water_depth)
30.0
Source code in src/owi/metadatabase/geometry/processing.py
95 96 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 | |
Functions¶
set_df_structure ¶
Calculate and/or convert geometrical data of subassemblies.
Calculates and/or converts geometrical data of subassemblies from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Possible index to identify corresponding subassembly. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing geometry data from database with z in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index. |
Source code in src/owi/metadatabase/geometry/processing.py
process_structure_geometry ¶
Calculate and/or convert geometrical data for FE models.
Calculates and/or converts geometrical data of subassemblies from the database to use as input for FE models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Possible index to identify corresponding subassembly. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe consisting of the required data to build FE models. |
Source code in src/owi/metadatabase/geometry/processing.py
process_rna ¶
Set dataframe with required properties to model the RNA system.
Raises:
| Type | Description |
|---|---|
ValueError
|
If tower subassembly data not found. |
Source code in src/owi/metadatabase/geometry/processing.py
set_df_appurtenances ¶
Set dataframe with required properties for concentrated masses.
Sets dataframe containing the required properties to model concentrated masses from database subassemblies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing lumped masses data from database with Z coordinates in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index. |
Source code in src/owi/metadatabase/geometry/processing.py
process_lumped_masses ¶
Create dataframe with required properties for lumped masses.
Creates dataframe containing the required properties to model lumped mass appurtenances. Note that if the preprocessor package does not find any appurtenances it'll return an empty dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with lumped mass properties. |
Source code in src/owi/metadatabase/geometry/processing.py
set_df_distributed_appurtenances ¶
Set dataframe with required properties for distributed masses.
Sets dataframe containing the required properties to model distributed lumped masses from database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing distributed lumped masses data from database. Z coordinates in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index or distributed lumped masses located outside the transition piece. |
Source code in src/owi/metadatabase/geometry/processing.py
process_distributed_lumped_masses ¶
Create dataframe with uniformly distributed appurtenances.
Creates dataframe containing the required properties to model uniformly distributed appurtenances. Note that if the preprocessor package does not find any appurtenances it'll return an empty dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with distributed lumped mass properties. |
Source code in src/owi/metadatabase/geometry/processing.py
process_structure ¶
Set dataframe with required properties to model the tower.
Sets dataframe containing the required properties to model the tower geometry, including the RNA system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
option
|
str
|
Option to process the data for a specific subassembly. Possible values:
|
'full'
|
Examples:
>>> from contextlib import ExitStack
>>> from unittest import mock
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> def _set_subassemblies(self, subassemblies):
... self.sub_assemblies = {}
>>> def _set_members(self):
... return None
>>> with mock.patch.object(
... OWT,
... "_set_subassemblies",
... _set_subassemblies,
... ), mock.patch.object(OWT, "_set_members", _set_members):
... owt = OWT(
... api=object(),
... materials=pd.DataFrame(),
... subassemblies=pd.DataFrame(),
... location=location,
... )
>>> empty_df = pd.DataFrame()
>>> with ExitStack() as stack:
... _ = stack.enter_context(mock.patch.object(OWT, "process_rna"))
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_structure_geometry",
... return_value=empty_df,
... )
... )
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_lumped_masses",
... return_value=empty_df,
... )
... )
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_distributed_lumped_masses",
... return_value=empty_df,
... )
... )
... owt.process_structure(option="TW")
>>> owt._init_proc
True
Source code in src/owi/metadatabase/geometry/processing.py
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 | |
can_adjust_properties
staticmethod
¶
Recalculate can properties based on section and elevations.
Recalculation of can properties based on section properties and can elevations: height [m], volume [m3], mass [t], rho [t/m].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
Original can properties. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Pandas series of recalculated can properties. |
Examples:
>>> row = pd.Series(
... {
... "Mass [t]": 10.0,
... "Volume [m3]": 5.0,
... "Elevation from [mLAT]": 10.0,
... "Elevation to [mLAT]": 0.0,
... "Diameter from [m]": 6.0,
... "Diameter to [m]": 6.0,
... "Wall thickness [mm]": 10.0,
... }
... )
>>> out = OWT.can_adjust_properties(row)
>>> float(out["Height [m]"])
10.0
Source code in src/owi/metadatabase/geometry/processing.py
can_modification ¶
Change can properties based on the altitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe containing the can properties. |
required |
altitude
|
float64 or None
|
Altitude in mLAT. |
required |
position
|
str
|
Position of the can with respect to the altitude with possible values: "bottom" or "top", default is "bottom". |
'bottom'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the modified can properties. |
Examples:
>>> df = pd.DataFrame(
... {
... "Elevation from [mLAT]": [10.0],
... "Elevation to [mLAT]": [0.0],
... "Diameter from [m]": [6.0],
... "Diameter to [m]": [6.0],
... "Wall thickness [mm]": [10.0],
... "Volume [m3]": [5.0],
... "Mass [t]": [10.0],
... "rho [t/m]": [1.0],
... },
... index=["A"],
... )
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(can_adjust_properties=OWT.can_adjust_properties)
>>> out = OWT.can_modification(helper, df.copy(), np.float64(5.0))
>>> float(out["Elevation to [mLAT]"].iloc[0])
5.0
Source code in src/owi/metadatabase/geometry/processing.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | |
assembly_tp_mp ¶
Process TP structural item to assembly with MP foundation.
Processes TP structural item to assembly with MP foundation ensuring continuity. TP skirt is processed as well.
Raises:
| Type | Description |
|---|---|
TypeError
|
If TP or MP items need to be processed before. |
Examples:
>>> from types import SimpleNamespace
>>> import pandas as pd
>>> helper = SimpleNamespace(
... transition_piece=None,
... monopile=None,
... _init_spec_part=False,
... )
>>> OWT.assembly_tp_mp(helper)
Traceback (most recent call last):
...
TypeError: TP or MP items need to be processed before!
>>> tp = pd.DataFrame(
... {
... "Elevation from [mLAT]": [6.0, 0.0],
... "Elevation to [mLAT]": [8.0, 4.0],
... "Diameter from [m]": [6.0, 6.0],
... "Diameter to [m]": [6.0, 6.0],
... "Wall thickness [mm]": [10.0, 10.0],
... "Volume [m3]": [5.0, 5.0],
... "Mass [t]": [10.0, 10.0],
... "rho [t/m]": [1.0, 1.0],
... }
... )
>>> mp = pd.DataFrame(
... {
... "Elevation from [mLAT]": [0.0],
... "Elevation to [mLAT]": [-10.0],
... "Diameter from [m]": [6.0],
... "Diameter to [m]": [6.0],
... "Wall thickness [mm]": [10.0],
... "Volume [m3]": [5.0],
... "Mass [t]": [10.0],
... "rho [t/m]": [1.0],
... }
... )
>>> helper = SimpleNamespace(
... transition_piece=tp,
... monopile=mp,
... pile_head=5.0,
... substructure=None,
... tp_skirt=None,
... _init_spec_part=False,
... )
>>> helper.can_adjust_properties = OWT.can_adjust_properties
>>> helper.can_modification = lambda df, altitude, position="bottom": OWT.can_modification(
... helper,
... df,
... altitude,
... position=position,
... )
>>> OWT.assembly_tp_mp(helper)
>>> helper.substructure is not None
True
>>> helper.tp_skirt is not None
True
Source code in src/owi/metadatabase/geometry/processing.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | |
assembly_full_structure ¶
Process the full structure of the OWT.
Processes the full structure of the OWT: tower + tp combination with monopile.
Raises:
| Type | Description |
|---|---|
TypeError
|
If tower or substructure needs to be processed before. |
Examples:
>>> import pandas as pd
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(
... substructure=pd.DataFrame({"Height [m]": [1.0]}),
... tower=pd.DataFrame({"Height [m]": [2.0]}),
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
>>> float(helper.full_structure["Height [m]"].sum())
3.0
>>> helper._init_spec_full
True
>>> helper = SimpleNamespace(
... substructure=None,
... tower=None,
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
Traceback (most recent call last):
...
TypeError: Substructure needs to be processed before!
>>> helper = SimpleNamespace(
... substructure=pd.DataFrame({"Height [m]": [1.0]}),
... tower=None,
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
Traceback (most recent call last):
...
TypeError: Tower needs to be processed before!
Source code in src/owi/metadatabase/geometry/processing.py
extend_dfs ¶
Extend the dataframes with the subassembly columns.
Examples:
>>> import pandas as pd
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(
... pile_toe=None,
... rna=None,
... tower=pd.DataFrame({"Height [m]": [1.0]}),
... transition_piece=None,
... monopile=None,
... tw_lumped_mass=None,
... tp_lumped_mass=None,
... mp_lumped_mass=None,
... tp_distributed_mass=None,
... mp_distributed_mass=None,
... grout=None,
... sub_assemblies={},
... substructure=None,
... tp_skirt=None,
... full_structure=None,
... _init_spec_part=False,
... _init_spec_full=False,
... )
>>> OWT.extend_dfs(helper)
>>> helper.tower["Subassembly"].iloc[0]
'TW'
>>> helper.tp_skirt is None
True
Source code in src/owi/metadatabase/geometry/processing.py
transform_monopile_geometry ¶
Return a dataframe with monopile geometry.
Returns a dataframe with the monopile geometry with the mudline as reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cutoff_point
|
floating
|
Depth from the mudline to cut the monopile geometry. |
nan
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the monopile geometry. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If monopile subassembly data not found. |
Source code in src/owi/metadatabase/geometry/processing.py
OWTs ¶
Class to process the geometry data of multiple OWTs.
:param owts: List of OWT objects. :param api: API object used to call get_* methods. :param materials: Pandas dataframe with the materials data. :param sub_assemblies: Dictionary of dictionaries of the subassemblies for each turbine. :param tower_base: Dictionary of the elevation of the OWT tower base in mLAT for each turbine. :param pile_head: Dictionary of the elevation of the pile head in mLAT for each turbine. :param water_depth: Dictionary of the water depth in mLAT for each turbine. :param tw_sub_assemblies: Dataframe of the tower subassemblies data from each turbine. :param tp_sub_assemblies: Dataframe of the transition piece subassemblies data from each turbine. :param mp_sub_assemblies: Dataframe of the monopile subassemblies data from each turbine. :param pile_toe: Dataframe of the elevation of the pile toe in mLAT from each turbine. :param rna: Dataframe of the RNA data from each turbine. :param tower: Dataframe of the tower data from each turbine. :param transition_piece: Dataframe of the transition piece data from each turbine. :param monopile: Dataframe of the monopile data from each turbine. :param tw_lumped_mass: Dataframe of the lumped masses data of the tower from each turbine. :param tp_lumped_mass: Dataframe of the lumped masses data of the transition piece from each turbine. :param mp_lumped_mass: Dataframe of the lumped masses data of the monopile from each turbine. :param tp_distributed_mass: Dataframe of the distributed masses data of the transition piece from each turbine. :param mp_distributed_mass: Dataframe of the distributed masses data of the monopile from each turbine. :param grout: Dataframe of the grout data from each turbine. :param full_structure: Dataframe of the full structure data from each turbine. :param tp_skirt: Dataframe of the transition piece skirt data from each turbine. :param substructure: Dataframe of the substructure data from each turbine. :param all_turbines: Dataframe of the general geometry data from each turbine. :param all_tubular_structures: Dataframe of the tubular structures data from each turbine. :param all_distributed_mass: Dataframe of the distributed masses data from each turbine. :param all_lumped_mass: Dataframe of the lumped masses data from each turbine.
Create an instance of the OWTs class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
list of str
|
List of turbine titles. |
required |
owts
|
list of OWT
|
List of OWT objects. |
required |
Examples:
>>> from types import SimpleNamespace
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> owts.api
'api'
Source code in src/owi/metadatabase/geometry/processing.py
Functions¶
process_structures ¶
Set dataframes with required properties to model the tower.
Sets dataframes containing the required properties to model the tower geometry, including the RNA system.
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={"TW": 1, "TP": 1, "MP": 1},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... process_structure=lambda *args, **kwargs: None,
... extend_dfs=lambda *args, **kwargs: None,
... pile_toe=0.0,
... rna=None,
... tower=None,
... transition_piece=None,
... monopile=None,
... tw_lumped_mass=None,
... tp_lumped_mass=None,
... mp_lumped_mass=None,
... tp_distributed_mass=None,
... mp_distributed_mass=None,
... grout=None,
... full_structure=None,
... tp_skirt=None,
... substructure=None,
... all_tubular_structures=None,
... all_distributed_mass=None,
... all_lumped_mass=None,
... all_turbines=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> with mock.patch.object(OWTs, "_concat_list", lambda self, attrs: None), mock.patch.object(
... OWTs, "_assembly_turbine", lambda self: None
... ):
... owts.process_structures()
>>> owts._init
True
Source code in src/owi/metadatabase/geometry/processing.py
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 | |
select_owt ¶
Select OWT object from the OWTs object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbine
|
str or int
|
Title of the turbine or its index in the original list of turbine titles (from get method). |
required |
Returns:
| Type | Description |
|---|---|
OWT
|
OWT object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If turbine must be specified as single turbine title or its index from the get method input turbine list. |
Examples:
>>> from types import SimpleNamespace
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> owts.select_owt("T01") is stub
True
Source code in src/owi/metadatabase/geometry/processing.py
geometry.io — API Client¶
io ¶
Module to connect to the database API to retrieve and operate on geometry data.
Classes¶
GeometryAPI ¶
Bases: API
Class to connect to the geometry data API with methods to retrieve data.
Create an instance of the GeometryAPI class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_subdir
|
str
|
Subdirectory of the API endpoint url for specific type of data. |
'/geometry/userroutes/'
|
**kwargs
|
Additional parameters to pass to the API (see the base class). |
{}
|
Examples:
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> api.api_root.endswith("/geometry/userroutes/")
True
Source code in src/owi/metadatabase/geometry/io.py
Functions¶
Get all relevant model definitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_model_definitions(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
Get the ID of a model definition.
Either the asset location or the project site must be specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assetlocation
|
str
|
Title of the asset location. |
None
|
projectsite
|
str
|
Title of the projectsite. |
None
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If at least one of assetlocation or projectsite is not specified, if no location found, if no model definitions found, if multiple model definitions found without specification, or if specified model definition not found. |
Examples:
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> api.get_modeldefinition_id()
Traceback (most recent call last):
...
ValueError: At least either of the related ... must be specified!
Source code in src/owi/metadatabase/geometry/io.py
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 | |
get_subassemblies(
projectsite=None,
assetlocation=None,
subassembly_type=None,
model_definition=None,
)
Get all relevant structure subassemblies.
If you specify a model definition, you also must specify either the projectsite or the asset location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
assetlocation
|
str
|
Title of the asset location. |
None
|
subassembly_type
|
str
|
Type of the subassembly. |
None
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If model definition specified without projectsite or assetlocation, or if specified model definition not found. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_subassemblies(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
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 | |
get_buildingblocks(
projectsite=None,
assetlocation=None,
subassembly_type=None,
subassembly_id=None,
)
Get all relevant building blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Title of the projectsite. |
None
|
assetlocation
|
str
|
Title of the asset location. |
None
|
subassembly_type
|
str
|
Type of the subassemblies (e.g. 'MP', 'TW', 'TP'). |
None
|
subassembly_id
|
int or int64
|
ID of the subassembly. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_buildingblocks(projectsite="Site")
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
Get all the materials of building blocks.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> df = pd.DataFrame({"id": [1]})
>>> with mock.patch.object(
... GeometryAPI,
... "process_data",
... return_value=(df, {"existance": True}),
... ):
... out = api.get_materials()
>>> out["exists"]
True
Source code in src/owi/metadatabase/geometry/io.py
Get all subassemblies for a given turbine, divided by type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbine
|
str
|
Turbine title. |
required |
subassembly
|
str
|
Sub-assembly type (e.g. 'MP', 'TW', 'TP'). |
None
|
model_definition_id
|
int or int64
|
ID of the model definition to filter the subassemblies. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no subassemblies found for the turbine or if no materials found in the database. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> materials = pd.DataFrame(
... [
... {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
... ]
... )
>>> item = {
... "id": np.int64(1),
... "title": "SA_1",
... "description": "",
... "slug": "sa",
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "subassembly_type": "TW",
... "source": "api",
... "asset": np.int64(1),
... "model_definition": np.int64(1),
... }
>>> response = SimpleNamespace(
... status_code=200,
... reason="OK",
... json=lambda: [item],
... )
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> with mock.patch.object(
... GeometryAPI,
... "send_request",
... return_value=response,
... ), mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ):
... out = api.get_subassembly_objects("T01")
>>> sorted(out.keys())
['TW']
Source code in src/owi/metadatabase/geometry/io.py
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 457 458 459 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 | |
Return the required processing class.
Will return data even if some turbines have issues given that at least one is fully OK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
str or list of str
|
Title(s) of the turbines. |
required |
model_definition
|
str
|
Title of the model definition. |
None
|
tower_base
|
float or list of float
|
Height(s) of the tower base. |
None
|
monopile_head
|
float or list of float
|
Height(s) of the monopile head. |
None
|
Returns:
| Type | Description |
|---|---|
OWTs
|
Object containing information about all the requested turbines. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no materials found in the database or if all turbines encounter processing errors. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> materials = pd.DataFrame({"id": [1]})
>>> location = pd.DataFrame({"projectsite_name": ["Site"]})
>>> subassemblies = pd.DataFrame({"subassembly_type": ["TW"]})
>>> def _make_owt(*args, **kwargs):
... return "owt"
>>> def _make_owts(turbines, owts):
... return {"turbines": turbines, "owts": owts}
>>> with mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ), mock.patch.object(
... api.loc_api,
... "get_assetlocation_detail",
... return_value={"exists": True, "data": location},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": subassemblies},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch(
... "geometry.io.OWT",
... _make_owt,
... ), mock.patch(
... "geometry.io.OWTs",
... _make_owts,
... ):
... out = api.get_owt_geometry_processor("T01")
>>> out["turbines"]
['T01']
Source code in src/owi/metadatabase/geometry/io.py
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 | |
Return a dataframe with the monopile geometry.
Uses the mudline as reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projectsite
|
str
|
Name of the project site. |
required |
assetlocation
|
str
|
Name of the wind turbine location. |
required |
cutoff_point
|
float
|
Elevation of the load application point in (mLAT) above the mudline. |
nan
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the monopile geometry. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no subassemblies or location found for turbine. |
Examples:
>>> from unittest import mock
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> bbs = pd.DataFrame(
... [
... {
... "z_position": 0,
... "material_name": "Steel",
... "density": 7850.0,
... "wall_thickness": 20.0,
... "bottom_outer_diameter": 6.0,
... "top_outer_diameter": 6.0,
... "youngs_modulus": 210000.0,
... "poissons_ratio": 0.3,
... },
... {
... "z_position": -1000,
... "material_name": "Steel",
... "density": 7850.0,
... "wall_thickness": 20.0,
... "bottom_outer_diameter": 6.0,
... "top_outer_diameter": 6.0,
... "youngs_modulus": 210000.0,
... "poissons_ratio": 0.3,
... },
... ]
... )
>>> sas = pd.DataFrame({"z_position": [-50000]})
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> with mock.patch.object(
... GeometryAPI,
... "get_buildingblocks",
... return_value={"exists": True, "data": bbs},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": sas},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch.object(
... api.loc_api,
... "get_assetlocation_detail",
... return_value={"exists": True, "data": location},
... ):
... pile = api.get_monopile_pyles("Site", "T01")
>>> "Depth from [m]" in pile.columns
True
Source code in src/owi/metadatabase/geometry/io.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | |
Plot turbines' frontal geometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
str or list of str
|
Title(s) of the turbines. |
required |
figures_per_line
|
int
|
Number of figures per line, default is 5. |
5
|
return_fig
|
bool
|
Boolean indicating whether to return the figure, default is False. |
False
|
model_definition
|
str
|
Title of the model definition. |
None
|
Returns:
| Type | Description |
|---|---|
Figure or None
|
Plotly figure object with selected turbines front profiles (if requested) or nothing. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no materials or subassemblies found in the database. |
Examples:
>>> from unittest import mock
>>> class _StubSubassembly:
... def __init__(self, *args, **kwargs):
... self.building_blocks = []
... def plotly(self):
... layout = {
... "scene": {},
... "yaxis": {
... "title": {"text": "Height , mm"},
... "scaleanchor": "x",
... "scaleratio": 1,
... "type": "linear",
... },
... }
... return [], layout
>>> api = GeometryAPI(
... api_root="https://example",
... header={"Authorization": "Token test"},
... )
>>> materials = pd.DataFrame({"id": [1]})
>>> subassemblies = pd.DataFrame({"subassembly_type": ["TW"]})
>>> with mock.patch.object(
... GeometryAPI,
... "get_materials",
... return_value={"exists": True, "data": materials},
... ), mock.patch.object(
... GeometryAPI,
... "get_subassemblies",
... return_value={"exists": True, "data": subassemblies},
... ), mock.patch.object(
... GeometryAPI,
... "_check_if_need_modeldef",
... return_value=None,
... ), mock.patch(
... "geometry.io.SubAssembly",
... _StubSubassembly,
... ):
... fig = api.plot_turbines(["T01"], return_fig=True)
>>> fig is not None
True
Source code in src/owi/metadatabase/geometry/io.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | |
Compare two instances of the API class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
object
|
Another instance of the API class or a dictionary. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the instances are equal, False otherwise. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If comparison is not possible due to incompatible types. |
Examples:
>>> api_1 = API(api_root="https://example", token="test")
>>> api_2 = API(api_root="https://example", token="test")
>>> api_1 == api_2
True
Source code in src/owi/metadatabase/io.py
Handle sending appropriate request.
Handles sending appropriate request according to the type of authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
url_params
|
Mapping
|
Parameters to send with the request to the database. |
required |
Returns:
| Type | Description |
|---|---|
Response
|
An instance of the Response object. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If neither header nor username and password are defined. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> response = SimpleNamespace(status_code=200, reason="OK")
>>> with mock.patch("requests.get", return_value=response):
... api = API(api_root="https://example", token="test")
... resp = api.send_request("/projects", {})
>>> resp is response
True
Source code in src/owi/metadatabase/io.py
staticmethod
¶Check status code of the response and provide details.
Checks status code of the response to request and provides details if unexpected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resp
|
Response
|
Instance of the Response object. |
required |
Raises:
| Type | Description |
|---|---|
APIConnectionError
|
If response status code is not 200. |
Examples:
>>> from types import SimpleNamespace
>>> ok = SimpleNamespace(status_code=200, reason="OK")
>>> API.check_request_health(ok)
Source code in src/owi/metadatabase/io.py
staticmethod
¶Transform output to Pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
Raw output of the sent request. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Pandas dataframe of the data from the output. |
Raises:
| Type | Description |
|---|---|
DataProcessingError
|
If failed to decode JSON from API response. |
Examples:
>>> from types import SimpleNamespace
>>> resp = SimpleNamespace(text='[{"a": 1}]')
>>> int(API.output_to_df(resp)["a"].iloc[0])
1
Source code in src/owi/metadatabase/io.py
staticmethod
¶Process dataframe information to extract additional data.
Processes dataframe information to extract the necessary additional data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe of the output data. |
required |
output_type
|
str
|
Expected type (amount) of the data extracted. |
required |
Returns:
| Type | Description |
|---|---|
PostprocessData
|
Dictionary of the additional data extracted. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError
|
If more than one record was returned for 'single' output type, or if output type is not 'single' or 'list'. |
Examples:
Source code in src/owi/metadatabase/io.py
staticmethod
¶Validate the data extracted from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe of the output data. |
required |
data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with corrected data. |
Examples:
Source code in src/owi/metadatabase/io.py
Process output data according to specified request parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_data_type
|
str
|
Type of the data we want to request (according to database model). |
required |
url_params
|
Mapping
|
Parameters to send with the request to the database. |
required |
output_type
|
str
|
Expected type (amount) of the data extracted. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple of dataframe with the requested data and additional data from postprocessing. |
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> response = SimpleNamespace(text="[]", status_code=200, reason="OK")
>>> api = API(api_root="https://example", token="test")
>>> with mock.patch.object(API, "send_request", return_value=response):
... df, info = api.process_data("projects", {}, "list")
>>> df.empty
True
>>> info["existance"]
False
Source code in src/owi/metadatabase/io.py
geometry.processing — Data Processing¶
processing ¶
Module containing the processing functions for the geometry data.
Classes¶
OWT ¶
Class to process the geometry data of a single OWT.
:param api: API object used to call get_* methods. :param materials: Pandas dataframe with the materials data. :param sub_assemblies: Dictionary of the subassemblies. :param tw_sub_assemblies: Pandas dataframe with the tower subassemblies data for a given turbine. :param tp_sub_assemblies: Pandas dataframe with the transition piece subassemblies data for a given turbine. :param mp_sub_assemblies: Pandas dataframe with the monopile subassemblies data for a given turbine. :param tower_base: Elevation of the OWT tower base in mLAT. :param pile_head: Elevation of the pile head in mLAT. :param water_depth: Water depth in mLAT. :param pile_toe: Elevation of the pile toe in mLAT. :param rna: Pandas dataframe with the RNA data. :param tower: Pandas dataframe with the tower data. :param transition_piece: Pandas dataframe with the transition piece data. :param monopile: Pandas dataframe with the monopile data. :param tw_lumped_mass: Pandas dataframe with the lumped masses data for the tower. :param tp_lumped_mass: Pandas dataframe with the lumped masses data for the transition piece. :param mp_lumped_mass: Pandas dataframe with the lumped masses data for the monopile. :param tp_distributed_mass: Pandas dataframe with the distributed masses data for the transition piece. :param mp_distributed_mass: Pandas dataframe with the distributed masses data for the monopile. :param grout: Pandas dataframe with the grout data. :param full_structure: Pandas dataframe with the full structure data. :param tp_skirt: Pandas dataframe with the transition piece skirt data. :param substructure: Pandas dataframe with the substructure data.
Create an instance of the OWT class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
Any
|
API object used to call get_* methods. |
required |
materials
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the materials data. |
required |
subassemblies
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the subassemblies data for a given turbine. |
required |
location
|
DataFrame or bool or int64 or None
|
Pandas dataframe with the location data for a given turbine. |
required |
tower_base
|
float64
|
Elevation of the OWT tower base in mLAT. |
None
|
pile_head
|
float64
|
Elevation of the pile head in mLAT. |
None
|
Examples:
>>> from contextlib import ExitStack
>>> from unittest import mock
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> def _set_subassemblies(self, subassemblies):
... self.sub_assemblies = {}
>>> def _set_members(self):
... return None
>>> with mock.patch.object(
... OWT,
... "_set_subassemblies",
... _set_subassemblies,
... ), mock.patch.object(OWT, "_set_members", _set_members):
... owt = OWT(
... api=object(),
... materials=pd.DataFrame(),
... subassemblies=pd.DataFrame(),
... location=location,
... )
>>> float(owt.water_depth)
30.0
Source code in src/owi/metadatabase/geometry/processing.py
95 96 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 | |
Functions¶
Calculate and/or convert geometrical data of subassemblies.
Calculates and/or converts geometrical data of subassemblies from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Possible index to identify corresponding subassembly. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing geometry data from database with z in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index. |
Source code in src/owi/metadatabase/geometry/processing.py
Calculate and/or convert geometrical data for FE models.
Calculates and/or converts geometrical data of subassemblies from the database to use as input for FE models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Possible index to identify corresponding subassembly. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe consisting of the required data to build FE models. |
Source code in src/owi/metadatabase/geometry/processing.py
Set dataframe with required properties to model the RNA system.
Raises:
| Type | Description |
|---|---|
ValueError
|
If tower subassembly data not found. |
Source code in src/owi/metadatabase/geometry/processing.py
Set dataframe with required properties for concentrated masses.
Sets dataframe containing the required properties to model concentrated masses from database subassemblies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing lumped masses data from database with Z coordinates in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index. |
Source code in src/owi/metadatabase/geometry/processing.py
Create dataframe with required properties for lumped masses.
Creates dataframe containing the required properties to model lumped mass appurtenances. Note that if the preprocessor package does not find any appurtenances it'll return an empty dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with lumped mass properties. |
Source code in src/owi/metadatabase/geometry/processing.py
Set dataframe with required properties for distributed masses.
Sets dataframe containing the required properties to model distributed lumped masses from database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TW', 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe containing distributed lumped masses data from database. Z coordinates in mLAT system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If subassembly data not found or unknown index or distributed lumped masses located outside the transition piece. |
Source code in src/owi/metadatabase/geometry/processing.py
Create dataframe with uniformly distributed appurtenances.
Creates dataframe containing the required properties to model uniformly distributed appurtenances. Note that if the preprocessor package does not find any appurtenances it'll return an empty dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
str
|
Index to identify corresponding subassembly with possible values: 'TP', 'MP'. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with distributed lumped mass properties. |
Source code in src/owi/metadatabase/geometry/processing.py
Set dataframe with required properties to model the tower.
Sets dataframe containing the required properties to model the tower geometry, including the RNA system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
option
|
str
|
Option to process the data for a specific subassembly. Possible values:
|
'full'
|
Examples:
>>> from contextlib import ExitStack
>>> from unittest import mock
>>> location = pd.DataFrame({"elevation": [30.0]})
>>> def _set_subassemblies(self, subassemblies):
... self.sub_assemblies = {}
>>> def _set_members(self):
... return None
>>> with mock.patch.object(
... OWT,
... "_set_subassemblies",
... _set_subassemblies,
... ), mock.patch.object(OWT, "_set_members", _set_members):
... owt = OWT(
... api=object(),
... materials=pd.DataFrame(),
... subassemblies=pd.DataFrame(),
... location=location,
... )
>>> empty_df = pd.DataFrame()
>>> with ExitStack() as stack:
... _ = stack.enter_context(mock.patch.object(OWT, "process_rna"))
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_structure_geometry",
... return_value=empty_df,
... )
... )
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_lumped_masses",
... return_value=empty_df,
... )
... )
... _ = stack.enter_context(
... mock.patch.object(
... OWT,
... "process_distributed_lumped_masses",
... return_value=empty_df,
... )
... )
... owt.process_structure(option="TW")
>>> owt._init_proc
True
Source code in src/owi/metadatabase/geometry/processing.py
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 | |
staticmethod
¶Recalculate can properties based on section and elevations.
Recalculation of can properties based on section properties and can elevations: height [m], volume [m3], mass [t], rho [t/m].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
Original can properties. |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Pandas series of recalculated can properties. |
Examples:
>>> row = pd.Series(
... {
... "Mass [t]": 10.0,
... "Volume [m3]": 5.0,
... "Elevation from [mLAT]": 10.0,
... "Elevation to [mLAT]": 0.0,
... "Diameter from [m]": 6.0,
... "Diameter to [m]": 6.0,
... "Wall thickness [mm]": 10.0,
... }
... )
>>> out = OWT.can_adjust_properties(row)
>>> float(out["Height [m]"])
10.0
Source code in src/owi/metadatabase/geometry/processing.py
Change can properties based on the altitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Dataframe containing the can properties. |
required |
altitude
|
float64 or None
|
Altitude in mLAT. |
required |
position
|
str
|
Position of the can with respect to the altitude with possible values: "bottom" or "top", default is "bottom". |
'bottom'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the modified can properties. |
Examples:
>>> df = pd.DataFrame(
... {
... "Elevation from [mLAT]": [10.0],
... "Elevation to [mLAT]": [0.0],
... "Diameter from [m]": [6.0],
... "Diameter to [m]": [6.0],
... "Wall thickness [mm]": [10.0],
... "Volume [m3]": [5.0],
... "Mass [t]": [10.0],
... "rho [t/m]": [1.0],
... },
... index=["A"],
... )
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(can_adjust_properties=OWT.can_adjust_properties)
>>> out = OWT.can_modification(helper, df.copy(), np.float64(5.0))
>>> float(out["Elevation to [mLAT]"].iloc[0])
5.0
Source code in src/owi/metadatabase/geometry/processing.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | |
Process TP structural item to assembly with MP foundation.
Processes TP structural item to assembly with MP foundation ensuring continuity. TP skirt is processed as well.
Raises:
| Type | Description |
|---|---|
TypeError
|
If TP or MP items need to be processed before. |
Examples:
>>> from types import SimpleNamespace
>>> import pandas as pd
>>> helper = SimpleNamespace(
... transition_piece=None,
... monopile=None,
... _init_spec_part=False,
... )
>>> OWT.assembly_tp_mp(helper)
Traceback (most recent call last):
...
TypeError: TP or MP items need to be processed before!
>>> tp = pd.DataFrame(
... {
... "Elevation from [mLAT]": [6.0, 0.0],
... "Elevation to [mLAT]": [8.0, 4.0],
... "Diameter from [m]": [6.0, 6.0],
... "Diameter to [m]": [6.0, 6.0],
... "Wall thickness [mm]": [10.0, 10.0],
... "Volume [m3]": [5.0, 5.0],
... "Mass [t]": [10.0, 10.0],
... "rho [t/m]": [1.0, 1.0],
... }
... )
>>> mp = pd.DataFrame(
... {
... "Elevation from [mLAT]": [0.0],
... "Elevation to [mLAT]": [-10.0],
... "Diameter from [m]": [6.0],
... "Diameter to [m]": [6.0],
... "Wall thickness [mm]": [10.0],
... "Volume [m3]": [5.0],
... "Mass [t]": [10.0],
... "rho [t/m]": [1.0],
... }
... )
>>> helper = SimpleNamespace(
... transition_piece=tp,
... monopile=mp,
... pile_head=5.0,
... substructure=None,
... tp_skirt=None,
... _init_spec_part=False,
... )
>>> helper.can_adjust_properties = OWT.can_adjust_properties
>>> helper.can_modification = lambda df, altitude, position="bottom": OWT.can_modification(
... helper,
... df,
... altitude,
... position=position,
... )
>>> OWT.assembly_tp_mp(helper)
>>> helper.substructure is not None
True
>>> helper.tp_skirt is not None
True
Source code in src/owi/metadatabase/geometry/processing.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | |
Process the full structure of the OWT.
Processes the full structure of the OWT: tower + tp combination with monopile.
Raises:
| Type | Description |
|---|---|
TypeError
|
If tower or substructure needs to be processed before. |
Examples:
>>> import pandas as pd
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(
... substructure=pd.DataFrame({"Height [m]": [1.0]}),
... tower=pd.DataFrame({"Height [m]": [2.0]}),
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
>>> float(helper.full_structure["Height [m]"].sum())
3.0
>>> helper._init_spec_full
True
>>> helper = SimpleNamespace(
... substructure=None,
... tower=None,
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
Traceback (most recent call last):
...
TypeError: Substructure needs to be processed before!
>>> helper = SimpleNamespace(
... substructure=pd.DataFrame({"Height [m]": [1.0]}),
... tower=None,
... _init_spec_full=False,
... )
>>> OWT.assembly_full_structure(helper)
Traceback (most recent call last):
...
TypeError: Tower needs to be processed before!
Source code in src/owi/metadatabase/geometry/processing.py
Extend the dataframes with the subassembly columns.
Examples:
>>> import pandas as pd
>>> from types import SimpleNamespace
>>> helper = SimpleNamespace(
... pile_toe=None,
... rna=None,
... tower=pd.DataFrame({"Height [m]": [1.0]}),
... transition_piece=None,
... monopile=None,
... tw_lumped_mass=None,
... tp_lumped_mass=None,
... mp_lumped_mass=None,
... tp_distributed_mass=None,
... mp_distributed_mass=None,
... grout=None,
... sub_assemblies={},
... substructure=None,
... tp_skirt=None,
... full_structure=None,
... _init_spec_part=False,
... _init_spec_full=False,
... )
>>> OWT.extend_dfs(helper)
>>> helper.tower["Subassembly"].iloc[0]
'TW'
>>> helper.tp_skirt is None
True
Source code in src/owi/metadatabase/geometry/processing.py
Return a dataframe with monopile geometry.
Returns a dataframe with the monopile geometry with the mudline as reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cutoff_point
|
floating
|
Depth from the mudline to cut the monopile geometry. |
nan
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with the monopile geometry. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If monopile subassembly data not found. |
Source code in src/owi/metadatabase/geometry/processing.py
OWTs ¶
Class to process the geometry data of multiple OWTs.
:param owts: List of OWT objects. :param api: API object used to call get_* methods. :param materials: Pandas dataframe with the materials data. :param sub_assemblies: Dictionary of dictionaries of the subassemblies for each turbine. :param tower_base: Dictionary of the elevation of the OWT tower base in mLAT for each turbine. :param pile_head: Dictionary of the elevation of the pile head in mLAT for each turbine. :param water_depth: Dictionary of the water depth in mLAT for each turbine. :param tw_sub_assemblies: Dataframe of the tower subassemblies data from each turbine. :param tp_sub_assemblies: Dataframe of the transition piece subassemblies data from each turbine. :param mp_sub_assemblies: Dataframe of the monopile subassemblies data from each turbine. :param pile_toe: Dataframe of the elevation of the pile toe in mLAT from each turbine. :param rna: Dataframe of the RNA data from each turbine. :param tower: Dataframe of the tower data from each turbine. :param transition_piece: Dataframe of the transition piece data from each turbine. :param monopile: Dataframe of the monopile data from each turbine. :param tw_lumped_mass: Dataframe of the lumped masses data of the tower from each turbine. :param tp_lumped_mass: Dataframe of the lumped masses data of the transition piece from each turbine. :param mp_lumped_mass: Dataframe of the lumped masses data of the monopile from each turbine. :param tp_distributed_mass: Dataframe of the distributed masses data of the transition piece from each turbine. :param mp_distributed_mass: Dataframe of the distributed masses data of the monopile from each turbine. :param grout: Dataframe of the grout data from each turbine. :param full_structure: Dataframe of the full structure data from each turbine. :param tp_skirt: Dataframe of the transition piece skirt data from each turbine. :param substructure: Dataframe of the substructure data from each turbine. :param all_turbines: Dataframe of the general geometry data from each turbine. :param all_tubular_structures: Dataframe of the tubular structures data from each turbine. :param all_distributed_mass: Dataframe of the distributed masses data from each turbine. :param all_lumped_mass: Dataframe of the lumped masses data from each turbine.
Create an instance of the OWTs class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbines
|
list of str
|
List of turbine titles. |
required |
owts
|
list of OWT
|
List of OWT objects. |
required |
Examples:
>>> from types import SimpleNamespace
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> owts.api
'api'
Source code in src/owi/metadatabase/geometry/processing.py
Functions¶
Set dataframes with required properties to model the tower.
Sets dataframes containing the required properties to model the tower geometry, including the RNA system.
Examples:
>>> from types import SimpleNamespace
>>> from unittest import mock
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={"TW": 1, "TP": 1, "MP": 1},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... process_structure=lambda *args, **kwargs: None,
... extend_dfs=lambda *args, **kwargs: None,
... pile_toe=0.0,
... rna=None,
... tower=None,
... transition_piece=None,
... monopile=None,
... tw_lumped_mass=None,
... tp_lumped_mass=None,
... mp_lumped_mass=None,
... tp_distributed_mass=None,
... mp_distributed_mass=None,
... grout=None,
... full_structure=None,
... tp_skirt=None,
... substructure=None,
... all_tubular_structures=None,
... all_distributed_mass=None,
... all_lumped_mass=None,
... all_turbines=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> with mock.patch.object(OWTs, "_concat_list", lambda self, attrs: None), mock.patch.object(
... OWTs, "_assembly_turbine", lambda self: None
... ):
... owts.process_structures()
>>> owts._init
True
Source code in src/owi/metadatabase/geometry/processing.py
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 | |
Select OWT object from the OWTs object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turbine
|
str or int
|
Title of the turbine or its index in the original list of turbine titles (from get method). |
required |
Returns:
| Type | Description |
|---|---|
OWT
|
OWT object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If turbine must be specified as single turbine title or its index from the get method input turbine list. |
Examples:
>>> from types import SimpleNamespace
>>> stub = SimpleNamespace(
... api="api",
... materials="materials",
... sub_assemblies={},
... tower_base=0.0,
... pile_head=0.0,
... water_depth=0.0,
... tw_sub_assemblies=None,
... tp_sub_assemblies=None,
... mp_sub_assemblies=None,
... )
>>> owts = OWTs(["T01"], [stub])
>>> owts.select_owt("T01") is stub
True
Source code in src/owi/metadatabase/geometry/processing.py
Functions¶
geometry.structures — Data Structures¶
structures ¶
Module containing the data classes for the geometry module.
Classes¶
BaseStructure ¶
Base class for all structures.
Material ¶
Bases: BaseStructure
Material derived from the raw data.
Create an instance of the Material class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
DataMat
|
JSON data containing the material information. |
required |
Examples:
>>> data = {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
>>> material = Material(data)
>>> material.title
'Steel'
Source code in src/owi/metadatabase/geometry/structures.py
Functions¶
Transform data into dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Examples:
>>> data = {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
>>> Material(data).as_dict()["title"]
'Steel'
Source code in src/owi/metadatabase/geometry/structures.py
Position ¶
Position(
x=DEFAULT_NP_FLOAT64_VALUE,
y=DEFAULT_NP_FLOAT64_VALUE,
z=DEFAULT_NP_FLOAT64_VALUE,
alpha=DEFAULT_NP_FLOAT64_VALUE,
beta=DEFAULT_NP_FLOAT64_VALUE,
gamma=DEFAULT_NP_FLOAT64_VALUE,
reference_system="LAT",
)
Bases: BaseStructure
Position of the components.
Create an instance of the Position class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float64
|
X coordinate of the component. |
DEFAULT_NP_FLOAT64_VALUE
|
y
|
float64
|
Y coordinate of the component. |
DEFAULT_NP_FLOAT64_VALUE
|
z
|
float64
|
Z coordinate of the component. |
DEFAULT_NP_FLOAT64_VALUE
|
alpha
|
float64
|
Rotation around the x-axis. |
DEFAULT_NP_FLOAT64_VALUE
|
beta
|
float64
|
Rotation around the y-axis. |
DEFAULT_NP_FLOAT64_VALUE
|
gamma
|
float64
|
Rotation around the z-axis. |
DEFAULT_NP_FLOAT64_VALUE
|
reference_system
|
str
|
Reference system for the vertical position, default is "LAT". |
'LAT'
|
Examples:
>>> pos = Position(np.float64(1), np.float64(2), np.float64(3))
>>> tuple(map(float, (pos.x, pos.y, pos.z)))
(1.0, 2.0, 3.0)
Source code in src/owi/metadatabase/geometry/structures.py
Functions¶
BuildingBlock ¶
Bases: BaseStructure
Building blocks description.
Create an instance of the BuildingBlock class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json
|
DataBB
|
JSON data containing the building block information. |
required |
subassembly
|
Any
|
Subassembly object containing the building block. |
None
|
Examples:
>>> data = {
... "id": np.int64(1),
... "description": "",
... "slug": "bb",
... "alpha": np.float64(0),
... "beta": np.float64(0),
... "gamma": np.float64(0),
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "title": "BB_1",
... "height": np.float64(0),
... "mass_distribution": np.float64(np.nan),
... "volume_distribution": np.float64(np.nan),
... "area_distribution": np.float64(np.nan),
... "c_d": np.float64(np.nan),
... "c_m": np.float64(np.nan),
... "sub_assembly": np.int64(1),
... "projectsite_name": "Site",
... "asset_name": "T01",
... "subassembly_name": "SA",
... "material_name": "Steel",
... "youngs_modulus": np.float64(np.nan),
... "density": np.float64(np.nan),
... "poissons_ratio": np.float64(np.nan),
... "bottom_outer_diameter": np.float64(np.nan),
... "top_outer_diameter": np.float64(np.nan),
... "wall_thickness": np.float64(np.nan),
... "material": np.float64(np.nan),
... "moment_of_inertia_x": np.float64(1.0),
... "moment_of_inertia_y": np.float64(2.0),
... "moment_of_inertia_z": np.float64(3.0),
... "mass": np.float64(100.0),
... }
>>> BuildingBlock(data).title
'BB_1'
Source code in src/owi/metadatabase/geometry/structures.py
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 | |
Attributes¶
property
¶Type of the building block.
Examples:
>>> data = {
... "id": np.int64(1),
... "description": "",
... "slug": "bb",
... "alpha": np.float64(0),
... "beta": np.float64(0),
... "gamma": np.float64(0),
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "title": "BB_1",
... "height": np.float64(0),
... "mass_distribution": np.float64(np.nan),
... "volume_distribution": np.float64(np.nan),
... "area_distribution": np.float64(np.nan),
... "c_d": np.float64(np.nan),
... "c_m": np.float64(np.nan),
... "sub_assembly": np.int64(1),
... "projectsite_name": "Site",
... "asset_name": "T01",
... "subassembly_name": "SA",
... "material_name": "Steel",
... "youngs_modulus": np.float64(np.nan),
... "density": np.float64(np.nan),
... "poissons_ratio": np.float64(np.nan),
... "bottom_outer_diameter": np.float64(np.nan),
... "top_outer_diameter": np.float64(np.nan),
... "wall_thickness": np.float64(np.nan),
... "material": np.float64(np.nan),
... "moment_of_inertia_x": np.float64(1.0),
... "moment_of_inertia_y": np.float64(2.0),
... "moment_of_inertia_z": np.float64(3.0),
... "mass": np.float64(100.0),
... }
>>> BuildingBlock(data).type
'lumped_mass'
property
¶Bottom outer diameter of the building block (if exists), mm.
property
¶Top outer diameter of the building block (if exists), mm.
property
¶Mass of the building block, kg.
Examples:
>>> data = {
... "id": np.int64(1),
... "description": "",
... "slug": "bb",
... "alpha": np.float64(0),
... "beta": np.float64(0),
... "gamma": np.float64(0),
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "title": "BB_1",
... "height": np.float64(0),
... "mass_distribution": np.float64(np.nan),
... "volume_distribution": np.float64(np.nan),
... "area_distribution": np.float64(np.nan),
... "c_d": np.float64(np.nan),
... "c_m": np.float64(np.nan),
... "sub_assembly": np.int64(1),
... "projectsite_name": "Site",
... "asset_name": "T01",
... "subassembly_name": "SA",
... "material_name": "Steel",
... "youngs_modulus": np.float64(np.nan),
... "density": np.float64(np.nan),
... "poissons_ratio": np.float64(np.nan),
... "bottom_outer_diameter": np.float64(np.nan),
... "top_outer_diameter": np.float64(np.nan),
... "wall_thickness": np.float64(np.nan),
... "material": np.float64(np.nan),
... "moment_of_inertia_x": np.float64(1.0),
... "moment_of_inertia_y": np.float64(2.0),
... "moment_of_inertia_z": np.float64(3.0),
... "mass": np.float64(100.0),
... }
>>> float(BuildingBlock(data).mass)
100.0
property
¶Moment of inertia of the building block, kg*m².
IMPORTANT! Only works for building blocks of the type lumped_mass.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing the moment of inertia around the three axes, x, y, z. |
Examples:
>>> data = {
... "id": np.int64(1),
... "description": "",
... "slug": "bb",
... "alpha": np.float64(0),
... "beta": np.float64(0),
... "gamma": np.float64(0),
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "title": "BB_1",
... "height": np.float64(0),
... "mass_distribution": np.float64(np.nan),
... "volume_distribution": np.float64(np.nan),
... "area_distribution": np.float64(np.nan),
... "c_d": np.float64(np.nan),
... "c_m": np.float64(np.nan),
... "sub_assembly": np.int64(1),
... "projectsite_name": "Site",
... "asset_name": "T01",
... "subassembly_name": "SA",
... "material_name": "Steel",
... "youngs_modulus": np.float64(np.nan),
... "density": np.float64(np.nan),
... "poissons_ratio": np.float64(np.nan),
... "bottom_outer_diameter": np.float64(np.nan),
... "top_outer_diameter": np.float64(np.nan),
... "wall_thickness": np.float64(np.nan),
... "material": np.float64(np.nan),
... "moment_of_inertia_x": np.float64(1.0),
... "moment_of_inertia_y": np.float64(2.0),
... "moment_of_inertia_z": np.float64(3.0),
... "mass": np.float64(100.0),
... }
>>> float(BuildingBlock(data).moment_of_inertia["y"])
2.0
property
¶Trace of the outlines.
Returns:
| Type | Description |
|---|---|
tuple or None
|
A tuple of two lists containing the x and corresponding z coordinates of the outline, or None if not applicable. |
property
¶Indication for the lumped mass in the building block.
Returns:
| Type | Description |
|---|---|
dict or None
|
Dictionary containing the x, y, z coordinates of the marker and the radius of the marker, or None if not applicable. |
property
¶Line for the distributed mass in the building block.
Returns:
| Type | Description |
|---|---|
dict or None
|
Dictionary containing the x, y, z coordinates of the line and the color of the line, or None if not applicable. |
Functions¶
Transform data into dictionary.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with the following keys:
|
Source code in src/owi/metadatabase/geometry/structures.py
Examples:
>>> data = {
... "id": np.int64(1),
... "description": "",
... "slug": "bb",
... "alpha": np.float64(0),
... "beta": np.float64(0),
... "gamma": np.float64(0),
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "title": "BB_1",
... "height": np.float64(0),
... "mass_distribution": np.float64(np.nan),
... "volume_distribution": np.float64(np.nan),
... "area_distribution": np.float64(np.nan),
... "c_d": np.float64(np.nan),
... "c_m": np.float64(np.nan),
... "sub_assembly": np.int64(1),
... "projectsite_name": "Site",
... "asset_name": "T01",
... "subassembly_name": "SA",
... "material_name": "Steel",
... "youngs_modulus": np.float64(np.nan),
... "density": np.float64(np.nan),
... "poissons_ratio": np.float64(np.nan),
... "bottom_outer_diameter": np.float64(np.nan),
... "top_outer_diameter": np.float64(np.nan),
... "wall_thickness": np.float64(np.nan),
... "material": np.float64(np.nan),
... "moment_of_inertia_x": np.float64(1.0),
... "moment_of_inertia_y": np.float64(2.0),
... "moment_of_inertia_z": np.float64(3.0),
... "mass": np.float64(100.0),
... }
>>> str(BuildingBlock(data))
'BB_1 (lumped_mass)'
Source code in src/owi/metadatabase/geometry/structures.py
SubAssembly ¶
Bases: BaseStructure
Subassemblies description.
Create an instance of the SubAssembly class with required parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
materials
|
DataFrame or bool or int64 or None
|
Pandas dataframe containing the material information. |
required |
json
|
DataSA
|
JSON data containing the subassembly information. |
required |
api_object
|
Any
|
API object to access the building blocks. |
None
|
Examples:
>>> materials = pd.DataFrame([
... {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
... ])
>>> data = {
... "id": np.int64(1),
... "title": "SA_1",
... "description": "",
... "slug": "sa",
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "subassembly_type": "TW",
... "source": "api",
... "asset": np.int64(1),
... "model_definition": np.int64(1),
... }
>>> sa = SubAssembly(materials, data)
>>> sa.title
'SA_1'
Source code in src/owi/metadatabase/geometry/structures.py
Attributes¶
property
¶Color based on subassembly type.
Examples:
>>> materials = pd.DataFrame([
... {
... "title": "Steel",
... "slug": "steel",
... "id": np.int64(1),
... "description": "",
... "young_modulus": np.float64(210000.0),
... "density": np.float64(7850.0),
... "poisson_ratio": np.float64(0.3),
... }
... ])
>>> data = {
... "id": np.int64(1),
... "title": "SA_1",
... "description": "",
... "slug": "sa",
... "x_position": np.float64(0),
... "y_position": np.float64(0),
... "z_position": np.float64(0),
... "vertical_position_reference_system": "LAT",
... "subassembly_type": "TW",
... "source": "api",
... "asset": np.int64(1),
... "model_definition": np.int64(1),
... }
>>> SubAssembly(materials, data).color
'grey'
property
¶Building blocks of the subassembly.
Returns:
| Type | Description |
|---|---|
list of BuildingBlock or None
|
List of instances of building block class. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no API configured or no building blocks found. |
property
¶Defines the traces of the outline of the subassembly.
Returns:
| Type | Description |
|---|---|
tuple
|
A tuple of two lists containing the x and corresponding z coordinates of the outline. |
Functions¶
Plot the subassembly.
Source code in src/owi/metadatabase/geometry/structures.py
Plot the subassembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_offset
|
float64
|
Offset in the x direction. |
DEFAULT_NP_FLOAT64_VALUE
|
y_offset
|
float64
|
Offset in the y direction. |
DEFAULT_NP_FLOAT64_VALUE
|
Returns:
| Type | Description |
|---|---|
tuple
|
Plotly data and layout. |
Source code in src/owi/metadatabase/geometry/structures.py
Transform data into pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_absolute_postion
|
bool
|
Include absolute position of the building blocks, default is False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Pandas dataframe with the building block information. |
Source code in src/owi/metadatabase/geometry/structures.py
Return a string representation of the subassembly.