Last active
December 13, 2023 13:48
-
-
Save pukpr/c7ab804de3621a6f5f96be1152cf2d24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The command you want to execute | |
$command = " .\eexp.exe 0.8" | |
# The name of the output file generated by the command | |
$generatedFileName = "lte_results.csv" | |
$generatedDataName = "dlod_compare.csv" | |
# The base name for the renamed output files | |
$baseFileName = "lte_results" | |
$baseDataName = "dlod_compare" | |
# Starting index for file numbering | |
$index = 1 | |
# Define how many times to repeat the execution | |
$repeatCount = 15 # Change this to the desired count | |
for ($i = 0; $i -lt $repeatCount; $i++) { | |
# Execute the command | |
Invoke-Expression $command | |
# Wait for the file to be created if necessary | |
# while (-not (Test-Path $generatedFileName)) { | |
# Start-Sleep -Milliseconds 100 | |
# } | |
# Construct the new file name | |
$newFileName = $baseFileName + $index + ".csv" | |
$newDataName = $baseDataName + $index + ".csv" | |
# Rename or move the output file | |
Move-Item $generatedFileName $newFileName | |
Move-Item $generatedDataName $newDataName | |
# Increment the file index for the next iteration | |
$index++ | |
} | |
# End of script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import sys | |
def ensemble_average(prefix, file_count): | |
# Initialize an empty DataFrame for the sum | |
sum_df = None | |
count = 0 | |
# Loop through each file and add to the sum | |
for i in range(1, file_count + 1): | |
filename = f"{prefix}{i}.csv" | |
try: | |
df = pd.read_csv(filename, header=None) | |
if sum_df is None: | |
sum_df = df | |
else: | |
sum_df += df | |
count += 1 | |
except FileNotFoundError: | |
print(f"File not found: {filename}") | |
continue | |
# Calculate the average | |
avg_df = sum_df / count | |
# Save the ensemble average to a new CSV file | |
avg_df.to_csv(f"{prefix}.csv", header=False, index=False) | |
if __name__ == "__main__": | |
if len(sys.argv) != 3: | |
print("Usage: python ensemble_average.py [prefix] [file_count]") | |
sys.exit(1) | |
prefix = sys.argv[1] | |
file_count = int(sys.argv[2]) | |
ensemble_average(prefix, file_count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Status: 4 2 0.73618 0.41347 # 591
CC 0.4134731916 0.7361752774 4 1
0.99999997629:dLOD:
PS C:\Users\pp\github\pukpr\GeoEnergyMath\qbo> ..\io\backup amo-abs-pt413pt736pt999999976
Status: 1 2 0.77076 0.35996 # 1808
CC 0.3599551384 0.7707615926 1 1
0.99999994763:dLOD:
PS C:\Users\pp\github\pukpr\GeoEnergyMath\qbo> notepad enso_opt.exe.resp
PS C:\Users\pp\github\pukpr\GeoEnergyMath\qbo> ..\io\backup amo-abs-pt36pt77pt999999947
.\eexp.exe 0.75 0.2"