Conversation
1107210 to
19f6fd6
Compare
|
@ZanderKeith, do you have some time to take a look? |
There was a problem hiding this comment.
Pull request overview
Reintroduces DIII-D physics support for n=1 B-radial parameters by reimplementing D3DPhysicsMethods.get_n1_bradial_parameters and factoring out a reusable toroidal-field helper.
Changes:
- Added
D3DPhysicsMethods.get_btorto retrieve/interpolate toroidal field (btor). - Reimplemented
get_n1_bradial_parametersto fetch ONFR/DUD bradial signals and compute normalized n=1 amplitude. - Updated
get_n1rms_parametersto useget_btorfor normalization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ZanderKeith
left a comment
There was a problem hiding this comment.
Methods look correct physics-wise. Ran them for a few shots from our recent DIII-D campaign with significant MHD activity. Signals line up well with those in reviewplus.
I'd still like to know what dusbradial vs onsbradial mean (and perhaps have a comment noting the difference), but other than that looks good to me.
|
I ran: it "only" raised |
|
I just checked the d3d So yeah it's a lot of shots. |
| n_equal_1_mode = tree.getNode("dusbradial").data().squeeze() # [G] | ||
| t_n1 = tree.getNode("dusbradial").dim_of().data() # [ms] | ||
| finally: | ||
| tree.close() |
There was a problem hiding this comment.
I'm not sure you want the tree closing operation in the finally block... I'd just put it as a last thing in the try block, otherwise you will raise exceptions if eg the tree does not exist.
There was a problem hiding this comment.
AFAICS we have custom recalc trees for 3,814 shots out of the total 16,232 in the specified range -- 12,418 are missing.
There was a problem hiding this comment.
This is consistent with the docstring in the MATLAB script
disruption-py/DIII-D/get_n1_bradial_d3d.m
Lines 27 to 37 in 5d1a80d
There was a problem hiding this comment.
For that finally block, I was worrying if e.g. the tree.getNode statement raises an error and terminates this method, then this opened tree will never be closed. I don't know if the garbage collector does this automatically.
| ) | ||
| filename = config("d3d").physics.bradial_path.recalc_nc | ||
| ds = xr.open_dataset(filename) | ||
| shot_data = ds.sel(shot=params.shot_id) |
There was a problem hiding this comment.
does that exist for all shots in the range, or should we check for existence and possibly catch KeyErrors and reraise them as our upcoming custom exceptions?
There was a problem hiding this comment.
AFAICS these 4 shots (between 176030 and 176912) are not included in the .nc file:
- 176108 176209 176226 176227
There was a problem hiding this comment.
We should raise an FetchDataError here to make it consistent with the behavior of xr.py.
Implemented changes
D3DPhysicsMethods.get_n1_bradial_parameters. This method was previously moved todrafts/machine/d3d/physics.pyin v0.8 (Add docstrings for modules/classes/methods #325) and later removed alongside all other draft scripts in v0.11 (Remove draft scripts #420).D3DPhysicsMethods.get_btorand use it inget_n1_bradial_parametersandget_n1rms.n_equal_1_mode,n_equal_1_normalized(tested & XFAIL), andbtor(not tested)Notes on testing
n_equal_1_modeandn_equal_1_normalizedare both marked asXFAILas all 4 testing shots fall within the range of shots where the raw signal data need to be retrieved from files previously stored oniris.DISRUPTION_WARNINGtable and the outputs from this physics method match the data in the table.DISRUPTION_WARNINGtable. I found out that these stored data match those from the legacy DUD system (fallback data source in the method's logic) instead of the ONFR system which is available for this shot.Future TODO