Skip to content

Conversation

@mgyoo86
Copy link
Contributor

@mgyoo86 mgyoo86 commented Mar 12, 2025

Minor bug fixes in

  • runtest.jl
  • parse_gfile_header
    • New default time in writeg with postfix, (e.g., "1ms") is parsed as Expr, which causes an error.
    • If time is Expr, convert it to String first, then the error is gone.

@bclyons12 could you please review the changes?
I cannot find the reviewers button for this PR..

Suggestion

If the GitHub CI action is added, it would be useful to automatically test runtest.jl.
The current Travis CI seems not to be triggered automatically.

@bclyons12 bclyons12 added the bug Something isn't working label Mar 12, 2025
@bclyons12
Copy link
Collaborator

@eldond Do you know why the "####ms" time style isn't being parsed properly? That's what all the sample gEQDSK files in OMFIT have, so I assume it's the default EFIT output format.

@mgyoo86
Copy link
Contributor Author

mgyoo86 commented Mar 13, 2025

Additional Fixes in imas2geqdsk

  1. Correct 2D Flux Map Reading
    The code now uses findfirst(:rectangular, eqt.profiles_2d) to correctly read the 2D flux map from dd.

  2. Interpolation of 1D Profiles on Rectangular Grids
    GEQDSK requires the number of 1D profiles to match nw (the number of horizontal R grid points). Since IMAS does not impose this restriction, 1D profiles are now interpolated when the grid is rectangular (i.e. when nw != nh) to satisfy the GEQDSK format.

  3. New Test Dataset and Test Added
    A new test dataset and corresponding tests have been added to validate these changes.

@bclyons12 @eldond Could you please review the changes? Thanks!

@mgyoo86
Copy link
Contributor Author

mgyoo86 commented Mar 13, 2025

Minor fix in writeg

  • Check the length of description before writing a file, which could prevent accidental overwriting of the file.

@orso82
Copy link
Member

orso82 commented Mar 20, 2025

@mgyoo86 @bclyons12 @lstagner should this be merged and a new version released?

There's also the question of where to add documentation like @mgyoo86 example on Discord:

import EFIT
import EFIT.IMASdd

filename = joinpath(dirname(dirname(pathof(EFIT))), "test", "test_dd_eq.json")
dd = IMASdd.json2imas(filename);

# Convert dd to GEQDSK struct (Note: GEQDSK is not a file)
ggs = EFIT.imas2geqdsk(dd)

# Write into file
for gg in ggs
    file_name = gg.file  # default file name has "g00000.xxxxx" format
    EFIT.writeg(gg, file_name)
end

# You can specify a file name
EFIT.writeg(ggs[1], "my_equilibrium.geqdsk")

# specify description, shot, and time as keyword arguments
# NOTE: time must be in `ms` unit (You can just put a number in `ms` without postfix `ms`) 
EFIT.writeg(ggs[1], "my_equilibrium.geqdsk"; desc="my description", shot="my shot 12345", time="1000ms")

# If the description is too long, it will cause an error.
EFIT.writeg(ggs[1], "my_equilibrium.geqdsk"; desc="This too long description will cause error.")

Copy link
Collaborator

@bclyons12 bclyons12 left a comment

Choose a reason for hiding this comment

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

Overall looks good, but I'd make the simplifying change I suggest and maybe add a test.

@bclyons12
Copy link
Collaborator

I have confirmed that the format produced by this PR can be opened in OMFIT, which for me, is the minimal requirement :-)

@mgyoo86
Copy link
Contributor Author

mgyoo86 commented Mar 21, 2025

@bclyons12
The followings are updated:

  • Reduction of duplication for the interpolation of 1D profiles
  • Added tests for the keywords in writeg

@orso82
Maybe, we can add some examples into README.md file?

@orso82
Copy link
Member

orso82 commented Mar 21, 2025

@mgyoo86 I'd be in favor of that, just the basic functionality. We can then add a link to the regression tests for people to see any extra/optional features.

@bclyons12
Copy link
Collaborator

@mgyoo86 Great work. And I agree. In the Readme, just add a section on reading and writing gEQDSK files, including from IMAS.

@mgyoo86
Copy link
Contributor Author

mgyoo86 commented Mar 21, 2025

@orso82 @bclyons12
I updated README.md by adding an example of writing GEQDSK files from dd.
It seems this PR is now ready to be merged.

@orso82 orso82 merged commit c0d3d81 into JuliaFusion:master Mar 21, 2025
@orso82
Copy link
Member

orso82 commented Mar 21, 2025

Fantastic! Thank you @mgyoo86
I'll release a new version of EFIT.jl

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants