示例#1
0
    def Initialize(cls, comm=None, xml=None, readid=""):

        # Need a communicator in both the Kittie (global space) and each group
        cls.comm = comm
        if cls.comm is not None:
            cls.rank = cls.comm.Get_rank()
            cls.comm_self = cls.comm.Split(cls.rank, cls.rank)
        else:
            cls.rank = 0
            cls.comm_self = None

        args = []
        if xml is not None:
            args += [xml]
        if cls.comm is not None:
            args += [cls.comm]
        args += [adios2.DebugON]
        cls.adios = adios2.ADIOS(*args)

        cls.AllStep = False
        #cls.AllStep = True
        #cls.BuildYaml()
        cls.GroupsYaml()
        cls.CodesYaml(readid=readid)

        cls.StepInit = False
        #cls.StepGroupname = cls.appname + "-step"
        cls.StepGroupname = cls.Codename + "-step"
示例#2
0
文件: writers.py 项目: rkube/delta
    def __init__(self, cfg_transport: dict, channel_name: str):
        """Initialize writer_base."""
        comm = MPI.COMM_WORLD
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()
        self.logger = logging.getLogger("simple")

        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.IO = self.adios.DeclareIO(gen_io_name(self.rank))
        self.writer = None
        # Adios2 variable that is defined in DefineVariable
        # Keep the defined variables in a dictionary: {"var_name": (shape, dtype)}
        self.var_dict = {}
        # self.variable = None
        # The shape used to define self.variable
        # self.shape = None

        # Generate a descriptive channel name
        self.channel_name = channel_name

        # Set IO parameters
        self.IO.SetEngine(cfg_transport["engine"])

        if cfg_transport["engine"].lower() == "dataman":
            cfg_transport["params"].update(
                Port=str(int(cfg_transport["params"]["Port"]) + 2 * self.rank))

        print(
            f"rank: {self.rank:d} - port = {cfg_transport['params']['Port']}")
        self.IO.SetParameters(cfg_transport["params"])

        # To generate statistics
        self.stats = stream_stats()
示例#3
0
    def __init__(self, cfg: dict):

        print(
            "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        )
        print(
            "+                                                                                    +"
        )
        print(
            "+      readers.py is deprecated. Use reader_mpi.py or reader_nompi.py                +"
        )
        print(
            "+                                                                                    +"
        )
        print(
            "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
        )
        comm = MPI.COMM_WORLD
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()

        self.logger = logging.getLogger("simple")

        self.shotnr = cfg["shotnr"]
        self.adios = adios2.ADIOS(MPI.COMM_WORLD)
        self.IO = self.adios.DeclareIO(gen_io_name(self.shotnr))
        self.reader = None

        # Generate a descriptive channel name
        chrg = channel_range.from_str(
            cfg["transport"]["channel_range"][self.rank])
        self.channel_name = gen_channel_name_v2(self.shotnr, chrg.to_str())
        self.logger.info(f"reader_base: channel_name =  {self.channel_name}")
    def test_write_read_string_fullAPI(self):
        comm = MPI.COMM_WORLD
        theString = 'hello adios'
        bpFilename = 'string_test_fullAPI.bp'
        varname = 'mystringvar'
        NSteps = 3
        adios = adios2.ADIOS(comm)
        ioWrite = adios.DeclareIO('ioWriter')
        adEngine = ioWrite.Open(bpFilename, adios2.Mode.Write)
        varMyString = ioWrite.DefineVariable(varname)
        for step in range(NSteps):
            adEngine.BeginStep()
            adEngine.Put(varMyString, theString + str(step))
            adEngine.EndStep()
        adEngine.Close()

        ioRead = adios.DeclareIO('ioReader')
        adEngine = ioRead.Open(bpFilename, adios2.Mode.Read)
        varReadMyString = ioRead.InquireVariable(varname)
        for step in range(NSteps):
            adEngine.BeginStep()
            result = adEngine.Get(varReadMyString)
            adEngine.EndStep()
            self.assertEqual(result, theString + str(step))
        adEngine.Close()
示例#5
0
    def __init__(self, cfg: dict, shotnr: int = 18431):
        """Generates a reader for KSTAR ECEI data.

        Parameters:
        -----------
        cfg: delta config dictionary
        """

        self.adios = adios2.ADIOS()
        self.logger = logging.getLogger("simple")

        self.shotnr = shotnr
        self.IO = self.adios.DeclareIO(gen_io_name(self.shotnr))

        self.reader = None
        # Generate a descriptive channel name
        if len(cfg["channel_range"]) > 1:
            self.logger.error(
                "reader_base is not using MPI. The following channel_ranges are ignored:"
            )
            for crg in cfg["channel_range"][1:]:
                self.logger.error(f"Ignoring channel range {crg}")

        self.chrg = channel_range.from_str(cfg["channel_range"][0])
        self.channel_name = gen_channel_name_v3(cfg["datapath"], self.shotnr,
                                                self.chrg.to_str())
        self.logger.info(f"reader_base: channel_name =  {self.channel_name}")
示例#6
0
def main():
    """driver function"""
    ad = adios2.ADIOS(comm)
    greeting = "Hello World from ADIOS2"
    writer(ad, greeting)
    message = reader(ad)
    print("{}".format(message))
    return 0
示例#7
0
    def __init__(self, shotnr, id):
        #comm = MPI.COMM_WORLD
        self.rank = 0
        self.size = 1

        self.shotnr = shotnr
        self.id = id
        self.adios = adios2.ADIOS()
        self.IO = self.adios.DeclareIO("stream_{0:03d}".format(self.rank))
        print("reader_base.__init__(): rank = {0:02d}".format(self.rank))
示例#8
0
def Plot2D(plane_direction, data, args, fullshape, step, fontsize):
    # Plotting part
    displaysec = args.displaysec
    gs = gridspec.GridSpec(1, 1)
    fig = plt.figure(1, figsize=(8, 8))
    ax = fig.add_subplot(gs[0, 0])
    colorax = ax.imshow(data,
                        origin='lower',
                        interpolation='quadric',
                        extent=[0, fullshape[1], 0, fullshape[0]],
                        cmap=plt.get_cmap('gist_ncar'))
    cbar = fig.colorbar(colorax, orientation='horizontal')
    cbar.ax.tick_params(labelsize=fontsize - 4)

    for i in range(args.ny):
        y = fullshape[0] / args.ny * i
        ax.plot([0, fullshape[1]], [y, y], color='black')

    for i in range(args.nx):
        x = fullshape[1] / args.nx * i
        ax.plot([x, x], [0, fullshape[0]], color='black')

    ax.set_title("{0}, {1} plane, step {2}".format(args.varname,
                                                   plane_direction, step),
                 fontsize=fontsize)
    ax.set_xlabel(plane_direction[0], fontsize=fontsize)
    ax.set_ylabel(plane_direction[1], fontsize=fontsize)
    plt.tick_params(labelsize=fontsize - 8)
    plt.ion()
    if (args.outfile == "screen"):
        plt.show()
        plt.pause(displaysec)
    elif args.outfile.endswith(".bp"):
        if step == 0:
            global adios
            global ioWriter
            global var
            global writer
            adios = adios2.ADIOS(mpi.comm_app)
            ioWriter = adios.DeclareIO("VizOutput")
            var = ioWriter.DefineVariable(args.varname, data.shape, [0, 0],
                                          data.shape, adios2.ConstantDims,
                                          data)
            writer = ioWriter.Open(args.outfile, adios2.Mode.Write)

        writer.BeginStep()
        writer.Put(var, data, adios2.Mode.Sync)
        writer.EndStep()
    else:
        imgfile = args.outfile + "{0:0>5}".format(
            step) + "_" + plane_direction + ".png"
        fig.savefig(imgfile)

    plt.clf()
示例#9
0
def Initialize(comm=None, xml=None, appname=None):
    args = [adios2.DebugON]
    if comm is not None:
        args.insert(0, comm)
    if xml is not None:
        args.insert(0, xml)
    ADIOS2.adios = adios2.ADIOS(*args)

    if appname is not None:
        yamlfile = ".kittie-setup-{0}.yaml".format(appname)
        with open(yamlfile, 'r') as ystream:
            ADIOS2.config = yaml.load(ystream)
示例#10
0
def TimingRead(filename, comm=None):
    if comm is not None:
        adios = adios2.ADIOS(comm, adios2.DebugON)
    else:
        adios = adios2.ADIOS(adios2.DebugON)

    TmpIO = adios.DeclareIO("tmp-{0}".format(filename))
    TmpEngine = TmpIO.Open(filename, adios2.Mode.Read)
    steps = TmpEngine.Steps()

    data = {}
    for name in ["start", "other", "end", "total"]:
        var = TmpIO.InquireVariable(name)
        shape = var.Shape()
        var.SetSelection([[0], shape])
        var.SetStepSelection([0, steps])
        data[name] = np.zeros((steps, shape[0]))
        TmpEngine.Get(var, data[name])

    #TmpEngine.Flush()
    TmpEngine.Close()
    return data
示例#11
0
 def test_select_steps_reading_fullAPI(self):
     selected_steps = [3, 5, 7]
     param_string = ",".join([str(i) for i in selected_steps])
     adios = adios2.ADIOS()
     ioReadBP = adios.DeclareIO("hellopy")
     ioReadBP.SetParameter(TESTDATA_FILENAME, param_string)
     fh = ioReadBP.Open(TESTDATA_FILENAME, adios2.Mode.Read)
     var = ioReadBP.InquireVariable("step")
     var.SetStepSelection([0, len(selected_steps)])
     data = np.zeros(len(selected_steps), dtype=np.int32)
     fh.Get(var, data, adios2.Mode.Sync)
     self.assertTrue(all([data[i] == selected_steps[i] for i in
                          range(len(selected_steps))]))
示例#12
0
    def __init__(self, cfg: dict, shotnr: int=18431):

        self.logger = logging.getLogger("simple")

        self.shotnr = shotnr
        self.adios = adios2.ADIOS()
        self.IO = self.adios.DeclareIO(gen_io_name(0))
        self.writer = None
        # Adios2 variable that is defined in DefineVariable
        self.variable = None
        # The shape used to define self.variable
        self.shape = None

        # Generate a descriptive channel name
        self.chrg = channel_range.from_str(cfg["channel_range"][0])
        self.channel_name = gen_channel_name_v3(cfg["datapath"], self.shotnr, self.chrg.to_str())
        self.logger.info(f"writer_base: channel_name =  {self.channel_name}")
示例#13
0
    def __init__(self, shotnr, ecei_cfg):
        self.adios = adios2.ADIOS()
        self.shotnr = shotnr
        self.IO = self.adios.DeclareIO("KSTAR_18431")
        # Keeps track of the past chunk sizes. This allows to construct a dummy time base
        self.chunk_sizes = []

        # Store configuration of the ECEI diagnostic
        self.ecei_cfg = ecei_cfg

        # If false, indicates that raw data is returned.
        # If true, indicates that normalized data is returned.
        # This flag is set in Get()
        self.is_data_normalized = False

        # Defines the time where we take the offset
        self.tnorm = ecei_cfg["t_norm"]
 def __init__(self, infile, eng, mpi_comm, blocks_to_read=0):
     self.inputfile = infile
     self.eng_name = eng
     self.mpi_comm = mpi_comm
     self.blocks_to_read = blocks_to_read
     self.size = 1
     self.conn = None
     self.cstep_avail_vars = None
     self.cstep_avail_attrs = None
     self.cstep_map_vars = {}
     self.cstep = None
     self.is_step = False
     self.is_open = False
     self.current_step = 0
     self.adios = adios2.ADIOS(mpi_comm)
     self.ioReader = self.adios.DeclareIO("reader")
     self.reset = False
     self.timestamp = None
示例#15
0
 def test_select_steps_reading_fullAPI(self):
     selected_steps = [3, 5, 7]
     param_string = ",".join([str(i) for i in selected_steps])
     adios = adios2.ADIOS()
     ioReadBP = adios.DeclareIO("hellopy")
     ioReadBP.SetParameter(TESTDATA_FILENAME, param_string)
     fh = ioReadBP.Open(TESTDATA_FILENAME, adios2.Mode.Read, comm)
     var = ioReadBP.InquireVariable("step")
     var.SetSelection([[0], [size * Nx]])
     var.SetStepSelection([0, len(selected_steps)])
     data = np.zeros((len(selected_steps), size * Nx), dtype=np.int32)
     fh.Get(var, data)
     fh.PerformGets()
     self.assertTrue(
         all([
             list(data[i]) == [
                 selected_steps[i] for x in range(len(data[i]))
             ] for i in range(len(selected_steps))
         ]))
示例#16
0
    def __init__(self, shotnr, id, virtual_rank=None, channel=None):
        if virtual_rank is None:
            comm = MPI.COMM_WORLD
            self.rank = comm.Get_rank()
            self.size = comm.Get_size()
        else:
            self.rank = virtual_rank
            self.size = 1

        self.shotnr = shotnr
        self.id = id
        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.channel = channel
        if self.channel is None:
            self.IO = self.adios.DeclareIO("stream_{0:03d}".format(self.rank))
        else:
            self.IO = self.adios.DeclareIO("stream_{0:03d}_s{1:03d}".format(
                self.rank, self.channel))
        self.reader = None
示例#17
0
def runQuery():
    adios = adios2.ADIOS(configFile, comm, True)
    queryIO = adios.DeclareIO("query")
    reader = queryIO.Open(dataPath, adios2.Mode.Read, comm)
    w = adios2.Query(queryFile, reader)

    touched_blocks = []

    var = [queryIO.InquireVariable("T")]

    print("Num steps: ", reader.Steps())

    while (reader.BeginStep() == adios2.StepStatus.OK):
        # say only rank 0 wants to process result
        if (rank == 0):
            touched_blocks = w.GetResult()
            doAnalysis(reader, touched_blocks, var)

    reader.EndStep()
    reader.Close()
示例#18
0
    def __init__(self, cfg: dict, stream_name: str):
        """Initialize writer_base."""
        comm = MPI.COMM_WORLD
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()
        self.logger = logging.getLogger("simple")

        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.IO = self.adios.DeclareIO(gen_io_name(self.rank))
        self.writer = None
        # Adios2 variable that is defined in DefineVariable
        self.variable = None
        # The shape used to define self.variable
        self.shape = None

        # Generate a descriptive channel name
        self.stream_name = stream_name

        # To generate statistics
        self.stats = stream_stats()
示例#19
0
    def __init__(self, cfg: dict, channel_name: str):
        """Initializes the generic reader base class.

        Arguments:
            cfg (dict):
                delta config dictionary
            channel_name (str):
                ADIOS2 name of the stream

        Returns:
            None
        """
        self.adios = adios2.ADIOS()
        self.logger = logging.getLogger("simple")

        self.IO = self.adios.DeclareIO(gen_io_name(0))
        self.IO.SetEngine(cfg["engine"])
        self.IO.SetParameters(cfg["params"])
        # Keeps track of the past chunk sizes. This allows to construct a dummy time base
        self.reader = None
        self.channel_name = channel_name
示例#20
0
    def __init__(self, cfg: dict, channel_name: str):
        """Initialize writer_base."""
        # comm = MPI.COMM_WORLD
        self.rank = 0 
        self.logger = logging.getLogger("simple")

        self.adios = adios2.ADIOS()
        self.IO = self.adios.DeclareIO(gen_io_name(self.rank))
        self.writer = None
        # Adios2 variable that is defined in DefineVariable
        self.variable = None
        # The shape used to define self.variable
        self.shape = None

        # Generate a descriptive channel name
        self.channel_name = channel_name

        self.IO.SetEngine(cfg_transport["engine"])
        self.IO.SetParameters(cfg_transport["params"])


        # To generate statistics
        self.stats = stream_stats()
示例#21
0
    def __init__(self, cfg: dict, stream_name: str):
        """Initializes the generic reader base class.

        Arguments:
            cfg (dict):
                delta config dictionary
            stream_name (str):
                ADIOS2 name of the stream

        Returns:
            None
        """
        comm  = MPI.COMM_SELF
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()
        # This should be MPI.COMM_SELF, not MPI.COMM_WORLD
        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.logger = logging.getLogger("simple")

        self.IO = self.adios.DeclareIO(gen_io_name(self.rank))
        # Keeps track of the past chunk sizes. This allows to construct a dummy time base
        self.reader = None
        self.stream_name = stream_name
示例#22
0
    def __init__(self, cfg_transport: dict, stream_name: str):
        """Initializes the generic reader base class.

        Args:
            cfg_transport (dict):
                delta config dict
            stream_name (str):
                Name of the data stream to read

        Returns:
            A class instance

        Used keys from cfg:
            * transport.engine - Defines the `ADIOS2 engine <https://adios2.readthedocs.io/en/latest/engines/engines.html#supported-engines>`_
            * transport.params - Passed to `SetParameters <https://adios2.readthedocs.io/en/latest/api_full/api_full.html?highlight=setparameters#_CPPv4N6adios22IO13SetParametersERKNSt6stringE>`_
  
        """
        comm = MPI.COMM_WORLD
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()
        # This should be MPI.COMM_SELF, not MPI.COMM_WORLD
        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.logger = logging.getLogger("simple")

        self.IO = self.adios.DeclareIO(gen_io_name(self.rank))
        self.IO.SetEngine(cfg_transport["engine"])
        if cfg_transport["engine"].lower() == "dataman":
            cfg_transport["params"].update(
                Port=str(int(cfg_transport["params"]["Port"]) + 2 * self.rank))

            self.logger.info(
                f"rank: {self.rank:d} - port = {cfg_transport['params']['Port']}"
            )
        self.IO.SetParameters(cfg_transport["params"])
        # Keeps track of the past chunk sizes. This allows to construct a dummy time base
        self.reader = None
        self.stream_name = stream_name
示例#23
0
    def __init__(self, cfg: dict, shotnr: int=18431):
        """Generates a reader for KSTAR ECEI data.

        Parameters:
        -----------
        cfg: delta config dictionary
        """

        comm  = MPI.COMM_SELF
        self.rank = comm.Get_rank()
        self.size = comm.Get_size()
        # This should be MPI.COMM_SELF, not MPI.COMM_WORLD
        self.adios = adios2.ADIOS(MPI.COMM_SELF)
        self.logger = logging.getLogger("simple")

        self.shotnr = shotnr
        self.IO = self.adios.DeclareIO(gen_io_name(self.shotnr))
        # Keeps track of the past chunk sizes. This allows to construct a dummy time base

        self.reader = None
        # Generate a descriptive channel name
        self.chrg = channel_range.from_str(cfg["channel_range"][self.rank])
        self.channel_name = gen_channel_name_v3(cfg["datapath"], self.shotnr, self.chrg.to_str())
        self.logger.info(f"reader_base: channel_name =  {self.channel_name}")
示例#24
0
Nx = 10
Ny = 10

count = [Nx, Ny]
start = [rank * Nx, 0]
shape = [size * Nx, Ny]

temperatures = np.zeros(count, dtype=np.int)

for i in range(0, Nx):
    for j in range(0, Ny):
        temperatures[i, j] = (start[0] + i) * shape[1] + (j + start[1])

# print(temperatures)
# ADIOS2 read
adios = adios2.ADIOS(comm)
ioWrite = adios.DeclareIO("ioWriter")

varTemperature = ioWrite.DefineVariable("temperature2D", temperatures, shape,
                                        start, count, adios2.ConstantDims)

obpStream = ioWrite.Open('HeatMap2D_py.bp', adios2.Mode.Write)
obpStream.Put(varTemperature, temperatures)
obpStream.Close()

if rank == 0:
    # ADIOS2 read
    ioRead = adios.DeclareIO("ioReader")
    ibpStream = ioRead.Open('HeatMap2D_py.bp', adios2.Mode.Read, MPI.COMM_SELF)
    var_inTemperature = ioRead.InquireVariable("temperature2D")
示例#25
0
                 ((y0 + iy * dy - ly / 2.0) / 2.0)**2) +
    50 * np.exp(-((x0 + ix * dx - lx / 1.5) / 2.0)**2 -
                ((y0 + iy * dy - ly / 2.0) / 2.0)**2) for ix in range(nx)
    for iy in range(ny)
], (nx, ny))

# ADIOS2
# (size and start of the local and global problem)
nxy_nohalo = [nx - 2, ny - 2]  # In ADIOS2 slang: count
nxy_g_nohalo = [nx_g - 2, ny_g - 2]  # ...              shape
start = [coords[0] * nxy_nohalo[0],
         coords[1] * nxy_nohalo[1]]  # ...              start
T_nohalo = np.zeros(nxy_nohalo)  # Prealocate array for writing temperature
# (intialize ADIOS2, io, engine and define the variable temperature)
adios = adios2.ADIOS(
    configFile="adios2.xml",
    comm=comm)  # Use the configurations defined in "adios2.xml"...
io = adios.DeclareIO("writerIO")  # ... in the section "writerIO"
T_id = io.DefineVariable(
    "temperature", T, nxy_g_nohalo, start, nxy_nohalo,
    adios2.ConstantDims)  # Define the variable "temperature"
engine = io.Open("diffusion2D.bp",
                 adios2.Mode.Write)  # Open the file/stream "diffusion2D.bp"

# Time loop
nsteps = 50  # Number of times data is written during the simulation
dt = min(dx, dy)**2 * cp_min / lam / 4.1  # Time step for the 2D Heat diffusion
t = 0  # Initialize physical time
tic = time.time()  # Start measuring wall time
for it in range(nt):
    if it % (nt / nsteps) == 0:  # Write data only nsteps times
