nenupy.beamlet.sdata
SData
SData
is a class designed for
embedding dynamic spectrum data sets. Many methods from the
nenupy
library return SData
objects such as:
beamform()
time_profile()
azel_transit()
radec_transit()
radec_tracking()
It therefore provides a unified way of accessing, comparing
and eventually plotting dynamic spectrum data sets throughout
every nenupy
manipulations.
SData
are unit sensitive
objets, therefore in addition it is worth importing
astropy.time
and astropy.units
modules:
>>> from nenupy.beamlet import SData
>>> import numpy as np
>>> from astropy.time import Time, TimeDelta
>>> import astropy.units as u
Operations
All basic mathematical operations are enabled between
SData
instances (addition,
subtraction, multiplication and division).
In the following example, s1
and s2
are two identical
SData
instances with every
data set to 1.
. They define data taken at the same
times, frequencies and polarizations (time
, freq
and
polar
respectively):
>>> dts = TimeDelta(np.arange(3), format='sec')
>>> s1 = SData(
data=np.ones((3, 5, 1)),
time=Time('2020-04-01 12:00:00') + dts,
freq=np.ones(5) * u.MHz,
polar=['NE']
)
>>> s2 = SData(
data=np.ones((3, 5, 1)),
time=Time('2020-04-01 12:00:00') + dts,
freq=np.ones(5) * u.MHz,
polar=['NE']
)
Addition:
>>> s_add = s1 + s2
>>> s_add.amp
array([[2., 2., 2., 2., 2.],
[2., 2., 2., 2., 2.],
[2., 2., 2., 2., 2.]])
Subtraction:
>>> s_sub = s1 - s2
>>> s_add.amp
array([[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.]])
Multiplication:
>>> s_mul = s1 * s2
>>> s_add.amp
array([[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.]])
Division:
>>> s_div = s1 / s2
>>> s_add.amp
array([[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1.]])
Concatenation
Besides mathematical operations,
SData
objects may also be
concatenated along the time or frequency axis for building up
dataset purposes.
In the following example, s1
is the main instance, s2
has similar times but different frequencies and s3
has
similar frequencies but different times than s1
.
>>> dts = TimeDelta(np.arange(2), format='sec')
>>> s1 = SData(
data=np.ones((2, 3, 1)),
time=Time('2020-04-01 12:00:00') + dts,
freq=np.arange(3) * u.MHz,
polar=['NE']
)
>>> s2 = SData(
data=np.ones((2, 3, 1)),
time=Time('2020-04-01 12:00:00') + dts,
freq=(10+np.arange(3)) * u.MHz,
polar=['NE']
)
>>> s2 = SData(
data=np.ones((2, 3, 1)),
time=Time('2020-04-01 13:00:00') + dts,
freq=np.arange(3) * u.MHz,
polar=['NE']
)
Concatenation in frequency:
>>> s_freq_concat = s1 & s2
>>> s_freq_concat.shape
(2, 6, 1)
Concatenation in time:
>>> s_time_concat = s1 | s3
>>> s_time_concat.shape
(4, 3, 1)
- class nenupy.beamlet.sdata.SData(data, time, freq, polar)[source]
Bases:
object
A class to handle dynamic spectrum data.
- Parameters:
- property background
- property data
- property fbackground
- property freq
- property medianFProfile
Added in version 1.1.0.
- property medianTProfile
Added in version 1.1.0.
- plot(fig=None, ax=None, polarization=None, figname=None, db=True, **kwargs)[source]
kwargs keys: cmap, title, cblabel, figsize, altaza, vmin, vmax
- property polar
Returns a list of polarizations
- property shape
- property time