gafusion / omas

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

improved profiles_fluxes plotting method #104

Closed TimSlendebroek closed 4 years ago

TimSlendebroek commented 4 years ago

Changes so that it makes:

image

codecov[bot] commented 4 years ago

Codecov Report

Merging #104 into master will increase coverage by 0.95%. The diff coverage is 86.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #104      +/-   ##
==========================================
+ Coverage   77.84%   78.79%   +0.95%     
==========================================
  Files          46       46              
  Lines        8308     8375      +67     
==========================================
+ Hits         6467     6599     +132     
+ Misses       1841     1776      -65     
Impacted Files Coverage Δ
omas/omas_core.py 84.95% <31.25%> (-0.45%) :arrow_down:
omas/omas_physics.py 71.58% <42.85%> (-0.15%) :arrow_down:
omas/omas_sample.py 99.41% <94.28%> (-0.59%) :arrow_down:
omas/omas_plot.py 74.30% <95.94%> (+5.48%) :arrow_up:
omas/omas_utils.py 81.03% <100.00%> (-0.42%) :arrow_down:
omas/tests/test_omas_plot.py 99.31% <100.00%> (+0.02%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f0f515b...d65e690. Read the comment docs.

TimSlendebroek commented 4 years ago

also can we add the {ods}.plot_profiles_fluxes() method to: image

@orso82 I tested and calling the .plot_profiles_fluxes() method on an ods works! (Also it would be nice for that plotting method to grey out when core_transport is not avail)

TimSlendebroek commented 4 years ago

The thing is that in this way you can add a core_sample in any time_index spot as is done with ods_core_profiles for example. I added the core_profiles and equliubrium in the second commit. I am not sure why it is failing @orso82

orso82 commented 4 years ago

@TimSlendebroek if you click on the Details on the right of the Travis CI and follow the white rabbit it will tell you why the regression tests are failing.

TimSlendebroek commented 4 years ago

I can see the error message now but it is odd since:

ods_test.sample_core_transport()
ods_test.sample_core_profiles()
ods_test.sample_equilibrium()

Should add all the samples I need (this is what I see when I call these methods in an omfit session)

orso82 commented 4 years ago

@TimSlendebroek these are the errors that need to get addressed:

======================================================================
ERROR: test_satisfy_imas_requirements (test_omas_core.TestOmasCore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_core.py", line 296, in test_satisfy_imas_requirements
    ods.satisfy_imas_requirements()
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 1478, in satisfy_imas_requirements
    out.append(self.getraw(ds).satisfy_imas_requirements(attempt_fix=attempt_fix, raise_errors=raise_errors))
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 1504, in satisfy_imas_requirements
    raise ValueError(self.location + '.time cannot be automatically filled! Missing time information in the data structure.')
ValueError: core_sources.time cannot be automatically filled! Missing time information in the data structure.
======================================================================
ERROR: test_core_pressure (test_omas_plot.TestOmasPlot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_plot.py", line 248, in test_core_pressure
    ods3.sample_core_profiles(add_junk_ion=True)
  File "/home/travis/build/gafusion/omas/omas/omas_sample.py", line 178, in core_profiles
    ions[len(ions) - 1][items] *= 0
NameError: name 'items' is not defined
======================================================================
ERROR: test_core_transport (test_omas_plot.TestOmasPlot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_plot.py", line 238, in test_core_transport
    ods_test.plot_core_transport_fluxes()
  File "/home/travis/build/gafusion/omas/omas/omas_plot.py", line 1106, in core_transport_fluxes
    if ods['core_transport.ids_properties.comment'] == "TGYRO":
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 931, in __getitem__
    return value.__getitem__(key[1:], cocos_and_coords)
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 931, in __getitem__
    return value.__getitem__(key[1:], cocos_and_coords)
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 921, in __getitem__
    dynamic=self.dynamic))
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 643, in __setitem__
    raise ValueError('`%s` has no data' % location)
ValueError: `core_transport.ids_properties.comment` has no data
======================================================================
ERROR: test_satisfy_imas_requirements (test_omas_core.TestOmasCore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_core.py", line 296, in test_satisfy_imas_requirements
    ods.satisfy_imas_requirements()
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 1478, in satisfy_imas_requirements
    out.append(self.getraw(ds).satisfy_imas_requirements(attempt_fix=attempt_fix, raise_errors=raise_errors))
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 1504, in satisfy_imas_requirements
    raise ValueError(self.location + '.time cannot be automatically filled! Missing time information in the data structure.')
ValueError: core_sources.time cannot be automatically filled! Missing time information in the data structure.
======================================================================
ERROR: test_core_pressure (test_omas_plot.TestOmasPlot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_plot.py", line 248, in test_core_pressure
    ods3.sample_core_profiles(add_junk_ion=True)
  File "/home/travis/build/gafusion/omas/omas/omas_sample.py", line 178, in core_profiles
    ions[len(ions) - 1][items] *= 0
NameError: name 'items' is not defined
======================================================================
ERROR: test_core_transport (test_omas_plot.TestOmasPlot)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_plot.py", line 238, in test_core_transport
    ods_test.plot_core_transport_fluxes()
  File "/home/travis/build/gafusion/omas/omas/omas_plot.py", line 1106, in core_transport_fluxes
    if ods['core_transport.ids_properties.comment'] == "TGYRO":
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 931, in __getitem__
    return value.__getitem__(key[1:], cocos_and_coords)
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 931, in __getitem__
    return value.__getitem__(key[1:], cocos_and_coords)
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 921, in __getitem__
    dynamic=self.dynamic))
  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 643, in __setitem__
    raise ValueError('`%s` has no data' % location)
ValueError: `core_transport.ids_properties.comment` has no data
----------------------------------------------------------------------
TimSlendebroek commented 4 years ago

hmm still some issues.

Still some issues with downsampling equilib.2d and sample_core_sources.

Also ['equilibrium']['time_slice'][0]['profiles_1d']['centroid'] appears in the OMFITtree but omas is telling me this doesn't exist in the IMAS datastructure (which is right checking the dataschema). Is there a place for these quantities:

image

in the IMAS data structure?

orso82 commented 4 years ago

That's correct. We should place a request for adding the flux surfaces centroid to IMAS. It's not there right now. This is not what is holding up the regression tests though.

TimSlendebroek commented 4 years ago

Well I fixed the comment issue so now:

Traceback (most recent call last):

  File "/home/travis/build/gafusion/omas/omas/tests/test_omas_core.py", line 133, in test_coordinates

    ods = ods_sample()

  File "/home/travis/build/gafusion/omas/omas/omas_sample.py", line 40, in ods_sample

    ods = eval(ds)(ods, time_index=k)

  File "/home/travis/build/gafusion/omas/omas/omas_sample.py", line 138, in equilibrium

    ods['equilibrium.time_slice'][time_index].update(eq['equilibrium.time_slice.0'])

  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 1252, in update

    self[item] = ods2[item]

  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 801, in __setitem__

    self.getraw(key[0])[key[1:]] = pass_on_value

  File "/home/travis/build/gafusion/omas/omas/omas_core.py", line 670, in __setitem__

    raise LookupError(underline_last(text, len('LookupError: ')) + '\n' + options)

LookupError: Not a valid IMAS 3.28.1 location: equilibrium.time_slice.0.profiles_1d.centroid

                                                                                    ^^^^^^^^
TimSlendebroek commented 4 years ago

I think it is ready now apart from the centroid problem.

TimSlendebroek commented 4 years ago

I guess we need to add a wall ODS structure to sample_equilib

orso82 commented 4 years ago

@TimSlendebroek please note that I have added a make samples which is what I want to use to generate the sample json files. Give me a second to fix what I have done there...

TimSlendebroek commented 4 years ago

:)

orso82 commented 4 years ago

yes, progress. Note: One thing that we need to do throughout OMFIT is to start using rotation_frequency_tor_sonic instead of omega0