hyperion-rt / hyperion

Hyperion Radiative Transfer Code
http://www.hyperion-rt.org
BSD 2-Clause "Simplified" License
52 stars 26 forks source link

[Documentation] Updating yt usage in docs. #48

Closed ngoldbaum closed 11 years ago

ngoldbaum commented 11 years ago

Hi Tom,

I'm at the HIPACC summer school here at UCSC and Stella Offner just finished telling us about your code (first I've heard of it, I'm ashamed to say) and it's awesome integration with yt.

I looked over the docs and noticed that you're using the old, soon-to-be deprecated plotting routines. This change updates the example script to use the new ProjectionPlot routine, which is more full featured and somewhat easier to approach.

Unfortunately I couldn't update the images but I think that would be easier to do on your end. You'll also be able to spot if I made a mistake in the updated script.

Very much looking forward to trying Hyperion out in the near future. Recently Andrew Myers wrote a RadMC3D exporter and added it to yt so all supported codes can dump inputs for RadMC3D - hopefully we'll be able to do something similar for Hyperion.

astrofrog commented 11 years ago

@ngoldbaum - thanks for the update! I will test out this updated code to make sure it reproduces the same plots.

It would be fantastic if we could add an exporter to yt for Hyperion!

astrofrog commented 11 years ago

@ngoldbaum - I had to change pc to p2 but even with that I get the following error:


INFO: No density present in output, reading initial density [hyperion.model.model_output]
yt : [INFO     ] 2013-08-06 20:12:51,405 Parameters: current_time              = 0.0
yt : [INFO     ] 2013-08-06 20:12:51,405 Parameters: domain_dimensions         = [256 256 256]
yt : [INFO     ] 2013-08-06 20:12:51,406 Parameters: domain_left_edge          = [ -1.00400000e+18  -1.00400000e+18  -1.00400000e+18]
yt : [INFO     ] 2013-08-06 20:12:51,406 Parameters: domain_right_edge         = [  1.00400000e+18   1.00400000e+18   1.00400000e+18]
yt : [INFO     ] 2013-08-06 20:12:51,406 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2013-08-06 20:12:51,407 Parameters: current_time              = 0.0
yt : [INFO     ] 2013-08-06 20:12:51,407 Parameters: domain_dimensions         = [256 256 256]
yt : [INFO     ] 2013-08-06 20:12:51,407 Parameters: domain_left_edge          = [ -1.00400000e+18  -1.00400000e+18  -1.00400000e+18]
yt : [INFO     ] 2013-08-06 20:12:51,408 Parameters: domain_right_edge         = [  1.00400000e+18   1.00400000e+18   1.00400000e+18]
yt : [INFO     ] 2013-08-06 20:12:51,408 Parameters: cosmological_simulation   = 0.0
ERROR: KeyError: '1' [yt.data_objects.static_output]
astropy: [ERROR    ] 2013-08-06 20:12:51,792 KeyError: '1'
Traceback (most recent call last):
  File "extract_updated.py", line 11, in <module>
    center=[0.0, 0.0, 0.0])
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/visualization/plot_window.py", line 1040, in __init__
    (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/visualization/plot_window.py", line 149, in GetBoundsAndCenter
    width = (Wx/pf[unit], Wy/pf[unit])
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/data_objects/static_output.py", line 143, in __getitem__
    raise KeyError(key)
KeyError: '1'

In case you are interested in investigating, the input/output files are here:

http://mpia.de/~robitaille/share/test_model.tar

along with the test script. This is with a recent developer version. I tested and the previous example code I had still works, so it must be something to do with the new functionality. Do you have any ideas of what could be going wrong?

ngoldbaum commented 11 years ago

Thanks for the note about the typo, which should be fixed. Thanks also for the tarball, which I am downloading as I write this. I'll go ahead and try to figure out what's going wrong with the plotting routines and will update once I have a working script.

My guess is that you need to do something to supply units to yt. One of the nice new features of the new plotting routines is that one gets fine-grained control over the size of the 'window' into the data, using physically relevant units, however, this requires that units be set up properly.

ngoldbaum commented 11 years ago

Ok, things should be working now. Can you try once more on your end?

astrofrog commented 11 years ago

@ngoldbaum - thanks for the fix! Almost there - the code is now getting further, but I'm using a very recent version of Matplotlib and running into the following error:

Expected end of text (at char 0), (line:1, col:1)
Traceback (most recent call last):
  File "extract_updated.py", line 11, in <module>
    center=[0.0, 0.0, 0.0])
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/visualization/plot_window.py", line 1042, in __init__
    PWViewerMPL.__init__(self,proj,bounds,origin=origin)
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/visualization/plot_window.py", line 478, in __init__
    if setup: self._setup_plots()
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/yt-2.5dev-py2.7-macosx-10.7-x86_64.egg/yt/visualization/plot_window.py", line 761, in _setup_plots
    parser.parse(r'$'+md['units']+r'$')
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/mathtext.py", line 3011, in parse
    box = self._parser.parse(s, font_output, fontsize, dpi)
  File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/mathtext.py", line 2345, in parse
    str(err)]))
ValueError: 
$$
^
Expected end of text (at char 0), (line:1, col:1)

is this a yt bug?

ngoldbaum commented 11 years ago

Hmm, I think this is actually due to a regression in matplotlib's development branch since $$ is a valid (although boring) LaTeX sequence. I'm running matplotlib 1.3.0 on my laptop and can run the script with no issues - I guess there's been some refactoring of the mathtext code since the recent release. Can you try again with matplotlib 1.3.0 or 1.2.1?

astrofrog commented 11 years ago

@ngoldbaum - yes, I'll try and will report back.

astrofrog commented 11 years ago

Interestingly, it doesn't work with Matplotlib 1.2.1 either. I can try and look into it some more tomorrow (but if you have other ideas in the mean time, let me know!)

ngoldbaum commented 11 years ago

Just tried again with 1.2.1 and things are working (http://i.imgur.com/30r2bGJ.png and http://i.imgur.com/rV8ITRv.png). Taking a look at your traceback, I notice that you're running a yt 2.5dev egg and we're currently on 2.6dev. Can you try updating to the latest development version of yt or the 2.5.3 release?

astrofrog commented 11 years ago

Ok, trying now - I just tried installing 2.5.4 but this gives an error (https://bitbucket.org/yt_analysis/yt/issue/620/yt-254-does-not-install-missing) so I will try 2.5.3 or the dev version.

astrofrog commented 11 years ago

Ok, it works fine with yt 2.5.3 and Matplotlib 1.2.1, and also the latest yt dev and Matplotlib 1.2.1, and yt dev and matplotlib dev. So I think it was an intermittent issue in one of the dev versions.

astrofrog commented 11 years ago

The outputs look good, so I'll merge this - thanks @ngoldbaum!