Skip to content

Instantly share code, notes, and snippets.

View vterron's full-sized avatar

Víctor Terrón vterron

View GitHub Profile
@vterron
vterron / groupby_distance.py
Last active May 17, 2020 18:33
Use itertools.groupby() to split a series of numbers into sub-itervals based on distance to the first element.
#! /usr/bin/env python3
"""Use itertools.groupby() to split a series of numbers into sub-itervals.
For each interval, all its elements satisfy (x_{i} - x_{0}) < WINDOW.
Keys to this approach:
- We need a global variable to keep track of the current x_{0}.
- The key value of each element is x_{0} (so that all the elements fall into the same group).
"""
@vterron
vterron / export-stars.py
Created August 4, 2015 14:12
List the stars and (if any) the standard deviations of the astronomical objects in a LEMONdB
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
@vterron
vterron / export-phot.py
Created August 4, 2015 11:29
Export from a LEMONdB the photometric measurements of a series of astronomical objects
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
@vterron
vterron / unbounded-erathosthenes.py
Last active August 29, 2015 14:26
Prime generator via unbounded Sieve of Erathosthenes
#! /usr/bin/env python3
""" See this URL for an explanation of what we're doing here:
https://wthwdik.wordpress.com/2007/08/30/an-unbounded-sieve-of-eratosthenes/
"""
import itertools
import types
class Prime(types.SimpleNamespace):
@vterron
vterron / issue-60-bitpix.py
Created June 16, 2015 09:58
Run montage_wrapper.mosaic() with BITPIX=-64
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
""" Mosaic a series of input FITS images with montage.mosaic(), using
bitpix=-64 (double precision floating point). Both the input and output
temporary directories are immediately removed when the function exits.
"""
@vterron
vterron / export-coordinates.py
Created June 11, 2015 10:03
Print the coordinates of all the astronomical objects in a LEMON database
#! /usr/bin/env python
""" Take a LEMONdB file and print to standard output the right ascension and
declination of all the astronomical objects. """
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
from __future__ import division
@vterron
vterron / issue-60c.py
Last active August 29, 2015 14:22
Third attempt at debugging issue #60
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
""" Mosaic all the input FITS files using Montage, then all of them except for
the first ten, then all of them minus the first twenty, et cetera. That is: the
number of mosaicked images decreases in steps of ten. We stop as soon as one of
the data sets doesn't cause Montage to raise an error. ."""
@vterron
vterron / issue-60b.py
Created May 28, 2015 16:56
Second attempt at debugging issue #60
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
""" Mosaic the first ten FITS files using Montage, then the first twenty, then
the first thirty, et cetera. That is: the number of mosaicked images increases
in steps of ten, stopping as soon as an error, if any, is encountered."""
@vterron
vterron / issue-60.py
Created May 27, 2015 13:28
First attempt at debugging issue #60
#! /usr/bin/env python
# Author: Victor Terron (c) 2015
# Email: `echo vt2rron1iaa32s | tr 132 @.e`
# License: GNU GPLv3
""" Feed a series of input FITS files to Montage (via montage-wrapper),
one by one, identifying those, if any, that cause it to raise an error. """
from __future__ import division
@vterron
vterron / coordinates
Last active August 29, 2015 14:21
Zillionth attempt at debugging issue #57
100.1191901 9.8177770