Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions PV_ICE/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2683,33 +2683,38 @@ class Material:
def __init__(self, materialname, massmatfile, energymatfile=None):
self.materialname = materialname

# Load mass material file
if massmatfile is None:
try:
massmatfile = _interactive_load('Select material baseline ' +
'file')
except:
raise Exception('Interactive load failed. Tkinter not ' +
'supported on this system. Try installing ' +
'X-Quartz and reloading')
massmatfile = _interactive_load('Select material baseline file')
except Exception:
raise RuntimeError('Interactive load failed. Tkinter not supported. '
'Try installing XQuartz (macOS) and reloading.')

data, meta = _readPVICEFile(massmatfile)

self.massmatfile = massmatfile
self.matmetdataIn_m = meta
self.matdataIn_m = data

# SAVING A COPY TO RAW
# Joining the metdata back in
foometa = pd.DataFrame(meta, index=[0])
foodata = pd.concat([foometa, data], axis=0)
# Removing the path to just get the filename
# TODO - find fancy python way, this will probably break on a mac
# Save a copy to /raw/ folder
try:
foomassmatfile = massmatfile.split('\\')[-1]
foodata.to_csv(os.path.join('raw', materialname + '_' +
foomassmatfile))
except:
print("Can't save raw files on macs yet.")
raw_dir = Path("raw")
raw_dir.mkdir(exist_ok=True) # Create directory if it doesn't exist

# Get filename only, regardless of OS
foomassmatfile = Path(massmatfile).name

# Combine meta and data into one DataFrame
foometa = pd.DataFrame(meta, index=[0])
foodata = pd.concat([foometa, data], axis=0)

# Construct output path and save
output_path = raw_dir / f"{materialname}_{foomassmatfile}"
foodata.to_csv(output_path, index=False)
except Exception as e:
print(f"[Warning] Could not save raw material file: {e}")

# Optional energy file
if energymatfile is not None:
self.addEnergytoMaterial(energymatfile)
else:
Expand Down
12 changes: 12 additions & 0 deletions contributors/rwoodsrobinson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
2023-10-24

I hereby agree to the terms of the Contributors License Agreement,
version 1.0, with MD5 checksum c54efab3bc98a2ca5e631c204a58a15c.

I furthermore declare that I am authorized and able to make this
agreement and sign this declaration.

Signed,

Rachel Woods-Robinson
https://github.com/rwoodsrobinson