|
1 | 1 | """ |
2 | | -Older versions of PAN files created by PVsyst use a Borland Pascal Real48 format. |
| 2 | +Older versions of PAN files created by PVsyst use a Borland Pascal Real48 |
| 3 | +format. |
3 | 4 |
|
4 | 5 | This is based on: |
5 | | - https://github.com/CanadianSolar/CASSYS/blob/b5487bb4e9e77174c805d64e3c960c46d357b7e2/CASSYS%20Interface/DatabaseImportModule.vba#L4 |
| 6 | + https://github.com/CanadianSolar/CASSYS/blob/ |
| 7 | + b5487bb4e9e77174c805d64e3c960c46d357b7e2/CASSYS%20Interface/ |
| 8 | + DatabaseImportModule.vba#L4 |
6 | 9 | """ |
7 | 10 |
|
8 | 11 | import struct |
@@ -131,7 +134,8 @@ def _extract_byte_parameters(byte_array, start_index, num_bytes): |
131 | 134 | # Check bounds to avoid index errors |
132 | 135 | if start_index + num_bytes > len(byte_array): |
133 | 136 | raise IndexError( |
134 | | - f"Not enough bytes: need {num_bytes} bytes starting at {start_index}" |
| 137 | + f"Not enough bytes: need {num_bytes} bytes starting at " |
| 138 | + f"{start_index}" |
135 | 139 | ) |
136 | 140 |
|
137 | 141 | # Extract the specified number of bytes starting at start_index |
@@ -174,7 +178,9 @@ def _extract_iam_profile(start_index, byte_array): |
174 | 178 | # Check if AOI is not null/empty (like VB.NET vbNullString check) |
175 | 179 | if aoi_formatted != "": |
176 | 180 | # Extract modifier value |
177 | | - modifier_index = _get_param_index(start_index=start_index, offset_num=i + 1) |
| 181 | + modifier_index = _get_param_index( |
| 182 | + start_index=start_index, offset_num=i + 1 |
| 183 | + ) |
178 | 184 | modifier_bytes = _extract_byte_parameters( |
179 | 185 | byte_array=byte_array, start_index=modifier_index, num_bytes=6 |
180 | 186 | ) |
@@ -230,7 +236,9 @@ def read_pan_binary(filename): |
230 | 236 | marker=DOT_MARKER, start_index=0, byte_array=byte_array |
231 | 237 | ) |
232 | 238 | source_start_index = _find_marker_index( |
233 | | - marker=DOT_MARKER, start_index=panel_start_index, byte_array=byte_array |
| 239 | + marker=DOT_MARKER, |
| 240 | + start_index=panel_start_index, |
| 241 | + byte_array=byte_array |
234 | 242 | ) |
235 | 243 | version_start_index = _find_marker_index( |
236 | 244 | marker=DOUBLE_DOT_MARKER, |
@@ -310,17 +318,23 @@ def read_pan_binary(filename): |
310 | 318 | .strip() |
311 | 319 | ) |
312 | 320 | data["Technology"] = ( |
313 | | - byte_array[technology_start_index : cells_in_series_start_index - 1] |
| 321 | + byte_array[ |
| 322 | + technology_start_index : cells_in_series_start_index - 1 |
| 323 | + ] |
314 | 324 | .decode("latin-1") |
315 | 325 | .strip() |
316 | 326 | ) |
317 | 327 | data["Cells_In_Series"] = ( |
318 | | - byte_array[cells_in_series_start_index : cells_in_parallel_start_index - 1] |
| 328 | + byte_array[ |
| 329 | + cells_in_series_start_index : cells_in_parallel_start_index - 1 |
| 330 | + ] |
319 | 331 | .decode("latin-1") |
320 | 332 | .strip() |
321 | 333 | ) |
322 | 334 | data["Cells_In_Parallel"] = ( |
323 | | - byte_array[cells_in_parallel_start_index : bypass_diodes_start_index - 1] |
| 335 | + byte_array[ |
| 336 | + cells_in_parallel_start_index : bypass_diodes_start_index - 1 |
| 337 | + ] |
324 | 338 | .decode("latin-1") |
325 | 339 | .strip() |
326 | 340 | ) |
@@ -349,7 +363,9 @@ def read_pan_binary(filename): |
349 | 363 | } |
350 | 364 |
|
351 | 365 | for name, offset in param_map.items(): |
352 | | - start = _get_param_index(start_index=real48_start_index, offset_num=offset) |
| 366 | + start = _get_param_index( |
| 367 | + start_index=real48_start_index, offset_num=offset |
| 368 | + ) |
353 | 369 | end = start + 6 |
354 | 370 | param_bytes = byte_array[start:end] |
355 | 371 | value = _read48_to_float(real48=param_bytes) |
|
0 commit comments