Skip to content

Instantly share code, notes, and snippets.

@drdavella
drdavella / asdf_in_fits.py
Created March 19, 2018 19:24
Easily reproduce ASDF-in-FITS object for testing
# coding: utf-8
from astropy.io import fits
from astropy.io.fits import HDUList, ImageHDU
from asdf.fits_embed import AsdfInFits
import numpy as np
get_ipython().run_line_magic('rm', '-f asdf.fits')
image = ImageHDU(np.random.random(1000))
hdulist = HDUList()
@drdavella
drdavella / asdf_test_case.py
Last active January 25, 2018 22:29
Simple reproducer for transient ASDF bug
#!/usr/bin/env python
import asdf
from astropy import units as u
from astropy.coordinates.representation import SphericalRepresentation
tree = {'coord': SphericalRepresentation(10*u.deg, 10*u.deg, 1*u.m)}
print('distance:', tree['coord'].distance)
with asdf.AsdfFile(tree=tree) as ff:
ff.write_to("test.asdf")
@drdavella
drdavella / asdf-testenv.yaml
Created January 25, 2018 22:09
A simple Conda environment file for attempting to reproduce ASDF test failures
name: asdf-test-env
channels:
dependencies:
- python=3.5
- ipython
- pytest
- numpy>=1.13
- pip:
- git+https://github.com/cadair/astropy@asdf_tags_coords#egg=astropy
- git+https://github.com/spacetelescope/asdf#egg=asdf
@drdavella
drdavella / mp-benchmark.py
Created December 19, 2017 18:54
Simple benchmark for testing data transfer between processes using Python's multiprocess module
#!/usr/bin/env python
from argparse import ArgumentParser
from multiprocessing import Process, Array, Pipe, Queue
from timeit import default_timer as timer
import numpy as np
def process_with_array(dest, source):
input_data = np.array(source, copy=False, dtype=float)