-
Notifications
You must be signed in to change notification settings - Fork 0
Processing Time Step
The processData class reads one or more .txt files containing ground motion acceleration data. It detects the original time step from the first line in each file, optionally upsamples the data to a new time step, applies a user-defined scaling factor, and saves the results (including time vs acceleration data and a plot).
- Automatically detect the original time step from each input file’s header.
- Scale acceleration data by a user-defined factor.
- Interpolate (upsample) data if the original time step differs from a user-defined target.
- Generate separate plot images and upscaled data files for each input.
- When the input time step matches the user’s desired time step, the script skips interpolation and outputs a single-axis plot.
Each input .txt file is expected to have:
- Header Line (line 1):
<num_points> <dt_input>
- <num_points> = integer, the number of data points in the file.
- <dt_input> = float, the time step in seconds. Example:
18000 0.005
- Acceleration Data (the next
<num_points>lines):
- Each line contains a single floating-point value of acceleration. Example .txt File
18000 0.005
0.000123
0.000457
...
0.002345
Dependencies The script relies on a few Python libraries that are commonly used for scientific computing and plotting:
NumPy Matplotlib The standard Python os and glob modules To install the required libraries:
bash Copy Edit pip install numpy matplotlib Script Usage Clone or download this repository to your local machine. Verify that numpy and matplotlib are installed in your environment. Adjust the variables in the if name == "main": block near the bottom of the script: python Copy Edit if name == "main": input_folder = "site" # Path to folder with .txt files output_folder = "outputs" # Path to save results dt_new = 0.01 # Desired new time step (seconds) scale_factor = 10 # Multiply the accelerations by 10
processor = processData(
input_folder=input_folder,
output_folder=output_folder,
dt_new=dt_new,
scale_factor=scale_factor
)
processor.process_all_files()
Run the script: bash Copy Edit python process_data.py Look in the outputs folder (or whatever folder you specified) to view your newly generated results.
the structure should be like the following for processing the data.
📁 input
📁 output
📄 your file
- Nyquist-Shannon Sampling Theorem: Ensures no aliasing occurs during resampling.
- Signal Interpolation Theory: Linear interpolation used to estimate values for finer time steps.
- Standard Scaling Methods in Signal Processing: Used for amplitude adjustment.
Developed by : Albert Pamonag, M.Eng