gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
30 stars 15 forks source link

How can I plot the equilibrium cross section with contours of normalized psi or normailzed rho? #120

Closed eldond closed 4 years ago

eldond commented 4 years ago

It used to be that the equilibrium_CX method in https://github.com/gafusion/omas/blob/master/omas/omas_plot.py could use 'phi' to determine 'rho' and also I think it provided normalized psi. Now gathering of contour_quantity usually goes through this get2d() function: https://github.com/gafusion/omas/blob/bf0b06b8fc4ca917747d62d1f1be65c312c46a1e/omas/omas_plot.py#L642 which relies on having 1d profiles present, but there's apparently no 1d profile of psi_norm, so this quantity seems unavailable. It's an easy calculation, I just don't know how to ask for it.

This change also defeats https://github.com/gafusion/OMFIT-source/blob/62cf92b7680050b9e06b6db30c71d9550e893265/omfit/classes/omfit_omas_utils.py#L143 , which tries to provide rho by writing phi, which worked under the old rules.

So I think I have to update multi_efit_to_omas() (should it include a version check and retain the old functionality for backwards compatibility?), and then equilibrium_CX() needs a special case to handle psi_N from psi in profiles_2d and psi_axis and psi_boundary in global_quantities.

orso82 commented 4 years ago

@eldond can you please share your ODS to illustrate the problem?

eldond commented 4 years ago

My point is that the source code relies on quantities being in profiles_1d or profiles_2d instead of calculating some of them, and I can't figure out how to write psi_norm or psi_n into the IDS. I tried things like ods['equilibrium']['time_slice'][0]['profiles_1d']['psi_norm'] = 2 and it told me LookupError: Not a valid IMAS 3.28.1 location: equilibrium.time_slice.0.profiles_1d.psi_norm.

But anyway, here are screenshots of two ODSs that are hard to deal with in efitviewer now:

This one is generated by OMFITgeqdsk.to_omas(): image image This one by multi_efit_to_omas(): image

Now that I know the magic password, I can plot rho_tor_norm. If there's a secret way to get psi_norm, that would be great. But my reading of the source code suggests that there isn't.

orso82 commented 4 years ago

@eldond you raise a good point that the IMAS data dictionary does not support psi_norm (don't get me started on that), but for the case of generating contours that should not matter. You should be able to use psi and visually get the same result, no?

eldond commented 4 years ago

@orso82 You're right that current capability is adequate for a simple visualization or overview, but it doesn't support detailed comparisons between shots. If I overlay two different shots, they'll have different psi values for the separatrix, so I can't compare the strike point legs. For psi_N, I can just put in 1.0 and see the legs for both (it's not always just the legs, either; I might need psi_N=1.02 to see flux expansion changes or something).

Just take psi from profiles_2d and psi_axis and psi_boundary from globals and do the calculation within the plot method. Or give OMAS a macro so it calculates psi_norm on the fly when you ask for it (instead of actually storing an array that can easily be calculated from other values). Just let me have psi_N contours somehow.