Skip to content

Instantly share code, notes, and snippets.

@pllim
Created August 10, 2017 19:08
Show Gist options
  • Select an option

  • Save pllim/86954c6783eb2bb9c3b552edbdd134a7 to your computer and use it in GitHub Desktop.

Select an option

Save pllim/86954c6783eb2bb9c3b552edbdd134a7 to your computer and use it in GitHub Desktop.
Python replacement for buildasn task
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The example below is adapted from an older version of the same tutorial at http://www.stsci.edu/hst/HST_overview/documents/multidrizzle/ch56.html#250820"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"\n",
"import glob\n",
"\n",
"from stsci.tools import asnutil"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['j6lq01naq_raw.fits', 'j6lq01ndq_raw.fits', 'jbp601krq_raw.fits']\n"
]
}
],
"source": [
"inputlist = glob.glob(\"*raw.fits\")\n",
"print(inputlist)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"asntab = asnutil.ASNTable(inputlist, output='custom') # shiftfile=\"shifts.txt\"\n",
"asntab.create()\n",
"asntab.write()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Filename: custom_asn.fits\n",
"No. Name Ver Type Cards Dimensions Format\n",
" 0 PRIMARY 1 PrimaryHDU 23 () \n",
" 1 1 BinTableHDU 26 4R x 9C [26A, 14A, L, E, E, E, E, E, E] \n",
" 2 WCS 1 ImageHDU 22 () \n"
]
}
],
"source": [
"from astropy.io import fits\n",
"\n",
"pf = fits.open('custom_asn.fits')\n",
"pf.info()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" MEMNAME MEMTYPE MEMPRSNT XOFFSET YOFFSET XDELTA YDELTA ROTATION SCALE\n",
"--------- -------- -------- ------- ------- ------ ------ -------- -----\n",
"j6lq01naq EXP-DTH True 0.0 0.0 0.0 0.0 0.0 1.0\n",
"j6lq01ndq EXP-DTH True 0.0 0.0 0.0 0.0 0.0 1.0\n",
"jbp601krq EXP-DTH True 0.0 0.0 0.0 0.0 0.0 1.0\n",
" custom PROD-DTH False 0.0 0.0 0.0 0.0 0.0 1.0\n"
]
}
],
"source": [
"from astropy.table import Table\n",
"\n",
"tab = Table.read(pf[1], format='fits')\n",
"print(tab)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"pf.close()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment