Skip to content

Commit

Permalink
Deploying to gh-pages from @ 4682294 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
smutch committed Feb 16, 2024
1 parent a436d7c commit d27683f
Show file tree
Hide file tree
Showing 72 changed files with 10,227 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: f957e872d798e19e10970813fa8f1dbb
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/authors.doctree
Binary file not shown.
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/installation.doctree
Binary file not shown.
Binary file added .doctrees/meraxes.doctree
Binary file not shown.
Binary file added .doctrees/munge.doctree
Binary file not shown.
Binary file added .doctrees/nbody.doctree
Binary file not shown.
Binary file added .doctrees/plotutils.doctree
Binary file not shown.
Binary file added .doctrees/readme.doctree
Binary file not shown.
Empty file added .nojekll
Empty file.
210 changes: 210 additions & 0 deletions _modules/dragons/meraxes/galaxy_history.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dragons.meraxes.galaxy_history &mdash; DRAGONS Tools 0.5.1.dev4+g4682294 documentation</title>
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../../_static/documentation_options.js?v=fb93ffc6"></script>
<script src="../../../_static/doctools.js?v=888ff710"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../../genindex.html" />
<link rel="search" title="Search" href="../../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../../index.html" class="icon icon-home">
DRAGONS Tools
</a>
<div class="version">
0.5.1.dev4+g4682294
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../readme.html">DRAGONS Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../authors.html">Credits</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../meraxes.html">meraxes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../munge.html">munge</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../nbody.html">nbody</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../plotutils.html">plotutils</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../index.html">DRAGONS Tools</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../../index.html">Module code</a></li>
<li class="breadcrumb-item active">dragons.meraxes.galaxy_history</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for dragons.meraxes.galaxy_history</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>

<span class="sd">&quot;&quot;&quot;Generate the full (first progenitor line) history of a galaxy.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">..munge</span> <span class="kn">import</span> <span class="n">ndarray_to_dataframe</span>
<span class="kn">from</span> <span class="nn">.io</span> <span class="kn">import</span> <span class="n">read_gals</span><span class="p">,</span> <span class="n">read_firstprogenitor_indices</span><span class="p">,</span> <span class="n">read_descendant_indices</span>
<span class="kn">from</span> <span class="nn">tqdm</span> <span class="kn">import</span> <span class="n">tqdm</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>


<div class="viewcode-block" id="galaxy_history">
<a class="viewcode-back" href="../../../meraxes.html#dragons.meraxes.galaxy_history.galaxy_history">[docs]</a>
<span class="k">def</span> <span class="nf">galaxy_history</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">gal_id</span><span class="p">,</span> <span class="n">snapshot</span><span class="p">,</span> <span class="n">future_snapshot</span><span class="o">=-</span><span class="mi">1</span><span class="p">,</span> <span class="n">pandas</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">props</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>

<span class="w"> </span><span class="sd">&quot;&quot;&quot; Read in the full first progenitor history of a galaxy at a given final</span>
<span class="sd"> snapshot.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> fname : str</span>
<span class="sd"> Full path to input hdf5 master file.</span>

<span class="sd"> gal_id : int</span>
<span class="sd"> Unique ID of the target galaxy.</span>

<span class="sd"> snapshot : int</span>
<span class="sd"> Snapshot at which the history is to be traced from.</span>

<span class="sd"> props : list</span>
<span class="sd"> A list of galaxy properties requested. (default: All properties)</span>

