nenupy.io.tf.Spectra
- class nenupy.io.tf.Spectra(filename, check_missing_data=True)[source]
Bases:
objectClass to read UnDySPuTeD Time-Frequency files (.spectra extension).
Notes
Added in version 2.6.0.
- __init__(filename, check_missing_data=True)[source]
Generate an instance of
Spectra.- Parameters:
- Raises:
ValueError – If the
filenameextension differs from ‘.spectra’.
Methods
__init__(filename[, check_missing_data])Generate an instance of
Spectra.get([file_name])Perform data selection and pipeline computation.
info()Display informations about the file.
select_raw_data(tmin_unix, tmax_unix, ...)Select a subset from a time-frequency NenuFAR dataset.
Attributes
Path to the .spectra file.
Highest recorded frequency.
Lowest recorded frequency.
Final time of the data content.
Starting time of the data content.
- property frequency_max
Highest recorded frequency. This value is defined at the channel granularity, i.e. it corresponds to the last channel of the highest sub-band.
Example
>>> from nenupy.io.tf import Spectra >>> sp = Spectra("/my/file.spectra") >>> sp.frequency_max 57.421875 MHz
- Type:
- property frequency_min
Lowest recorded frequency. This value is defined at the channel granularity, i.e. it corresponds to the first channel of the lowest sub-band.
Example
>>> from nenupy.io.tf import Spectra >>> sp = Spectra("/my/file.spectra") >>> sp.frequency_min 19.921875 MHz
- Type:
- get(file_name=None, **pipeline_kwargs)[source]
Perform data selection and pipeline computation.
- Parameters:
file_name (
str, default:None) – If different thanNone(default value), name of the HDF5 file (extension ‘.hdf5’) to create and store the result.**pipeline_kwargs – Any
pipelineparameter passed as keyword argument from the list below. Changes applied here are not kept once the method has resolved.tmin (
strorTime, default: \({\rm min}(t)\)) – Lower edge of time selection, can either be given as aTimeobject or an ISOT/ISO string.tmax (
strorTime, default: \({\rm max}(t)\)) – Upper edge of time selection, can either be given as anTimeobject or an ISOT/ISO string.fmin (
floatorQuantity, default: \({\rm min}(\nu)\)) – Lower frequency boundary selection, can either be given as aQuantityobject or float (assumed to be in MHz in that case).fmax (
floatorQuantity, default: \({\rm max}(\nu)\)) – Higher frequency boundary selection, can either be given as aQuantityobject or float (assumed to be in MHz in that case).beam (
int, default: first recorded beam) – Beam selection, a single integer corresponding to the index of a recorded numerical beam is expected.dispersion_measure (
floatorQuantity, default:None) – Enable de-dispersion of the data by this Dispersion Measure. Note that thede_disperse()task should be present in the planned pipeline (pipeline). It can either be provided as aQuantityobject or a float (assumed to be in \({\rm pc}\,{\rm cm}^{-3}\) in that case).rotation_measure (
floatorQuantity, default:None) – Enable the correction of the Faraday rotation using this Rotation Measure. Note that thecorrect_faraday_rotation()task should be present in the planned pipeline (pipeline). It can either be provided as aQuantityobject or a float (assumed to be in \({\rm rad}\,{\rm m}^{-2}\) in that case).rebin_dt (
floatorQuantity, default:None) – Desired rebinning time resolution, can either be given as aQuantityobject or a float (assumed to be in sec in that case). Note that thetime_rebin()task should be present in the planned pipeline (pipeline).rebin_df (
floatorQuantity, default:None) – Desired rebinning frequency resolution, can either be given as aQuantityobject or float (assumed to be in kHz in that case). Note that thefrequency_rebin()task should be present in the planned pipeline (pipeline).smooth_frequency_profile (
bool, defaultFalse) – Keyword used ifflatten_subband()is in the pipeline: smooth the frequency profile, this option mau result in unexpected behavior if the subbands are not contiguous or the selected beamlets do not belong to the same digital beam.remove_channels (
listorndarray, default:None) – List of subband channels to remove, e.g.remove_channels=[0,1,-1]would remove the first, second (low-freq) and last channels from each subband. Note that theremove_channels()task should be present in the planned pipeline (pipeline).skycoord (
SkyCoord, default:None) – Tracked celestial coordinates used for beam and polarization corrections, aSkyCoordobject is expected. Note that thecorrect_polarization()orcorrect_parallactic_rotation()task should be present in the planned pipeline (pipeline).calib_dt (
floatorQuantity, default:None) – Time resolution used for beam and polarization corrections, aQuantityobject or a float (assumed in seconds) are expected. Note that thecorrect_polarization()orcorrect_parallactic_rotation()task should be present in the planned pipeline (pipeline).dreambeam_parallactic (
bool, default:True) – DreamBeam parallactic angle correction (along with'skycoord'and'calib_dt'), a boolean is expected. Note that thecorrect_polarization()task should be present in the planned pipeline (pipeline).stokes (
strorlist[str], default:"I") – Stokes parameter selection, can either be given as a string or a list of strings, e.g.['I', 'Q', 'V/I']. Note that theget_stokes()task should be present in the planned pipeline (pipeline).ignore_volume_warning (
bool, default:False) – Ignore or not (default value) the limit regarding output data volume.
- Returns:
Processed data selection.
- Return type:
SData
Examples
>>> from nenupy.io.tf import Spectra >>> sp = Spectra("/my/file.spectra") >>> result = sp.get(tmin="2024-01-01 12:00:00", tmax="2024-01-01 13:00:00")
- info()[source]
Display informations about the file.
Example
>>> from nenupy.io.tf import Spectra >>> sp = Spectra("/my/file.spectra") >>> sp.info() filename: /my/file.spectra time_min: 2023-05-27T08:39:02.0000050 time_max: 2023-05-27T08:59:34.2445748 dt: 20.97152 ms frequency_min: 19.921875 MHz frequency_max: 57.421875 MHz df: 3.0517578125 kHz Available beam indices: ['0']
- select_raw_data(tmin_unix, tmax_unix, fmin_hz, fmax_hz, beam)[source]
Select a subset from a time-frequency NenuFAR dataset.
- Parameters:
- Raises:
KeyError – If
beamdoes not correspond to any recorded value.- Returns:
Length-3 tuple, respectively containing the frequency in Hz and the time in unix as
numpyarrays, then the selected dataset. The latter should be shaped as (time, frequency, 2, 2) where the last two dimensions are the Jones matrix of the electric field cross correlations. If the chosen time arguments lead to an empty selection, a length-3 tuple ofNoneis returned. If the frequency selection is off, the closest subband is returned.- Return type:
Notes
Added in version 2.6.0.
Example
>>> import nenupy >>> sp = Spectra("/my/file.spectra") >>> data = sp.select_raw_data( tmin_unix=1685176742.000005, tmax_unix=1685176802.000005, fmin_hz=21e6, fmax_hz=22e6, beam=0 ) >>> data[0].shape, data[1].shape, data[2].shape ((384,), (2856,), (2856, 384, 2, 2))
- property time_max
Final time of the data content.
Example
>>> from nenupy.io.tf import Spectra >>> sp = Spectra("/my/file.spectra") >>> sp.time_max.isot '2023-05-27T08:59:34.2445748'
- Type: