z_order below 200 is never used?

未关闭
#696 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
重构
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
backend

调研方向

The issue points to OpticsManager, Effect and its subclasses, including TERCurve, PSF, SurfaceList and PupilTransmission. First trace the get_z_order_effects() calls and how effects are applied to FovVolumeList; the issue leaves the preferred design unresolved. Done means explaining the z-order behavior and agreeing on a direction with the maintainers before changing the effect system.

由索引模型根据 Issue 内容生成。

描述

effects

I looked through the OpticsManager and noticed that a) there's no call to .get_z_order_effects() for z_orders below 100 and b) the call .get_z_order_effects(100) (which accesses z_orders between 100 and 199) is only used in .system_transmission and .surfaces_table, both properties are not used anywhere in the codebase (except unit tests). It would appear to me that any z_order below 200 is never actually used and thus completely redundant. This has a few interesting consequences:

This means for example that any TERCurve is only applied to FovVolumeList when it happens to be the current element of a wheel effect, which has a 2xx-range z_order. So e.g. SkycalcTERCurve is never applied to FovVolumeList.

For the PSFs, it mostly works, because the various PSF subclasses that are actually used override the z_order and set something in the 2xx-range. I generally don't understand how the z_orders are chosen for the PSFs. E.g., the simple SeeingPSF has z_order = (242, 642), its base class AnalyticalPSF has z_order = (41, 641) and its base class PSF has z_order = (40, 640). So using the final SeeingPSF will be applied as expected because it has a 2xx-range z_order. I understand the final digit change so that no two effects have the same z_order (which doesn't make any practical difference, because only the "hundreds digit" is considered anyway). But why does the PSF then not have 240 but 40, and the AnalyticalPSF 41 and not 241?

Any SurfaceList effect (of which there are a few) is only ever applied to the source, its 20 and 120 z_orders seem to have no effect whatsoever. The same is true for PupilTransmission and its 10 and 110 (inherited from TERCurve).

Now, I'm not sure if I'm missing anything here, or if there was a good reason to choose e.g. which TERCurve subclass will be applied to FovVolumeList and which won't. In any case, all this is IMNSHO a clear case for eventually ditching the z_order completely and dealing with this in another way. There was some discussion about this already some time ago I believe. I currently see two options:

  1. Use an in-between base class layer for Effect or alternatively mixin classes so that we can do something like isinstance(eff, FovSetupEffect). This might have the advantage that we could add methods like e.g. FovSetupEffect._apply_to_fov_volume_list() (which is then dispatched to by the normal .apply_to()) that has a raise NotImplementedError in the abstract base class, such that is we subclass an effect with the intention of applying it to e.g. the FOV setup phase, but forget to implement the relevant part of the .apply_to(), we'd notice immediately.
  2. Given that the various .apply_to(obj, ...) methods are written such that if obj is not the correct type (or one of several) to apply this effect to, the obj is returned as-is, i.e. a straight pass-through. This might be used to simply always apply all effect everywhere, and the ones that don't apply to the current type of obj are then simply ignored. This approach seems a bit messy on one hand, but on the other hand we could just keep a global (per OpticalTrain that is) list of effects and be done with it.

I used to have option 1 in the back of my mind for a while, thinking that I'd probably want to go there eventually. But now I'm not so sure anymore, because option 2 also seems appealing. Thoughts @hugobuddel ?

Also, I need to talk to @astronomyk once he's back from vacation about the original motivation behind the <200 z_orders and the case of applying some subclasses of the same base to the setup phase but not others...

主要语言
Python
星标
42
派生
30
平均合并
2 天 22 小时
30 天内合并 PR
7

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AstarVienna/ScopeSim 的其他 Issue

查看 AstarVienna/ScopeSim 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。