original_docstring: Load synthetic data and calculate histogram
docstring: Load synthetic data and calculate histogram
docstring_tokens: Load synthetic data and calculate histogram
code: def synthetic(self):
          """Load synthetic data and calculate histogram"""
  
          filelist = os.listdir(self.trackPath)
          trackfiles = [pjoin(self.trackPath, f) for f in filelist
                        if f.startswith('tracks')]
          self.synHist = -9999. * np.ones((len(trackfiles),
                                           len(self.lon_range),
                                           len(self.lat_range)))
  
          work_tag = 0
          result_tag = 1
  
          if (pp.rank() == 0) and (pp.size() > 1):
              w = 0
              n = 0
              for d in range(1, pp.size()):
                  pp.send(trackfiles[w], destination=d, tag=work_tag)
                  LOG.debug("Processing track file {0:d} of {1:d}".\
                            format(w, len(trackfiles)))
                  w += 1
  
              terminated = 0
              while terminated < pp.size() - 1:
                  results, status = pp.receive(pp.any_source, tag=result_tag,
                                               return_status=True)
                  self.synHist[n, :, :] = results
                  n += 1
  
                  d = status.source
                  if w < len(trackfiles):
                      pp.send(trackfiles[w], destination=d, tag=work_tag)
                      LOG.debug("Processing track file {0:d} of {1:d}".\
                                format(w, len(trackfiles)))
                      w += 1
                  else:
                      pp.send(None, destination=d, tag=work_tag)
                      terminated += 1
  
              self.calculateMeans()
  
          elif (pp.size() > 1) and (pp.rank() != 0):
              while True:
                  trackfile = pp.receive(source=0, tag=work_tag)
                  if trackfile is None:
                      break
  
                  LOG.debug("Processing %s", trackfile)
                  tracks = loadTracks(trackfile)
                  results = self._calculate(tracks) #/ self.synNumYears
                  pp.send(results, destination=0, tag=result_tag)
  
          elif (pp.size() == 1) and (pp.rank() == 0):
              for n, trackfile in enumerate(trackfiles):
                  LOG.debug("Processing track file {0:d} of {1:d}".\
                            format(n + 1, len(trackfiles)))
                  tracks = loadTracks(trackfile)
                  self.synHist[n, :, :] = self._calculate(tracks) #/ self.synNumYears
  
              self.calculateMeans()
code_tokens: def synthetic ( self ) : filelist = os . listdir ( self . trackPath ) trackfiles = [ pjoin ( self . trackPath , f ) for f in filelist if f . startswith ( 'tracks' ) ] self . synHist = - 9999. * np . ones ( ( len ( trackfiles ) , len ( self . lon_range ) , len ( self . lat_range ) ) ) work_tag = 0 result_tag = 1 if ( pp . rank ( ) == 0 ) and ( pp . size ( ) > 1 ) : w = 0 n = 0 for d in range ( 1 , pp . size ( ) ) : pp . send ( trackfiles [ w ] , destination = d , tag = work_tag ) LOG . debug ( "Processing track file {0:d} of {1:d}" . format ( w , len ( trackfiles ) ) ) w += 1 terminated = 0 while terminated < pp . size ( ) - 1 : results , status = pp . receive ( pp . any_source , tag = result_tag , return_status = True ) self . synHist [ n , : , : ] = results n += 1 d = status . source if w < len ( trackfiles ) : pp . send ( trackfiles [ w ] , destination = d , tag = work_tag ) LOG . debug ( "Processing track file {0:d} of {1:d}" . format ( w , len ( trackfiles ) ) ) w += 1 else : pp . send ( None , destination = d , tag = work_tag ) terminated += 1 self . calculateMeans ( ) elif ( pp . size ( ) > 1 ) and ( pp . rank ( ) != 0 ) : while True : trackfile = pp . receive ( source = 0 , tag = work_tag ) if trackfile is None : break LOG . debug ( "Processing %s" , trackfile ) tracks = loadTracks ( trackfile ) results = self . _calculate ( tracks ) pp . send ( results , destination = 0 , tag = result_tag ) elif ( pp . size ( ) == 1 ) and ( pp . rank ( ) == 0 ) : for n , trackfile in enumerate ( trackfiles ) : LOG . debug ( "Processing track file {0:d} of {1:d}" . format ( n + 1 , len ( trackfiles ) ) ) tracks = loadTracks ( trackfile ) self . synHist [ n , : , : ] = self . _calculate ( tracks ) self . calculateMeans ( )
short_docstring: Load synthetic data and calculate histogram
short_docstring_tokens: Load synthetic data and calculate histogram
comment: """Load synthetic data and calculate histogram"""$SEP$#/ self.synNumYears$SEP$#/ self.synNumYears