rsseismic.Motion module#

class rsseismic.Motion.DiscoveredMotionPairs(folderPath: str, pairs: list[MotionPairInfo])#

Bases: object

Motion pairs discovered in a folder for Manual match-to-target selection.

Selection starts empty. Call select / selectAll, then pass selectedPairs into MotionLibrary.matchToTargetSpectraManual.

property folderPath: str#
property allPairs: list[MotionPairInfo]#
property selectedPairs: list[MotionPairInfo]#
select(pairIds: list[str], selectOnlyListed: bool = True) → None#

Select pairs by pairId.

When selectOnlyListed is True (default), only the listed ids remain selected. When False, listed ids are added to the current selection.

selectAll() → None#

Select every discovered pair.

deselectAll() → None#

Clear the selection.

class rsseismic.Motion.MotionLibrary(client: Client)#

Bases: object

App-level ground motion library (Motion Manager).

No project is required. Use getMotion(name) for one motion (file name without extension), or getMotionPair(pairId) for a horizontal pair (shared name prefix of the H1 and H2 files). Use getUnitSystem / changeUnitSystem to switch Motion Manager display units (Metric or Imperial) for this session.

getMotion(motionName: str) → Motion#

Return one motion from the library.

getMotionPair(pairId: str) → MotionPair#

Return one horizontal motion pair from the library.

getUnitSystem() → UnitSystem#

Return the Motion Manager display unit system (Metric or Imperial).

This is independent of the open project’s unit system.

changeUnitSystem(unitSystem: UnitSystem) → UnitSystem#

Switch Motion Manager display units between Metric and Imperial.

Affects properties and tables from the motion library for this session. Does not change the open project’s unit system or Preferences. Returns the unit system now in effect.

convertMotionText(sourceFilePath: str, motionName: str, outputDirectory: str, accelerationUnit: MotionAccelerationUnit, layout: MotionConvertLayout = MotionConvertLayout.ACCELERATION_ONLY, delimiter: MotionConvertDelimiter = MotionConvertDelimiter.SPACE, overwrite: bool = False, timeStep: float = 0.0, hasTimeStep: bool = False, accelerationColumn: int = 1, timeColumn: int = 1, firstLine: int = 1, lastLine: int = 0) → ConvertMotionResult#

Convert a text motion file and add it to the motion library.

outputDirectory must be one of the Motion Manager preference folders. For MotionConvertLayout.ACCELERATION_ONLY, set hasTimeStep=True and provide timeStep. For MotionConvertLayout.TIME_AND_ACCELERATION, the timestep is read from the file. Set lastLine to 0 to read through the end of the file.

convertMotionAT2(sourceFilePath: str, motionName: str, outputDirectory: str, overwrite: bool = False, accelerationUnit: MotionAccelerationUnit | None = None) → ConvertMotionResult#

Convert a PEER AT2 acceleration record and add it to the motion library.

outputDirectory must be one of the Motion Manager preference folders. Leave accelerationUnit as None to auto-detect the unit from the AT2 header.

deleteMotions(motionNames: list[str]) → DeleteMotionsResult#

Delete motions from the library by name.

Removes the motion files from disk and updates the Motion Manager list. Names that were not found or could not be deleted are returned in failedMotionNames.

authenticateDatabase(database: GroundMotionDatabase, username: str, password: str = '') → None#

Authenticate against an external ground-motion database for this session.

Call once before searchDatabaseRecords / importDatabaseRecords / matchToTargetSpectraAutomatic. Password may be omitted for username-only databases (e.g. CESMD).

searchDatabaseRecords(database: GroundMotionDatabase, filters: DatabaseSearchFilters, maxResults: int | None = None) → list[DatabaseRecordInfo]#

Search an external ground-motion database and return matching records.

Call authenticateDatabase for this database first. Pass selected records from this result into importDatabaseRecords.

maxResults optionally caps how many records the server returns (omit or None / <= 0 = no scripting-side truncate).

importDatabaseRecords(database: GroundMotionDatabase, outputDirectory: str, records: list[DatabaseRecordInfo], overwrite: bool = False) → ImportDatabaseRecordsResult#

