threeML.io package¶
Subpackages¶
- threeML.io.cern_root_utils package
- threeML.io.plotting package
- Submodules
- threeML.io.plotting.cmap_cycle module
- threeML.io.plotting.data_residual_plot module
- threeML.io.plotting.light_curve_plots module
- threeML.io.plotting.model_plot module
- threeML.io.plotting.plot_style module
- threeML.io.plotting.post_process_data_plots module
- threeML.io.plotting.step_plot module
- Module contents
Submodules¶
threeML.io.calculate_flux module¶
threeML.io.dict_with_pretty_print module¶
threeML.io.download_from_ftp module¶
threeML.io.download_from_http module¶
-
class
threeML.io.download_from_http.
ApacheDirectory
(url)[source]¶ Bases:
object
Allows to interact with a directory listing like the one returned by an Apache server
-
property
directories
¶
-
download
(remote_filename, destination_path: str, new_filename=None, progress=True, compress=False)[source]¶
-
download_all_files
(destination_path, progress=True, pattern=None)[source]¶ Download all files in the current directory
- Parameters
destination_path – the path for the destination directory in the local file system
progress – (True or False) whether to display progress or not
pattern – (default: None) If not None, only files matching this pattern (a regular expression) will be
downloaded :return: list of the downloaded files as absolute paths in the local file system
-
property
files
¶
-
property
threeML.io.file_utils module¶
-
threeML.io.file_utils.
fits_file_existing_and_readable
(filename) → bool[source]¶ checks if a FITS file exists ignoring extension ({}) info
-
threeML.io.file_utils.
get_random_unique_name
()[source]¶ Returns a name which is random and (with extremely high probability) unique
- Returns
random file name
-
threeML.io.file_utils.
if_directory_not_existing_then_make
(directory) → None[source]¶ If the given directory does not exists, then make it
- Parameters
directory – directory to check or make
- Returns
None
-
threeML.io.file_utils.
temporary_directory
(prefix='', within_directory=None)[source]¶ This context manager creates a temporary directory in the most secure possible way (with no race condition), and removes it at the end.
- Parameters
prefix – the directory name will start with this prefix, if specified
within_directory – create within a specific directory (assumed to exist). Otherwise, it will be created in the
default system temp directory (/tmp in unix) :return: the absolute pathname of the provided directory
threeML.io.fits_file module¶
-
class
threeML.io.fits_file.
FITSExtension
(data_tuple, header_tuple)[source]¶ Bases:
object
-
property
hdu
¶
-
property
-
class
threeML.io.fits_file.
FITSFile
(primary_hdu=None, fits_extensions=None)[source]¶ Bases:
object
-
index_of
(key)[source]¶ Get the index of an HDU from the HDUList.
- keyint, str, tuple of (string, int) or an HDU object
The key identifying the HDU. If
key
is a tuple, it is of the form(name, ver)
wherever
is anEXTVER
value that must match the HDU being searched for.If the key is ambiguous (e.g. there are multiple ‘SCI’ extensions) the first match is returned. For a more precise match use the
(name, ver)
pair.If even the
(name, ver)
pair is ambiguous (it shouldn’t be but it’s not impossible) the numeric index must be used to index the duplicate HDU.When
key
is an HDU object, this function returns the index of that HDU object in theHDUList
.
- indexint
The index of the HDU in the HDUList.
- ValueError
If
key
is an HDU object and it is not found in theHDUList
.- KeyError
If an HDU specified by the
key
that is an extension number, extension name, or a tuple of extension name and version is not found in theHDUList
.
-
info
(output=None)[source]¶ Summarize the info of the HDUs in this HDUList.
Note that this function prints its results to the console—it does not return a value.
- outputfile, bool, optional
A file-like object to write the output to. If False, does not output to a file and instead returns a list of tuples representing the HDU info. Writes to
sys.stdout
by default.
-
writeto
(*args, **kwargs)[source]¶ Write the HDUList to a new file.
- fileobjstr, file-like or pathlib.Path
File to write to. If a file object, must be opened in a writeable mode.
- output_verifystr
Output verification option. Must be one of
"fix"
,"silentfix"
,"ignore"
,"warn"
, or"exception"
. May also be any combination of"fix"
or"silentfix"
with"+ignore"
,+warn
, or+exception" (e.g. ``"fix+warn"
). See verify for more info.- overwritebool, optional
If
True
, overwrite the output file if it exists. Raises anOSError
ifFalse
and the output file exists. Default isFalse
.Changed in version 1.3:
overwrite
replaces the deprecatedclobber
argument.- checksumbool
When True adds both
DATASUM
andCHECKSUM
cards to the headers of all HDU’s written to the file.
-
threeML.io.get_heasarc_table_as_pandas module¶
-
threeML.io.get_heasarc_table_as_pandas.
get_heasarc_table_as_pandas
(heasarc_table_name, update=False, cache_time_days=1)[source]¶ Obtain a a VO table from the HEASARC archives and return it as a pandas table indexed by object/trigger names. The heasarc_table_name values are the ones referenced at:
https://heasarc.gsfc.nasa.gov/docs/archive/vo/
In order to speed up the processing of the tables, 3ML can cache the XML table in a cache that is updated every cache_time_days. The cache can be forced to update, i.e, reload from the web, by setting update to True.
- Parameters
heasarc_table_name – the name of a HEASARC browse table
update – force web read of the table and update cache
cache_time_days – number of days to hold the current cache
- Returns
pandas DataFrame with results and astropy table
threeML.io.network module¶
threeML.io.package_data module¶
threeML.io.progress_bar module¶
-
exception
threeML.io.progress_bar.
CannotGenerateHTMLBar
¶ Bases:
RuntimeError
-
class
threeML.io.progress_bar.
ProgressBarAscii
(iterations, width, scale=1, units='', title=None)¶ Bases:
threeML.io.progress_bar.ProgressBarBase
-
finish
()¶
-
-
class
threeML.io.progress_bar.
ProgressBarBase
(iterations, width, scale=1, units='', title=None)¶ Bases:
object
-
animate
(iteration)¶
-
finish
()¶
-
increase
(n_steps=1)¶
-
-
class
threeML.io.progress_bar.
ProgressBarHTML
(iterations, width, scale=1, units='', title=None)¶
-
class
threeML.io.progress_bar.
ProgressBarOld
(iterations)¶ Bases:
object
-
animate
(iter)¶
-
increase
()¶
-
update_iteration
(elapsed_iter)¶
-
-
threeML.io.progress_bar.
multiple_progress_bars
(iterations, n, width=None, force_html=False)¶
-
threeML.io.progress_bar.
progress_bar
(iterations, width=None, scale=1, units='', title=None)¶ Use as a context manager to display a progress bar which adapts itself to the environment. It will be a widget in jupyter or a text progress bar in a terminal (but you don’t have to worry about it)
- Parameters
iterations – number of iterations for completion of the task
width – width of the progress bar (default: None, which means self-decided)
scale – display the progress scaled for this number (useful to display downloads for example) (default: 1)
units – a unit to display after the progress (default: ‘’)
title – a title for the task, which will be displayed before the progress bar (default: None, i.e., no title)
- Returns
a ProgressBarAscii or a ProgressBarHTML instance, depending on the environment (jupyter or terminal)
threeML.io.results_table module¶
threeML.io.serialization module¶
threeML.io.suppress_stdout module¶
threeML.io.table module¶
-
class
threeML.io.table.
NumericMatrix
(data=None, masked=False, names=None, dtype=None, meta=None, copy=True, rows=None, copy_indices=True, units=None, descriptions=None, **kwargs)[source]¶ Bases:
threeML.io.table.Table
threeML.io.uncertainty_formatter module¶
-
threeML.io.uncertainty_formatter.
get_uncertainty_tokens
(x)[source]¶ Split the given uncertainty in number, error and exponent.
- Parameters
x – an uncertainty instance
- Returns
number, error and exponent
-
threeML.io.uncertainty_formatter.
interval_to_errors
(value, low_bound, hi_bound)[source]¶ Convert error intervals to errors
- Parameters
value – central value
low_bound – interval low bound
hi_bound – interval high bound
- Returns
(error minus, error plus)
-
threeML.io.uncertainty_formatter.
uncertainty_formatter
(value, low_bound, hi_bound)[source]¶ Gets a value and its error in input, and returns the value, the uncertainty and the common exponent with the proper number of significant digits in a string like (4.2 -0.023 +5.23) x 10^5
- Parameters
value –
error – a positive value
- Returns
string representation of interval