[Yt-dev] Column Density derived field

Stephen Skory s at skory.us
Mon Oct 24 13:37:03 PDT 2011


Hi all,

I think I have the column density thingy working. I've got slices,
projections and volume renders working (http://vimeo.com/31035296). I
have a few questions.

- Where in yt should I put this? Keeping the file in my work directory
I use it like this, below. yt/utilities? Better ideas?

from ColumnDensity import *

cdnumdens = ColumnDensity(pf, 'NumberDensity', [0.5, 0.5, 0.5])

def _CDNumberDensity(field, data, cd = cdnumdens):
    return cd._build_derived_field(data)
add_field('CDNumberDensity', _CDNumberDensity)

- The function _build_derived_field, used directly above, is slightly
odd. What happens in it is I get the cell positions from data
(data['x'], etc..) and put those into the stuff that interpolates the
column density. I get a field based on these positions, and that's
what gets returned. However, and this shows what I don't understand,
for projections (as in not slices) one of the times this function gets
called as part of the add_field machinations data is a FieldDetector,
and calling data['x'] on them is not what I want. So I've added an
"if" that basically returns na.ones when data is a FieldDetector. What
would be a better option than that? The source as it stands is pasted
below.

http://paste.enzotools.org/show/1892/

Thanks for your thoughts!

-- 
Stephen Skory
s at skory.us
http://stephenskory.com/
510.621.3687 (google voice)



More information about the yt-dev mailing list