Fix CUDB equilibrium time unit so g-file header time is correct#86
Open
kripnerl wants to merge 1 commit into
Open
Fix CUDB equilibrium time unit so g-file header time is correct#86kripnerl wants to merge 1 commit into
kripnerl wants to merge 1 commit into
Conversation
Equilibria loaded from CUDB (Fiesta) carry their time axis in seconds, but `Equilibrium.__init__` defaulted `time_unit` to "ms" whenever the dataset did not state it. `geqdsk.write` then encodes `int(time)` seconds as the header time, so e.g. a t = 0.65 s slice was written as 0 ms. - `get_ds_from_cudb` now records `time_unit = 's'` on the dataset, mirroring the existing `shot` handling. - `Equilibrium` normalises `time_unit` read from a dataset to a plain `str` (it was previously stored as a 0-d `DataArray`). - Add a regression test built on the `test00.nc` fixture (time in seconds). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Equilibria loaded from CUDB (Fiesta) via
pleque.io.compass.cudb/get_ds_from_cudbcarry theirtimeaxis in seconds. However,Equilibrium.__init__defaultstime_unitto"ms"whenever the input dataset does not explicitly state it.geqdsk.writethen encodes the header time asint(time)seconds interpreted as milliseconds:So writing a GEQDSK file for e.g. COMPASS-U shot 11600 at t = 0.65 s produced a header stamped
0msinstead of650ms.Fix
pleque/io/compass.py—get_ds_from_cudbnow recordstime_unit = 's'on the dataset, symmetric with the existingdst['shot'] = int(shot)handling. This makes CUDB-loaded equilibria self-describing.pleque/core/equilibrium.py—time_unitread from a dataset is now normalised to a plainstr(it was previously stored as a raw 0-dxarray.DataArray).tests/test_gfile.py— addedtest_time_unit_from_dataset_seconds, a regression test built on the existingtest00.ncfixture (whosetimeis in seconds), assertingtime_unit == 's'(astr) and that the GEQDSK header carries the correct millisecond value.Verification
pytest tests/test_gfile.py tests/test_equilibria.py tests/test_omas.py tests/test_cocos.py tests/test_io.py→ 107 passed, no regressions.🤖 Generated with Claude Code