Skip to content

Instantly share code, notes, and snippets.

View wkerzendorf's full-sized avatar

Wolfgang Kerzendorf wkerzendorf

View GitHub Profile
SELECT
stars.name,
obs.id,
fit_gridchi_1.vcorr,
fit_gridchi_1.teff,
fit_gridchi_1.logg,
fit_gridchi_1.feh,
fit_gridchi_1.chi,
fit_minuit_1.teff,
fit_minuit_1.logg,
@wkerzendorf
wkerzendorf / gist:1631397
Created January 18, 2012 06:12
very slow update
lines ~ 200k
levels ~ 20k
update
lines
set
level_id_upper =
(select level_id from levels
where lines.atom=levels.atom and
lines.ion=levels.ion and
@wkerzendorf
wkerzendorf / gist:2986286
Created June 25, 2012 03:19
ipython parallel recarray problem
In [1]: from IPython.parallel import Client
In [2]: rc = Client()
In [3]: myrec = random.random((10,3))
In [4]: myrec
Out[4]:
array([[ 0.83451781, 0.86186735, 0.11552798],
[ 0.4613526 , 0.01918926, 0.97660991],
@wkerzendorf
wkerzendorf / specwcs.py
Created March 18, 2013 23:31
Spectrum1D simple WCS
# This module provides a basic and probably temporary WCS solution until astropy has a wcs built-in
#This is all built upon @nden's work on the models class
from astropy import models
import numpy as np
class BaseSpectrum1DWCSError(Exception):
pass
class BaseSpectrum1DWCS(models.Model):
"""
@wkerzendorf
wkerzendorf / pip virtualenv log
Created October 18, 2013 02:15
pip installation in an empty virtualenv
➜ virtualenvs virtualenv-2.7 --no-site-packages tardis_release
New python executable in tardis_release/bin/python
Installing setuptools............done.
Installing pip...............done.
➜ virtualenvs source tardis_release/bin/activate
(tardis_release)➜ virtualenvs cd tardis_release
bin include lib
(tardis_release)➜ ~VIRTUAL_ENV pip install astropy
Downloading/unpacking astropy
Downloading astropy-0.2.4.tar.gz (4.7MB): 4.7MB downloaded
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
@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'
@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 / 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: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