hendrics package

Submodules

hendrics.base module

A miscellaneous collection of basic functions.

hendrics.base.common_name(str1, str2, default=u'common')[source] [edit on github]

Strip two strings of the letters not in common.

Filenames must be of same length and only differ by a few letters.

Parameters:

str1 : str

str2 : str

Returns:

common_str : str

A string containing the parts of the two names in common

Other Parameters:
 

default : str

The string to return if common_str is empty

hendrics.base.deorbit_events(events, parameter_file=None)[source] [edit on github]
hendrics.base.detection_level(nbins, epsilon=0.01, n_summed_spectra=1, n_rebin=1)[source] [edit on github]

Detection level for a PDS.

Return the detection level (with probability 1 - epsilon) for a Power Density Spectrum of nbins bins, normalized a la Leahy (1983), based on the 2-dof \({\chi}^2\) statistics, corrected for rebinning (n_rebin) and multiple PDS averaging (n_summed_spectra)

hendrics.base.gti_len(gti)[source] [edit on github]

Return the total good time from a list of GTIs.

hendrics.base.hen_root(filename)[source] [edit on github]

Return the root file name (without _ev, _lc, etc.).

Parameters:filename : str
hendrics.base.is_string(s)[source] [edit on github]

Portable function to answer this question.

hendrics.base.mkdir_p(path)[source] [edit on github]

Safe mkdir function.

Parameters:

path : str

Name of the directory/ies to create

Notes

Found at http://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python

hendrics.base.optimal_bin_time(fftlen, tbin)[source] [edit on github]

Vary slightly the bin time to have a power of two number of bins.

Given an FFT length and a proposed bin time, return a bin time slightly shorter than the original, that will produce a power-of-two number of FFT bins.

hendrics.base.probability_of_power(level, nbins, n_summed_spectra=1, n_rebin=1)[source] [edit on github]

Give the probability of a given power level in PDS.

Return the probability of a certain power level in a Power Density Spectrum of nbins bins, normalized a la Leahy (1983), based on the 2-dof \({\chi}^2\) statistics, corrected for rebinning (n_rebin) and multiple PDS averaging (n_summed_spectra)

hendrics.base.r_det(td, r_in)[source] [edit on github]

Calculate detected countrate given dead time and incident countrate.

hendrics.base.r_in(td, r_0)[source] [edit on github]

Calculate incident countrate given dead time and detected countrate.

hendrics.base.read_header_key(fits_file, key, hdu=1)[source] [edit on github]

Read the header key key from HDU hdu of the file fits_file.

Parameters:

fits_file: str

key: str

The keyword to be read

Other Parameters:
 

hdu : int

hendrics.base.ref_mjd(fits_file, hdu=1)[source] [edit on github]

Read MJDREFF+ MJDREFI or, if failed, MJDREF, from the FITS header.

Parameters:

fits_file : str

Returns:

mjdref : numpy.longdouble

the reference MJD

Other Parameters:
 

hdu : int

hendrics.binary module

Save different input files in PRESTO-readable format.

hendrics.binary.get_header_info(obj)[source] [edit on github]

Get header info from a Stingray object.

hendrics.binary.main_presto(args=None)[source] [edit on github]
hendrics.binary.save_events_to_binary(events, filename, bin_time, tstart=None, emin=None, emax=None)[source] [edit on github]

Save an event list to binary format.

Parameters:

events : :class:stingray.Eventlist

Input event list

filename : str

Output file name

bin_time : float

Bin time of the output light curve

Returns:

lcinfo : object

light curve info

Other Parameters:
 

tstart : float

Starting time

emin : float

Minimum energy of the photons

emax : float

Maximum energy of the photons

hendrics.binary.save_inf(lcinfo, info, filename)[source] [edit on github]

Save information file.

hendrics.binary.save_lc_to_binary(lc, filename)[source] [edit on github]

Save a light curve to binary format.

Parameters:

