Skip to content

Commit

Permalink
Merge pull request #311 from AstarVienna/fh/tqdm
Browse files Browse the repository at this point in the history
Include more progress bars
  • Loading branch information
teutoburg authored Dec 18, 2023
2 parents 8c4a18b + 77fa8d6 commit a783dda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion scopesim/effects/spectral_trace_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import logging
from itertools import cycle

from tqdm import tqdm

from astropy.io import fits
from astropy.table import Table

Expand Down Expand Up @@ -295,7 +297,8 @@ def rectify_traces(self, hdulist, xi_min=None, xi_max=None, interps=None,
# pdu.header["FILTER"] = from_currsys("!OBS.filter_name_fw1")
outhdul = fits.HDUList([pdu])

for i, trace_id in enumerate(self.spectral_traces, start=1):
for i, trace_id in tqdm(enumerate(self.spectral_traces, start=1),
desc=" Traces"):
hdu = self[trace_id].rectify(hdulist,
interps=interps,
bin_width=bin_width,
Expand Down
10 changes: 7 additions & 3 deletions scopesim/optics/optical_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from scipy.interpolate import interp1d
from astropy import units as u

from tqdm import tqdm

from synphot.units import PHOTLAM

from .optics_manager import OpticsManager
Expand Down Expand Up @@ -183,23 +185,25 @@ def observe(self, orig_source, update=True, **kwargs):

# [3D - Atmospheric shifts, PSF, NCPAs, Grating shift/distortion]
fovs = self.fov_manager.fovs
for fov in fovs:
for fov in tqdm(fovs, desc=" FOVs", position=0):
# print("FOV", fov_i+1, "of", n_fovs, flush=True)
# .. todo: possible bug with bg flux not using plate_scale
# see fov_utils.combine_imagehdu_fields
fov.extract_from(source)

hdu_type = "cube" if self.fov_manager.is_spectroscope else "image"
fov.view(hdu_type)
for effect in self.optics_manager.fov_effects:
for effect in tqdm(self.optics_manager.fov_effects,
desc=" FOV effects", position=1, leave=False):
fov = effect.apply_to(fov)

fov.flatten()
self.image_planes[fov.image_plane_id].add(fov.hdu, wcs_suffix="D")
# ..todo: finish off the multiple image plane stuff

# [2D - Vibration, flat fielding, chopping+nodding]
for effect in self.optics_manager.image_plane_effects:
for effect in tqdm(self.optics_manager.image_plane_effects,
desc=" Image Plane effects"):
for ii, image_plane in enumerate(self.image_planes):
self.image_planes[ii] = effect.apply_to(image_plane)

Expand Down

0 comments on commit a783dda

Please sign in to comment.