Skip to content

Instantly share code, notes, and snippets.

View taldcroft's full-sized avatar

Tom Aldcroft taldcroft

View GitHub Profile
@taldcroft
taldcroft / play-tables-from-apj-html.ipynb
Created December 14, 2023 15:03
Try to get an ApJ data table programmatically
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / custom-table-for-array-formatting.ipynb
Created May 27, 2022 19:38
Custom table class for custom multidimensional array formatting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / par_table.py
Created May 6, 2022 11:09
Table subclass with parameters
import numpy as np
from astropy.table import Table, Column
from astropy.table.ndarray_mixin import NdarrayMixin, NdarrayMixinInfo
from astropy.io.registry import UnifiedReadWriteMethod
from astropy.table.connect import TableRead, TableWrite
from astropy.table.info import serialize_method_as
def fmt_func(val):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / mystyle.css
Last active May 20, 2020 13:54
Annotated data tables
table {
table-layout: fixed;
border-collapse: collapse;
border: 3px solid black;
}
th, td {
padding: 5px;
border: 1px solid black;
}
@taldcroft
taldcroft / combine-intervals.ipynb
Created March 20, 2020 18:14
Combine cheta logical intervals
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@taldcroft
taldcroft / table_aggregation.py
Created January 20, 2016 17:39
Generalized table aggregation example using astropy Table
from __future__ import division, print_function
from astropy import table
from astropy.table import Table
from collections import OrderedDict
t = Table([['a', 'a', 'a', 'b', 'b', 'c'],
[1, 2, 3, 4, 5, 6],
[2, 2, 1, 2, 1, 1]],
names=('name', 'value', 'weight'))
@taldcroft
taldcroft / 10-startup.py
Last active September 10, 2017 01:28
IPython startup magic
# ~/.ipython/profile_default/startup/10-mystartup.py
import numpy as np
ip = get_ipython()
def import_astropy(self, arg):
ip.ex('import astropy')
ip.ex('print(astropy.__version__)')
ip.ex('from astropy.io import ascii')
skadev-unagi$ python
iActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb 7 2011, 11:30:54)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
po>>> import astropy
astropy.test()
WARNING: ConfigurationChangedWarning: The configuration options in astropy 1.0rc2 may have changed, your configuration file was not updated in order to preserve local changes. A new configuration template has been saved to '/home/aldcroft/.astropy/config/astropy.1.0rc2.cfg'. [astropy.config.configuration]
>>> astropy.test()
========================================================== test session starts ===========================================================