-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Describe the bug
When using a WIND Toolkit-formatted .csv weather file with the LandBOSSE BOS cost module, SAM returns the error: Run LandBOSSE error: Error in Weather_Data: Length of values does not match length of index. This occurs because the read_weather_data() function in landbosse_api/run.py hardcodes skiprows=5, assuming the input weather file is in .srw format with exactly 5 header rows. WIND Toolkit .csv files have only 2 header rows, so skiprows=5 consumes 3 rows of actual data, leaving fewer than 8,760 data rows. When LandBOSSE then attempts to assign a pre-built 8,760-entry datetime index to this shorter dataframe, pandas raises the length mismatch error.
To Reproduce
- Download a hourly wind resource file from the NREL WIND Toolkit in
.csvformat - Open SAM and create a Wind Power project
- Assign the WIND Toolkit
.csvas the weather resource file - Enable the LandBOSSE BOS cost model and fill in required inputs
- Run the simulation — the BOS calculation returns the error described above
Expected behavior
LandBOSSE should accept WIND Toolkit .csv formatted weather files without error, consistent with SAM's own documentation noting a transition toward WIND Toolkit .csv format compatibility. The read_weather_data() function should either detect the number of header rows dynamically, or SAM should preprocess the weather file into .srw format before passing it to LandBOSSE.
Screenshots
Operating System and Version
- OS: Windows
- Version: SAM 2025.4.16
Additional context
The relevant code is in landbosse_api/run.py (installed with LandBOSSE 2.3.0.3 in SAM's bundled Python environment at runtime/python/python-3.7.6/Lib/site-packages/landbosse/). The specific function is:
def read_weather_data(file_path):
weather_data = pd.read_csv(file_path,
sep=",",
header=None,
skiprows=5,
usecols=[0, 1, 2, 3, 4]
)
return weather_dataA workaround is to manually add 3 dummy header rows to the WIND Toolkit .csv file (bringing the total to 5 header rows) before using it with LandBOSSE. This modified file will break SAM's main production simulation, so two separate copies of the weather file are needed — one unmodified for production calculations, and one with the dummy rows added for LandBOSSE BOS calculations.