Carriers and Bandwidth Parts
The module carrier.py
implements the classes Carrier
and BandwidthPart
. Each
Carrier
can be associated with several BandwidthPart
objects. This implementation is
based on 3GPP TR 38.211.
- class neoradium.carrier.BandwidthPart(carrier, **kwargs)
This class encapsulates the functionality of a bandwidth part. A bandwidth part is a subset of contiguous common resource blocks for a specific numerology on a given carrier. For more detailed information, please refer to 3GPP TR 38.211, section 4.4.5. It is important to note that BandwidthPart objects are not directly created. Instead, you typically create a
Carrier
object and retrieve its current BandwidthPart using itscurBwp
property.- Parameters:
carrier (Carrier object)
kwargs (dict) –
A set of optional arguments.
- startRb:
The starting resource block (RB). This is the number of RBs from CRB 0. The default is 0.
- numRbs:
The number of RBs included in the bandwidth part. The default is 50.
- spacing:
The subcarrier spacing in kHz. This also specifies the numerology used. To specify the subcarrier spacing, you can use 15, 30, 60, 120, 240, 480, or 960. To specify the numerology, you can use 0, 1, …, 6. Please refer to 3GPP TR 38.211, section 4.2 for more details.
- cpType:
Cyclic Prefix type. It can be either “Normal” or “Extended”. The “Extended” type is only available for 60 kHz subcarrier spacing.
Other Properties:
Here is a list of additional properties:
- u:
The numerology value, which falls within the range of 0 to 6 (\(\mu\)). See 3GPP TR 38.211, table 4.2-1.
- bandwidth:
The bandwidth of this bandwidth part in Hz.
- nFFT:
The FFT size used for OFDM modulation of the resource grids (See
Grid
) which are created based on this bandwidth part. It is calculated as follows:\[N_{FFT} = \big [\frac {\frac {f_s} {1000} - \sum_{l=0}^{N_{symb}^{slot}-1} N_{CP,l}^{\mu}} {N_{symb}^{subframe,\mu}} \big ]\]where \(f_s=\frac 1 {T_s}\), is the 5G sample rate (\(f_s=30,720,000\) Hz), \(N_{symb}^{slot}\) is the number of symbols per slot, \(N_{CP,l}^{\mu}\) is the number of samples in cyclic prefix of symbol \(l\) based on numerology \(\mu\), and \(N_{symb}^{subframe,\mu}\) is the number of symbols in each subframe for numerology \(\mu\).
- symbolsPerSlot:
The number of OFDM symbols in each slot (\(N_{symb}^{slot}\)). This is equal to 14 and 12 for “Normal” and “Extended” Cyclic Prefix types, respectively.
- slotsPerSubFrame:
The number of slots per subframe based on current numerology (\(N_{slot}^{subframe,\mu}\)).
- symbolLens:
A list of symbol length values in number of time samples for every symbol in a subframe. The symbol length for symbol
l
,symbolLens[l]
, is the sum of \(N_{FFT}\) and \(N_{CP,l}^{\mu}\).- slotsPerFrame:
The number of slots per frame based on current numerology (\(N_{slot}^{frame,\mu}\)).
- symbolsPerSubFrame:
The number of OFDM Symbols per subframe based on current numerology (\(N_{symb}^{subframe,\mu}\)).
- slotNoInFrame:
The slot number in current frame (\(n_{s,f}^{\mu}\)).
- slotNoInSubFrame:
The slot number in current subframe (\(n_{s}^{\mu}\)).
- avgSlotDuration:
The average slot duration in seconds.
- cellId:
The Cell identifier of the Carrier containing this bandwidth part.
- slotNo:
Current slot number. A counter that can be used in simulation.
- frameNo:
Current frame number. A counter that can be used in simulation. This is incremented every
slotsPerFrame
slots.- sampleRate:
The sample rate. For 3GPP, this is set to 30,720,000 samples per second (\(f_s=\frac 1 {T_s}\)).
- dataTimeRatio:
The average ratio of the amount of time in an OFDM symbol spent transmitting user data to total OFDM symbol time. This is always less than one because some duration of time is spent transmitting the Cyclic Prefix, which does not carry useful information.
- print(indent=0, title=None, getStr=False)
Prints the properties of this
BandwidthPart
object.- Parameters:
indent (int) – The number of indentation characters.
title (str or None) – If specified, it is used as a title for the printed information. If
None
(default), the text “Bandwidth Part Properties:” is used for the title.getStr (Boolean) – If
True
, returns a text string instead of printing it.
- Returns:
If the
getStr
parameter isTrue
, then this function returns the information in a text string. Otherwise, nothing is returned.- Return type:
None or str
- createGrid(numPlanes, useReDesc=False)
Creates a resource grid and returns an empty
Grid
object based on this bandwidth part.- Parameters:
numPlanes (int) – The number of “planes” in the resource grid. See the
Grid
class for more information.useReDesc (Boolean) – If
True
, the resource grid created will also include additional fields that describe the content of each resource element (RE). This can be used during the debugging to make sure the resources are allocated correctly. See theGrid
class for more information.
- Returns:
An empty
Grid
object based on this bandwidth part object.- Return type:
- getCpLen(symIdxInSubframe)
Returns the number of time samples in the Cyclic Prefix for the OFDM symbol specified by
symIdxInSubframe
. This is based on TS 38.211, Section 5.3.1.- Parameters:
symIdxInSubframe (int) – The index of symbol from the beginning of subframe.
- Returns:
The number of time samples in Cyclic Prefix for the OFDM symbol specified by
symIdxInSubframe
.- Return type:
int
- getSlotLen(slotIndex=None)
Returns the total number of time samples in the slot specified by
slotIndex
.- Parameters:
slotIndex (int) – The index of the slot from the beginning of subframe.
- Returns:
The total number of time samples in the slot specified by
slotIndex
.- Return type:
int
- getSymLens()
Returns an array containing the symbol lengths for the symbols in the current slot, plus the first symbol of the next slot. The symbol length represents the total number of samples (at a sampling rate of 30,720,000 samples per second) for each symbol.
- Returns:
An array containing the symbol lengths for all the symbols in the current slot, plus the first symbol of the next slot. Therefore, the length of the returned array is
symbolsPerSlot+1
.- Return type:
numpy array
- class neoradium.carrier.Carrier(**kwargs)
This class encapsulates the functionality of a Carrier. A Carrier object serves as a container for a group of resource blocks dedicated to either uplink or downlink communication. It is possible to associate a Carrier object with multiple instances of the
BandwidthPart
class, but only one instance can be active at any time.- Parameters:
kwargs (dict) –
A set of optional arguments.
- startRb:
The starting resource block (RB). This is the number of RBs from CRB 0. The default is 0.
- numRbs:
The number of RBs included in the carrier. The default is 50.
- bwps:
A list of
BandwidthPart
objects associated with this Carrier. If this is not specified, a single bandwidth part is automatically created covering the whole carrier. In this case, the following additionalBandwidthPart
parameters can also be specified when creating the Carrier object:- spacing:
The subcarrier spacing in kHz. This also specifies the numerology used. To specify the subcarrier spacing, you can use 15, 30, 60, 120, 240, 480, or 960. To specify the numerology, you can use 0, 1, …, 6. Please refer to 3GPP TR 38.211, section 4.2 for more details.
- cpType:
Cyclic Prefix type. It can be either “Normal” or “Extended”. The “Extended” type is only available for 60 kHz subcarrier spacing.
Example:
# Create a carrier with a single BandwidthPart: carrier = Carrier(startRb=0, numRbs=25, spacing=30, cpType="Normal")
- cellId:
The Cell identifier of this Carrier. The default is 1.
- curBwpIndex:
The index of current bandwidth part. The default is 0.
Other Properties:
Here is a list of additional properties:
- slotNo:
Current slot number. A counter that can be used in simulation.
- frameNo:
Current frame number. A counter that can be used in simulation. This is incremented every
slotsPerFrame
slots.- curBwp:
The currently active
BandwidthPart
object.- frameNoRel:
The remainder of current frame number divided by 1024.
- slotNoInFrame:
The slot number in current frame (\(n_{s,f}^{\mu}\)).
- symbolsPerSlot:
The number of OFDM symbols in each slot (\(N_{symb}^{slot}\)) based on the numerology of the currently active
BandwidthPart
. This is equal to 14 and 12 for “Normal” and “Extended” Cyclic Prefix types, respectively.- slotsPerSubFrame:
The number of slots per subframe based on the numerology of the currently active
BandwidthPart
(\(N_{slot}^{subframe,\mu}\)).- slotsPerFrame:
The number of slots per frame based on the numerology of the currently active
BandwidthPart
(\(N_{slot}^{frame,\mu}\)).- symbolsPerSubFrame:
The number of OFDM Symbols per subframe based on the numerology of the currently active
BandwidthPart
(\(N_{symb}^{subframe,\mu}\)).
- print(indent=0, title=None, getStr=False)
Prints the properties of this
Carrier
object.- Parameters:
indent (int) – The number of indentation characters.
title (str or None) – If specified, it is used as a title for the printed information. If
None
(default), the text “Carrier Properties:” is used for the title.getStr (Boolean) – If
True
, returns a text string instead of printing it.
- Returns:
If the
getStr
parameter isTrue
, then this function returns the information in a text string. Otherwise, nothing is returned.- Return type:
None or str
- goNext()
Increments the current slot number in this carrier (
slotNo
). If the slot number passes the boundary of a frame, the frame number (frameNo
) is also incremented.
- createGrid(numPorts, useReDesc=False)
Creates a resource grid and returns an empty
Grid
object based on the currently activeBandwidthPart
. SeeBandwidthPart.createGrid()
for more details.