dsavransky / EXOSIMS

Simulator for exoplanet direct imaging space missions
BSD 3-Clause "New" or "Revised" License
25 stars 35 forks source link

Apparent caching bug noted regarding missionLife, keepout, and Zodi #371

Open dsavransky opened 4 months ago

dsavransky commented 4 months ago

Reported by @turmon:

I changed the missionLife of a working script from 10 to 1.1 for a test, and found a possible caching bug.

The interaction is that the zodi minimum is found in ZodiacalLight Prototype like so:

    for i in range(len(sInds)):
        tmpfZmin = min(fZmins[i, :])  # fZ_matrix has dimensions sInds

        if tmpfZmin == sys.float_info.max:
            valfZmin[i] = np.nan
            absTimefZmin[i] = -1
        else:
            valfZmin[i] = tmpfZmin
            indfZmin = np.argmin(fZmins[i, :])  # Gets indices where fZmin occurs
            absTimefZmin[i] = koTimes[indfZmin].value

But the koTimes is now "short" (1.1 years) because I changed missionLife. So, koTimes has length 402, while indfZmin happens to be 580. And then we look 580 up in koTimes, and it's not the right size.

Here's the traceback.

Note in the PDB session afterwards that koTimes.shape < indfZmin. And fZmins.shape is the original 10-years long (3653).

Traceback (most recent call last): File "/usr/local/anaconda3/envs/cornell-v2/lib/python3.10/pdb.py", line 1726, in main pdb._runscript(mainpyfile) File "/usr/local/anaconda3/envs/cornell-v2/lib/python3.10/pdb.py", line 1586, in _runscript self.run(statement) File "/usr/local/anaconda3/envs/cornell-v2/lib/python3.10/bdb.py", line 597, in run exec(cmd, globals, locals) File "", line 1, in File "/proj/exep/rhonda/Sandbox/HabEx/Local/ipcluster_ensemble_jpl_driver.py", line 425, in message = main(args, xspecs) File "/proj/exep/rhonda/Sandbox/HabEx/Local/ipcluster_ensemble_jpl_driver.py", line 336, in main res = sim.run_ensemble(int(args.numruns), run_one=run_one, kwargs=kwargs) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/MissionSim.py", line 369, in run_ensemble res = self.SurveyEnsemble.run_ensemble( File "/proj/exep/rhonda/Sandbox/HabEx/Local/EXOSIMS_local/IPClusterEnsembleJPL2.py", line 108, in run_ensemble return self.run_ensemble_stand(sim, nb_run_sim, run_one, genNewPlanets, rewindPlanets, kwargs) File "/proj/exep/rhonda/Sandbox/HabEx/Local/EXOSIMS_local/IPClusterEnsembleJPL2.py", line 126, in run_ensemble_stand ar = run_one(genNewPlanets=genNewPlanets, rewindPlanets=rewindPlanets, kwargs) File "/proj/exep/rhonda/Sandbox/HabEx/Local/ipcluster_ensemble_jpl_driver.py", line 209, in run_one SS.reset_sim(genNewPlanets=genNewPlanets, rewindPlanets=rewindPlanets) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/Prototypes/SurveySimulation.py", line 2385, in reset_sim self.init(specs) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/SurveySimulation/tieredScheduler_DD.py", line 19, in init tieredScheduler.init(self, specs) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/SurveySimulation/tieredScheduler.py", line 92, in init SurveySimulation.init(self, specs) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/Prototypes/SurveySimulation.py", line 457, in init self.valfZmin, self.absTimefZmin = self.ZodiacalLight.extractfZmin( File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/Prototypes/ZodiacalLight.py", line 495, in extractfZmin absTimefZmin[i] = koTimes[indfZmin].value File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/astropy/utils/shapes.py", line 225, in getitem return self._apply("getitem", item) File "/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/astropy/time/core.py", line 1273, in _apply jd1 = apply_method(jd1) IndexError: index 580 is out of bounds for axis 0 with size 402 Uncaught exception. Entering post mortem debugging Running 'cont' or 'step' will restart the program

/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/astropy/time/core.py(1273)_apply() -> jd1 = apply_method(jd1)

(Pdb) up

/proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/astropy/utils/shapes.py(225)getitem() -> return self._apply("getitem", item) (Pdb) up /proj/exep/rhonda/Sandbox/Python-venvs/exosims-3.2.0/lib/python3.10/site-packages/EXOSIMS/Prototypes/ZodiacalLight.py(495)extractfZmin() -> absTimefZmin[i] = koTimes[indfZmin].value (Pdb) indfZmin 580 (Pdb) koTimes.shape (402,) (Pdb) fZmins.shape (714, 3653) (Pdb)