Skip to content

Instantly share code, notes, and snippets.

View taldcroft's full-sized avatar

Tom Aldcroft taldcroft

View GitHub Profile
@taldcroft
taldcroft / test_asciitable_format.ipynb
Last active December 12, 2015 08:09
Example of writing a Table object to an ASCII file and reading it back with no loss of metadata
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / calc_agn.ipynb
Last active December 12, 2015 09:29
Calculate contaminating AGN in CygOB2 survey
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / curve_fit.ipynb
Last active June 7, 2018 14:24
Investigating `scipy.optimize.curve_fit` covariance output
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#
# coding=utf8
# Copyright 2013, 2014 Bence Béky
#
# This file is part of Spotrod.
#
# Spotrod is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# -*- coding: utf-8 -*-
from astropy import coordinates as coords
from astropy import units as u
import astropy.time
J2001 = astropy.time.Time('J2001',scale='utc')
#<---------------------------"High-level" class-------------------------------->
frame0 frame1 equinox0 equinox1 obstime0 obstime1 dt1 dt2 dt3 OK coord equinox obstime
----------- ----------- -------- -------- -------- -------- -------- -------- -------- ---- ----- ------- -------
icrs icrs ... ... ... ... 1.988 4.884 2.843 OK True ... ...
icrs icrs ... ... ... J1980.0 1.270 4.175 2.423 OK True ... ...
icrs icrs ... J1975.0 ... ... 1.687 7.620 2.961 OK True ... ...
icrs icrs ... J1975.0 ... J1980.0 1.708 4.537 2.692 OK True ... ...
icrs icrs ... ... J1980.0 ... 1.157 4.182 2.320 OK True ... True
icrs icrs ... ... J1980.0 J1980.0 1.152 4.114 2.308 OK True ... True
icrs icrs ... J1975.0 J1980.0 ... 1.155 4.131 2.316 OK True ... Tru
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Tests for the SkyCoord class. Note that there are also SkyCoord tests in
test_api_ape5.py
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import division
import numpy as np
import Ska.Numpy
times = np.arange(0, 86400 * 365, 10) # 10 second sampling for a year
vals = np.random.uniform(size=len(times))
on_mask = vals < 0.5 # 50% duty cycle
on_vals = vals[on_mask]
import numpy
import matplotlib
import scipy # things like coordinates matching, modeling, convolution use this
import astropy
from distutils import version
# Astropy version 0.3.2 or later, and 0.4.0 for coordinates
astropy_version = version.LooseVersion(astropy.__version__)
if astropy_version < version.LooseVersion('0.3.2'):
print('Error: astropy version 0.3.2 or later is required, you have {0}'
@taldcroft
taldcroft / quarter_bin.py
Created July 18, 2014 02:32
Vectorized version of quarter binning
"""
Vectorized version of quarter_bin() function.
"""
import numpy as np
def quarter_bin(dates):
# print(Time(datetime(2014,1,31)).jyear)
# Jan31 = np.modf(Time(datetime(2014,1,31)).jyear)[0]