Created
February 9, 2017 20:48
-
-
Save josePhoenix/6b8565ebd96abe5e0dce61f0483d5568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"from astropy.io import fits" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"hdul = fits.open('./test.original.fits')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"60409" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"cards = hdul[1].header.cards\n", | |
"len(cards)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"cleaned_cards = [a for a in cards if a.keyword != 'COMMENT']" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"XTENSION= 'BINTABLE' /Binary table written by MWRFITS v1.10 \n", | |
"BITPIX = 8 /Required value \n", | |
"NAXIS = 2 /Required value \n", | |
"NAXIS1 = 24 /Number of bytes per row \n", | |
"NAXIS2 = 2283 /Number of rows \n", | |
"PCOUNT = 0 /Normally 0 (no varying arrays) \n", | |
"GCOUNT = 1 /Required value \n", | |
"TFIELDS = 3 /Number of columns in table \n", | |
"STARTIME= 57225.0025663 / \n", | |
"ENDTIME = 57296.2277080 / \n", | |
"TIME = 'Time BJD-2400000.0' / \n", | |
"FLUX = 'Normalised systematics corrected Flux' / \n", | |
"FLUXERR = 'Error of the normalised systematics corrected Flux' / \n", | |
"TTYPE1 = 'TIME ' / \n", | |
"TTYPE2 = 'FLUX ' / \n", | |
"TTYPE3 = 'FLUXERROR' / \n", | |
"TFORM1 = 'D ' / \n", | |
"TFORM2 = 'D ' / \n", | |
"TFORM3 = 'D ' / " | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fits.Header(cards=cleaned_cards)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import time" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"time elapsed: 2.167024850845337\n" | |
] | |
} | |
], | |
"source": [ | |
"start = time.time()\n", | |
"hdul_to_clean = fits.open('./test.original.fits')\n", | |
"cards = hdul_to_clean[1].header.cards\n", | |
"cleaned_cards = [a for a in cards if a.keyword != 'COMMENT']\n", | |
"hdul_to_clean[1].header = fits.Header(cards=cleaned_cards)\n", | |
"hdul_to_clean.writeto('./test.output.fits', overwrite=True)\n", | |
"print('time elapsed: ', time.time() - start)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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.6.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment