def show_summary(self, out=None, prefix=""): if (out is None): out = sys.stdout p = prefix print >> out, p+"Title:", self.title() print >> out, p+"Space group symbol from file:", self.space_group_name() print >> out, p+"Space group number from file:", self.space_group_number() self.space_group_info().show_summary( f=out, prefix=p+"Space group from matrices: ") print >> out, p+"Point group symbol from file:", self.point_group_name() if (self.n_batches() > 0): print >> out, p+"Number of batches:", self.n_batches() print >> out, p+"Number of crystals:", self.n_crystals() print >> out, p+"Number of Miller indices:", self.n_reflections() if (self.n_crystals() > 0 and self.n_reflections() > 0): print >> out, p+"Resolution range: %.6g %.6g" % self.max_min_resolution() print >> out, p+"History:" for line in self.history(): print >> out, p+" ", line.rstrip() for i_crystal,crystal in enumerate(self.crystals()): print >> out, p+"Crystal %d:" % (i_crystal+1) print >> out, p+" Name:", crystal.name() print >> out, p+" Project:", crystal.project_name() print >> out, p+" Id:", crystal.id() crystal.unit_cell().show_parameters(f=out, prefix=p+" Unit cell: ") print >> out, p+" Number of datasets:", crystal.n_datasets() for i_dataset,dataset in enumerate(crystal.datasets()): print >> out, p+" Dataset %d:" % (i_dataset+1) print >> out, p+" Name:", dataset.name() print >> out, p+" Id:", dataset.id() print >> out, p+" Wavelength: %.6g" % dataset.wavelength() print >> out, p+" Number of columns:", dataset.n_columns() if (dataset.n_columns() > 0): fields_list = [[ "label", "#valid", "%valid", "min", "max", "type", ""]] max_field_lengths = [len(field) for field in fields_list[0]] max_field_lengths[-2] = 0 for i_column,column in enumerate(dataset.columns()): fields = column.format_fields_for_mtz_dump( n_refl=self.n_reflections()) fields_list.append(fields) for i,field in enumerate(fields): max_field_lengths[i] = max(max_field_lengths[i], len(field)) format = " %%-%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%s" % tuple( max_field_lengths[:6]) for fields in fields_list: print >> out, p+(format % tuple(fields)).rstrip() return self
def as_miller_arrays_dict(self, crystal_symmetry=None, force_symmetry=False, merge_equivalents=True, base_array_info=None, anomalous=None): """ Returns a python dictionary with keys of tuples containing (crystal name, dataset name, column label) and values of the Miller arrays from :func:`as_miller_arrays`. The arguments to :func:`as_miller_arrays_dict` are the same as :func:`as_miller_arrays`. >>> miller_dict = mtz_file.as_miller_arrays_dict() >>> miller_dict[('NATIVE', 'NATIVE', 'FTOXD3')] <cctbx.miller.array at 0x108a87b90> >>> miller_dict[('NATIVE', 'NATIVE', 'SIGFTOXD3')] <cctbx.miller.array at 0x108a87b90> """ miller_arrays = self.as_miller_arrays( crystal_symmetry, force_symmetry, merge_equivalents, base_array_info, anomalous=anomalous ) keys = [] for crystal in self.crystals(): for dataset in crystal.datasets(): for label in dataset.column_labels(): keys.append((crystal.name(), dataset.name(), label)) miller_dict = {} ikeys = iter(keys) for miller_array in miller_arrays: for label in miller_array.info().labels: for key in ikeys: if label == key[2]: miller_dict[key] = miller_array break return miller_dict
def as_miller_arrays_dict(self, crystal_symmetry=None, force_symmetry=False, merge_equivalents=True, base_array_info=None): """ Returns a python dictionary with keys of tuples containing (crystal name, dataset name, column label) and values of the Miller arrays from :func:`as_miller_arrays`. The arguments to :func:`as_miller_arrays_dict` are the same as :func:`as_miller_arrays`. >>> miller_dict = mtz_file.as_miller_arrays_dict() >>> miller_dict[('NATIVE', 'NATIVE', 'FTOXD3')] <cctbx.miller.array at 0x108a87b90> >>> miller_dict[('NATIVE', 'NATIVE', 'SIGFTOXD3')] <cctbx.miller.array at 0x108a87b90> """ miller_arrays = self.as_miller_arrays(crystal_symmetry, force_symmetry, merge_equivalents, base_array_info) keys = [] for crystal in self.crystals(): for dataset in crystal.datasets(): for label in dataset.column_labels(): keys.append((crystal.name(), dataset.name(), label)) miller_dict = {} ikeys = iter(keys) for miller_array in miller_arrays: for label in miller_array.info().labels: for key in ikeys: if label == key[2]: miller_dict[key] = miller_array break return miller_dict