data_structure_dicts
Access the dictionaries for variable information.
This ultimately provides access to variable information that is included in the python source (e.g. docstrings) or that cannot be dynamically accessed (e.g. variable initial values).
INPUT_TYPE_MAP = {int: 'int', float: 'real', str: 'string'}
module-attribute
NON_F_VALUES = ['f_j_cs_start_pulse_end_flat_top', 'f_c_plasma_non_inductive', 'feffcd', 'f_a_tf_turn_cable_copper']
module-attribute
output_dict = {}
module-attribute
Dictionary
Source code in process/core/io/data_structure_dicts.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
name = name
instance-attribute
dict = {}
instance-attribute
make_dict()
Source code in process/core/io/data_structure_dicts.py
48 49 50 | |
post_process()
Source code in process/core/io/data_structure_dicts.py
52 53 54 | |
publish()
Source code in process/core/io/data_structure_dicts.py
56 57 58 | |
SourceDictionary
Bases: Dictionary
Source code in process/core/io/data_structure_dicts.py
61 62 63 64 65 66 67 68 69 70 | |
dict_creator_func = dict_creator_func
instance-attribute
make_dict()
Source code in process/core/io/data_structure_dicts.py
68 69 70 | |
HardcodedDictionary
Bases: Dictionary
Source code in process/core/io/data_structure_dicts.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
hardcoded_dict = hardcoded_dict
instance-attribute
make_dict()
Source code in process/core/io/data_structure_dicts.py
82 83 84 | |
to_type(string)
Given a string, attempts to convert the string to a numerical value. If the string can't be simply converted, the function looks to see if it begins with a integer and returns that (since some lines have clarification text after the number). If this also fails, return string.strip()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
|
required |
Returns:
| Type | Description |
|---|---|
|
Either a float, int or string depending on input |
Source code in process/core/io/data_structure_dicts.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
grep(file, regexp, flags=re.UNICODE)
Implements an in-python grep. Returns the lines that match as a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Name of file to be read |
required | |
regexp
|
Regular expression to search for |
required | |
flags
|
re flags to use in search. Default is re.U which has |
UNICODE
|
Returns:
| Name | Type | Description |
|---|---|---|
lines |
List of matching lines |
Source code in process/core/io/data_structure_dicts.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
slice_file(file, re1, re2)
Returns a slice of a file that is bounded by lines containing a substring matching the given regular expressions. The first match to re1 in the file marks the start of the slice, the first match to re2 after that marks the end of the slice. The list of lines returned includes the two bounding lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
Name of file to read through |
required | |
re1
|
Starting regular expression |
required | |
re2
|
Ending regular expression |
required |
Returns:
| Type | Description |
|---|---|
|
lines:List of lines from file between re1 and re2 inclusive |
Source code in process/core/io/data_structure_dicts.py
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 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
remove_comments(line)
Function to remove comments from a fortran line. Works by simply removing everything after the first '!' in the line. This will cause problems in the case of '!' characters contained within strings so am assuming this won't happen. Need to change this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line to strip comments from |
required |
Returns:
| Name | Type | Description |
|---|---|---|
modified_line |
Line with comments removed |
Source code in process/core/io/data_structure_dicts.py
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 | |
dict_ixc2nsweep()
Returns a dict mapping ixc_no to nsweep_no, if both exist for a particular variable.
Example dictionary entry: DICT_IXC2NSWEEP['1'] = '1'
Source code in process/core/io/data_structure_dicts.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
dict_nsweep2ixc()
Returns a dict mapping nsweep_no to ixc_no; the inverse of dict_ixc2nsweep
Source code in process/core/io/data_structure_dicts.py
248 249 250 251 252 253 254 255 | |
dict_var_type()
Function to return a dictionary mapping variable name to variable type eg. 'real_variable' or 'int_array'. Looks in input.f90 at the process functions that read in variables from IN.DAT.
Example of line we are looking for: call parse_real_variable('BETA', beta, 0.0D0, 1.0D0, &
Example dictionary entry: DICT_VAR_TYPE['beta'] = 'real_variable'
Source code in process/core/io/data_structure_dicts.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
dict_input_bounds()
Returns a dictionary matching variable names to dictionary containing upper and lower bounds that PROCESS checks variable lies between when reading IN.DAT. Looks in input.f90 for parse_real_variable and parse_int_variable.
Example of a line we are looking for: call parse_real_variable('BETA', beta, 0.0D0, 1.0D0, &
Example dictionary entry: DICT_INPUT_BOUNDS['beta'] = {'lb' : 0.0, 'ub' : 1.0}
Source code in process/core/io/data_structure_dicts.py
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 | |
dict_nsweep2varname()
Source code in process/core/io/data_structure_dicts.py
310 311 | |
dict_ixc_full()
Function to return a dictionary matching str(ixc_no) to a dictionary containing the name, lower and upper bounds of that variable.
Example dictionary entry: DICT_IXC_FULL['5'] = {'name' : 'beta', 'lb' : 0.001, 'ub' : 1.0}
Source code in process/core/io/data_structure_dicts.py
314 315 316 317 318 319 320 321 322 323 324 325 | |
dict_ixc_bounds()
Source code in process/core/io/data_structure_dicts.py
328 329 330 331 332 333 334 335 336 337 338 | |
dict_ixc_simple()
Source code in process/core/io/data_structure_dicts.py
341 342 343 344 345 346 347 348 | |
dict_ixc_simple_rev()
Source code in process/core/io/data_structure_dicts.py
351 352 353 354 | |
get_dicts()
cached
Constructs the dictionaries which contain information about every PROCESS variable.
WARNING: this function must be used carefully because it re-initialises the PROCESS state
Source code in process/core/io/data_structure_dicts.py
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 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |