@@ -118,6 +118,56 @@ def gen_version_str(concise=False):
118118 return output
119119
120120
121+ def gen_data_str (data , concise = False ):
122+ """Generate a string representation summarizing current data.
123+
124+ Parameters
125+ ----------
126+ data : Data
127+ Data object to summarize data for.
128+ Can also be any derived data object (e.g. Data2D).
129+ concise : bool, optional, default: False
130+ Whether to print the report in concise mode.
131+
132+ Returns
133+ -------
134+ output : str
135+ Formatted string of data summary.
136+ """
137+
138+ # Get number of spectra, checking attributes for {Data3D, Data2DT, Data2D, Data}
139+ if getattr (data , 'n_events' , None ):
140+ n_spectra_str = '{} spectrograms with {} windows each' .format (data .n_events , data .n_time_windows )
141+ elif getattr (data , 'n_time_windows' , None ):
142+ n_spectra_str = '1 spectrogram with {} windows' .format (data .n_time_windows )
143+ elif getattr (data , 'n_spectra' , None ):
144+ n_spectra_str = '{} power spectra' .format (data .n_spectra )
145+ else :
146+ n_spectra_str = '1 power spectrum'
147+
148+ if not data .has_data :
149+
150+ no_data_str = "No data currently loaded in the object."
151+ str_lst = [DIVIDER ,'' , no_data_str , '' , DIVIDER ]
152+
153+ else :
154+
155+ str_lst = [
156+
157+ DIVIDER ,
158+ '' ,
159+ 'The data object contains {}' .format (n_spectra_str ),
160+ 'with a frequency range of {} Hz' .format (data .freq_range ),
161+ 'and a frequency resolution of {} Hz.' .format (data .freq_res ),
162+ '' ,
163+ DIVIDER ,
164+ ]
165+
166+ output = _format (str_lst , concise )
167+
168+ return output
169+
170+
121171def gen_modes_str (modes , description = False , concise = False ):
122172 """Generate a string representation of fit modes.
123173
0 commit comments