<jupyter_start><jupyter_text>Workflow for Abstract Analysis without Geoferenced LocationsIn this application, we showcase the capability for pre-process network graphs and simplify their topologiesThe workflow is structured as follows:1. Import relevant modules / tools / packages2. Define Hydrogen Supply Chain Alternatives3. Run Supply Chain Model4. Postprocessing  1. Import relevant modules / tools / packages<jupyter_code>from HIM.workflow.scenarioExample import *

#import processing as prc
from HIM import dataHandling as sFun
from HIM import optiSetup as optiFun
from HIM import hscClasses as hscFun
from HIM import plotFunctions as pFun
import copy as copy
import os
pathPlot=None
from HIM import hscAbstract as hscA<jupyter_output><empty_output><jupyter_text>2. Define Hydrogen Supply Chain Alternatives<jupyter_code>hscPathways=[["Electrolyzer","None","Compressor", "GH2-Cavern","None","Compressor","Pipeline","Compressor","GH2-Truck","GH2 (Trailer)"],
             ["Electrolyzer","None","Compressor", "GH2-Cavern","None","Compressor","Pipeline","None","Pipeline","GH2 (Pipeline)"],
             ["Electrolyzer","None","Compressor", "GH2-Cavern","None","Compressor","GH2-Truck","None","None","GH2 (Trailer)"],
             ["Electrolyzer","None","Compressor", "GH2-Cavern","None","Liquefaction","LH2-Truck","None","None","LH2"],
             ["Electrolyzer","None","Compressor", "GH2-Cavern","None","Hydrogenation","LOHC-Truck","None","None","LOHC (NG)"],
             ["Electrolyzer","None","Liquefaction", "LH2-Tank","Evaporation","Compressor","Pipeline","Compressor","GH2-Truck","GH2 (Trailer)"],
             ["Electrolyzer","None","Liquefaction", "LH2-Tank","Evaporation","Compressor","Pipeline","None","Pipeline","GH2 (Pipeline)"],
             ["Electrolyzer","None","Liquefaction", "LH2-Tank","Evaporation","Compressor","GH2-Truck","None","None","GH2 (Trailer)"],
             ["Electrolyzer","Liquefaction","None", "LH2-Tank","None","None","LH2-Truck","None","None","LH2"],
             ["Electrolyzer","None","Hydrogenation", "LOHC-Tank","Dehydrogenation","Compressor","Pipeline","Compressor","GH2-Truck","GH2 (Trailer)"],
             ["Electrolyzer","None","Hydrogenation", "LOHC-Tank","Dehydrogenation","Compressor","Pipeline","None","Pipeline","GH2 (Pipeline)"],
             ["Electrolyzer","None","Hydrogenation", "LOHC-Tank","Dehydrogenation","Compressor","GH2-Truck","None","None","GH2 (Trailer)"],
             ["Electrolyzer","Hydrogenation","None", "LOHC-Tank","None","None","LOHC-Truck","None","None","LOHC (NG)"]]
dfHSC=pd.DataFrame(hscPathways, columns=["Production",
                                         "Connector1",
                                         "Connector2",
                                         "Storage",
                                         "Connector3",
                                        "Connector4",
                                         "Transport1",
                                         "Connector5",
                                         "Transport2",
                                         "Station"])
nameHSC=[]
for key, values in dfHSC.iterrows():
    if values["Transport2"]=="None":
        nameHSC.append(values["Storage"]+"\n"+values["Transport1"])
    elif values["Transport2"]=="Pipeline":
        nameHSC.append(values["Storage"]+"\nPipePipe")
    else:
        nameHSC.append(values["Storage"]+"\nPipe+"+values["Transport2"])
                       
dfHSC["General"]=nameHSC
dfHSC<jupyter_output><empty_output><jupyter_text>3. Run Abstract Supply Chain Model<jupyter_code>res=100<jupyter_output><empty_output><jupyter_text>Calculation of demand and distance arrays<jupyter_code>demArr, distArr = builtDemDistArray(demMax=100000,     # maximal demand
                                    distMax=500,       # maximal distance
                                    res=res)           # Resolution
Results={}
for x in range(len(hscPathways)):
    Results[x]=hscA.HSCAbstract(demArr=demArr,
                          distArr=distArr,
                          dfTable=dfTable,
                          listHSC=hscPathways[x])
    Results[x].calcHSC()<jupyter_output>C:\ProgramData\Anaconda3\envs\him\lib\site-packages\pandas\core\indexing.py:1418: FutureWarning: 
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.

See the documentation here:
https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike
  return self._getitem_tuple(key)<jupyter_text>Initialization<jupyter_code>totalCost = np.empty((len(distArr), demArr.shape[1], len(hscPathways)))
minimalCost = np.empty((len(distArr), demArr.shape[1]))<jupyter_output><empty_output><jupyter_text>extract data<jupyter_code>for i in range(len(hscPathways)):
# Read interesting Numbers
    totalCost[:, :, i] = Results[i].cumCost["Station"]<jupyter_output><empty_output><jupyter_text>Cut disturbing Data<jupyter_code>cuttedCost = copy.copy(totalCost)
lineCost = copy.copy(totalCost)
lineCost[:, :, :] = np.nan
minimalLineCost = np.empty((len(distArr), demArr.shape[1]))
minimalLineCost[:, :] = np.nan

for i in range(len(distArr)):
    for j in range(len(demArr.T)):
        minimalCost[i, j] = min(cuttedCost[i, j, :])

        for k in range(len(hscPathways)):
            if minimalCost[i, j] < cuttedCost[i, j, k]:
                cuttedCost[i, j, k] = np.nan
                if (
                    np.isnan(cuttedCost[i, j, k]) and np.isnan(cuttedCost[i - 1, j, k]) == False) or (np.isnan( cuttedCost[i, j, k]) == False and np.isnan(cuttedCost[i - 1, j, k]) == True):
                    if not(i == 0):
                        minimalLineCost[i, j] = minimalCost[i, j]
                        minimalLineCost[i - 1, j] = minimalCost[i - 1, j]
                        minimalLineCost[i, j - 1] = minimalCost[i, j - 1]
                elif (np.isnan(cuttedCost[i, j, k]) and np.isnan(cuttedCost[i, j - 1, k]) == False) or (np.isnan(cuttedCost[i, j, k]) == False and np.isnan(cuttedCost[i, j - 1, k]) == True):
                    if not j == 0:
                        minimalLineCost[i, j] = minimalCost[i, j]
                        minimalLineCost[i - 1, j] = minimalCost[i - 1, j]
                        minimalLineCost[i, j - 1] = minimalCost[i, j - 1]<jupyter_output><empty_output><jupyter_text>4. Postprocessing<jupyter_code>pFun.trisurfplotMin(
    demArr/1000,
    distArr,
    cuttedCost,
    minimalCost,
    minimalLineCost,
    dfHSC,
    figSize=(7,4),
    zmax=10.5,
    savePath=os.path.join(os.getcwd(),'results','FigureComparison.png'))<jupyter_output>c:\users\l.kotzur\sciebo\fzj\04_public\him\HIM\plotFunctions.py:165: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  plt.tight_layout()
{'fraction_non_alphanumeric': 0.15464369158878505, 'fraction_numerical': 0.013872663551401869, 'mean_word_length': 3.128390596745027, 'pattern_counts': {'":': 2, '<': 32, '<?xml version=': 0, '>': 31, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '558109', 'license': 'MIT', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2117, 'n_words': 380, 'path': 'apps/Example - Abstract analysis without geoferenced locations.ipynb', 'repo_name': 'noah80/HIM', 'size': '6848'}