text:
# Physics Definition, What Is Physics

### What is Physics?

It is simply the study of the world around us. For example: when a ball is thrown up in the air comes back to the ground the study of motion of this ball is physics, the study of elasticity of spring is physics, the study of twinkling of stars is physics. The word physics itself is of Greek origin, and it means nature. Among the Sciences, it is considered to be the oldest. This is because, according to current records, the beginning is marked with people observing the moon and therefore delving into astronomy. Of course at this point of time everything was just theories and assumptions till the Scientific Revolution began. We can say that it is simply the study of matter and energy around us, and how they interact and influence each other.

### Physics through the words of popular physicists:

There are many big names, Galileo Galilei, Isaac Newton, Albert Einstein, Richard Feynman and so many others when it comes to the world of science. Of course many people do not limit themselves to just one of the sciences because they are all interconnected. These scientist have contributed much to the world of science leading to many discoveries and their advancements through decades.

This is a quote by the famed quantum physicist, Richard Feynman

“Science is a way to teach how something gets to be known, what is not known, to what extent things are known (for nothing is known absolutely), how to handle doubt and uncertainty, what the rules of evidence are, how to think about things so that judgments can be made, how to distinguish truth from fraud, and from show.”

### Branches of Physics:

● Classical Mechanics
Thermodynamics
● Electromagnetism
● Relativity
● Integrative Fields

$~~~~~~~~~~~~~$


text:
# [OS X TeX] Goto Error (TS 4.23)

Ross Moore ross.moore at mq.edu.au
Mon Jan 28 23:46:56 CET 2019

Hello Louis, Justin, Themis,

On 29 Jan 2019, at 9:18 am, Louis Talman <talmanl at gmail.com<mailto:talmanl at gmail.com>> wrote:

On Mon, 28 Jan 2019 13:18:32 -0700, Justin C. Walker <justin at mac.com<mailto:justin at mac.com>>
wrote:

> the error occurs where the closing brace isn’t :-}, and that is hard to
> locate…

Is your error the missing closing brace?

That is actually not an error until TeX encounters something that is not supposed
to be enclosed within \textit{…. } which is an “inner” macro.
“Outer" material is stuff like an end of paragraph (\par  or  blank line).
This inner/outer distinction is part of TeX (the language).
It isn’t all that well explained in LaTeX documentation.

Put simply, macros like \textit, \textbf, \textsf, etc. are meant to have short arguments
consisting of just a few words. Although they can be nested, this is usually not a good idea.

If you want to apply font-style changes to whole paragraphs, or to several paragraphs
(within an environment, or perhaps not), it is better to use the declarative forms
\itshape,  \bfseries , \sffamily,  etc.
These apply up until the closing of the grouping within which they occur.
Since each adjust font-family characteristics, you can use multiples of these to get
the required representation; e.g. use a bold-italic sans-serif font, if this is available
with whatever packages you are using.

In your case however, it’s probably not until the end of the paragraph that an error will be reported.
Maybe not until several paragraphs, depending on how clean is your LaTeX coding.

Cannot you use syntax-colouring to find the mistake?
Locate \textit and arrow-right to the { .
Everything until *an* actual close should become coloured.
Presumably only a few words were intended, so you’ll have to decide which ones for yourself.

A bit more precisely: \textit{everywhere} is where the closing brace isn't.

--Louis A. Talman, Ph.D.
Emeritus Professor of Mathematics
Metropolitan State University of Denver

<http://sites.msudenver.edu/talmanl/homepage/<https://protect-au.mimecast.com/s/agALC5QP8ySgPp5GClmbT1?domain=sites.msudenver.edu>>

Hope this helps.

Ross

Dr Ross Moore
Department of Mathematics and Statistics
12 Wally’s Walk, Level 7, Room 734
Macquarie University, NSW 2109, Australia
T: +61 2 9850 8955  |  F: +61 2 9850 8114
M:+61 407 288 255  |  E: ross.moore at mq.edu.au<mailto:ross.moore at mq.edu.au>
http://www.maths.mq.edu.au
[cid:image001.png at 01D030BE.D37A46F0]
CRICOS Provider Number 00002J. Think before you print.
Please consider the environment before printing this email.

This message is intended for the addressee named and may
contain confidential information. If you are not the intended
recipient, please delete it and notify the sender. Views expressed
in this message are those of the individual sender, and are not
necessarily the views of Macquarie University. <http://mq.edu.au/>
<http://mq.edu.au/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/macostex-archives/attachments/20190128/83e8ec5b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4605 bytes
Desc: image001.png
URL: <https://tug.org/pipermail/macostex-archives/attachments/20190128/83e8ec5b/attachment-0001.png>
-------------- next part --------------
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

format: plain


text:
# Explaining the resolution rule.

It is nice to have inference rules explained informally. For example, the rule of Disjunctive Syllogism $((x \lor y) \land \neg y)\rightarrow x$ can be explained as follows: since $x \lor y$ is true, so either $x$ or $y$ is true. But $y$ is false and so $x$ must be true.

I was trying to give a similar informal explanation of why the resolution rule is true but I could not come up with one: $$((x \lor y) \land (\neg x \lor z))\rightarrow (y \lor z)$$ Is there any such convincing argument?

• Resolution rule is simply a "generalization" of modus ponens : "from $p \to q$ and $p$, derive $q$". In classical logic, you can rewrite $p \to q$ as $\lnot p \lor q$. – Mauro ALLEGRANZA Jun 14 '18 at 17:55
• Hint: Also, $((x\lor y)\land \neg x) \to y$ from the disjunctive syllogism. – Mr Pie Jun 15 '18 at 1:13

One possible explanation:

Since $\neg x\vee z$ is true, so either $\neg x$ or $z$ is true.

If $z$ is true, then $y\vee z$ is true and we are done.

If not, then $\neg x$ must be true i.e., $x$ is false. But $x\vee y$ is also true and therefore it must be that $y$ is true hence again giving the truthness of $y\vee z$.

This is vacuously true a lot, which is sort of unsatisfying. The contrapositive is tidier:

By contraposition, if both y and z are false, and since one of x, $\lnot$x is false, then the whole left hand side is false.

In classical logic, either $x$ is true or $x$ is false (tertium non datur).

In the first case, $\lnot x$ is false and hence from the hypothesis $\lnot x \lor z$ it follows that $z$ is true.

In the second case, $x$ is false and hence from the hypothesis $x \lor y$ it follows that $y$ is true.

Summing up, since one of the two cases ($x$ is true or $x$ is false) holds, then either $z$ is true or $y$ is true, i.e. $y \lor z$ is true.


text:
Drawing#

NetworkX provides basic functionality for visualizing graphs, but its main goal is to enable graph analysis rather than perform graph visualization. In the future, graph visualization functionality may be removed from NetworkX or only available as an add-on package.

Proper graph visualization is hard, and we highly recommend that people visualize their graphs with tools dedicated to that task. Notable examples of dedicated and fully-featured graph visualization tools are Cytoscape, Gephi, Graphviz and, for LaTeX typesetting, PGF/TikZ. To use these and other such tools, you should export your NetworkX graph into a format that can be read by those tools. For example, Cytoscape can read the GraphML format, and so, networkx.write_graphml(G, path) might be an appropriate choice.

Matplotlib#

Draw networks with matplotlib.

Examples#

>>> G = nx.complete_graph(5)
>>> nx.draw(G)

 draw(G[, pos, ax]) Draw the graph G with Matplotlib. draw_networkx(G[, pos, arrows, with_labels]) Draw the graph G using Matplotlib. draw_networkx_nodes(G, pos[, nodelist, ...]) Draw the nodes of the graph G. draw_networkx_edges(G, pos[, edgelist, ...]) Draw the edges of the graph G. draw_networkx_labels(G, pos[, labels, ...]) Draw node labels on the graph G. draw_networkx_edge_labels(G, pos[, ...]) Draw edge labels. draw_circular(G, **kwargs) Draw the graph G with a circular layout. draw_kamada_kawai(G, **kwargs) Draw the graph G with a Kamada-Kawai force-directed layout. draw_planar(G, **kwargs) Draw a planar networkx graph G with planar layout. draw_random(G, **kwargs) Draw the graph G with a random layout. draw_spectral(G, **kwargs) Draw the graph G with a spectral 2D layout. draw_spring(G, **kwargs) Draw the graph G with a spring layout. draw_shell(G[, nlist]) Draw networkx graph G with shell layout.

Graphviz AGraph (dot)#

Interface to pygraphviz AGraph class.

Examples#

>>> G = nx.complete_graph(5)
>>> A = nx.nx_agraph.to_agraph(G)
>>> H = nx.nx_agraph.from_agraph(A)

 from_agraph(A[, create_using]) Returns a NetworkX Graph or DiGraph from a PyGraphviz graph. Returns a pygraphviz graph from a NetworkX graph N. write_dot(G, path) Write NetworkX graph G to Graphviz dot format on path. read_dot(path) Returns a NetworkX graph from a dot file on path. graphviz_layout(G[, prog, root, args]) Create node positions for G using Graphviz. pygraphviz_layout(G[, prog, root, args]) Create node positions for G using Graphviz.

Graphviz with pydot#

Import and export NetworkX graphs in Graphviz dot format using pydot.

Either this module or nx_agraph can be used to interface with graphviz.

Examples#

>>> G = nx.complete_graph(5)
>>> PG = nx.nx_pydot.to_pydot(G)
>>> H = nx.nx_pydot.from_pydot(PG)

 Returns a NetworkX graph from a Pydot graph. Returns a pydot graph from a NetworkX graph N. write_dot(G, path) Write NetworkX graph G to Graphviz dot format on path. read_dot(path) Returns a NetworkX MultiGraph or MultiDiGraph from the dot file with the passed path. graphviz_layout(G[, prog, root]) Create node positions using Pydot and Graphviz. pydot_layout(G[, prog, root]) Create node positions using pydot and Graphviz.

Graph Layout#

Node positioning algorithms for graph drawing.

For random_layout() the possible resulting shape is a square of side [0, scale] (default: [0, 1]) Changing center shifts the layout by that amount.

For the other layout routines, the extent is [center - scale, center + scale] (default: [-1, 1]).

Warning: Most layout routines have only been tested in 2-dimensions.

 bipartite_layout(G, nodes[, align, scale, ...]) Position nodes in two straight lines. circular_layout(G[, scale, center, dim]) Position nodes on a circle. kamada_kawai_layout(G[, dist, pos, weight, ...]) Position nodes using Kamada-Kawai path-length cost-function. planar_layout(G[, scale, center, dim]) Position nodes without edge intersections. random_layout(G[, center, dim, seed]) Position nodes uniformly at random in the unit square. rescale_layout(pos[, scale]) Returns scaled position array to (-scale, scale) in all axes. rescale_layout_dict(pos[, scale]) Return a dictionary of scaled positions keyed by node shell_layout(G[, nlist, rotate, scale, ...]) Position nodes in concentric circles. spring_layout(G[, k, pos, fixed, ...]) Position nodes using Fruchterman-Reingold force-directed algorithm. spectral_layout(G[, weight, scale, center, dim]) Position nodes using the eigenvectors of the graph Laplacian. spiral_layout(G[, scale, center, dim, ...]) Position nodes in a spiral layout. multipartite_layout(G[, subset_key, align, ...]) Position nodes in layers of straight lines.

LaTeX Code#

Export NetworkX graphs in LaTeX format using the TikZ library within TeX/LaTeX. Usually, you will want the drawing to appear in a figure environment so you use to_latex(G, caption="A caption"). If you want the raw drawing commands without a figure environment use to_latex_raw(). And if you want to write to a file instead of just returning the latex code as a string, use write_latex(G, "filname.tex", caption="A caption").

To construct a figure with subfigures for each graph to be shown, provide to_latex or write_latex a list of graphs, a list of subcaptions, and a number of rows of subfigures inside the figure.

To be able to refer to the figures or subfigures in latex using \\ref, the keyword latex_label is available for figures and sub_labels for a list of labels, one for each subfigure.

We intend to eventually provide an interface to the TikZ Graph features which include e.g. layout algorithms.

Let us know via github what you’d like to see available, or better yet give us some code to do it, or even better make a github pull request to add the feature.

The TikZ approach#

Drawing options can be stored on the graph as node/edge attributes, or can be provided as dicts keyed by node/edge to a string of the options for that node/edge. Similarly a label can be shown for each node/edge by specifying the labels as graph node/edge attributes or by providing a dict keyed by node/edge to the text to be written for that node/edge.

Options for the tikzpicture environment (e.g. “[scale=2]”) can be provided via a keyword argument. Similarly default node and edge options can be provided through keywords arguments. The default node options are applied to the single TikZ “path” that draws all nodes (and no edges). The default edge options are applied to a TikZ “scope” which contains a path for each edge.

Examples#

>>> G = nx.path_graph(3)
>>> nx.write_latex(G, "just_my_figure.tex", as_document=True)
>>> nx.write_latex(G, "my_figure.tex", caption="A path graph", latex_label="fig1")
>>> latex_code = nx.to_latex(G)  # a string rather than a file

You can change many features of the nodes and edges.

>>> G = nx.path_graph(4, create_using=nx.DiGraph)
>>> pos = {n: (n, n) for n in G}  # nodes set on a line

>>> G.nodes[0]["style"] = "blue"
>>> G.nodes[2]["style"] = "line width=3,draw"
>>> G.nodes[3]["label"] = "Stop"
>>> G.edges[(0, 1)]["label"] = "1st Step"
>>> G.edges[(0, 1)]["label_opts"] = "near start"
>>> G.edges[(1, 2)]["style"] = "line width=3"
>>> G.edges[(1, 2)]["label"] = "2nd Step"
>>> G.edges[(2, 3)]["style"] = "green"
>>> G.edges[(2, 3)]["label"] = "3rd Step"
>>> G.edges[(2, 3)]["label_opts"] = "near end"

>>> nx.write_latex(G, "latex_graph.tex", pos=pos, as_document=True)

Then compile the LaTeX using something like pdflatex latex_graph.tex and view the pdf file created: latex_graph.pdf.

If you want subfigures each containing one graph, you can input a list of graphs.

>>> H1 = nx.path_graph(4)
>>> H2 = nx.complete_graph(4)
>>> H3 = nx.path_graph(8)
>>> H4 = nx.complete_graph(8)
>>> graphs = [H1, H2, H3, H4]
>>> caps = ["Path 4", "Complete graph 4", "Path 8", "Complete graph 8"]
>>> lbls = ["fig2a", "fig2b", "fig2c", "fig2d"]
>>> nx.write_latex(graphs, "subfigs.tex", n_rows=2, sub_captions=caps, sub_labels=lbls)
>>> latex_code = nx.to_latex(graphs, n_rows=2, sub_captions=caps, sub_labels=lbls)

>>> node_color = {0: "red", 1: "orange", 2: "blue", 3: "gray!90"}
>>> edge_width = {e: "line width=1.5" for e in H3.edges}
>>> pos = nx.circular_layout(H3)
>>> latex_code = nx.to_latex(H3, pos, node_options=node_color, edge_options=edge_width)
>>> print(latex_code)
\documentclass{report}
\usepackage{tikz}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw
(1.0, 0.0) node[red] (0){0}
(0.707, 0.707) node[orange] (1){1}
(-0.0, 1.0) node[blue] (2){2}
(-0.707, 0.707) node[gray!90] (3){3}
(-1.0, -0.0) node (4){4}
(-0.707, -0.707) node (5){5}
(0.0, -1.0) node (6){6}
(0.707, -0.707) node (7){7};
\begin{scope}[-]
\draw[line width=1.5] (0) to (1);
\draw[line width=1.5] (1) to (2);
\draw[line width=1.5] (2) to (3);
\draw[line width=1.5] (3) to (4);
\draw[line width=1.5] (4) to (5);
\draw[line width=1.5] (5) to (6);
\draw[line width=1.5] (6) to (7);
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

Notes#

If you want to change the preamble/postamble of the figure/document/subfigure environment, use the keyword arguments: figure_wrapper, document_wrapper, subfigure_wrapper. The default values are stored in private variables e.g. nx.nx_layout._DOCUMENT_WRAPPER

References#

TikZ: https://tikz.dev/

TikZ options details: https://tikz.dev/tikz-actions

 to_latex_raw(G[, pos, tikz_options, ...]) Return a string of the LaTeX/TikZ code to draw G to_latex(Gbunch[, pos, tikz_options, ...]) Return latex code to draw the graph(s) in Gbunch write_latex(Gbunch, path, **options) Write the latex code to draw the graph(s) onto path.


text:
# Cartesian Product

## Preliminaries

# import pandas as pd
import pandas as pd

## Create Data

# Create two lists
i = [1,2,3,4,5]
j = [1,2,3,4,5]

## Calculate Cartesian Product (Method 1)

# List every single x in i with every single y (i.e. Cartesian product)
[(x, y) for x in i for y in j]

[(1, 1),
(1, 2),
(1, 3),
(1, 4),
(1, 5),
(2, 1),
(2, 2),
(2, 3),
(2, 4),
(2, 5),
(3, 1),
(3, 2),
(3, 3),
(3, 4),
(3, 5),
(4, 1),
(4, 2),
(4, 3),
(4, 4),
(4, 5),
(5, 1),
(5, 2),
(5, 3),
(5, 4),
(5, 5)]

## Calculate Cartesian Product (Method 2)

# An alternative way to do the cartesian product

# import itertools
import itertools

# for two sets, find the the cartisan product
for i in itertools.product([1,2,3,4,5], [1,2,3,4,5]):
# and print it
print(i)

(1, 1)
(1, 2)
(1, 3)
(1, 4)
(1, 5)
(2, 1)
(2, 2)
(2, 3)
(2, 4)
(2, 5)
(3, 1)
(3, 2)
(3, 3)
(3, 4)
(3, 5)
(4, 1)
(4, 2)
(4, 3)
(4, 4)
(4, 5)
(5, 1)
(5, 2)
(5, 3)
(5, 4)
(5, 5)


text:
# Simultaneous similarity and triangularization of sets of 2 by 2 matrices - Mathematics > Rings and Algebras

Simultaneous similarity and triangularization of sets of 2 by 2 matrices - Mathematics > Rings and Algebras - Descarga este documento en PDF. Documentación en PDF para descargar gratis. Disponible también para leer online.

Abstract: Let $\mathcal{A}=A {1}, .,A {n}, .$ be a finite or infinite sequence of$2\times2$ matrices with entries in an integral domain. We show that, exceptfor a very special case, $\mathcal{A}$ is simultaneously triangularizable ifand only if all pairs $A {j},A {k}$ are triangularizable, for $1\leqj,k\leq\infty$. We also provide a simple numerical criterion fortriangularization.Using constructive methods in invariant theory, we define a map with theminimal number of invariants that distinguishes simultaneous similarityclasses for non-commutative sequences over a field of characteristic $eq2$.We also describe canonical forms for sequences of $2\times2$ matrices overalgebraically closed fields, and give a method for finding sequences with agiven set of invariants.

Autor: Carlos A. A. Florentino

Fuente: https://arxiv.org/

DESCARGAR PDF


text:
Hydrogen fuel cells combine hydrogen and oxygen to produce water and energy. Assume 1 kg of fuel is used, and the mass of the water produced is 1.10 x

Question:

Hydrogen fuel cells combine hydrogen and oxygen to produce water and energy. Assume 1 kg of fuel is used, and the mass of the water produced is 1.10 x 10-11 kg. How much energy is produced by this fuel cell? (Hint: Use E = mc2.)

What are the powers and functions of the Supreme Court? Explain at least 3 ofthem.

What are the powers and functions of the Supreme Court? Explain at least 3 ofthem....

Which one helps me

Which one helps me $Which one helps meeeeeeeeeee$...

The radius of a basketball is 4.7 inches what is the voloume of the basketball round to the nearest tenth

The radius of a basketball is 4.7 inches what is the voloume of the basketball round to the nearest tenth...

Sherwin-Williams' Dutch Boy paint has packaging that is getting rave reviews. The new Twist & Pour paint is packaged in an

Sherwin-Williams' Dutch Boy paint has packaging that is getting rave reviews. The new Twist & Pour paint is packaged in an all-plastic gallon container with an easy twist-off lid, comfortable side handle, and even a pouring spout. There's no other paint product like it on the market. This innova...


text:
# All Science Fair Projects

## Science Fair Project Encyclopedia for Schools!

 Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary

# Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

# Geodesic

In mathematics, a geodesic is a generalization of the notion of a "straight line" to curved spaces. It takes its name from the science of geodesy of measuring the size and shape of the earth, and was originally the shortest route between two points on the surface of the earth. For example the great circle path between points on the Earth, idealised as a sphere, is a geodesic. A small circle path is not. In intuitive terms, an elastic band stretched along a path that is not geodesic would contract its length for energy reasons to a nearby shorter path — this though only serves to explain that a geodesic is a local minimum for length.

 Contents

## Metric geometry

In metric geometry, a geodesic is a curve which is everywhere locally a distance minimizer. More precisely, if M is a metric space, a curve $\gamma:I\to M$ is a geodesic if there is a constant $v\ge 0$ such that for any $t\in I$ there is a neighborhood J of t in I such that for any $t_1,t_2\in J$ we have

d(γ(t1),γ(t2)) = v | t1 - t2 | .

This notion generalizes notion of geodesic for Riemannian manifolds. However, in metric geometry the geodesic considered almost always equipped with natural parametrization, i.e. in the above identity v=1 and

d(γ(t1),γ(t2)) = | t1 - t2 | .

If the last equality is satisfied on all I, the geodesic is called a minimizing geodesic or shortest path.

In general, a metric space may have no geodesics, except constant curves.

## Riemannian geometry and the geodesic equation

On a (pseudo-)Riemannian manifold M a geodesic can be defined as a smooth curve γ(t) that parallel transports its own tangent vector. That is,

$\frac{D}{dt}\dot\gamma(t) = \nabla_{\dot\gamma(t)}\dot\gamma(t) = 0$.

where ∇ stands for Levi-Civita connection on M.

In terms of local coordinates on M the geodesic equation can be written (using the summation convention):

$\frac{d^2x^a}{dt^2} + \Gamma^{a}_{bc}\frac{dx^b}{dt}\frac{dx^c}{dt} = 0$

where xa(t) are the coordinates of the curve γ(t) and $\Gamma^{a}_{bc}$ are the Christoffel symbols.

Equivalently, geodesics can be defined as extremal curves for the following energy functional

$E(\gamma)=\frac{1}{2}\int g(\dot\gamma(t),\dot\gamma(t))\,dt,$

where g is Riemannian (or pseudo-Riemannian) metric. This "energy functional" should be called action, but only few in mathematics use this term; the geodesic equation can then be obtained as the Euler-Lagrange equations of motion for this action. The geodesic that one obtains by extremizing the energy functional is identical to the geodesic obtained by extremizing the length functional; both are given by the geodesic equations.

### Examples

The most familiar examples are the straight lines in Euclidean geometry. On a sphere, the geodesics are the great circles. The shortest path from point A to point B on a sphere is given by the shorter piece of the great circle passing through A and B. Note that if A and B are antipodal points (like the North pole and the South pole), then there are many shortest paths between them.

### Existence and uniqueness

The local existence and uniqueness theorem for geodesics states that geodesics exist, and are unique; this is a variant of the Frobenius theorem. More precisely, for any point p in M and for any vector V in TpM (the tangent space to M at p) there exists a unique geodesic γ : IM such that γ(0) = p and $\dot\gamma(0) = V$. Here I is a maximal open interval in R containing 0. In general, I may not be all of R as for example for an open disc in R². The proof of this theorem follows from the theory of ordinary differential equations, by noticing that the geodesic equation is a second-order ODE. Existence and uniqueness then follows from the Picard-Lindelöf theorem for the solutions of ODE's with prescribed initial conditions. Note that γ depends smoothly on both p and V.

### Completeness

Given a point p in M and a vector V in TpM, the exponential map will map the vector tV to a geodesic in M, where t is a real number, scaling the vector V. The Hopf-Rinow theorem states, among other things, that any two points on a Riemannian manifold are joined by a geodesic.

## Geodesic flow

The geodesic equations are second order differential equations; they can be re-expressed as first-order ordinary differential equations taking the form of Hamiltonian equations by introducing additional independent variables, as shown below. Start by finding a chart that trivializes the cotangent bundle T * M (i.e. a local trivialization):

$T^*M|_{U}\simeq U \times \mathbb{R}^n$

where U is an open subset of the manifold M, and the tangent space is of rank n. Label the coordinates of the chart as (x1,x2,...,xn,p1,p2,...,pn). Then introduce the Hamiltonian as

$H(x,p)=\frac{1}{2}g^{ab}(x)p_a p_b.$

Here, gab(x) is the inverse of the metric tensor: $g^{ab}(x)g_{bc}(x)=\delta^a_c$. This inverse almost always exists for a broad class of metric manifolds. The behaviour of the metric tensor under coordinate transformations implies that H is invariant under a change of variable. The geodesic equations can then be written as

$\dot{x}^a = \frac{\partial H}{\partial p_a} = g^{ab}(x) p_b$

and

$\dot{p}_a = - \frac {\partial H}{\partial x^a} = -\frac{1}{2} \frac {\partial g^{bc}(x)}{\partial x^a} p_b p_c.$

The second order geodesic equations are easily obtained by substitution of one into the other. The flow determined by these equations is called the cogeodesic flow. The first of the two equations gives the flow on the tangent bundle TM, the geodesic flow. Thus, the geodesic lines are the integral curves of the geodesic flow onto the manifold M. Note that this is a Hamiltonian flow, and that the Hamiltonian is constant along the geodesics:

$\frac{dH}{dt} = \frac {\partial H}{\partial x^a} \dot{x}^a + \frac{\partial H}{\partial p_a} \dot{p}_a = - \dot{p}_a \dot{x}^a + \dot{x}^a \dot{p}_a = 0.$

Thus, the geodesic flow splits the cotangent bundle into level sets of constant energy

$M_E = \{ (x,p) \in T^*M : H(x,p)=E \}$

for each energy $E \ge 0$, so that

$T^*M=\bigcup_{E \ge 0} M_E$.

The Hopf-Rinow theorem gaurentees the completeness of the manifold. Note that the positivity of the energy follows from the positivity of the metric tensor; this analysis is modified on pseudo-Riemannian manifolds.

## Geodesics in general relativity

Geodesics are important in the theory of general relativity where they represent the paths of particles in free fall, that is, particles moving under the influence of no forces except gravity. For example, the orbit of a planet around a star follows a geodesic path.

Recall that spacetime in general relativity is a Lorentzian manifold with signature (− + + +). Geodesics on a Lorentzian manifold fall into three classes according to the sign of the norm of their tangent vector:

• timelike geodesics have a tangent vector whose norm is negative,
• null geodesics have a tangent vector whose norm is zero, and
• spacelike geodesics have a tangent vector whose norm is positive.

Note that a geodesic cannot be spacelike at one point and timelike at another since parallel transport preserves the norm of the vector (since the metric is parallel transported along any curve).

Massive particles and objects will always follow timelike geodesics, while massless particles like the photon will follow null geodesics. Spacelike geodesics exist, but do not correspond to the path of any physical particle.

## References

• Jurgen Jost, Riemannian Geometry and Geometric Analysis, (2002) Springer-Verlag, Berlin ISBN 3-540-4267-2 See section 1.4.
• Ronald Adler, Maurice Bazin, Menahem Schiffer, Introductin to General Relativity (Second Edition), (1975) McGraw-Hill New York, ISBN 0-07-000423-4 See chapter 2.
• Ralph Abraham and Jarrold E. Marsden, Foundations of Mechanics, (1978) Benjamin-Cummings, London ISBN 0-8053-0102-X See section 2.7.
• Steven Weinberg, Gravitation and Cosomology: Principles and Applications of the General Theory of Relativity, (1972) John Wiley & Sons, New York ISBN 0-471-92567-5 See chapter 3.
• Lev D. Landau and Evgenii M. Lifschitz, The Classical Theory of Fields, (1973) Pergammon Press, Oxford ISBN 0-08-018176-7 See section 87.
• Charles W. Misner, Kip S. Thorne, John Archibald Wheeler, Gravitation, (1970) W.H. Freeman, New York; ISBN 0-7167-0344-0.

03-10-2013 05:06:04


text:
# Composite numbers dividing binomial coefficients

Let $$k$$ be the number of composite integers $$n$$ that satisfy the condition that $$n$$ is a factor of $$\dbinom{n}{r}$$ for all $$r\in \{ 1, 2, 3, \ldots, n-1\}.$$ Which one of the following statements is always true for $$k$$? Prove that your answer is right.

Note: An integer number is called composite if it is greater than 1 and has at least a factor that is different from 1 and from itself.

×


text:
• ### Coupled dynamics of heavy and light flavor flow harmonics from EPOSHQ(1711.01485)

Nov. 4, 2017 hep-ph, nucl-th
We pursue the study of event by event correlations between low-mass particles and heavy mesons flow harmonics in ultrarelativistic heavy ion collisions and clarify some ambiguities found in one of our previous work.
• ### Measurements of $\pi^\pm$, K$^\pm$, p and $\bar{\textrm{p}}$ spectra in proton-proton interactions at 20, 31, 40, 80 and 158 GeV/c with the NA61/SHINE spectrometer at the CERN SPS(1705.02467)

Sept. 27, 2017 nucl-ex
Measurements of inclusive spectra and mean multiplicities of $\pi^\pm$, K$^\pm$, p and $\bar{\textrm{p}}$ produced in inelastic p+p interactions at incident projectile momenta of 20, 31, 40, 80 and 158 GeV/c ($\sqrt{s} =$ 6.3, 7.7, 8.8, 12.3 and 17.3 GeV, respectively) were performed at the CERN Super Proton Synchrotron using the large acceptance NA61/SHINE hadron spectrometer. Spectra are presented as function of rapidity and transverse momentum and are compared to predictions of current models. The measurements serve as the baseline in the NA61/SHINE study of the properties of the onset of deconfinement and search for the critical point of strongly interacting matter.
• ### Measurement of Meson Resonance Production in $\pi^{-} +$C Interactions at SPS energies(1705.08206)

May 23, 2017 nucl-ex, astro-ph.HE
We present measurements of $\rho^0$, $\omega$ and K$^{*0}$ spectra in $\pi^{-} +$C production interactions at 158 GeV/c and $\rho^0$ spectra at 350 GeV/c using the NA61/SHINE spectrometer at the CERN SPS. Spectra are presented as a function of the Feynman's variable $x_\text{F}$ in the range $0 < x_\text{F} < 1$ and $0 < x_\text{F} < 0.5$ for 158 GeV/c and 350 GeV/c respectively. Furthermore, we show comparisons with previous measurements and predictions of several hadronic interaction models. These measurements are essential for a better understanding of hadronic shower development and for improving the modeling of cosmic ray air showers.
• ### Two-particle correlations in azimuthal angle and pseudorapidity in inelastic p+p interactions at the CERN Super Proton Synchrotron(1610.00482)

Feb. 7, 2017 nucl-ex
Results on two-particle $\Delta\eta\Delta\phi$ correlations in inelastic p+p interactions at 20, 31, 40, 80, and 158~GeV/c are presented. The measurements were performed using the large acceptance NA61/SHINE hadron spectrometer at the CERN Super Proton Synchrotron. The data show structures which can be attributed mainly to effects of resonance decays, momentum conservation, and quantum statistics. The results are compared with the EPOS and UrQMD models.
• ### Parton-hadron dynamics in heavy-ion collisions(1312.7578)

Dec. 29, 2013 hep-ph, nucl-th
The dynamics of partons and hadrons in relativistic nucleus-nucleus collisions is analyzed within the novel Parton-Hadron-String Dynamics (PHSD) transport approach, which is based on a dynamical quasiparticle model for the partonic phase (DQPM) including a dynamical hadronization scheme. The PHSD approach is applied to nucleus-nucleus collisions from low SPS to LHC energies. The traces of partonic interactions are found in particular in the elliptic flow of hadrons and in their transverse mass spectra. We investigate also the equilibrium properties of strongly-interacting infinite parton-hadron matter characterized by transport coefficients such as shear and bulk viscosities and the electric conductivity in comparison to lattice QCD results.
• ### Emissivity and conductivity of parton-hadron matter(1308.6259)

Oct. 25, 2013 hep-ph, nucl-th
We investigate the properties of the QCD matter across the deconfinement phase transition. In the scope of the parton-hadron string dynamics (PHSD) transport approach, we study the strongly interacting matter in equilibrium as well as the out-of equilibrium dynamics of relativistic heavy-ion collisions. We present here in particular the results on the electromagnetic radiation, i.e. photon and dilepton production, in relativistic heavy-ion collisions and the relevant correlator in equilibrium, i.e. the electric conductivity. By comparing our calculations for the heavy-ion collisions to the available data, we determine the relative importance of the various production sources and address the possible origin of the observed strong elliptic flow $v_2$ of direct photons.
• ### Electrical Conductivity of Hot QCD Matter(1302.0906)

Oct. 24, 2013 hep-ph, nucl-th
We study the electric conductivity of hot QCD matter at various temperatures T within the off-shell parton-hadron-string dynamics transport approach for interacting partonic, hadronic or mixed systems in a finite box with periodic boundary conditions. The response of the strongly interacting system in equilibrium to an external electric field defines the electric conductivity sigma_0. We find a sizable temperature dependence of the ratio sigma_0/T well in line with calculations in a relaxation time approach for Tc<T<2.5Tc. The ratio drops in the hadronic phase with T, shows a minimum close to Tc, and becomes approximately constant (~0.3) above ~5Tc. Our findings imply that the QCD matter even at T=Tc is a much better electric conductor than Cu or Ag (at room temperature).
• ### Shear and bulk viscosities of strongly-interacting 'infinite' parton-hadron matter within the parton-hadron-string transport approach(1212.5393)

July 3, 2013 hep-ph, nucl-th
We study the shear and bulk viscosities of partonic and hadronic matter as functions of temperature T within the parton-hadron-string dynamics (PHSD) off-shell transport approach. Dynamical hadronic and partonic systems in equilibrium are studied by the PHSD simulations in a finite box with periodic boundary conditions. The ratio of the shear viscosity to entropy density \eta(T)/s(T) from PHSD shows a minimum (with a value of about 0.1) close to the critical temperature T_c, while it approaches the perturbative QCD limit at higher temperatures in line with lattice QCD (lQCD) results. For T<T_c, i.e., in the hadronic phase, the ratio \eta/s rises fast with decreasing temperature due to a strong decrease of the entropy density $s$ in the hadronic phase at decreasing T. Within statistics, we obtain practically the same results in the Kubo formalism and in the relaxation time approximation. The bulk viscosity \zeta(T)---evaluated in the relaxation time approach---is found to strongly depend on the effects of mean fields (or potentials) in the partonic phase. We find a significant rise of the ratio \zeta(T)/s(T) in the vicinity of the critical temperature T_c, when consistently including the scalar mean-field from PHSD, which is also in agreement with that from lQCD calculations. Furthermore, we present the results for the ratio (\eta+ 3\zeta/4)/s, which is found to depend nontrivially on temperature and to generally agree with the lQCD calculations as well. Within the PHSD calculations, the strong maximum of \zeta(T)/\eta(T) close to T_c has to be attributed to mean-field (or potential) effects that in PHSD are encoded in the temperature dependence of the quasiparticle masses, which is related to the infrared enhancement of the resummed (effective) coupling g(T).
• ### Parton-hadron matter in- and out-off equilibrium(1304.7154)

April 26, 2013 nucl-th
We study the shear and bulk viscosities of partonic and hadronic matter - as well as the electric conductivity - as functions of temperature $T$ within the Parton-Hadron-String Dynamics (PHSD) off-shell transport approach. Dynamical hadronic and partonic systems in equilibrium are studied by the PHSD simulations in a finite box with periodic boundary conditions. The ratio of the shear viscosity to entropy density $\eta(T)/s(T)$ from PHSD shows a minimum (with a value of about 0.1) close to the critical temperature $T_c$. For $T<T_c$, i.e. in the hadronic phase, the ratio $\eta/s$ rises fast with decreasing temperature due to a lower interaction rate of the hadronic system and a significantly smaller number of degrees-of-freedom. The bulk viscosity $\zeta(T)$ -- evaluated in the relaxation time approach -- is found to strongly depend on the effects of mean fields (or potentials) in the partonic phase. We find a significant rise of the ratio $\zeta(T)/s(T)$ in the vicinity of the critical temperature $T_c$, when consistently including the scalar mean-field from PHSD, which is also in agreement with that from lQCD calculations. Furthermore, we present the results for the ratio $(\eta+3\zeta/4)/s$, which is found to depend non-trivially on temperature and to generally agree with the lQCD calculations as well. Within the PHSD calculations, the strong maximum of $\zeta(T)/\eta(T)$ close to $T_c$ has to be attributed to mean-fields (or potential) effects that in PHSD are encoded in the temperature dependence of the quasiparticle masses, which is related to the infrared enhancement of the resummed (effective) coupling $g(T)$. We also find that the dimensionless ratio of the electric conductivity over temperature $\sigma_0/T$ rises above $T_c$ approximately linearly with $T$ up to $T=2.5 T_c$, but approaches a constant above $5 T_c$, as expected qualitatively from perturbative QCD (pQCD).
• ### Dynamical equilibration of strongly interacting "infinite" parton matter within the parton-hadron-string dynamics transport approach(1203.4734)

Jan. 28, 2013 nucl-th
We study the kinetic and chemical equilibration in "infinite" parton matter within the parton-hadron-string dynamics off-shell transport approach, which is based on a dynamical quasiparticle model (DQPM) for partons matched to reproduce lattice QCD results-including the partonic equation of state-in thermodynamic equilibrium. The "infinite" parton matter is simulated by a system of quarks and gluons within a cubic box with periodic boundary conditions, at different energy densities, initialized slightly out of kinetic and chemical equilibrium. We investigate the approach of the system to equilibrium and the time scales for the equilibration of different observables. We, furthermore, study particle distributions in the strongly interacting quark-gluon plasma (sQGP) including partonic spectral functions, momentum distributions, abundances of the different parton species and their fluctuations (scaled variance, skewness, and kurtosis) in equilibrium. We also compare the results of the microscopic calculations with the ansatz of the DQPM. It is found that the results of the transport calculations are in equilibrium well matched by the DQPM for quarks and antiquarks, while the gluon spectral function shows a slightly different shape due to the explicit interaction of partons. The time scales for the relaxation of fluctuation observables are found to be shorter than those for the average values. Furthermore, in the local subsystem, a strong change of the fluctuation observables with the size of the local volume is observed. These fluctuations no longer correspond to those of the full system and are reduced to Poissonian distributions when the volume of the local subsystem becomes much smaller than the total volume.
• ### Dilepton production from SIS to LHC energies(1207.3198)

July 13, 2012 hep-ph, nucl-th
We study e+e- pair production in proton-proton and in nucleus-nucleus collisions from SIS to LHC energies within the parton-hadron-string dynamics (PHSD) approach which incorporates explicit partonic degrees-of-freedom in terms of strongly interacting quasiparticles (quarks and gluons) in line with an equation-of-state from lattice QCD as well as the dynamical hadronization and hadronic collision dynamics in the final reaction phase. We find a visible in-medium effect in the low mass dilepton sector from dynamical vector-meson spectral functions from SIS to SPS energies whereas at RHIC and LHC energies such medium effects become more moderate. In the intermediate mass regime from 1.1 to 3 GeV pronounced traces of the partonic degrees of freedom are found at SPS and RHIC energies which superseed the hadronic (multi-meson) channels as well as the correlated and uncorrelated semi-leptonic D-meson decays. The dilepton production from the strongly interacting quark gluon plasma (sQGP) becomes already visible at top SPS energies and more pronounced at RHIC and LHC energies.
• ### Dilepton production in nucleus-nucleus collisions at top SPS energy within the Parton-Hadron-String Dynamics (PHSD) transport approach(1107.3402)

July 18, 2011 hep-ph, nucl-th
Dilepton production in In+In collisions at 158 AGeV is studied within the microscopic parton-hadron-string dynamics (PHSD) transport approach that incorporates explicit partonic degrees-of-freedom, dynamical hadronization as well as the more familiar hadronic dynamics in the final reaction stages. A comparison to the data of the NA60 Collaboration shows that the measured dilepton yield is well described by including the collisional broadening of vector mesons, while simultaneously accounting for the electromagnetic radiation of the strongly coupled quark-gluon plasma (sQGP) via off-shell quark-antiquark annihilation, quark annihilation with additional gluon Bremsstrahlung and the gluon-Compton scattering mechanisms. In particular, the spectra in the intermediate mass range (1 GeV < M < 2.5 GeV) are dominated by quark-antiquark annihilation in the nonperturbative QGP. Also, the observed softening of the transverse mass spectra at intermediate masses (1 GeV < M < 2.5 GeV) is approximately reproduced. Furthermore, for dileptons of low masses (M < 0.6 GeV), we find a sizable contribution from the quark annihilation with additional gluon bremsstrahlung, thus providing another possible window for probing the properties of the sQGP.
• ### Properties of the partonic phase at RHIC within PHSD(1106.1859)

June 9, 2011 hep-ph, nucl-th
The dynamics of partons, hadrons and strings in relativistic nucleus-nucleus collisions is analyzed within the novel Parton-Hadron-String Dynamics (PHSD) transport approach, which is based on a dynamical quasiparticle model for partons (DQPM) matched to reproduce recent lattice-QCD results -- including the partonic equation of state -- in thermodynamic equilibrium. The transition from partonic to hadronic degrees of freedom is described by covariant transition rates for the fusion of quark-antiquark pairs or three quarks (antiquarks), respectively, obeying flavor current-conservation, color neutrality as well as energy-momentum conservation. In order to explore the space-time regions of 'partonic matter' the PHSD approach is applied to nucleus-nucleus collisions from SPS to RHIC energies. Detailed comparisons are presented for hadronic rapidity spectra and transverse mass distributions. The traces of partonic interactions are found in particular in the elliptic flow of hadrons as well as in an approximate quark-number scaling at the top RHIC energy.


text:
## Overview

In this workshop you will apply the HEC-HMS Variable Clark unit hydrograph method to a modeling application. Initial parameter estimates will be estimated using GIS information. HEC-HMS version 4.9 was used to created this workshop. You will need to use HEC-HMS version 4.9, or newer, to open the project files.

## Background

According to Sherman, the unit hydrograph of a watershed is “…the basin outflow resulting from one unit of direct runoff generated uniformly over the drainage area at a uniform rainfall rate during a specified period of rainfall duration” (Sherman, 1932).  This implies that ordinates of any hydrograph resulting from a quantity of runoff-producing rainfall of unit duration would be equal to corresponding ordinates of a unit hydrograph for the same areal distribution of rainfall, multiplied by the ratio of rainfall excess values.  However, due to differences in areal distributions of rainfall and hydraulic reactions between large and small precipitation events, the corresponding unit hydrographs have not been found to be equal, as implied by unit hydrograph theory (Minshall, 1960; Meyersohn, 2016).  These realizations must also be combined with the fact that most precipitation events used when calibrating hydrologic models are normally much less intense than those used to design dams and other water resources infrastructure.

In an attempt to use conservative runoff parameters and counteract the inherent linearity of unit hydrograph theory, guidance has been followed within the U.S. Army Corps of Engineers (USACE) for approximately 50 years requiring the use of unit hydrograph peaking factors between 1.25 and 1.5 when simulating design storms (e.g. the Probable Maximum Precipitation, PMP) within dam safety studies (U.S. Army Corps of Engineers, 1991).  This action shifts the resultant peak unit response at the location of interest upwards and earlier in time while maintaining the same runoff volume.  These peaking factors are typically applied uniformly throughout time and space.  The concept of peaking the unit response at a particular location is visualized within the following figure.

However, the applicability of these rules of thumb is not thoroughly analyzed within most dam safety studies.  For instance, it is unknown whether a 25% peaking factor over or under-predicts the true unit hydrograph of a watershed in response to the PMP.  Similarly, it is unknown whether a 50% peaking factor over or under-predicts the true unit hydrograph.  Also, applying these peaking factors uniformly in time and space likely overpredicts the runoff response of a watershed during times of low excess precipitation rates (Bartles & Fleming, 2016).  As an alternative, excess precipitation vs. Tc and R relationships can be used to simulate these effects in both spatially and temporally appropriate ways (Bartles, 2014; Bartles & Fleming, 2016).  For example, only the subbasins of interest and most extreme periods of excess precipitation should be modified.  The Variable Clark unit hydrograph method allows the user to make use of these excess precipitation vs. Tc and R relationships.

## Review Clark Unit Hydrograph Parameter Estimation

Recall that separate regression equations were developed for time of concentration and watershed storage coefficient.  The regression equations and techniques presented within the W2 - Applying the Clark/ModClark Unit Hydrograph Method workshop were used to estimate Clark unit hydrograph parameters for the study area.

Subbasin

L (mi)

DA (sq mi)

S1085 (ft/ft)

LSqrtDAS

RR

Tc (hr)

R (hr)

MF_American_Rv_S3017.747.20.01937875.30.040443.22.9

## Review Clark Unit Hydrograph Calibration Results

Next, review the results of the Dec_1996_Jan_1997 simulation.  Recall that the Clark unit hydrograph parameters were applied and calibrated within

1. Open the Variable_Clark_Workshop project.
2. Open the Dec_1996_Jan_1997 Basin Model.
3. Select the MF_American_Rv_S30 subbasin element.
4. Select the Dec_1996_Jan_1997 simulation run from the Compute toolbar, .
5. Press the Compute All Elements button,  , to run the simulation.
6. Once the compute is complete, investigate the results for the MF_American_Rv_S30 subbasin element.
1. Navigate to the Results tab, expand the Simulation Runs node, click on the Dec_1996_Jan_1997 node, and select the MF_American_Rv_S30 node.
2. Select the Excess Precipitation time series and click the result graph button, to open the graph within a stand-alone frame, as shown in the following figure.

Question 1: What is the maximum excess precipitation rate (in inches/hour) that was realized within the Dec_1996_Jan_1997 simulation?

The maximum excess precipitation depth during this simulation was approximately 0.11 inches within 15 minutes.  Thus, the maximum excess precipitation rate in inches/hour can be calculated as: 0.11 in / 15 minutes * 60 minutes / 1 hour = 0.44 inches/hour.

Question 2: What are the calibrated Tc and R values for the Dec_1996_Jan_1997 simulation?

Tc = 3.2 hours and R = 2.9 hours.

## Simulate Hypothetical Event Using Clark Parameters

Next, apply the calibrated parameters achieved during the Dec_1996_Jan_1997 simulation to a hypothetical event.

1. Open the Clark Basin Model.
2. Select the Clark simulation run from the Compute toolbar.
3. Press the Compute All Elements button to run the simulation.
4. Once the compute is complete, view the result graph and summary table for the French_Meadows_In junction element, as shown in the following figure.  The computed results are shown in blue while the 2D Diffusion Wave results are shown in black.

Question 3. How do the Clark results compare against the 2D Diffusion Wave results?

The 2D Diffusion Wave results are much more piqued than the Clark results.  Most notably, the Clark peak discharge of 59100 cfs is approximately half as large as the 2D Diffusion Wave peak discharge of 106800 cfs.  Also, the Clark time of peak is occurs approximately 1.45 hours after the 2D Diffusion Wave time of peak.  The runoff volumes are essentially the same.

## Estimate Variable Clark Parameters

Regression equations that can be used to predict Variable Clark unit hydrograph parameters were developed for the state of California as part of Task 8 within the Memorandum of Agreement between HEC and DSOD.  These equations relate physically measurable watershed characteristics (e.g. longest flow path) to ratios of Tc and R.  Separate regression equations were developed for ratios of Tc and R to index parameters for all of the aforementioned excess precipitation rates.  The same predictive variables were chosen for each excess precipitation rate to ease the use of the regression equations and mitigate the potential for sharp inflection points in the output or increasing ratios of Tc and R as excess precipitation rates increase for reasonable parameter values.  A summary of the regression equations for each excess precipitation rate is presented within the following table.

Excess Precipitation Rate (in/hr)Equation

0.25

0.5

1.0

2.0

3.0

4.0

5.0

6.0

where $//$ = drainage area (sq mi); $//$ = average slope of the flowpath represented by 10 to 85 percent of the longest flow path (ft/ft); $//$ = centroidal longest flowpath length (mi); $//$ = basin relief (feet); and $//$ = relief ratio (dimensionless).

### Designate Index Parameters

Question 4. Report the Excess Precipitationindex, Tcindex and Rindex values realized during the Dec_1996_Jan_1997 simulation.

Recall that the maximum excess precipitation rate was 0.44 inches/hour, the calibrated Tc was 3.2 hours, and the calibrated R was 2.9 hours.  Thus, Excess Precipitationindex = 0.44 in/hr, Tcindex = 3.2 hr, and Rindex = 2.9 hr.

### Extract Basin Characteristics and Estimate Ratios of Tcindex and Rindex

1. Compute basin characteristics for the MF_American_Rv_S30 subbasin element by selecting Parameters | Characteristics Subbasin, as shown within the following figure.
2. HEC-HMS will populate characteristics for each subbasin element within the basin model, as shown within the following figure.

3. Next, use the regression equations presented above to estimate ratios of Tcindex and Rindex for excess precipitation rates of 0.25, 0.5, 1, 2, 3, 4, 5, and 6 in/hr, as shown below.

Predicted Tcindex Ratio for Excess Precip Rate (in/hr)
Excess Precipitation  Rate (in/hr)0.250.5123456
Ratio2.3331191.4549220.9885650.7085190.5829860.5327850.4926620.45718
Predicted Rindex Ratio for Excess Precip Rate (in/hr)
Excess Precipitation  Rate (in/hr)0.250.5123456
Ratio5.6244473.5935611.6592840.7411640.5124760.4263920.3539050.317881
4. Next, divide each of the aforementioned excess precipitation rates by the index excess precipitation rate of 0.44 in/hr and multiply by 100 to determine % Excess Precipitationindex.  Also, multiply the Tcindex and Rindex ratios by 100 to determine % Tcindex and % Rindex.  The resultant relationships are tabulated below.

% Excess Precipitationindex% Tcindex% Rindex
56.8233.3562.4
113.6145.5359.4
227.398.9165.9
454.570.974.1
681.858.351.2
909.153.342.6
1136.449.335.4
1363.645.731.8
5. Next, add two additional points representing (0, Tcindex, Rindex) and (100, Tcindex, Rindex), as shown below.

% Excess Precipitationindex% Tcindex% Rindex
0100100
56.8233.3562.4
100100100
113.6145.5359.4
227.398.9165.9
454.570.974.1
681.858.351.2
909.153.342.6
1136.449.335.4
1363.645.731.8
6. Finally, set ratios of Tcindex and Rindex greater than 100% to 100%.  This ensures that no values greater than Tcindex and Rindex are used, as shown below.

% Excess Precipitationindex% Tcindex% Rindex
0100100
56.8100100
100100100
113.6100100
227.398.9100
454.570.974.1
681.858.351.2
909.153.342.6
1136.449.335.4
1363.645.731.8
7. The predicted and final relationships are plotted below.
8. A close up of these relationships focusing on the values of interest are shown below.

## Simulate Hypothetical Event Using Variable Clark Parameters

Now that you have defined the variable Tc and R relationships, input them as new shared data components within HEC-HMS and use them within the Variable Clark unit hydrograph method.

1. Click Components | Paired Data Manager.
2. Change the Data Type to Percentage Curves and click New.
3. Name the new Percentage Curve MF_American_Rv_S30_Tc.
4. Repeat the previous steps to create another Percentage Curve called MF_American_Rv_S30_R.
5. Select the new Percentage Curves within the tree and enter the values for each, as shown in the following figure.  For simplicity, non-essential ordinates were removed.
6. Now, create a new Basin Model that can make use of these curves.  Right click on the Clark Basin Model and select Create Copy...
1. Name the new Basin Model Variable_Clark.
7. Select the Variable_Clark Basin Model withn the Project Explorer tree.
1. Select the MF_American_Rv_S30 subbasin element.
2. Select the Transform tab.
3. Change the Method to Variable Parameter, enter a Tc of 3.2 hr, an R of 2.9, an Index Excess of 0.44 in/hr, and select the two previously created Percentage Curves.  The Variable Clark Component Editor should resemble the following figure.
8. Select Compute | Create Compute | Simulation Run.
1. Name the new simulation Variable_Clark.
2. Select the Variable_Clark Basin Model, the Hypothetical Meteorologic Model, and the Hypothetical Control Specifications.
9. Select the Hypothetical Meteorologic Model within the Project Explorer tree.
1. Select the Basins tab.
2. Toggle the drop down menu for the Variable_Clark Basin Model to Yes, as shown in the following figure.
10. Select the Variable_Clark simulation run from the Compute toolbar.
11. Press the Compute All Elements button to run the simulation.
12. Once the compute is complete, view the result graph and summary table for the French_Meadows_In junction element, as shown in the following figure.  The computed results are shown in blue while the 2D Diffusion Wave results are shown in black.

Question 5. How do the Variable Clark results compare against the 2D Diffusion Wave results at the French_Meadows_In junction element?  How do the Variable Clark results compare against the Clark results?

The Variable Clark results more closely match the 2D Diffusion Wave results.  The Variable Clark peak discharge of 89250 cfs is approximately 17550 cfs less than the 2D Diffusion Wave peak discharge of 106800 cfs.  Also, the Variable Clark time of peak occurs at nearly the same time as the 2D Diffusion Wave time of peak.  A summary of the Clark, Variable Clark, and 2D Diffusion Wave results at the French_Meadows_In junction element are shown below.

StatisticClarkVariable Clark2D Diffusion Wave
Peak Discharge (cfs)5912589250106800
Time of Peak Discharge1/2/2000 15:151/2/2000 13:451/2/2000 13:30
Volume (in)28.0128.0127.54

A plot of these results are shown in the following figure.  The Clark results are shown in blue, the Variable Clark results are shown in red, and the the 2D Diffusion Wave results are shown in black.

Question 6. For the period ending 02Jan2000 12:15?, what was the excess precipitation rate (in inches/hr)?  What percentage of the Excess Precipitationindex does this represent?  For the same time period, what Tc and R were used?  What percentage of the Tcindex and Rindex does this represent?

Using the output from the Results tab | Simulation Runs | Variable_Clark | MF_American_Rv_S30 | Excess Precipitation time series, the excess precipitation for the 15-min time step ending at 02Jan2000 12:15 was 1.0 inches.  Thus, the excess precipitation rate in inches/hour can be calculated as: 1.0 in / 15 minutes * 60 minutes / 1 hour = 4.0 inches/hour.  This represents 909% of the index excess precipitation rate (i.e. 4 in/hr / 0.44 in/hr).

From the console output, the Tc and R for the period ending 02Jan2000 12:15 were 1.71 hr and 1.24 hr, respectively, as shown in the following image.  This represents 53.3% and 42.6% of Tcindex and Rindex, respectively.

The excess precipitation, Tc, and R values that were realized or used for each time step are shown in the figure below.


text:
# User:Anastasia A. Ierides/Notebook/Physics 307L/2009/10/12

Speed of Light Main project page
Previous entry      Next entry

## Speed Of Light

Partner: Alex Andrego

SJK 00:35, 16 November 2009 (EST)
00:35, 16 November 2009 (EST)
See my comments on the shared version of this primary notebook in Alex's notebook

### Equipment

• Bertan Associates Inc. Power Supply Model 313B (0-3000V, 0-10mADC)
• Harrison Laboratories Power Supply Model 6207A (0-160V, 0-0.2A)
• Canberra 2058 Delay Module
• Ortec 567 TAC/SCA Module
• Harshaw NQ-75 NIM Bin
• Photomultiplier Tube (PMT)
• Tektronix TDS 1002 Oscilloscope
• LED circuit
• BNC Cables

### Safety

Before we begin, some points of safety must be noted:

1. First and foremost your safety comes first and then the equipments'
2. Check the cords, cables, and machinery in use for any damage or possible electrocution points on fuses of machinery by making sure the power cords' protective grounding conductor must be connected to ground
3. Be careful when handling the photomultiplier tube (PMT) (it can be ruined in ambient light when at operating voltages)
4. Be careful when handling the Harrison Laboratories 6207A Power Supply when the capacitor plates are fully charged, even when unplugged wait for it to discharge for it may be a source of electrical shock
5. Make sure the areas containing and around the experiment are clear of obstacles

### Purpose

The purpose of this lab is to measure the speed of light, $\displaystyle c\,\!$ using short pulses of light and a high speed detector in a direct time of flight measurement over distances of one to two meters. Speed Of Light Introduction

### Brief Description of Light

Light, in physics, is described as electromagnetic radiation of any wavelength consisting of photons (tiny packets of energy with both a wavelike and particle-like property, called wave-particle duality). The speed of light $\displaystyle c\,\!$ in vacuum is currently accepted as $\displaystyle 299,792,458 m/s \,\!$ . The speed of light is constant in every reference frame between particles. The speed of light appears to slow down through particles; the reason for this is the displacement of energy through which subatomic particles, such as electrons, are excited. Light can be measured by its intensity, frequency (or wavelength), polarization, and/or phase. Wiki on Light

### Setup & Procedure

Note: Alex and I used the same set up and procedure. This is a direct copy of it. [1]

The procedure we followed was based on the descriptions given in Professor Gold's manual and outlined with more detail in Tom Mahony's Speed of Light Lab Note Book.

• We first connected all elements of our experiment with our BNC cables.
• The "-HQ" connection of the photomultiplier tube (PMT) to the Bertan Power Supply (PSU).
• The "A" connection of the photomultiplier tube (PMT) to the top input of the delay module.
• The output of the delay module to a BNC T-splitter
• One side connected to the channel 1 input on the oscilloscope
• The other to the "Stop" input of the Time-Amplitude Converter (TAC).
• The "Start" input of the TAC to the cable attached to the LED.
• The power cable for the LED to the Harrison PSU.
• The output of the TAC to the channel 2 input of the oscilloscope.
• We then had to varify that all of our equipment was on the correct setting
• For the Bertan power supply:
• Top polarity switch on negative
• 2000 volts
• For the the delay module
• Delay equal to 9 ns.
• The Ortec Time-Amplitude Converter (TAC)
• The range at 100 ns
• The multiplier to 1
• Start and stop switches to "anti"
• The output switch to "out."
• The Harrison PSU
• 190 volts
• We then turned our entire set up on and witnessed the delay between the LED circuit triggering and the PMT measuring the LED's pulse
• We measured this delay using the TAC
• We were then able to convert the measured voltage to be the response time.
• By measuring this voltage at different points, we were able to calculate the difference and divide by the distance to find the speed of the incident light.

### Data, Tables, & Analysis

key=teTWlTyOO5GM4bE0VXN0RAA width=700 height=1600

key=tNjNKH0scZphhBVdGH84a7w width=750 height=340

}}

