[docs]classSimulatedDrop(Drop[SimulatedDeviceTransmission,SimulatedDeviceReception]):"""Drop containing all information generated during a simulated wireless scenario transmission, channel propagation and reception."""__channel_realizations:Sequence[ChannelRealization]def__init__(self,timestamp:float,device_transmissions:Sequence[SimulatedDeviceTransmission],channel_realizations:Sequence[ChannelRealization],device_receptions:Sequence[SimulatedDeviceReception],)->None:""" Args: timestamp (float): Time at which the drop was generated. device_transmissions (Sequence[DeviceTransmission]): Transmitted device information. channel_realizations (Sequence[ChannelRealization]): Matrix of channel realizations linking the simulated devices. device_receptions (Sequence[ProcessedSimulatedDeviceReception]): Received device information. """# Initialize attributesself.__channel_realizations=channel_realizations# Initialize base classDrop.__init__(self,timestamp,device_transmissions,device_receptions)@propertydefchannel_realizations(self)->Sequence[ChannelRealization]:"""Squence of channel realizations linking the simulated devices."""returnself.__channel_realizationsdefto_HDF(self,group:Group)->None:# Serialize attributesgroup.attrs["timestamp"]=self.timestampgroup.attrs["num_transmissions"]=self.num_device_transmissionsgroup.attrs["num_receptions"]=self.num_device_receptionsgroup.attrs["num_devices"]=self.num_device_transmissions# Serialize groupsfort,transmissioninenumerate(self.device_transmissions):transmission.to_HDF(self._create_group(group,f"transmission_{t:02d}"))forr,receptioninenumerate(self.device_receptions):reception.to_HDF(self._create_group(group,f"reception_{r:02d}"))forcr,channel_realizationinenumerate(self.channel_realizations):realization_group=self._create_group(group,f"channel_realization_{cr:02d}")channel_realization.to_HDF(realization_group)
[docs]@classmethoddeffrom_HDF(cls:Type[SimulatedDrop],group:Group,devices:Sequence[Device]|None=None,channels:Sequence[Channel]|None=None,)->SimulatedDrop:"""Recall a simulated drop from a HDF5 group. Args: group (Group): The HDF5 group containing the serialized drop. devices (Sequence[Device], optional): The devices participating in the scenario. channels (Sequence[Channel], optional): The channels used in the scenario. """# Recall attributestimestamp=group.attrs.get("timestamp",0.0)num_transmissions=group.attrs.get("num_transmissions",0)num_receptions=group.attrs.get("num_receptions",0)num_devices=group.attrs.get("num_devices",1)_devices=[None]*num_devicesifdevicesisNoneelsedevices# Recall groupstransmissions=[SimulatedDeviceTransmission.from_HDF(group[f"transmission_{t:02d}"],NoneifdisNoneelselist(d.transmitters))fort,dinzip(range(num_transmissions),_devices)]receptions=[SimulatedDeviceReception.from_HDF(group[f"reception_{r:02d}"],NoneifdisNoneelselist(d.receivers))forr,dinzip(range(num_receptions),_devices)]channel_realizations:List[ChannelRealization]=[]forc,channelinenumerate(channels):realization=channel.recall_realization(group[f"channel_realization_{c:02d}"])channel_realizations.append(realization)returnSimulatedDrop(timestamp,transmissions,channel_realizations,receptions)