Skip to content

Instantly share code, notes, and snippets.

View wkerzendorf's full-sized avatar

Wolfgang Kerzendorf wkerzendorf

View GitHub Profile
@wkerzendorf
wkerzendorf / artis_fitness_function
Last active October 5, 2015 16:56
setup for fitting artis models
from dalek import assemble_tardis_model
from dalek.base.model import SimpleTARDISUncertaintyModel, NormRedSpectrum, LogLikelihood
from dalek.base.base import BaseLikelihoodModel
from dalek.base.transform import uniform_transform
from astropy import units as u, constants as const
import os
base_dir = '/home/hpc/pr94se/di73qom/projects/tardis/dalek/test_artis_run/artis_fit'
artis_filename = os.path.join(base_dir, 'aaflux_057.dat')
@wkerzendorf
wkerzendorf / match_cat.py
Created September 30, 2015 17:09
matching catalogues
from astropy import coordinates as coord
from astropy import units as u, constants as const
import pandas as pd
cats = ['ut150625_g.h5', 'ut150625_r.h5', 'ut150625_u.h5']
gdata = pd.read_hdf(cats[0], 'data')
gdata = gdata[gdata.type == 1]
gcat = coord.SkyCoord(gdata.RA.values, gdata.Dec.values, unit=u.degree)
rdata = pd.read_hdf(cats[1], 'data')
@wkerzendorf
wkerzendorf / decam2tbl.py
Created September 30, 2015 15:52
concatenating decam tables
import argparse
from astropy.io import fits
from astropy import wcs
import os
from glob import glob
import pandas as pd
parser = argparse.ArgumentParser(description='Convert DECAM photometry to Tables')
from astropy.table import Table
from astropy.io import fits
import pandas as pd
import numpy as np
class XShooterEchelle(object):
coef_types = ['cen', 'edgup', 'edglo']
@wkerzendorf
wkerzendorf / test_fit
Created August 11, 2015 17:15
script for linear least squared
from astropy.io import fits
from scipy import optimize
import numpy as np
from extract_spectral.trace import GaussianPolynomialTrace, ModelFrame2D, LogLikelihood, LinearLstSqExtraction
from DIRECT import solve
from astropy.modeling import models
#download from
data = fits.getdata('IRCQ00467448.fits')
#data = fits.getdata('test_data/fors_many_stars.fits').T
@wkerzendorf
wkerzendorf / gist:47fd23359bc95c225551
Created June 12, 2015 21:51
Idea for Echelle Model
class IRCSEchelle(Model):
inputs = ()
outputs = ('polygon_array', )
slit_width = Parameter(default=5.)
slit_length = Parameter(default=10.)
def evaluate(self, slit_width, slit_length, ...):
parray = run_idl_code(slit_width, slit_length)
return parray
@wkerzendorf
wkerzendorf / gist:3bc9b7f86226471e5b60
Created May 15, 2015 12:38
Download the photoabsorption cross section
import requests
from bs4 import BeautifulSoup
base_url = 'http://henke.lbl.gov/cgi-bin/pert_cgi.pl'
def get_photo_absorption_cross_section(element_code, energy):
data = requests.get(base_url, data=dict(
Element=element_code, Energy=energy))
bs = BeautifulSoup(data.text)
@wkerzendorf
wkerzendorf / gist:7472208
Created November 14, 2013 18:46
Mutlispec WCS for 2 dimensional
class MultiSpecWCS(Model):
def __init__(self, single_wcs=[list of 1d WCSs]):
self.single_wcs = single_wcs
def __call__(self, x, y):
assert type(x) == int # we need to make sure that the user does not expect to interpolate between two adjacent spectra
@wkerzendorf
wkerzendorf / pdflatex.py
Created November 13, 2013 02:31
pdflatex python script with latex/bibtex/latex/latex and moving unwanted files into output-directory
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import shutil
pdflatex_bin = 'pdflatex'
bibtex_bin = 'bibtex'
ERROR: AttributeError: 'Spectrum1DLookupWCS' object has no attribute '_param_dim' [astropy.modeling.core]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-01a2fdaa6cd5> in <module>()
----> 1 specwcs.Spectrum1DLookupWCS(np.arange(3000, 6000) * u.Angstrom)
/Users/wkerzend/scripts/python/specutils/specutils/wcs/specwcs.py in __init__(self, lookup_table, unit, lookup_table_interpolation_kind)
60 self.lookup_table_parameter = lookup_table * unit
61 elif unit is None: # lookup_table is already unit'd
---> 62 self.lookup_table_parameter = lookup_table