Commits

Matthew Turk committed 6938248

Adding spatial data examples and info

  • Participants
  • Parent commits 6dee662

Comments (0)

Files changed (3)

File scripts/averaged_temperature.py

+from yt.mods import *
+
+@derived_field(name = "AveragedTemperature",
+               validators = [ValidateSpatial(1)],
+               units = r"K")
+def _AveragedTemperature(field, data):
+    nx, ny, nz = data["Temperature"].shape
+    new_field = na.zeros((nx-2,ny-2,nz-2), dtype='float64')
+    weight_field = na.zeros((nx-2,ny-2,nz-2), dtype='float64')
+    i_i, j_i, k_i = na.mgrid[0:3,0:3,0:3]
+    for i,j,k in zip(i_i.ravel(),j_i.ravel(),k_i.ravel()):
+        sl = [slice(i,nx-(2-i)),slice(j,ny-(2-j)),slice(k,nz-(2-k))]
+        new_field += data["Temperature"][sl] * data["CellMass"][sl]
+        weight_field += data["CellMass"][sl]
+    # Now some fancy footwork
+    new_field2 = na.zeros((nx,ny,nz))
+    new_field2[1:-1,1:-1,1:-1] = new_field/weight_field
+    return new_field2
+
+pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+sp = pf.h.sphere("max", (100.0, 'kpc'))
+print sp["AveragedTemperature"].min(),
+print sp["AveragedTemperature"].max()

File scripts/field_parameters.py

 from yt.mods import *
 
 @derived_field(name = "delta_Velocity",
-               validators = [ValidateParameter("bulk_velocity")])
+               validators = [ValidateParameter("bulk_velocity")],
+               units = r"cm/s")
 def delta_Velocity(field, data):
     bv = data.get_field_parameter("bulk_velocity")
     delta_v = ((data["x-velocity"] - bv[0])**2.0
 sp = pf.h.sphere("max", (1.0, 'mpc'))
 sp.set_field_parameter("bulk_velocity", bv)
 
-print sp["delta_Velocity"].min()
+print sp["delta_Velocity"].min(),
 print sp["delta_Velocity"].max()

File yt_fields.tex

   ``#1''
   \end{center}
   \\
-  \hspace{1in}
+  \vspace{1in}
   \\
   #2
   \end{frame}
 \end{frame}
 
 \begin{frame}[fragile,t]{Defining a Field}
-\hspace{1.0in}
+\vspace{1.0in}
 \tiny
 <<d['scripts/derived_fields.py|fn|pyg|l']>>
 \end{frame}
 <<d['scripts/field_parameters.py|fn|py|pyg|l']>>
 \end{frame}
 
+\begin{frame}[fragile, t]{Example: Spatial Data}
+\tiny
+<<d['scripts/averaged_temperature.py|fn|pyg|l']>>
+\end{frame}
+
+\begin{frame}[fragile, t]{Example: Spatial Data}
+\tiny
+<<d['scripts/averaged_temperature.py|fn|py|pyg|l']>>
+\end{frame}
+
+\begin{frame}[t]{Generating Spatial Data}
+\vspace{1in}
+\begin{enumerate}
+\item Identify level at which region is fully contained
+\item Fill from those grids \label{enum:fill}
+\item Interpolate to next level; return to Step~\ref{enum:fill}
+\end{enumerate}
+\end{frame}
 
 \end{document}