Exemplo n.º 1
0
    def __init__(self, spots, targetResolution, fractionCalculator):
        #Total rows by formula
        Total_rows = int(math.pow(targetResolution / spots[len(spots) - 1],
                                  3.)) + 1
        Spreadsheet.__init__(self, rows=Total_rows)
        self.addColumn('Limit')
        self.addColumn('Fract')
        self.addColumn('Population', 0)
        self.addColumn('adjustPop',
                       Formula('self.Population[%row] / self.Fract[%row]'))

        # the outer resolution limit of the lowest-resolution shell
        self.Limit[0] = targetResolution
        self.Fract[0] = 1.0

        def BinRes(shellnumber):
            return self.Limit[0] / math.pow(shellnumber + 1, 1.0 / 3.0)

        #this little loop consumes 1.2 seconds of CPU time for a 1400-row spreadsheet
        for xrow in range(1, Total_rows):
            self.Limit[xrow] = BinRes(xrow)
            self.Fract[xrow] = fractionCalculator(self.Limit[xrow])

        bp = bin_populations(spots, self.Limit[0])
        for c in range(min(Total_rows,
                           len(bp))):  #reconcile inconsistent bin counts
            self.Population[c] = bp[c]

        self.Limit.format = "%.2f"
        self.Fract.format = "%.2f"
        self.Population.format = "%7d"
        self.adjustPop.format = "%7.1f"
Exemplo n.º 2
0
  def __init__(self,spots,targetResolution,fractionCalculator):
    #Total rows by formula
    Total_rows = int(math.pow(
       targetResolution/spots[len(spots)-1],3.))+1
    Spreadsheet.__init__(self,rows=Total_rows)
    self.addColumn('Limit')
    self.addColumn('Fract')
    self.addColumn('Population',0)
    self.addColumn('adjustPop',
                   Formula('self.Population[%row] / self.Fract[%row]'))

    # the outer resolution limit of the lowest-resolution shell
    self.Limit[0] = targetResolution
    self.Fract[0] = 1.0

    def BinRes(shellnumber):
      return self.Limit[0]/math.pow(shellnumber+1,1.0/3.0)

    #this little loop consumes 1.2 seconds of CPU time for a 1400-row spreadsheet
    for xrow in xrange(1,Total_rows):
      self.Limit[xrow] = BinRes(xrow)
      self.Fract[xrow] = fractionCalculator(self.Limit[xrow])

    bp = bin_populations(spots,self.Limit[0])
    for c in xrange(min(Total_rows,len(bp))): #reconcile inconsistent bin counts
        self.Population[c]=bp[c]

    self.Limit.format = "%.2f"
    self.Fract.format = "%.2f"
    self.Population.format = "%7d"
    self.adjustPop.format = "%7.1f"
Exemplo n.º 3
0
  def __init__(self,spots,phil_params,targetResolution=None,wavelength=None,
               max_total_rows=None,fractionCalculator=None,use_binning_of=None):

    if len(spots) == 0: return # No spots, no binwise analysis
    if use_binning_of is None or not hasattr(use_binning_of,"binning"):
      self.original_binning=True
      assert targetResolution is not None and wavelength is not None
      self.wavelength = wavelength

      #Total rows by formula
      Total_rows = int(math.pow(
         targetResolution/spots[len(spots)-1],3.))+1
      if max_total_rows is not None:
        Total_rows = min(Total_rows, max_total_rows)

      Spreadsheet.__init__(self,rows=Total_rows)
      self.addColumn('Limit')
      self.addColumn('Fract')
      self.addColumn('Missing') # fraction res shell remaining after missing cone is subtracted
      self.addColumn('Population',0)

      if fractionCalculator is not None and \
        phil_params.distl.bins.corner:
        last_d_star = 1./flex.min(fractionCalculator.corner_resolutions())
      else:
        last_d_star = 1./spots[-1]
      volume_fraction = (1./Total_rows)*math.pow(last_d_star,3)

      def BinRes(shellnumber):
        return 1./math.pow((shellnumber+1)*volume_fraction,1.0/3.0)

      #this little loop consumes 1.2 seconds of CPU time for a 1400-row spreadsheet
      for xrow in xrange(0,Total_rows):
        self.Limit[xrow] = BinRes(xrow)
        self.Fract[xrow] = fractionCalculator(self.Limit[xrow])

      self.populate_missing_cone(Total_rows)

    if use_binning_of is not None:
      if not hasattr(use_binning_of,"binning"):
        use_binning_of.binning = self #inject this spreadsheet into caller's space
      else:
        self.original_binning=False
        self.wavelength = wavelength

        Spreadsheet.__init__(self,rows=use_binning_of.binning.S_table_rows)
        self.addColumn('Limit')
        self.addColumn('Fract')
        self.addColumn('Missing')
        self.addColumn('Population',0)

        for xrow in xrange(0,self.S_table_rows):
          self.Limit[xrow] = use_binning_of.binning.Limit[xrow]
          self.Fract[xrow] = use_binning_of.binning.Fract[xrow]
          self.Missing[xrow] = use_binning_of.binning.Missing[xrow]
        Total_rows = self.S_table_rows

    bp = bin_populations(spots,self.Limit[0])
    for c in xrange(min(Total_rows,len(bp))): #reconcile inconsistent bin counts
        self.Population[c]=bp[c]

    self.Limit.format = "%.2f"
    self.Fract.format = "%.2f"
    self.Missing.format = "%.2f"
    self.Population.format = "%7d"
