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
Data record times.
Data record frequencies.
Data values.
Analog pointing start times corresponding to this data set.
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.
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:
- 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:
- fit_transit(only_gaussian=False, upper_threshold=None, **kwargs)[source]
Do a fit.
- kwargs
filter_window (default (200))
- 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 toTrue
, the data will be displayed in a decibel scale (i.e., \({\rm dB} = 10 \log_{10}({\rm data})\)). Default isTrue
.xmin (
Quantity
orTimeDatetime
) – Minimal x-axis value (could be either time or frequency units depending on the data shape). Default is automatic scaling.xmax (
Quantity
orTimeDatetime
) – Maximal x-axis value (could be either time or frequency units depending on the data shape). Default is automatic scaling.ymin (
float
orQuantity
) – Minimal y-axis value (could be either data amplitude or frequency units depending on the data shape). Default is automatic scaling.ymax (
float
orQuantity
) – 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 ofTimeDatetime
. Default is[]
.analog_pointing (
bool
) – Temporal plot only. Overplots vertical dot-dashed black lines at analog pointing start times. Default isFalse
.digital_pointing (
bool
) – Temporal plot only. Overplots vertical dotted black lines at analog pointing start times. Default isFalse
.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)
wherehatched_array
is a booleanndarray
, shaped as (frequency, time), set toTrue
where a hatched cell should be drawn. Default isNone
.
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'
ifdecibel=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:
- 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 )