• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python filesystem.join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pts.core.tools.filesystem.join函数的典型用法代码示例。如果您正苦于以下问题:Python join函数的具体用法?Python join怎么用?Python join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了join函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: make_animation

    def make_animation(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Making animation ...")

        # Get the best
        best = self.optimizer.best

        # Determine path
        temp_path = self.optimizer.config.path
        filepath = fs.join(temp_path, "best.png")

        # Make plot of best

        # Create animated gif
        animation = Animation()

        # Open the images present in the directory
        for path in fs.files_in_path(temp_path, extension="png", exact_not_name="best"):
            # Add frame to the animation
            animation.add_frame_from_file(path)

        # Save the animation
        animation_path = fs.join(temp_path, "animation.gif")
        animation.saveto(animation_path)
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:test.py


示例2: setup

    def setup(self, **kwargs):

        """
        This function ...
        :param kwargs:
        :return:
        """

        # Call the setup function of the base class
        super(M81TestBase, self).setup(**kwargs)

        # Reference base path
        self.reference_path = fs.create_directory_in(self.path, "ref")

        # Reference wcs path
        self.reference_wcs_path = fs.join(self.reference_path, "wcs.txt")

        # Reference ski path
        self.reference_ski_path = fs.join(self.reference_path, "M81.ski")

        # Determine the simulation input and output path
        self.simulation_input_path = fs.create_directory_in(self.reference_path, "in")
        self.simulation_output_path = fs.create_directory_in(self.reference_path, "out")
        self.simulation_extract_path = fs.create_directory_in(self.reference_path, "extr")
        self.simulation_plot_path = fs.create_directory_in(self.reference_path, "plot")
        self.simulation_misc_path = fs.create_directory_in(self.reference_path, "misc")

        # Determine the path to the wavelength grid file
        self.wavelength_grid_path = fs.join(self.simulation_input_path, reference_wavelength_grid_filename)

        # Create the plot path
        self.plot_path = fs.create_directory_in(self.path, "plot")

        # Set the execution platforms
        self.set_platforms()
开发者ID:SKIRT,项目名称:PTS,代码行数:35,代码来源:base.py


示例3: create_dataset

    def create_dataset(self, masks=None):

        """
        This function ...
        :param masks:
        :return:
        """

        # Inform the user
        log.info("Creating the dataset ...")

        # Initialize
        self.dataset = DataSet()

        # Add the frames
        for fltr in self.frames:

            # Determine name for the image
            name = str(fltr)

            # Determine path for this frame
            path = fs.join(self.data_frames_path, name + ".fits")

            # Debugging
            log.debug("Saving the frame ...")

            # Save the frame
            self.frames[fltr].saveto(path)

            # Debugging
            log.debug("Adding the '" + name + "' image to the dataset ...")

            # Add the frame to the dataset
            self.dataset.add_path(name, path)

            # Determine the path for the mask
            mask_path = fs.join(self.data_masks_path, name + ".fits")

            # Mask
            if masks is not None and fltr in masks:

                # Debugging
                log.debug("Saving the mask ...")

                # Save
                masks[fltr].saveto(mask_path)

                # Debugging
                log.debug("Adding mask ...")

                # Add the mask
                self.dataset.add_mask_path(name, mask_path)

        # Determine database path
        path = fs.join(self.path, "database.dat")

        # Write the dataset
        self.dataset.saveto(path)
开发者ID:SKIRT,项目名称:PTS,代码行数:58,代码来源:base.py


示例4: import_package_update

    def import_package_update(self, name, as_name=None, from_name=None, show_output=False):

        """
        Thins function ...
        :param name:
        :param as_name:
        :param from_name:
        :param show_output:
        :return:
        """

        # Try to import
        success, module_name, import_statement = self.import_package(name, as_name=as_name, from_name=from_name, show_output=show_output, return_false_if_fail=True, return_failed_module=True)

        # Not succesful, try updating the module on which it failed
        if not success:

            # No problem module, show import statement
            if module_name is None: raise RuntimeError("Unsolvable import error occured at: '" + import_statement + "'")

            # Debugging
            log.debug("Import of '" + name + "' was unsuccesful: trying updating the '" + module_name + "' package ...")

            from ..prep.update import update_pts_dependencies_remote

            # Find conda
            conda_installation_path, conda_main_executable_path = self.remote.find_conda()

            # Determine the conda environment for PTS
            env_name = self.remote.conda_environment_for_pts
            if env_name is None: raise Exception("Cannot determine the conda environment used for pts")
            conda_environment = env_name

            environment_bin_path = fs.join(conda_installation_path, "envs", conda_environment, "bin")
            if not self.remote.is_directory(environment_bin_path): raise RuntimeError("The environment directory is not present")
            conda_executable_path = fs.join(environment_bin_path, "conda")

            # Set ...
            conda_pip_path = fs.join(environment_bin_path, "pip")
            conda_python_path = fs.join(environment_bin_path, "python")
            conda_easy_install_path = fs.join(environment_bin_path, "easy_install")

            # Update the module
            packages = [module_name]
            update_pts_dependencies_remote(self.remote, packages, conda_executable_path,
                                           conda_environment, conda_python_path, conda_pip_path,
                                           conda_easy_install_path)

            # Try again
            success, module_name, import_statement = self.import_package(name, as_name=as_name, from_name=from_name,
                                                       show_output=show_output, return_false_if_fail=True,
                                                       return_failed_module=True)

            # Not succesful again
            if not success: raise ImportError("The import statement '" + import_statement + "' failed on remote host '" + self.host_id + "'")
开发者ID:SKIRT,项目名称:PTS,代码行数:55,代码来源:python.py


示例5: old

    def old(self):

        """
        This function ...
        :return:
        """

        exit()

        # FWHM of all the images
        fwhm = 11.18 * u("arcsec")
        fwhm_pix = (fwhm / frame.average_pixelscale).to("pix").value
        sigma = fwhm_pix * statistics.fwhm_to_sigma

        # Get the center pixel of the galaxy
        parameters_path = fs.join(components_path, "parameters.dat")
        parameters = load_parameters(parameters_path)
        center = parameters.center.to_pixel(frame.wcs)

        # Create a source around the galaxy center
        ellipse = PixelEllipseRegion(center, 20.0*sigma)
        source = Source.from_ellipse(model_residual, ellipse, 1.5)

        source.estimate_background("polynomial")

        source.plot()

        position = source.center
        model = source.subtracted.fit_model(position, "Gaussian")

        rel_center = center - Extent(source.x_min, source.y_min)
        rel_model = fitting.shifted_model(model, -source.cutout.x_min, -source.cutout.y_min)
        plotting.plot_peak_model(source.cutout, rel_center.x, rel_center.y, rel_model)

        model_fwhm_pix = fitting.fwhm(model)
        model_fwhm = (model_fwhm_pix * frame.average_pixelscale).to("arcsec")

        print("Model FWHM: ", model_fwhm)

        evaluated_model = source.cutout.evaluate_model(model)

        all_residual = Frame(np.copy(model_residual))
        all_residual[source.y_slice, source.x_slice] -= evaluated_model
        all_residual.saveto(fs.join(residuals_path, "all_residual.fits"))

        model = Gaussian2D(amplitude=0.0087509425805, x_mean=center.x, y_mean=center.y, x_stddev=sigma, y_stddev=sigma)
        rel_model = fitting.shifted_model(model, -source.cutout.x_min, -source.cutout.y_min)
        plotting.plot_peak_model(source.cutout, rel_center.x, rel_center.y, rel_model)

        evaluated_model = source.cutout.evaluate_model(model)

        all_residual2 = Frame(np.copy(model_residual))
        all_residual2[source.y_slice, source.x_slice] -= evaluated_model
        all_residual2.saveto(fs.join(residuals_path, "all_residual2.fits"))
开发者ID:SKIRT,项目名称:PTS,代码行数:54,代码来源:residuals.py


示例6: restore_chi_squared

    def restore_chi_squared(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Restoring the chi squared tables ...")

        # Loop over the generations
        for generation_name in self.generation_names:

            # Has generation?
            if not self.has_generation(generation_name): continue

            # Debugging
            log.debug("Creating backup of chi squared table for generation '" + generation_name + "' ...")

            # Get the generation
            generation = self.generations[generation_name]

            # Get the generation path
            generation_path = self.get_generation_restore_path(generation_name)

            # Determine the filepath
            filepath = fs.join(generation_path, "chi_squared.dat")

            # Copy the file
            fs.copy_file(filepath, generation.chi_squared_table_path)
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:restore.py


示例7: load_i1

    def load_i1(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Loading the IRAC 3.6 micron image ...")

        # Determine the path to the truncated 3.6 micron image
        #path = fs.join(truncation_path, "IRAC I1.fits")

        path = fs.join(self.prep_path, "IRAC I1", "result.fits")
        frame = Frame.from_file(path)

        # Convert the frame to Jy/pix
        conversion_factor = 1.0
        conversion_factor *= 1e6

        # Convert the 3.6 micron image from Jy / sr to Jy / pixel
        pixelscale = frame.average_pixelscale
        pixel_factor = (1.0/pixelscale**2).to("pix2/sr").value
        conversion_factor /= pixel_factor
        frame *= conversion_factor
        frame.unit = "Jy"

        # Set the frame
        self.i1_jy = frame
开发者ID:SKIRT,项目名称:PTS,代码行数:29,代码来源:residuals.py


示例8: uninstall_conda_remote

    def uninstall_conda_remote(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Uninstalling the Conda python distribution on the remote host ...")

        # Determine path of miniconda installation
        installation_path = fs.join(self.remote.home_directory, "miniconda")
        if not self.remote.is_directory(installation_path):
            log.warning("Conda was not found on the remote host")
            return

        # Debugging
        log.debug("Removing the Conda directory ...")

        # Remove the directory
        self.remote.remove_directory(installation_path)

        # Debugging
        log.debug("Removing lines from shell configuration ...")

        # Remove lines from shell configuration file
        comment = "For Conda, added by PTS (Python Toolkit for SKIRT)"
        self.remote.remove_aliases_and_variables_with_comment(comment)
        self.remote.remove_from_path_variable_containing("miniconda/bin")
开发者ID:SKIRT,项目名称:PTS,代码行数:29,代码来源:uninstaller.py


示例9: create_wcs

    def create_wcs(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Creating the WCS ...")

        min_pixelscale = None

        # Determine the path to the headers directory
        headers_path = fs.join(m81_data_path, "headers")

        # Loop over the header files
        for path, name in fs.files_in_path(headers_path, extension="txt", returns=["path", "name"]):

            # Get the filter
            fltr = parse_filter(name)
            filter_name = str(fltr)

            # Set the path of the file for the filter name
            self.wcs_paths[filter_name] = path

            # Get WCS
            wcs = CoordinateSystem.from_header_file(path)

            # Adjust the pixelscale
            if min_pixelscale is None:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
            elif min_pixelscale > wcs.pixelscale:
                min_pixelscale = wcs.pixelscale
                self.wcs = wcs
开发者ID:SKIRT,项目名称:PTS,代码行数:35,代码来源:test.py


示例10: uninstall_conda_local

    def uninstall_conda_local(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Uninstalling the Conda python distribution locally ...")

        # Check installation
        installation_path = fs.join(fs.home, "miniconda")
        if not fs.is_directory(installation_path):
            log.warning("Conda was not found locally")
            return

        # Debugging
        log.debug("Removing the Conda directory ...")

        # Remove the directory
        fs.remove_directory(installation_path)

        # Debugging
        log.debug("Removing lines from shell configuration ...")

        # Remove lines from shell configuration file
        comment = "For Conda, added by PTS (Python Toolkit for SKIRT)"
        terminal.remove_aliases_and_variables_with_comment(comment)
        terminal.remove_from_path_variable_containing("miniconda/bin")
开发者ID:SKIRT,项目名称:PTS,代码行数:29,代码来源:uninstaller.py


示例11: run_script

def run_script(matches, args):

    """
    This function ...
    :param matches:
    :param args:
    :return:
    """

    if args.remote is not None: raise ValueError("This do command cannot be executed remotely")

    match = matches[0]

    # Execute the matching script, after adjusting the command line arguments so that it appears that the script was executed directly
    target = fs.join(introspection.pts_do_dir, match[0], match[1])
    sys.argv[0] = target
    del sys.argv[1]
    print("Executing: " + match[0] + "/" + match[1] + " " + " ".join(sys.argv[1:]))

    #command_name = match[1]

    # Set target
    #def start(): exec open(target)

    # Start # DOESN'T WORK WHEN THE SCRIPT FILE DEFINES A FUNCTION
    #start_target(command_name, start)
    exec open(target)
开发者ID:SKIRT,项目名称:PTS,代码行数:27,代码来源:run.py


示例12: restore_generations_path

    def restore_generations_path(self):

        """
        This function ...
        :return:
        """

        return fs.join(self.restore_path, "generations")
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:restore.py


示例13: modeling_path

    def modeling_path(self):

        """
        This function ...
        :return: 
        """

        return fs.join(self.path, self.modeling_name)
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:base.py


示例14: restore_prob_path

    def restore_prob_path(self):

        """
        This function ...
        :return:
        """

        return fs.join(self.restore_path, "prob")
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:restore.py


示例15: restore_best_parameters_path

    def restore_best_parameters_path(self):

        """
        This function ...
        :return:
        """

        return fs.join(self.restore_path, "best_parameters.dat")
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:restore.py


示例16: restore_configuration_path

    def restore_configuration_path(self):

        """
        This function ...
        :return:
        """

        return fs.join(self.restore_path, "configuration.cfg")
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:restore.py


示例17: restore_weights_path

    def restore_weights_path(self):

        """
        This function ...
        :return:
        """

        return fs.join(self.restore_path, "weights.dat")
开发者ID:SKIRT,项目名称:PTS,代码行数:8,代码来源:restore.py


示例18: write_input

    def write_input(self):

        """
        This function ...
        :return:
        """

        # Inform the user
        log.info("Writing the simulation input ...")

        # Write wavelength grid
        self.wavelength_grid.to_skirt_input(self.wavelength_grid_path)

        # Write maps
        self.maps["old"].saveto(fs.join(self.simulation_input_path, old_filename))
        self.maps["young"].saveto(fs.join(self.simulation_input_path, young_filename))
        self.maps["ionizing"].saveto(fs.join(self.simulation_input_path, ionizing_filename))
        self.maps["dust"].saveto(fs.join(self.simulation_input_path, dust_filename))
开发者ID:SKIRT,项目名称:PTS,代码行数:18,代码来源:base.py


示例19: get_generation_restore_path

    def get_generation_restore_path(self, generation_name):

        """
        This function ...
        :param generation_name:
        :return:
        """

        return fs.join(self.restore_generations_path, generation_name)
开发者ID:SKIRT,项目名称:PTS,代码行数:9,代码来源:restore.py


示例20: elitism_table_path_for_generation

    def elitism_table_path_for_generation(self, generation_name):

        """
        This function ...
        :param generation_name: 
        :return: 
        """

        return fs.join(self.fitting_run.generations_path, generation_name, "elitism.dat")
开发者ID:SKIRT,项目名称:PTS,代码行数:9,代码来源:base.py



注:本文中的pts.core.tools.filesystem.join函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python readers.BaseEventReader类代码示例发布时间:2022-05-25
下一篇:
Python log.info函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap