using_celme_classes.html 20.1 KB

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>User guide to program with celme Python classes &#8212; Mount Control Software 1.0.0 documentation</title>
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
    
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Generate this documentation" href="generate_documentation.html" />
    <link rel="prev" title="User guide to program with mount Python classes" href="using_mount_classes.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="generate_documentation.html" title="Generate this documentation"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="using_mount_classes.html" title="User guide to program with mount Python classes"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Mount Control Software 1.0.0 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">User guide to program with celme Python classes</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="user-guide-to-program-with-celme-python-classes">
<h1>User guide to program with celme Python classes<a class="headerlink" href="#user-guide-to-program-with-celme-python-classes" title="Permalink to this headline">¶</a></h1>
<p>This section show how to use celme in a Python code.</p>
<div class="section" id="context">
<h2>1. Context<a class="headerlink" href="#context" title="Permalink to this headline">¶</a></h2>
<p>Celestial mechanics allow to compute celestial bodies positions and manage dates, durations, angles, coordinates.</p>
</div>
<div class="section" id="python-classes-provided-by-celme">
<h2>2. Python classes provided by celme<a class="headerlink" href="#python-classes-provided-by-celme" title="Permalink to this headline">¶</a></h2>
<p>Brief descrition of the celme classes:</p>
<blockquote>
<div><ul class="simple">
<li><p>Angle: Convert angles in complex formats.</p></li>
<li><p>Coords: Convert angles in complex formats.</p></li>
<li><p>Home: Define a mount location on the Earth surface.</p></li>
<li><p>Horizon: Define horizon line to set the limits of telescope pointings.</p></li>
<li><p>Atmosphere: Define atmospheric conditions to set the conditions to compute refraction effects.</p></li>
<li><p>Site: Define an observation site by merging Home, Horizon, Atmosphere.</p></li>
<li><p>Date: Convert dates in complex formats.</p></li>
<li><p>Duration: Convert durations in complex formats.</p></li>
<li><p>Mechanics: Low level methods for celestial mechanics</p></li>
<li><p>Targets: High level methods for celestial mechanics</p></li>
</ul>
</div></blockquote>
<img alt="_images/classes_celme.png" src="_images/classes_celme.png" />
</div>
<div class="section" id="using-the-python-module-celme-for-angles">
<h2>3. Using the Python module celme for angles<a class="headerlink" href="#using-the-python-module-celme-for-angles" title="Permalink to this headline">¶</a></h2>
<div class="section" id="simple-example-to-convert-angles">
<h3>3.1. Simple example to convert angles<a class="headerlink" href="#simple-example-to-convert-angles" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Angle</span><span class="p">(</span><span class="s2">&quot;2h3m27s&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;angle deg =&quot;</span><span class="p">,</span> <span class="n">a</span><span class="o">.</span><span class="n">deg</span><span class="p">())</span>
</pre></div>
</div>
<p>angle deg = 30.862499999999994</p>
</div>
<div class="section" id="operation-with-angles">
<h3>3.2. Operation with angles<a class="headerlink" href="#operation-with-angles" title="Permalink to this headline">¶</a></h3>
<p>We want to compute sum of the angles 2h3m27s and -0d28m12.4s. Display the results in sexagesimal format expressed in degrees:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Angle</span><span class="p">(</span><span class="s2">&quot;2h3m27s&quot;</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Angle</span><span class="p">(</span><span class="s2">&quot;-0d28m12.4s&quot;</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">sexagesimal</span><span class="p">(</span><span class="s2">&quot;d&quot;</span><span class="p">)))</span>
</pre></div>
</div>
<p>‘30d23m32.60s’</p>
</div>
</div>
<div class="section" id="using-the-python-module-celme-for-dates">
<h2>4. Using the Python module celme for dates<a class="headerlink" href="#using-the-python-module-celme-for-dates" title="Permalink to this headline">¶</a></h2>
<p>Celme module is located in the folder pyros/src/utils
Examples: pyros/src/utils/report/dates.py
help(Date)</p>
<div class="section" id="simple-example-to-convert-dates">
<h3>4.1. Simple example to convert dates<a class="headerlink" href="#simple-example-to-convert-dates" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Date</span><span class="p">(</span><span class="s2">&quot;now&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Date ISO =&quot;</span><span class="p">,</span> <span class="n">a</span><span class="o">.</span><span class="n">iso</span><span class="p">())</span>
<span class="n">Date</span> <span class="n">ISO</span> <span class="o">=</span> <span class="mi">2018</span><span class="o">-</span><span class="mi">10</span><span class="o">-</span><span class="mi">11</span><span class="n">T22</span><span class="p">:</span><span class="mi">45</span><span class="p">:</span><span class="mf">44.958</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Date Julian Day =&quot;</span><span class="p">,</span> <span class="n">a</span><span class="o">.</span><span class="n">jd</span><span class="p">())</span>
</pre></div>
</div>
<p>Date Julian Day = 2458403.448437011</p>
</div>
<div class="section" id="operation-with-dates">
<h3>4.2. Operation with dates<a class="headerlink" href="#operation-with-dates" title="Permalink to this headline">¶</a></h3>
<p>We want to compute date corresponding to add 2 days and 28 minutes to the 2018-10-11T22:45:44.958. Display the results in ISO format:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Date</span><span class="p">(</span><span class="s2">&quot;2018-10-11T22:45:44.958&quot;</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Duration</span><span class="p">(</span><span class="s2">&quot;2d28m&quot;</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Date ISO =&quot;</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">iso</span><span class="p">())</span>
</pre></div>
</div>
<p>Date ISO = 2018-10-13T23:13:44.958</p>
</div>
</div>
<div class="section" id="using-the-python-module-celme-for-ephemeris">
<h2>5. Using the Python module celme for ephemeris<a class="headerlink" href="#using-the-python-module-celme-for-ephemeris" title="Permalink to this headline">¶</a></h2>
<div class="line-block">
<div class="line">Celme module is located in the folder pyros/src/utils</div>
<div class="line">Examples: pyros/src/utils/report/targets.py</div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">Target</span><span class="p">)</span>
</pre></div>
</div>
<div class="section" id="simple-example-to-compute-sun-coordinates">
<h3>5.1. Simple example to compute Sun coordinates<a class="headerlink" href="#simple-example-to-compute-sun-coordinates" title="Permalink to this headline">¶</a></h3>
<p>First we compute RA, DEC coordinates of the Sun:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="n">date</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Date</span><span class="p">(</span><span class="s2">&quot;now&quot;</span><span class="p">)</span>
<span class="n">site</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="s2">&quot;GPS 0 E 49 200&quot;</span><span class="p">)</span>
<span class="n">skyobj</span><span class="o">=</span> <span class="p">{</span><span class="s1">&#39;planet&#39;</span><span class="p">:</span><span class="s1">&#39;Sun&#39;</span><span class="p">}</span>
<span class="n">target</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Target</span><span class="p">()</span>
<span class="n">target</span><span class="o">.</span><span class="n">define</span><span class="p">(</span><span class="n">skyobj</span><span class="p">)</span>
<span class="n">output0s</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;ra&#39;</span><span class="p">,</span><span class="s1">&#39;dec&#39;</span><span class="p">]</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">target</span><span class="o">.</span><span class="n">ephem</span><span class="p">(</span><span class="n">date</span><span class="p">,</span><span class="n">site</span><span class="p">,</span><span class="n">output0s</span><span class="p">)</span>
<span class="n">ra</span> <span class="o">=</span> <span class="n">results</span><span class="p">[</span><span class="s1">&#39;RA&#39;</span><span class="p">]</span>
<span class="n">dec</span> <span class="o">=</span> <span class="n">results</span><span class="p">[</span><span class="s1">&#39;DEC&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>Second, we inject RA, DEC to compute its local coordinates:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">skyobj</span><span class="o">=</span> <span class="p">{</span><span class="s1">&#39;RA&#39;</span><span class="p">:</span><span class="n">ra</span> <span class="p">,</span> <span class="s1">&#39;DEC&#39;</span><span class="p">:</span><span class="n">dec</span> <span class="p">}</span>
<span class="n">outputs</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;elev&#39;</span><span class="p">]</span>
<span class="n">target</span><span class="o">.</span><span class="n">define</span><span class="p">(</span><span class="n">skyobj</span><span class="p">)</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">target</span><span class="o">.</span><span class="n">ephem</span><span class="p">(</span><span class="n">date</span><span class="p">,</span><span class="n">site</span><span class="p">,</span><span class="n">outputs</span><span class="p">)</span>
<span class="n">elev</span> <span class="o">=</span> <span class="n">results</span><span class="p">[</span><span class="s1">&#39;ELEV&#39;</span><span class="p">]</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="angle-formats">
<h2>6. Angle formats<a class="headerlink" href="#angle-formats" title="Permalink to this headline">¶</a></h2>
<p>Input accepted formats:</p>
<div class="line-block">
<div class="line">-12.345 : Decimal degrees</div>
<div class="line">-0.3421r : Decimal radians</div>
<div class="line">6h3m2s : Sexagesimal HMS</div>
<div class="line">3mh2s : Sexagesimal MS</div>
<div class="line">2sh : Sexagesimal S</div>
<div class="line">6d3m2s : Sexagesimal dms</div>
<div class="line">3m2s : Sexagesimal ms</div>
<div class="line">2s : Sexagesimal s (i.e. arcsec)</div>
<div class="line">“6 3 2” : Sexagesimal dms</div>
<div class="line">“6:3:2” : Sexagesimal dms</div>
<div class="line">“6h3:2” : Sexagesimal HMS</div>
</div>
<p>Sexagesimal formating using uspzad convention rad is an angle in radian
Sexagesimal format:</p>
<blockquote>
<div><ul class="simple">
<li><p>u (unit) = h,H,d,D (default=D). Capital mean module [0:360[, lower case means module [-180:180[</p></li>
<li><p>s (separator) = ” “,:,”” (default=”” means letters hms or dms)</p></li>
<li><p>p (plus/minus) = +,”” (default=”“)</p></li>
<li><p>z (zeros) = 0,”” (default=”“)</p></li>
<li><p>a (angle_limits) = “”,90, (+/-limit if unit D,H, default=”” means 360)</p></li>
<li><p>d (sec_digits) = “”,”.1”,”.2”,… (default=”“)</p></li>
</ul>
</div></blockquote>
<p>Style 1:</p>
<blockquote>
<div><ul class="simple">
<li><p>To Display a R.A.: “H0.2” =&gt;  23h07m42.49s</p></li>
<li><p>To Display a Decl.: “d+090.1” =&gt; +00d34m22.6s</p></li>
<li><p>To Display a H.A.: “h0.2” =&gt; -08h43m16.05s</p></li>
</ul>
</div></blockquote>
<p>Style 2:</p>
<blockquote>
<div><ul class="simple">
<li><p>To Display a R.A.: “H 0.2” =&gt;  23 07 42.49</p></li>
<li><p>To Display a Decl.: “d +090.1” =&gt; -00 34 22.6</p></li>
<li><p>To Display a H.A.: “h 0.2” =&gt; -08 43 16.05</p></li>
</ul>
</div></blockquote>
<p>Style 3:</p>
<blockquote>
<div><ul class="simple">
<li><p>To Display a R.A.: “H:0.2” =&gt;  23:07:42.49</p></li>
<li><p>To Display a Decl.: “d:+090.1” =&gt; -00:34:22.6</p></li>
<li><p>To Display a H.A.: “h:0.2” =&gt; -08:43:16.05</p></li>
</ul>
</div></blockquote>
</div>
<div class="section" id="date-formats">
<h2>7. Date formats<a class="headerlink" href="#date-formats" title="Permalink to this headline">¶</a></h2>
<p>Input accepted formats:</p>
<ul class="simple">
<li><p>now = Now. e.g. “now”</p></li>
<li><p>jd = Julian day. e.g. 24504527.45678</p></li>
<li><p>iso = ISO 8601. e.g. 2018-02-28T12:34:55.23</p></li>
<li><p>sql = ISO 8601. e.g. 2018-02-28 12:34:55.23</p></li>
<li><p>ymdhms = Calendar. e.g. 2018 2 28 12 34 55.23</p></li>
<li><p>equinox = Equinox. e.g. J2000,0</p></li>
<li><p>digits = Pure digits e.g. 20180228123455.23</p></li>
</ul>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">User guide to program with celme Python classes</a><ul>
<li><a class="reference internal" href="#context">1. Context</a></li>
<li><a class="reference internal" href="#python-classes-provided-by-celme">2. Python classes provided by celme</a></li>
<li><a class="reference internal" href="#using-the-python-module-celme-for-angles">3. Using the Python module celme for angles</a><ul>
<li><a class="reference internal" href="#simple-example-to-convert-angles">3.1. Simple example to convert angles</a></li>
<li><a class="reference internal" href="#operation-with-angles">3.2. Operation with angles</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-the-python-module-celme-for-dates">4. Using the Python module celme for dates</a><ul>
<li><a class="reference internal" href="#simple-example-to-convert-dates">4.1. Simple example to convert dates</a></li>
<li><a class="reference internal" href="#operation-with-dates">4.2. Operation with dates</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-the-python-module-celme-for-ephemeris">5. Using the Python module celme for ephemeris</a><ul>
<li><a class="reference internal" href="#simple-example-to-compute-sun-coordinates">5.1. Simple example to compute Sun coordinates</a></li>
</ul>
</li>
<li><a class="reference internal" href="#angle-formats">6. Angle formats</a></li>
<li><a class="reference internal" href="#date-formats">7. Date formats</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="using_mount_classes.html"
                        title="previous chapter">User guide to program with mount Python classes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="generate_documentation.html"
                        title="next chapter">Generate this documentation</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/using_celme_classes.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="generate_documentation.html" title="Generate this documentation"
             >next</a> |</li>
        <li class="right" >
          <a href="using_mount_classes.html" title="User guide to program with mount Python classes"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">Mount Control Software 1.0.0 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">User guide to program with celme Python classes</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021, astromecca.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.4.0.
    </div>
  </body>
</html>