@@ -887,6 +887,41 @@ def _set_nsky_parts(Nsrcs, cat_nfreqs, Nsky_parts):
887887 return Nsky_parts
888888
889889
890+ def _check_uvdata (input_uv ):
891+ """Perform UVData checks for run_uvdata_uvsim.
892+
893+ Moved checks to reduce complexity.
894+
895+ Parameters
896+ -----------
897+ input_uv : :class:`pyuvdata.UVData` instance
898+ Provides baseline/time/frequency information.
899+
900+ Returns
901+ -------
902+ the UVData ordering convention
903+ """
904+ if not isinstance (input_uv , UVData ):
905+ raise TypeError ("input_uv must be UVData object" )
906+
907+ if not (
908+ (input_uv .Npols == 4 )
909+ and (input_uv .polarization_array .tolist () == [- 5 , - 6 , - 7 , - 8 ])
910+ ):
911+ raise ValueError ("input_uv must have XX,YY,XY,YX polarization" )
912+
913+ if not input_uv .future_array_shapes :
914+ input_uv .use_future_array_shapes ()
915+
916+ input_order = input_uv .blt_order
917+ if input_order != ("time" , "baseline" ):
918+ input_uv .reorder_blts (order = "time" , minor_order = "baseline" )
919+
920+ return input_order
921+
922+
923+ # this function is very complex according to flake8.
924+ # too many ifs, we can swing back to this later.
890925def run_uvdata_uvsim (
891926 input_uv ,
892927 beam_list ,
@@ -986,21 +1021,7 @@ def run_uvdata_uvsim(
9861021 beam_dict = comm .bcast (beam_dict , root = 0 )
9871022 catalog .share (root = 0 )
9881023
989- if not isinstance (input_uv , UVData ):
990- raise TypeError ("input_uv must be UVData object" )
991-
992- if not (
993- (input_uv .Npols == 4 )
994- and (input_uv .polarization_array .tolist () == [- 5 , - 6 , - 7 , - 8 ])
995- ):
996- raise ValueError ("input_uv must have XX,YY,XY,YX polarization" )
997-
998- if not input_uv .future_array_shapes :
999- input_uv .use_future_array_shapes ()
1000-
1001- input_order = input_uv .blt_order
1002- if input_order != ("time" , "baseline" ):
1003- input_uv .reorder_blts (order = "time" , minor_order = "baseline" )
1024+ input_order = _check_uvdata (input_uv )
10041025
10051026 # The root node will initialize our simulation
10061027 # Read input file and make uvtask list
0 commit comments