Example #1
0
def second_version(root=""):
    from srxraylib.metrology.dabam import dabam
    import matplotlib.pylab as plt
    entry = 900
    dm = dabam()
    dm.set_input_outputFileRoot("")  # avoid output files
    dm.set_input_silent(1)
    dm.set_entry(entry)
    dm.load()

    dm.inputs["setDetrending"] = -1

    # dm.inputs["plot"] = "heights"
    # dm.plot()
    # plt.show()

    f1 = plt.figure(1)
    plt.plot(1e3 * dm.y, 1e6 * dm.zHeights)
    plt.title('Slope Error RMS: %.3f urad\n' %
              (1e6 * dm.stdev_profile_slopes()))
    plt.xlabel("Y [mm]")
    plt.ylabel("Z [um]")
    if root != "":
        filename = "%s_%s.png" % (root, entry)
        plt.savefig(filename)
        print("File written to disk: %s" % filename)
    plt.show()

    print(dm.info_profiles())
Example #2
0
def first_version():
    dir = "../Oasys/"
    files = ["ID16A_ML_W-B4C_120Strp", "ID16A_KB1_VF", "ID16A_KB1_HF"]
    fontsize = 12

    plt.figure(figsize=(10, 10))

    plt_counter = 0
    for file in files:
        plt_counter += 1
        plt.subplot(3, 2, plt_counter)
        a = numpy.loadtxt(dir + file + ".dat")
        d = dabam()
        d.load_external_profile(a[:, 0], a[:, 1])

        # plot(1e3*d.y,1e9*d.zHeights,xtitle="X [mm]",ytitle="Height error [nm]",
        #      title=file,
        #      legend="Slope Error RMS = %4.3f urad"%(1e6*d.stdev_profile_slopes()),
        #      show=False)

        plt.plot(1e3 * d.y, 1e9 * d.zHeights)
        plt.xlabel("X [mm]", fontsize=fontsize)
        plt.ylabel("Height error [nm]", fontsize=fontsize)
        # plt.title("Slope Error RMS = %4.3f urad"%(1e6*d.stdev_profile_slopes()))

        # filename = file+"_heights.png"
        # plt.savefig(filename)
        # print("File written to disk: ",filename)
        # plt.show()

        plt_counter += 1
        plt.subplot(3, 2, plt_counter)
        # f3 = plt.figure(3)
        plt.loglog(d.f, d.psdHeights)
        # y = d.f ** (d.powerlaw["hgt_pendent"]) * 10 ** d.powerlaw["hgt_shift"]
        # i0 = d.powerlaw["index_from"]
        # i1 = d.powerlaw["index_to"]
        # plt.loglog(d.f, y)
        # plt.loglog(d.f[i0:i1], y[i0:i1])
        # beta = -d.powerlaw["hgt_pendent"]
        # plt.title("PSD of heights profile (beta=%.2f,Df=%.2f)" % (beta, (5 - beta) / 2))
        plt.xlabel("f [m^-1]", fontsize=fontsize)
        plt.ylabel("PSD [m^3]", fontsize=fontsize)
        # filename = file+"_psd.png"
        # plt.savefig(filename)
        # print("File written to disk: ",filename)
        # plt.show()

    filename = "metrology.pdf"
    plt.savefig(filename, bbox_inches='tight')
    print("File written to disk: ", filename)
    plt.show()
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Calculate Height Profile", self)
        self.runaction.triggered.connect(self.calculate_heigth_profile_ni)
        self.addAction(self.runaction)

        self.runaction = widget.OWAction("Generate Height Profile File", self)
        self.runaction.triggered.connect(self.generate_heigth_profile_file_ni)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(
            QRect(round(geom.width() * 0.05), round(geom.height() * 0.05),
                  round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                  round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        # DABAM INITIALIZATION
        self.server = dabam.dabam()
        self.server.set_input_silent(True)

        gui.separator(self.controlArea)

        button_box = oasysgui.widgetBox(self.controlArea,
                                        "",
                                        addSpace=False,
                                        orientation="horizontal")

        button = gui.button(button_box,
                            self,
                            "Calculate Height\nProfile",
                            callback=self.calculate_heigth_profile)
        button.setFixedHeight(45)

        button = gui.button(button_box,
                            self,
                            "Generate Height\nProfile File",
                            callback=self.generate_heigth_profile_file)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(150)

        button = gui.button(button_box,
                            self,
                            "Reset Fields",
                            callback=self.call_reset_settings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        gui.separator(self.controlArea)

        tabs_setting = oasysgui.tabWidget(self.controlArea)
        tabs_setting.setFixedHeight(self.TABS_AREA_HEIGHT)
        tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH - 5)

        tab_input = oasysgui.createTabPage(tabs_setting,
                                           "DABAM Search Setting")
        tab_gener = oasysgui.createTabPage(tabs_setting,
                                           "DABAM Generation Setting")
        tab_out = oasysgui.createTabPage(tabs_setting, "Output")

        manual_box = oasysgui.widgetBox(tab_input,
                                        "Manual Entry",
                                        addSpace=True,
                                        orientation="vertical")

        oasysgui.lineEdit(manual_box,
                          self,
                          "entry_number",
                          "Entry Number",
                          labelWidth=300,
                          valueType=int,
                          orientation="horizontal")

        gui.separator(manual_box)

        button = gui.button(manual_box,
                            self,
                            "Retrieve Profile",
                            callback=self.retrieve_profile)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH - 35)

        input_box = oasysgui.widgetBox(tab_input,
                                       "Search Parameters",
                                       addSpace=True,
                                       orientation="vertical")

        gui.comboBox(input_box,
                     self,
                     "shape",
                     label="Mirror Shape",
                     labelWidth=300,
                     items=[
                         "All", "Plane", "Cylindrical", "Elliptical",
                         "Toroidal", "Spherical"
                     ],
                     sendSelectedValue=False,
                     orientation="horizontal")

        gui.separator(input_box)

        input_box_1 = oasysgui.widgetBox(input_box,
                                         "",
                                         addSpace=True,
                                         orientation="horizontal")

        oasysgui.lineEdit(input_box_1,
                          self,
                          "slope_error_from",
                          "Slope Error From (" + u"\u03BC" + "rad)",
                          labelWidth=150,
                          valueType=float,
                          orientation="horizontal")
        oasysgui.lineEdit(input_box_1,
                          self,
                          "slope_error_to",
                          "To (" + u"\u03BC" + "rad)",
                          labelWidth=60,
                          valueType=float,
                          orientation="horizontal")

        input_box_2 = oasysgui.widgetBox(input_box,
                                         "",
                                         addSpace=True,
                                         orientation="horizontal")

        self.le_dimension_y_from = oasysgui.lineEdit(input_box_2,
                                                     self,
                                                     "dimension_y_from",
                                                     "Mirror Length From",
                                                     labelWidth=150,
                                                     valueType=float,
                                                     orientation="horizontal")
        self.le_dimension_y_to = oasysgui.lineEdit(input_box_2,
                                                   self,
                                                   "dimension_y_to",
                                                   "To",
                                                   labelWidth=60,
                                                   valueType=float,
                                                   orientation="horizontal")

        table_box = oasysgui.widgetBox(tab_input,
                                       "Search Results",
                                       addSpace=True,
                                       orientation="vertical",
                                       height=250)

        self.overlay_search = Overlay(table_box, self.search_profiles)
        self.overlay_search.hide()

        button = gui.button(input_box,
                            self,
                            "Search",
                            callback=self.overlay_search.show)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH - 35)

        gui.comboBox(table_box,
                     self,
                     "use_undetrended",
                     label="Use Undetrended Profile",
                     labelWidth=300,
                     items=["No", "Yes"],
                     callback=self.table_item_clicked,
                     sendSelectedValue=False,
                     orientation="horizontal")

        gui.separator(table_box)

        self.scrollarea = QScrollArea()
        self.scrollarea.setMinimumWidth(self.CONTROL_AREA_WIDTH - 35)

        table_box.layout().addWidget(self.scrollarea,
                                     alignment=Qt.AlignHCenter)

        self.table = QTableWidget(1, 5)
        self.table.setStyleSheet("background-color: #FBFBFB;")
        self.table.setAlternatingRowColors(True)
        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
        self.table.verticalHeader().setVisible(False)

        self.table.setColumnWidth(0, 40)
        self.table.setColumnWidth(1, 70)
        self.table.setColumnWidth(2, 70)
        self.table.setColumnWidth(3, 85)
        self.table.setColumnWidth(4, 80)

        self.table.resizeRowsToContents()
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.itemClicked.connect(self.table_item_clicked)

        self.scrollarea.setWidget(self.table)
        self.scrollarea.setWidgetResizable(1)

        output_profile_box = oasysgui.widgetBox(
            tab_gener,
            "Surface Generation Parameters",
            addSpace=True,
            orientation="vertical",
            height=370)

        gui.comboBox(output_profile_box,
                     self,
                     "center_y",
                     label="Center Profile in the middle of O.E.",
                     labelWidth=300,
                     items=["No", "Yes"],
                     sendSelectedValue=False,
                     orientation="horizontal")

        gui.separator(output_profile_box)

        gui.comboBox(output_profile_box,
                     self,
                     "modify_y",
                     label="Modify Length?",
                     labelWidth=150,
                     items=[
                         "No", "Rescale to new length",
                         "Fit to new length (fill or cut)"
                     ],
                     callback=self.set_ModifyY,
                     sendSelectedValue=False,
                     orientation="horizontal")

        self.modify_box_1 = oasysgui.widgetBox(output_profile_box,
                                               "",
                                               addSpace=False,
                                               orientation="vertical",
                                               height=60)

        self.modify_box_2 = oasysgui.widgetBox(output_profile_box,
                                               "",
                                               addSpace=False,
                                               orientation="vertical",
                                               height=60)
        self.le_new_length_1 = oasysgui.lineEdit(self.modify_box_2,
                                                 self,
                                                 "new_length",
                                                 "New Length",
                                                 labelWidth=300,
                                                 valueType=float,
                                                 orientation="horizontal")

        self.modify_box_3 = oasysgui.widgetBox(output_profile_box,
                                               "",
                                               addSpace=False,
                                               orientation="vertical",
                                               height=60)
        self.le_new_length_2 = oasysgui.lineEdit(self.modify_box_3,
                                                 self,
                                                 "new_length",
                                                 "New Length",
                                                 labelWidth=300,
                                                 valueType=float,
                                                 orientation="horizontal")
        oasysgui.lineEdit(self.modify_box_3,
                          self,
                          "filler_value",
                          "Filler Value (if new length > profile length) [nm]",
                          labelWidth=300,
                          valueType=float,
                          orientation="horizontal")

        self.set_ModifyY()

        gui.comboBox(output_profile_box,
                     self,
                     "renormalize_y",
                     label="Renormalize Length Profile to different RMS",
                     labelWidth=300,
                     items=["No", "Yes"],
                     callback=self.set_RenormalizeY,
                     sendSelectedValue=False,
                     orientation="horizontal")

        self.output_profile_box_1 = oasysgui.widgetBox(output_profile_box,
                                                       "",
                                                       addSpace=False,
                                                       orientation="vertical",
                                                       height=60)
        self.output_profile_box_2 = oasysgui.widgetBox(output_profile_box,
                                                       "",
                                                       addSpace=False,
                                                       orientation="vertical",
                                                       height=60)

        gui.comboBox(
            self.output_profile_box_1,
            self,
            "error_type_y",
            label="Normalization to",
            labelWidth=270,
            items=["Figure Error (nm)", "Slope Error (" + u"\u03BC" + "rad)"],
            sendSelectedValue=False,
            orientation="horizontal")

        oasysgui.lineEdit(self.output_profile_box_1,
                          self,
                          "rms_y",
                          "Rms Value",
                          labelWidth=300,
                          valueType=float,
                          orientation="horizontal")

        self.set_RenormalizeY()

        output_box = oasysgui.widgetBox(tab_gener,
                                        "Outputs",
                                        addSpace=True,
                                        orientation="vertical")

        select_file_box = oasysgui.widgetBox(output_box,
                                             "",
                                             addSpace=True,
                                             orientation="horizontal")

        self.le_heigth_profile_file_name = oasysgui.lineEdit(
            select_file_box,
            self,
            "heigth_profile_file_name",
            "Output File Name",
            labelWidth=120,
            valueType=str,
            orientation="horizontal")

        gui.button(select_file_box, self, "...", callback=self.selectFile)

        self.shadow_output = oasysgui.textArea(height=400)

        out_box = oasysgui.widgetBox(tab_out,
                                     "System Output",
                                     addSpace=True,
                                     orientation="horizontal",
                                     height=500)
        out_box.layout().addWidget(self.shadow_output)

        gui.rubber(self.controlArea)

        self.initializeTabs()

        gui.rubber(self.mainArea)

        self.overlay_search.raise_()
    def __init__(self):
        super().__init__()

        self.runaction = widget.OWAction("Calculate Height Profile", self)
        self.runaction.triggered.connect(self.calculate_heigth_profile_ni)
        self.addAction(self.runaction)

        self.runaction = widget.OWAction("Generate Height Profile File", self)
        self.runaction.triggered.connect(self.generate_heigth_profile_file_ni)
        self.addAction(self.runaction)

        geom = QApplication.desktop().availableGeometry()
        self.setGeometry(QRect(round(geom.width() * 0.05),
                               round(geom.height() * 0.05),
                               round(min(geom.width() * 0.98, self.MAX_WIDTH)),
                               round(min(geom.height() * 0.95, self.MAX_HEIGHT))))

        self.setMaximumHeight(self.geometry().height())
        self.setMaximumWidth(self.geometry().width())

        # DABAM INITIALIZATION
        self.server = dabam.dabam()
        self.server.set_input_silent(True)

        gui.separator(self.controlArea)

        button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=False, orientation="horizontal")

        button = gui.button(button_box, self, "Calculate Height\nProfile", callback=self.calculate_heigth_profile)
        button.setFixedHeight(45)

        button = gui.button(button_box, self, "Generate Height\nProfile File", callback=self.generate_heigth_profile_file)
        font = QFont(button.font())
        font.setBold(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Blue'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)
        button.setFixedWidth(150)

        button = gui.button(button_box, self, "Reset Fields", callback=self.call_reset_settings)
        font = QFont(button.font())
        font.setItalic(True)
        button.setFont(font)
        palette = QPalette(button.palette())  # make a copy of the palette
        palette.setColor(QPalette.ButtonText, QColor('Dark Red'))
        button.setPalette(palette)  # assign new palette
        button.setFixedHeight(45)

        gui.separator(self.controlArea)

        tabs_setting = gui.tabWidget(self.controlArea)
        tabs_setting.setFixedHeight(self.TABS_AREA_HEIGHT)
        tabs_setting.setFixedWidth(self.CONTROL_AREA_WIDTH-5)

        tab_input = oasysgui.createTabPage(tabs_setting, "DABAM Search Setting")
        tab_gener = oasysgui.createTabPage(tabs_setting, "DABAM Generation Setting")
        tab_out = oasysgui.createTabPage(tabs_setting, "Output")

        manual_box = oasysgui.widgetBox(tab_input, "Manual Entry", addSpace=True, orientation="vertical")

        oasysgui.lineEdit(manual_box, self, "entry_number", "Entry Number",
                           labelWidth=300, valueType=int, orientation="horizontal")

        gui.separator(manual_box)

        button = gui.button(manual_box, self, "Retrieve Profile", callback=self.retrieve_profile)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH-35)

        input_box = oasysgui.widgetBox(tab_input, "Search Parameters", addSpace=True, orientation="vertical")

        gui.comboBox(input_box, self, "shape", label="Mirror Shape", labelWidth=300,
                     items=["All", "Plane", "Cylindrical", "Elliptical", "Toroidal", "Spherical"],
                     sendSelectedValue=False, orientation="horizontal")

        gui.separator(input_box)
        
        input_box_1 = oasysgui.widgetBox(input_box, "", addSpace=True, orientation="horizontal")

        oasysgui.lineEdit(input_box_1, self, "slope_error_from", "Slope Error From (" + u"\u03BC" + "rad)",
                           labelWidth=150, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(input_box_1, self, "slope_error_to", "To (" + u"\u03BC" + "rad)",
                           labelWidth=60, valueType=float, orientation="horizontal")

        input_box_2 = oasysgui.widgetBox(input_box, "", addSpace=True, orientation="horizontal")

        self.le_dimension_y_from = oasysgui.lineEdit(input_box_2, self, "dimension_y_from", "Mirror Length From",
                           labelWidth=150, valueType=float, orientation="horizontal")
        self.le_dimension_y_to = oasysgui.lineEdit(input_box_2, self, "dimension_y_to", "To",
                           labelWidth=60, valueType=float, orientation="horizontal")

        table_box = oasysgui.widgetBox(tab_input, "Search Results", addSpace=True, orientation="vertical", height=290)

        self.overlay_search = Overlay(table_box, self.search_profiles)
        self.overlay_search.hide()

        button = gui.button(input_box, self, "Search", callback=self.overlay_search.show)
        button.setFixedHeight(35)
        button.setFixedWidth(self.CONTROL_AREA_WIDTH-35)

        gui.comboBox(table_box, self, "use_undetrended", label="Use Undetrended Profile", labelWidth=300,
                     items=["No", "Yes"], callback=self.table_item_clicked, sendSelectedValue=False, orientation="horizontal")

        gui.separator(table_box)

        self.scrollarea = QScrollArea()
        self.scrollarea.setMinimumWidth(self.CONTROL_AREA_WIDTH-35)

        table_box.layout().addWidget(self.scrollarea, alignment=Qt.AlignHCenter)

        self.table = QTableWidget(1, 5)
        self.table.setAlternatingRowColors(True)
        self.table.horizontalHeader().setResizeMode(QHeaderView.Fixed)
        self.table.verticalHeader().setVisible(False)

        self.table.setColumnWidth(0, 40)
        self.table.setColumnWidth(1, 70)
        self.table.setColumnWidth(2, 70)
        self.table.setColumnWidth(3, 85)
        self.table.setColumnWidth(4, 80)

        self.table.resizeRowsToContents()
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.itemClicked.connect(self.table_item_clicked)

        self.scrollarea.setWidget(self.table)
        self.scrollarea.setWidgetResizable(1)

        output_profile_box = oasysgui.widgetBox(tab_gener, "Surface Generation Parameters", addSpace=True, orientation="vertical", height=270)

        self.le_dimension_x = oasysgui.lineEdit(output_profile_box, self, "dimension_x", "Width",
                           labelWidth=300, valueType=float, orientation="horizontal")
        self.le_step_x = oasysgui.lineEdit(output_profile_box, self, "step_x", "Step Width",
                           labelWidth=300, valueType=float, orientation="horizontal")

        gui.comboBox(output_profile_box, self, "center_y", label="Center Profile in the middle of O.E.", labelWidth=300,
                     items=["No", "Yes"], sendSelectedValue=False, orientation="horizontal")

        gui.comboBox(output_profile_box, self, "modify_y", label="Modify Length?", labelWidth=240,
                     items=["No", "Rescale to new length", "Fit to new length (fill or cut)"], callback=self.set_ModifyY, sendSelectedValue=False, orientation="horizontal")

        self.modify_box_1 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)

        self.modify_box_2 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)
        oasysgui.lineEdit(self.modify_box_2, self, "scale_factor_y", "Scale Factor", labelWidth=300, valueType=float, orientation="horizontal")

        self.modify_box_3 = oasysgui.widgetBox(output_profile_box, "", addSpace=False, orientation="vertical", height=50)
        self.le_new_length = oasysgui.lineEdit(self.modify_box_3, self, "new_length", "New Length", labelWidth=300, valueType=float, orientation="horizontal")
        oasysgui.lineEdit(self.modify_box_3, self, "filler_value", "Filler Value (if new length > profile length) [nm]", labelWidth=300, valueType=float, orientation="horizontal")

        self.set_ModifyY()

        gui.comboBox(output_profile_box, self, "renormalize_y", label="Renormalize Length Profile to different RMS", labelWidth=300,
                     items=["No", "Yes"], callback=self.set_RenormalizeY, sendSelectedValue=False, orientation="horizontal")

        self.output_profile_box_1 = oasysgui.widgetBox(output_profile_box, "", addSpace=True, orientation="vertical")

        gui.comboBox(self.output_profile_box_1, self, "error_type_y", label="Normalization to", labelWidth=270,
                     items=["Figure Error (nm)", "Slope Error (" + u"\u03BC" + "rad)"],
                     sendSelectedValue=False, orientation="horizontal")

        oasysgui.lineEdit(self.output_profile_box_1, self, "rms_y", "Rms Value",
                           labelWidth=300, valueType=float, orientation="horizontal")

        self.set_RenormalizeY()

        output_box = oasysgui.widgetBox(tab_gener, "Outputs", addSpace=True, orientation="vertical")

        select_file_box = oasysgui.widgetBox(output_box, "", addSpace=True, orientation="horizontal")

        self.le_heigth_profile_file_name = oasysgui.lineEdit(select_file_box, self, "heigth_profile_file_name", "Output File Name",
                                                        labelWidth=120, valueType=str, orientation="horizontal")

        gui.button(select_file_box, self, "...", callback=self.selectFile)

        self.shadow_output = QTextEdit()
        self.shadow_output.setReadOnly(True)

        out_box = oasysgui.widgetBox(tab_out, "System Output", addSpace=True, orientation="horizontal", height=500)
        out_box.layout().addWidget(self.shadow_output)

        gui.rubber(self.controlArea)

        self.initializeTabs()

        gui.rubber(self.mainArea)

        self.overlay_search.raise_()
