Skip to content

Commit 7ae494e

Browse files
committed
update get_response (dof can be int)f
1 parent 18b80fc commit 7ae494e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pyLump.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -482,24 +482,24 @@ def get_IRF_matrix(self, freq:np.ndarray, frf_method:str="f", return_t_axis:bool
482482
return IRF_matrix
483483

484484

485-
def get_response(self, exc_dof:np.ndarray|list, exc:np.ndarray, sampling_rate:int,
486-
resp_dof:np.ndarray=None, domain:str="f", frf_method:str="f",
485+
def get_response(self, exc_dof:np.ndarray|list|int, exc:np.ndarray, sampling_rate:int,
486+
resp_dof:np.ndarray|int=None, domain:str="f", frf_method:str="f",
487487
return_matrix:bool=False, return_t_axis:bool=False, return_f_axis:bool=False,
488488
**kwargs) -> np.ndarray|tuple[np.ndarray]:
489489
"""
490490
Get response time series.
491491
492492
Parameters
493493
----------
494-
exc_dof : ndarray, list
494+
exc_dof : ndarray, list, int
495495
Degrees of freedom (masses) where the system is excited.
496496
exc : ndarray
497497
Excitation time array 1D (one excitation DOF) or 2D (multiple excitation DOFs).
498498
1D shape (single excitation DOF): (time series)
499499
2D shape (multiple excitation DOFs): (number of DOFs, time series)
500500
sampling_rate : int
501501
Sampling rate of excitation time signals.
502-
resp_dof : ndarray, list, optional
502+
resp_dof : ndarray, list, int, optional
503503
Degrees of freedom (masses) where the response is calculated. If None - responses of all masses are caluclated.
504504
frf_method : str, optional
505505
Method of calculating the FRF matrix:
@@ -540,13 +540,17 @@ def get_response(self, exc_dof:np.ndarray|list, exc:np.ndarray, sampling_rate:in
540540
# check exc_dof:
541541
if isinstance(exc_dof, list):
542542
exc_dof = np.array(exc_dof)
543+
elif isinstance(exc_dof, int):
544+
exc_dof = np.array([exc_dof])
543545
if len(exc_dof.shape) > 1:
544546
raise Exception("Multiple dimension array not allowed for exc_dof array")
545547

546548
# check resp_dof:
547549
if resp_dof is not None:
548550
if isinstance(resp_dof, list):
549551
resp_dof = np.array(resp_dof)
552+
elif isinstance(resp_dof, int):
553+
resp_dof = np.array([resp_dof])
550554
if len(resp_dof.shape) > 1:
551555
raise Exception("Multiple dimension array not allowed for resp_dof array")
552556
else: # all rsponse DOFs are calculated

0 commit comments

Comments
 (0)