suncasa.utils.DButil
Attributes
Classes
Produce A play/stop button widget for bokeh plot |
Functions
|
|
|
|
|
Convert spectrogram to audio in WAV format |
|
smooth the data using a window with requested size. |
|
|
|
|
|
|
|
|
|
Call in a loop to create terminal progress bar |
|
|
|
|
|
|
|
|
|
|
|
return a list of the data path relative to the SDOdir |
|
return the index of files not in the list |
|
do expisure normalization of an aia map |
|
|
|
|
|
rescale the aia image |
|
rescale the aia image |
|
|
|
read sdo file from local database |
|
read sdo file from local database |
|
|
|
|
|
|
|
reference: https://ui.adsabs.harvard.edu/abs/2011ApJ...742...92W/abstract |
|
|
|
get the grad of at data point |
|
Pixel-value cross-section along line segment in an image |
|
|
|
|
|
get polarisation information from fits header |
|
|
|
get frequency in GHz from fits header |
|
convert the results from pimfit or pmaxfit tasks to pandas DataFrame structure. |
|
return the count of how many times of the element starts with col occurs in columns of dspecDF |
|
filter the unselect polarisation from dspecDF |
|
|
|
|
|
|
|
|
|
re-grid the data on a regular grid with uneven grid spacing to an uniform grid |
|
|
|
|
|
|
|
|
|
get the cross correlation map along y axis |
Module Contents
- suncasa.utils.DButil.spectrogram2wav(spec, threshld=None, gama=1, fs=1.0, t_length=None, w=1, wavfile='output.wav')[source]
Convert spectrogram to audio in WAV format :param spec: spec.shape (nfreq, ntime) :param threshld: below which is set to be threshold :param gama: :param fs: :param t_length: time duration of output WAV file :param w: width of the smooth window, if apply :param wavfile: :return:
- suncasa.utils.DButil.smooth(x, window_len=11, window='hanning')[source]
smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.
- input:
x: the input signal window_len: the dimension of the smoothing window; should be an odd integer window: the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’
flat window will produce a moving average smoothing.
- output:
the smoothed signal
example:
t=linspace(-2,2,0.1) x=sin(t)+randn(len(t))*0.1 y=smooth(x)
see also:
numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter
NOTE: length(output) != length(input), to correct this: return y[(window_len/2-1):-(window_len/2)] instead of just y.
- suncasa.utils.DButil.img2movie(imgprefix='', img_ext='png', outname='movie', size=None, start_num=0, crf=15, fps=10, overwrite=False, crop=[], title=[], dpi=200, keeptmp=False, usetmp=False, autorotate=True)[source]
- Parameters:
imgprefix
img_ext
outname
size
start_num
crf
fps
overwrite
title – the timestamp on each frame
crop – 4-tuple of integer specifies the cropping pixels [x0, x1, y0, y1]
dpi
keeptmp
usetmp – use the image in the default tmp folder
- Returns:
- suncasa.utils.DButil.ProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=100, empfill=' ', fill='#')[source]
Call in a loop to create terminal progress bar @params:
iteration - Required : current iteration (Int) total - Required : total iterations (Int) prefix - Optional : prefix string (Str) suffix - Optional : suffix string (Str) decimals - Optional : positive number of decimals in percent complete (Int) length - Optional : character length of bar (Int) fill - Optional : bar fill character (Str) empfill - Optional : empty bar fill character (Str)
- suncasa.utils.DButil.getsdodir(filename, unique=True)[source]
return a list of the data path relative to the SDOdir :param filename: :return:
- suncasa.utils.DButil.FileNotInList(file2chk, filelist)[source]
return the index of files not in the list :param file2chk: files to be check :param filelist: the list :return:
- suncasa.utils.DButil.normalize_aiamap(aiamap)[source]
do expisure normalization of an aia map :param aia map made from sunpy.map: :return: normalised aia map
- suncasa.utils.DButil.sdo_aia_scale_dict(wavelength=None, imagetype='image')[source]
rescale the aia image :param image: normalised aia image data :param wavelength: :return: byte scaled image data
- suncasa.utils.DButil.sdo_aia_scale(image=None, wavelength=None)[source]
rescale the aia image :param image: normalised aia image data :param wavelength: :return: byte scaled image data
- suncasa.utils.DButil.readsdofile(datadir=None, wavelength=None, trange=None, isexists=False, timtol=1)[source]
read sdo file from local database :param datadir: :param wavelength: :param trange: the timestamp or timerange in Julian days. if is timerange, return a list of files in the timerange :param isexists: check if file exist. if files exist, return file name :param timtol: time difference tolerance in days for considering data as the same timestamp :return:
- suncasa.utils.DButil.readsdofileX(datadir=None, filelist=None, wavelength=None, trange=None, isexists=False, timtol=1)[source]
read sdo file from local database :param datadir: :param wavelength: :param trange: time object. the timestamp or timerange. if is timerange, return a list of files in the timerange :param isexists: check if file exist. if files exist, return file name :param timtol: time difference tolerance in days for considering data as the same timestamp :return:
- suncasa.utils.DButil.htfit_warren2011(x, y, cutlength)[source]
reference: https://ui.adsabs.harvard.edu/abs/2011ApJ…742…92W/abstract
- suncasa.utils.DButil.get_curve_grad(x, y)[source]
get the grad of at data point :param x: :param y: :return: grad,posang
- suncasa.utils.DButil.improfile(z, xi, yi, interp='cubic')[source]
Pixel-value cross-section along line segment in an image :param z: an image array :param xi and yi: equal-length vectors specifying the pixel coordinates of the endpoints of the line segment :param interp: interpolation type to sampling, ‘nearest’ or ‘cubic’ :return: the intensity values of pixels along the line
- suncasa.utils.DButil.polsfromfitsheader(header)[source]
get polarisation information from fits header :param header: fits header :return pols: polarisation stokes
- suncasa.utils.DButil.freqsfromfitsheader(header)[source]
get frequency in GHz from fits header :param header: fits header :return pols: polarisation stokes
- suncasa.utils.DButil.transfitdict2DF(datain, gaussfit=True, getcentroid=False)[source]
convert the results from pimfit or pmaxfit tasks to pandas DataFrame structure. :param datain: The component list from pimfit or pmaxfit tasks :param gaussfit: True if the results is from pimfit, otherwise False. :param getcentroid: If True returns the centroid :return: the pandas DataFrame structure.
- suncasa.utils.DButil.getcolctinDF(dspecDF, col)[source]
return the count of how many times of the element starts with col occurs in columns of dspecDF :param dspecDF: :param col: the start string :return: the count and items
- suncasa.utils.DButil.dspecDFfilter(dspecDF, pol)[source]
filter the unselect polarisation from dspecDF :param dspecDF: the original dspecDF :param pol: selected polarisation, dtype = string :return: the output dspecDF
- suncasa.utils.DButil.map2wcsgrids(snpmap, cell=True, antialiased=True)[source]
- Parameters:
snpmap
cell – if True, return the coordinates of the pixel centers. if False, return the coordinates of the pixel boundaries
- Returns:
- suncasa.utils.DButil.regridimage(values, x, y, grid=None, resize=[1.0, 1.0])[source]
re-grid the data on a regular grid with uneven grid spacing to an uniform grid :param values: The image data on the regular grid :param x: the points defining the regular grid in x :param y: the points defining the regular grid in y :param grid: new uniform mesh grid [gridx,gridy] :param resize: list of re-size ratio factors of x and y. if resize is not [1.0,1.0], grid is neglected. :return: re-gridded image
- suncasa.utils.DButil.regridspec(spec, x, y, nxmax=None, nymax=None, interp=False)[source]
- Parameters:
spec – ndarray of float or complex, shape (npol,nbl,nf,nt) Data values.
x – Data point x coordinates.
y – Data point y coordinates.
nxmax
nymax
- Returns:
- suncasa.utils.DButil.c_correlateX(a, v, returnx=False, returnav=False, s=0)[source]
- Parameters:
a
v – a and v can be a dict in following format {‘x’:[],’y’:[]}. The length of a and v can be different.
returnx
- Returns: