Question - Load matrices from OP2

Skip to first unread message

Gustav Graves

Feb 8, 2021, 10:00:11 AMFeb 8
to pyNastran Discuss
Hello. I'm quite new to pyNastran and would appreciate little help. I've got OP2 file with results from modal analysis in which are stored modal mass matrices(EFMASS,EFMFACS etc.) My question is, how can I load these matrices into numpy array/matrix? I've got into the point where I've created the .matrix/Matrix "variable" but I am unable to load actual values. Here is copy from python console:

  Matrix['EFMASSS'];  shape=(6, 6);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=square
  Matrix['EFMFACS'];  shape=(1, 2);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=rectangular
  Matrix['EFMFSMS'];  shape=(1, 1);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=symmetric
  Matrix['MEFMASS'];  shape=(6, 2);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=rectangular
  Matrix['MEFWTS'];   shape=(6, 2);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=rectangular
  Matrix['MPFACS'];   shape=(6, 2);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=rectangular
  Matrix['RBMASSS'];  shape=(6, 6);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=square


Out[101]: Matrix['EFMASSS'];  shape=(6, 6);     type=scipy.sparse.coo.coo_matrix;      dtype=float64;   desc=square

Steven Doyle

Feb 8, 2021, 10:14:58 AMFeb 8
Ohh...those really should use numpy arrays vs. sparse matrices.  Close enough ;)

I think you’re getting confused due to the print.  It’s just meant to be a quick overview.  You just need:

    data = model.matrices[‘EFMASSS’].data

You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages