1

我一直在使用这个 python 程序来查找我的文件的 max_dens,但是每当我执行文件时,我都会遇到同样的错误。谁能告诉我这些错误指的是什么?我正在使用 yt 3.1

计算并绘制随时间变化的最大密度

    import yt
    #import LibCartesian3D
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    import glob
    import numpy as np
    flashFolder = '/work/03858/thaque56/run_149/'
    basename = 'super3d_' # sets the prefix of the plotfiles and checkpoint files. Usually 'super3d_' for MHD, 'relax_' for purehydro.
    useAllPlotfiles = False # set True to use glob.glob to select plotfiles (by default uses all available files)
    endcount = 5  # specify if useAllPlotfiles == False, gives the number of the last plotfile which is used

    # ============================ constructs list of filenames if script is run on its own, otherwise supplied by allPlots.py !
    def getfilenames(useAllPlotfiles,endcount):
            if useAllPlotfiles == True:
                    plotFilenames_own = glob.glob(flashFolder + basename + 'hdf5_plt_cnt_[0-9][0-9][0-9][0-9]')
                    plotFilenames_own.sort()
            else:
                    plotFilenames_own = []
                    for n in range(0,endcount + 1):
                            filename = flashFolder + basename + 'hdf5_plt_cnt_%04d' % n
                            plotFilenames_own.append(filename)
            return plotFilenames_own

    #============================

    def main(filenames):
            print 'Executing maxDens.py'

            max_dens = np.zeros(len(filenames))
            time = np.zeros(len(filenames))

            for n in range (len(filenames)):
                    pf =yt.load(filenames[n])
                    time[n] = pf.current_time
                    dens_max, dens_max_location = pf.h.find_max('dens')
                    max_dens[n] = dens_max

            print time, max_dens
            plt.plot(time,max_dens)
            plt.xlabel('time [s]')
            plt.ylabel('density [g/cm^3]')
            plt.title('Maximum Density over Time')
            plt.savefig('MaxDens.png')


    if __name__ == "__main__":
            plotFilenames_own = getfilenames(useAllPlotfiles,endcount)
            main(plotFilenames_own)

为了您的方便,我还附上了错误。

>     TACC: Starting up job 6517689
>     TACC: Setting up parallel environment for MVAPICH2+mpispawn.
>     TACC: Starting parallel tasks...
>     Traceback (most recent call last):
>       File "maxDens.py", line 3, in <module>
>         import yt
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/__init__.py",
> line 121, in <module>
>         from yt.data_objects.api import \
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/data_objects/api.py",
> line 51, in <module>
>         from . import construction_data_containers as __cdc
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.py",
> line 52, in <module>
>         from yt.frontends.stream.api import load_uniform_grid
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/frontends/stream/api.py",
> line 16, in <module>
>         from .data_structures import \
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/frontends/stream/data_structures.py",
> line 38, in <module>
>         from yt.geometry.grid_geometry_handler import \
>       File "/work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/yt/geometry/grid_geometry_handler.py",
> line 38, in <module>
>         from .grid_container import \
>       File "yt/geometry/selection_routines.pxd", line 34, in init yt.geometry.grid_container (yt/geometry/grid_container.c:9108)
>     ValueError: yt.geometry.selection_routines.SelectorObject has the wrong size, try recompiling
>     [c557-601.stampede.tacc.utexas.edu:mpispawn_0][child_handler] MPI

进程(等级:0,pid:130364)以状态1退出

TACC: MPI job exited with code: 1

TACC: Shutdown complete. Exiting.

请帮我解决这个问题。我认为 yt 版本存在一些问题。

4

1 回答 1

0

问题是 yt 使用 cython 生成的一些 C 扩展需要重新编译。事实证明clean.sh脚本不会删除那些,所以你必须像这样清理它们:

$ cd /work/03858/thaque56/sw/yt-3.1/yt-x86_64/src/yt-hg/
$ hg --config extensions.purge= purge --all yt
$ python setup.py develop

很抱歉昨晚在 yt 邮件列表上给了你不好的建议!希望这可以为您解决问题。

于 2016-02-07T16:34:01.633 回答