[yt-svn] commit/yt-doc: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Jul 6 16:04:46 PDT 2012
3 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/changeset/dd80a359d8b6/
changeset: dd80a359d8b6
user: MatthewTurk
date: 2012-07-07 01:04:08
summary: Some additions to the headers in the cookbook
affected #: 2 files
diff -r df8f33041942e47073a4bcbf1096e85587417655 -r dd80a359d8b64da7bb686f6580ec9e9f792588d1 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,7 +1,6 @@
syntax:glob
*.pyc
.*.swp
-source/cookbook/_*
build/*
source/reference/api/generated/*
**/.DS_Store
diff -r df8f33041942e47073a4bcbf1096e85587417655 -r dd80a359d8b64da7bb686f6580ec9e9f792588d1 source/cookbook/index.rst
--- a/source/cookbook/index.rst
+++ b/source/cookbook/index.rst
@@ -9,6 +9,11 @@
how to do some fairly common tasks -- which can lead to combining these, with
other Python code, into more complicated and advanced tasks.
+All of the data used here was used in the `2012 yt Workshop
+<http://yt-project.org/workshop2012/>`_ and can be found at the workshop home
+page. This includes FLASH and Enzo datasets, both of which are in evidence
+here.
+
.. note::
If you want to take a look at more complex recipes, or submit your own,
check out the `yt Hub <http://hub.yt-project.org>`.
@@ -21,44 +26,71 @@
Making Simple Plots
-------------------
+Simple Slices
+~~~~~~~~~~~~~
+
+This script shows the simplest way to make a slice from the scripting
+interface.
+
+.. literalinclude:: simple_slice.py
+
+
Simple Probability Distribution Functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Often, one wants to examine the distribution of one variable as a function of
+another. This shows how to see the distribution of mass in a simulation, with
+respect to the total mass in the simulation.
+
.. literalinclude:: simple_pdf.py
Simple Phase Plots
~~~~~~~~~~~~~~~~~~
+This demonstrates how to make a phase plot. Phase plots can be thought of as
+two-dimensional histograms, where the value is either the weighted-average or
+the total accumualtion in a cell.
+
.. literalinclude:: simple_phase.py
Simple 1D Histograms
~~~~~~~~~~~~~~~~~~~~
+This is a "profile," which is a 1D profile. This can be thought of as either
+the total accumulation (when weight is set to ``None``) or the average (when a
+weight is supplied.)
+
.. literalinclude:: simple_profile.py
Simple Projections
~~~~~~~~~~~~~~~~~~
+This is the simplest way to make a projection through a dataset.
+
.. literalinclude:: simple_projection.py
Simple Radial Profiles
~~~~~~~~~~~~~~~~~~~~~~
+This shows how to make a profile of a quantity with respect to the radius, in
+this case the radius in Mpc.
+
.. literalinclude:: simple_radial_profile.py
-Simple Slices
-~~~~~~~~~~~~~
-
-.. literalinclude:: simple_slice.py
-
Simple Volume Rendering
~~~~~~~~~~~~~~~~~~~~~~~
+Here we see how to make a very simple volume rendering, where each option is
+considered in turn.
+
.. literalinclude:: simple_volume_rendering.py
Off-Axis Slicing
~~~~~~~~~~~~~~~~
+A cutting plane allows you to slice at some angle that isn't aligned with the
+axes.
+
.. literalinclude:: aligned_cutting_plane.py
Calculating Dataset Information
https://bitbucket.org/yt_analysis/yt-doc/changeset/e4a35f7d9a68/
changeset: e4a35f7d9a68
user: MatthewTurk
date: 2012-07-07 01:04:26
summary: Merge
affected #: 1 file
diff -r dd80a359d8b64da7bb686f6580ec9e9f792588d1 -r e4a35f7d9a6826a3175dccfa3b6a060a79df44ad source/advanced/reason_architecture.rst
--- /dev/null
+++ b/source/advanced/reason_architecture.rst
@@ -0,0 +1,190 @@
+Reason Architecture
+===================
+
+Reason (see :ref:`reason`) has been ported as of 2.4 to work with the `ExtJS4
+<http://www.sencha.com/>`_ framework. The architecture has been completely
+reworked in the style of 'model-view-controller,' and the source tree has been
+laid out to reflect this.
+
+The javascript objects are laid out in a clear namespace, which corresponds to
+their layout on disk. For instance, ``Reason.controller.DataObjects``
+corresponds to ``app/Reason/controller/DataObjects.js``.
+
+ * ``app.js``: This is where the main application object is instantiated and
+ the Viewport created.
+ * ``app/Reason/view/*``: Objects corresponding to the display of Reason on the page.
+ These only contain markup; no logic code.
+ * ``app/Reason/view/widgets/*``: Objects corresponding to the display of widgets
+ in the Reason windows. These only contain markup; no logic code.
+ * ``app/Reason/controller/*``: Objects corresponding to controlling actions, data,
+ and interactions between components. These can contain logic code.
+ * ``app/Reason/controller/widgets/*``: Widget objects that can talk to yt, and the
+ mechanisms for controlling them. See :ref:`adding_widgets` for more
+ information.
+ * ``app/Reason/templates/*``: Template Management helper classes.
+ * ``app/Reason/store/*``: The definitions of data stores, where objects can be
+ inserted, filtered, queried and displayed.
+ * ``app/Reason/store/widgets/*``: Stores for widget data.
+ * ``app/Reason/model/*``: Any models that correspond to data store members
+ live here. Note that we usually use implicit models, except for data objects
+ that live in the tree.
+
+Each class exists in its own file, as per the ExtJS standard. Each class is
+defined inside an ``Ext.define`` block, extending the appropriate type of
+component. Wherever possible, lazy-evaluations are done and variables are not
+created by Reason's js code.
+
+Below we describe this in somewhat more detail.
+
+MVC Components
+--------------
+
+The ExtJS philosophy of separating models, views and controllers works quite
+well for what Reason is designed to do. While more detailed discussions of
+this can be found in the ExtJS4 docuemntation, for our purposes this separates
+into:
+
+ * Model: In our situation, the model is typically the same as a store. This
+ is the fundamental data object being passed around. For the purposes of using
+ and developing Reason, the main data objects are the cells, the parameter
+ files and attendent yt data objects, the payloads from the server (including
+ things like new images to display in the plot windows) and the widgets.
+ Each of these has a store, and each can be operated on and viewed in
+ different ways.
+ * Controller: The object that possesses a view, potentially a store, and
+ creates application logic to tie the display to the data. For instance, a
+ widget possesses a controller. This controller sets up handlers for events
+ that occur on a widget, and it also accepts payloads and updates the widget.
+ In this way, layout code is completely independent of application logic, and
+ both can be updated more easily and independently.
+ * View: The display mechanism for objects. In our terminology, this is simply
+ a javascript config object that tells ExtJS what a layout should look like
+ and what its components should be called.
+
+To keep the code maintainable, *all* logic should exist only within
+controllers. Controllers in ExtJS are powerful enough to get references to
+views automatically, create and update window state, and issue commands.
+
+For creating widgets, there is a special set of methods provided to do things
+like tie events together, execute commands in yt, and get references to
+objects. These are described below in :ref:`adding_widgets`.
+
+Adding a new Widget
+-------------------
+
+The procedure for adding a new widget is straightforward, but details of
+implementation may pose problems. In particular, JavaScript has scoping rules
+that sometimes trip up developers coming from Python, as the variable "this" is
+implicit rather than explicit (and can be modified by the calling function.)
+
+A skeleton widget is available in "SimpleWidget.js." This shows all of the
+places that your code may override existing code, and it provides a sample for
+how to create custom control code.
+
+Here are the steps:
+
+ #. Create a new widget file in ``app/controller/widgets/YourWidget.js``. For
+ what this widget needs to implement, see just below.
+ #. Create a new view for this widget in ``app/view/widgets/YourWidget.js``.
+ If necessary, also create a ``aap/view/widgets/YourWidgetCreator.js`` to
+ serve as a creation window, querying the user.
+ #. Add the widget to the ``requires`` section in the
+ ``app/controller/WidgetDirector.js`` file, similar to how the other widgets
+ are implemented.
+
+For the widget to function, a small amount of routines and variables either
+must be or can be set.
+
+ * ``templates`` (optional): This should be a mapping from the name of the
+ template to a string in the form of an Ext.XTemplate. This template will
+ have access to the variables ``widget``, which will be the view object, as
+ well as the handler's arguments in the form ``a0``, ``a1``, ``a2``, and so
+ on. To access these variables, place them inside single ``{`` and ``}``
+ brackets. To call javascript code (such as to get references to Ext
+ components, as in the PlotWindow wiget) put square brackets inside the curly
+ brackets. The PlotWindow widget is the most advanced example of the usage
+ of templates, and the Scene widget has a simpler yet complete example.
+ * ``widgetTriggers`` (optional): A array of arrays, composed of the itemId of
+ the object on which to place a handler, the handler to implement, and the
+ name of the function to call on that handler. For instance, you could bind a
+ button with the click event and have it call a function on the controller.
+ * ``executionTriggers`` (optional): This is similar to the ``widgetTriggers``
+ object, except that instead of the name of the function on the controller
+ to call, the name of the template to be evaluated and sent to the server
+ for execution in Python space is provided. This allows for very simple
+ binding of buttons, dropdowns and so on to the execution of Python code on
+ the server.
+ * ``viewRefs`` (optional): Because multiple controllers can be instantiated,
+ each with their own views, the standard mechanism for tracking views in
+ ExtJS doesn't quite work. This provides a workaround. It implements
+ identical logic to the ``views`` mechanism in ExtJS (see the ExtJS4 docs for
+ more info) but the view queried will only be the view affiliated with the
+ variable desired.
+ * ``createView``: This function must define a view, which should be returned
+ from the function. The view should also be assigned to the controller
+ object (i.e., ``this.plotWindowView = ...``). It can also create helper
+ widgets, as the PlotWindow does.
+ * ``applyPayload``: This must accept a ``payload`` object and apply its
+ contents to the widget.
+ * ``statics: widgetName``: This variable, defined under the ``statics``
+ namespace, is the (tokenizable and unique) shortname of the widget.
+ * ``statics: supportsDataObjects``: should this widget be applied to data
+ objects created from parameter files? (true or false)
+ * ``statics: supportsParameterFiles``: should this widget be applied to
+ parameter files? (true or false)
+ * ``statics: displayName``: What should this widget show up as in the context
+ menu?
+ * ``statics: preCreation``: This function, called with either a data object or
+ a parameter file object, will be called when the item is selected from the
+ context menu. It can spawn new views (potentially of creation widgets) and
+ if successful a widget payload should be expected from the server.
+
+For an example of a fully-fledged widget that accepts data from the server,
+applies callbacks and expects new data, see the ``PlotWindow.js`` controller
+file and its affiliated views. For a much simpler, static data-display
+widgets, see ``GridDataViewer.js`` and its affiliated class files. The
+``Scene.js`` controller file demonstrates most functionality.
+
+To create the widget on the Python side, you must create a member function in
+the ``widget_store.py`` file. This member function can accept whatever
+arguments you like, and must create a persistent object that can be controlled
+by Reason. For example, the ``create_slice`` function accepts a parameter file
+and some slice parameters, and then creates a widget payload describing the
+plot window that uses that slice. This plot window knows how to deliver
+payloads back to the clientside web browser, which are threaded through to the
+isntance of the PlotWindow controller's ``applyPayload`` mechanism. In this
+way, the Javascript code can call methods in Python, which can then supply
+results that are rich in data.
+
+How to Call yt Functions
+------------------------
+
+We currently use Ext.Direct to communicate with yt on the server, from the web
+browser. This allows us to have an RPC interface. All cell contents are
+supplied via payloads, with a heartbeat function that runs at regular (fast)
+intervals. To call a function on the server, use the
+``reason.server.execute`` function, supplying the ``code`` and (optionally)
+``hide`` values arguments. You can also supply a callback function; in this
+case, the input cell will not be disabled during the call to the server.
+
+.. code-block:: javascript
+
+ reason.server.execute(code, false);
+
+To call a function implemneted on the ExtDirectREPL, replace ``method`` and
+supply the first argument as a string of the method name. Widget creation
+should be done in this manner on the server-side.
+
+Debugging
+---------
+
+Debugging javascript can be much different from debugging Python code. If you
+are developing a new widget in reason, opening the console should be your first
+attempt whenever something goes wrong. In Chrome, this is done with
+Ctrl-Alt-j. In the main Reason menu there is also a debugging option, which
+will open up grid views of data objects that have been passed to the server.
+
+To access widgets, use the ``Reason.debug`` object's query functions.
+Additionally, the global variable ``examine`` exists in the main namespace, and
+this variable can be assigned values and inspected in the console. To log an
+entry to the javascript console, use ``console.log('your message here');``.
https://bitbucket.org/yt_analysis/yt-doc/changeset/233daac42c04/
changeset: 233daac42c04
user: MatthewTurk
date: 2012-07-07 01:04:39
summary: Merge
affected #: 0 files
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list