lc : :class:stingray.Lightcurve

Input light curve

filename : str

Output file name

Returns

——-

lcinfo : object

light curve info

hendrics.calibrate module

Calibrate event lists by looking in rmf files.

hendrics.calibrate.calibrate(fname, outname, rmf_file=None)[source] [edit on github]

Do calibration of an event list.

Parameters:

fname : str

The HENDRICS file containing the events

outname : str

The output file

Other Parameters:
 

rmf_file : str

The rmf file used to read the calibration. If None or not specified, the one given by default_nustar_rmf() is used.

hendrics.calibrate.default_nustar_rmf()[source] [edit on github]

Look for the default rmf file in the CALDB.

The CALDB environment variable has to point to the correct location of the NuSTAR CALDB

Note

The calibration might change in the future. The hardcoded file name will be eventually replaced with a smarter choice based on observing time

hendrics.calibrate.main(args=None)[source] [edit on github]

Main function called by the HENcalibrate command line script.

hendrics.calibrate.read_calibration(pis, rmf_file=None)[source] [edit on github]

Read the energy channels corresponding to the given PI channels.

Parameters:

pis : array-like

The channels to lookup in the rmf

Other Parameters:
 

rmf_file : str

The rmf file used to read the calibration. If None or not specified, the one given by default_nustar_rmf() is used.

hendrics.calibrate.read_rmf(rmf_file=None)[source] [edit on github]

Load RMF info.

Note

Preliminary: only EBOUNDS are read.

Parameters:

rmf_file : str

The rmf file used to read the calibration. If None or not specified, the one given by default_nustar_rmf() is used.

Returns:

pis : array-like

the PI channels

e_mins : array-like

the lower energy bound of each PI channel

e_maxs : array-like

the upper energy bound of each PI channel

hendrics.colors module

Functions to calculate colors and hardness.

hendrics.colors.colors()[source] [edit on github]
hendrics.colors.main(args=None)[source] [edit on github]

Main function called by the HENcolors command line script.

hendrics.create_gti module

Functions to create and apply GTIs.

hendrics.create_gti.apply_gti(fname, gti, outname=None, minimum_length=0)[source] [edit on github]

Apply a GTI list to the data contained in a file.

File MUST have a GTI extension already, and an extension called time.

hendrics.create_gti.create_gti(fname, filter_expr, safe_interval=[0, 0], outfile=None, minimum_length=0)[source] [edit on github]

Create a GTI list by using boolean operations on file data.

Parameters:

fname : str

File name. The file must be in HENDRICS format.

filter_expr : str

A boolean condition on one or more of the arrays contained in the data. E.g. ‘(lc > 10) & (lc < 20)’

Returns:

gtis : [[gti0_0, gti0_1], [gti1_0, gti1_1], …]

The newly created GTIs

Other Parameters:
 

safe_interval : float or [float, float]

A safe interval to exclude at both ends (if single float) or the start and the end (if pair of values) of GTIs.

outfile : str

The output file name. If None, use a default root + ‘_gti’ combination

hendrics.create_gti.filter_gti_by_length(gti, minimum_length)[source] [edit on github]

Filter a list of GTIs: keep those longer than minimum_length.

hendrics.create_gti.main(args=None)[source] [edit on github]

Main function called by the HENcreategti command line script.

hendrics.efsearch module

Search for pulsars.

hendrics.efsearch.decide_binary_parameters(length, freq_range, porb_range, asini_range, fdot_range=[0, 0], NMAX=10, csv_file='db.csv', reset=False)[source] [edit on github]
hendrics.efsearch.fit(frequencies, stats, center_freq, width=None, obs_length=None, baseline=0)[source] [edit on github]
hendrics.efsearch.main_efsearch(args=None)[source] [edit on github]

Main function called by the HENefsearch command line script.

hendrics.efsearch.main_zsearch(args=None)[source] [edit on github]

Main function called by the HENzsearch command line script.

