dustapprox.tools package
Contents
dustapprox.tools package#
Convenient tools to generate models and plots.
Submodules#
dustapprox.tools.downloader module#
A simple tool to download files from URLs
- dustapprox.tools.downloader.download_file(link: str, file_name: str, overwrite: bool = False) str [source]#
Download a file on disk from url
- Parameters
link (str) – url of the file
file_name (str) – path and filename of the download location
overwrite (bool) – set to re-download (default False)
- Return type
Returns the filename of the data
dustapprox.tools.grid module#
Generate a grid of models with extinction from an atmosphere library
Example of script that produces a grid of dust attenuated stellar models from an atmosphere library.
This example can run in parallel on multiple processes or cores.
See also
- dustapprox.tools.grid.compute_photometric_grid(sources='models/Kurucz2003all/*.fl.dat.txt', n_jobs=1, verbose=0)[source]#
Run the computations of the photometric grid in parallel
- Parameters
sources (str) – pattern of atmospehric models to process (using glob syntax)
n_jobs (int) – number of parallel processes to run (default: 1, -1 for as many as CPUs)
verbose (int) – verbosity level (default: 0)
- Returns
Dataframe with the photometric values for each passband
- Return type
pd.DataFrame
dustapprox.tools.parallel module#
Parallel processing with joblib and tqdm.
- dustapprox.tools.parallel.tqdm_joblib(tqdm_object)[source]#
Context manager to patch joblib to report into tqdm progress bar given as argument
Solution adapted from Stackoverflow.
import time from joblib import Parallel, delayed def some_method(wait_time): time.sleep(wait_time) with tqdm_joblib(tqdm(desc="My method", total=10)) as progress_bar: Parallel(n_jobs=2)(delayed(some_method)(0.2) for i in range(10))