### Calculations

The slope achieved by excel from our plot was:

$\displaystyle 0.006663636\frac{Volts}{centimeter}\,\!$

The uncertainty in our slope was calculated using codes in excel and was:

$\displaystyle 0.000110554\frac{Volts}{centimeter}\,\!$

The uncertainty is added and subtracted to the slope before it is inverted:

$\displaystyle (0.006663636\pm0.000110554)\frac{Volts}{centimeter}\,\!$

Then we invert it to get:

Minimum Range Inverse Slope:
$\displaystyle \frac{1}{0.006663636+0.000110554}\simeq147.6191135\frac{centimeters}{Volt}\,\!$
Maximum Range Inverse Slope:
$\displaystyle \frac{1}{0.006663636-0.000110554}\simeq152.5999475\frac{centimeters}{Volt}\,\!$
Average Inverse Slope:
$\displaystyle \frac{1}{0.006663636}\simeq150.0682128\frac{centimeters}{Volt}\,\!$

To attain a slope in "meters per second" we use the TAC conversion given for our settings which was $\displaystyle 5ns/Volt\,\!$

$\displaystyle c_{measured, average}=\frac{150.0682128\times10^{-2}meters}{Volt}\times\frac{1 Volt}{5\times10^{-9}s}\simeq3.0014\times10^8 m/s\,\!$
$\displaystyle c_{measured, minimum}=\frac{147.6191135\times10^{-2}meters}{Volt}\times\frac{1 Volt}{5\times10^{-9}s}\simeq2.9524\times10^8 m/s\,\!$
$\displaystyle c_{measured, maximum}=\frac{152.5999475\times10^{-2}meters}{Volt}\times\frac{1 Volt}{5\times10^{-9}s}\simeq3.0520\times10^8 m/s\,\!$

Here we've found our best guess as well as the maximum and minimum range of values for the measured speed of light.

The percentage error of our average measured value relative to the accepted value of the speed of light $\displaystyle c_{accepted}=299,792,458 m/s \,\!$ can be calculated as:

$\displaystyle \% error=\frac{c_{accepted}-c_{measured, average}}{c_{accepted}}\,\!$
$\displaystyle \% error=\frac{(299,792,458-3.0014\times10^8) m/s}{299,792,458 m/s}\,\!$
$\displaystyle \simeq0.001159\,\!$
$\displaystyle \simeq0.116%\,\!$

Systematic Error:

• The meter stick was placed in an odd way in which each distance measurement had originated from a value of $\displaystyle +0.8 mm$ more than a rounded measurement (i.e. instead of reading 60 cm off of the meter stick we had to read 60.8 cm)
• The PMT had to be manually adjusted so that the polarizers would align; this was to decrease the intensity of light approaching the PMT in order to have consistent data with the time walk effect (time walk effect is due to differing voltage peaks on oscilloscope, therefore different trigger levels)
Note:For a better explanation of the time walk effect please refer to Tom Mahony's Lab Notebook which explains this in greater detail.

Other Error:

• Due to the fact that zooming into the graphs of the oscilloscope was not possible, our data may vary due to the level of precision we were allowed for measuring the intensity of light coming through for each trial

### Speed Of Light Lab Summary

This is the link to my Balmer Series Lab Summary: Speed Of Light Lab Summary

### Acknowledgments

Please note that Alexandra S. Andrego was my lab partner for this lab. Her version of this lab can be found here

Prof. Gold's Lab Manual served as a loose guideline for our lab procedure and our calibration wave lengths
We used Google Docs to format and post our raw data and error analysis to our wiki notebook
We used Tom Mahony's Speed of Light Lab Note Book for more specific set up instructions, since his was so well done
This link Wiki on Light was used as the reference for the description of light


text:
# EM algorithm for mixture of Negative Binomial distributions

I am trying to derive the EM-algorithm of mixtures of negative binomial distribution $Neg\;Bin(r,p)$. I have the updating equations for updating the E-step as well as $p$ and the mixing coefficients $\phi_j$ s.

However, when I try to derive the M-step for $r$, I got stuck with an equation that involves the digamma function.

$$\frac{dQ}{dr} = \sum_{i=1}^m w^{(i)} \left( \psi(x^{(i)} + r) - \psi(r) + log(p) \right) = 0$$

Note that $Q$ is conditional expectation of log-likelihood and $w^{(i)}$ comes form the E-step, and hence can be treated as a constant. And $\psi$ is the digamma function. The superscript of $w$ and $x$ are just the index of data.