hendrics.exvar module

Created on Thu Aug 17 08:55:47 2017

@author: marta

hendrics.exvar.excvar_none(lc)[source] [edit on github]
hendrics.exvar.excvar_norm(lc)[source] [edit on github]
hendrics.exvar.fvar(lc)[source] [edit on github]
hendrics.exvar.main(args=None)[source] [edit on github]

hendrics.exposure module

Calculate the exposure correction for light curves.

Only works for data taken in specific data modes of NuSTAR, where all events are telemetered.

hendrics.exposure.correct_lightcurve(lc_file, uf_file, outname=None, expo_limit=1e-07)[source] [edit on github]

Apply exposure correction to light curve.

Parameters:

lc_file : str

The light curve file, in HENDRICS format

uf_file : str

The unfiltered event file, in FITS format

Returns:

outdata : str

Output data structure

Other Parameters:
 

outname : str

Output file name

hendrics.exposure.get_exposure_from_uf(time, uf_file, dt=None, gti=None)[source] [edit on github]

Get livetime from unfiltered event file.

Parameters:

time : array-like

The time bins of the light curve

uf_file : str

Unfiltered event file (the one in the event_cl directory with the _uf suffix)

Returns:

expo : array-like

Exposure (livetime) values corresponding to time bins

Other Parameters:
 

dt : float

If time array is not sampled uniformly, dt can be specified here.

hendrics.exposure.get_livetime_per_bin(times, events, priors, dt=None, gti=None)[source] [edit on github]

Get the livetime in a series of time intervals.

Parameters:

times : array-like

The array of times to look at

events : array-like

A list of events, producing dead time

priors : array-like

The livetime before each event (as in the PRIOR column of unfiltered NuSTAR event files)

Returns:

livetime_array : array-like

An array of the same length as times, containing the live time values

Other Parameters:
 

dt : float or array-like

The width of the time bins of the time array. Can be a single float or an array of the same length as times

gti : [[g0_0, g0_1], [g1_0, g1_1], …]

Good time intervals. Defaults to [[time[0] - dt[0]/2, time[-1] + dt[-1]/2]]

hendrics.exposure.main(args=None)[source] [edit on github]

Main function called by the HENexposure command line script.

hendrics.fake module

Functions to simulate data and produce a fake event file.

hendrics.fake.filter_for_deadtime(event_list, deadtime, bkg_ev_list=None, dt_sigma=None, paralyzable=False, additional_data=None, return_all=False)[source] [edit on github]

Filter an event list for a given dead time.

Parameters:

ev_list : array-like

The event list

deadtime: float

The (mean, if not constant) value of deadtime

Returns:

new_ev_list : array-like

The filtered event list

additional_output : dict

Object with all the following attributes. Only returned if return_all is True

uf_events : array-like

Unfiltered event list (events + background)

is_event : array-like

Boolean values; True if event, False if background

deadtime : array-like

Dead time values

bkg : array-like

The filtered background event list

mask : array-like, optional

The mask that filters the input event list and produces the output event list.

Other Parameters:
 

bkg_ev_list : array-like

A background event list that affects dead time

dt_sigma : float

The standard deviation of a non-constant dead time around deadtime.

return_all : bool

If True, return the mask that filters the input event list to obtain the output event list.

hendrics.fake.generate_fake_fits_observation(event_list=None, filename=None, instr='FPMA', gti=None, tstart=None, tstop=None, mission='NUSTAR', mjdref=55197.00076601852, livetime=None, additional_columns={})[source] [edit on github]

Generate fake NuSTAR data.

Takes an event list (as a list of floats) All inputs are None by default, and can be set during the call.

Parameters:

event_list : list-like

stingray.events.Eventlist object. If left None, 1000 random events will be generated, for a total length of 1025 s or the difference between tstop and tstart.

filename : str

Output file name

Returns:

hdulist : FITS hdu list

FITS hdu list of the output file

