Skip to content

Simplify calls to data getters#555

Open
gtrevisan wants to merge 10 commits intodevfrom
glt/params-get
Open

Simplify calls to data getters#555
gtrevisan wants to merge 10 commits intodevfrom
glt/params-get

Conversation

@gtrevisan
Copy link
Copy Markdown
Member

@gtrevisan gtrevisan commented Apr 28, 2026

  • offer data getters from params itself,
  • remove params.data_conn shortcuts,
  • call data getters from params,
  • relint all files.

since we are now shortening data getter calls by 10 chars, many files got changed with nontrivial changes by black.
I made sure to push atomic commits for easier review!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to simplify data access by exposing common DataConnection getters directly on the params objects, then refactors existing code and examples to use the shorter params.get_* calls (with repo-wide reformatting/linting applied).

Changes:

  • Add get_data, get_data_with_dims, and get_dims delegators to PhysicsMethodParams.
  • Refactor multiple tokamak physics/EFIT modules and docs examples to call getters via params instead of params.data_conn.
  • Update time-setting implementations to use the new params.get_* style.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
docs/examples/custom_time_setting.py Updates custom time-setting example to use params.get_dims.
docs/examples/custom_physics_method.py Updates example physics method to use params.get_data.
disruption_py/settings/time_setting.py Refactors time-setting retrieval to use params.get_* getters.
disruption_py/machine/mast/physics.py Refactors MAST physics retrieval to use params.get_data.
disruption_py/machine/mast/efit.py Refactors MAST EFIT retrieval to use params.get_data.
disruption_py/machine/hbtep/physics.py Refactors HBT-EP physics retrieval to use params.get_data_with_dims/get_dims/get_data.
disruption_py/machine/east/physics.py Refactors EAST physics retrieval to use params.get_data_with_dims/get_dims/get_data.
disruption_py/machine/east/efit.py Refactors EAST EFIT retrieval to use params.get_data.
disruption_py/machine/d3d/util.py Refactors D3D utility getter use to params.get_data.
disruption_py/machine/d3d/physics.py Refactors D3D physics retrieval to use params.get_* and updates a tree-name lookup call.
disruption_py/machine/d3d/efit.py Refactors D3D EFIT retrieval to use params.get_data.
disruption_py/machine/cmod/thomson.py Refactors CMOD Thomson retrieval to use params.get_* for several signals.
disruption_py/machine/cmod/physics.py Refactors CMOD physics retrieval to use params.get_*.
disruption_py/machine/cmod/efit.py Refactors CMOD EFIT retrieval to use params.get_data/get_dims.
disruption_py/core/physics_method/params.py Adds delegating getter methods to PhysicsMethodParams.
Comments suppressed due to low confidence (1)

disruption_py/settings/time_setting.py:343

  • TimeSettingParams currently has no get_data_with_dims method; this will fail at runtime when computing the D3D disruption timebase. Use params.data_conn.get_data_with_dims(...) or add a delegating get_data_with_dims method to TimeSettingParams.
        raw_ip, ip_time = params.get_data_with_dims(f"ptdata('ip', {params.shot_id})")
        ip_time = ip_time / 1.0e3
        baseline = np.mean(raw_ip[:10])
        ip = raw_ip - baseline
        return self._calculate_disruption_times(params, ip, ip_time)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread disruption_py/settings/time_setting.py
Comment thread disruption_py/settings/time_setting.py
Comment thread disruption_py/machine/d3d/physics.py Outdated
Comment thread disruption_py/settings/time_setting.py
Comment thread disruption_py/settings/time_setting.py
Comment thread docs/examples/custom_time_setting.py
Comment thread disruption_py/core/physics_method/params.py Outdated
Comment thread disruption_py/core/physics_method/params.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread disruption_py/settings/time_setting.py
@yumouwei
Copy link
Copy Markdown
Contributor

Do you want to add a shortcut to params.data_conn.get as well? Right now there are 6 occurrences of it in the physics methods.

@gtrevisan
Copy link
Copy Markdown
Member Author

gtrevisan commented Apr 29, 2026

not right now, as that's a method of MDSplus connections only, but not xarray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants