base
PROCESS MFILE.DAT IO library
MFileVariable
Bases: dict
Class for containing a single mfile variable
Source code in process/core/io/mfile/base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
var_name = var_name
instance-attribute
var_description = var_description
instance-attribute
var_unit = var_unit
instance-attribute
var_flag = var_flag
instance-attribute
latest_scan = 0
instance-attribute
exists
property
set_scan(scan_number, scan_value)
Sets the class attribute self.scan# where # is scan number
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan_number
|
scan number |
required | |
scan_value
|
value of parameter for scan |
required |
Source code in process/core/io/mfile/base.py
55 56 57 58 59 60 61 62 63 64 65 66 | |
get_scan(scan_number)
Returns the value of a specific scan. For scan = -1 or None the last scan is given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan_number
|
scan number to return |
required |
Returns:
| Type | Description |
|---|---|
type
|
[single scan requested] |
Source code in process/core/io/mfile/base.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
get_scans()
Returns a list of scan values in order of scan number
Returns:
| Type | Description |
|---|---|
[List of all scans for variable]
|
|
Source code in process/core/io/mfile/base.py
86 87 88 89 90 91 92 93 | |
get_number_of_scans()
Function to return the number of scans in the variable class
Source code in process/core/io/mfile/base.py
95 96 97 | |
MFileErrorClass
Error class for handling missing data from MFILE
Source code in process/core/io/mfile/base.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
item = item
instance-attribute
get_scan = self.get_error
instance-attribute
get_scans = self.get_error
instance-attribute
set_scan = self.get_error
instance-attribute
get_number_of_scans = self.get_error
instance-attribute
exists
property
get_error(*args, **kwargs)
Source code in process/core/io/mfile/base.py
114 115 116 117 118 119 120 121 122 123 | |
MFileDataDictionary
Bases: OrderedDict
Class object to act as a dictionary for the data.
Source code in process/core/io/mfile/base.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
DefaultOrderedDict
Bases: OrderedDict
Source code in process/core/io/mfile/base.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
default_factory = default_factory
instance-attribute
copy()
Source code in process/core/io/mfile/base.py
170 171 | |
MFile
Class object to store the MFile Objects
Source code in process/core/io/mfile/base.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
filename = Path(filename)
instance-attribute
data = DefaultOrderedDict()
instance-attribute
mfile_lines = []
instance-attribute
mfile_modules = {}
instance-attribute
des_name = []
instance-attribute
current_module = 'Misc'
instance-attribute
get_variables(*variables, scan=-1)
Get a number of variables from a single scan
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*variables
|
str
|
|
()
|
scan
|
int
|
(Default value = -1) |
-1
|
Source code in process/core/io/mfile/base.py
200 201 202 203 204 205 206 207 208 209 210 | |
get(variable, *, scan=-1)
Get variable data from a given scan
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
|
required |
scan
|
int
|
(Default value = -1) |
-1
|
Source code in process/core/io/mfile/base.py
212 213 214 215 216 217 218 219 220 221 222 | |
open_mfile()
Function to open MFILE.DAT
Source code in process/core/io/mfile/base.py
224 225 226 227 228 229 230 231 232 233 234 235 236 | |
parse_mfile()
Function to parse MFILE.DAT
Source code in process/core/io/mfile/base.py
238 239 240 241 242 243 | |
add_line(line)
Function to read the line from MFILE and add to the appropriate class or create a new class if it is the first instance of it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
|
required |
Source code in process/core/io/mfile/base.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
add_to_mfile_variable(des, name, value, unit, flag, scan=None)
Function to add value to MFile class for that name/description
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
des
|
|
required | |
name
|
|
required | |
value
|
|
required | |
unit
|
|
required | |
flag
|
|
required | |
scan
|
(Default value = None) |
None
|
Source code in process/core/io/mfile/base.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
to_dict(keys=None, scan=-1, verbose=False)
Convert MFile to dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
keys to select |
None
|
|
scan
|
int | None
|
scan to select |
-1
|
verbose
|
verbosity of output |
False
|
Source code in process/core/io/mfile/base.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
to_json(filename=None, keys_to_write=None, scan=-1, verbose=False)
Write MFILE object to JSON file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys_to_write
|
keys to select |
None
|
|
scan
|
int | None
|
scan to select |
-1
|
verbose
|
verbosity of output |
False
|
Source code in process/core/io/mfile/base.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
to_toml(filename=None, keys_to_write=None, scan=-1, verbose=False)
Write MFILE object to JSON file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys_to_write
|
keys to select |
None
|
|
scan
|
int | None
|
scan to select |
-1
|
verbose
|
verbosity of output |
False
|
Source code in process/core/io/mfile/base.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
to_csv(filename=None, keys_to_write=None, scan=-1, verbose=False)
Write to csv file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
string, list of tuples
|
input filename, variable data |
required |
csv_outfile
|
|
required | |
output_data
|
(Default value = None) |
required |
Source code in process/core/io/mfile/base.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
sort_value(value_words)
Parse value section of a line in MFILE.
value_words is a list of strings, which is then parsed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_words
|
List[str]
|
value of var in MFILE as list of strings |
required |
value_words
|
list[str]
|
|
required |
Returns:
| Type | Description |
|---|---|
Union[str, float]
|
string or float representation of value list |
Source code in process/core/io/mfile/base.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
sort_brackets(var)
Function to sort bracket madness on variable name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
|
required |
Source code in process/core/io/mfile/base.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 | |
clean_line(line)
Cleans an MFILE line into the three parts we care about
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
|
required |
Source code in process/core/io/mfile/base.py
516 517 518 519 520 521 522 523 524 | |
search_keys(dictionary, variable)
Searches the dictionary keys for matches to the variable name 'variable' in arguments.
Puts everything into lower case before searching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
dictionary to search in |
required | |
variable
|
variable name to search for |
required |
Returns:
| Type | Description |
|---|---|
|
List of matches to the searched for variable |
Source code in process/core/io/mfile/base.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
search_des(dictionary, description)
Searches the dictionary descriptions for matches to the description 'description' from the arguments.
Puts everything into lower case before searching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
dictionary to search in |
required | |
variable
|
variable name to search for |
required |
Returns:
| Type | Description |
|---|---|
|
List of matches to the searched for description |
Source code in process/core/io/mfile/base.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
get_unit(variable_desc)
Returns the unit from a variable description if possible, else None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_desc
|
|
required |
Source code in process/core/io/mfile/base.py
570 571 572 573 574 575 576 577 578 579 580 581 | |
get_mfile_initial_ixc_values(file_path)
Initialise the input file and obtain the initial values of the iteration variables
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path
|
The path to the MFile to get the initial iteration variable values from. |
required |
Notes
This method initialises a SingleRun. At present, this involves mutating the global data structure so it is not safe to run this method during a PROCESS run.
Source code in process/core/io/mfile/base.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |