コード例 #1
0
ファイル: xsh_bragg.py プロジェクト: hlp2002/ShadowOui
    def compute(self):
        try:
            sys.stdout = EmittingStream(textWritten=self.writeStdOut)

            self.checkFields()

            if not self.DESCRIPTOR == 18:  # GRAPHITE
                tmp = bragg(interactive=False,
                            DESCRIPTOR=self.crystals[self.DESCRIPTOR],
                            H_MILLER_INDEX=self.H_MILLER_INDEX,
                            K_MILLER_INDEX=self.K_MILLER_INDEX,
                            L_MILLER_INDEX=self.L_MILLER_INDEX,
                            TEMPERATURE_FACTOR=self.TEMPERATURE_FACTOR,
                            E_MIN=self.E_MIN,
                            E_MAX=self.E_MAX,
                            E_STEP=self.E_STEP,
                            SHADOW_FILE=congruence.checkFileName(
                                self.SHADOW_FILE))
            else:
                OWxsh_bragg.new_bragg(
                    H_MILLER_INDEX=self.H_MILLER_INDEX,
                    K_MILLER_INDEX=self.K_MILLER_INDEX,
                    L_MILLER_INDEX=self.L_MILLER_INDEX,
                    TEMPERATURE_FACTOR=self.TEMPERATURE_FACTOR,
                    E_MIN=self.E_MIN,
                    E_MAX=self.E_MAX,
                    E_STEP=self.E_STEP,
                    SHADOW_FILE=congruence.checkFileName(self.SHADOW_FILE))

            self.send("PreProcessor_Data",
                      ShadowPreProcessorData(bragg_data_file=self.SHADOW_FILE))
        except Exception as exception:
            QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)

            if self.IS_DEVELOP: raise exception
コード例 #2
0
 def send_data(self, dimension_x, dimension_y):
     self.send(
         "PreProcessor_Data",
         ShadowPreProcessorData(
             error_profile_data_file=self.heigth_profile_file_name,
             error_profile_x_dim=dimension_x,
             error_profile_y_dim=dimension_y))
コード例 #3
0
    def generate_waviness_file(self, not_interactive_mode=False):
        if not self.zz is None and not self.yy is None and not self.xx is None:
            try:
                congruence.checkDir(self.waviness_file_name)

                sys.stdout = EmittingStream(textWritten=self.writeStdOut)

                ST.write_shadow_surface(self.zz.T,
                                        self.xx,
                                        self.yy,
                                        outFile=congruence.checkFileName(
                                            self.waviness_file_name))
                if not not_interactive_mode:
                    QMessageBox.information(
                        self, "QMessageBox.information()", "Waviness file " +
                        self.waviness_file_name + " written on disk",
                        QMessageBox.Ok)

                self.send(
                    "PreProcessor_Data",
                    ShadowPreProcessorData(
                        error_profile_data_file=self.waviness_file_name,
                        error_profile_x_dim=self.dimension_x,
                        error_profile_y_dim=self.dimension_y))
            except Exception as exception:
                QMessageBox.critical(self, "Error", exception.args[0],
                                     QMessageBox.Ok)
コード例 #4
0
    def convert_surface(self):
        if not self.oasys_data is None:
            try:
                if isinstance(self.oasys_data, OasysPreProcessorData):
                    error_profile_data = self.oasys_data.error_profile_data
                    surface_data = error_profile_data.surface_data
                    error_profile_data_file = surface_data.surface_data_file

                    filename, file_extension = os.path.splitext(error_profile_data_file)

                    if (file_extension==".hd5" or file_extension==".hdf5" or file_extension==".hdf" or file_extension==".h5"):
                        error_profile_data_file = filename + "_shadow.dat"

                    ST.write_shadow_surface(surface_data.zz/self.workspace_units_to_m,
                                            numpy.round(surface_data.xx/self.workspace_units_to_m, 6),
                                            numpy.round(surface_data.yy/self.workspace_units_to_m, 6),
                                            error_profile_data_file)

                    self.send("PreProcessor_Data", ShadowPreProcessorData(error_profile_data_file=error_profile_data_file,
                                                                          error_profile_x_dim=error_profile_data.error_profile_x_dim/self.workspace_units_to_m,
                                                                          error_profile_y_dim=error_profile_data.error_profile_y_dim/self.workspace_units_to_m))
                elif isinstance(self.oasys_data, OasysSurfaceData):
                    surface_data_file = self.oasys_data.surface_data_file

                    filename, file_extension = os.path.splitext(surface_data_file)

                    if (file_extension==".hd5" or file_extension==".hdf5" or file_extension==".hdf" or file_extension==".h5"):
                        surface_data_file = filename + "_shadow.dat"

                    ST.write_shadow_surface(self.oasys_data.zz/self.workspace_units_to_m,
                                            numpy.round(self.oasys_data.xx/self.workspace_units_to_m, 9),
                                            numpy.round(self.oasys_data.yy/self.workspace_units_to_m, 9),
                                            surface_data_file)

                    error_profile_x_dim = abs(self.oasys_data.xx[-1] - self.oasys_data.xx[0])/self.workspace_units_to_m
                    error_profile_y_dim = abs(self.oasys_data.yy[-1] - self.oasys_data.yy[0])/self.workspace_units_to_m

                    self.send("PreProcessor_Data", ShadowPreProcessorData(error_profile_data_file=surface_data_file,
                                                                          error_profile_x_dim=error_profile_x_dim,
                                                                          error_profile_y_dim=error_profile_y_dim))



            except Exception as exception:
                QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)

                if self.IS_DEVELOP: raise exception
コード例 #5
0
 def send_data(self, height_profile_file_names, dimension_x, dimension_y):
     self.send(
         "PreProcessor_Data",
         ShadowPreProcessorData(
             error_profile_data_file=height_profile_file_names,
             error_profile_x_dim=dimension_x,
             error_profile_y_dim=dimension_y))
     self.send("Files", height_profile_file_names)
コード例 #6
0
    def compute(self):
        try:
            sys.stdout = EmittingStream(textWritten=self.writeStdOut)

            self.checkFields()

            if self.GRADE_DEPTH == 0:
                FILE_DEPTH = "NONE"
            else:
                FILE_DEPTH = congruence.checkFileName(self.FILE_DEPTH)

            if self.GRADE_SURFACE == 1:
                FILE_SHADOW = congruence.checkFileName(self.FILE_SHADOW)
                FILE_THICKNESS = congruence.checkFileName(self.FILE_THICKNESS)
                FILE_GAMMA = congruence.checkFileName(self.FILE_GAMMA)
            else:
                FILE_SHADOW = "NONE"
                FILE_THICKNESS = "NONE"
                FILE_GAMMA = "NONE"

            tmp = pre_mlayer(
                interactive=False,
                FILE=congruence.checkFileName(self.FILE),
                E_MIN=self.E_MIN,
                E_MAX=self.E_MAX,
                S_DENSITY=self.S_DENSITY,
                S_MATERIAL=self.S_MATERIAL,
                E_DENSITY=self.E_DENSITY,
                E_MATERIAL=self.E_MATERIAL,
                O_DENSITY=self.O_DENSITY,
                O_MATERIAL=self.O_MATERIAL,
                GRADE_DEPTH=self.GRADE_DEPTH,
                N_PAIRS=self.N_PAIRS,
                THICKNESS=self.THICKNESS,
                GAMMA=self.GAMMA,
                ROUGHNESS_EVEN=self.ROUGHNESS_EVEN,
                ROUGHNESS_ODD=self.ROUGHNESS_ODD,
                FILE_DEPTH=FILE_DEPTH,
                GRADE_SURFACE=self.GRADE_SURFACE,
                FILE_SHADOW=FILE_SHADOW,
                FILE_THICKNESS=FILE_THICKNESS,
                FILE_GAMMA=FILE_GAMMA,
                AA0=self.AA0,
                AA1=self.AA1,
                AA2=self.AA2,
                AA3=self.AA3,
            )

            self.send(
                "PreProcessor_Data",
                ShadowPreProcessorData(m_layer_data_file_dat=self.FILE,
                                       m_layer_data_file_sha=self.FILE_SHADOW))
        except Exception as exception:
            QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)
