@@ -346,7 +346,6 @@ def __check_if_field_id(self, field):
346346 else :
347347 return field .id .id != 0
348348
349- @protect_grpc
350349 def _get_frequencies (self , cplx = False ):
351350 """Retrieves a field of all the frequencies in the model
352351 (complex or real).
@@ -361,17 +360,13 @@ def _get_frequencies(self, cplx=False):
361360 field : dpf.core.Field
362361 Field of all the frequencies in the model (complex or real).
363362 """
364- request = time_freq_support_pb2 .ListRequest ()
365- request .time_freq_support .CopyFrom (self ._message )
366363
367- list_response = self ._stub .List (request )
368- if cplx is True and self .__check_if_field_id (list_response .freq_complex ):
369- return dpf .core .Field (server = self ._server , field = list_response .freq_complex )
370- elif cplx is False and self .__check_if_field_id (list_response .freq_real ):
371- return dpf .core .Field (server = self ._server , field = list_response .freq_real )
372- return None
364+ attributes_list = self ._get_attributes_list ()
365+ if cplx and "freq_complex" in attributes_list :
366+ return attributes_list ["freq_complex" ]
367+ elif cplx != True and "freq_real" in attributes_list :
368+ return attributes_list ["freq_real" ]
373369
374- @protect_grpc
375370 def _get_rpms (self ):
376371 """Retrieves a field of all the RPMs in the model.
377372
@@ -380,15 +375,10 @@ def _get_rpms(self):
380375 field : dpf.core.Field
381376 Field of all the RPMs in the model (complex or real).
382377 """
383- request = time_freq_support_pb2 .ListRequest ()
384- request .time_freq_support .CopyFrom (self ._message )
378+ attributes_list = self ._get_attributes_list ()
379+ if "rpm" in attributes_list :
380+ return attributes_list ["rpm" ]
385381
386- list_response = self ._stub .List (request )
387- if self .__check_if_field_id (list_response .rpm ):
388- return dpf .core .Field (server = self ._server , field = list_response .rpm )
389- return None
390-
391- @protect_grpc
392382 def _get_harmonic_indices (self , stage_num = 0 ):
393383 """Retrieves a field of all the harmonic indices in the model.
394384
@@ -400,16 +390,34 @@ def _get_harmonic_indices(self, stage_num=0):
400390 stage_num: int, optional, default = 0
401391 Targeted stage number.
402392 """
393+ attributes_list = self ._get_attributes_list (stage_num )
394+ if "cyc_harmonic_index" in attributes_list :
395+ return attributes_list ["cyc_harmonic_index" ]
396+
397+ @protect_grpc
398+ def _get_attributes_list (self , stage_num = None ):
403399 request = time_freq_support_pb2 .ListRequest ()
404400 request .time_freq_support .CopyFrom (self ._message )
405- request . cyclic_stage_num = stage_num
406-
401+ if stage_num :
402+ request . cyclic_stage_num = stage_num
407403 list_response = self ._stub .List (request )
408- if self .__check_if_field_id (list_response .cyc_harmonic_index ):
409- return dpf .core .Field (
410- server = self ._server , field = list_response .cyc_harmonic_index
411- )
412- return None
404+ out = {}
405+ if list_response .HasField ("freq_real" ):
406+ out ["freq_real" ] = dpf .core .Field (
407+ server = self ._server , field = list_response .freq_real )
408+ if list_response .HasField ("freq_complex" ):
409+ out ["freq_complex" ] = dpf .core .Field (
410+ server = self ._server , field = list_response .freq_complex )
411+ if list_response .HasField ("rpm" ):
412+ out ["rpm" ] = dpf .core .Field (
413+ server = self ._server , field = list_response .rpm )
414+ if list_response .HasField ("cyc_harmonic_index" ):
415+ out ["cyc_harmonic_index" ] = dpf .core .Field (
416+ server = self ._server , field = list_response .cyc_harmonic_index )
417+ if list_response .HasField ("cyclic_harmonic_index_scoping" ):
418+ out ["cyclic_harmonic_index_scoping" ] = dpf .core .Scoping (
419+ server = self ._server , scoping = list_response .cyclic_harmonic_index_scoping )
420+ return out
413421
414422 def append_step (
415423 self ,
0 commit comments