elif _type == 'repr': np.fill_diagonal(_ellipsoid, _T) # The mathematics of this transformation can be found on pp. 206 in Giacovazzo _X_ijk = np.matmul(_V, np.matmul(_ellipsoid, np.transpose(_V))) _X_abc = np.matmul( structure.ABC_Mbt_IJK, np.matmul(_X_ijk, np.transpose(structure.ABC_Mbt_IJK))) _X_o = np.linalg.inv(np.matmul(oMa, np.matmul(_X_abc, oMa))) * _scale _magnetic_atom_U_index = cf[_blockname][ '_atom_site_aniso_label'].index(atom) cf[_blockname]['_atom_site_aniso_U_11'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[0, 0]) cf[_blockname]['_atom_site_aniso_U_22'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[1, 1]) cf[_blockname]['_atom_site_aniso_U_33'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[2, 2]) cf[_blockname]['_atom_site_aniso_U_23'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[1, 2]) cf[_blockname]['_atom_site_aniso_U_13'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[0, 2]) cf[_blockname]['_atom_site_aniso_U_12'][ _magnetic_atom_U_index] = '{:<7.5f}'.format(_X_o[0, 1]) _outname = _cifname[:-4] + '_magn.cif' outfile = open(_outname, 'w') outfile.write(cf.WriteOut()) outfile.close() subprocess.Popen(['mercury', '{}'.format(_outname)])
def finalise_parameters(self, file_name, index, current_temp): #Finalises the CIF with important parameters such as beamline parameters cif = ReadCif(file_name) try: data_block = cif[str(index + 1)] except TypeError as error: os.remove(file_name) self.logger.info(f'Cif empty due to poor refinement - {error}') else: self.C = data_block['_diffrn_reflns_number'] self.A = data_block['_diffrn_reflns_theta_min'] self.B = data_block['_diffrn_reflns_theta_max'] beamline = self.cfg['User_Parameters_Full_Pipeline'][ 'Experiment_Configuration']['beamline'] if beamline != '': data_block['_computing_data_collection'] = self.cfg[ 'Instrument_Parameters'][beamline + '_data_collection'] data_block['_exptl_absorp_correction_type'] = self.cfg[ 'Instrument_Parameters'][beamline + '_absorp_correction'] data_block['_diffrn_radiation_wavelength'] = self.cfg[ 'User_Parameters_Full_Pipeline'][ 'Experiment_Configuration']['wavelength'] data_block['_diffrn_radiation_type'] = self.cfg[ 'Instrument_Parameters'][beamline + '_radiation_type'] data_block['_diffrn_source'] = self.cfg[ 'Instrument_Parameters'][beamline + '_radiation_type'] data_block['_diffrn_measurement_device_type'] = self.cfg[ 'Instrument_Parameters'][beamline + '_detector'] data_block['_diffrn_measurement_method'] = self.cfg[ 'Instrument_Parameters'][beamline + '_measurement_method'] data_block['_computing_cell_refinement'] = self.cfg[ 'Instrument_Parameters'][beamline + '_cell_refinement'] data_block['_computing_data_reduction'] = self.cfg[ 'Instrument_Parameters'][beamline + '_cell_refinement'] data_block['_computing_structure_solution'] = self.cfg[ 'Instrument_Parameters'][beamline + '_structure_soln'] data_block['_diffrn_radiation_monochromator'] = self.cfg[ 'Instrument_Parameters'][beamline + '_monochromator'] data_block['_diffrn_radiation_source'] = self.cfg[ 'Instrument_Parameters'][beamline + '_source'] data_block['_chemical_formula_moiety'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'chemical_formula'] data_block['_exptl_crystal_colour'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'crystal_colour'] data_block['_exptl_crystal_description'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'crystal_habit'] data_block['_cell_measurement_temperature'] = current_temp data_block['_diffrn_ambient_temperature'] = current_temp data_block['_exptl_crystal_size_max'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'max_crystal_dimension'] data_block['_exptl_crystal_size_mid'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'middle_crystal_dimension'] data_block['_exptl_crystal_size_min'] = self.cfg[ 'User_Parameters_Full_Pipeline']['Crystal_Descriptions'][ 'min_crystal_dimension'] data_block['_cell_measurement_reflns_used'] = self.C data_block['_cell_measurement_theta_min'] = self.A data_block['_cell_measurement_theta_max'] = self.B with open('edited.cif', 'w') as updated: updated.write(cif.WriteOut()) os.rename('edited.cif', file_name)