コード例 #7
0
    def convert_surfaces(self):
        if not self.oasys_data is None:
            try:
                if isinstance(self.oasys_data, OasysPreProcessorData):
                    error_profile_data = self.oasys_data.error_profile_data
                    surface_data = error_profile_data.surface_data

                    error_profile_data_files = []

                    for xx, yy, zz, error_profile_data_file in zip(
                            surface_data.xx, surface_data.yy, surface_data.zz,
                            surface_data.surface_data_file):

                        filename, file_extension = os.path.splitext(
                            error_profile_data_file)

                        if (file_extension == ".hd5"
                                or file_extension == ".hdf5"
                                or file_extension == ".hdf"):
                            error_profile_data_file = filename + "_shadow.dat"

                        ST.write_shadow_surface(
                            zz / self.workspace_units_to_m,
                            numpy.round(xx / self.workspace_units_to_m, 6),
                            numpy.round(yy / self.workspace_units_to_m, 6),
                            error_profile_data_file)

                        error_profile_data_files.append(
                            error_profile_data_file)

                    self.send(
                        "PreProcessor_Data",
                        ShadowPreProcessorData(
                            error_profile_data_file=error_profile_data_files,
                            error_profile_x_dim=error_profile_data.
                            error_profile_x_dim / self.workspace_units_to_m,
                            error_profile_y_dim=error_profile_data.
                            error_profile_y_dim / self.workspace_units_to_m))
                    self.send("Files", error_profile_data_files)
            except Exception as exception:
                QMessageBox.critical(self, "Error", str(exception),
                                     QMessageBox.Ok)

                if self.IS_DEVELOP: raise exception
コード例 #8
0
    def compute(self):
        try:
            sys.stdout = EmittingStream(textWritten=self.writeStdOut)

            self.checkFields()

            tmp = prerefl(interactive=False,
                          SYMBOL=self.SYMBOL,
                          DENSITY=self.DENSITY,
                          FILE=congruence.checkFileName(self.SHADOW_FILE),
                          E_MIN=self.E_MIN,
                          E_MAX=self.E_MAX,
                          E_STEP=self.E_STEP)

            self.send(
                "PreProcessor_Data",
                ShadowPreProcessorData(prerefl_data_file=self.SHADOW_FILE))
        except Exception as exception:
            QMessageBox.critical(self, "Error", str(exception), QMessageBox.Ok)
    def completeOperations(self, shadow_oe):
        shadow_oe_temp = shadow_oe.duplicate()
        input_beam_temp = self.input_beam.duplicate(history=False)

        self.manage_acceptance_slits(shadow_oe_temp)

        ShadowBeam.traceFromOE(input_beam_temp,
                               shadow_oe_temp,
                               write_start_file=0,
                               write_end_file=0,
                               widget_class_name=type(self).__name__)

        x, y, z = self.calculate_ideal_surface(shadow_oe_temp)

        bender_parameter, z_bender_correction = self.calculate_bender_correction(
            y, z, self.kind_of_bender, self.shape)

        self.M1_out = round(bender_parameter[0],
                            int(6 * self.workspace_units_to_mm))
        if self.shape == TRAPEZIUM:
            self.e_out = round(bender_parameter[1], 5)
            if self.kind_of_bender == DOUBLE_MOMENTUM:
                self.ratio_out = round(bender_parameter[2], 5)
        elif self.shape == RECTANGLE:
            if self.kind_of_bender == DOUBLE_MOMENTUM:
                self.ratio_out = round(bender_parameter[1], 5)

        self.plot3D(x, y, z_bender_correction, 2, "Ideal - Bender Surfaces")

        if self.modified_surface > 0:
            x_e, y_e, z_e = ShadowPreProcessor.read_surface_error_file(
                self.ms_defect_file_name)

            if len(x) == len(x_e) and len(y) == len(y_e) and \
                    x[0] == x_e[0] and x[-1] == x_e[-1] and \
                    y[0] == y_e[0] and y[-1] == y_e[-1]:
                z_figure_error = z_e
            else:
                z_figure_error = interp2d(y_e, x_e, z_e, kind='cubic')(y, x)

            z_bender_correction += z_figure_error

            self.plot3D(x, y, z_figure_error, 3, "Figure Error Surface")
            self.plot3D(x, y, z_bender_correction, 4,
                        "Ideal - Bender + Figure Error Surfaces")

        ST.write_shadow_surface(z_bender_correction.T, numpy.round(x, 6),
                                numpy.round(y, 6), self.output_file_name_full)

        # Add new surface as figure error
        shadow_oe._oe.F_RIPPLE = 1
        shadow_oe._oe.F_G_S = 2
        shadow_oe._oe.FILE_RIP = bytes(self.output_file_name_full, 'utf-8')

        # Redo Raytracing with the new file
        super().completeOperations(shadow_oe)

        self.send(
            "PreProcessor_Data",
            ShadowPreProcessorData(
                error_profile_data_file=self.output_file_name,
                error_profile_x_dim=self.dim_x_plus + self.dim_x_minus,
                error_profile_y_dim=self.dim_y_plus + self.dim_y_minus))