Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for ScopeSimple #510

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scopesim/commands/scopesimple.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ def _get_vminmax(self, adjust_scale: bool):
return {"vmin": vmin, "vmax": vmax}

@staticmethod
def _get_figax(n_imgs: int):
fig, axs = figure_factory(nrows=int(n_imgs), ncols=int(n_imgs))
def _get_figax(n_imgs: int, fig_kwargs):
fig, axs = figure_factory(nrows=int(n_imgs), ncols=int(n_imgs),
**fig_kwargs)
if isinstance(axs, np.ndarray):
axs = list(axs.flatten())
else:
Expand All @@ -268,10 +269,11 @@ def plot(self, img_slice=None, adjust_scale=False, **kwargs):
" create an uneven image plot.")

vminmax = self._get_vminmax(adjust_scale)
fig_kwargs = kwargs.pop("fig_kwargs", {})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to suggest this anyway: I think it would be better to just add fig_kwargs as an optional parameter to the function instead of popping it from kwargs. As far as I'm aware, there is no good argument for doing it this way; or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did that first, but then there would be fig_kwargs followed by "normal" **kwargs (which go into the plot but not the figure), and also we'd need a default, but dict is mutable so need to use None, then need another line if fig_kwargs is None and so on. But maybe I should have done that rather than this intransparent implicit kwarg-popping. I'll probably change at some point...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

pltkwargs = {"origin": "lower", "norm": "log"} | vminmax | kwargs
img_slice = img_slice or slice(None)

fig, axs = self._get_figax(n_imgs)
fig, axs = self._get_figax(n_imgs, fig_kwargs)
for ax, img in zip(axs, imgs):
ax.imshow(img.data[img_slice], **pltkwargs)
ax.set_aspect("equal")
Expand Down
2 changes: 2 additions & 0 deletions scopesim/server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ def download_missing_pkgs(instrument: str) -> None:
def check_packages(instrument: str, download_missing: bool) -> None:
"""Check if required package is in CWD, download if needed."""
pkgdir = Path(rc.__config__["!SIM.file.local_packages_path"])
if not pkgdir.exists():
pkgdir.mkdir()
pkgdir = patch_fake_symlinks(pkgdir)
if not (pkgdir / instrument).exists():
logger.warning("IRDB package for %s not found.", instrument)
Expand Down