I read a paper here , which primarily deals with mixtures of gamma distribution. And it uses gradient ascent algorithm to estimate $\alpha$. If I follow the paper's approach to estimate $r$, then I will have the following gradient ascent algorithm:

$$r^{(t+1)} = r^{(t)} + \frac{a_t}{n} \frac{dQ}{dr}$$ I am not sure if this is the right way to go about this problem.

Does anyone what I can do solve for $r$ ?


text:
# Other methods for Laplacian equations

Assume $$A^{2}=(x^{2}+y^{2})\cos^{2}\psi+z^{2}\cot^{2}\psi$$ which $A$ is constant. How we can show $\psi(x,y,z)$ satisfies the Laplacian equation $\psi_{xx}+\psi_{yy}+\psi_{zz}=0$ ($\operatorname{div}\nabla\psi=0$) without calculating $\psi(x,y,z)$? I calculate $\psi(x,y,z)$ itself and differentiate, but I'm looking for easier methods, It's not important to use what, only the time that it takes is important.

-
Hmmm...WolframAlpha can't simplify the expression, but you could try implicit differentiation and Laplacian in the cylindrical coordinates. May I know the origin of this question? –  Shuhao Cao Jul 28 '13 at 3:17
@ShuhaoCao, about the origin of the question, I don't know. A physics student asked it from me and I had no idea so I put it here. –  AmirHosein SadeghiManesh Jul 28 '13 at 7:32


text:
National Institute of Standards and Technology (NIST) Traceability

Chapter 15 - Basic Principles of Instrument Calibration and Ranging

As defined previously, calibration means the comparison and adjustment (if necessary) of an instrument’s response to a stimulus of precisely known quantity, to ensure operational accuracy. In order to perform a calibration, one must be reasonably sure that the physical quantity used to stimulate the instrument is accurate in itself. For example, if I try calibrating a pressure gauge to read accurately at an applied pressure of 200 PSI, I must be reasonably sure that the pressure I am using to stimulate the gauge is actually 200 PSI. If it is not 200 PSI, then all I am doing is adjusting the pressure gauge to register 200 PSI when in fact it is sensing something different.

Ultimately, this is a philosophical question of : how do we know what is true? There are no easy answers here, but teams of scientists and engineers known as metrologists devote their professional lives to the study of calibration standards to ensure we have access to the best approximation of “truth” for our calibration purposes. Metrology is the science of measurement, and the central repository of expertise on this science within the United States of America is the National Institute of Standards and Technology, or the NIST (formerly known as the National Bureau of Standards, or NBS).

Experts at the NIST work to ensure we have means of tracing measurement accuracy back to intrinsic standards, which are quantities inherently fixed (as far as anyone knows). The vibrational frequency of an isolated cesium atom when stimulated by radio energy, for example, is an intrinsic standard used for the measurement of time (forming the basis of the so-called atomic clock). So far as anyone knows, this frequency is fixed in nature and cannot vary: each and every isolated cesium atom has the exact same resonant frequency. The distance traveled in a vacuum by 1650763.73 wavelengths of light emitted by an excited krypton-86 ($$^{86}$$Kr) atom is the intrinsic standard for one meter of length. Again, so far as anyone knows, this distance is fixed in nature and cannot vary. This means any suitably equipped laboratory in the world should be able to build their own intrinsic standards to reproduce the exact same quantities based on the same (universal) physical constants. The accuracy of an intrinsic standard is ultimately a function of nature rather than a characteristic of the device. Intrinsic standards therefore serve as absolute references which we may calibrate certain instruments against.

The machinery necessary to replicate intrinsic standards for practical use is quite expensive and usually delicate. This means the average metrologist (let alone the average industrial instrument technician) simply will never have access to one. While the concept of an intrinsic standard is tantalizing in its promise of ultimate accuracy and repeatability, it is simply beyond the reach of most laboratories to maintain. An example of an intrinsic standard is this Josephson Junction array in the primary metrology lab at the Fluke corporation’s headquarters in Everett, Washington:

A Josephson junction functions as an intrinsic standard for voltage, generating extremely precise DC voltages in response to a DC excitation current and a microwave radiation flux. Josephson junctions are superconducting devices, and as such must be operated in an extremely cold environment, hence the dewar vessel filled with liquid helium in the right-hand side of the photograph. The microwave radiation flux itself must be of a precisely known frequency, as the Josephson voltage varies in direct proportion to this frequency. Thus, the microwave frequency source is synchronized with the NIST’s atomic clock (another intrinsic standard).

While theoretically capable of generating voltages with uncertainties in the low parts per billion range, a Josephson Array such as this one maintained by Fluke is quite an expensive beast, being too impractical for most working labs and shops to justify owning. In order for these intrinsic standards to be useful within the industrial world, we use them to calibrate other instruments, which are then used to calibrate other instruments, and so on until we arrive at the instrument we intend to calibrate for field service in a process. So long as this “chain” of instruments is calibrated against each other regularly enough to ensure good accuracy at the end-point, we may calibrate our field instruments with confidence. The documented confidence is known as NIST traceability: that the accuracy of the field instrument we calibrate is ultimately ensured by a trail of documentation leading to intrinsic standards maintained by the NIST. This “paper trail” proves to anyone interested that the accuracy of our calibrated field instruments is of the highest pedigree.

• Share
Published under the terms and conditions of the Creative Commons Attribution 4.0 International Public License


text:
# Stop Thinking, Just Do!

Sung-Soo Kim's Blog

# Working with RDD Operations

## Resilient Distributed Datasets (RDD)

The primary abstraction of Spark is RDD. Remember, there are two types of RDD operations: transformations and actions. Transformations return a pointer to the new RDD. Actions return the value of the operation. RDD transformations are lazy evaluations. This means nothing is processed until an action occurs. Each transformation updates the direct acyclic graph (DAG), which is only executed after an action is called. Due to this inherent behavior, Spark’s applications are fault tolerant. The DAG can be used to rebuild the data within a node.

In this lab exercise, you will work with various RDD operations and learn some of the APIs from Scala and Python.

After completing this hands-on lab, you should be able to:

• Create a RDD froman external dataset

• View the Direct Acyclic Graph(DAG) of an RDD

• Work with various RDD operations including shared variables and key-value pairs

Allow 60 minutes to complete this section of lab.

Step 1. Open up a docker terminal. If you closed the terminal from the previous exercise, run the commands to start up the same bdu_spark container:

docker start bdu_spark

docker attach bdu_spark

Note: If the docker terminal doesn’t return back with a prompt, just hit the Enter key and the prompt should appear.

Step 2. You’ll need to start up the Hadoop service if you started a new terminal.

/etc/bootstrap.sh

Note: The Hadoop name node may be in safe mode. Exit the safe mode by entering in:

hdfs dfsadmin -safemode leave

Step 3. Copy a log file to the HDFS. You can copy the log file from the /opt/ibm/labfiles/ into the HDFS or you can upload any log file that you like for this exercise. Type in this command to load and rename the log file name to something shorter such as sparkLog.out

hdfs dfs –put /opt/ibm/labfiles/<log filename> input/tmp/sparkLog.out

Step 4. You should have the README.md file already in your image if you continued with the bdu-spark container. If not, use this command to copy it in.

hdfs dfs -put /opt/ibm/labfiles/README.md input/tmp

Setp 5. Copy the CHANGES.txt file located from the /opt/ibm/labfiles directory to the HDFS as well, under “input/tmp”

hdfs dfs -put /opt/ibm/labfiles/CHANGES.txt input/tmp

Step 6. Verify that the files were copied over by doing a listing of the HDFS

hdfs dfs -ls input/tmp/

## 1.2 RDD operations using Scala

### 1.2.1 Analyzing a log file

Step 1. Start the Scala Spark shell:

\$SPARK_HOME/bin/spark-shell

val logFile = sc.textFile("input/tmp/sparkLog.out")

Step 3. Filter out the lines that contains INFO (or ERROR, if the particular log has it)

val info = logFile.filter(line => line.contains("INFO"))

Step 4. Count the lines:

info.count()

Step 5. Count the lines with Spark in it by combining transformation and action.

info.filter(line => line.contains("spark")).count()

Step 6. Fetch those lines as an array of Strings

info.filter(line => line.contains("spark")).collect()

Step 7. Remember that we went over the DAG. It is what provides the fault tolerance in Spark. Nodes can re-compute its state by borrowing the DAG from a neighboring node. You can view the graph of an RDD using the toDebugString command.

info.toDebugString

￼￼￼Note: Occasionally, it may seem like the shell has not returned back the prompt. In that case, just hit the Enter key and the prompt will show back up. ￼

### 1.2.2 Joining RDDs

Step 8. Next, you are going to create RDDs for the README and the CHANGES file.

val readmeFile = sc.textFile("input/tmp/README.md")

val changesFile = sc.textFile("input/tmp/CHANGES.txt")

Step 9. How many Spark keywords are in each file?

readmeFile.filter(line => line.contains("Spark")).count()

changesFile.filter(line => line.contains("Spark")).count()

Step 10. Now do a WordCount on each RDD so that the results are (K,V) pairs of (word,count)

val readmeCount = readmeFile.flatMap(line => line.split(" ")).map(word => (word, 1)).reduceByKey(_ + _)

val changesCount = changesFile.flatMap(line => line.split(" ")).map(word => (word, 1)).reduceByKey(_ + _)

Step 11. To see the array for either of them, just call the collect function on it.

readmeCount.collect()

changesCount.collect()

Step 12. Now let’s join these two RDDs together to get a collective set. The join function combines the two datasets (K,V) and (K,W) together and get (K, (V,W)). Let’s join these two counts together

val joined = readmeCount.join(changesCount)

Step 13. Cache the joined dataset.

joined.cache()

Step 14. Print the value to the console

joined.collect.foreach(println)

Step 15. Let’s combine the values together to get the total count. The operations in this command tells Spark to combine the go from (K,V) and (K,W) to (K, V+W). The ._ notation is a way to access the value on that particular index of the key value pair.

val joinedSum = joined.map(k => (k._1, (k._2)._1 + (k._2)._2))

