Ejemplo n.º 1
0
def make_doc_notebooks(notebooks):
    src_path = os.path.dirname(__file__) + "/elements/"
    dst_path = os.path.dirname(__file__) + "/../docs/notebooks/"
    if os.path.isdir(dst_path):
        try:
            shutil.rmtree(dst_path)

        except PermissionError:
            pass
    os.makedirs(dst_path, exist_ok=True)
    for name in notebooks:
        nb = Notebook(src_path + name + ".ipynb")
        t = '[Try this yourself](https://colab.research.google.com/github/DTUWindEnergy/PyWake/blob/master/docs/notebooks/%s.ipynb) (requires google account)'
        nb.insert_markdown_cell(1, t % name)
        code = """%%capture
# Install PyWake if needed
try:
    import py_wake
except ModuleNotFoundError:
    !pip install py_wake"""
        nb.insert_code_cell(2, code)
        #cells = nb.cells

        #cells = cells[:1] + doc_header(name) + cells[1:]
        #nb['cells'] = cells
        nb.save(dst_path + name + ".ipynb")
Ejemplo n.º 2
0
def make_doc_notebooks(notebooks):
    src_path = os.path.dirname(__file__) + "/elements/"
    dst_path = os.path.dirname(__file__) + "/../docs/notebooks/"
    if os.path.isdir(dst_path):
        try:
            shutil.rmtree(dst_path)

        except PermissionError:
            pass
    os.makedirs(dst_path, exist_ok=True)
    for name in notebooks:
        nb = Notebook(src_path + name + ".ipynb")
        t = '[Try this yourself](https://colab.research.google.com/github/DTUWindEnergy/TopFarm2/blob/master/docs/notebooks/%s.ipynb) (requires google account)'
        nb.insert_markdown_cell(1, t % name)
        code = """%%capture
# Install Topfarm if needed
import importlib
if not importlib.util.find_spec("topfarm"):
    !pip install topfarm
"""
        if not name in ['loads', 'wake_steering_and_loads', 'layout_and_loads']:
            nb.insert_code_cell(2, code)
        nb.save(dst_path + name + ".ipynb")