@@ -2017,8 +2017,7 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
20172017 # make sure to save all desiered resuts for first and last time step for
20182018 # the report
20192019 resTypesReport = fU.splitIniValueToArraySteps(cfg["REPORT"]["plotFields"])
2020- # always add particles to first and last time step
2021- resTypesLast = list(set(resTypes + resTypesReport + ["particles"]))
2020+ resTypesLast = list(set(resTypes + resTypesReport))
20222021 # derive friction type
20232022 # turn friction model into integer
20242023 frictModelsList = [
@@ -2059,7 +2058,7 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
20592058 # setup a result fields info data frame to save max values of fields and avalanche front
20602059 resultsDF = setupresultsDF(resTypesLast, cfg["VISUALISATION"].getboolean("createRangeTimeDiagram"))
20612060
2062- # TODO: add here different time stepping options
2061+ # Add different time stepping options here
20632062 log.debug("Use standard time stepping")
20642063 # Initialize time and counters
20652064 nSave = 1
@@ -2074,6 +2073,12 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
20742073 # export initial time step
20752074 if cfg["EXPORTS"].getboolean("exportData"):
20762075 exportFields(cfg, t, fields, dem, outDir, cuSimName, TSave="initial")
2076+
2077+ if "particles" in resTypes:
2078+ outDirData = outDir / "particles"
2079+ fU.makeADir(outDirData)
2080+ savePartToPickle(particles, outDirData, cuSimName)
2081+
20772082 # export particles properties for visulation
20782083 if cfg["VISUALISATION"].getboolean("writePartToCSV"):
20792084 particleTools.savePartToCsv(
@@ -2085,10 +2090,6 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
20852090 countParticleCsv = countParticleCsv + 1
20862091
20872092 # export particles dictionaries of saving time steps
2088- # (if particles is not in resType, only first and last time step are saved)
2089- outDirData = outDir / "particles"
2090- fU.makeADir(outDirData)
2091- savePartToPickle(particles, outDirData, cuSimName)
20922093
20932094 zPartArray0 = copy.deepcopy(particles["z"])
20942095
@@ -2187,7 +2188,8 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
21872188 exportFields(cfg, t, fields, dem, outDir, cuSimName, TSave="intermediate")
21882189
21892190 # export particles dictionaries of saving time steps
2190- savePartToPickle(particles, outDirData, cuSimName)
2191+ if "particles" in resTypes:
2192+ savePartToPickle(particles, outDirData, cuSimName)
21912193
21922194 # export particles properties for visulation
21932195 if cfg["VISUALISATION"].getboolean("writePartToCSV"):
@@ -2315,7 +2317,8 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si
23152317 exportFields(cfg, t, fields, dem, outDir, cuSimName, TSave="final")
23162318
23172319 # export particles dictionaries of saving time steps
2318- savePartToPickle(particles, outDirData, cuSimName)
2320+ if "particles" in resTypes:
2321+ savePartToPickle(particles, outDirData, cuSimName)
23192322 else:
23202323 # fetch contourline info
23212324 contourDictXY = outCom1DFA.fetchContCoors(
@@ -2371,7 +2374,7 @@ def setupresultsDF(resTypes, cfgRangeTime):
23712374 resultsDF: dataframe
23722375 data frame with on line for iniital time step and max and mean values of fields
23732376 """
2374-
2377+ # TODO catch empty resTypes
23752378 resDict = {"timeStep": [0.0]}
23762379 for resT in resTypes:
23772380 if resT != "particles" and resT != "FTDet":
@@ -2968,12 +2971,18 @@ def exportFields(
29682971 # convert from J/cell to kJ/m²
29692972 # (by dividing the peak kinetic energy per cell by the real area of the cell)
29702973 resField = resField * 0.001 / dem["areaRaster"]
2974+
29712975 dataName = cuSimName + "_" + resType + "_" + "t%.2f" % (timeStep)
29722976 # create directory
29732977 outDirPeak = outDir / "peakFiles" / "timeSteps"
29742978 fU.makeADir(outDirPeak)
29752979 outFile = outDirPeak / dataName
29762980 IOf.writeResultToRaster(dem["originalHeader"], resField, outFile, flip=True)
2981+ log.debug(
2982+ "Results parameter: %s has been exported to Outputs/peakFiles for time step: %.2f "
2983+ % (resType, timeStep)
2984+ )
2985+
29772986 if TSave == "final":
29782987 log.debug(
29792988 "Results parameter: %s exported to Outputs/peakFiles for time step: %.2f - FINAL time step "
@@ -2985,11 +2994,6 @@ def exportFields(
29852994 fU.makeADir(outDirPeakAll)
29862995 outFile = outDirPeakAll / dataName
29872996 IOf.writeResultToRaster(dem["originalHeader"], resField, outFile, flip=True)
2988- else:
2989- log.debug(
2990- "Results parameter: %s has been exported to Outputs/peakFiles for time step: %.2f "
2991- % (resType, timeStep)
2992- )
29932997
29942998
29952999def prepareVarSimDict(standardCfg, inputSimFiles, variationDict, simNameExisting="", module=com1DFA):
0 commit comments