Download selected database records into a Motion Manager preference folder.

Call authenticateDatabase for this database first. outputDirectory must already be listed in Preferences → Motions. Records that fail to download or save are returned in failedRecordIds.

discoverMotionPairsInFolder(folderPath: str) → DiscoveredMotionPairs#

Scan a folder (and subfolders) for horizontal motion pairs.

The returned DiscoveredMotionPairs has an empty selection. Call select / selectAll, then pass selectedPairs to matchToTargetSpectraManual.

getTargetSpectra(model: UserDefinedTargetSpectraModel | RexelTargetSpectraModel | NshmpTargetSpectraModel) → TargetSpectra#

Generate or load target spectra from a wizard-style model.

Pass one of: - UserDefinedTargetSpectraModel(filePath) - RexelTargetSpectraModel(...) - NshmpTargetSpectraModel(...)

User-defined loads period–Sa points from the spectrum file. REXEL / NSHMP call the remote services and return resolved period–Sa points.

For REXEL, omit fields to use server/UI defaults (NTC18, Rome latitude/longitude, soil class A, and other code-specific wizard defaults). Which extra fields apply depends on seismicCode.

For NSHMP, longitude / latitude are required; omit other fields to use server/UI defaults (Conterminous U.S. 2018, vs30 760, AFE 2475, truncate/maxdir false).

matchToTargetSpectraManual(targetSpectra: TargetSpectra, pairs: list[MotionPairInfo], outputDirectory: str, amplitude: AmplitudeScalingParams | None = None, overwrite: bool = False) → MatchToTargetSpectraResult#

Amplitude-scale selected motion pairs to target spectra.

targetSpectra is a period–Sa list (build manually, or from getTargetSpectra with a model such as UserDefinedTargetSpectraModel(path)). pairs must be an explicit list (typically discovered.selectedPairs). outputDirectory must already be listed in Preferences → Motions.

matchToTargetSpectraAutomatic(database: GroundMotionDatabase, filters: DatabaseSearchFilters, targetSpectra: TargetSpectra, outputDirectory: str, selection: RecordSelectionParams | None = None, amplitude: AmplitudeScalingParams | None = None, overwrite: bool = False) → MatchToTargetSpectraResult#

Automatically select and scale database records to target spectra.

Requires a prior authenticateDatabase for database (GMDB or FDSN/ESM only; CESMD is not supported). filters must include at least one search criterion. outputDirectory must already be listed in Preferences → Motions. Omit selection / amplitude to use wizard defaults (amplitude also drives the selection period window and scale-factor bounds).

class rsseismic.Motion.Motion(client: Client, motionName: str)#

Bases: _ProxyObject

Inspect and transform one ground motion from the app motion library.

Obtain an instance from app.MotionLibrary.getMotion(name). Scaling, baseline correction, and timestep reduction write a new motion file and do not add it to the project or library automatically. Estimate Kappa returns fitted (or user-supplied) kappa-line values without plots.

property name: str#

Motion name (file name without extension).

getProperties() → MotionProperties#

Return timestep, Nyquist frequency, PGA, PGV, PGD, and point count.

Unit strings follow the Motion Manager units provider.

scaleToG(targetG: float, filePath: str, overwrite: bool = False) → ScaleMotionResult#

Scale this motion so peak acceleration equals targetG (in g) and save it.

The output file is not added to the motion library. When overwrite is False (default), an existing file at filePath is an error.

scaleBy(factor: float, filePath: str, overwrite: bool = False) → ScaleMotionResult#

Multiply this motion’s acceleration by factor and save it.

The output file is not added to the motion library. When overwrite is False (default), an existing file at filePath is an error.

getTimeHistoryData() → pandas.DataFrame#

Return the Single Motion View time-history table as a pandas DataFrame.

Columns match the UI grid: Time, Acceleration, Velocity, Displacement, AriasIntensity, and HousnerIntensity. Column units are in dataframe.attrs["column_units"] when available.

getSpectralData() → tuple[pandas.DataFrame, pandas.DataFrame]#

Return Fourier and spectral-acceleration tables as pandas DataFrames.

Returns:

A (fourier, spectralAcceleration) tuple. Fourier columns are Frequency, Amplitude, PhaseAngle, and SmoothedAmplitude. Spectral acceleration columns are Period plus the response-spectrum methods shown in Single Motion View. Column units are in dataframe.attrs["column_units"] when available.

estimateKappaFromBoundingFrequencies(startFrequency: float, endFrequency: float) → EstimateKappaResult#

Estimate kappa by linear regression between bounding frequencies (Hz).

Matches the Estimate Kappa dialog option “Bounding frequencies”. endFrequency must be less than 100 Hz.

estimateKappaFromConstantIntercept(kappa: float, yIntercept: float) → EstimateKappaResult#

Evaluate the kappa line from a constant kappa and Y-intercept.

Matches the Estimate Kappa dialog option “Constant value and intercept”. Start and end frequencies default to 0 Hz and 100 Hz on the server.

baselineCorrection(filePath: str, overwrite: bool = False) → BaselineCorrectionResult#

Apply baseline correction and save the corrected motion.

The output file is not added to the motion library. When overwrite is False (default), an existing file at filePath is an error.

timestepReduction(factor: int, filePath: str, overwrite: bool = False) → TimestepReductionResult#

Reduce the motion timestep by an integer factor of at least 2 and save it.

Use getProperties() on this motion for the original timestep, Nyquist frequency, and point count. The returned properties are the reduced motion. The output file is not added to the motion library. When overwrite is False (default), an existing file at filePath is an error.

class rsseismic.Motion.MotionPair(client: Client, pairId: str)#

Bases: _ProxyObject

Inspect and transform one horizontal ground-motion pair from the motion library.

Get an instance with app.MotionLibrary.getMotionPair(pairId). Use this for geometric-mean spectra, effective amplitude spectra, and scaling both components. For tools that apply to one component (kappa, baseline correction, timestep reduction), use h1 or h2. Scaling writes new files and does not add them to the library.

property pairId: str#

Pair name (shared prefix of the two horizontal motion file names).

property h1: Motion#

First horizontal component of this pair.

property h2: Motion#

Second horizontal component of this pair.

getProperties() → MotionPairProperties#

Return timestep, Nyquist frequency, PGA, PGV, PGD, and point count for both horizontals.

Values use the current Motion Manager display units.

getTimeHistoryData() → tuple[pandas.DataFrame, pandas.DataFrame]#

Return time-history tables for both horizontals.

Each table includes Time, Acceleration, Velocity, Displacement, AriasIntensity, and HousnerIntensity.

getSpectralData() → tuple[tuple[pandas.DataFrame, pandas.DataFrame], tuple[pandas.DataFrame, pandas.DataFrame]]#

Return Fourier and spectral-acceleration tables for both horizontals.

For each component, the first table is Fourier data and the second is spectral acceleration.

getGeometricMeanSpectrum(spectralType: GeometricMeanSpectralType = GeometricMeanSpectralType.FREQUENCY_DOMAIN) → pandas.DataFrame#

Return the geometric-mean response spectrum for this pair.

spectralType chooses the response-spectrum method (Frequency Domain, Duhamel, Duhamel with timestep correction, Newmark, or Newmark with timestep correction). Defaults to Frequency Domain.

getEffectiveAmplitudeSpectrum(bandwidth: float | None = None) → pandas.DataFrame#

Return the smoothed Effective Amplitude Spectrum (EAS) for this pair.

bandwidth is the Konno-Ohmachi smoothing parameter (PEER Report 2018/05), not a damping ratio. Omit it to use the recommended default (188.5).

scaleToG(targetG: float, h1FilePath: str, h2FilePath: str, overwrite: bool = False) → ScaleMotionPairResult#

Scale each horizontal so peak acceleration equals targetG (in g) and save both files.

Each component is scaled on its own peak. The saved files are not added to the motion library. When overwrite is False (default), an existing file at either path is an error.

scaleBy(factor: float, h1FilePath: str, h2FilePath: str, overwrite: bool = False) → ScaleMotionPairResult#

Multiply both horizontals by factor and save both files.

The saved files are not added to the motion library. When overwrite is False (default), an existing file at either path is an error.