Other Parameters:
 

mjdref : float

Reference MJD. Default is 55197.00076601852 (NuSTAR)

pi : list-like

The PI channel of each event

tstart : float

Start of the observation (s from mjdref)

tstop : float

End of the observation (s from mjdref)

instr : str

Name of the instrument. Default is ‘FPMA’

livetime : float

Total livetime. Default is tstop - tstart

hendrics.fake.jit(fun)[source] [edit on github]

Dummy decorator in case jit cannot be imported.

hendrics.fake.main(args=None)[source] [edit on github]

Main function called by the HENfake command line script.

hendrics.fspec module

Functions to calculate frequency spectra.

hendrics.fspec.calc_cpds(lcfile1, lcfile2, fftlen, save_dyn=False, bintime=1, pdsrebin=1, outname='cpds.p', normalization='leahy', back_ctrate=0.0, noclobber=False)[source] [edit on github]

Calculate the CPDS from a pair of input light curve files.

Parameters:

lcfile1 : str

The first light curve file

lcfile2 : str

The second light curve file

fftlen : float

The length of the chunks over which FFTs will be calculated, in seconds

Other Parameters:
 

save_dyn : bool

If True, save the dynamical power spectrum

bintime : float

The bin time. If different from that of the light curve, a rebinning is performed

pdsrebin : int

Rebin the PDS of this factor.

normalization : str

‘Leahy’, ‘frac’, ‘rms’, or any normalization accepted by stingray. Default ‘Leahy’

back_ctrate : float

The non-source count rate

noclobber : bool

If True, do not overwrite existing files

outname : str

Output file name for the cpds. Default: cpds.[nc|p]

hendrics.fspec.calc_fspec(files, fftlen, do_calc_pds=True, do_calc_cpds=True, do_calc_cospectrum=True, do_calc_lags=True, save_dyn=False, bintime=1, pdsrebin=1, outroot=None, normalization='leahy', nproc=1, back_ctrate=0.0, noclobber=False, ignore_instr=False)[source] [edit on github]

Calculate the frequency spectra: the PDS, the cospectrum, …

Parameters:

files : list of str

List of input file names

fftlen : float

length of chunks to perform the FFT on.

Other Parameters:
 

save_dyn : bool

If True, save the dynamical power spectrum

bintime : float

The bin time. If different from that of the light curve, a rebinning is performed

pdsrebin : int

Rebin the PDS of this factor.

normalization : str

‘Leahy’ [3] or ‘rms’ [4] [5]. Default ‘Leahy’.

back_ctrate : float

The non-source count rate

noclobber : bool

If True, do not overwrite existing files

outroot : str

Output file name root

nproc : int

Number of processors to use to parallelize the processing of multiple files

ignore_instr : bool

Ignore instruments; files are alternated in the two channels

References

[3] Leahy et al. 1983, ApJ, 266, 160.

[4] Belloni & Hasinger 1990, A&A, 230, 103

[5] Miyamoto et al. 1991, ApJ, 383, 784

hendrics.fspec.calc_pds(lcfile, fftlen, save_dyn=False, bintime=1, pdsrebin=1, normalization='leahy', back_ctrate=0.0, noclobber=False, outname=None)[source] [edit on github]

Calculate the PDS from an input light curve file.

Parameters:

lcfile : str

The light curve file

fftlen : float

The length of the chunks over which FFTs will be calculated, in seconds

Other Parameters:
 

save_dyn : bool

If True, save the dynamical power spectrum

bintime : float

The bin time. If different from that of the light curve, a rebinning is performed

pdsrebin : int

Rebin the PDS of this factor.

normalization: str

‘Leahy’, ‘frac’, ‘rms’, or any normalization accepted by stingray. Default ‘Leahy’

back_ctrate : float

The non-source count rate

noclobber : bool

If True, do not overwrite existing files

outname : str