示例#26
0
from mpi4py import MPI
import adios2
import numpy as np

# MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

# User data
myArray = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
nx = myArray.size

# ADIOS
adios = adios2.ADIOS(comm, adios2.DebugON)

# IO
bpIO = adios.DeclareIO("BPN2N")

# Variables
bpArray = bpIO.DefineVariable("bpArray", [size * nx], [rank * nx], [nx],
                              adios2.ConstantDims)
bpTimeStep = bpIO.DefineVariable("bpTimeStep")

# Engine
bpFileWriter = bpIO.Open("myArray.bp", adios2.OpenModeWrite)
# Doesn't work: bpFileWriter = bpIO.Open("myArray.bp", adiosOpenModeWrite,
#                                                      MPI.COMM_WORLD)

for t in range(0, 10):
示例#27
0
# First we gather all the different channel names
for h5_fname, chlist in zip([h5fname_g, h5fname_h, h5fname_l], 
                            [chlist_g, chlist_h, chlist_l]):
    with h5py.File(h5_fname) as h5file:
        for i in h5file["/ECEI"].items():
            chlist.append(i[0])
            if(len(chlist) == 1):
                num_data = h5file["/ECEI/{0:s}/Voltage".format(chlist[-1])].shape[0]
                num_timesteps = num_data // num_per_chunk

                print("num_data = {0:d}, num_timestpes = {1:d}".format(num_data, num_timesteps))
        h5file.close()