Example #5
0
data = [x_shadow, y_shadow, z_shadow]
plt.plot(x_shadow, z_shadow[1])
plt.show()

writesrwfile = 'mirror_srw2D.dat'
#writepsdfile='mirror_srw_psd_format.dat'
write_srw_format_profile(data, writesrwfile)
#write_psd_analysis_format_profile(data,writepsdfile)

(x_srw, y_srw, z_srw) = get_srw_format_profile(writesrwfile)
#data=[x_srw,y_srw,z_srw]
plt.plot(x_srw, z_srw[0])
plt.show()

####################PSD calculation of new generated profile#########################
dm = dabam.dabam()
dm.load_external_profile([(1e-3) * i for i in x_srw],
                         [(1e-3) * i for i in z_srw[0]],
                         type='heights')  #switch unit from mm to m
plt.plot(1e3 * dm.y, 1e9 * dm.zHeightsUndetrended)
plt.show()
plt.plot(1e3 * dm.y, 1e9 * dm.zHeights)
plt.show()

plt.loglog(dm.f, dm.psdHeights, label=dabam_entry)
y = dm.f**(dm.powerlaw["hgt_pendent"]) * 10**dm.powerlaw["hgt_shift"]
i0 = dm.powerlaw["index_from"]
i1 = dm.powerlaw["index_to"]
plt.loglog(dm.f, y)
plt.loglog(dm.f[i0:i1], y[i0:i1])
beta = -dm.powerlaw["hgt_pendent"]
Example #6
0
import numpy
from srxraylib.metrology.dabam import dabam
from srxraylib.plot.gol import plot

