barnabytprowe / great3-public

Public repository for the Third Gravitational Lensing Accuracy Testing Challenge
BSD 3-Clause "New" or "Revised" License
9 stars 11 forks source link

Changing settings in constants.py #27

Closed pgee2000 closed 9 years ago

pgee2000 commented 9 years ago

I'm curious to know if there is any way to change these settings other than by modifying the file itself prior to importing great3sims. It appears that these values are already in use during module initialization. Does that mean that a script which runs great3sims.run() cannot change the constants.py values programmatically?

rmandelb commented 9 years ago

No, you can still change the values programmatically. For an example, see: https://github.com/barnabytprowe/great3-public/blob/master/tests/test_run.py

This test script was used for quick runs, so we have it change the values of some quantities in the constants module (see lines 88-92) before calling great3sims.run() a few times.

pgee2000 commented 9 years ago

I should have debugged this problem before I sent it to you. It is actually more simple and specific than I thought.

When I set n_subfields=1 and n_deep_subfields=0 in python code, (and deep_frac = 0.0, as required) so that I can do a run with just one subfield, it turns out that I must also set subfield_max=0 in the great3sims.run() call. I assumed that subfield_max would automatically be set to not run beyond the sum of n_subfields and n_deep_subfields. This is true when I change the value in constants.py, but not when I change the value in python prior to calling run.

In fact, subfields_max is still set to 220, so the code at line 197 of init.py run() which calls writeSubfieldCatalog fails, since it thinks there are more subfield_parameters yaml files than there really are.

Now that I understand the problem, I can set subfield_max=0 on the call to run, and that fixes the problem.

Thanks,

rmandelb commented 9 years ago

Oh I see.

Yes, the test_run.py script was designed to do very simple tests of the code and was not debugged for many possible combinations of changes of parameters (either within the script or by modifying items in constants.py). So it is easy to run into these problems if you modify it in some way that we never particularly considered as necessary for our tests.

pgee2000 commented 9 years ago

Yes, I can understand that you can't have done complete tests on this kind of thing. It was simple to solve, once I understood what was going on.