Exemplo n.º 1
0
    def dump(self, filename=".azimint.json"):
        """
        Dump the status of the current widget to a file in JSON

        @param filename: path where to save the config
        @type filename: str

        """
        print "Dump!"
        to_save = { "poni": str(self.poni.text()).strip(),
                    "detector": str(self.detector.currentText()).lower(),
                    "wavelength":float_(self.wavelength.text()),
                    "splineFile":str(self.splineFile.text()).strip(),
                    "pixel1": float_(self.pixel1.text()),
                    "pixel2":float_(self.pixel2.text()),
                    "dist":float_(self.dist.text()),
                    "poni1":float_(self.poni1.text()),
                    "poni2":float_(self.poni2.text()),
                    "rot1":float_(self.rot1.text()),
                    "rot2":float_(self.rot2.text()),
                    "rot3":float_(self.rot3.text()),
                    "do_dummy": bool(self.do_dummy.isChecked()),
                    "do_mask":  bool(self.do_mask.isChecked()),
                    "do_dark": bool(self.do_dark.isChecked()),
                    "do_flat": bool(self.do_flat.isChecked()),
                    "do_polarization":bool(self.do_polarization.isChecked()),
                    "val_dummy":float_(self.val_dummy.text()),
                    "delta_dummy":float_(self.delta_dummy.text()),
                    "mask_file":str(self.mask_file.text()).strip(),
                    "dark_current":str(self.dark_current.text()).strip(),
                    "flat_field":str(self.flat_field.text()).strip(),
                    "polarization_factor":float_(self.polarization_factor.value()),
                    "rad_pt":int_(self.rad_pt.text()),
                    "do_2D":bool(self.do_2D.isChecked()),
                    "azim_pt":int_(self.azim_pt.text()),
                    "chi_discontinuity_at_0": bool(self.chi_discontinuity_at_0.isChecked()),
                    "do_solid_angle": bool(self.do_solid_angle.isChecked()),
                    "do_radial_range": bool(self.do_radial_range.isChecked()),
                    "do_azimuthal_range": bool(self.do_azimuthal_range.isChecked()),
                    "do_poisson": bool(self.do_poisson.isChecked()),
                    "radial_range_min":float_(self.radial_range_min.text()),
                    "radial_range_max":float_(self.radial_range_max.text()),
                    "azimuth_range_min":float_(self.azimuth_range_min.text()),
                    "azimuth_range_max":float_(self.azimuth_range_max.text()),
                   }
        if self.q_nm.isChecked():
            to_save["unit"] = "q_nm^-1"
        elif self.q_A.isChecked():
            to_save["unit"] = "q_A^-1"
        elif self.tth_deg.isChecked():
            to_save["unit"] = "2th_deg"
        elif self.tth_rad.isChecked():
            to_save["unit"] = "2th_rad"
        elif self.r_mm.isChecked():
            to_save["unit"] = "r_mm"

        with open(filename, "w") as myFile:
            json.dump(to_save, myFile, indent=4)
        logger.debug("Saved")
Exemplo n.º 2
0
    def dump(self, filename=".azimint.json"):
        """
        Dump the status of the current widget to a file in JSON

        @param filename: path where to save the config
        @type filename: str

        """
        print "Dump!"
        to_save = {
            "poni": str(self.poni.text()).strip(),
            "detector": str(self.detector.currentText()).lower(),
            "wavelength": float_(self.wavelength.text()),
            "splineFile": str(self.splineFile.text()).strip(),
            "pixel1": float_(self.pixel1.text()),
            "pixel2": float_(self.pixel2.text()),
            "dist": float_(self.dist.text()),
            "poni1": float_(self.poni1.text()).strip(),
            "poni2": float_(self.poni2.text()).strip(),
            "rot1": float_(self.rot1.text()).strip(),
            "rot2": float_(self.rot2.text()).strip(),
            "rot3": float_(self.rot3.text()).strip(),
            "do_dummy": bool(self.do_dummy.isChecked()),
            "do_mask": bool(self.do_mask.isChecked()),
            "do_dark": bool(self.do_dark.isChecked()),
            "do_flat": bool(self.do_flat.isChecked()),
            "do_polarization": bool(self.do_polarization.isChecked()),
            "val_dummy": float_(self.val_dummy.text()).strip(),
            "delta_dummy": float_(self.delta_dummy.text()).strip(),
            "mask_file": str(self.mask_file.text()).strip(),
            "dark_current": str(self.dark_current.text()).strip(),
            "flat_field": str(self.flat_field.text()).strip(),
            "polarization_factor": float_(self.polarization_factor.value()),
            "nbpt_rad": int_(self.rad_pt.text()),
            "do_2D": bool(self.do_2D.isChecked()),
            "nbpt_azim": int_(self.nbpt_rad.text()),
            "chi_discontinuity_at_0":
            bool(self.chi_discontinuity_at_0.isChecked()),
            "do_radial_range": bool(self.do_radial_range.isChecked()),
            "do_azimuthal_range": bool(self.do_azimuthal_range.isChecked()),
            "radial_range_min": float_(self.radial_range_min.text()),
            "radial_range_max": float_(self.radial_range_max.text()),
            "azimuth_range_min": float_(self.azimuth_range_min.text()),
            "azimuth_range_max": float_(self.azimuth_range_max.text()),
        }
        if self.q_nm.isChecked():
            to_save["unit"] = "q_nm^-1"
        elif self.tth_deg.isChecked():
            to_save["unit"] = "2th_deg"
        elif self.r_mm.isChecked():
            to_save["unit"] = "r_mm"
        with open(filename, "w") as myFile:
            json.dump(to_save, myFile, indent=4)
        logger.debug("Saved")