Exemplo n.º 4
0
    def __init__(self,
                 spots,
                 phil_params,
                 targetResolution=None,
                 wavelength=None,
                 max_total_rows=None,
                 fractionCalculator=None,
                 use_binning_of=None):

        if len(spots) == 0: return  # No spots, no binwise analysis
        if use_binning_of is None or not hasattr(use_binning_of, "binning"):
            self.original_binning = True
            assert targetResolution is not None and wavelength is not None
            self.wavelength = wavelength

            #Total rows by formula
            Total_rows = int(
                math.pow(targetResolution / spots[len(spots) - 1], 3.)) + 1
            if max_total_rows is not None:
                Total_rows = min(Total_rows, max_total_rows)

            Spreadsheet.__init__(self, rows=Total_rows)
            self.addColumn('Limit')
            self.addColumn('Fract')
            self.addColumn(
                'Missing'
            )  # fraction res shell remaining after missing cone is subtracted
            self.addColumn('Population', 0)

            if fractionCalculator is not None and \
              phil_params.distl.bins.corner:
                last_d_star = 1. / flex.min(
                    fractionCalculator.corner_resolutions())
            else:
                last_d_star = 1. / spots[-1]
            volume_fraction = (1. / Total_rows) * math.pow(last_d_star, 3)

            def BinRes(shellnumber):
                return 1. / math.pow(
                    (shellnumber + 1) * volume_fraction, 1.0 / 3.0)

            #this little loop consumes 1.2 seconds of CPU time for a 1400-row spreadsheet
            for xrow in xrange(0, Total_rows):
                self.Limit[xrow] = BinRes(xrow)
                self.Fract[xrow] = fractionCalculator(self.Limit[xrow])

            self.populate_missing_cone(Total_rows)

        if use_binning_of is not None:
            if not hasattr(use_binning_of, "binning"):
                use_binning_of.binning = self  #inject this spreadsheet into caller's space
            else:
                self.original_binning = False
                self.wavelength = wavelength

                Spreadsheet.__init__(self,
                                     rows=use_binning_of.binning.S_table_rows)
                self.addColumn('Limit')
                self.addColumn('Fract')
                self.addColumn('Missing')
                self.addColumn('Population', 0)

                for xrow in xrange(0, self.S_table_rows):
                    self.Limit[xrow] = use_binning_of.binning.Limit[xrow]
                    self.Fract[xrow] = use_binning_of.binning.Fract[xrow]
                    self.Missing[xrow] = use_binning_of.binning.Missing[xrow]
                Total_rows = self.S_table_rows

        bp = bin_populations(spots, self.Limit[0])
        for c in xrange(min(Total_rows,
                            len(bp))):  #reconcile inconsistent bin counts
            self.Population[c] = bp[c]

        self.Limit.format = "%.2f"
        self.Fract.format = "%.2f"
        self.Missing.format = "%.2f"
        self.Population.format = "%7d"