joinedSum.collect()

Step 16. To check if it is correct, print the first five elements from the joined and the joinedSum RDD

joined.take(5).foreach(println)

joinedSum.take(5).foreach(println)

### 1.2.3 Shared variables

Broadcast variables are useful for when you have a large dataset that you want to use across all the worker nodes. Instead of having to send out the entire dataset, only the variable is sent out.

Step 17. In the same shell from the last section, create a broadcast variable. Type in

val broadcastVar = sc.broadcast(Array(1,2,3))

Step 18. To get the value, type in:

broadcastVar.value

Accumulators are variables that can only be added through an associative operation. It is used to implement counters and sum efficiently in parallel. Spark natively supports numeric type accumulators and standard mutable collections. Programmers can extend these for new types. Only the driver can read the values of the accumulators. The workers can only invoke it to increment the value.

Step 19. Create the accumulator variable. Type in:

val accum = sc.accumulator(0)

Step 20. Next parallelize an array of four integers and run it through a loop to add each integer value to the accumulator variable. Type in:

sc.parallelize(Array(1,2,3,4)).foreach(x => accum += x)

Step 21. To get the current value of the accumulator variable, type in:

accum.value

You should get a value of 10.

This command can only be invoked on the driver side. The worker nodes can only increment the accumulator.

### 1.2.4 Key-value pairs

You have already seen a bit about key-value pairs in the Joining RDD section. Here is a brief example of how to create a key-value pair and access its values. Remember that certain operations such as map and reduce only works on key-value pairs.

Step 22. Create a key-value pair of two characters. Type in:

val pair = ('a', 'b')

Step 23. To access the value of the first index, type in:

pair._1

Step 24. To access the value of the second index, type in:

pair._2

Step 25. Quit the Scala shell by typing in

CTRL + D

## Summary

Having completed this exercise, you should now be able perform various RDD operations, view the DAG of an RDD and also perform join operations to combine two datasets into one. You should be able to user shared variables such as broadcast and accumulators. Finally, you saw how to use Spark and Scala to determine the top ten taxis based on the numbers of trips from a sample dataset.


text:
# Efficient dynamic drawing

So for example I have this code:

points = {}; k = 0;
Dynamic@k
Dynamic@Graphics[Point@points]

x = .1; y = .3; K = .9;
While[True,
k++;
{x, y} = {FractionalPart[x + K y], FractionalPart[x]};
AppendTo[points, {x, y}];
]

The problem is that the list of points is growing and it slows down with time. What I want is to be able to add a point (or another primitive) directly on the dynamic graph without storing unnecessary chunks of data.

-
AppendTo[] is notoriously slow... –  Ｊ. Ｍ. Oct 1 '12 at 9:08
@J.M. And increasing the number of points to plot ad infinitum doesn't help –  belisarius Oct 1 '12 at 9:18
For systems like Matlab this works because it uses a more PostScript-like approach to rendering (just adding on top)... –  Yves Klett Oct 1 '12 at 12:55

As it was mentioned in the comments: your loop is infinite, which eventually will cause the slowdown of any computation that accumulates data in the memory. The important rule of thumb for Dynamic updating is: only update when necessary and only update what is necessary. Accordingly, you can speed up the performance of the dynamic drawing by wrapping only points and k in Dynamic. By this way, only the list of points is updated (and the label) and Mathematica does not have to redraw the whole Graphics object again and again (which involves a lot of extra computation).

points = {};
Graphics[Point@Dynamic@points, PlotLabel -> Dynamic@k]

x = .1; y = .3; K = .9;
Do[
{x, y} = {FractionalPart[x + K y], FractionalPart[x]};
points = Append[points, {x, y}];
, {k, 20000}]

Starting from @belisarius' comment, I came up with a more economic version (time scales linearly with k). If one does not have to keep all the points we can apply a reasonable resolution to bin the ranges and saving new datapoints in a matrix, overwriting previous data.

resolution = 256;  (* divide the (0,1) range into 256 bins *)
array = Array[0 &, {resolution, resolution}];

Dynamic@ArrayPlot[array, PlotLabel -> Dynamic@k]

x = .1; y = .3; K = .9;
Do[
{x, y} = {FractionalPart[x + K y], FractionalPart[x]};
array = ReplacePart[array, (Min[#, resolution] & /@ (Round[{x, y}*resolution] + 1)) -> 1],
{k, 1000000}]

-
Yes it's much faster but execution still slows down with time. The goal is to get rid off list and just add primitives directly to the existing graph. –  swish Oct 1 '12 at 10:14
@swish: I think that in any case a list must be maintained to store points if you want to build up your graphics by successively introducing points. –  István Zachar Oct 1 '12 at 10:32
How about keeping a rasterized pre-image, and adding a point at a time. It's slow, but O(1) –  belisarius Oct 1 '12 at 12:33
Thanks for the tip @belisarius. See edit. –  István Zachar Oct 1 '12 at 13:39
Thank you all, it is really fast now. I was playing with ArrayPlot too. –  swish Oct 1 '12 at 14:25


text:
# Example scripts¶

In this chapter we’ll discuss some scripts showing common examples of how to download and analyse data. We’ll start with a short discussion of the general layout of such scripts and how to run them interactively. Then, we’ll continue with examples for some common tasks.

## First, some tips and tricks¶

### The not in globals() trick¶

import datetime

import tables

from sapphire import esd

DATAFILE = 'data.h5'
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

data = tables.open_file(DATAFILE, 'w')

This script can be run from the command line like this:

\$ python <name_of_script.py>

Every time you run the script, the old data will be removed and new data will be downloaded. Except that the data is probably unchanged. What a waste of time and bandwidth! If you do not run this from the command line you can run into trouble. For example, the second time you run the script from an IPython console, you can run into an exception:

>>> %run simple-download.py
100%|################################################################|Time: 5.22
Traceback (most recent call last):
data = tables.open_file(DATAFILE, 'w')
File "/Users/david/anaconda/lib/python2.7/site-packages/tables/file.py", line 315, in open_file
"close it before reopening in write mode." % filename)
ValueError: The file 'data.h5' is already opened.  Please close it before reopening in write mode.

The second time the script is run, the file is already opened. The script, however, does not know that. You can close the file at the end of your script, but then you don’t have access to the file from the interactive console. It is very useful to run the script, keep the file open, and be able to inspect the file and any variables created by the script. The console has access to all variables declared by the script, but by default the script is not allowed to know about any variables defined in the console. In other words, the script cannot know about the opened file. This is fixed by running the script with the -i option:

>>> %run -i simple-download.py

The script still does not check for opened files. To do this, one can use the globals() function. This will return a dictionary containing all variables in the global scope. If data is defined, then 'data' will be present in that dictionary. We can check for that:

import datetime

import tables

from sapphire import esd

DATAFILE = 'data.h5'
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

if 'data' not in globals():
data = tables.open_file(DATAFILE, 'w')

Now, the script can be rerun multiple times:

>>> %run -i simple-download-with-globals.py
100%|################################################################|Time: 5.29

The second time the script is run, it does nothing. This is useful, because we can include stuff that needs to be rerun after the if-statement.

### The not in data trick¶

Every time we run the previous script from the command-line, or start a new IPython console, the script still overwrites the data file with ‘new’ data. We need something more! In addition to checking if the file is already opened, the script needs to check if the data is already present in the file. If it is, the script should do nothing. It is important to open the file in append mode, not in write mode. If you do the latter, the file is overwritten the moment you open it. The script becomes:

import datetime

import tables

from sapphire import esd

DATAFILE = 'data.h5'
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

if 'data' not in globals():
data = tables.open_file(DATAFILE, 'a')

if '/s501' not in data:

### The if __name__ == '__main__' trick¶

Finally, most scripts of any decent size include a weird-looking line:

if __name__ == '__main__':
do_something()

This is very useful, in fact! A small script invariably grows to a larger size. Most probably, you’ll write a few functions that are useful elsewhere. If they are, you can import them from a new script. That, however, causes problems if you did not include the lines above. For example, take this script:

is_useful.py
def square(x):
return x ** 2

print(1, 2, 3)
print(square(1), square(2), square(3))

This script defines a function to calculate the squares of numbers. We use it to print the squared of the numbers 1, 2, and 3. Now, we want to print the square of 16:

>>> from is_useful import square
1 2 3
1 4 9
>>> print(square(16))
256

What happened? When we import a module, the code inside that module is run as well. We don’t want that. When we run a script, the special variable __name__ is equal to '__main__'. When we import a script, the variable is equal to the name of the module, and not equal to '__main__'. So, we can check for that:

is_useful_and_importable.py
def square(x):
return x ** 2

if __name__ == '__main__':
print(1, 2, 3)
print(square(1), square(2), square(3))

If we run the script stand-alone, we get the expected result:

>>> %run is_useful_and_importable.py
1 2 3
1 4 9

But we can now also import the script without any unintended side effects:

>>> from is_useful_and_importable import square
>>> print(square(16))
256

It is good practice to always include the __name__ == '__main__' check.

import datetime

import tables

from sapphire import esd

DATAFILE = 'data.h5'
STATIONS = [501, 503, 506]
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

if __name__ == '__main__':
if 'data' not in globals():
data = tables.open_file(DATAFILE, 'a')

for station in STATIONS:
group = '/s%d' % station
if group not in data:

import datetime

import tables

from sapphire import esd

DATAFILE = 'data.h5'
STATIONS = [501, 503, 506]
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

if __name__ == '__main__':
if 'data' not in globals():
data = tables.open_file(DATAFILE, 'a')

if '/coincidences' not in data:

import datetime

import tables

from sapphire import esd
from sapphire.analysis import reconstructions

DATAFILE = 'data.h5'
STATIONS = [501, 503, 506]
START = datetime.datetime(2016, 1, 1)
END = datetime.datetime(2016, 1, 2)

if __name__ == '__main__':
if 'data' not in globals():
data = tables.open_file(DATAFILE, 'a')

if '/coincidences' not in data:

if '/reconstructions' not in data:
rec = reconstructions.ReconstructESDCoincidences(data)
rec.reconstruct_and_store()

### Plot zenith angle distribution¶

import tables

import pylab as plt

def plot_zenith_distribution(data):
events = data.root.coincidences.reconstructions

# get all zenith values
zenith = events.col('zenith')

# remove all NaNs.
zenith = zenith.compress(-isnan(zenith))

plt.hist(degrees(zenith), bins=linspace(0, 90, 51), histtype='step')
plt.xlabel("zenith [deg]")
plt.ylabel("count")

if __name__ == '__main__':
if 'data' not in globals():
data = tables.open_file('data.h5')

plot_zenith_distribution(data)