diff --git a/README.md b/README.md index 99450330f46c42d32e59182d82259a3487b0ac44..715fc334c9b296316c7eccc7c94d71d0d376672b 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,11 @@ load calculations, and create load envelopes. Additional documentation can be found here: -- [Auto-generation of Design Load Cases](docs/howto-make-dlcs.md) -- [How to use the Statistics DataFrame](docs/using-statistics-df.md) -- [Generate DLB spreadsheets](docs/generate-spreadsheet.md) - +- [Getting started with DLBs](docs/getting-started-with-dlbs.md) + - [Generate DLB spreadsheets](docs/generate-spreadsheet.md) + - [Auto-generation of Design Load Cases](docs/howto-make-dlcs.md) + - [House rules for storing results on ```mimer/hawc2sim```](docs/houserules-mimerhawc2sim.md) + - [How to use the Statistics DataFrame](docs/using-statistics-df.md) ### [fast](wetb/fast) Tools for working with NREL's FAST code (An aeroelastic computer-aided engineering (CAE) tool for horizontal axis wind turbines) diff --git a/wetb/prepost/dlcdefs.py b/wetb/prepost/dlcdefs.py index 6443ab5d8a127e8ab4cc8fa451dfa018480e4487..2a861991bde576963d7d18a9eaff7e656cb62b85 100644 --- a/wetb/prepost/dlcdefs.py +++ b/wetb/prepost/dlcdefs.py @@ -13,10 +13,9 @@ from future.utils import viewitems from future import standard_library standard_library.install_aliases() - - import os import unittest +from glob import glob import pandas as pd @@ -62,16 +61,30 @@ def configure_dirs(verbose=False): def find_master_file(proot, htc_dir='htc', master_dir='_master', - master_contains='_master_'): + pattern='*_master_*'): """ Find the master file name. It is assumed that the master file is in the - folder _master, under htc, and contains _master_ in the file name. + folder _master, under htc, and contains _master_ in the file name. If + multiple files contain pattern, the last file of the sorted list is + returned. + + Parameters + ---------- + + proot + + htc_dir : str, default: htc + + master_dir : str, default: _master + + pattern : str, default: *_master_* + """ - for root, dirs, files in os.walk(os.path.join(proot, htc_dir, master_dir)): - for fname in files: - if fname.find(master_contains) > -1: - return fname + fpath_search = os.path.join(proot, htc_dir, master_dir, pattern) + files = glob(fpath_search) + if len(files) > 0: + return sorted(files)[-1] return None