Skip to content

Commit

Permalink
fix notebook example
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarter committed Jan 21, 2025
1 parent 17b5b9c commit a28d71d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 35 deletions.
75 changes: 41 additions & 34 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -24,7 +24,7 @@
"import pandas as pd\n",
"import ruamel.yaml as ry\n",
"\n",
"from pCrunch import LoadsAnalysis, PowerProduction, FatigueParams, read\n",
"from pCrunch import Crunch, FatigueParams, read\n",
"from pCrunch.utility import save_yaml, get_windspeeds, convert_summary_stats\n",
"\n",
"def valid_extension(fp):\n",
Expand All @@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -134,7 +134,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -173,23 +173,23 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# The API has changed and is in more of an object oriented framework.\n",
"la = LoadsAnalysis(\n",
" outputs, # The primary input is a list of output files\n",
"cruncher = Crunch(\n",
" outputs, # The primary input is a list of output files\n",
" magnitude_channels=magnitude_channels, # All of the following inputs are optional\n",
" fatigue_channels=fatigue_channels, # \n",
" extreme_channels=channel_extremes, #\n",
" trim_data=(0,), # If 'trim_data' is passed, all input files will\n",
") # be trimmed to (tmin, tmax(optional))\n",
"\n",
"la.process_outputs(cores=1, # Once LoadsAnalysis is configured, process outputs with\n",
" return_damage=True, # optional return of Palmgren-Miner damange and\n",
" goodman=True) # optional use of goodman correction for mean load values\n",
" # Note `cores` is optional but will trigger parallel processing if configured"
"cruncher.process_outputs(cores=1, # Once LoadsAnalysis is configured, process outputs with\n",
" return_damage=True, # optional return of Palmgren-Miner damange and\n",
" goodman=True) # optional use of goodman correction for mean load values\n",
" # Note `cores` is optional but will trigger parallel processing if configured"
]
},
{
Expand All @@ -201,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -434,19 +434,19 @@
"[5 rows x 1113 columns]"
]
},
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The summary stats per each file are here:\n",
"la.summary_stats"
"cruncher.summary_stats"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -550,19 +550,19 @@
"DLC2.3_3.out 8986.223847 306007.537691 "
]
},
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# These are indexable by channel, stat:\n",
"la.summary_stats[\"RootMc1\"]"
"cruncher.summary_stats[\"RootMc1\"]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -576,18 +576,18 @@
"Name: (RootMc1, min), dtype: float64"
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"la.summary_stats[(\"RootMc1\", 'min')]"
"cruncher.summary_stats[(\"RootMc1\", 'min')]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -607,19 +607,19 @@
"Name: DLC2.3_1.out, Length: 1113, dtype: float64"
]
},
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Or by file\n",
"la.summary_stats.loc[\"DLC2.3_1.out\"]"
"cruncher.summary_stats.loc[\"DLC2.3_1.out\"]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -692,19 +692,19 @@
"DLC2.3_3.out 5708.372415 5607.452586 2132.788161"
]
},
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Damage equivalent loads are found here:\n",
"la.dels"
"cruncher.dels"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -777,19 +777,19 @@
"DLC2.3_3.out 4.790238e-42 4.007654e-42 2.539284e-46"
]
},
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Palmgren-Miner damage can be viewed with:\n",
"la.damage"
"cruncher.damage"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -963,15 +963,22 @@
" 'RootMc3': 7709.833036454162}]}"
]
},
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Extreme events:\n",
"la.extremes"
"cruncher.extremes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion pCrunch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .analysis import Crunch, FatigueParams
from .crunch import Crunch, FatigueParams
from .openfast_readers import OpenFASTAscii, OpenFASTBinary, load_FAST_out, read
from .aeroelastic_output import AeroelasticOutput

0 comments on commit a28d71d

Please sign in to comment.