You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
file path to material parameters json with same schema as material parameters json files in `pvdeg/data`. `pvdeg_file` will override `fp` if both are provided.
1364
+
"""
1365
+
fromIPython.displayimportdisplay, HTML
1366
+
1367
+
ifpvdeg_file:
1368
+
try:
1369
+
fp=pvdeg_datafiles[pvdeg_file]
1370
+
exceptKeyError:
1371
+
raiseKeyError(f"{pvdeg_file} does not exist in pvdeg/data. Options are {pvdeg_datafiles.keys()}")
file path to material parameters json with same schema as material parameters json files in `pvdeg/data`. `pvdeg_file` will override `fp` if both are provided.
1414
+
name_or_alias: str
1415
+
searches for matching subkey value in either `name` or `alias` attributes. exits on the first matching instance.
1416
+
1417
+
Returns
1418
+
---------
1419
+
jsonkey: str
1420
+
arbitrary key from json that owns the matching subattribute of `name` or `alias`.
1421
+
"""
1422
+
1423
+
ifpvdeg_file:
1424
+
try:
1425
+
fp=pvdeg_datafiles[pvdeg_file]
1426
+
exceptKeyError:
1427
+
raiseKeyError(rf"{pvdeg_file} does not exist in pvdeg/data. Options are {pvdeg_datafiles.keys()}")
1428
+
1429
+
withopen(fp, "r") asfile:
1430
+
data=json.load(file)
1431
+
1432
+
forkey, subdictindata.items():
1433
+
if"name"insubdictand"alias"insubdict:
1434
+
if (subdict["name"] ==name_or_aliasorsubdict["alias"] ==name_or_alias):
1435
+
returnkey
1436
+
1437
+
raiseValueError(rf"name_or_alias: {name_or_alias} not in JSON at {os.path(fp)}")
1438
+
1439
+
defread_material(
1440
+
pvdeg_file: str=None,
1441
+
fp: str=None,
1442
+
key: str=None,
1443
+
parameters: list[str] =None,
1444
+
)->dict:
1445
+
"""
1446
+
Read material parameters from a `pvdeg/data` file or JSON file path.
1447
+
1448
+
Parameters
1449
+
-----------
1450
+
pvdeg_file: str
1451
+
keyword for material json file in `pvdeg/data`. Options:
file path to material parameters json with same schema as material parameters json files in `pvdeg/data`. `pvdeg_file` will override `fp` if both are provided.
1455
+
key: str
1456
+
key corresponding to specific material in the file. In the pvdeg files these have arbitrary names. Inspect the files or use `display_json` or `search_json` to identify the key for desired material.
1457
+
parameters: list[str]
1458
+
parameters to grab from the file at index key. If none, will grab all items at index key. the elements in parameters must match the keys in the json exactly or the output value for the specific key/parameter in the retunred dict will be `None`.
1459
+
1460
+
Returns
1461
+
--------
1462
+
material: dict
1463
+
dictionary of material parameters from the seleted file at the index key.
1464
+
"""
1465
+
1466
+
# these live in the `pvdeg/data` folder
1467
+
ifpvdeg_file:
1468
+
try:
1469
+
fp=pvdeg_datafiles[pvdeg_file]
1470
+
exceptKeyError:
1471
+
raiseKeyError(f"{pvdeg_file} does not exist in pvdeg/data. Options are {pvdeg_datafiles.keys()}")
0 commit comments