If speficied, output file name. If not specified or None, the new file will have the same root as the input light curve and the ‘_pds’ suffix

hendrics.fspec.dumpdyn(fname, plot=False)[source] [edit on github]

Dump a dynamical frequency spectrum in text files.

Parameters:

fname : str

The file name

Other Parameters:
 

plot : bool

if True, plot the spectrum

hendrics.fspec.dumpdyn_main(args=None)[source] [edit on github]

Main function called by the HENdumpdyn command line script.

hendrics.fspec.main(args=None)[source] [edit on github]

Main function called by the HENfspec command line script.

hendrics.io module

Functions to perform input/output operations.

class hendrics.io.EFPeriodogram(freq=None, stat=None, kind=None, nbin=None, N=None, peaks=None, peak_stat=None, best_fits=None, fdots=0)[source] [edit on github]

Bases: object

hendrics.io.get_file_extension(fname)[source] [edit on github]

Get the file extension.

hendrics.io.get_file_format(fname)[source] [edit on github]

Decide the file format of the file.

hendrics.io.get_file_type(fname, raw_data=False)[source] [edit on github]

Return the file type and its contents.

Only works for hendrics-format pickle or netcdf files.

hendrics.io.high_precision_keyword_read(hdr, keyword)[source] [edit on github]

Read FITS header keywords, also if split in two.

In the case where the keyword is split in two, like

MJDREF = MJDREFI + MJDREFF

in some missions, this function returns the summed value. Otherwise, the content of the single keyword

Parameters:

hdr : dict_like

The header structure, or a dictionary

keyword : str

The key to read in the header

Returns:

value : long double

The value of the key, or None if keyword not present

hendrics.io.load_data(fname)[source] [edit on github]

Load generic data in hendrics format.

hendrics.io.load_events(fname)[source] [edit on github]

Load events from a file.

hendrics.io.load_events_and_gtis(fits_file, additional_columns=None, gtistring='GTI, STDGTI', gti_file=None, hduname='EVENTS', column='TIME')[source] [edit on github]

Load event lists and GTIs from one or more files.

Loads event list from HDU EVENTS of file fits_file, with Good Time intervals. Optionally, returns additional columns of data from the same HDU of the events.

Parameters:

fits_file : str

return_limits: bool, optional

Return the TSTART and TSTOP keyword values

additional_columns: list of str, optional

A list of keys corresponding to the additional columns to extract from the event HDU (ex.: [‘PI’, ‘X’])

Returns:

ev_list : array-like

gtis: [[gti0_0, gti0_1], [gti1_0, gti1_1], …]

additional_data: dict

A dictionary, where each key is the one specified in additional_colums. The data are an array with the values of the specified column in the fits file.

t_start : float

t_stop : float

hendrics.io.load_folding(fname)[source] [edit on github]

Load PDS from a file.

hendrics.io.load_gtis(fits_file, gtistring=None)[source] [edit on github]

Load GTI from HDU EVENTS of file fits_file.

hendrics.io.load_lcurve(fname)[source] [edit on github]

Load light curve from a file.

hendrics.io.load_model(modelstring)[source] [edit on github]
hendrics.io.load_pds(fname, nosub=False)[source] [edit on github]

Load PDS from a file.

hendrics.io.main(args=None)[source] [edit on github]

Main function called by the HENreadfile command line script.

hendrics.io.print_fits_info(fits_file, hdu=1)[source] [edit on github]

Print general info about an observation.

hendrics.io.read_from_netcdf(fname)[source] [edit on github]

Read from a netCDF4 file.

hendrics.io.save_as_ascii(cols, filename='out.txt', colnames=None, append=False)[source] [edit on github]

Save arrays as TXT file with respective errors.

hendrics.io.save_as_netcdf(vars, varnames, formats, fname)[source] [edit on github]

Save variables in a NetCDF4 file.

hendrics.io.save_as_qdp(arrays, errors=None, filename='out.qdp', mode='w')[source] [edit on github]

Save arrays in a QDP file.

Saves an array of variables, and possibly their errors, to a QDP file.

Parameters:

arrays: [array1, array2]

List of variables. All variables must be arrays and of the same length.

errors: [array1, array2]

List of errors. The order has to be the same of arrays; the value can be: - None if no error is assigned - an array of same length of variable for symmetric errors - an array of len-2 lists for non-symmetric errors (e.g. [[errm1, errp1], [errm2, errp2], [errm3, errp3], …])

Other Parameters:
 

mode : str

the file access mode, to be passed to the open() function. Can be ‘w’ or ‘a’

hendrics.io.save_data(struct, fname, ftype='data')[source] [edit on github]

Save generic data in hendrics format.

hendrics.io.save_events(eventlist, fname)[source] [edit on github]

Save events in a file.

Parameters:

eventlist: :class:`stingray.EventList` object

Event list to be saved

fname: str

Name of output file

hendrics.io.save_folding(efperiodogram, fname)[source] [edit on github]

Save PDS in a file.

hendrics.io.save_lcurve(lcurve, fname, lctype='Lightcurve')[source] [edit on github]

Save Light curve to file

Parameters:

lcurve: :class:`stingray.Lightcurve` object

Event list to be saved

fname: str

Name of output file

hendrics.io.save_model(model, fname='model.p', constraints=None)[source] [edit on github]

Save best-fit models to data.

Parameters:

model : func or astropy.modeling.core.Model object

The model to be saved

fname : str, default ‘models.p’

The output file name

Other Parameters:
 

constraints: dict

Additional model constraints. Ignored for astropy models.

hendrics.io.save_pds(cpds, fname, save_all=True)[source] [edit on github]

Save PDS in a file.

hendrics.io.sort_files(files)[source] [edit on github]

Sort a list of HENDRICS files, looking at Tstart in each.

hendrics.lcurve module

Light curve-related functions.

hendrics.lcurve.baseline_main(args=None)[source] [edit on github]

Main function called by the HENbaselinesub command line script.

hendrics.lcurve.filter_lc_gtis(lc, safe_interval=None, delete=False, min_length=0, return_borders=False)[source] [edit on github]

Filter a light curve for GTIs.

Parameters:

lc : Lightcurve object

The input light curve

Returns:

newlc : Lightcurve object

The output light curve

borders : [[i0_0, i0_1], [i1_0, i1_1], …], optional

The indexes of the light curve corresponding to the borders of the GTIs. Returned if return_borders is set to True

Other Parameters:
 

safe_interval : float or [float, float]

Seconds to filter out at the start and end of each GTI. If single float, these safe windows are equal, otherwise the two numbers refer to the start and end of the GTI respectively

delete : bool

If delete is True, the intervals outside of GTIs are filtered out from the light curve. Otherwise, they are set to zero.

min_length : float

Minimum length of GTI. GTIs below this length will be removed.

return_borders : bool

If True, return also the indexes of the light curve corresponding to the borders of the GTIs

hendrics.lcurve.join_lightcurves(lcfilelist, outfile=u'out_lc.p')[source] [edit on github]

Join light curves from different files.

Light curves from different instruments are put in different channels.

Parameters:

lcfilelist : list of str

List of input file names

outfile :

Output light curve

See Also

——–

scrunch_lightcurves : Create a single light curve from input light

curves.

hendrics.lcurve.lcurve_from_events(f, safe_interval=0, pi_interval=None, e_interval=None, min_length=0, gti_split=False, ignore_gtis=False, bintime=1.0, outdir=None, outfile=None, noclobber=False)[source] [edit on github]

Bin an event list in a light curve.

Parameters:

f : str

Input event file name

bintime : float

The bin time of the output light curve

Returns:

outfiles : list

List of output light curves

Other Parameters:
 

safe_interval : float or [float, float]

Seconds to filter out at the start and end of each GTI. If single float, these safe windows are equal, otherwise the two numbers refer to the start and end of the GTI respectively

pi_interval : [int, int]

PI channel interval to select. Default None, meaning that all PI channels are used

e_interval : [float, float]

Energy interval to select (only works if event list is calibrated with calibrate). Default None

min_length : float

GTIs below this length will be filtered out

gti_split : bool

If True, create one light curve for each good time interval

ignore_gtis : bool

Ignore good time intervals, and get a single light curve that includes possible gaps

outdir : str

Output directory

outfile : str

Output file

noclobber : bool

If True, do not overwrite existing files

hendrics.lcurve.lcurve_from_fits(fits_file, gtistring=u'GTI', timecolumn=u'TIME', ratecolumn=None, ratehdu=1, fracexp_limit=0.9, outfile=None, noclobber=False, outdir=None)[source] [edit on github]

Load a lightcurve from a fits file and save it in HENDRICS format.

Note

FITS light curve handling is still under testing. Absolute times might be incorrect depending on the light curve format.

Parameters:

fits_file : str

File name of the input light curve in FITS format

Returns:

outfile : [str]

Returned as a list with a single element for consistency with lcurve_from_events

Other Parameters:
 

gtistring : str

Name of the GTI extension in the FITS file

timecolumn : str

Name of the column containing times in the FITS file

ratecolumn : str

Name of the column containing rates in the FITS file

ratehdu : str or int

Name or index of the FITS extension containing the light curve

fracexp_limit : float

Minimum exposure fraction allowed

outfile : str

Output file name

noclobber : bool

If True, do not overwrite existing files

hendrics.lcurve.lcurve_from_txt(txt_file, outfile=None, noclobber=False, outdir=None, mjdref=None, gti=None)[source] [edit on github]

Load a lightcurve from a text file.

Parameters:

txt_file : str

File name of the input light curve in text format. Assumes two columns: time, counts. Times are seconds from MJDREF 55197.00076601852 (NuSTAR) if not otherwise specified.

Returns:

outfile : [str]

Returned as a list with a single element for consistency with lcurve_from_events

Other Parameters:
 

outfile : str

Output file name

noclobber : bool

If True, do not overwrite existing files

mjdref : float, default 55197.00076601852

the MJD time reference

gti : [[gti0_0, gti0_1], [gti1_0, gti1_1], …]

Good Time Intervals

hendrics.lcurve.main(args=None)[source] [edit on github]

Main function called by the HENlcurve command line script.

hendrics.lcurve.scrunch_lightcurves(lcfilelist, outfile=u'out_scrlc.p', save_joint=False)[source] [edit on github]

Create a single light curve from input light curves.

Light curves are appended when they cover different times, and summed when they fall in the same time range. This is done regardless of the channel or the instrument.

Parameters:

lcfilelist : list of str

The list of light curve files to scrunch

Returns:

time : array-like

The time array

lc :

The new light curve

gti : [[gti0_0, gti0_1], [gti1_0, gti1_1], …]

Good Time Intervals

Other Parameters:
 

outfile : str

The output file name

save_joint : bool

If True, save the per-channel joint light curves

See also

join_lightcurves
Join light curves from different files
hendrics.lcurve.scrunch_main(args=None)[source] [edit on github]

Main function called by the HENscrunchlc command line script.

hendrics.modeling module

hendrics.modeling.main_model(args=None)[source] [edit on github]

Main function called by the HENfspec command line script.

hendrics.plot module

Quicklook plots.

hendrics.plot.main(args=None)[source] [edit on github]

Main function called by the HENplot command line script.

hendrics.plot.plot_color(file0, file1, xlog=None, ylog=None, figname=None, output_data_file=None)[source] [edit on github]
hendrics.plot.plot_cospectrum(fnames, figname=None, xlog=None, ylog=None, output_data_file=None)[source] [edit on github]

Plot the cospectra from a list of CPDSs, or a single one.

