Skip to content
Snippets Groups Projects

sub-budget plotting

Merged Jameson Rollins requested to merge jameson.rollins/pygwinc:load-sub-budget into master
2 unresolved threads

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)

Edited by Jameson Rollins

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 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

    thermal

    and the correct substrate thermal sub-budget produced with

    traces.Thermal.Substrate.plot()

    is

    substrate_thermal

    So now there are two issues for the command line interface

    1. How do you plot the second layer of sub-budget (Thermal.Substrate and Thermal.Coating)?
    2. 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

    thermal_cli

    It looks like the strain calibration isn't being applied when run from the command line.

  • @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 Rollins
  • Jameson Rollins added 4 commits

    added 4 commits

    • 619eb013 - allow specifying budget class to load
    • 940a4257 - cli: option to recursively list all elements of the budget
    • 35e87231 - add ability to retrieve nested items from Budget and Trace objects
    • 56fc9c2b - cli: allow specifying sub-budget or individual budget item to plot

    Compare with previous version

  • Jameson Rollins changed title from allow specifying budget class to load to sub-budget plotting

    changed title from allow specifying budget class to load to sub-budget plotting

  • Jameson Rollins changed the description

    changed the description

    • @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
        • Coating Thermal
          • Brownian
          • Thermo-optic
        • Substrate Thermal
          • ITM thermorefractive
          • Brownian
          • Thermo-elastic
      • 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
    • Please register or sign in to reply
  • Jameson Rollins added 2 commits

    added 2 commits

    • 26a05c2e - add ability to retrieve nested items from Budget and Trace objects
    • 265fb2cf - cli: allow specifying sub-budget or individual budget item to plot

    Compare with previous version

  • added 1 commit

    • fb0883cc - cli: allow specifying sub-budget or individual budget item to plot

    Compare with previous version

  • Kevin Kuns approved this merge request

    approved this merge request

  • Jameson Rollins added 6 commits

    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

    Compare with previous version

  • Kevin Kuns approved this merge request

    approved this merge request

  • Jameson Rollins mentioned in commit f488e64e

    mentioned in commit f488e64e

Please register or sign in to reply
Loading