Jekyll2019-11-26T16:08:23+00:00http://astronotes.co.uk/feed.xmlastronotesDavid Young's NotebookJoe Doed.r.young@qub.ac.ukDownloading PanSTARRS DR1 Catalogue Data2018-06-20T00:00:00+01:002018-06-20T00:00:00+01:00http://astronotes.co.uk/blog/2018/06/20/downloading-panstarrs-dr1-catalogue-data<h1 id="downloadingthepanstarrsdr1catalogueviacasjobs">Downloading the PanSTARRS DR1 Catalogue via CasJobs</h1>
<p>Before you begin running SQL queries on the <a href="http://mastweb.stsci.edu/ps1casjobs/default.aspx">PanSTARRS DR1 Catalogue</a> via the command-line you first need to <a href="http://skyserver.sdss.org/casjobs/download/casjobs.jar">download the <code>casjobs.jar</code> </a> java archive file and <a href="http://skyserver.sdss.org/casjobs/download/CasJobs.config.x">a config file</a>.</p>
<h2 id="installationofcasjobscommand-lineutil">Installation of CasJobs Command-Line Util</h2>
<p>First move the jar files to a location on your machine’s <code>$PATH</code>. For example:</p>
<pre><code class="bash">cd ~/Downloads
mv casjobs.jar /usr/local/bin/
</code></pre>
<!--summary-->
<p>Now create a directory somewhere where you’re going to be doing your work and move the config file into that directory:</p>
<pre><code class="bash">mkdir ~/Desktop/panstarrs_dr1_casjob_batch_download
cd ~/Desktop/panstarrs_dr1_casjob_batch_download
mv ~/Downloads/CasJobs.config.x CasJobs.config
</code></pre>
<p>Note the removal of the <code>.x</code> extension on the config file.</p>
<p>Before we continue, you’ll need to find what your MAST <code>WSID</code> is. To find this ID, <a href="http://mastweb.stsci.edu/ps1casjobs/login.aspx">log into the MAST CasJob</a>, navigate to ‘profile’ in the top toolbar and you should find your 9 digit WSID there:</p>
<figure>
<img src="https://farm1.staticflickr.com/876/40981703960_5697a86254_o.png" alt="" />
<figcaption></figcaption>
</figure>
<p>Open the <code>CasJobs.config</code> configuration file in your favourite text-editor and amend the details to look like this:</p>
<pre><code class="yaml">wsid=<your_wsid>
password=<your_mast_password>
default_target=PanSTARRS_DR1
default_queue=1
default_days=1
verbose=true
debug=false
jobs_location=http://mastweb.stsci.edu/gcasjobs/services/jobs.asmx
</code></pre>
<p>To test your install run the command:</p>
<pre><code class="bash">java -jar /usr/local/bin/casjobs.jar execute "select top 10 * from stackobjectthin"
</code></pre>
<p>If everything is setup correctly you should get 10 rows returned from the PanSTARRS <code>StackObjectThin</code> table. I added the following alias to my <code>.bashrc</code> file:</p>
<pre><code class="bash">alias casjobs='java -jar /usr/local/bin/casjobs.jar'
</code></pre>
<p>so I can execute the same CasJob with the command:</p>
<pre><code class="bash">casjobs execute "select top 10 * from stackobjectthin"
</code></pre>
<p>You can read more about <a href="http://mastweb.stsci.edu/ps1casjobs/">PanSTARRS CasJobs here</a> and a <a href="http://mastweb.stsci.edu/gcasjobs/services/jobs.asmx">list of command you can execute with CasJobs here</a>.</p>
<h2 id="selectwhichdatatodownload">Select Which Data to Download</h2>
<p>The PanSTARRS DR1 database has a few core tables containing the majority of the catalogued data and multiple helper tables and views that support those core tables. <a href="http://astronotes.co.uk/blog/2018/06/06/a-query-to-export-panstarrs-dr1-data-for-use-with-sherlock.html">I’ve decided that I catalogued data I need are from the <code>StackObjectThin</code> and <code>StackObjectAttributes</code> tables</a>.</p>
<p>Inspecting the PanSTARRS DR1 table schema from the CasJobs webpages we find that the <code>StackObjectThin</code> table contains <span class="math">\(\sim 3.5\times 10^9\)</span> rows.</p>
<figure>
<img src="https://farm2.staticflickr.com/1739/28937688708_81391a81f2_o.png" alt="" />
<figcaption></figcaption>
</figure>
<p>Select only rows with primary_detection = 1 leaves us with 2,877,925,753 rows to download. It’s also clear that <code>StackObjectsAttributes</code> is not a table but a view:</p>
<figure>
<img src="https://farm2.staticflickr.com/1754/42093637814_b5e2c81d39_o.png" alt="" />
<figcaption></figcaption>
</figure>
<h2 id="anindexingschemeforsystematicdownloads">An Indexing Scheme for Systematic Downloads</h2>
<p>Having targeted a few different combinations of columns for remote selection and indexing downloaded results, I 've settle on using just the <code>objID</code> column as I’m sure it’s used as a SQL Server index as MAST<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"><sup>1</sup></a>. Also using a JOIN to combine the <code>StackObjectThin</code> and <code>StackObjectAttributes</code> table data resulted in very sluggish very times.</p>
<p><a href="https://gist.github.com/thespacedoctor/9c41f8417452719fba248ac3ddd4325c#file-panstarrs_dr1_downloader-py">This script</a> (see bottom of post) iterates over the <code>StackObjectThin</code> and <code>StackObjectAttributes</code> tables, ordered by the PanSTARRS <code>objId</code> and downloads packets of <span class="math">\(0.5 \times 10^6\)</span> rows in FITS format. The filenames are prefixed with <code>t</code> for <code>StackObjectThin</code> and <code>a</code> for <code>StackObjectAttributes</code> and the 18 digit integer is the maximum <code>objId</code> in the file. For example:</p>
<pre><code class="plain">t070002762982847811.fits
a070002762982847811.fits
</code></pre>
<h2 id="kickingoffadownload">Kicking off a Download</h2>
<p>Before you run the download script, you need to make sure you have a spare <sub>3TB</sub> of space on the machine you’re running the download on. As you can imaging <span class="math">\(\sim3 \times 10^9\)</span> rows of data eats up a lot of bytes!</p>
<p>To run the script, download it into the same directory as your <code>CasJobs.config</code> file:</p>
<pre><code class="bash">wget https://gist.githubusercontent.com/thespacedoctor/9c41f8417452719fba248ac3ddd4325c/raw/panstarrs_dr1_downloader.py
</code></pre>
<p>And run with:</p>
<pre><code class="bash">python panstarrs_dr1_downloader.py
</code></pre>
<p>My initial speed tests are suggesting it should take <sub>5</sub>–6 days to download all of the data.</p>
<p><script src="https://gist.github.com/thespacedoctor/9c41f8417452719fba248ac3ddd4325c.js"></script></p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>using <code>projectionid</code> and <code>skycellid</code> seemed like a smart idea but query times indicated it was going to take over 15 years for the download to complete! <a href="#fnref:1" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
</ol>
</div>Joe Doed.r.young@qub.ac.ukDownloading the PanSTARRS DR1 Catalogue via CasJobs Before you begin running SQL queries on the PanSTARRS DR1 Catalogue via the command-line you first need to download the casjobs.jar java archive file and a config file. Installation of CasJobs Command-Line Util First move the jar files to a location on your machine’s $PATH. For example: cd ~/Downloads mv casjobs.jar /usr/local/bin/A Query to Export PanSTARRS-DR1 Data for Use with Sherlock2018-06-06T00:00:00+01:002018-06-06T00:00:00+01:00http://astronotes.co.uk/blog/2018/06/06/a-query-to-export-panstarrs-dr1-data-for-use-with-sherlock<p><a href="https://outerspace.stsci.edu/display/PANSTARRS">PanSTARRS DR1 lives in Space-Telescope archives</a> (images and catalogues) and a list of the DR1 database tables and their corresponding schema can be found <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+Source+extraction+and+catalogs#PS1Sourceextractionandcatalogs-DBtables">here</a>. We want to extract the minimum information from these tables required to integrate the catalogue into the <a href="https://github.com/thespacedoctor/sherlock">Sherlock</a> crossmatch-catalogues database. The big three checkboxes we need to hit are:</p>
<ol>
<li>Positions of sources</li>
<li>Magnitudes of sources</li>
<li>Star-galaxy separation metric(s) for each source</li>
</ol>
<!--summary-->
<h2 id="detectionsvsobjects">Detections vs Objects</h2>
<p>Here are the formal definitions for detections and objects in <a href="https://panstarrs.stsci.edu/">PanSTARRS</a>:</p>
<p>Detection</p>
<p>: source found in a single exposure
</p>
<p>Object</p>
<p>: either a collection of detections matched across exposures, or
: sources found in stacked images that combine multiple epochs to produce deeper detection limits
</p>
<h2 id="pan-starrscataloguedbtables">Pan-Starrs Catalogue DB Tables</h2>
<p>In DR1 there are only 2 tables we need to focus on to extract what we need:</p>
<ol>
<li><strong><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a>: </strong>Contains the <strong>positional and photometric information for all photometry of detections on the stacks</strong>. One detection of each object will be flagged as the best. <strong>This table can be used on its own as a primary source of stack photometry</strong>.</li>
<li><strong><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a>:</strong> For all stack detections it contains the <strong>PSFFlux, KronFlux, and APFlux fluxes</strong> (as opposed to magnitudes) for all filters in a single row, along with <strong>point-source object shape parameters (e.g. FWHM, moments)</strong>. Also sky statistics, exposure times, <strong>basic s/g separation parameter</strong>. Needs to be JOINed to <strong><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">PS1 StackObjectThin table fields</a></strong> to get positions.</li>
</ol>
<p>Come DR2 we will also target the <strong><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+Detection+table+fields">Detection table</a></strong>, but for now a lot of the columns we require are not yet populated in this table.</p>
<h2 id="star-galaxyseparationrecipes">Star-Galaxy Separation Recipes</h2>
<p>This page mentions a ‘basic s/g separation parameter’ to be found in the <code>StackObjectAttributes</code> table:</p>
<p>https://outerspace.stsci.edu/display/PANSTARRS/PS1+Source+extraction+and+catalogs</p>
<p>The columns this comment relates to are the <em>X</em>ExtNSigma columns (X = grizy). From the definition:</p>
<blockquote>
<p>An extendedness measure for the g filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty.</p>
</blockquote>
<p>it seems this metric is to be used with the <a href="https://outerspace.stsci.edu/display/PANSTARRS/How+to+separate+stars+and+galaxies#Howtoseparatestarsandgalaxies-PSF-Kron">first recipe found here</a>. Not sure how normalisation with the PSF mag error works, but I think we can assume anything < 0 is a star and > 0 is a galaxy.</p>
<p>Alongside the basic s/g separation parameter in the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a> table, the PanSTARRS data archive pages have <a href="https://outerspace.stsci.edu/display/PANSTARRS/How+to+separate+stars+and+galaxies">some other recipes for separating stars and galaxies</a>. These recipes include the following parameters:</p>
<ul>
<li><code>PSFMag</code> and <code>KronMag</code>: contained in <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a> table</li>
<li><code>psfLikelihood</code>: contained in the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a> table. Should be <sub>0</sub> for galaxies.</li>
<li><code>momentsR1</code> or <code>KronRad</code>: contained in the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a> and <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a> table.</li>
<li><code>momentRH</code>: contained in the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a> and <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a> table.</li>
</ul>
<h2 id="extractingwhatweneed">Extracting what we need</h2>
<p>It seems from this information that everything we need from PanSTARRS DR1 is contained within the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a> and <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a> tables. I’ve decided to include <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+Detection+Flags">the detection flag columns</a> in the export as it’s unclear how clean the data is in the stack tables and we may have to do some data scrubbing once we have the data locally.</p>
<p>Given the data required for the star-galaxy separation recipes alongside magnitude and portions, here are the definitions for the columns I think we need from the 2 tables:</p>
<h3 id="stackobjectthinhttps:outerspace.stsci.edudisplaypanstarrsps1stackobjectthintablefields"><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">StackObjectThin</a></h3>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;"> Name </th>
<th style="text-align:left;"> Unit </th>
<th style="text-align:left;"> Data Type </th>
<th style="text-align:left;"> Size </th>
<th style="text-align:left;"> Default Value </th>
<th style="text-align:left;"> Description </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"> <strong>objID</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> Unique object identifier. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>uniquePspsSTid</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> Unique internal PSPS stack identifier. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>primaryDetection</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> TINYINT </td>
<td style="text-align:left;"> 1 </td>
<td style="text-align:left;"> 255 </td>
<td style="text-align:left;"> Identifies if this row is the primary stack detection. Note that in the DR1 database, about 0.5% of the objects have more than one entry with primaryDetection=1. This is expected to be fixed in the DR2 database. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gra</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Right ascension from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gdec</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Declination from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gPSFMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> PSF magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gPSFMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in PSF magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gApMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Aperture magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gApMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in aperture magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gKronMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gKronMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in Kron (1980) magnitude from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ginfoFlag</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the g filter stack photometry. Values listed in DetectionFlags. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ginfoFlag2</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the g filter stack photometry. Values listed in DetectionFlags2. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ginfoFlag3</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the g filter stack photometry. Values listed in DetectionFlags3. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rra</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Right ascension from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rdec</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Declination from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rPSFMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> PSF magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rPSFMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in PSF magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rApMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Aperture magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rApMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in aperture magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rKronMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rKronMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in Kron (1980) magnitude from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rinfoFlag</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the r filter stack photometry. Values listed in DetectionFlags. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rinfoFlag2</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the r filter stack photometry. Values listed in DetectionFlags2. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rinfoFlag3</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the r filter stack photometry. Values listed in DetectionFlags3. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ira</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Right ascension from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>idec</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Declination from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iPSFMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> PSF magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iPSFMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in PSF magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iApMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Aperture magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iApMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in aperture magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iKronMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iKronMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in Kron (1980) magnitude from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iinfoFlag</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the i filter stack photometry. Values listed in DetectionFlags. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iinfoFlag2</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the i filter stack photometry. Values listed in DetectionFlags2. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iinfoFlag3</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the i filter stack photometry. Values listed in DetectionFlags3. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zra</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Right ascension from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zdec</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Declination from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zPSFMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> PSF magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zPSFMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in PSF magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zApMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Aperture magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zApMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in aperture magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zKronMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zKronMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in Kron (1980) magnitude from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zinfoFlag</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the z filter stack photometry. Values listed in DetectionFlags. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zinfoFlag2</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the z filter stack photometry. Values listed in DetectionFlags2. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zinfoFlag3</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the z filter stack photometry. Values listed in DetectionFlags3. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yra</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Right ascension from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ydec</strong> </td>
<td style="text-align:left;"> degrees </td>
<td style="text-align:left;"> FLOAT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Declination from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yPSFMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> PSF magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yPSFMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in PSF magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yApMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Aperture magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yApMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in aperture magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yKronMag</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yKronMagErr</strong> </td>
<td style="text-align:left;"> AB magnitudes </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Error in Kron (1980) magnitude from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yinfoFlag</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the y filter stack photometry. Values listed in DetectionFlags. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yinfoFlag2</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the y filter stack photometry. Values listed in DetectionFlags2. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yinfoFlag3</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> INT </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> 0 </td>
<td style="text-align:left;"> Information flag bitmask indicating details of the y filter stack photometry. Values listed in DetectionFlags3. </td>
</tr>
</tbody>
</table>
<h3 id="stackobjectattributeshttps:outerspace.stsci.edudisplaypanstarrsps1stackobjectattributestablefields"><a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectAttributes+table+fields">StackObjectAttributes</a></h3>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;"> Name </th>
<th style="text-align:left;"> Unit </th>
<th style="text-align:left;"> Data Type </th>
<th style="text-align:left;"> Size </th>
<th style="text-align:left;"> Default Value </th>
<th style="text-align:left;"> Description </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"> <strong>objID</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> Unique object identifier. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>uniquePspsSTid</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> BIGINT </td>
<td style="text-align:left;"> 8 </td>
<td style="text-align:left;"> NA </td>
<td style="text-align:left;"> Unique internal PSPS stack identifier. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>primaryDetection</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> TINYINT </td>
<td style="text-align:left;"> 1 </td>
<td style="text-align:left;"> 255 </td>
<td style="text-align:left;"> Identifies if this row is the primary stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>bestDetection</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> TINYINT </td>
<td style="text-align:left;"> 1 </td>
<td style="text-align:left;"> 255 </td>
<td style="text-align:left;"> Identifies if this row is the best detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gpsfLikelihood</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Likelihood that this g filter stack detection is best fit by a PSF. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gmomentR1</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> First radial moment for g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gmomentRH</strong> </td>
<td style="text-align:left;"> arcsec<sup>0</sup>.5 </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Half radial moment (r<sup>0</sup>.5 weighting) for g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gKronRad</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) radius from g filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>gExtNSigma</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> An extendedness measure for the g filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rpsfLikelihood</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Likelihood that this r filter stack detection is best fit by a PSF. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rmomentR1</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> First radial moment for r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rmomentRH</strong> </td>
<td style="text-align:left;"> arcsec<sup>0</sup>.5 </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Half radial moment (r<sup>0</sup>.5 weighting) for r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rKronRad</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) radius from r filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>rExtNSigma</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> An extendedness measure for the r filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ipsfLikelihood</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Likelihood that this i filter stack detection is best fit by a PSF. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>imomentR1</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> First radial moment for i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>imomentRH</strong> </td>
<td style="text-align:left;"> arcsec<sup>0</sup>.5 </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Half radial moment (r<sup>0</sup>.5 weighting) for i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iKronRad</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) radius from i filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>iExtNSigma</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> An extendedness measure for the i filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zpsfLikelihood</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Likelihood that this z filter stack detection is best fit by a PSF. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zmomentR1</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> First radial moment for z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zmomentRH</strong> </td>
<td style="text-align:left;"> arcsec<sup>0</sup>.5 </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Half radial moment (r<sup>0</sup>.5 weighting) for z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zKronRad</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) radius from z filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>zExtNSigma</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> An extendedness measure for the z filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ypsfLikelihood</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Likelihood that this y filter stack detection is best fit by a PSF. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ymomentR1</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> First radial moment for y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>ymomentRH</strong> </td>
<td style="text-align:left;"> arcsec<sup>0</sup>.5 </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Half radial moment (r<sup>0</sup>.5 weighting) for y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yKronRad</strong> </td>
<td style="text-align:left;"> arcsec </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> Kron (1980) radius from y filter stack detection. </td>
</tr>
<tr>
<td style="text-align:left;"> <strong>yExtNSigma</strong> </td>
<td style="text-align:left;"> dimensionless </td>
<td style="text-align:left;"> REAL </td>
<td style="text-align:left;"> 4 </td>
<td style="text-align:left;"> -999 </td>
<td style="text-align:left;"> An extendedness measure for the y filter stack detection based on the deviation between PSF and Kron (1980) magnitudes, normalized by the PSF magnitude uncertainty. </td>
</tr>
<tr>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
</tr>
</tbody>
</table>
<h2 id="finalmastquery">Final MAST Query</h2>
<p>According to the <a href="https://outerspace.stsci.edu/display/PANSTARRS/PS1+StackObjectThin+table+fields">PanSTARRS database documentation</a>, the <code>bestDetection</code> should not be trusted for DR1, but to instead request <code>primaryDetection=1</code> to receive unique object rows. But also note that in the DR1 database, about 0.5% of the objects have more than one entry with <code>primaryDetection=1</code>!</p>
<p>Here then is the final query I’ve developed that should get us all the data we need:</p>
<pre><code class="sql">SELECT
a.objID,
o.objID,
a.uniquePspsSTid,
o.uniquePspsSTid,
a.primaryDetection,
a.bestDetection,
a.gra,
a.gdec,
a.gPSFMag,
a.gPSFMagErr,
a.gApMag,
a.gApMagErr,
a.gKronMag,
a.gKronMagErr,
a.ginfoFlag,
a.ginfoFlag2,
a.ginfoFlag3,
a.rra,
a.rdec,
a.rPSFMag,
a.rPSFMagErr,
a.rApMag,
a.rApMagErr,
a.rKronMag,
a.rKronMagErr,
a.rinfoFlag,
a.rinfoFlag2,
a.rinfoFlag3,
a.ira,
a.idec,
a.iPSFMag,
a.iPSFMagErr,
a.iApMag,
a.iApMagErr,
a.iKronMag,
a.iKronMagErr,
a.iinfoFlag,
a.iinfoFlag2,
a.iinfoFlag3,
a.zra,
a.zdec,
a.zPSFMag,
a.zPSFMagErr,
a.zApMag,
a.zApMagErr,
a.zKronMag,
a.zKronMagErr,
a.zinfoFlag,
a.zinfoFlag2,
a.zinfoFlag3,
a.yra,
a.ydec,
a.yPSFMag,
a.yPSFMagErr,
a.yApMag,
a.yApMagErr,
a.yKronMag,
a.yKronMagErr,
a.yinfoFlag,
a.yinfoFlag2,
a.yinfoFlag3,
o.gpsfLikelihood,
o.gmomentR1,
o.gmomentRH,
o.gKronRad,
o.gExtNSigma,
o.rpsfLikelihood,
o.rmomentR1,
o.rmomentRH,
o.rKronRad,
o.rExtNSigma,
o.ipsfLikelihood,
o.imomentR1,
o.imomentRH,
o.iKronRad,
o.iExtNSigma,
o.zpsfLikelihood,
o.zmomentR1,
o.zmomentRH,
o.zKronRad,
o.zExtNSigma,
o.ypsfLikelihood,
o.ymomentR1,
o.ymomentRH,
o.yKronRad,
o.yExtNSigma
FROM
StackObjectThin a
JOIN
StackObjectAttributes AS o ON a.objid = o.objid
WHERE
a.primaryDetection = 1;
</code></pre>
<p>You can download the <a href="https://www.dropbox.com/s/3q75u6ydift141o/sherlockExportSample.fits?dl=1">FITS binary sample of the data here</a>, which is easily opened and viewed in <a href="http://www.star.bris.ac.uk/~mbt/topcat/">topcat</a>.</p>Joe Doed.r.young@qub.ac.ukPanSTARRS DR1 lives in Space-Telescope archives (images and catalogues) and a list of the DR1 database tables and their corresponding schema can be found here. We want to extract the minimum information from these tables required to integrate the catalogue into the Sherlock crossmatch-catalogues database. The big three checkboxes we need to hit are: Positions of sources Magnitudes of sources Star-galaxy separation metric(s) for each sourceUnderstanding Errors from ATLAS Phase Curve Fitting2018-05-31T00:00:00+01:002018-05-31T00:00:00+01:00http://astronotes.co.uk/blog/2018/05/31/understanding-errors-from-atlas-phase-curve-fitting<p>The reported errors in the ATLAS phase-curve fits appear to be coming out way too small. I’m calculating them as the square-root of the diagonals of the resulting co-variance matrix returned by <a href="https://www.scipy.org/">scipy</a>’s <code>curve_fit</code>.</p>
<pre><code class="python">perr = np.sqrt(np.diag(pcov))
</code></pre>
<p>Here’s what the covariance matrix looks like for Kleopatra:</p>
<pre><code class="text">[
[ 0.00066722 0.00066133]
[ 0.00066133 0.00073213]
]
</code></pre>
<p>Taking the sqrt of the diagonals gives the <span class="math">\(1\sigma\)</span> errors in <em>G</em> and <em>H</em>:</p>
<p><span class="math">\(G_{err} = \sqrt{0.00066722}= 0.0258\)</span>,</p>
<p>and</p>
<p><span class="math">\(H_{err} = \sqrt{0.00073213}= 0.0271\)</span></p>
<!--summary-->
<p>But these values seem ridiculously small given the range of scatter in the plot:</p>
<figure>
<img src="https://farm2.staticflickr.com/1755/40643024570_1ab8cd14c0_o.png" alt="" id="screengrab40643024570" />
<figcaption></figcaption>
</figure>
<p>However, if I use the errors reported for <span class="math">\(c_0\)</span> and <span class="math">\(G\)</span> from the phase-curve fit to determine errors in the reduced magnitude <span class="math">\(c(\alpha)\)</span> it’s easy to then visualise the reported uncertainties on the plot. To do this I have to calculate the maximum and minimum values for <span class="math">\(c_\alpha\)</span> at any given phase-angle on the plot:</p>
<pre><code class="python"># THESE ARE THE H and G VALUES AND ERRORS OUTPUT FROM CURVE_FIT
H = popt[0]
G = popt[1]
Herr = perr[0]
Gerr = perr[1]
# GIVEN THE TWO VARIABLE PARAMETERS I HAVE TO CALCULATE 2^2 = 4 ARRAYS ...
nstd = 3 # 3 sigma range
p1 = magnitude_phase_func(
phaseRange, popt[0] + nstd * perr[0], popt[1] + nstd * perr[1])
p2 = magnitude_phase_func(
phaseRange, popt[0] - nstd * perr[0], popt[1] + nstd * perr[1])
p3 = magnitude_phase_func(
phaseRange, popt[0] + nstd * perr[0], popt[1] - nstd * perr[1])
p4 = magnitude_phase_func(
phaseRange, popt[0] - nstd * perr[0], popt[1] - nstd * perr[1])
# ... AND FIND THE MAXUMUM AND MINIMUM VALUES FOR H IN THE 4 ARRAYS
vHigh = np.maximum(np.maximum(p1, p2), np.maximum(p3, p4))
vLow = np.minimum(np.minimum(p1, p2), np.minimum(p3, p4))
</code></pre>
<p>And now I can plot the <span class="math">\(3\sigma\)</span> uncertainties in the reduced magnitude <span class="math">\(c(\alpha)\)</span>:</p>
<figure>
<img src="https://farm1.staticflickr.com/878/27601458957_0a9bb9aa8a_o.png" alt="" id="screengrab27601458957" />
<figcaption></figcaption>
</figure>
<p>Now the errors look very sensible.</p>
<h2 id="weightingthedata">Weighting the Data</h2>
<p>If I try and now weight the data to account for the photometry errors:</p>
<pre><code class="python"># WEIGHTING WITH PHOTOMETRY ERRORS
popt, pcov = curve_fit(magnitude_phase_func,
phase_radians, y, sigma=yerr, absolute_sigma=True)
</code></pre>
<p>The errors reduce dramatically (by almost an order on magnitude), revealing an uncertainty that no longer looks realistic:</p>
<figure>
<img src="https://farm2.staticflickr.com/1729/40663436530_fcf2a98bef_o.png" alt="" id="screengrab40663436530" />
<figcaption></figcaption>
</figure>
<p>The reason for this is because there’s is a hidden ‘error’ in the data that hasn’t been accounted for; asteroid rotation. For this reason we can’t reasonably state that the photometry errors in our data are ‘absolute’ in the sense that <code>curve_fit</code>, but rather they are relative. Settting <code>absolute_sigma=False</code> and we’re back on-track:</p>
<pre><code class="python"># WEIGHTING WITH PHOTOMETRY ERRORS
popt, pcov = curve_fit(magnitude_phase_func,
phase_radians, y, sigma=yerr, absolute_sigma=False)
</code></pre>
<figure>
<img src="https://farm1.staticflickr.com/889/27601663667_bdd6e90465_o.png" alt="" id="screengrab27601663667" />
<figcaption></figcaption>
</figure>
<p>Because the errors in the data are dominated by the scatter in the photometry induced by rotation, including the measured photometric errors make little difference to the uncertainties.</p>Joe Doed.r.young@qub.ac.ukThe reported errors in the ATLAS phase-curve fits appear to be coming out way too small. I’m calculating them as the square-root of the diagonals of the resulting co-variance matrix returned by scipy’s curve_fit. perr = np.sqrt(np.diag(pcov)) Here’s what the covariance matrix looks like for Kleopatra: [ [ 0.00066722 0.00066133] [ 0.00066133 0.00073213] ] Taking the sqrt of the diagonals gives the \(1\sigma\) errors in G and H: \(G_{err} = \sqrt{0.00066722}= 0.0258\), and \(H_{err} = \sqrt{0.00073213}= 0.0271\)Determining the H & G Parameters of ATLAS Asteroid Phase Curves2018-05-28T00:00:00+01:002018-05-28T00:00:00+01:00http://astronotes.co.uk/blog/2018/05/28/determining-the-h--g-parameters-of-atlas-asteroid-phase-curves<p>The <em>phase curve</em> of a solar-system body reveals how its brightness changes as a function of its solar phase-angle, α <a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"><sup>1</sup></a>. The smaller the phase angle, the greater fraction of the asteroid’s lit surface can be seen from earth (or wherever the observer happens to be) and therefore the brighter its measured absolute magnitude. At a phase angle of 0<sup>o</sup> the asteroid is fully illuminated.</p>
<figure>
<img src="https://farm1.staticflickr.com/954/27319815327_cfea1514c4_o.png" alt="Solar Phase Angle. Image Credit: Buchheim (2010)" id="solarphaseangle27319815327" title="solar phase angle. Image Credit: Buchheim (2010)" width="600" />
<figcaption>Solar Phase Angle. Image Credit: Buchheim (2010)</figcaption>
</figure>
<p>As the asteroid orbits the sun it’s not only the asteroid’s phase-angle that changes but the sun-asteroid and asteroid-earth distances are also in constant flux. This has lead to the concept of a <em>reduced magnitude</em> which takes account of these distances to normalise the apparent magnitudes of asteroid. This reduced magnitude is now a function of only the asteroid’s solar phase-angle and is often represented as <span class="math">\(H(\alpha)\)</span> to reflect this dependence.</p>
<!--summary-->
<p>Plotting the reduced magnitude <span class="math">\(H(\alpha)\)</span> against the phase-angle reveals the asteroids phase-curve.</p>
<figure>
<img src="https://farm5.staticflickr.com/4625/24783081857_ace0db88b1_o.png" alt="Phase Curve Of Mercury. Image Credit: Mallama et al. (2002)" id="phasecurveofmercury24783081857" title="phase curve of mercury" height="400" />
<figcaption>Phase Curve Of Mercury. Image Credit: Mallama et al. (2002)</figcaption>
</figure>
<p>The main goal behind fitting a phase-curve to asteroid photometry is to determine a value for <span class="math">\(G\)</span>, the so-called <em>slope-parameter</em>. The <span class="math">\(G\)</span> value is likely telling us something about the texture of the asteroid’s surface and its albedo (generally the higher the value of <span class="math">\(G\)</span> the higher the albedo) and hints at the class the asteroid belongs to<a href="#fn:2" id="fnref:2" title="see footnote" class="footnote"><sup>2</sup></a>.</p>
<h2 id="aphase-functionmodel">A Phase-Function Model</h2>
<p>Prior to 2012 the IAU had adopted the following 2-parameter phase function developed by Bowell et al. (1989) as a description of how an asteroid’s reduced magnitude relates to its phase-angle at any given apparition.</p>
<p><span class="math">\(H(\alpha) = H-2.5log[(1-G)\Phi_1(\alpha)+G\Phi_2(\alpha)]\)</span></p>
<p><strong>where</strong>:</p>
<p><span class="math">\(H\)</span> is the reduced magnitude at zero phase-angle. The <span class="math">\(\Phi\)</span> functions detail the scattering of light in the asteroids surface and <span class="math">\(G\)</span> is the slope-parameter describing the shape of the phase-curve.</p>
<p><span class="math">\(\Phi_n(\alpha) = W\phi_{nS}+(1-W)\phi_{nL} \\
W=exp[-90.56 \times tan^2(\alpha/2)] \\
\phi_{nS}=1-\frac{C_nsin\alpha}{0.119+1.1341sin\alpha - 0.754sin^2\alpha} \\
\phi_{nL}=exp[-A_n(tan(\alpha/2))^{B_n}]\)</span></p>
<p>and</p>
<p><span class="math">\(A_1 = 3.332 \\
B_1 = 0.631 \\
C_1 = 0.986\)</span></p>
<p>and</p>
<p><span class="math">\(A_2 = 1.862 \\
B_2 = 1.218 \\
C_2 = 0.238\)</span></p>
<p>Note there’s often a spike in asteroid brightness known as the <em>‘opposition effect’</em> as it approaches zero phase-angle. This surge in brightness is thought to be due to a combination if physical effects including <em>shadow hiding</em> and other <em>light scattering</em> mechanisms. And a final spanner to throw into the mix is that of rotation. An asteroid’s rotation as it orbits the sun also causes its brightness to periodically fluctuate and this change is superimposed onto the phase-curve.</p>
<h2 id="anexample">An Example</h2>
<p>Let’s move onto a concrete example of fitting a phase-curve to a set of asteroid data. I’m going to use ATLAS cyan-band data taken over the past few years of the asteroid Kleopatra (MPC#216). Using ephemerides generated for each of the photometry epochs it’s trivial to convert observed to reduced magnitudes.</p>
<p><span class="math">\(c(\alpha) = c - 5 \times log(RD)\)</span></p>
<p>where <span class="math">\(R\)</span> is the sun-asteroid distance and <span class="math">\(D\)</span> is the earth-asteroid distance.</p>
<p>Plotting reduced magnitude vs phase-angle gives us the observed phase-curve:</p>
<figure>
<img src="https://farm1.staticflickr.com/825/41292266785_93127862dc_o.png" alt="kleopatra" id="kleopatra41292266785" title="kleopatra" width="600" />
<figcaption>kleopatra</figcaption>
</figure>
<p>Using <a href="https://www.scipy.org/">scipy’s</a> <code>curve_fit</code>, a non-linear least squared fitting routine, alongside a simplified version of the Bowell et al. (1989) model phase-function:</p>
<p><span class="math">\(c(\alpha) = c_o-2.5log[(1-G)\Phi_1(\alpha)+G\Phi_2(\alpha)] \\
\Phi_{n}=exp[-A_n(tan(\alpha/2))^{B_n}]\)</span></p>
<p>we can fit a phase-curve to the data and output optimal values of <em>H</em> and <em>G</em>. Given the phase-function, an array of x-data (the independent variable, i.e. the phase angle) and an array of y-data (the dependent variable, i.e. our reduced magnitudes) <code>curve_fit</code> will iterate over various parameter values for <em>H</em> and <em>G</em> until the sum of the squares of the residuals between the fit and the input data is minimised. First an unweighted fit, where each data-point is treated equally:</p>
<figure>
<img src="https://farm1.staticflickr.com/951/42210724572_080450738a_o.png" alt="kleopatra unweighted fit" id="kleopatraunweightedfit42210724572" title="kleopatra unweighted fit" width="600" />
<figcaption>kleopatra unweighted fit</figcaption>
</figure>
<p>Next, I reran the fitting but this time I passed the measured uncertainties of the magnitudes to <code>curve_fit</code> and set <code>absolute_sigma=True</code> to indicate that these are absolute measured errors (not just relative errors). As you can see <code>curve_fit</code> does well to fit a non-linear least-squares curve to the data and outputs the optimal values for <em>H</em> and <em>G</em>. Alongside the optimised parameter values <code>curve_fit</code> outputs a covariance matrix. The diagonals of this matrix provide individual variances of the parameter estimates therefore we can calculate the 1-std errors in the parameter values as the square-root of variance.</p>
<figure>
<img src="https://farm1.staticflickr.com/828/28381043948_63619bfc08_o.png" alt="Kleopatra Simplified Phase Curve Fit" id="kleopatraphase_curvefit28381043948" title="kleopatra phase_curve fit" width="600" />
<figcaption>Kleopatra Simplified Phase Curve Fit</figcaption>
</figure>
<p>Note <strong>one huge caveat</strong> in the resulting parameter errors; <em>we have entirely neglected the effects of asteroid rotation until now</em>. Once we account of rotation in the error budget then these uncertainties will certainly grow.</p>
<h3 id="fittingthefullbowelletal.1989phase-function">Fitting the Full Bowell et al. (1989) phase-function</h3>
<p>Now using the full 2-parameter version of the Bowell et al. (1989) phase-function:</p>
<figure>
<img src="https://farm1.staticflickr.com/910/40448772630_644b225ccb_o.png" alt="Kleopatra. Using the full Bowell et al. (1989) phase function" id="kleopatrafullbowelletal.iauphasefunction40448772630" title="kleopatra full bowell et al. IAU phase function" width="600" />
<figcaption>Kleopatra. Using the full Bowell et al. (1989) phase function</figcaption>
</figure>
<p>You can see more of a kink in the phase-curve causing it to arch up to a brighter <em>c<sub>0</sub></em> value than when given the simplified version of the phase-function. I’d say this accounts for the opposition effect a little better.</p>
<p><strong>UPDATE May 31, 2018: The errors reported in these plot are not correct. I’ve done some better analysis of the errors reported by <code>curve_fit</code>. See <a href="/blog/2018/05/31/understanding-errors-from-atlas-phase-curve-fitting.html">here</a> for more details</strong></p>
<h2 id="anasideonscipyscurve_fitroutine">An Aside on Scipy’s <code>curve_fit</code> Routine</h2>
<p>The curve fit routine returns:</p>
<p><strong>popt</strong> : an array of the optimal values calculated for the function’s parameters that forms the moving least-squared fit to the input data.
<strong>pcov</strong> : a 2D array of the estimated covariance of parameter solutions (<code>popt</code>). To convert this matrix to 1-stdev parameter errors use <code>perr = np.sqrt(np.diag(pcov))</code>.</p>
<p>There are various parameters we can adjust to get a better fit but I found that (at least for my dataset) that altering the follow parameters made no difference:</p>
<table>
<colgroup>
<col style="text-align:left;"/>
<col style="text-align:left;"/>
</colgroup>
<thead>
<tr>
<th style="text-align:left;"> Parameter </th>
<th style="text-align:left;"> Effect of Change </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;"> <code>p0</code> - inital estimate of H and G </td>
<td style="text-align:left;"> No change to final values or errors </td>
</tr>
<tr>
<td style="text-align:left;"> <code>bounds</code> – bounds for H and G values </td>
<td style="text-align:left;"> No change to final values or errors </td>
</tr>
<tr>
<td style="text-align:left;"> <code>method</code> – least squares optimisation method </td>
<td style="text-align:left;"> No discernable change to final values or errors </td>
</tr>
</tbody>
</table>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>from earth the phase angle of a solar–system object is the angle traced by light travelling from the sun to the object to the earth <a href="#fnref:1" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
<li id="fn:2">
<p>although spectral data is really needed to determine asteroid type <a href="#fnref:2" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
</ol>
</div>Joe Doed.r.young@qub.ac.ukThe phase curve of a solar-system body reveals how its brightness changes as a function of its solar phase-angle, α 1. The smaller the phase angle, the greater fraction of the asteroid’s lit surface can be seen from earth (or wherever the observer happens to be) and therefore the brighter its measured absolute magnitude. At a phase angle of 0o the asteroid is fully illuminated. Solar Phase Angle. Image Credit: Buchheim (2010) As the asteroid orbits the sun it’s not only the asteroid’s phase-angle that changes but the sun-asteroid and asteroid-earth distances are also in constant flux. This has lead to the concept of a reduced magnitude which takes account of these distances to normalise the apparent magnitudes of asteroid. This reduced magnitude is now a function of only the asteroid’s solar phase-angle and is often represented as \(H(\alpha)\) to reflect this dependence. from earth the phase angle of a solar–system object is the angle traced by light travelling from the sun to the object to the earth  ↩Creating a Bright Star Matcher for Sherlock2018-05-04T00:00:00+01:002018-05-04T00:00:00+01:00http://astronotes.co.uk/blog/2018/05/04/creating-a-bright-star-matcher-for-sherlock<p>Stars saturate and bleed across many image pixels at the brighter end of the magnitude distribution. This can become an issue when it comes to correctly crossmatching and classifying these sources as image subtraction routines fail to difference the sources cleanly, resulting in a multiple artifacts being injected into the transient alert stream. Generally speaking, artefacts spread outward over a greater area from the source’s true centre the brighter the star is.</p>
<!--summary-->
<p>How can we compensate for this in Sherlock’s crossmatching algorithms so as to mitigate the flood of false-positive transient alerts generated by these bright stars? The solution we landed on is to generate a pseudo-bright-star mask that scales with the catalogued source brightness.</p>
<h2 id="investigation">Investigation</h2>
<p>To generate a dataset to use for my investigations I did some crossmatching to extract out a bunch of ATLAS difference detections that are likely associated with bright stars in the Guide-Star Catalogue. The query took all GSC stars brighter than <span class="math">\(V=16\)</span>, crossmatched all ATLAS difference detections within 5 arcmin and calculated the mean angular separation of the matched sets for each star.</p>
<p>Plotting the mean-separation vs GSC magnitude reveals a clear population of ‘transients’ resulting from bright star difference artefacts (the clustered at the bottom of the plot) and those probably resulting from matching non-associated sources as the separation increases (top cluster). The saturation limit for ATLAS is reported as <span class="math">\(r \sim 12.5\)</span>, which is in general agreement with the artefact cluster in this plot as you see matching straying above <span class="math">\(3''\)</span> at around this limit.</p>
<figure>
<img src="https://farm1.staticflickr.com/824/28014220958_9caebcaa18_o.png" alt="GSC-ATLAS Matched Populations" id="gsc-atlasmatchedpopulations28014220958" title="GSC-ATLAS Matched Populations" width="600" />
<figcaption>GSC-ATLAS Matched Populations</figcaption>
</figure>
<p>It’s clear there’s some overlap between these populations so whatever line we draw between the two populations in magnitude/separation space will result in some contamination of mismatched sources in our selected bright-star population and visa-versa. From our experience of eye-balling many transient candidates, the trade-off between wading through thousands of false-positive transients to find a handful of real transients and saving hours of work by <em>automatically</em> <s>trashing</s> parking many more bright-star artefacts but sacrificing these few real transients is definitely worth it.</p>
<p>With this in mind we’ve settled on using the inequality for matching ‘transients’ against catalogued bright-stars (visualised in the plot below):</p>
<p><span class="math">\[separation < 10^{3.7-0.2 \times mag}\]</span></p>
<figure>
<img src="https://farm1.staticflickr.com/868/40079371180_ab2ffa0172_o.png" alt="Sherlock Bright Star Cut" id="sherlockbrightstarcut40079371180" title="Sherlock Bright Star Cut" width="600" />
<figcaption>Sherlock Bright Star Cut</figcaption>
</figure>
<h2 id="addingthebrightstarmatcherintoasherlocksearch">Adding The Bright Star Matcher into A Sherlock Search</h2>
<p>To add a bright-star match into a Sherlock search algorithm, add the following settings to a point-source search module (SDSS in this example):</p>
<pre><code class="yaml">sdss star:
database table: tcs_view_star_sdss_photo_stars_galaxies_dr12
mag column: _r
bright:
mag limit: 16.
angular radius arcsec: 100.0
synonym: VS
association: BS
...
</code></pre>
<p>This search requests that Sherlock switch on the bright-star check for point-sources brighter than <span class="math">\(r=16^{th}\)</span>, using an initial sweep radius of <span class="math">\(100.0''\)</span>. Matches collected in the initial sweep are then matched using the magnitude-separation inequality above and positive matches given the appropriately named ‘BS’ classification.</p>Joe Doed.r.young@qub.ac.ukStars saturate and bleed across many image pixels at the brighter end of the magnitude distribution. This can become an issue when it comes to correctly crossmatching and classifying these sources as image subtraction routines fail to difference the sources cleanly, resulting in a multiple artifacts being injected into the transient alert stream. Generally speaking, artefacts spread outward over a greater area from the source’s true centre the brighter the star is.How to … Use Orbfit5.0 to Generate Ephemerides for Asteroids and Comets2017-10-12T14:39:41+01:002017-10-12T14:39:41+01:00http://astronotes.co.uk/blog/2017/10/12/Using-Orbfit5.0-to-Generate-Ephemerides-for-Asteroids-and-Comets<p>OrbFit comes with four main programs <code>Orbfit</code>, <code>Fitobs</code>, <code>Catpro</code> and <code>Bineph</code>. In this tutorial we’re focusing on OrbFit’s title track, <code>Orbfit</code>, which can reportedly run in a <em>non-interactive, batch-mode</em> to perform a various operations on the orbits of asteroids and comets. However, in my experience so far orbfit neither works in non-interactive or batch-mode straight out of the box, but I’ve managed to generate a workflow that gets us part-way there.</p>
<!--summary-->
<h2 id="aworkspacewithinputfiles">A Workspace with Input Files</h2>
<p>To start using Orbfit, you’ll need to generate/download some files containing the input data required. The 2 types<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"><sup>1</sup></a> of input files required are:</p>
<ol>
<li>An <strong>observation</strong> file stored in a specified <code>obsdir</code> directory (extensions include <code>.rwo</code>, <code>.obs</code>, <code>.rad</code>)</li>
<li>An <strong>orbital elements</strong> file<a href="#fn:2" id="fnref:2" title="see footnote" class="footnote"><sup>2</sup></a>.</li>
</ol>
<p>As well as the input files, you will need to write an options file (with extension <code>.oop</code>) which tells OrbFit where the input files<a href="#fn:3" id="fnref:3" title="see footnote" class="footnote"><sup>3</sup></a> can be found <em>and</em> what exactly you want OrbFit to do.</p>
<p>Let’s go ahead and create a workspace with an options file and some input files. Make a directory somewhere called <code>orbfit-workspace</code> and change into it:</p>
<pre><code class="bash">$ mkdir ~/Desktop/orbfit-workspace
$ cd ~/Desktop/orbfit-workspace
</code></pre>
<p>Now download the Lowell Observatory <code>astorb</code> flavour of orbital elements from <a href="ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz">here</a> and uncompress.</p>
<pre><code class="bash">wget ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz
gunzip astorb.dat.gz
</code></pre>
<p>Finally grab my template options file and dummy observation files from this <a href="https://gist.github.com/thespacedoctor/f97ce22bbe2d6d2889de74c73089cf5d">gist</a> (click on the ‘Download ZIP’ button). Now you should have 3 files in your workspace:</p>
<pre><code class="bash">$ ls
astorb.dat
dummy.obs
orbfit-template-run-options.oop
</code></pre>
<h2 id="gettingorbfittoruninnon-interactivemode">Getting OrbFit to Run in Non-Interactive Mode</h2>
<p>The <code>orbfit.x</code> executable seems to want to run in interactive-mode. If you run the command <code>orbfit.x</code>, it then prompts you for the <em>Run Name</em> which is the name of your options file without the extension, i.e. <code>orbfit-template-run-options</code>. To get round this interactiveness you can run the command like so:</p>
<pre><code class="bash">$ echo "orbfit-template-run-options" | orbfit.x
</code></pre>
<p>which gets orbit to run straight away:</p>
<pre><code class="bash">$ orbfit.x
Run name =
orbfit-template-run-options
Run name = orbfit-template-run-options
JPL planetary ephemerides DE413
number of perturbers = 0
binary ephemerides file= CPV
perturbing asteroids used: none
ngr_opt = F
No .rwo file, reading .obs and/or .rad files.
input_obs: 1 obs in ./dummy.obs
Using .rwo file, but checking .obs,.rad for update.
input_obs: 1 obs from ./dummy.rwo
input_obs: 1 obs from ./dummy.obs
There are no updates in .obs or .rad files.
Scanning file "astorb.dat" (format: BA2)
Semimajor axis = 3.1166357900000001E+00 au
Eccentricity = 0.115222750000000
Inclination = 12.5288100000000 deg
Long. of node = 148.0323380000000 deg
Arg. of pericenter = 357.0506910000000 deg
Mean anomaly = 39.3705710000000 deg
Scanning file "astorb.dat" (format: BA2)
Semimajor axis = 3.1166357900000001E+00 au
Eccentricity = 0.115222750000000
Inclination = 12.5288100000000 deg
Long. of node = 148.0323380000000 deg
Arg. of pericenter = 357.0506910000000 deg
Mean anomaly = 39.3705710000000 deg
ORBFIT: propagation of orbital elements
write_elems: ndim.ne.nd 32767 6
write_elems: ndim.ne.nd 32767 6
ORBFIT: generating ephemerides
</code></pre>
<p>and you will find an ephemeris file has been created called <code>orbfit-template-run-options.oep</code> containing the following:</p>
<pre><code class="text">Ephemeris for object 1999 YQ10
Origin of orbital elements: read from file "astorb.dat" at record 49980
Equatorial coordinates App. motion
Date Hour MJD RAJ2000 DEC Mag Delta R SolEl Phase Glat RA/dt DEC/dt
(UTC) (UTC) h m s d ' " (au) (au) (deg) (deg) (deg) arcsec/s arcsec/s
=========== ====== ============ ============= ============ ===== ======= ======= ====== ====== ===== ========== ==========
12 Jun 2017 0.000 57916.000000 7 40 56.720 +19 2 19.41 21.51 3.2776 2.4865 -32.87 12.81 19.21 1.7256E-02 -2.6170E-03
Ephemeris for object 1999 YQ10
Origin of orbital elements: read from file "astorb.dat" at record 49980
Equatorial coordinates App. motion
Date Hour MJD RAJ2000 DEC Mag Delta R SolEl Phase Glat RA/dt DEC/dt
(UTC) (UTC) h m s d ' " (au) (au) (deg) (deg) (deg) arcsec/s arcsec/s
=========== ====== ============ ============= ============ ===== ======= ======= ====== ====== ===== ========== ==========
12 Jun 2017 0.000 57916.000000 7 40 56.720 +19 2 19.41 21.51 3.2776 2.4865 -32.87 12.81 19.21 1.7256E-02 -2.6170E-03
</code></pre>
<p>Note the duplication of results due to the fact that the options file lists ‘1999 YQ10’ as both object 1 and 2.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>There is another type of input file requried, the <strong><code>jpleph</code> binary ephemerides</strong> file, but this should have been generated at the install stage. This JPL ephemerides file provides the dynamic model of the Solar System used for for orbit propagation. <a href="#fnref:1" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
<li id="fn:2">
<p>can contain either a set of six numbers defining the orbit of one object at some epoch, or a list of the orbital elements for many asteroids and/or comets (e.g. <code>astorb.dat</code>) <a href="#fnref:2" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
<li id="fn:3">
<p>note there are hardwired default input–filenames and options so in many cases you will just be tweaking whatever values you need to for your specific use–case. <a href="#fnref:3" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
</ol>
</div>Joe Doed.r.young@qub.ac.ukOrbFit comes with four main programs Orbfit, Fitobs, Catpro and Bineph. In this tutorial we’re focusing on OrbFit’s title track, Orbfit, which can reportedly run in a non-interactive, batch-mode to perform a various operations on the orbits of asteroids and comets. However, in my experience so far orbfit neither works in non-interactive or batch-mode straight out of the box, but I’ve managed to generate a workflow that gets us part-way there.Crafting an Orbfit 5 Options File2017-10-12T13:03:03+01:002017-10-12T13:03:03+01:00http://astronotes.co.uk/blog/2017/10/12/Crafting-an-Orbfit-5-Options-File<h2 id="defaultvsuseroptionsfiles">Default vs User Options Files</h2>
<p>Orbfit reads its options from multiple setting files on your machine. Let’s call these the <em>default</em> settings and the <em>user</em> settings. The <em>default</em> settings are read first add can be found in the <code>lib/</code> folder of wherever you compiled Orbfit on your machine. For me these files are found at <code>~/Orbfit5.0/lib/*.def</code></p>
<pre><code class="bash">$ cd ~/Orbfit5.0/lib/
$ ls *.def
bineph.def fitdeb.def fitobs.def impcor.def orbfit.def propag.def reject.def
</code></pre>
<!--summary-->
<p>Your <em>user</em> settings have a <code>.oop</code> (<em>O</em>rbfit <em>OP</em>tions) extension and are found in your current working directory and these are read after the default settings, over-riding any common options the two file may have, i.e. User settings trump default settings.</p>
<h2 id="optionsets">Option Sets</h2>
<p>There are various sets of options, each written as a keyword followed by a period:</p>
<ul>
<li><code>operations.</code> - usage mode options</li>
<li><code>object1.</code> & <code>object2.</code> - object specific options</li>
<li><code>output.</code> - orbital element options</li>
<li><code>ephem.</code> - ephemeris generation options</li>
<li><code>propag.</code> - orbit propagation options</li>
<li><code>ident.</code> - orbit identification options (I don’t report on these option in this post)</li>
<li><code>lsfit.</code> - least squared fitting of orbits options (I don’t report on these option in this post)</li>
</ul>
<h3 id="usagemodeoptions">Usage Mode Options</h3>
<p>Basically you switch these options on and off depending on your use-case. There are 3 modes for each option:</p>
<ul>
<li><code>0</code>: off</li>
<li><code>1</code>: only perform task if needed</li>
<li><code>2</code>: on</li>
</ul>
<pre><code class="fortran">operations.
.init_orbdet = 0|1|2
.diffcor = 0|1|2
.ident = 0|1
.ephem = 0|1
</code></pre>
<dl>
<dt><code>.init_orbdet</code></dt>
<dd> calcualte and initial orbit with Guass' method. <strong>Default:</strong> <em>1</em></dd>
<dt><code>.diffcor</code></dt>
<dd> perform some differential corrections of the orbital elements with least square fitting <strong>Default:</strong> <em>1</em></dd>
<dt><code>.ident</code></dt>
<dd> try to identify a single orbit to the observations of both objects. <strong>Default:</strong> <em>1</em></dd>
<dt><code>.ephem</code></dt>
<dd> generate an ephemeris for the object(s). <strong>Default:</strong> <em>0</em></dd>
</dl>
<h3 id="objectsoptions">Objects Options</h3>
<pre><code class="fortran">object1.
.name = <string>
.inc_name = <string>
.obs_fname = <string>
.obs_dir = <string>
.inc_files = <string>
</code></pre>
<dl>
<dt><code>.name</code></dt>
<dd> the name for the object; can be used in naming of some input and output files. Note you can have several different run-names for the same object. <strong>Default:</strong> <em>name of run.</em></dd>
<dt><code>.inc_name</code></dt>
<dd> object name in orbital elements file. <strong>Default:</strong> <em>same as <code>.name</code></em></dd>
<dt><code>.obs_fname</code></dt>
<dd> the basename of the observation file (without <code>.obs</code> extension). <strong>Default:</strong> <em>same as <code>.name</code></em></dd>
<dt><code>.obs_dir</code></dt>
<dd> location of the observation file. <strong>Default:</strong> <em><code>./</code> i.e. cwd</em></dd>
<dt><code>.inc_files</code></dt>
<dd> initial conditions file (orbital elements). Can be in <em>astorb.dat</em> [BA], <em>MPC</em> [MPC-A] or the native <em>orbfit</em> [OEF] format. Note only the first match in the any set of orbital elements files is used. Speed up the search by explicitly stating the format of the input file by appending a format codename. <strong>Default:</strong> <em>None</em></dd>
</dl>
<h3 id="orbitalelementsoutputoptions">Orbital Elements Output Options</h3>
<pre><code class="fortran">output.
.epoch = <date-time>
.elements = CAR|EQU|EQP|KEP
output_files.
.elem = <string>
</code></pre>
<dl>
<dt><code>.epoch</code></dt>
<dd> the epoch at which orbital elements are to be calculated. Can be in many formats (I prefer MJD). Example: <code>MJD 50982.94143519 UTC</code>. <strong>Default:</strong> <em>orbfit will decide.</em></dd>
<dt><code>.elements</code></dt>
<dd> the type of orbital elements to output. <code>CAR</code> for cartesian, <code>EQU</code> for equinoctial, <code>EQP</code> for equinoctial for highly inclined orbits, and <code>KEP</code> for keplerian. <strong>Default:</strong> <em><code>EQU</code></em></dd>
<dt><code>output_files.elem</code></dt>
<dd> where to write calculated orbital elements to. <strong>Default:</strong> <em><code><name of run>.oel</code></em></dd>
</dl>
<h3 id="ephemerisgenerationoptions">Ephemeris Generation Options</h3>
<pre><code class="fortran">ephem.
.objects = 1|2|3 (or any combination)
.epoch.start = <date-time>
.epoch.end = <date-time>
.step = <float>
.obscode = <string>
.timescale = UT1|TAI|UTC|TDT
.fields = <string>
</code></pre>
<dl>
<dt><code>.objects</code></dt>
<dd> the ‘list’ of objects which to calculate an ephemeris for. The ‘list’ include 1 and/or 2 relating to objects 1 and 2. You can also use 3 for the result of an identified orbit from both objects (3). <strong>Default:</strong> <em>1 2 3</em></dd>
<dt><code>.epoch.start</code></dt>
<dd> the start epoch of ephemeris to be calculated. Can be in many formats (I prefer MJD). Example: <code>MJD 50982.94143519 UTC</code>. <strong>Default:</strong> <em>orbfit will decide.</em></dd>
<dt><code>.epoch.end</code></dt>
<dd> the end epoch of ephemeris to be calculated. Can be in many formats (I prefer MJD). Example: <code>MJD 50982.94143519 UTC</code>. <strong>Default:</strong> <em>orbfit will decide.</em></dd>
<dt><code>.step</code></dt>
<dd> the ephemeris step-size in days <strong>Default:</strong> <em>1.0</em></dd>
<dt><code>.obscode</code></dt>
<dd> observatory code for ephemeris fro topocentric correction. <strong>Default:</strong> <em>500, i.e. geocentric</em></dd>
<dt><code>.timescale</code></dt>
<dd> the timescale ephemeris is to be reported in. <code>UT1</code>, <code>TAI</code>, <code>UTC</code> or <code>TDT</code>. <strong>Default:</strong> <em>TDT</em></dd>
<dt><code>.fields</code></dt>
<dd> a list of comma-separated keywords, the values of which you want reported in the ephemeris. Options include <code>cal</code> calendar date, <code>mjd</code>, <code>coord</code> (RA and DEC), <code>mag</code> magnitude, <code>delta</code> distance from the Earth, <code>r</code> distance from the Sun, <code>elong</code> Sun elongation angle, <code>phase</code> Sun phase angle, <code>glat</code> galactic latitude, <code>appmot</code> apparent motion and <code>skyerr</code> sky plane error. <strong>Default:</strong> <em>‘cal,coord,delta,r,elong,phase,mag’</em></dd>
</dl>
<pre><code class="fortran">ephem.appmot.
.format = <string>
.units
</code></pre>
<dl>
<dt><code>.format</code></dt>
<dd> format of apparent motion ‘rectangular’ (1) or ‘polar’ (2).</dd>
<dt><code>.units</code></dt>
<dd> velocity units. Angular unit can <code>rad</code>, <code>deg</code>, <code>arcmin</code> or <code>arcsec</code>. Time units can be <code>d</code>, <code>h</code>, <code>min</code>, <code>s</code>. Example <code>arcsec/min</code>.</dd>
</dl>
<h3 id="orbitpropagationoptions">Orbit Propagation Options</h3>
<p>I list only the most important options here. To see the rest of the options take a look at the <code>lib/propag.def</code> file in you local install of Orbfit.</p>
<pre><code class="fortran">propag.
.output_des = <boolean>
.ab_mag= = <boolean>
.iast = <int>
.ilun = 0|1
.imerc = 0|1
.iplut = 0|1
.irel = 0|1
.filbe = <string>
.iclap = 0|1
.iaber = 0|1
.istat = 0|1
.npoint= <int>
</code></pre>
<dl>
<dt><code>.output_des</code></dt>
<dd> Output in DES format? <strong>Default:</strong> <em>False - <code>.rwo</code>format</em></dd>
<dt><code>.ab_mag</code></dt>
<dd> report AB mags <strong>Default:</strong> <em>False</em></dd>
<dt><code>.iast</code></dt>
<dd> number of massive asteroids to use <strong>Default:</strong> <em>0</em></dd>
<dt><code>.ilun</code></dt>
<dd> include moon <strong>Default:</strong> <em>0</em></dd>
<dt><code>.iplut</code></dt>
<dd> include pluto <strong>Default:</strong> <em>0</em></dd>
<dt><code>.imerc</code></dt>
<dd> include mercury <strong>Default:</strong> <em>1</em></dd>
<dt><code>.irel</code></dt>
<dd> account for general relativity <strong>Default:</strong> <em>1</em></dd>
<dt><code>.filbe</code></dt>
<dd> asteroid ephemerides file <strong>Default:</strong> <em>CPV</em></dd>
<dt><code>.iclap</code></dt>
<dd> include close approach <strong>Default:</strong> <em>1</em></dd>
<dt><code>.iaber</code></dt>
<dd> account for aberration effects <strong>Default:</strong> <em>1</em></dd>
<dt><code>.istat</code></dt>
<dd> add topocentric correction <strong>Default:</strong> <em>1</em></dd>
<dt><code>.npoint</code></dt>
<dd> the minimum number of data points required for a close approach calculations <strong>Default:</strong> <em>100</em></dd>
</dl>Joe Doed.r.young@qub.ac.ukDefault vs User Options Files Orbfit reads its options from multiple setting files on your machine. Let’s call these the default settings and the user settings. The default settings are read first add can be found in the lib/ folder of wherever you compiled Orbfit on your machine. For me these files are found at ~/Orbfit5.0/lib/*.def $ cd ~/Orbfit5.0/lib/ $ ls *.def bineph.def fitdeb.def fitobs.def impcor.def orbfit.def propag.def reject.defAn Astronomer’s Guide to .*Conda2017-10-04T13:55:54+01:002017-10-04T13:55:54+01:00http://astronotes.co.uk/blog/2017/10/04/An-Astronomer's-Guide-to-dotstar-Conda<p>The land of Conda, Anaconda, Miniconda, Astroconda, AfishcalledConda … can be very confusing if you’re just starting out trying to work out what the <enter expletive> each of these service are and which ones you personally need to install. Let’s begin with some definitions that will hopefully help us out later on.</p>
<!--summary-->
<dl>
<dt>Package Manager</dt>
<dd> A package manager is a tool that automates the process of installing, updating, and removing packages. Think <code>apt</code> or <code>yum</code>. Here’s what wikipedia has to say:</dd>
</dl>
<blockquote>
<p>A package manager or package management system a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer’s operating system in a consistent manner. <a href="https://en.wikipedia.org/wiki/Package_manager">Wikipedia</a></p>
</blockquote>
<dl>
<dt>Channel</dt>
<dd> a channel is basically a remote repository containing software packages that can be installed by a package manager.</dd>
<dt>Distribution</dt>
<dd> A software distribution is a pre-built and pre-configured collection of packages that can be installed and used on a system.</dd>
<dt>Isolated or Virtual Environments</dt>
<dd> a dedicated space for your software project, allowing for it to have its own dependencies, regardless of what dependencies every other project has.</dd>
<dt>Software Stack</dt>
<dd> A ‘stack’ is a collection of software designed to target the various use-cases of an end-user</dd>
</dl>
<h2 id="whatsthedifferencebetweencondaanacondaminicondaandastroconda">What’s the Difference between Conda, Anaconda, Miniconda and Astroconda?</h2>
<h3 id="conda">Conda</h3>
<p>Conda is both <strong>a package manager</strong> and an <strong>isolated-environment manager</strong>. As a package manager it’s designed to build and manage software of any language (i.e. it’s not python specific).</p>
<h3 id="anacondaminiconda">Anaconda & Miniconda</h3>
<p>Anaconda is a software <strong>distribution</strong>, but note that Conda and Python (2.7 or 3.*) are packaged <em>with</em> Anaconda. The distribution also includes the <a href="https://docs.anaconda.com/anaconda/packages/py2.7_osx-64">binaries for several hundred python packages</a>, so when you install Anaconda you’re also installing most of all the major scientific python-packages you’ll probably need at some point in the future. This is a real time-saver!</p>
<p>Miniconda is the stripped-down, lightweight version of Anaconda and contains only a Conda root environment with Python (again 2.7 or 3.*).</p>
<h3 id="astroconda">Astroconda</h3>
<p>AstroConda a third-party Conda <strong>channel</strong> hosting a suite of software provided and maintained by <a href="http://www.stsci.edu/portal/">STScI</a>. The channel’s software is compatible with both of the 2 and 3 variants of *Conda and contains two types of their software stack:</p>
<ol>
<li>Standard Software Stack (without IRAF)</li>
<li>Legacy Software Stack (with IRAF)</li>
</ol>
<p>Note the Legacy Software Stack is the full suite of STScI software and also includes an IRAF/PyRAF environment. Due to the limitations of IRAF it’s only available for Python 2.7.</p>
<h2 id="asanastronomerwhatshouldiinstall">As an Astronomer, What Should I install?</h2>
<p>If you work with Python packages which rely on external dependencies (like <em>NumPy</em>, <em>SciPy</em>, and <em>Matplotlib</em>) I strongly advice installing Anaconda over Miniconda and you probably want to install the Python 2.7 version of Anaconda. Installing the Python 2.7 version means that any isolated Conda environments you create will default to Python 2.7, but this doesn’t stop you creating Python 3.* environments (you just need to remember to <a href="https://conda.io/docs/user-guide/tasks/manage-environments.html#id1">request the python version upon creation</a>).</p>
<p>If you work with IRAF, or other tools that require IRAF, then AstroConda is currently the most painless way of installing it (and it’s getting evermore painful!).</p>
<h2 id="installinganacondaastroconda">Installing Anaconda & Astroconda</h2>
<h3 id="anaconda">Anaconda</h3>
<p>To download the Anaconda installer, head over to the <a href="https://docs.continuum.io/anaconda/install/">Continuum Analytics website</a> and navigate to the relevant installation guide for your operating system. A link to the graphical installer should be found near the top of the page.</p>
<figure>
<img src="https://farm5.staticflickr.com/4397/36185215194_f9fa1a367d_o.png" alt="macOS installers" id="1" title="macOS installers" width="600" />
<figcaption>macOS installers</figcaption>
</figure>
<p>Click to download the Python 2.7 version of Anaconda. The installer download weighs in at about <sub>450MB</sub> so may take some time to download if you are on a ropey internet connection. From here on in I’m assuming you’re working with macOS, but the install instructions should be similar with other OS flavours.</p>
<p>Once download, open the installer package and click through all of the permission and licence agreements
alerts and get the installation going. On my mac (running macOS Sierra v10.12.6) the install took <sub>6</sub>.5 minutes.</p>
<figure>
<img src="https://farm5.staticflickr.com/4404/37021101895_41af80b6e5_o.png" alt="Anaconda2 Successful Install" id="2" title="Anaconda2 Successful Install" width="600" />
<figcaption>Anaconda2 Successful Install</figcaption>
</figure>
<p>If you choose to install anaconda in the default location you will find it in <code>~/anaconda</code> with a directory structure looking similar to this:</p>
<figure>
<img src="https://farm5.staticflickr.com/4427/37021624255_16bcd6efc3_o.png" alt="anaconda directory" id="3" title="anaconda directory" width="600" />
<figcaption>anaconda directory</figcaption>
</figure>
<p>My total install eats up about 1.5GB on disk.</p>
<p>The install of Anaconda will have edited your <code>~.bash_profile</code> file to add the Anaconda executables to your path:</p>
<pre><code class="bash">export PATH="/Users/Bob/anaconda/bin:$PATH"
</code></pre>
<p>Note if Anaconda is sourced in this manor then Anaconda’s python instance will become the ‘default’ python as it will be the first found on your path. I prefer to have my native python install as my default python, and only choosing to use the conda python instance(s) by activating a conda environment. To fix this replace the anaconda added export above with the following alias<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"><sup>1</sup></a>:</p>
<pre><code class="bash">alias anaconda-init='source /Users/Bob/anaconda/etc/profile.d/conda.sh'
</code></pre>
<p>This way you can keep your native python as default, and choose to run the command <code>anaconda-init</code> when you want to switch to anaconda’s python instead.</p>
<p>To verify your conda install and make sure it’s setup correctly in you path run the command:</p>
<pre><code class="bash">$ conda --version
conda 4.5.11
</code></pre>
<h4 id="guivscommand-line">GUI vs Command-Line</h4>
<p>Anaconda comes with a useful application called <code>Anaconda-Navigator</code> that can be launched from Finder or via the terminal with the command:</p>
<pre><code class="bash">anaconda-navigator
</code></pre>
<figure>
<img src="https://farm5.staticflickr.com/4429/36186146074_fdb5cc971b_o.png" alt="anaconda naviagtor home" id="5" title="anaconda naviagtor home" width="600" />
<figcaption>anaconda naviagtor home</figcaption>
</figure>
<p>Within the navigator you can install, uninstall and upgrade packages, manage your conda environments, start a jupyter notebook environment, add and remove channels and a bunch of other tasks. You also get access to some great tutorials and links to various community forums and events.</p>
<p>Although I prefer to use the command-line in most cases, I appreciate the visualisation provided by the Navigator. I can see at a glance which conda packages need updated and what environments I have setup.</p>
<p>From here on in I will show you how to perform tasks via the command-line and leave it to you to work out how to do it via the Navigator if you prefer to do it that way.</p>
<h3 id="astroconda">Astroconda</h3>
<p>Now its time to add the AstroConda <em>channel</em> to Conda<a href="#fn:2" id="fnref:2" title="see footnote" class="footnote"><sup>2</sup></a>. Open your terminal and run the command:</p>
<pre><code class="xxx">$ conda config --add channels http://ssb.stsci.edu/astroconda
</code></pre>
<p>We can now install the AstroConda software stack found in the AstroConda channel. I’d advice installing IRAF & PyRAF alongside the STScI Python stack inside a dedicated isolated conda environment. You can do so with one command:</p>
<pre><code class="bash">conda create -n astroconda python=2.7 iraf-all pyraf-all stsci
</code></pre>
<p>Note the <code>python=2.7</code> is the default if you have installed Astroconda 2, but you will need this option if you want your environment to useje Python 2.7 under an Anaconda 3 install. You will be asked along the way to verify that you wish to install all of the package included in the install. Select <code>Y</code> to confirm. The install of IRAF/PyRAF & the STScI Python stack took about 7 mins on my machine and used up about 3.5GB of space.</p>
<p>Once installed run the following command to activate the <code>astroconda</code> conda environment:</p>
<pre><code class="bash">source activate astroconda
</code></pre>
<p>To see all of the <sub>250</sub> packages now installed and ready to be used in this environment, run the command:</p>
<pre><code class="bash">conda list
</code></pre>
<h2 id="conflictswithpythonvirtualenvwrapper">Conflicts with Python Virtualenvwrapper</h2>
<p>Once I installed Conda I discovered the distinct but identically named <code>deactivate</code> commands called by virtualenvwrapper and conda where clashing with one another. For example:</p>
<pre><code class="bash">$ workon breaker
Error: deactivate must be sourced. Run 'source deactivate'
instead of 'deactivate'.
</code></pre>
<p>I’ll not give the details here, but <a href="https://stackoverflow.com/a/42014049/8608595">this solution worked perfectly</a> for me.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>I also move the export command from my <code>.bash_profile</code> to my <code>.bashrc</code> file as that's they way I roll. <a href="#fnref:1" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
<li id="fn:2">
<p>this simply adds the channel URL to a config file in your home directory at <code>~/.condarc</code>. <a href="#fnref:2" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
</ol>
</div>Joe Doed.r.young@qub.ac.ukThe land of Conda, Anaconda, Miniconda, Astroconda, AfishcalledConda … can be very confusing if you’re just starting out trying to work out what the <enter expletive> each of these service are and which ones you personally need to install. Let’s begin with some definitions that will hopefully help us out later on.How to … Install OrbFit 5.0 on macOS2017-09-15T16:52:44+01:002017-09-15T16:52:44+01:00http://astronotes.co.uk/blog/2017/09/15/Installing-OrbFit-5.0-on-macOS<p><a href="http://adams.dm.unipi.it/orbfit/">OrbFit</a> is a software package used to determine the orbits of asteroids written by the <a href="http://adams.dm.unipi.it/orbfit/OrbFit/doc/help.html#authors">OrbFit Consortium</a>. But it’s very sparsely documented, and can be a little tricky to install, never-mind learning how to use it.</p>
<p>Here’s my guide to getting it to successfully install on my mac (macOS Sierra).</p>
<!--summary-->
<h2 id="acondaenvironmentwithalovelyfortrancompiler">A Conda Environment with a Lovely Fortran Compiler</h2>
<p>Anaconda/Miniconda are going to greatly reduce the headache of having to install OrbFit, so make sure you have one or the other installed on your mac. There are plenty of tutorials just a google away, the <a href="https://docs.continuum.io/anaconda/install/mac-os">Anaconda docs are excellent</a> and I even wrote up my <a href="http://astronotes.co.uk/blog/2017/10/04/An-Astronomer's-Guide-to-dotstar-Conda.html">own guide and tutorial here</a>.</p>
<p>Once you have .*Conda installed, go ahead and create a new environment within which to install Orbfit. I’m calling mine <code>orbfit5.0</code> in case I want install an older/newer version of OrbFit at any point.</p>
<pre><code class="bash">$ conda create -n orbfit5.0
Fetching package metadata ...............
Solving package specifications:
Package plan for installation in environment /Users/Dave/anaconda/envs/orbfit5.0:
Proceed ([y]/n)? y
# To activate this environment, use:
# > source activate orbfit5.0
#
# To deactivate this environment, use:
# > source deactivate orbfit5.0
</code></pre>
<p>Now activate your new environment:</p>
<pre><code class="bash">$ source activate orbfit5.0
</code></pre>
<p>As OrbFit is written in Fortran you will need a suitable compiler to install the code. Go ahead and install one into your environment:</p>
<pre><code class="bash">$ conda install -c uvcdat gfortran
Fetching package metadata .................
Solving package specifications: .
Package plan for installation in environment /Users/Dave/anaconda/envs/orbfit5.0:
The following NEW packages will be INSTALLED:
cloog: 0.18.0-0
gfortran: 4.9.3-1 uvcdat
gmp: 6.1.0-0
isl: 0.15-0
mpc: 1.0.3-0
mpfr: 3.1.5-0
Proceed ([y]/n)? y
</code></pre>
<p>Typing <code>gfortran -v</code> reveals that I’ve just installed the gcc v4.9.3 version of the compiler. Yours maybe a more recent version.</p>
<h2 id="download">Download</h2>
<p>The next thing to do is download the Orbfit distribution. You can find the latest distribution here:</p>
<p><a href="http://adams.dm.unipi.it/orbfit/OrbFit/">http://adams.dm.unipi.it/orbfit/OrbFit/</a></p>
<p>As of writing this tutorial, <a href="http://adams.dm.unipi.it/orbfit/OrbFit5.0.5.tar.gz">OrbFit v5.0.5</a> was the latest version, and you can download the compressed version of that distribution from <a href="http://adams.dm.unipi.it/orbfit/OrbFit5.0.5.tar.gz">here</a>. Unpack the code somewhere sensible.</p>
<pre><code class="bash">mkdir ~/Orbfit5.0
mv ~/Downloads/OrbFit5.0.5.tar.gz ~/Orbfit5.0
cd ~/Orbfit5.0
tar -xvf OrbFit5.0.5.tar.gz
</code></pre>
<h2 id="install">Install</h2>
<h3 id="configureandmakeorbfit">Configure and Make OrbFit</h3>
<p>Once unpacked, jump into the directory, wherever you’ve placed it (let’s assume it’s on your desktop):</p>
<pre><code class="bash">$ cd ~/Orbfit5.0
</code></pre>
<p>Configure <code>make</code> to perform an optimised compile with gfortran:</p>
<pre><code class="bash">$ ./config -O gfortran
</code></pre>
<p>Next we have to tweak the Make flags so the compiler knows where to find the conda library files. Open the file <code>./src/make.flags</code> and change the line <code>FFLAGS= -O3 -I../include</code> to <code>FFLAGS= -O3 -I../include -Wl,-rpath,${CONDA_PREFIX}/lib</code>.</p>
<p>Now you can compile the code:</p>
<pre><code class="bash">$ make
</code></pre>
<p>If at any point in this stage you slip-up or something goes wrong, try a <code>make clean</code> and begin again from the start of the configure and make processed.</p>
<p>At this point you either want the add Orbfit’s <code>./bin</code> directory to your path. Open your <code>~/.bashrc</code>, or equivalent file for your shell, and append:</p>
<pre><code class="bash"># ORBFIT
export PATH="$PATH:$HOME/Orbfit5.0/bin"
</code></pre>
<h3 id="buildingajplephemeridesbinary">Building a JPL Ephemerides Binary</h3>
<p>Before you can use any of the OrbFit programs we need to generate a binary JPL ephemeris file for your machine. To do this first connect to the <a href="ftp://ssd.jpl.nasa.gov">JPL FTP site</a> via the command-line or your favourite FTP client. The server URL is:</p>
<p><a href="ftp://ssd.jpl.nasa.gov/">ftp://ssd.jpl.nasa.gov</a></p>
<p>and the directory you want to download is <code>/pub/eph/planets/ascii/de413</code></p>
<p>Once downloaded, copy the contents of this directory into <code>src/jpleph</code>:</p>
<pre><code class="bash">$ cp de413/* src/jpleph/
</code></pre>
<p>And now combine these ascii files into one binary file:</p>
<pre><code class="bash">$ cd src/jpleph/
$ cat header.413 ascp1900.413 ascp1925.413 ascp1950.413 ascp1975.413 ascp2000.413 ascp2025.413 | ./asc2eph.x
</code></pre>
<p>If successful you will see something like this:</p>
<pre><code class="text">...
1713 EPHEMERIS RECORDS WRITTEN. LAST JED = 2469808.50
STOP OK
</code></pre>
<p>and a non-zero sized <code>JPLEPH</code> file containing the combined JPL ephemerides:</p>
<pre><code class="bash">$ ls -l JPLEPH
-rw-r--r--@ 1 Dave admin 13966960 7 Sep 15:10 JPLEPH
</code></pre>
<p>Move this file into Orbfit’s <code>lib</code> directory:</p>
<pre><code class="bash">$ mv JPLEPH ../../lib/jpleph
</code></pre>
<h3 id="testtheinstall">Test the Install</h3>
<p>The final task is to test your install. To do so make a directory somewhere called <code>orbfit-workspace</code> and change into it:</p>
<pre><code class="bash">$ mkdir ~/Desktop/orbfit-workspace
$ cd ~/Desktop/orbfit-workspace
</code></pre>
<p>Now download the Lowell Observatory <code>astorb</code> flavour of orbital elements from <a href="ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz">here</a> and uncompress.</p>
<pre><code class="bash">wget ftp://ftp.lowell.edu/pub/elgb/astorb.dat.gz
gunzip astorb.dat.gz
</code></pre>
<p>Finally grab my template options file and dummy observation files from this <a href="https://gist.github.com/thespacedoctor/f97ce22bbe2d6d2889de74c73089cf5d">gist</a> (click on the ‘Download ZIP’ button). Now you should have 3 files in your workspace:</p>
<pre><code class="bash">$ ls
astorb.dat
dummy.obs
orbfit-template-run-options.oop
</code></pre>
<p>Run the command <code>orbfit.x</code> and then give <code>orbfit-template-run-options</code> as the run name. You should see something like this:</p>
<pre><code class="bash">$ orbfit.x
Run name =
orbfit-template-run-options
Run name = orbfit-template-run-options
JPL planetary ephemerides DE413
number of perturbers = 0
binary ephemerides file= CPV
perturbing asteroids used: none
ngr_opt = F
No .rwo file, reading .obs and/or .rad files.
input_obs: 1 obs in ./dummy.obs
Using .rwo file, but checking .obs,.rad for update.
input_obs: 1 obs from ./dummy.rwo
input_obs: 1 obs from ./dummy.obs
There are no updates in .obs or .rad files.
Scanning file "astorb.dat" (format: BA2)
Semimajor axis = 3.1166357900000001E+00 au
Eccentricity = 0.115222750000000
Inclination = 12.5288100000000 deg
Long. of node = 148.0323380000000 deg
Arg. of pericenter = 357.0506910000000 deg
Mean anomaly = 39.3705710000000 deg
Scanning file "astorb.dat" (format: BA2)
Semimajor axis = 3.1166357900000001E+00 au
Eccentricity = 0.115222750000000
Inclination = 12.5288100000000 deg
Long. of node = 148.0323380000000 deg
Arg. of pericenter = 357.0506910000000 deg
Mean anomaly = 39.3705710000000 deg
ORBFIT: propagation of orbital elements
write_elems: ndim.ne.nd 32767 6
write_elems: ndim.ne.nd 32767 6
ORBFIT: generating ephemerides
</code></pre>
<p>and you will find an ephemeris file has been created called <code>orbfit-template-run-options.oep</code> containing the following:</p>
<pre><code class="text">Ephemeris for object 1999
Origin of orbital elements: read from file "astorb.dat" at record 1999
Equatorial coordinates App. motion
Date Hour MJD RA DEC Mag Delta R SolEl Phase Glat RA*cosDE DEC
(UTC) (UTC) h m s d ' " (au) (au) (deg) (deg) (deg) arcsec/s arcsec/s
=========== ====== ============ ============= ============ ===== ======= ======= ====== ====== ===== ========== ==========
12 Jun 2017 0.000 57916.000000 10 34 12.030 +14 59 6.76 16.5 2.9078 2.7977 -73.7 20.4 55.9 1.1476E-02 -3.8280E-03
Ephemeris for object 1999
Origin of orbital elements: read from file "astorb.dat" at record 1999
Equatorial coordinates App. motion
Date Hour MJD RA DEC Mag Delta R SolEl Phase Glat RA*cosDE DEC
(UTC) (UTC) h m s d ' " (au) (au) (deg) (deg) (deg) arcsec/s arcsec/s
=========== ====== ============ ============= ============ ===== ======= ======= ====== ====== ===== ========== ==========
12 Jun 2017 0.000 57916.000000 10 34 12.030 +14 59 6.76 16.5 2.9078 2.7977 -73.7 20.4 55.9 1.1476E-02 -3.8280E-03
</code></pre>
<p>Job done. Coffee time.</p>
<p>If you want some more details on the Orbfit options <a href="//blog/2017/10/12/Crafting-an-Orbfit-5-Options-File.html">see here</a>.</p>Joe Doed.r.young@qub.ac.ukOrbFit is a software package used to determine the orbits of asteroids written by the OrbFit Consortium. But it’s very sparsely documented, and can be a little tricky to install, never-mind learning how to use it. Here’s my guide to getting it to successfully install on my mac (macOS Sierra).Downloading PS1 FITS Images Known to Contain Detections of Specific Moving Objects using PanStamps2017-07-05T15:17:51+01:002017-07-05T15:17:51+01:00http://astronotes.co.uk/blog/2017/07/05/Downloading-PS1-FITS-Images-Known-to-Contain-Detections-of-Specific-Moving-Objects<p>Now that it’s possible to <a href="http://psweb.mp.qub.ac.uk/dry//blog/2017/07/03/using-panstamps-to-download-images-within-a-given-time-window-using-panstamps-to-download-images-within-a-given-time-window.html">use PanStamps to download images within a given time-window</a> we should be able to take list of PS1-MOPS detections for a given source and download the FITS images from the <a href="https://panstarrs.stsci.edu/">Pan-STARRS1 data archive</a>. Consider this list of detections of a single TNO:</p>
<!--summary-->
<p><script src="https://gist.github.com/thespacedoctor/9164d64547c58011bb1a96b80951d785.js?file=tno-01-ps1-detecion-list.dat"></script></p>
<h2 id="whichmjd">Which MJD?</h2>
<p>One things I’ve noted during my tests of the <a href="https://panstarrs.stsci.edu/">Pan-STARRS1 data archive</a> is that the MJD reported in the HTML table of returned warps is <code>MJD-OBS</code>; the time recorded at the start of the exposure. However the MJDs reported in the PS1-MOPS output files is <code>MJD-MID</code>; the time at the mid-point of the exposure. This makes matching specific PS1-MOPS detections with their associated warp frames a little tricky.</p>
<p>The best way to match an warp reported on the <a href="https://panstarrs.stsci.edu/">Pan-STARRS1 data archive</a> against its <code>MJD-MID</code> value is probably to use PanStamps to select the warp with the latest <code>MJD-OBS</code> before <code>MJD-MID</code>. PanStamps v0.5.0 introduced the <code>--closest</code> option via the command-land which allows us to do just that. The following command will select and download the warp taken closest in time <em>before</em> <em>MJD</em>=<code>55246.63228</code> at the selected sky-location:</p>
<pre><code class="bash">panstamps -jF --closest=before --width=4 --filters=grizy --downloadFolder=~/Desktop/tno-01 189.1960991 28.2374845 55246.63228
</code></pre>
<p>and here’s the resulting jpeg with our target clearly in the centre:</p>
<figure>
<img src="https://farm5.staticflickr.com/4043/35731942735_59284a42af_o.png" alt="The resulting jpeg image with target clearly visible in centre" id="theresultingjpegimagewithtargetclearlyvisibleincentre35731942735" title="the resulting jpeg image with target clearly visible in centre" width="600" />
<figcaption>The resulting jpeg image with target clearly visible in centre</figcaption>
</figure>
<p>But we’re not out of the woods yet! Occasionally a warp detection reported in the PS1-MOPS output <em>does not</em> get reported via the <a href="https://panstarrs.stsci.edu/">Pan-STARRS1 data archive</a> for reasons unknown. If the associated warp doesn’t exist then PanStamps is still going to download the next (wrong!) warp reported closest in time before the requested MJD. So instead of passing simply a <code>before</code> value to the <code>--closest</code> flag it’s better to pass in a time-window in seconds like so:</p>
<pre><code class="bash">panstamps -jF --closest=-120 --width=4 --filters=grizy --downloadFolder=~/Desktop/tno-01 189.1960991 28.2374845 55246.63228
</code></pre>
<p>This command will now only download the warp taken closest in time <em>before</em> <em>MJD</em>=<code>55246.63228</code> at the selected sky-location <em>if it is within 120 secs of the requested MJD</em>. A warning is issued if an image is not found.</p>
<h2 id="scriptingpanstamps">Scripting PanStamps</h2>
<p>Let’s give this go and download all of the warp jpegs for the moving object reported in the PS1-MOPS output above. If you want to give this a go then grab the bash script here and run it from your machine<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"><sup>1</sup></a>.</p>
<p><script src="https://gist.github.com/thespacedoctor/9164d64547c58011bb1a96b80951d785.js?file=tno-01-stamps-downloader.sh"></script></p>
<p>Here are the <a href="./tno-01/index.html">resulting jpegs</a>; as you can see the target object is clearly detected at the centre of all of the images. Trying again with another (fainter) source, from the <a href="./tno-02/index.html">results we see that everything seems to be working as expected</a>. Here’s the script for that last one:</p>
<p><script src="https://gist.github.com/thespacedoctor/9164d64547c58011bb1a96b80951d785.js?file=tno-02-stamps-downloader.sh"></script></p>
<p>For up-to-date PanStamps documentation, with install and usage instructions, see <a href="http://PanStamps.readthedocs.org/en/stable/">Read the Docs</a>.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">
<p>remember to access the warp images from the Pan–STARRS1 data archive you must run it from a machone with an IP address on their whitelist otherwise you can only access stacked images. I'm running this from within the QUB network. <a href="#fnref:1" title="return to body" class="reversefootnote"> ↩</a></p>
</li>
</ol>
</div>Joe Doed.r.young@qub.ac.ukNow that it’s possible to use PanStamps to download images within a given time-window we should be able to take list of PS1-MOPS detections for a given source and download the FITS images from the Pan-STARRS1 data archive. Consider this list of detections of a single TNO: