Skip to content

Instantly share code, notes, and snippets.

View SimonKrughoff's full-sized avatar

Simon Krughoff SimonKrughoff

  • AURA/Vera C. Rubin Observatory
  • AURA Tucson
View GitHub Profile
@SimonKrughoff
SimonKrughoff / get_ref_cat.py
Created February 2, 2017 22:46
How to get a reference catalog
# Necessary imports
from lsst.meas.algorithms import LoadIndexedReferenceObjectsTask
import lsst.daf.persistence as dafPersist
import lsst.afw.coord as afwCoord
import lsst.afw.geom as afwGeom
# Get a butler for this repository (assumes you are in the top level of the repo)
butler = dafPersist.Butler('.')
# Get the config and tell it which reference catalog to use
@SimonKrughoff
SimonKrughoff / repo.txt
Last active February 2, 2017 22:48
Make a repo with reference catalog on lsst_dev
mkdir repo_name
cd repo_name
echo 'lsst.obs.test.TestMapper' > _mapper # This makes it a repo
ln -s /datasets/refcats/htm/htm_baseline ref_cats # link in the reference catalogs
def myFunc(a, b, c):
print a+b
print "C is %s"%(c)
myFunc(1,2,"Hello there")
''' Returns:
3
C is Hello there
'''
from functools import wraps
class Parent(object):
def work(self, a, b):
"""Do work on a and b"""
return a+b
class Child(Parent):
@wraps(Parent.work)
def work(self, a, b):
@SimonKrughoff
SimonKrughoff / simpleIterator.py
Last active January 2, 2016 01:19
This shows how to make a class with a simple iterator without indexing (no __getitem__).
class myIter(object):
def __init__(self, arr):
self.marr = arr
def __iter__(self):
return self.marr.__iter__()
def __len__(self):
return len(self.marr)
arr = [1,2,3,4]
miter = myIter(arr)