<span class="sd"> future_snapshot: int</span>
<span class="sd"> Also read in the future of the galaxy object up to this snapshot.</span>
<span class="sd"> (default: -1 [don&#39;t read in future])</span>

<span class="sd"> pandas : bool</span>
<span class="sd"> Return panads dataframe. (default = False)</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> history : ndarray or DataFrame</span>
<span class="sd"> The requested first progenitor history. If future=True then the</span>
<span class="sd"> ndarray includes the future of this object.</span>

<span class="sd"> merged_snapshot : int</span>
<span class="sd"> If `future_snapshot != -1` then the snapshot at which the galaxy</span>
<span class="sd"> merged into another is also returned. If `merged_snapshot = -1`</span>
<span class="sd"> then the galaxy remains until `future_snapshot.`</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">gals</span> <span class="o">=</span> <span class="n">read_gals</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snapshot</span><span class="o">=</span><span class="n">snapshot</span><span class="p">,</span> <span class="n">props</span><span class="o">=</span><span class="n">props</span><span class="p">,</span> <span class="n">pandas</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

<span class="n">start_ind</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">gals</span><span class="p">[</span><span class="s2">&quot;ID&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">gal_id</span><span class="p">)[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
<span class="n">merged_snapshot</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>

<span class="k">if</span> <span class="n">future_snapshot</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="n">future_snapshot</span> <span class="o">=</span> <span class="n">snapshot</span>
<span class="n">history</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">future_snapshot</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">gals</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>

<span class="n">history</span><span class="p">[</span><span class="n">snapshot</span><span class="p">]</span> <span class="o">=</span> <span class="n">gals</span><span class="p">[</span><span class="n">start_ind</span><span class="p">]</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">read_firstprogenitor_indices</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snapshot</span><span class="p">)[</span><span class="n">start_ind</span><span class="p">]</span>

<span class="k">if</span> <span class="n">ind</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Warning</span><span class="p">(</span><span class="s2">&quot;This galaxy has no progenitors!&quot;</span><span class="p">)</span>

<span class="k">for</span> <span class="n">snap</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">snapshot</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))):</span>
<span class="n">history</span><span class="p">[</span><span class="n">snap</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_gals</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snapshot</span><span class="o">=</span><span class="n">snap</span><span class="p">,</span> <span class="n">pandas</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">props</span><span class="o">=</span><span class="n">props</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="p">[</span><span class="n">ind</span><span class="p">])</span>
<span class="k">if</span> <span class="n">snap</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">:</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">read_firstprogenitor_indices</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snap</span><span class="p">)[</span><span class="n">ind</span><span class="p">]</span>
<span class="k">if</span> <span class="n">ind</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="k">break</span>

<span class="k">if</span> <span class="n">future_snapshot</span> <span class="o">!=</span> <span class="n">snapshot</span><span class="p">:</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">start_ind</span>
<span class="k">for</span> <span class="n">snap</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">snapshot</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">future_snapshot</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))):</span>
<span class="n">last_ind</span> <span class="o">=</span> <span class="n">ind</span>
<span class="n">ind</span> <span class="o">=</span> <span class="n">read_descendant_indices</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snap</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)[</span><span class="n">ind</span><span class="p">]</span>
<span class="k">if</span> <span class="n">ind</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="k">break</span>

<span class="k">if</span> <span class="n">snap</span> <span class="o">&lt;</span> <span class="n">future_snapshot</span><span class="p">:</span>
<span class="n">fp</span> <span class="o">=</span> <span class="n">read_firstprogenitor_indices</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snap</span><span class="p">)[</span><span class="n">ind</span><span class="p">]</span>
<span class="k">if</span> <span class="n">fp</span> <span class="o">!=</span> <span class="n">last_ind</span> <span class="ow">and</span> <span class="n">merged_snapshot</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
<span class="n">merged_snapshot</span> <span class="o">=</span> <span class="n">snap</span>

<span class="n">history</span><span class="p">[</span><span class="n">snap</span><span class="p">]</span> <span class="o">=</span> <span class="n">read_gals</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">snapshot</span><span class="o">=</span><span class="n">snap</span><span class="p">,</span> <span class="n">pandas</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">props</span><span class="o">=</span><span class="n">props</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="p">[</span><span class="n">ind</span><span class="p">])</span>

<span class="k">if</span> <span class="n">pandas</span><span class="p">:</span>
<span class="n">history</span> <span class="o">=</span> <span class="n">ndarray_to_dataframe</span><span class="p">(</span><span class="n">history</span><span class="p">)</span>

<span class="k">if</span> <span class="n">future_snapshot</span> <span class="o">==</span> <span class="n">snapshot</span><span class="p">:</span>
<span class="k">return</span> <span class="n">history</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">history</span><span class="p">,</span> <span class="n">merged_snapshot</span></div>

</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2013, Simon Mutch.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit d27683f

Please sign in to comment.