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.get_style module
- threeML.io.plotting.light_curve_plots module
- threeML.io.plotting.model_plot module
- threeML.io.plotting.model_plot_2D module
- threeML.io.plotting.model_plot_tags 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.configuration module
threeML.io.detect_notebook 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
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
- 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.
- Parameters:
key (int, str, tuple of (string, int) or BaseHDU) – 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
.- Returns:
index – The index of the HDU in the HDUList.
- Return type:
int
- Raises:
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.
- Parameters:
output (file-like or 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.
- Parameters:
fileobj (str, file-like or pathlib.Path) – File to write to. If a file object, must be opened in a writeable mode.
output_verify (str) – 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 astropy:verify for more info.overwrite (bool, optional) – If
True
, overwrite the output file if it exists. Raises anOSError
ifFalse
and the output file exists. Default isFalse
.checksum (bool) – When True adds both
DATASUM
andCHECKSUM
cards to the headers of all HDU’s written to the file.
Notes
gzip, zip and bzip2 compression algorithms are natively supported. Compression mode is determined from the filename extension (‘.gz’, ‘.zip’ or ‘.bz2’ respectively). It is also possible to pass a compressed file object, e.g. gzip.GzipFile.
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.hdf5_utils module
threeML.io.logging module
- class threeML.io.logging.LoggingState(threeML_usr_log_handler, threeML_console_log_handler, astromodels_usr_log_handler, astromodels_console_log_handler)[source]
Bases:
object
- threeML.io.logging.activate_warnings()[source]
supress warning messages in console and file usr logs
- threeML.io.logging.get_path_of_log_file(log_file: str) Path [source]
returns the path of the log files
- threeML.io.logging.silence_console_log(and_progress_bars=True)[source]
temporarily silence the console and progress bars
threeML.io.network module
threeML.io.package_data module
- threeML.io.package_data.get_path_of_data_dir() Path [source]
Used to get internal testing data and for examples. Not for user data
- Returns:
threeML.io.results_table module
threeML.io.rich_display module
threeML.io.serialization module
threeML.io.suppress_stdout module
threeML.io.table module
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