dm = dabam()


def load_dabam_profile(entry_number,
                       mirror_length=2 * 0.07,
                       mirror_points=100,
                       mirror_rms=25e-9,
                       do_plot=True):

    # print(dm.inputs)

    dm.inputs['entryNumber'] = entry_number
    dm.load()  # access data

    # dm.inputs['plot'] = "heights"
    # dm.plot()

    x00 = dm.y.copy()
    y00 = dm.zHeights.copy()

    #center
    x0 = x00 - x00[x00.size // 2]
    y0 = y00.copy()
    #rescale abscissas
    x0 = x0 / numpy.abs(x0).max() * 0.5 * mirror_length
    # rescale heights
    print("RMS mirror: %5.3f nm " % (1e9 * y0.std()))
def test_kb_with_external_errors():

    #
    # initialize shadow3 source (oe0) and beam
    #
    beam = Shadow.Beam()
    oe0  = Shadow.Source()

    #

    # preprocessors
    #



    prerefl(interactive=0,SYMBOL="Pt",DENSITY=21.45,FILE="Pt5_55.dat",E_MIN=5000.0,E_MAX=55000.0,E_STEP=100.0)

    bragg(interactive=0,DESCRIPTOR="Si",H_MILLER_INDEX=1,K_MILLER_INDEX=1,L_MILLER_INDEX=1,TEMPERATURE_FACTOR=1.0,
                                            E_MIN=5000.0,E_MAX=53000.0,E_STEP=50,SHADOW_FILE="si5_55.111")
    dm = dabam.dabam()
    dm.set_input_shadowCalc(1)
    dm.set_input_shadowNx(10)
    dm.set_input_shadowWidth(10.0)
    dm.load(21)


    oe0.BENER = 6.03999996
    oe0.EPSI_X = 5.5200001e-08
    oe0.EPSI_Z = 1.07999998e-09
    oe0.FDISTR = 4
    oe0.FSOURCE_DEPTH = 4
    oe0.F_COLOR = 3
    oe0.F_PHOT = 0
    oe0.HDIV1 = 0.00079999998
    oe0.HDIV2 = 0.00079999998
    oe0.ISTAR1 = 567656
    oe0.NCOL = 0
    oe0.NPOINT = 500000
    oe0.N_COLOR = 0
    oe0.PH1 = 10000.0
    oe0.PH2 = 10010.0
    oe0.POL_DEG = 0.0
    oe0.R_ALADDIN = 2685.56747
    oe0.R_MAGNET = 26.8556747
    oe0.SIGDIX = 0.0
    oe0.SIGDIZ = 0.0
    oe0.SIGMAX = 0.00230000005
    oe0.SIGMAY = 0.0
    oe0.SIGMAZ = 0.000360000005
    oe0.VDIV1 = 2.20000002e-05
    oe0.VDIV2 = 2.20000002e-05
    oe0.WXSOU = 0.0
    oe0.WYSOU = 0.0
    oe0.WZSOU = 0.0


    bl = Shadow.CompoundOE(name="BL")
    bl.append_monochromator_double_crystal(p0=3153,q0=503,photon_energy_ev=10005,separation=40.0,
                    reflectivity_file="si5_55.111")

    bl.append_kb(p0=498.0,q0=95.0,separation=30.0,focal_positions=[4154.0,95.0],
                 dimensions1=[6.0,30.0],dimensions2=[6.0,30.0],reflectivity_kind=[1,1],
                 reflectivity_files=["Pt5_55.dat",
                                     "Pt5_55.dat"],
                 surface_error_files=["Shadow.dat",
                                      "Shadow.dat"])
                 # surface_error_files=["/mnt/scisoft/users/srio/Working/rt/CRG-LISA/MICROFUOCO_v01/mirror.dat",
                 #                      "/mnt/scisoft/users/srio/Working/rt/CRG-LISA/MICROFUOCO_v01/mirror.dat"])


    beam.genSource(oe0)

    beam.traceCompoundOE(bl)

    return beam
def test_kb_with_external_errors():

    #
    # initialize shadow3 source (oe0) and beam
    #
    beam = Shadow.Beam()
    oe0 = Shadow.Source()

    #

    # preprocessors
    #

    prerefl(interactive=0,
            SYMBOL="Pt",
            DENSITY=21.45,
            FILE="Pt5_55.dat",
            E_MIN=5000.0,
            E_MAX=55000.0,
            E_STEP=100.0)

    bragg(interactive=0,
          DESCRIPTOR="Si",
          H_MILLER_INDEX=1,
          K_MILLER_INDEX=1,
          L_MILLER_INDEX=1,
          TEMPERATURE_FACTOR=1.0,
          E_MIN=5000.0,
          E_MAX=53000.0,
          E_STEP=50,
          SHADOW_FILE="si5_55.111")
    dm = dabam.dabam()
    dm.set_input_shadowCalc(1)
    dm.set_input_shadowNx(10)
    dm.set_input_shadowWidth(10.0)
    dm.load(21)

    oe0.BENER = 6.03999996
    oe0.EPSI_X = 5.5200001e-08
    oe0.EPSI_Z = 1.07999998e-09
    oe0.FDISTR = 4
    oe0.FSOURCE_DEPTH = 4
    oe0.F_COLOR = 3
    oe0.F_PHOT = 0
    oe0.HDIV1 = 0.00079999998
    oe0.HDIV2 = 0.00079999998
    oe0.ISTAR1 = 567656
    oe0.NCOL = 0
    oe0.NPOINT = 500000
    oe0.N_COLOR = 0
    oe0.PH1 = 10000.0
    oe0.PH2 = 10010.0
    oe0.POL_DEG = 0.0
    oe0.R_ALADDIN = 2685.56747
    oe0.R_MAGNET = 26.8556747
    oe0.SIGDIX = 0.0
    oe0.SIGDIZ = 0.0
    oe0.SIGMAX = 0.00230000005
    oe0.SIGMAY = 0.0
    oe0.SIGMAZ = 0.000360000005
    oe0.VDIV1 = 2.20000002e-05
    oe0.VDIV2 = 2.20000002e-05
    oe0.WXSOU = 0.0
    oe0.WYSOU = 0.0
    oe0.WZSOU = 0.0

    bl = Shadow.CompoundOE(name="BL")
    bl.append_monochromator_double_crystal(p0=3153,
                                           q0=503,
                                           photon_energy_ev=10005,
                                           separation=40.0,
                                           reflectivity_file="si5_55.111")

    bl.append_kb(p0=498.0,
                 q0=95.0,
                 separation=30.0,
                 focal_positions=[4154.0, 95.0],
                 dimensions1=[6.0, 30.0],
                 dimensions2=[6.0, 30.0],
                 reflectivity_kind=[1, 1],
                 reflectivity_files=["Pt5_55.dat", "Pt5_55.dat"],
                 surface_error_files=["Shadow.dat", "Shadow.dat"])
    # surface_error_files=["/mnt/scisoft/users/srio/Working/rt/CRG-LISA/MICROFUOCO_v01/mirror.dat",
    #                      "/mnt/scisoft/users/srio/Working/rt/CRG-LISA/MICROFUOCO_v01/mirror.dat"])

    beam.genSource(oe0)

    beam.traceCompoundOE(bl)

    return beam