hendrics.plot.plot_folding(fnames, figname=None, xlog=None, ylog=None, output_data_file=None)[source] [edit on github]
hendrics.plot.plot_generic(fnames, vars, errs=None, figname=None, xlog=None, ylog=None, output_data_file=None)[source] [edit on github]

Generic plotting function.

hendrics.plot.plot_lc(lcfiles, figname=None, fromstart=False, xlog=None, ylog=None, output_data_file=None)[source] [edit on github]

Plot a list of light curve files, or a single one.

hendrics.plot.plot_pds(fnames, figname=None, xlog=None, ylog=None, output_data_file=None, white_sub=False)[source] [edit on github]

Plot a list of PDSs, or a single one.

hendrics.read_events module

Read and save event lists from FITS files.

hendrics.read_events.main(args=None)[source] [edit on github]

Main function called by the HENreadevents command line script.

hendrics.read_events.treat_event_file(filename, noclobber=False, gti_split=False, min_length=4, gtistring=None, length_split=None)[source] [edit on github]

Read data from an event file, with no external GTI information.

Parameters:

filename : str

Other Parameters:
 

noclobber: bool

if a file is present, do not overwrite it

gtistring: str

comma-separated set of GTI strings to consider

gti_split: bool

split the file in multiple chunks, containing one GTI each

length_split: float, default None

split the file in multiple chunks, with approximately this length

min_length: float

minimum length of GTIs accepted (only if gti_split is True or length_split is not None)

hendrics.rebin module

Functions to rebin light curves and frequency spectra.

hendrics.rebin.main(args=None)[source] [edit on github]

Main function called by the HENrebin command line script.

hendrics.rebin.rebin_file(filename, rebin)[source] [edit on github]

Rebin the contents of a file, be it a light curve or a spectrum.

hendrics.save_as_xspec module

Functions to save data in a Xspec-readable format.

hendrics.save_as_xspec.main(args=None)[source] [edit on github]

Main function called by the HEN2xspec command line script.

hendrics.save_as_xspec.save_as_xspec(fname, direct_save=False, save_lags=True)[source] [edit on github]

Save frequency spectra in a format readable to FTOOLS and Xspec.

Parameters:

fname : str

Input HENDRICS frequency spectrum file name

direct_save : bool

If True, also call flx2xsp to produce the output .pha and .rsp files. If False (default), flx2xsp has to be called from the user

Notes

Uses method described here: https://asd.gsfc.nasa.gov/XSPECwiki/fitting_timing_power_spectra_in_XSPEC

hendrics.sum_fspec module

Function to sum frequency spectra.

hendrics.sum_fspec.main(args=None)[source] [edit on github]

Main function called by the HENsumfspec command line script.

hendrics.sum_fspec.sum_fspec(files, outname=None)[source] [edit on github]

Take a bunch of (C)PDSs and sums them.

hendrics.timelags module

hendrics.timelags.main(args=None)[source] [edit on github]

hendrics.version module

hendrics.version.get_git_devstr(sha=False, show_warning=True, path=None)[source] [edit on github]

Determines the number of revisions in this repository.

Parameters:

sha : bool

If True, the full SHA1 hash will be returned. Otherwise, the total count of commits in the repository will be used as a “revision number”.

show_warning : bool

If True, issue a warning if git returns an error code, otherwise errors pass silently.

path : str or None

If a string, specifies the directory to look in to find the git repository. If None, the current working directory is used, and must be the root of the git repository. If given a filename it uses the directory containing that file.

Returns:

devversion : str

Either a string with the revision number (if sha is False), the SHA1 hash of the current commit (if sha is True), or an empty string if git version info could not be identified.

hendrics.version.update_git_devstr(version, path=None)[source] [edit on github]

Updates the git revision string if and only if the path is being imported directly from a git working copy. This ensures that the revision number in the version string is accurate.

Module contents

This is proposed as an Astropy affiliated package.