Skip to content
Merged
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
616 changes: 616 additions & 0 deletions examples/a_scan_input_file_IN.DAT

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions examples/csv_output.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "subslide"
Expand All @@ -37,16 +37,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching list of variables from /home/rhicha/process/process/io/mfile_to_csv_vars.json\n",
"Reading from MFILE: /home/rhicha/process/tests/integration/data/baseline_2018_MFILE.DAT\n",
"Variable 'capcost' not in MFILE. Skipping and moving on...\n",
"Variable 'step2001' not in MFILE. Skipping and moving on...\n",
"Variable 'step2115' not in MFILE. Skipping and moving on...\n",
"Variable 'step2116' not in MFILE. Skipping and moving on...\n",
"Variable 'step2117' not in MFILE. Skipping and moving on...\n",
"Variable 'step2198' not in MFILE. Skipping and moving on...\n",
"Variable 'step2199' not in MFILE. Skipping and moving on...\n",
"Writing to csv file: /home/rhicha/process/tests/integration/data/baseline_2018_MFILE.csv\n",
"Fetching list of variables from /home/clair/development/PROCESS/process/io/mfile_to_csv_vars.json\n",
"Reading from MFILE: /home/clair/development/PROCESS/examples/csv_output_large_tokamak_MFILE.DAT\n",
"Writing to csv file: /home/clair/development/PROCESS/examples/csv_output_large_tokamak_MFILE.csv\n",
"Complete.\n"
]
}
Expand All @@ -60,7 +53,7 @@
"proj_dir = Path.cwd().parent\n",
"\n",
"# Replace this path/to/MFILE.DAT with your target file:\n",
"mfilename = proj_dir / 'tests/integration/data/baseline_2018_MFILE.DAT'\n",
"mfilename = proj_dir / 'examples/csv_output_large_tokamak_MFILE.DAT'\n",
"\n",
"# Either replace this with your own path/to/file.json target, \n",
"# or add your required variables into the identified file:\n",
Expand All @@ -72,6 +65,13 @@
"# call to function:\n",
"mfile_to_csv.main(args=[\"-f\", str(mfilename), \"-v\", str(varfilename)])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -94,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
39 changes: 39 additions & 0 deletions examples/csv_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# %% [markdown]
# # Output to csv
#
# Routine to read from a PROCESS MFILE and write specified values into a csv.
#
# Input files:
# - MFILE.DAT as output from PROCESS
# - .json variable list as defined by user (defaults to local `mfile_to_csv_vars.json`)
#
# Instructions:
# - from command line: `python mfile_to_csv.py -f </path/to/mfile.dat> -v </path/to/varfile.json>`
# - from this Jupyter notebook: run the cell below
#
# Output file:
# - .csv will be saved to the directory of the input file

# %%
from pathlib import Path
from process.io import mfile_to_csv

# Project directory for example result file and default .json list;
# not needed if you replace both target filepaths below.
proj_dir = Path.cwd().parent

# Replace this path/to/MFILE.DAT with your target file:
mfilename = proj_dir / "examples/csv_output_large_tokamak_MFILE.DAT"

# Either replace this with your own path/to/file.json target,
# or add your required variables into the identified file:
varfilename = proj_dir / "process/io/mfile_to_csv_vars.json"
# This routine attempts to find every variable in the given list and
# writes the variable name, description and value to the output csv.
# Any listed variable that isn't in that MFILE will be skipped.

# call to function:
mfile_to_csv.main(args=["-f", str(mfilename), "-v", str(varfilename)])


# %%
1,807 changes: 1,807 additions & 0 deletions examples/csv_output_large_tokamak_MFILE.DAT

Large diffs are not rendered by default.

Loading