Commit b386f78d authored by Ole Streicher's avatar Ole Streicher
Browse files

New upstream version 0.80+dfsg

parent e4fc852b
......@@ -4,10 +4,8 @@
*/deps
*/lib*.a
*/test_*-main.c
gsl-an/*/*.o
gsl-an/*.dSYM
util/os-features-test-*
*/*.pyc
**/*.pyc
__pycache__
blind/astrometry-engine
blind/augment-xylist
blind/build-astrometry-index
......@@ -30,23 +28,27 @@ blind/plotstuff_c.py
blind/plotstuff_wrap.c
blind/plotxy
blind/solve-field
blind/query-starkd
blind/tablist
blind/tabmerge
blind/test.c
blind/wcs-grab
blind/job.axy
blind/startree
blind/fitsverify.dSYM
catalogs/2masstofits
catalogs/build-hd-tree
catalogs/ngc2000.py
catalogs/ngc2000accurate.py
catalogs/ngc2000entries.c
catalogs/ngc2000entries.py
catalogs/ngc2000names.c
catalogs/ngcic-accurate-entries.c
catalogs/nomadtofits
catalogs/openngc-entries.c
catalogs/openngc-entries.csv
catalogs/openngc-names.c
catalogs/openngc-names.csv
catalogs/tycho2tofits
catalogs/ucac3tofits
catalogs/ucac4tofits
catalogs/usnobtofits
gsl-an/*/*.o
gsl-an/*.dSYM
gsl-an/cc-out.tmp
gsl-an/config.h
gsl-an/config.log
......@@ -62,6 +64,7 @@ libkd/deps
libkd/fix-bb
sdss/cutils.py
sdss/cutils_wrap.c
util/os-features-test-*
util/an-fitstopnm
util/an-pnmtofits
util/an_build_ext.pyc
......@@ -87,3 +90,7 @@ util/wcs-resample
util/wcs-to-tan
util/wcs-xy2rd
util/wcsinfo
util/wcs-match
util/wcs-pv2sip
report.txt
.DS_Store
......@@ -3,45 +3,50 @@
# use the new containerized infrastructure
sudo: false
# Default distro, precise (12.04 LTS) has ancient python3.2 that doesn't
# support requests, required for pip3.
dist: trusty
#dist: trusty
dist: bionic
language: c
compiler:
- gcc
- clang
# language: c
# compiler:
# - gcc
# - clang
# env:
# - PY=2
# - PY=3
language: python
python:
- "2.7"
- "3.5"
env:
- PY=2
- PY=3
- CC=gcc
- CC=clang
# Apparently the wcslib version they have (4.8.3) doesn't use pkg-config
# And netpbm include files are right in /usr/include, not in /usr/include/netpbm
script:
- which python
- python --version
- which python2
- which python3
- mkdir -p ~/bin
- export PATH=~/bin:${PATH}
- ls -l $(which python$PY)
#- ln -s $(which python$PY) ~/bin/python
- alias python="python$PY"
- which python
- ls -l $(which python)
#- cat $(which python)
- python --version
- which pip2
- which pip3
- ls -l $(which pip$PY)
#- ln -s $(which pip$PY) ~/bin/pip
- alias pip="pip$PY"
- which pip
- pip install numpy --user
- pip install fitsio --user
- export WCSLIB_INC="-I/usr/include/wcslib-4.20"
- export WCSLIB_LIB="-lwcs"
- python --version
- pip --version
#- export PYTHON=python$PY
#- export PIP=pip$PY
- export PYTHON=$(which python)
- export PIP=$(which pip)
- $PYTHON --version
- which $PYTHON
# - mkdir -p ~/bin
# - export PATH=~/bin:${PATH}
# - ls -l $(which python$PY)
# - ln -s $(which python$PY) ~/bin/python
- which $PIP
- $PIP --version
- $PIP install numpy #--user
- $PIP install fitsio #--user
- $PYTHON -c "import numpy as np"
#- export WCSLIB_INC="-I/usr/include/wcslib-4.20"
#- export WCSLIB_LIB="-lwcs"
- make
- make py
- make extra
......@@ -49,7 +54,8 @@ script:
- (cd util; ./test)
- (cd blind; ./test)
- (cd libkd; ./test)
- make install INSTALL_DIR=~/an
- make install INSTALL_DIR=~/an PYTHON_SCRIPT="/usr/bin/env $PYTHON"
- ls ~/an/lib/python
- export PATH=${PATH}:~/an/bin
- build-astrometry-index -d 3 -o index-9918.fits -P 18 -S mag -B 0.1 -s 0 -r 1 -I 9918 -M -i demo/tycho2-mag6.fits
- echo -e 'add_path .\ninparallel\nindex index-9918.fits' > 99.cfg
......@@ -57,11 +63,7 @@ script:
- tablist demo/apod4.match
- listhead demo/apod4.wcs
- export PYTHONPATH=${PYTHONPATH}:~/an/lib/python
- python -c "import astrometry.libkd.spherematch"
# install:
# - sudo apt-get update -qq
# - sudo apt-get install -y libnetpbm10 libnetpbm10-dev wcslib-dev libcfitsio3 libcfitsio3-dev python-numpy swig gsl-bin libgsl0-dev
- $PYTHON -c "import astrometry.libkd.spherematch"
addons:
apt:
......@@ -70,21 +72,12 @@ addons:
- libnetpbm10-dev
- netpbm
- wcslib-dev
- libcfitsio3
- libcfitsio3-dev
- libcfitsio-dev
- swig
- gsl-bin
- libgsl0-dev
# The trusty image py3 already (in /opt); and use pip to install numpy.
# - python3
# - python3-dev
# - python3-pip
# - python3-numpy
# - python-numpy
# ugh, no python3-pip in 'precise'
# - python3-setuptools
# - libgsl10-dev
- libgsl-dev
# trusty:
#- libcfitsio3
#- libcfitsio3-dev
# - libgsl0-dev
......@@ -70,21 +70,9 @@ Data files:
http://vizier.cfa.harvard.edu/viz-bin/VizieR-3?-source=VI/49/bound_20
-catalogs/ngc2000{,names}.dat
Imported from ftp://cdsarc.u-strasbg.fr/cats/VII/118/
NGC 2000.0, The Complete New General Catalogue and Index Catalogue
of Nebulae and Star Clusters by J.L.E. Dreyer
Sinnott, R.W. (edited by)
Sky Publishing Corporation and Cambridge University Press (1988)
Copyright Notice:
This catalog is copyrighted by Sky Publishing Corporation, which has
kindly deposited the machine version in the data centers for permanent
archiving and dissemination to astronomers for scientific research
purposes only. The data should not be used for commercial purposes
without the explicit permission of Sky Publishing Corporation.
-catalogs/{ic,ngc}2000_pos.txt
Imported from http://www.ngcic.org/corwin/default.htm
Dr. Harold G. Corwin Jr (hgcjr@ipac.caltech.edu)
-catalogs/NGC.csv
(c) Mattia Verga, from OpenNGC
https://github.com/mattiaverga/OpenNGC
Licensed under CC-BY-SA 4.0
https://creativecommons.org/licenses/by-sa/4.0/
......@@ -217,7 +217,7 @@ config: util/os-features-config.h util/makefile.os-features
$(MAKE) -C util config
.PHONY: config
RELEASE_VER := 0.78
RELEASE_VER := 0.80
RELEASE_DIR := astrometry.net-$(RELEASE_VER)
RELEASE_RMDIRS := net
......@@ -232,7 +232,7 @@ release:
(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 := 0.78
cat $(RELEASE_DIR)/Makefile | sed "s/RELEASE_VER := 0.80
tar cf $(RELEASE_DIR).tar $(RELEASE_DIR)
gzip --best -c $(RELEASE_DIR).tar > $(RELEASE_DIR).tar.gz
bzip2 --best $(RELEASE_DIR).tar
......
......@@ -3,7 +3,7 @@ Astrometry.net
[![Build Status](https://travis-ci.org/dstndstn/astrometry.net.png?branch=master)](https://travis-ci.org/dstndstn/astrometry.net)
[![Tag Version](https://img.shields.io/github/tag/dstndstn/astrometry.net.svg)](https://github.com/dstndstn/astrometry.net/tags)
[![License](http://img.shields.io/:license-gpl2-blue.svg)](http://www.gnu.org/licenses/gpl-2.0.html)
[![License](http://img.shields.io/:license-gpl3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0.html)
Automatic recognition of astronomical images; or standards-compliant
astrometric metadata from data.
......
__version__ = '0.79-26-g3e790b81'
#! /usr/bin/env python
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
from __future__ import print_function
......
#! /usr/bin/env python
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
from __future__ import print_function
......
#! /usr/bin/env python
#! /usr/bin/env python3
from __future__ import print_function
from __future__ import absolute_import
import sys
......
#! /usr/bin/env python
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
from __future__ import print_function
......
#! /usr/bin/env python
#! /usr/bin/env python3
from __future__ import print_function
from __future__ import absolute_import
import sys
......
#! /usr/bin/env python
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
import sys
......
#! /usr/bin/env python
#! /usr/bin/env python3
from __future__ import print_function
from __future__ import absolute_import
import sys
......
#! /usr/bin/env python
#! /usr/bin/env python3
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
import sys
......
......@@ -97,14 +97,13 @@ resort-xylist: resort-xylist-main.o resort-xylist.o $(SLIB)
UTIL_OBJS :=
OTHER_OBJS := catalog.o codefile.o verify.o \
solver.o matchfile.o matchobj.o solvedclient.o solvedfile.o pnpoly.o \
tweak.o blind-main.o \
solver.o matchfile.o matchobj.o solvedfile.o pnpoly.o tweak.o \
plot-constellations.o quadcenters.o startree2rdls.o \
blindutils.o engine-main.o engine.o plotquad.o plotxy.o tweak2.o
NOT_INSTALLED_PIPELINE := blind agreeable certifiable \
NOT_INSTALLED_PIPELINE := agreeable certifiable \
hpquads codetree unpermute-quads unpermute-stars \
solvedserver printsolved mergesolved subwcs \
printsolved mergesolved subwcs \
augment-xylist merge-index index-to-table setsolved \
uniformize-catalog local-index index-info control-program
......@@ -128,7 +127,7 @@ INSTALL_LIB := $(ENGINE_LIB) $(ENGINE_SO)
ENGINE_OBJS := \
engine.o blindutils.o blind.o solver.o quad-utils.o \
matchfile.o matchobj.o solvedclient.o solvedfile.o tweak2.o \
matchfile.o matchobj.o solvedfile.o tweak2.o \
verify.o tweak.o
# These are required by solve-field and friends
......@@ -174,8 +173,7 @@ INSTALL_H := allquads.h augment-xylist.h axyfile.h \
engine.h blind.h blindutils.h build-index.h catalog.h \
codefile.h codetree.h fits-guess-scale.h hpquads.h \
image2xy-files.h matchfile.h matchobj.h merge-index.h \
new-wcs.h quad-builder.h quad-utils.h \
resort-xylist.h solvedclient.h \
new-wcs.h quad-builder.h quad-utils.h resort-xylist.h \
solvedfile.h solver.h tweak.h uniformize-catalog.h \
unpermute-quads.h unpermute-stars.h verify.h \
tweak2.h
......
......@@ -36,7 +36,6 @@ void printHelp(char* progname) {
" or [-a]: write out all matches passing the solve threshold.\n"
" (default is to write out the single best match (largest ratio))\n"
" )\n"
" [-s <solved-server-address>]\n"
" [-S <solved-file-template>]\n"
" <input-match-file> ...\n"
"\n", progname);
......@@ -53,7 +52,6 @@ char* agreefname = NULL;
matchfile* agreemf = NULL;
il* solved;
il* unsolved;
char* solvedserver = NULL;
char* solvedfile = NULL;
double ratio_tosolve = 0.0;
int ninfield_tosolve = 0;
......@@ -94,9 +92,6 @@ int main(int argc, char *argv[]) {
case 'S':
solvedfile = optarg;
break;
case 's':
solvedserver = optarg;
break;
case 'F':
mode = MODE_FIRST;
break;
......@@ -147,12 +142,6 @@ int main(int argc, char *argv[]) {
exit(-1);
}
if (solvedserver)
if (solvedclient_set_server(solvedserver)) {
fprintf(stderr, "Failed to set solved server.\n");
exit(-1);
}
if (leftoverfname) {
leftovermf = matchfile_open_for_writing(leftoverfname);
if (!leftovermf) {
......@@ -387,8 +376,6 @@ static void write_field(bl* agreeing,
il_append(unsolved, fieldnum);
else {
il_append(solved, fieldnum);
if (solvedserver)
solvedclient_set(fieldfile, fieldnum);
if (solvedfile) {
char fn[256];
sprintf(fn, solvedfile, fieldfile);
......
#!/bin/env python
from __future__ import print_function
"""
anet -- command line interface to astrometry.net website.
Finds WCS solutions to your FITS images.
Written by J. Bloom (jbloom@astro.berkeley.edu)
June 2008 Copyright (c) Josh Bloom
This program is free software licensed with the GNU Public License Version 3.
For a full copy of the license please go here http://www.gnu.org/licenses/licenses.html#GPL
SETUP:
* should work with python2.4 or higher (only tested on 2.5)
* you need pyfits.py (> 1.3) in your PYTHONPATH (available from STSCI). This will in turn require you
to have numpy (or numarray) installed. If you dont get any import errors when you
#user> python
>>> import pyfits
then you are ok.
* edit the variables astrometry_username and astrometry_email as appropriate
* you might want to edit job_dict, since I assume a platescale around 0.1 - 2.5"/pix to help with speed up.
you could also speed things along if you know the parity of your images
USAGE: python anet.py {fitsfile.fits | *.fits}
TODO: add an arg parser to allow user to tweak control over the URL calls
"""
import os, urllib, sys, datetime, copy
import urllib2, cookielib
import threading
import mimetools, mimetypes
import os, stat
from cStringIO import StringIO
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"
__version__ = "1.0"
# Put your name and the email you registered with astrometry.net here.
astrometry_username = "---Your Name Here---"
astrometry_email = "---Your Email Here---"
## some helper classes first.
class Callable:
def __init__(self, anycallable):
self.__call__ = anycallable
class MultipartPostHandler(urllib2.BaseHandler):
handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first
# Controls how sequences are uncoded. If true, elements may be given multiple values by
# assigning a sequence.
doseq = 1
def http_request(self, request):
data = request.get_data()
if data is not None and type(data) != str:
v_files = []
v_vars = []
try:
for(key, value) in data.items():
if type(value) == file:
v_files.append((key, value))
else:
v_vars.append((key, value))
except TypeError:
systype, value, traceback = sys.exc_info()
raise TypeError, "not a valid non-string sequence or mapping object", traceback
if len(v_files) == 0:
data = urllib.urlencode(v_vars, self.doseq)
else:
boundary, data = self.multipart_encode(v_vars, v_files)
contenttype = 'multipart/form-data; boundary=%s' % boundary
if(request.has_header('Content-Type')
and request.get_header('Content-Type').find('multipart/form-data') != 0):
print("Replacing %s with %s" % (request.get_header('content-type'), 'multipart/form-data'))
request.add_unredirected_header('Content-Type', contenttype)
request.add_data(data)
return request
def multipart_encode(vars, files, boundary = None, buf = None):
if boundary is None:
boundary = mimetools.choose_boundary()
if buf is None:
buf = StringIO()
for(key, value) in vars:
buf.write('--%s\r\n' % boundary)
buf.write('Content-Disposition: form-data; name="%s"' % key)
buf.write('\r\n\r\n' + str(value) + '\r\n')
for(key, fd) in files:
file_size = os.fstat(fd.fileno())[stat.ST_SIZE]
filename = fd.name.split('/')[-1]
contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
buf.write('--%s\r\n' % boundary)
buf.write('Content-Disposition: form-data; name="%s"; filename="%s"\r\n' % (key, filename))
buf.write('Content-Type: %s\r\n' % contenttype)
# buffer += 'Content-Length: %s\r\n' % file_size
fd.seek(0)
buf.write('\r\n' + fd.read() + '\r\n')
buf.write('--' + boundary + '--\r\n\r\n')
buf = buf.getvalue()
return boundary, buf
multipart_encode = Callable(multipart_encode)
https_request = http_request
opener = urllib2.build_opener(MultipartPostHandler)
results = []
class ImageContainer:
astrometry_dot_net_url = "http://live.astrometry.net/"
def __init__(self,call_string,name,verbose=True):
self.reqid = None
self.name = name
self.call_string = call_string
self.status = "unknown"
self.stat = "unknown"
self.newhead = None
self.verbose = verbose
self._make_request()
self._get_req_id()
self._get_job_status()
self._get_new_wcs()
self._replace_new_wcs()
results.append((self.name,self.status,self.stat,self.reqid))
def _make_request(self):
self.time_started= datetime.datetime.now()
self.status = "submitted"
if self.verbose:
print("** Submitting WCS request for image = %s" % self.name)
print(datetime.datetime.now())
self.req = opener.open(self.astrometry_dot_net_url + "index.php", self.call_string)
if self.verbose:
print(" (Finished uploading image = %s)" % self.name)
print(datetime.datetime.now())
self.status = "returned"
def _get_req_id(self):
if self.status != "returned":
self.status = "failed"
tmp = self.req.read().splitlines()
gotit = False
for i in range(len(tmp)):
if tmp[i].find("<title>") != -1:
gotit = True
break
if gotit:
tmp = tmp[i+1].split("Job ")
self.reqid = tmp[1].split()[0]
self.status = "got req id"
return
def _get_job_status(self,timeout=200.0):
if self.status != "got req id":
print("bad job status")
return
got_status = False
start = datetime.datetime.now()
call = self.astrometry_dot_net_url + "status.php?" + urllib.urlencode({"job": self.reqid})
timeout = datetime.timedelta(seconds=timeout)
if self.verbose:
print(" If you'd like to check the status of %s, go to: \n %s" % (self.name,call))
while not got_status and datetime.datetime.now() - start < timeout:
f = urllib.urlopen(call)
tmp = f.readlines()
for i in range(len(tmp)):
if tmp[i].find("<tr><td>Status:</td><td>") != -1:
self.stat = tmp[i+1].split("</td>")[0]
if self.stat in ["Failed", "Solved"]:
got_status = True
break
time.sleep(1)
# print " Status of file %s (req id = %s).... %s" % (self.name,self.reqid,self.stat)
def _get_new_wcs(self):
#print "here1 (%s)" % self.stat
if self.stat != "Solved":
return
call = self.astrometry_dot_net_url + "status.php?" + urllib.urlencode({"job": self.reqid, "get": "wcs.fits"})
self.newhead = "wcs-" + self.reqid + ".fits"
urllib.urlretrieve(call,self.newhead)
def _replace_new_wcs(self,delnew=True):
if self.newhead is None or self.stat != "Solved":
return
if self.name.find(".fits") == -1:
## not a fits image
self.status = "wcs=%s" % self.newhead
return
wascompressed = False
if self.name.endswith(".gz"):
os.system("gunzip " + self.name)
wascompressed = True
self.name = self.name.split(".gz")[0]
tmp = pyfits.open(self.name,"update")
tmp1 = pyfits.open(self.newhead,"readonly")
tmp2 = tmp1[0].header
del tmp2["SIMPLE"]
del tmp2["BITPIX"]
del tmp2["NAXIS"]
## copy the header over
tmp1.close()
for c in tmp2.ascardlist():
tmp[0].header.update(c.key,c.value,c.comment)
tmp.verify("silentfix")
tmp.close(output_verify='warn')
if delnew:
os.remove(self.newhead)
if wascompressed:
os.system("gzip " + self.name)
self.name += ".gz"
if self.verbose:
print("Finished WCS request for image %s (%s)" % (self.name,self.stat))
class AstrometrySolver:
job_dict = {"uname": astrometry_username,"email": astrometry_email, "fsunit" :"arcsecperpix",\
"fstype-ul": 1, "fsu": 1.1, "fsl": 0.9, "xysrc": "img", "parity": 2, "index": "10arcmin", "tweak": 1,\
"tweak_order": 2, "imgfile": "","submit": "Submit"}
def __init__(self,verbose=True):
self.verbose= verbose
self.threads = []
def _make_request(self,imgfile=None,pixel_size_range = [0.2,1.1], tweak_astrometry=True):
if imgfile is None or not os.path.isfile(imgfile):
if self.verbose:
print("! imgfile is bad")
return
tmp =copy.copy(self.job_dict)
tmp.update({"imgfile": open(imgfile,"rb"), "fsl": pixel_size_range[0], "fsu": pixel_size_range[1], "tweak": int(tweak_astrometry)})
if imgfile.find(".fits") == -1:
tmp.update({"index": "auto"})
self.threads.append(threading.Timer(0.0,ImageContainer,args=[tmp,imgfile],kwargs={'verbose': self.verbose}))
self.threads[-1].start()
#print opener.open(self.astrometry_dot_net_url, tmp).read()
#params = urllib.urlencode(tmp)
#print self.astrometry_dot_net_url + "?" + params
#f = url
def get_wcs(self,imlist=None,howmany_at_a_time=5,pixel_size_range = [0.2,1.1]):
print("Verbose is set to %s" % repr(self.verbose))
if imlist is None:
return
if type(imlist) == type("a"):
self._make_request(imlist,pixel_size_range = pixel_size_range)
self.threads[-1].join()
if type(imlist) == type([]):
nsets = len(imlist)/howmany_at_a_time + 1
for i in range(nsets):
# print (i, (i*howmany_at_a_time),((1 + i)*howmany_at_a_time))
for im in imlist[(i*howmany_at_a_time):((i+1)*howmany_at_a_time)]:
if im.find(".fits") == -1:
## probably cannot trust the image scale to be small
self._make_request(im,pixel_size_range=[0.1,500],tweak_astrometry=False)
else:
self._make_request(im)
## wait until the last guy finishes before firing off more
self.threads[-1].join()
self.threads[-1].join()
def __str__(self):
a = "RESULTS OF THE SUBMITTED JOBS\n"
a += "%-45s\t%-10s\t%-10s\t%-15s\n" % ("name","status","stat","reqid")
a += "*"*100 + "\n"
for r in results:
a += "%-45s\t'%-10s'\t%-10s\t%-15s\n" % (os.path.basename(r[0]),r[1],r[2],r[3])
return a
#results.append((self.name,self.status,self.stat,self.reqid))
if __name__ == "__main__":
if len(sys.argv) <= 1:
print(__doc__)
else:
a = AstrometrySolver()
a.get_wcs(imlist=sys.argv[1:],pixel_size_range = [0.2,2])
print(a)
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
#include <ctype.h>
#include <math.h>
#include "fitsioutils.h"
#include "boilerplate.h"
#include "blind.h"
#include "log.h"
#include "tic.h"
static int read_parameters(blind_t* bp);
int main(int argc, char *argv[]) {
blind_t my_bp;
blind_t* bp = &my_bp;
solver_t* sp = &(bp->solver);
log_init(LOG_MSG);
fits_use_error_system();
if (argc == 2 && strcmp(argv[1], "-s") == 0) {
log_set_level(LOG_NONE);
fprintf(stderr, "premptive silence\n");
}
// Read input settings until "run" is encountered; repeat.
for (;;) {
tic();
blind_init(bp);
// must be in this order because init_parameters handily zeros out sp
solver_set_default_values(sp);
if (read_parameters(bp)) {
solver_cleanup(sp);
blind_cleanup(bp);
break;
}
if (!blind_parameters_are_sane(bp, sp)) {
exit(-1);
}
if (blind_is_run_obsolete(bp, sp)) {
goto clean;
}
blind_log_run_parameters(bp);
blind_run(bp);
toc();
if (bp->hit_total_timelimit)
break;
if (bp->hit_total_cpulimit)
break;
clean:
solver_cleanup(sp);
blind_cleanup(bp);
}
return 0;
}
static int read_parameters(blind_t* bp) {
solver_t* sp = &(bp->solver);
for (;;) {
char buffer[10240];
char* nextword;
char* line;
if (!fgets(buffer, sizeof(buffer), stdin)) {
return -1;
}
line = buffer;
// strip off newline
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
// skip leading whitespace:
while (*line && isspace(*line))
line++;
logverb("Command: %s\n", line);
if (line[0] == '#') {
//logmsg("Skipping comment.\n");
continue;
}
// skip blank lines.
if (line[0] == '\0') {
continue;
}
if (is_word(line, "help", &nextword)) {
logmsg("No help soup for you!\n (use the source, Luke)\n");
} else if (is_word(line, "logtostderr", &nextword)) {
log_to(stderr);
} else if (is_word(line, "verbose", &nextword)) {
log_init(LOG_VERB);
} else if (is_word(line, "verify ", &nextword)) {
sl_append(bp->verify_wcsfiles, nextword);
} else if (is_word(line, "verify_wcs ", &nextword)) {
sip_t wcs;
int nread;
memset(&wcs, 0, sizeof(wcs));
if (sscanf(nextword, "%lg %lg %lg %lg %lg %lg %lg %lg%n",
&(wcs.wcstan.crval[0]), &(wcs.wcstan.crval[1]),
&(wcs.wcstan.crpix[0]), &(wcs.wcstan.crpix[1]),
&(wcs.wcstan.cd[0][0]), &(wcs.wcstan.cd[0][1]),
&(wcs.wcstan.cd[1][0]), &(wcs.wcstan.cd[1][1]),
&nread) < 8) {
logerr("Failed to parse verify_wcs entry.\n");
continue;
}
nextword += nread;
if (sscanf(nextword, " %i %i%n", &(wcs.a_order), &(wcs.ap_order), &nread) >= 2) {
int m, n;
wcs.b_order = wcs.a_order;
wcs.bp_order = wcs.ap_order;
nextword += nread;
for (m=0; m<=wcs.a_order; m++) {
for (n=0; (m+n)<=wcs.a_order; n++) {
if (sscanf(nextword, " %lg %lg%n", &(wcs.a[m][n]), &(wcs.b[m][n]), &nread) < 2) {
logerr("Failed to parse SIP terms: \"%s\"\n", nextword);
continue;
}
nextword += nread;
}
}
for (m=0; m<=wcs.ap_order; m++) {
for (n=0; (m+n)<=wcs.ap_order; n++) {
if (sscanf(nextword, " %lg %lg%n", &(wcs.ap[m][n]), &(wcs.bp[m][n]), &nread) < 2) {
logerr("Failed to parse SIP terms: \"%s\"\n", nextword);
continue;
}
nextword += nread;
}
}
}
blind_add_verify_wcs(bp, &wcs);
} else if (is_word(line, "cpulimit ", &nextword)) {
bp->cpulimit = atof(nextword);
} else if (is_word(line, "timelimit ", &nextword)) {
bp->timelimit = atoi(nextword);
} else if (is_word(line, "total_timelimit ", &nextword)) {
bp->total_timelimit = atof(nextword);
} else if (is_word(line, "total_cpulimit ", &nextword)) {
bp->total_cpulimit = atof(nextword);
} else if (is_word(line, "verify_pix ", &nextword)) {
sp->verify_pix = atof(nextword);
} else if (is_word(line, "nsolves ", &nextword)) {
bp->nsolves = atoi(nextword);
} else if (is_word(line, "ratio_tosolve ", &nextword)) {
bp->logratio_tosolve = log(atof(nextword));
} else if (is_word(line, "ratio_tokeep ", &nextword)) {
sp->logratio_tokeep = log(atof(nextword));
} else if (is_word(line, "ratio_toprint ", &nextword)) {
sp->logratio_toprint = log(atof(nextword));
} else if (is_word(line, "ratio_tobail ", &nextword)) {
sp->logratio_bail_threshold = log(atof(nextword));
} else if (is_word(line, "match ", &nextword)) {
blind_set_match_file(bp, nextword);
} else if (is_word(line, "indexrdls ", &nextword)) {
blind_set_rdls_file(bp, nextword);
} else if (is_word(line, "correspondences ", &nextword)) {
free(bp->corr_fname);
bp->corr_fname = strdup(nextword);
} else if (is_word(line, "best_only", &nextword)) {
bp->best_hit_only = TRUE;
} else if (is_word(line, "solved ", &nextword)) {
blind_set_solved_file(bp, nextword);
} else if (is_word(line, "solved_in ", &nextword)) {
blind_set_solvedin_file(bp, nextword);
} else if (is_word(line, "solved_out ", &nextword)) {
blind_set_solvedout_file(bp, nextword);
} else if (is_word(line, "cancel ", &nextword)) {
blind_set_cancel_file(bp, nextword);
} else if (is_word(line, "solvedserver ", &nextword)) {
free(bp->solvedserver);
bp->solvedserver = strdup(nextword);
} else if (is_word(line, "tweak_skipshift", &nextword)) {
// deprecated
} else if (is_word(line, "tweak_aborder ", &nextword)) {
sp->tweak_aborder = atoi(nextword);
} else if (is_word(line, "tweak_abporder ", &nextword)) {
sp->tweak_abporder = atoi(nextword);
} else if (is_word(line, "tweak", &nextword)) {
sp->do_tweak = TRUE;
} else if (is_word(line, "wcs ", &nextword)) {
blind_set_wcs_file(bp, nextword);
} else if (is_word(line, "fieldid_key ", &nextword)) {
free(bp->fieldid_key);
bp->fieldid_key = strdup(nextword);
} else if (is_word(line, "maxquads ", &nextword)) {
sp->maxquads = atoi(nextword);
} else if (is_word(line, "maxmatches ", &nextword)) {
sp->maxmatches = atoi(nextword);
} else if (is_word(line, "xcol ", &nextword)) {
blind_set_xcol(bp, nextword);
} else if (is_word(line, "ycol ", &nextword)) {
blind_set_ycol(bp, nextword);
} else if (is_word(line, "index ", &nextword)) {
blind_add_index(bp, nextword);
} else if (is_word(line, "indexes_inparallel", &nextword)) {
bp->indexes_inparallel = TRUE;
} else if (is_word(line, "field ", &nextword)) {
blind_set_field_file(bp, nextword);
} else if (is_word(line, "fieldw ", &nextword)) {
sp->field_maxx = atof(nextword);
} else if (is_word(line, "fieldh ", &nextword)) {
sp->field_maxy = atof(nextword);
} else if (is_word(line, "distractors ", &nextword)) {
sp->distractor_ratio = atof(nextword);
} else if (is_word(line, "fieldid ", &nextword)) {
bp->fieldid = atoi(nextword);
} else if (is_word(line, "sdepth ", &nextword)) {
sp->startobj = atoi(nextword);
} else if (is_word(line, "depth ", &nextword)) {
sp->endobj = atoi(nextword);
} else if (is_word(line, "tol ", &nextword)) {
sp->codetol = atof(nextword);
} else if (is_word(line, "parity ", &nextword)) {
sp->parity = atoi(nextword);
} else if (is_word(line, "quadsize_min ", &nextword)) {
sp->quadsize_min = atof(nextword);
} else if (is_word(line, "fieldunits_lower ", &nextword)) {
sp->funits_lower = atof(nextword);
} else if (is_word(line, "fieldunits_upper ", &nextword)) {
sp->funits_upper = atof(nextword);
} else if (is_word(line, "firstfield ", &nextword)) {
bp->firstfield = atoi(nextword);
} else if (is_word(line, "lastfield ", &nextword)) {
bp->lastfield = atoi(nextword);
} else if (is_word(line, "fields ", &nextword)) {
char* str = nextword;
while (str && *str) {
unsigned int lo, hi;
int nread;
if (sscanf(str, "%u%*1[-/]%u", &lo, &hi) == 2) {
sscanf(str, "%*u%*1[-/]%*u%n", &nread);
} else if (sscanf(str, "%u", &lo) == 1) {
sscanf(str, "%*u%n", &nread);
hi = lo;
} else {
fprintf(stderr, "Failed to parse fields fragment: \"%s\"\n", str);
return -1;
}
if (lo < 1) {
fprintf(stderr, "Field number %i is invalid: must be >= 1.\n", lo);
return -1;
}
if (lo > hi) {
fprintf(stderr, "Field range %i to %i is invalid: max must be >= min!\n", lo, hi);
return -1;
}
blind_add_field_range(bp, lo, hi);
str += nread;
while ((*str == ',') || isspace(*str))
str++;
}
} else if (is_word(line, "run", &nextword)) {
return 0;
} else if (is_word(line, "quit", &nextword)) {
return 1;
} else if (is_word(line, "nverify ", &nextword)) {
logmsg("DEPRECATED: \"nverify\" command.\n");
} else if (is_word(line, "nindex_tosolve ", &nextword)) {
logmsg("DEPRECATED: \"nindex_tosolve\" command.\n");
} else if (is_word(line, "nindex_tokeep ", &nextword)) {
logmsg("DEPRECATED: \"nindex_tokeep\" command.\n");
} else {
logmsg("I didn't understand this command:\n \"%s\"\n", line);
}
}
}
......@@ -29,7 +29,6 @@
#include "starutil.h"
#include "mathutil.h"
#include "quadfile.h"
#include "solvedclient.h"
#include "solvedfile.h"
#include "starkd.h"
#include "codekd.h"
......@@ -48,7 +47,6 @@
static anbool record_match_callback(MatchObj* mo, void* userdata);
static time_t timer_callback(void* user_data);
static void add_blind_params(blind_t* bp, qfits_header* hdr);
static void get_fields_from_solvedserver(blind_t* bp, solver_t* sp);
static void load_and_parse_wcsfiles(blind_t* bp);
static void solve_fields(blind_t* bp, sip_t* verify_wcs);
static void remove_invalid_fields(il* fieldlist, int maxfield);
......@@ -337,8 +335,6 @@ void blind_run(blind_t* bp) {
// Record current CPU usage for total cpu-usage limit.
bp->cpu_total_start = get_cpu_usage();
get_fields_from_solvedserver(bp, sp);
// Parse WCS files submitted for verification.
load_and_parse_wcsfiles(bp);
......@@ -492,9 +488,6 @@ void blind_run(blind_t* bp) {
// Clean up.
xylist_close(bp->xyls);
if (bp->solvedserver)
solvedclient_set_server(NULL);
if (write_solutions(bp))
exit(-1);
......@@ -519,8 +512,6 @@ void blind_init(blind_t* bp) {
bp->fieldid_key = strdup("FIELDID");
blind_set_xcol(bp, NULL);
blind_set_ycol(bp, NULL);
bp->firstfield = -1;
bp->lastfield = -1;
bp->quad_size_fraction_lo = DEFAULT_QSF_LO;
bp->quad_size_fraction_hi = DEFAULT_QSF_HI;
bp->nsolves = 1;
......@@ -579,31 +570,6 @@ int blind_is_run_obsolete(blind_t* bp, solver_t* sp) {
return 0;
}
static void get_fields_from_solvedserver(blind_t* bp, solver_t* sp) {
if (!bp->solvedserver)
return;
if (solvedclient_set_server(bp->solvedserver)) {
logerr("Error setting solvedserver.\n");
exit( -1);
}
if ((il_size(bp->fieldlist) == 0) && (bp->firstfield != -1) && (bp->lastfield != -1)) {
int j;
il_free(bp->fieldlist);
logmsg("Contacting solvedserver to get field list...\n");
bp->fieldlist = solvedclient_get_fields(bp->fieldid, bp->firstfield, bp->lastfield, 0);
if (!bp->fieldlist) {
logerr("Failed to get field list from solvedserver.\n");
exit( -1);
}
logmsg("Got %zu fields from solvedserver: ", il_size(bp->fieldlist));
for (j = 0; j < il_size(bp->fieldlist); j++) {
logmsg("%i ", il_get(bp->fieldlist, j));
}
logmsg("\n");
}
}
static void load_and_parse_wcsfiles(blind_t* bp) {
int i;
for (i = 0; i < sl_size(bp->verify_wcsfiles); i++) {
......@@ -643,8 +609,6 @@ void blind_log_run_parameters(blind_t* bp) {
logverb("solved_in %s\n", bp->solved_in);
if (bp->solved_out)
logverb("solved_out %s\n", bp->solved_out);
if (bp->solvedserver)
logverb("solvedserver %s\n", bp->solvedserver);
if (bp->cancelfname)
logverb("cancel %s\n", bp->cancelfname);
if (bp->wcs_template)
......@@ -688,7 +652,6 @@ void blind_cleanup(blind_t* bp) {
free(bp->scamp_fname);
free(bp->corr_fname);
free(bp->matchfname);
free(bp->solvedserver);
free(bp->solved_in);
free(bp->solved_out);
free(bp->wcs_template);
......@@ -876,12 +839,11 @@ static void add_blind_params(blind_t* bp, qfits_header* hdr) {
fits_add_long_comment(hdr, "Start obj: %i", sp->startobj);
fits_add_long_comment(hdr, "End obj: %i", sp->endobj);
// 'Solved_in' and 'Solvedserver' are often NULL pointers.
// 'Solved_in' is often a NULL pointer.
// If %s is a NULL pointer, vasprintf() causes a segmentation fault (due to strlen()) on Solaris -> added treatment of this case for portability.
// GNU/Linux implementation of vasprintf() catches NULL pointer and prints "(null)" in header. Seems to be an issue on Solaris only.
fits_add_long_comment(hdr, "Solved_in: %s", bp->solved_in?bp->solved_in:"(null)");
fits_add_long_comment(hdr, "Solved_out: %s", bp->solved_out?bp->solved_out:"(null)");
fits_add_long_comment(hdr, "Solvedserver: %s", bp->solvedserver?bp->solvedserver:"(null)");
fits_add_long_comment(hdr, "Parity: %i", sp->parity);
fits_add_long_comment(hdr, "Codetol: %g", sp->codetol);
......@@ -1062,12 +1024,6 @@ static anbool is_field_solved(blind_t* bp, int fieldnum) {
logmsg("Field %i: solvedfile %s: field has been solved.\n", fieldnum, bp->solved_in);
return TRUE;
}
if (bp->solvedserver &&
(solvedclient_get(bp->fieldid, fieldnum) == 1)) {
// field has already been solved.
logmsg("Field %i: field has already been solved.\n", fieldnum);
return TRUE;
}
return FALSE;
}
......@@ -1079,9 +1035,6 @@ static void solved_field(blind_t* bp, int fieldnum) {
logerr("Failed to write solvedfile %s.\n", bp->solved_out);
}
}
if (bp->solvedserver) {
solvedclient_set(bp->fieldid, fieldnum);
}
// If we're just solving a single field, and we solved it...
if (il_size(bp->fieldlist) == 1)
bp->single_field_solved = TRUE;
......
......@@ -54,7 +54,7 @@ static void print_help(char* progname) {
" [-A <column>]: specify the RA column name in the input FITS table (default \"RA\")\n"
" [-D <column>]: specify the Dec column name in the input FITS table (default \"Dec\")\n"
" [-B <val>]: cut any object whose sort-column value is less than 'val'; for mags this is a bright limit\n"
" [-U]: healpix Nside for uniformization (default: same as -n)\n"
" [-U]: healpix Nside for uniformization (default: same as -N)\n"
" [-H <big healpix>]; default is all-sky\n"
" [-s <big healpix Nside>]; default is 1\n"
" [-m <margin>]: add a margin of <margin> healpixels; default 0\n"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment