Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dstndstn/astrometry.net
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed May 14, 2015
2 parents 7e38981 + 0b6c02b commit a8a89a1
Show file tree
Hide file tree
Showing 76 changed files with 1,312 additions and 608 deletions.
14 changes: 13 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
0.54:
Try importing pyfits and then astropy.io.fits

0.53:
Update wcs-pv2sip and include in default build
Fixes for git version strings
Read and write linear SIP distortion terms
multiindex: don't assert when reloading already-loaded file

0.52:
Fix release version strings in released versions.

0.51:
Fix half-pixel bug in "solve-field --crpix-center": the center was
set to 1 + {W,H}/2, not 0.5 + {W,H}/2. (The WCS was still
correct, the CRPIX was set to a half pixel in each dimension away
from the center pixel.


4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ config: util/os-features-config.h util/makefile.os-features
$(MAKE) -C util config
.PHONY: config

RELEASE_VER := $(shell git describe | cut -f1 -d"-")
RELEASE_VER ?= $(shell git describe | cut -f1 -d"-")

RELEASE_DIR := astrometry.net-$(RELEASE_VER)
RELEASE_RMDIRS := net
Expand All @@ -187,6 +187,8 @@ release:
(cd $(RELEASE_DIR)/util && swig -python -I. -I../include/astrometry util.i)
(cd $(RELEASE_DIR)/blind && swig -python -I. -I../util -I../include/astrometry plotstuff.i)
(cd $(RELEASE_DIR)/sdss && swig -python -I. cutils.i)
cat $(RELEASE_DIR)/util/makefile.common | sed "s/AN_GIT_REVISION .=.*/AN_GIT_REVISION := $$(git describe)/" | sed "s/AN_GIT_DATE .=.*/AN_GIT_DATE := $$(git log -n 1 --format=%cd | sed 's/ /_/g')/" > $(RELEASE_DIR)/util/makefile.common.x && mv $(RELEASE_DIR)/util/makefile.common.x $(RELEASE_DIR)/util/makefile.common
cat $(RELEASE_DIR)/Makefile | sed "s/RELEASE_VER .=.*/RELEASE_VER := $(RELEASE_VER)/" > $(RELEASE_DIR)/Makefile.x && mv $(RELEASE_DIR)/Makefile.x $(RELEASE_DIR)/Makefile
tar cf $(RELEASE_DIR).tar $(RELEASE_DIR)
gzip --best -c $(RELEASE_DIR).tar > $(RELEASE_DIR).tar.gz
bzip2 --best $(RELEASE_DIR).tar
Expand Down
3 changes: 0 additions & 3 deletions blind/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,6 @@ fit-wcs: fit-wcs-main.o $(SLIB)

ALL_OBJ += image2xy-files.o

wcs-pv2sip: wcs-pv2sip.o tweak.o $(SLIB)
ALL_OBJ += wcs-pv2sip.o

hpgrid: hpgrid.o $(SLIB)

$(CFITS_UTILS) :: %: %.o $(CFITS_SLIB)
Expand Down
8 changes: 7 additions & 1 deletion blind/anet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
import mimetools, mimetypes
import os, stat
from cStringIO import StringIO
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
import time

__author__ = "J. S. Bloom"
Expand Down
8 changes: 7 additions & 1 deletion blind/centroid-noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
from pylab import *
from numpy import *
from numpy.random import *
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")

# Given an image and an xylist (including estimated image sigma),
# look at a cutout around each source position, add noise, and recompute
Expand Down
8 changes: 7 additions & 1 deletion blind/image2xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
# You need ctypes and a recent (1.0) numpy for this to work. I've included
# pyfits so you don't have to.

import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
import sys
import scipy
import os
Expand Down
4 changes: 3 additions & 1 deletion blind/solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,10 @@ static int solver_handle_hit(solver_t* sp, MatchObj* mo, sip_t* sip,
sip.wcstan.crpix+0, sip.wcstan.crpix+1);
}

int doshift = 1;
fit_sip_wcs(matchxyz, matchxy, weights, N, &(sip.wcstan),
sp->tweak_aborder, sp->tweak_abporder, &sip);
sp->tweak_aborder, sp->tweak_abporder, doshift,
&sip);

for (i=0; i<Ngood; i++) {
double xx,yy;
Expand Down
8 changes: 7 additions & 1 deletion blind/spoof.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
import math
from math import exp
from matplotlib.pylab import imread
Expand Down
8 changes: 7 additions & 1 deletion blind/test_plotstuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
matplotlib.use('Agg')
import unittest

import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
import numpy as np
import pylab as plt
from math import pi,sqrt
Expand Down
8 changes: 7 additions & 1 deletion blind/test_plotstuff2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
if __name__ == '__main__':
matplotlib.use('Agg')
import unittest
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
from astrometry.util.fits import *
from astrometry.blind.plotstuff import *
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion blind/tweak.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@ static void do_sip_tweak(tweak_t* t) {
weights[i] = dl_get(t->weight, i);
}

int doshift = 1;
result = fit_sip_wcs(starxyz, fieldxy, weights, M,
&(t->sip->wcstan), t->sip->a_order, t->sip->ap_order,
&(t->sip->wcstan), t->sip->a_order, t->sip->ap_order, doshift,
&sipout);
free(starxyz);
free(fieldxy);
Expand Down
3 changes: 2 additions & 1 deletion blind/tweak2.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,10 @@ sip_t* tweak2(const double* fieldxy, int Nfield,
crpix, &temptan, &sipout->wcstan);
}

int doshift = 1;
fit_sip_wcs(matchxyz, matchxy, weights, Nmatch,
&(sipout->wcstan), order, sip_invorder,
sipout);
doshift, sipout);

debug("Got SIP:\n");
if (log_get_level() > LOG_VERB)
Expand Down
8 changes: 7 additions & 1 deletion blind/ver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import math
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
from numpy import *
from matplotlib.pylab import figure, plot, xlabel, ylabel, loglog, clf
from matplotlib.pylab import semilogy, show, find, legend, hist, axis
Expand Down
8 changes: 7 additions & 1 deletion catalogs/ngc2000tofits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import pyfits
try:
import pyfits
except ImportError:
try:
from astropy.io import fits as pyfits
except ImportError:
raise ImportError("Cannot import either pyfits or astropy.io.fits")
from numpy import *
from ngc2000 import ngc2000, ngc2000accurate
from astrometry.util.fits import *
Expand Down
6 changes: 3 additions & 3 deletions doc/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Building/installing the Astrometry.net code

Grab the code::

wget http://astrometry.net/downloads/astrometry.net-0.46.tar.bz2
tar xjf astrometry.net-0.46.tar.bz2
cd astrometry.net-0.46
wget http://astrometry.net/downloads/astrometry.net-latest.tar.bz2
tar xjf astrometry.net-latest.tar.bz2
cd astrometry.net-*

Build it. The short version::

Expand Down
17 changes: 15 additions & 2 deletions include/astrometry/fit-wcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
#include "astrometry/sip.h"
#include "astrometry/starkd.h"

int fit_sip_coefficients(const double* starxyz,
const double* fieldxy,
const double* weights,
int M,
const tan_t* tanin1,
int sip_order,
int inv_order,
sip_t* sipout);

void wcs_shift(tan_t* wcs, double xs, double ys);

/**
Expand All @@ -40,7 +49,9 @@ int fit_sip_wcs(const double* starxyz,
const tan_t* tanin,
int sip_order,
int inv_order,
sip_t* sipout);
int doshift,
sip_t* sipout
);

int fit_sip_wcs_2(const double* starxyz,
const double* fieldxy,
Expand All @@ -51,7 +62,9 @@ int fit_sip_wcs_2(const double* starxyz,
int W, int H,
int crpix_center,
double* crpix,
sip_t* sipout);
int doshift,
sip_t* sipout
);

/**
Move the tangent point to the given CRPIX, keeping the corresponding
Expand Down
6 changes: 4 additions & 2 deletions include/astrometry/sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,15 @@ void sip_calc_distortion(const sip_t* sip, double u, double v, double* U, doub
// This applies the A,B matrix terms;
// This is the distortion applied in the pixel-to-RA,Dec direction.
// (pix -> "un"distorted -> TAN -> RA,Dec)
void sip_pixel_distortion(const sip_t* sip, double x, double y, double* X, double *Y);
void sip_pixel_distortion(const sip_t* sip, double x, double y,
double *p_x, double *p_y);

// Reverses sip_pixel_distortion;
// Applies "reverse" SIP distortion: the AP, BP matrices;
// This is the distortion applied in the RA,Dec-to-pixel direction:
// (RA,Dec -> TAN -> undistorted -> pix)
void sip_pixel_undistortion(const sip_t* sip, double x, double y, double* X, double *Y);
void sip_pixel_undistortion(const sip_t* sip, double x, double y,
double *p_x, double *p_y);

// Pixels to XYZ unit vector.
void tan_pixelxy2xyzarr(const tan_t* tan, double px, double py, double *xyz);
Expand Down
33 changes: 28 additions & 5 deletions net/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def handle_request(request, *args, **kwargs):
def upload_common(request, url=None, file=None):
df, original_filename = handle_upload(file=file, url=url)
submittor = request.user if request.user.is_authenticated() else None

pro = get_user_profile(submittor)
json = request.json
logmsg('upload: JSON', json)
allow_commercial_use = json.get('allow_commercial_use', 'd')
allow_modifications = json.get('allow_modifications', 'd')
license,created = License.objects.get_or_create(
default_license=submittor.get_profile().default_license,
default_license=pro.default_license,
allow_commercial_use=allow_commercial_use,
allow_modifications=allow_modifications,
)
Expand Down Expand Up @@ -159,15 +159,34 @@ def upload_common(request, url=None, file=None):
@csrf_exempt
@requires_json_args
@requires_json_session
@requires_json_login
def url_upload(req):
logmsg('request:' + str(req))
#logmsg('request:' + str(req))
url = req.json.get('url')
logmsg('url: %s' % url)

logmsg('req.session:', req.session)
logmsg('req.session keys:', req.session.keys())
user_id = req.session['_auth_user_id']
logmsg('user_id:', user_id)
backend_path = req.session['_auth_user_backend']
logmsg('backend_path:', backend_path)
from django.contrib.auth import load_backend

backend = load_backend(backend_path)
logmsg('backend:', backend)
user = backend.get_user(user_id)
logmsg('user:', user)
logmsg('is_auth:', user.is_authenticated())

logmsg('request.user:', req.user)

return upload_common(req, url=url)

@csrf_exempt
@requires_json_args
@requires_json_session
@requires_json_login
def api_upload(request):
#logmsg('request:' + str(request))
upfile = request.FILES.get('file', None)
Expand Down Expand Up @@ -258,10 +277,14 @@ def api_login(request):
#auth.authenticate(username=profile.user.username, password=password)
#auth.login(request, profile.user)

loginfo('backends:' + str(auth.get_backends()))
# Instead, since we're using the auth AuthenticationMiddleware,
# we just have to register the session?

#loginfo('backends:' + str(auth.get_backends()))

user = profile.user
user.backend = 'django_openid_auth.auth.OpenIDBackend'
#user.backend = 'django_openid_auth.auth.OpenIDBackend'
user.backend = 'django.contrib.auth.backends.ModelBackend'

session = create_session(None)

Expand Down
Loading

0 comments on commit a8a89a1

Please sign in to comment.