sot / xija

Thermal modeling framework for Chandra X-ray Observatory
https://sot.github.io/xija
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Add ability to use multiple No. of solar heat pitch bins within the same Xija model. #16

Closed matthewdahmer closed 11 years ago

matthewdahmer commented 11 years ago

Currently, all solar heat parameter sets need to have the same number of pitch bins within the same model. This results in the use of unnecessary parameters since the solar heating profile for some nodes will not require as high a fidelity as others.

taldcroft commented 11 years ago

This is probably difficult to do in the current framework, for technical reasons. There is a simple workaround that should work. In the xija/component/heat.py file add the following (after the class SolarHeat definition:

class SolarHeat5(SolarHeat):
    pass

This will be your solar heat model for 5 pitch bins. Do the same for 6, 7, etc. The point is that each number of pitch bins needs a separate class, but they can all derive from the same base SolarHeat.

taldcroft commented 11 years ago

@matthewdahmer - try that out in your local version and see if it works.

taldcroft commented 11 years ago

@matthewdahmer - I have an idea for a better way to do this by using __getattr__ and __setattr__ to handle parameter access. If it doesn't break something else this could work. I hope to have a chance to play with this later this week.

taldcroft commented 11 years ago

@matthewdahmer - This should do the trick, can you try it out? For some guidance see the new test code.

matthewdahmer commented 11 years ago

@taldcroft I was able to test this by editing the MinusYZ model so that three of the nodes with solarheat input used different numbers of pitch values; this ran just fine. I am however having trouble running the tests you set up in test_models.py. I keep getting errors related to relative imports or missing files. If you have some time next week, please stop by and perhaps you can show me how to run these tests.

taldcroft commented 11 years ago

@matthewdahmer - Sorry, I should have told you the test file can't be run directly. From the repo top directory use:

py.test xija/tests/
matthewdahmer commented 11 years ago

@taldcroft Thanks, this works! All tests passed!

taldcroft commented 11 years ago

Can you also try doing some fitting in gui_fit.py as a final test? Also save a model and read it back it in.

matthewdahmer commented 11 years ago

@taldcroft All set, I performed the following actions:

  1. Converted minusyz model json file to Python code
  2. Edited Python code to modify the number of pitch bins used by the solarheat path
  3. Converted the Python model code to json format
  4. Manually added initialization values for pseudo nodes in model json file
  5. Open model in gui_fit.py
  6. Fit model in gui_fit.py using default fitting method
  7. Save model in gui_fit.py
  8. Convert saved model from json format to Python model code
  9. Convert Python model code back to json format
  10. Manually add initialization values for pseudo nodes in model json file
  11. Open model in gui_fit.py
  12. Fit model in gui_fit.py

This should cover the process of creating, running, updating and rerunning models. All actions were completed smoothly with no errors.

taldcroft commented 11 years ago

@matthewdahmer - this is merged now, thanks for your help testing.