Skip to content

HAWC2InputWriter does not rewrite logname/resname

Currently neither the logfile nor the resfile names are updated.

MWE (pytest test)

import pandas as pd
from wetb.hawc2.tests import test_files
from wetb.hawc2.hawc2_input_writer import HAWC2InputWriter
import os
import shutil
from wetb.hawc2.htc_file import HTCFile
import pytest
from wetb.hawc2 import hawc2_input_writer
from tests.run_main import run_module_main


htc_dir = os.path.dirname(test_files.__file__) + '/simulation_setup/DTU10MWRef6.0/htc/'


@pytest.fixture
def h2writer():
    """HAWC2Write with DTU 10 MW as base file"""
    htc_base_file = htc_dir + 'DTU_10MW_RWT.htc'
    return HAWC2InputWriter(htc_base_file)


def test_pandas2htc(h2writer, tmp_path):
    """Write htc files from pandas dataframe"""
    # given
    wsp_lst = [4, 6, 8]
    df = pd.DataFrame({'wind.wsp': wsp_lst, 'Name': ['c1', 'c2', 'c3'], 'Folder': ['.']*3})
    # when
    h2writer.from_pandas(df)
    h2writer.write_all(tmp_path)
    # then
    for i, wsp in enumerate(wsp_lst, 1):
        htc_path = tmp_path / ('c%d.htc' % i)
        htc = HTCFile(htc_path, modelpath=tmp_path.as_posix())
        assert htc.wind.wsp[0] == wsp
        assert htc.simulation.logfile == ('./log/c%d.log' % i)
        assert htc.output.filename == ('c%d' % i)