nenupy.io.io_tools


Statistics file tools

class nenupy.io.io_tools.ST_Slice(time, frequency, value, analog_pointing_times=<Time object: scale='utc' format='jd' value=[]>, digital_pointing_times=<Time object: scale='utc' format='jd' value=[]>)[source]

Bases: object

Class to handle data sub-set from Statistical data.

Attributes Summary

time

Data record times.

frequency

Data record frequencies.

value

Data values.

analog_pointing_times

Analog pointing start times corresponding to this data set.

digital_pointing_times

Digital pointing start times corresponding to this data set.

Methods Summary

plot([fig_ax])

Plots the data, while automatically taking into account its shape (lightcurve, spectrum or dynamic spectrum).

rebin([dt, df, method])

Rebins the data in time and frequency.

fit_transit([only_gaussian, upper_threshold])

Do a fit.

flatten_frequency()

flatten_time()

clear_pointing_switch([flatten_frequency, ...])

Attributes and Methods Documentation

property analog_pointing_times

Analog pointing start times corresponding to this data set.

Getter:

Starting times array.

Type:

Time

clean_rfi(t_sigma=1, f_sigma=1)[source]
clear_pointing_switch(flatten_frequency=True, pointing_dt=<TimeDelta object: scale='None' format='sec' value=360.0>, peak_sample_error=2, return_correction=False)[source]
\[p(t) = a \log(t) + bt^2 + ct + d\]
property digital_pointing_times

Digital pointing start times corresponding to this data set.

Getter:

Starting times array.

Type:

Time

fit_transit(only_gaussian=False, upper_threshold=None, **kwargs)[source]

Do a fit.

kwargs

filter_window (default (200))

flatten_frequency()[source]
flatten_time()[source]
property frequency

Data record frequencies.

Getter:

Frequency array.

Type:

Quantity

median_filter(filter_size=None)[source]
plot(fig_ax=None, **kwargs)[source]

Plots the data, while automatically taking into account its shape (lightcurve, spectrum or dynamic spectrum).

Several parameters, listed below, can be tuned to adapt the plot to the user requirements:

Data display keywords

Parameters:
  • decibel (bool) – If set to True, the data will be displayed in a decibel scale (i.e., \({\rm dB} = 10 \log_{10}({\rm data})\)). Default is True.

  • xmin (Quantity or TimeDatetime) – Minimal x-axis value (could be either time or frequency units depending on the data shape). Default is automatic scaling.

  • xmax (Quantity or TimeDatetime) – Maximal x-axis value (could be either time or frequency units depending on the data shape). Default is automatic scaling.

  • ymin (float or Quantity) – Minimal y-axis value (could be either data amplitude or frequency units depending on the data shape). Default is automatic scaling.

  • ymax (float or Quantity) – Maximal y-axis value (could be either data amplitude or frequency units depending on the data shape). Default is automatic scaling.

  • vmin (float) – Dynamic spectrum plot only. Minimal data value to display.

  • vmax (float) – Dynamic spectrum plot only. Maximal data value to display.

Overplot keywords

Parameters:
  • vlines ([TimeDatetime]) – Temporal plot only. Adds vertical lines at specific times. The expected format is an array of TimeDatetime. Default is [].

  • analog_pointing (bool) – Temporal plot only. Overplots vertical dot-dashed black lines at analog pointing start times. Default is False.

  • digital_pointing (bool) – Temporal plot only. Overplots vertical dotted black lines at analog pointing start times. Default is False.

  • hatched_overlay ((Time, Quantity, ndarray)) – Dynamic spectrum plot only. Produces a hatched overlay on top of the dynamic spectrum. The expected format is (time, frequency, hatched_array) where hatched_array is a boolean ndarray, shaped as (frequency, time), set to True where a hatched cell should be drawn. Default is None.

Plotting layout keywords

Parameters:
  • figname (str) – Name of the file (absolute or relative path) to save the figure. Default is '' (i.e., only show the figure).

  • figsize (tuple) – Set the figure size. Default is (15, 7).

  • title (str) – Set the figure title. Default is ''.

  • colorbar_label (str) – Dynamic spectrum plot only. Label of the color bar. Default is 'Amp' if decibel=False and 'dB' otherwise.

  • cmap (str) – Dynamic spectrum plot only. Color map used to represent the data. Default is 'YlGnBu_r'.

Example:
from nenupy.io.bst import BST
from astropy.time import Time, TimeDelta
import astropy.units as u
import numpy as np

# Select BST data
bst = BST("/path/to/BST.fits")
data = bst.get()

# Prepare a boolean array to overlay a hatched pattern
hatch_array = np.zeros((30, 300), dtype=bool)
hatch_array[5:20, 100:200] = True
# Specify time and frequency arrays
time_dts = np.arange(300)*TimeDelta(1, format='sec')
times = Time("2022-01-24T11:01:00") + time_dts
frequencies = np.linspace(47, 52, 30)*u.MHz

# Plot
data.plot(
    hatched_overlay=(
        times,
        frequencies,
        hatch_array
    )
)
rebin(dt=None, df=None, method='mean')[source]

Rebins the data in time and frequency.

Parameters:
  • dt (Quantity) – Time bin widths. Default is None (i.e., no rebin in time).

  • df (Quantity) – Frequency bin widths. Default is None (i.e., no rebin in frequency).

  • method (str) – Type of method for rebin purpose (either 'mean' or 'median'). Default is 'mean'.

Returns:

Rebinned data.

Return type:

ST_Slice

Example:
from nenupy.io.bst import BST
import astropy.units as u

bst = BST("/path/to/BST.fits")
data = bst.get()
rebin_data = data.rebin(
    dt=3*u.s,
    df=2*u.MHz
)
property time

Data record times.

Getter:

Time array.

Type:

Time

property value

Data values.

Getter:

Values array.

Type:

ndarray

class nenupy.io.io_tools.StatisticsData(file_name)[source]

Bases: ABC

property frequencies

Returns the mid frequency of the recorded subbands.