sub-budget plotting
Add hooks to specify the specific Budget class to load from the budget module, and to plot specific BudgetItems from the calculated budget.
closes #82 (closed) #70 (closed)
Merge request reports
Activity
It looks like this is also addressing plotting sub-budgets from the command line (#82 (closed)). I don't think this fully addresses that though. One layer of sub-budgets works well, e.g.
python -m gwinc CE1 QuantumVacuum
makes the correct quantum sub-budget. I like how this works.
However, this doesn't seem to work for a second layer of sub-budgets. For example, suppose you put all the mirror thermal noise into one sub-budget with it further broken down into coating and substrate noise. The attached init.py file for CE2silicon is a complete example used to make the following plots, but the relevant changes are the following
class Coating(nb.Budget): """Coating Thermal """ name = 'Coating' style = dict( label='Coating Thermal', color='#fe0002', ) noises = [ CoatingBrownian, CoatingThermoOptic, ] class Substrate(nb.Budget): """Substrate Thermal """ name = 'Substrate' style = dict( label='Substrate Thermal', color='#fb7d07', ) noises = [ ITMThermoRefractive, SubstrateBrownian, SubstrateThermoElastic, ] class Thermal(nb.Budget): name = 'Thermal' style = dict( label='Thermal', color='xkcd:blood red', ) noises = [ Coating, Substrate ] class CE2silicon(nb.Budget): name = 'Cosmic Explorer 2 (Silicon)' noises = [ QuantumVacuum, Seismic, Newtonian, SuspensionThermal, Thermal, ExcessGas, ] calibrations = [ Strain, ] plot_style = PLOT_STYLE
The correct mirror thermal noise sub-budget produced with
traces = budget.run() traces.Thermal.plot()
is
and the correct substrate thermal sub-budget produced with
traces.Thermal.Substrate.plot()
is
So now there are two issues for the command line interface
- How do you plot the second layer of sub-budget (
Thermal.Substrate
andThermal.Coating
)? - There is a bug even with the first layer. Using the following from the command line
python -m gwinc CE2silicon Thermal
produces the incorrect budget
It looks like the strain calibration isn't being applied when run from the command line.
- How do you plot the second layer of sub-budget (
@kevin.kuns as for 1., just specify the name of the sub-sub budget object:
python -m gwinc CE2silicon Substrate
That works for me.
As for 2., there is an issue here. Calibrations from higher budgets aren't be applied. We need to do it in the command line more like you're doing it python.
Edited by Jameson Rollinsadded 4 commits
Toggle commit list@kevin.kuns I updated this to address your issues. Would you mind testing again to see if it now behaves as expected?
Yes, this addresses that issue and is applying the strain calibration as expected. However, it doesn't work for an extra layer of sub-budgets.
As an example, suppose you organized the noises as
- Quantum
- Seismic
- Newtonian
- Thermal
- Suspension Thermal
- Horizontal
- Top
- APM
- PUM
- TM
- Vertical
- Top
- APM
- PUM
- Horizontal
- Coating Thermal
- Brownian
- Thermo-optic
- Substrate Thermal
- ITM thermorefractive
- Brownian
- Thermo-elastic
- Suspension Thermal
- Residual gas
The attached init.py file for CE2silicon implements this.
Now with this budget all of the following work
budget = gwinc.load_budget('CE2silicon') traces = budget.run() traces.plot() traces.Thermal.plot() traces.Thermal.SuspensionThermal.plot() traces.Thermal.SuspensionThermal.HorizontalSuspensionThermal.plot()
and the following reproduce the same figures as the above python commands
python -m gwinc CE2silicon python -m gwinc CE2silicon Thermal python -m gwinc CE2silicon Thermal.SuspensionThermal
However, the following
python -m gwinc CE2silicon Thermal.SuspensionThermal.HorizontalSuspensionThermal
gives a KeyError:
Traceback (most recent call last): File "/home/kevin/Documents/Research/GWdetectionCode/pygwinc/gwinc/trace.py", line 68, in __getitem__ name, rest = name.split('.') ValueError: too many values to unpack (expected 2) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/kevin/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/home/kevin/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/kevin/Documents/Research/GWdetectionCode/pygwinc/gwinc/__main__.py", line 362, in <module> main() File "/home/kevin/Documents/Research/GWdetectionCode/pygwinc/gwinc/__main__.py", line 277, in main trace = trace[args.subbudget] File "/home/kevin/Documents/Research/GWdetectionCode/pygwinc/gwinc/trace.py", line 71, in __getitem__ return self._bdict[name] KeyError: 'Thermal.SuspensionThermal.HorizontalSuspensionThermal'
As a separate issue, would the following command line syntax make more sense?
python -m gwinc CE2silicon.Thermal
This isn't important if it's not easy to do though.
Edited by Kevin Kuns
added 1 commit
- fb0883cc - cli: allow specifying sub-budget or individual budget item to plot
@kevin.kuns I think I fixed the bug that was preventing processing of nested sub-budgets. Let me know if this works.
As for your last point, that command syntax won't work well with budgets specified by path instead of name.
added 6 commits
-
fb0883cc...d23fb2ad - 2 commits from branch
gwinc:master
- 1fec6185 - allow specifying budget class to load
- 89c435ad - cli: option to recursively list all elements of the budget
- 28381d12 - add ability to retrieve nested items from Budget and Trace objects
- 1c6a785a - cli: allow specifying sub-budget or individual budget item to plot
Toggle commit list-
fb0883cc...d23fb2ad - 2 commits from branch
mentioned in commit f488e64e