(fatigue-extra-04)= # Fatigue Analysis The fatigue extra is a feature that allows the user to analyze cycle-count metrics. ## Installation The extra is compatible with Python versions from 3.8 to 3.10, and installs the [py-fatigue](https://owi-lab.github.io/py_fatigue/) and [swifter](https://github.com/jmcarpenter2/swifter) packages. To install the extra, run the following command in your terminal: ::::{tab-set-code} ```powershell pip install api-24sea[fatigue] ``` ```bash pip install 'api-24sea[fatigue]' ``` :::: ## Usage Suppose you have already defined a {class}`pandas.DataFrame` and authenticated with the API. For instructions on how to do this, refer to the {ref}`getting started tutorial `. ### Importing the fatigue extra ```python # %% # - Local imports from api_24sea.datasignals import fatigue ``` ### Checking the available metrics after authentication If your *Metrics Overview* table shows metrics whose name starts with `CC_`, then the fatigue extra will be available for use. ### Getting data Similar to the data retrieval process described in the {ref}`getting started tutorial `, the data retrieval process for the fatigue extra follows the same steps. The only difference is that the selected metrics must include cycle-counts (CC). ```python # %% # **Data Retrieval** # Besides SCADA data, we will query cycle-count metrics, which are available # by looking for "CC" (cycle-count) and ["Mtn", "Mtl"] (i.e. Normal and # Lateral Bending moment). sites = ["wf"] locations = ["a01", "a02"] metrics = ["mean WinDSpEed", "mean pitch", "mean-Yaw", "mean power", "cc mtn", "cc mtl"] start_timestamp = "2020-03-01T00:00:00Z" end_timestamp = "2020-06-01T00:00:00Z" df.datasignals.get_data(sites, locations, metrics, start_timestamp, end_timestamp, as_dict=False) ``` ### Analyzing cycle-count metrics Converting the cycle-count JSON objects to {class}`py_fatigue.CycleCount` objects is the first step in the fatigue analysis. This is done by calling the {func}`api_24sea.datasignals.fatigue.Fatigue.cycle_counts_to_objects` method. ```python # %% # **Fatigue Analysis** # The fatigue analysis is done by calling the cycle_counts_to_objects() method # from the fatigue accessor. try: df.fatigue.cycle_counts_to_objects() except ImportError as ie: print(f"\033[31;1mImportError\033[22m: {ie}") ``` At this point, you can treat your {class}`py_fatigue.CycleCount` objects as you would normally do with [py-fatigue](https://owi-lab.github.io/py_fatigue/). For more information, check py-fatigue's [beginner's guide](https://owi-lab.github.io/py_fatigue/user/01-absolute-noob.html).