-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df8275c
commit 5cd5a1e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
srf_generation/source_parameter_generation/uncertainties/sites_info_perturb.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pandas as pd | ||
from qcore.uncertainties import distributions | ||
import argparse | ||
|
||
# Create the parser | ||
parser = argparse.ArgumentParser(description='Process a CSV file.') | ||
|
||
# Add an argument for the CSV file path | ||
parser.add_argument('csv_file_path', help='The path to the CSV file') | ||
|
||
# Parse the command-line arguments | ||
args = parser.parse_args() | ||
|
||
# Load the CSV file into a DataFrame, ensuring station name is the first column | ||
sites_info_df = pd.read_csv(args.csv_file_path, index_col=0) | ||
|
||
# Extract the rrup column data | ||
rrup_data = sites_info_df["rrup"] | ||
|
||
# Update the rrup column in the DataFrame | ||
sites_info_df["rrup"] = distributions.truncated_log_normal(rrup_data, 0.1, 4) | ||
|
||
# Generate a new file name with "__perturbed.csv" suffix | ||
new_file_name = args.csv_file_path.replace(".csv", "_perturbed.csv") | ||
|
||
# Save the updated DataFrame to a new file | ||
sites_info_df.to_csv(new_file_name) | ||
|