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()
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 __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}")
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}")
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()
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
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
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()
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
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}")