# Continue by creating an adios2 file
adios = adios2.ADIOS(adios2.DebugON)
bpIO = adios.DeclareIO("KSTAR")
bpIO.SetEngine("BP4")
bpWriter = bpIO.Open(join(scratch_dir, datadir, "KSTAR_018431_f32.bp"), adios2.Mode.Write)


# # Add all fields from the three H5 files to our bp file.
# # Do this one file at a time
bp_var_list_g = []
bp_var_list_h = []
bp_var_list_l = []

# # Add all the channels as variables to the bp file
dummy_arr = np.zeros(num_per_chunk, dtype=np.float32)
dummy_shape = [num_per_chunk]
dummy_start = [0]
示例#28
0
    plt.axis('scaled')
    plt.colorbar()
    plt.savefig(res_folder+name+'_rct.png')
    plt.close()
    plt.figure()
    trimesh = tri.Triangulation(r, z, conn)
    plt.tricontourf(trimesh, np.mean(rel_L_inf, axis=0))
    plt.axis('equal');
    plt.axis('off')
    plt.colorbar()
    plt.savefig(res_folder+name+'_tri_rnd.png')
    plt.close()
'''

steps = 101
adios = ad2.ADIOS()

import xgc4py

exdir = '/gpfs/alpine/world-shared/phy122/sku/su412_f0_data/'
#exdir = '/gpfs/alpine/proj-shared/csc143/jyc/summit/xgc-deeplearning/d3d_coarse_v2/'
xgcexp = xgc4py.XGC(exdir)

with ad2.open(exdir + 'xgc.mesh.bp', 'r') as f:
    nnodes = int(f.read('n_n', ))
    ncells = int(f.read('n_t', ))
    rz = f.read('rz')
    conn = f.read('nd_connect_list')
    psi = f.read('psi')
    nextnode = f.read('nextnode')
    epsilon = f.read('epsilon')
示例#29
0
import adios2
import numpy as np
import h5py

"""
Author: Ralph Kube

Compares the output of the data file written by create_ecei_bpfile.py to
the original data in the HDF5 file

"""
varname = "L0101"


adios = adios2.ADIOS()
IO = adios.DeclareIO("reader")
IO.SetEngine("BP4")

#bpStream = IO.Open("KSTAR.bp", adios2.Mode.Read)
bpStream = IO.Open("/global/cscratch1/sd/rkube/KSTAR/kstar_streaming/KSTAR_018431.bp", adios2.Mode.Read)
df_h5 = h5py.File("/global/cscratch1/sd/rkube/KSTAR/kstar_streaming/018431/ECEI.018431.LFS.h5")

ds = 10000
res = np.zeros(10000, dtype=np.float64)


for step in range(bpStream.Steps()):
    print("***Step: {0:d}".format(step))
    bpStream.BeginStep()

    var = IO.InquireVariable("ECEI_{0:s}".format(varname))
示例#30
0
        f"\tWorker: init. rank={rank} pid={os.getpid()} hostname={hostname} ID={pidmap[os.getpid()]} affinity={affinity}"
    )


# Main
if __name__ == "__main__":

    ## Generating dummy data
    if rank == 0:
        logging.info("Command: {0}".format(" ".join([x for x in sys.argv])))
        logging.info("All settings used:")
        for k, v in sorted(vars(args).items()):
            logging.info("\t{0}: {1}".format(k, v))

        logging.info(f"Dumping data")
        adios = adios2.ADIOS(MPI.COMM_SELF)
        IO = adios.DeclareIO('write')
        data_array = np.ones((192, args.chunksize))
        v1 = IO.DefineVariable('tstep', np.array(1))
        v2 = IO.DefineVariable(
            'data',
            data_array,
            data_array.shape,  # shape
            list(np.zeros_like(data_array.shape, dtype=int)),  # start 
            data_array.shape,  # count
            adios2.ConstantDims)

        writer = IO.Open('test.bp', adios2.Mode.Write)

        for i in range(args.nsteps):
            writer.BeginStep()