Commit 06a003f7 authored by Ole Streicher's avatar Ole Streicher
Browse files

Update upstream source from tag 'upstream/0.88+dfsg'

Update to upstream version '0.88+dfsg'
with Debian dir e6a066ffa9d4a13c156004bd4c5abdaa36a9fa96
parents 2ae769da 65a91ed6
version: 2
version: 2.1
jobs:
build-arm-docker-ubuntu-20-py39:
machine:
image: ubuntu-2004:202101-01
resource_class: arm.medium
#docker:
# - image: ubuntu:20.04
steps:
- run:
name: CPU info
command: cat /proc/cpuinfo; lscpu
- run:
name: Ubuntu packages
command: |
sudo apt update && sudo apt install -y apt-utils
DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends make gcc patch git openssh-client file pkg-config wget curl swig netpbm wcslib-dev wcslib-tools zlib1g-dev libbz2-dev libcairo2-dev libcfitsio-dev libcfitsio-bin libgsl-dev libjpeg-dev libnetpbm10-dev libpng-dev python3.9-dev libpython3.9-dev ca-certificates
sudo apt clean && sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3.9 get-pip.py
rm get-pip.py
- run:
name: Python packages
command: |
pip3 install numpy
pip3 install fitsio
- checkout
- run:
name: Make
command: |
export PYTHON=python3.9
make
make py
make extra
make test
- run:
name: Tests
command: |
export PYTHON=python3.9
(cd util && ./test)
(cd libkd && ./test)
(cd solver && ./test)
(cd plot && ./test)
make install INSTALL_DIR=~/an PYTHON_SCRIPT="/usr/bin/env python3.9"
export PYTHONPATH=${PYTHONPATH}:~/an/lib/python
(cd /tmp && $PYTHON -c "import astrometry.libkd.spherematch")
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
solve-field --config 99.cfg demo/apod4.jpg --continue
tablist demo/apod4.match
listhead demo/apod4.wcs
(cd /tmp && $PYTHON -c "import astrometry.util.util; print(dir(astrometry.util.util))")
solve-field --config demo/cfg demo/apod5.jpg --continue --no-tweak --objs 60
listhead demo/apod5.wcs
build-docker-ubuntu-20-py39:
docker:
- image: ubuntu:20.04
......@@ -49,6 +105,8 @@ jobs:
tablist demo/apod4.match
listhead demo/apod4.wcs
(cd /tmp && $PYTHON -c "import astrometry.util.util; print(dir(astrometry.util.util))")
solve-field --config demo/cfg demo/apod5.jpg --continue --no-tweak --objs 60
listhead demo/apod5.wcs
build-docker-ubuntu-18:
docker:
......@@ -93,6 +151,8 @@ jobs:
tablist demo/apod4.match
listhead demo/apod4.wcs
(cd /tmp && python3 -c "import astrometry.util.util; print(dir(astrometry.util.util))")
solve-field --config demo/cfg demo/apod5.jpg --continue --no-tweak --objs 60
listhead demo/apod5.wcs
build-docker-centos-8:
docker:
......@@ -147,6 +207,8 @@ jobs:
solve-field --config 99.cfg demo/apod4.jpg --continue
tablist demo/apod4.match
listhead demo/apod4.wcs
solve-field --config demo/cfg demo/apod5.jpg --continue --no-tweak --objs 60
listhead demo/apod5.wcs
workflows:
version: 2
......@@ -155,3 +217,4 @@ workflows:
- "build-docker-ubuntu-20-py39"
- "build-docker-ubuntu-18"
- "build-docker-centos-8"
- "build-arm-docker-ubuntu-20-py39"
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '41 6 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
......@@ -60,7 +60,7 @@ Now, some miscellaneous files:
From http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-libkd/an-fls.h
(c) Linus Torvalds, GPL v2
From FreeBSD; BSD 3-clause.
Data files:
......@@ -69,10 +69,14 @@ Data files:
IAU Constellation boundaries, in J2000, from
http://vizier.cfa.harvard.edu/viz-bin/VizieR-3?-source=VI/49/bound_20
-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/
-catalogs/brightstars.fits and catalogs/brightstars-data.c
From merging Stellarium's skycultures/*/star_names.fab data files with Hipparcos catalog.
Stellarium is copyright (C) 2004-2019 Fabien Chereau et al.,
and licensed under GPL v2+.
......@@ -222,7 +222,7 @@ config: util/os-features-config.h util/makefile.os-features
$(MAKE) -C util config
.PHONY: config
RELEASE_VER := 0.85
RELEASE_VER := 0.88
RELEASE_DIR := astrometry.net-$(RELEASE_VER)
RELEASE_RMDIRS := net
......@@ -237,7 +237,7 @@ release:
(cd $(RELEASE_DIR)/plot && 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.85
cat $(RELEASE_DIR)/Makefile | sed "s/RELEASE_VER := 0.88
tar cf $(RELEASE_DIR).tar $(RELEASE_DIR)
gzip --best -c $(RELEASE_DIR).tar > $(RELEASE_DIR).tar.gz
bzip2 --best $(RELEASE_DIR).tar
......
......@@ -27,7 +27,8 @@ Mierle and Sam Roweis (the Astrometry.net Team).
Contributions from Sjoert van Velzen, Themos Tsikas, Andrew Hood,
Thomas Stibor, Denis Vida, Ole Streicher, David Warde-Farley, Jon
Barron, Christopher Stumm, Michal Kočer (Klet Observatory) and others.
Barron, Christopher Stumm, Michal Kočer (Klet Observatory), Vladimir
Kouprianov and others.
Parts of the code written by the Astrometry.net Team are licensed
under a 3-clause BSD-style license. See the file LICENSE for the full
......@@ -37,6 +38,8 @@ the GNU GPL, the whole work must be distributed under the GPL version
Code development happens at http://github.com/dstndstn/astrometry.net
The web service is at http://nova.astrometry.net
The documentation is at http://astrometry.net/doc
There is a (google group) forum at http://astrometry.net/group
......@@ -45,8 +48,6 @@ Additional stuff at http://astrometry.net
Code snapshots and releases are at http://astrometry.net/downloads
The web service is at http://nova.astrometry.net
For academic use, please cite the paper:
> Lang, D., Hogg, D.W., Mierle, K., Blanton, M., & Roweis, S.,
......
__version__ = '0.84-57-g73ae3793'
__version__ = '0.87-10-gd7855b91'
......@@ -42,15 +42,24 @@ grab-stellarium-constellations: grab-stellarium-constellations.o \
starutil.o mathutil.o bl.o an-endian.o errors.o log.o ioutils.o qsort_reentrant.o tic.o
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS)
# brightstars-data.c and brightstars.fits:
# I fetched hip.fits by visiting
# http://vizier.u-strasbg.fr/viz-bin/VizieR-3?-source=I/239/hip_main
# and selecting FITS binary output, and columns HIP, Vmag, _RA.icrs, _DE.icrs
# the latter of which are ICRS, epoch 2000 coordinates.
#
# Then ran:
# python brightstars.py /Applications/Stellarium.app/Contents/Resources/skycultures/western/star_names.fab hip.fits brightstars.fits --letternames /Applications/Stellarium.app/Contents/Resources/stars/default/name.fab --brightstars brightstars-data.c --multi
OBJS := openngc.o brightstars.o constellations.o \
tycho2-fits.o tycho2.o usnob-fits.o usnob.o nomad.o nomad-fits.o \
ucac3-fits.o ucac3.o ucac4-fits.o ucac4.o 2mass-fits.o 2mass.o hd.o \
constellation-boundaries.o
ucac3-fits.o ucac3.o ucac4-fits.o ucac4.o ucac5-fits.o ucac5.o \
2mass-fits.o 2mass.o hd.o constellation-boundaries.o
HEADERS := brightstars.h constellations.h openngc.h \
tycho2.h tycho2-fits.h usnob-fits.h usnob.h nomad-fits.h nomad.h \
2mass-fits.h 2mass.h hd.h ucac3.h ucac4.h constellation-boundaries.h
2mass-fits.h 2mass.h hd.h ucac3.h ucac4.h ucac5.h constellation-boundaries.h
HEADERS_PATH := $(addprefix $(INCLUDE_DIR)/,$(HEADERS))
......@@ -90,7 +99,7 @@ $(LIBCAT): $(OBJS)
$(RANLIB) $@
PROGS := build-hd-tree tycho2tofits usnobtofits nomadtofits \
2masstofits
2masstofits ucac5tofits
#ucac3tofits ucac4tofits
# not built by default
......@@ -104,6 +113,10 @@ ucac4tofits: ucac4tofits.o $(SLIB)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS) -lbz2
ALL_OBJ += ucac4tofits.o
ucac5tofits: ucac5tofits.o $(SLIB)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS) -lbz2
ALL_OBJ += ucac5tofits.o
2masstofits: 2masstofits.o $(SLIB)
echo ZLIB_LIB is $(ZLIB_LIB)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS) $(ZLIB_LIB)
......@@ -120,23 +133,23 @@ hd1.fits: henry-draper.tsv build-hd-tree
# hd.fits: you can grab a pre-built one from:
# http://data.astrometry.net/hd.fits
# The instructions below are commented-out because some of the URLs have disappeared.
#
#
# hd.fits: henry-draper.tsv build-hd-tree tycho2.fits tyc2_hd.dat
# build-hd-tree -s -R 16 -T tycho2.fits -X tyc2_hd.dat henry-draper.tsv $@
#
#
# tyc2_hd.dat:
# wget "ftp://cdsarc.u-strasbg.fr/pub/cats/IV/25/tyc2_hd.dat.gz" -O $@.gz
# gunzip $@.gz
#
#
# henry-draper.tsv:
# wget "http://trac.astrometry.net/browser/binary/henry-draper/henry-draper.tsv?format=txt" -O $@
#
#
# tycho2.fits: catalog.dat suppl_1.dat
# tycho2tofits -o $@ $^
#
#
# catalog.dat:
# wget -c http://www.astro.ku.dk/~cf/CD/data/catalog.dat
#
#
# suppl_1.dat:
# wget -c http://www.astro.ku.dk/~cf/CD/data/suppl_1.dat
......@@ -171,9 +184,9 @@ pyinstall: $(PYTHON_INSTALL)
ALL_TEST_FILES = test_tycho2 test_usnob test_nomad test_2mass test_hd \
test_boundaries
ALL_TEST_EXTRA_OBJS =
ALL_TEST_EXTRA_OBJS =
ALL_TEST_LIBS = $(SLIB)
ALL_TEST_EXTRA_LDFLAGS =
ALL_TEST_EXTRA_LDFLAGS =
include $(COMMON)/makefile.tests
$(ALL_TEST_FILES): $(SLIB)
......
This diff is collapsed.
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
# Creates brightstars.fits and brightstars-data.c
# from the HIP catalog from Vizier
# and the Stellarium skycultures.
# Stellarium is licensed under GPL v2+.
# I fetched hip.fits by visiting
# http://vizier.u-strasbg.fr/viz-bin/VizieR-3?-source=I/239/hip_main
# and selecting FITS binary output, and columns HIP, Vmag, _RA.icrs, _DE.icrs
# the latter of which are ICRS, epoch 2000 coordinates.
def main():
from astrometry.util.fits import fits_table
import numpy as np
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('skyculture', help='Stellarium skyculture/XXX/star-names.fab file')
parser.add_argument('hip', help='Hipparcos catalog')
parser.add_argument('out', help='Output filename')
parser.add_argument('--brightstars', help='brightstars-data.c output filename')
parser.add_argument('--multi', default=False, action='store_true', help='Keep multiple names (default is keep the first one only')
parser.add_argument('--letternames', type=str, help='Stellarium stars/default/name.fab data file')
opt = parser.parse_args()
starnames = opt.skyculture
hipfn = opt.hip
H = fits_table(hipfn)
H.ra = H.get('_ra_icrs')
H.dec = H.get('_de_icrs')
hipmap = dict([(h,i) for i,h in enumerate(H.hip)])
got_hipnums = {}
bright = fits_table()
bright.hip = []
bright.ra = []
bright.dec = []
bright.vmag = []
bright.names = []
bright.letternames = []
filenames = [(starnames, False)]
if opt.letternames:
filenames.append((opt.letternames, True))
for fn,is_letter in filenames:
f = open(fn, 'r')
for line in f.readlines():
line = line.strip()
if line.startswith('#'):
continue
if len(line) == 0:
continue
hipnum = line.split('|')[0]
hipnum = int(hipnum)
if not is_letter:
startstr = '_("'
i0 = line.index(startstr) + len(startstr)
endstr = '")'
i1 = line.index(endstr)
name = line[i0:i1]
else:
name = line.split('|')[1]
name = name.replace('_', ' ')
name = name.encode('ascii', 'backslashreplace')
hipi = hipmap[hipnum]
print('Name', name, 'HIP', hipnum, H.ra[hipi], H.dec[hipi])
ra = H.ra[hipi]
if not np.isfinite(ra):
print('Null HIP entry?')
continue
if hipnum in got_hipnums:
i = got_hipnums[hipnum]
print('Appending to previous: HIP', bright.hip[i], 'names',
bright.letternames[i], 'and', bright.names[i])
if is_letter:
bright.letternames[i].append(name)
else:
bright.names[i].append(name)
continue
bright.hip.append(hipnum)
bright.ra.append(H.ra[hipi])
bright.dec.append(H.dec[hipi])
bright.vmag.append(H.vmag[hipi])
if is_letter:
bright.letternames.append([name])
bright.names.append([])
else:
bright.letternames.append([])
bright.names.append([name])
i = len(bright.hip)-1
assert(hipnum not in got_hipnums)
assert(bright.hip[i] == hipnum)
got_hipnums[hipnum] = i
if opt.multi:
bright.names = [b' / '.join(n) for n in bright.names]
bright.letternames = [b' / '.join(n) for n in bright.letternames]
else:
bright.names = [n[0] if len(n) else b'' for n in bright.names]
bright.letternames = [n[0] if len(n) else b'' for n in bright.letternames]
bright.to_np_arrays()
bright.rename('letternames', 'name1')
bright.rename('names', 'name2')
bright.writeto(opt.out)
if opt.brightstars:
f = open(opt.brightstars, 'wb')
f.write(b'// Autogenerated by brightstars.py\n')
f.write(b'{')
for b in bright:
f.write((b'{ "%s", "%s", %f, %f, %f},\n' % (b.name1, b.name2, b.ra, b.dec, b.vmag)))
f.write(b'}')
f.close()
if __name__ == '__main__':
main()
#!/bin/sh
# Build the full set of UCAC5 indexes
# Copyright 2021 Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
# Licensed under a 3-clause BSD style license - see LICENSE
# This script assumes that uncompressed UCAC5 files (z001..z900) are present in the current directory
# and that the following Astrometry.net binaries are on the path:
# 1. ucac5tofits
# 2. build-astrometry-index
# Modify this as appropriate; set to 0 to use the original UCAC epochs
EPOCH=2022
# Set index file overlapping to approx. half of the FOV in degrees
MARGIN=2
# Set to 1 if you want tag-along data in the indexes:
# ID, RA_GAIA, DEC_GAIA, RA_GAIA_ERR, DEC_GAIA_ERR, FLAGS, NUM_POS, UCAC_EPOCH,
# RA_UCAC, DEC_UCAC, PM_RA, PM_DEC, PM_RA_ERR, PM_DEC_ERR, GMAG, RMAG, JMAG, HMAG, KMAG
FULL=0
# Number of parallel index build jobs (perhaps number of CPU cores if enough RAM)
JOBS=8
# Common prefix for index files
PREFIX="ucac5-index-"
DATE=$(date "+%y%m%d")
# Store temporary files in the current dir
mkdir tmp
# Build scales from 0 to 2 with NSIDE=2 (48 healpix)
NSIDE=2
ucac5tofits -N $NSIDE -e $EPOCH -m $MARGIN -f $FULL -o ucac5_%02i.fits z???
NJOBS=0
HP=0
while [ $HP -lt 48 ]; do
for SCALE in 0 1 2; do
# shellcheck disable=SC2046 disable=SC2086
build-astrometry-index -A RA -D DEC -S MAG -E -t tmp -j 0.06 -P $SCALE -H $HP -s $NSIDE \
-I $DATE$(printf %02i $SCALE) -i ucac5_$(printf %02i $HP).fits \
-o $PREFIX$(printf %02i $SCALE)-$(printf %02i $HP).fits &
NJOBS=$((NJOBS+1))
if [ $NJOBS -ge $JOBS ]; then
NJOBS=0
wait
fi
done
HP=$((HP+1))
done
wait
rm ucac5_??.fits tmp/*
# Build scales from 3 to 6 with NSIDE=1 (12 healpix)
NSIDE=1
ucac5tofits -N $NSIDE -e $EPOCH -m $MARGIN -f $FULL -o ucac5_%02i.fits z???
NJOBS=0
HP=0
while [ $HP -lt 12 ]; do
for SCALE in 3 4 5 6; do
# shellcheck disable=SC2046 disable=SC2086
build-astrometry-index -A RA -D DEC -S MAG -E -t tmp -j 0.06 -P $SCALE -H $HP -s $NSIDE \
-I $DATE$(printf %02i $SCALE) -i ucac5_$(printf %02i $HP).fits \
-o $PREFIX$(printf %02i $SCALE)-$(printf %02i $HP).fits &
NJOBS=$((NJOBS+1))
if [ $NJOBS -ge $JOBS ]; then
NJOBS=0
wait
fi
done
HP=$((HP+1))
done
wait
rm ucac5_??.fits tmp/*
# Build scales from 7 to 19 with a single all-sky healpix
ucac5tofits -N 0 -e $EPOCH -f $FULL -o ucac5.fits z???
NJOBS=0
for SCALE in 7 8 9 10 11 12 13 14 15 16 17 18 19; do
# shellcheck disable=SC2046 disable=SC2086
build-astrometry-index -A RA -D DEC -S MAG -E -t tmp -j 0.06 -P $SCALE \
-I $DATE$(printf %02i $SCALE) -i ucac5.fits \
-o $PREFIX$(printf %02i $SCALE).fits &
NJOBS=$((NJOBS+1))
if [ $NJOBS -ge $JOBS ]; then
NJOBS=0
wait
fi
done
wait
# Done
rm -rf ucac5.fits tmp
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
// Author: Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include "ucac5-fits.h"
#include "fitsioutils.h"
// This is a naughty preprocessor function because it uses variables
// declared in the scope from which it is called.
#define ADDARR(ctype, ftype, col, units, member, arraysize) \
if (write) { \
fitstable_add_column_struct \
(tab, ctype, arraysize, offsetof(ucac5_entry, member), \
ftype, col, units, TRUE); \
} else { \
fitstable_add_column_struct \
(tab, ctype, arraysize, offsetof(ucac5_entry, member), \
any, col, units, TRUE); \
}
#define ADDCOL(ctype, ftype, col, units, member) \
ADDARR(ctype, ftype, col, units, member, 1)
static void add_columns(fitstable_t* tab, anbool write, anbool full) {
tfits_type any = fitscolumn_any_type();
tfits_type d = fitscolumn_double_type();
tfits_type f = fitscolumn_float_type();
tfits_type u8 = fitscolumn_u8_type();
tfits_type i64 = fitscolumn_i64_type();
char* nil = " ";
if (full)
ADDCOL(i64, i64, "ID", nil, srcid);
ADDCOL(d, d, "RA", "deg", ra);
ADDCOL(d, d, "DEC", "deg", dec);
if (full) {
ADDCOL(d, d, "RA_GAIA", "deg", rag);
ADDCOL(d, d, "DEC_GAIA", "deg", dcg);
ADDCOL(f, f, "RA_GAIA_ERR", "deg", erg);
ADDCOL(f, f, "DEC_GAIA_ERR", "deg", erg);
ADDCOL(u8, u8, "FLAGS", nil, flg);
ADDCOL(u8, u8, "NUM_POS", nil, nu);
ADDCOL(f, f, "UCAC_EPOCH", "yr", epu);
ADDCOL(d, d, "RA_UCAC", "deg", ira);
ADDCOL(d, d, "DEC_UCAC", "deg", idc);
ADDCOL(f, f, "PM_RA", "deg/yr", pmur);
ADDCOL(f, f, "PM_DEC", "deg/yr", pmud);
ADDCOL(f, f, "PM_RA_ERR", "deg/yr", pmer);
ADDCOL(f, f, "PM_DEC_ERR", "deg/yr", pmed);
ADDCOL(f, f, "GMAG", "mag", gmag);
}
ADDCOL(f, f, "MAG", "mag", umag);
if (full) {
ADDCOL(f, f, "RMAG", "mag", rmag);
ADDCOL(f, f, "JMAG", "mag", jmag);
ADDCOL(f, f, "HMAG", "mag", hmag);
ADDCOL(f, f, "KMAG", "mag", kmag);
}
}
#undef ADDCOL
#undef ADDARR
ucac5_entry* ucac5_fits_read_entry(ucac5_fits* cat) {
return (ucac5_entry*)fitstable_next_struct(cat);
}
int ucac5_fits_read_entries(ucac5_fits* cat, int offset,
int count, ucac5_entry* entries) {
return fitstable_read_structs(cat, entries, sizeof(ucac5_entry), offset, count);
}
int ucac5_fits_write_entry(ucac5_fits* cat, ucac5_entry* entry) {
return fitstable_write_struct(cat, entry);
}
int ucac5_fits_count_entries(ucac5_fits* cat) {
return fitstable_nrows(cat);
}
int ucac5_fits_close(ucac5_fits* ucac5) {
return fitstable_close(ucac5);
}
ucac5_fits* ucac5_fits_open(char* fn, anbool full) {
ucac5_fits* cat = NULL;
cat = fitstable_open(fn);
if (!cat)
return NULL;
add_columns(cat, FALSE, full);
fitstable_use_buffered_reading(cat, sizeof(ucac5_entry), 1000);
if (fitstable_read_extension(cat, 1)) {
fprintf(stderr, "ucac5-fits: table in extension 1 didn't contain the required columns.\n");
fprintf(stderr, " missing: ");
fitstable_print_missing(cat, stderr);
fprintf(stderr, "\n");
ucac5_fits_close(cat);
return NULL;
}
return cat;
}
ucac5_fits* ucac5_fits_open_for_writing(char* fn, anbool full) {
ucac5_fits* cat;
qfits_header* hdr;
cat = fitstable_open_for_writing(fn);
if (!cat)
return NULL;
add_columns(cat, TRUE, full);
hdr = fitstable_get_primary_header(cat);
qfits_header_add(hdr, "UCAC5", "T", "This is a UCAC5 catalog.", NULL);
qfits_header_add(hdr, "AN_FILE", AN_FILETYPE_UCAC5, "Astrometry.net file type", NULL);
return cat;
}
int ucac5_fits_write_headers(ucac5_fits* cat) {
if (fitstable_write_primary_header(cat))
return -1;
return fitstable_write_header(cat);
}
int ucac5_fits_fix_headers(ucac5_fits* cat) {
if (fitstable_fix_primary_header(cat))
return -1;
return fitstable_fix_header(cat);
}
/*
This file is part of the Astrometry.net suite.
Copyright 2011 Dustin Lang.
Copyright 2013 Michal Kočer, Klet Observatory.
Copyright 2021 Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
The Astrometry.net suite is free software; you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2.
The Astrometry.net suite is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Astrometry.net suite ; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Author: Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
#ifndef UCAC5_FITS_H
#define UCAC5_FITS_H
#include <stdio.h>
#include "astrometry/ucac5.h"
#include "astrometry/fitstable.h"
#define AN_FILETYPE_UCAC5 "UCAC5"
typedef fitstable_t ucac5_fits;
ucac5_fits* ucac5_fits_open(char* fn, anbool full);
ucac5_fits* ucac5_fits_open_for_writing(char* fn, anbool full);
int ucac5_fits_write_headers(ucac5_fits* ucac5);
int ucac5_fits_fix_headers(ucac5_fits* ucac5);
int ucac5_fits_count_entries(ucac5_fits* ucac5);
ucac5_entry* ucac5_fits_read_entry(ucac5_fits* t);
int ucac5_fits_read_entries(ucac5_fits* ucac5, int offset,
int count, ucac5_entry* entries);
int ucac5_fits_close(ucac5_fits* ucac5);
int ucac5_fits_write_entry(ucac5_fits* ucac5, ucac5_entry* entry);
#endif
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
// Author: Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include "ucac5.h"
#include "an-endian.h"
#include "starutil.h"
static int64_t grab_i64(void** v) {
int64_t val = (int64_t)u64_letoh(*((uint64_t*)(*v)));
*v = (((int64_t*)(*v)) + 1);
return val;
}
static uint32_t grab_u32(void** v) {
uint32_t uval = u32_letoh(*((uint32_t*)(*v)));
*v = (((uint32_t*)(*v)) + 1);
return uval;
}
static int32_t grab_i32(void** v) {
int32_t val = (int32_t)u32_letoh(*((uint32_t*)(*v)));
*v = (((int32_t*)(*v)) + 1);
return val;
}
static uint16_t grab_u16(void** v) {
uint16_t uval = u16_letoh(*((uint16_t*)(*v)));
*v = (((uint16_t*)(*v)) + 1);
return uval;
}
static int16_t grab_i16(void** v) {
int16_t val = (int16_t)u16_letoh(*((uint16_t*)(*v)));
*v = (((int16_t*)(*v)) + 1);
return val;
}
static uint8_t grab_u8(void** v) {
uint8_t val = *((uint8_t*)(*v));
*v = (((uint8_t*)(*v)) + 1);
return val;
}
int ucac5_parse_entry(ucac5_entry* entry, const void* encoded, float epoch) {
//const uint32_t* udata = encoded;
uint32_t uval;
void* buf = (void*)encoded;
// RESIST THE URGE TO RE-ORDER THESE, bonehead!
entry->srcid = grab_i64(&buf);
entry->rag = arcsec2deg(grab_u32(&buf) * 0.001);
entry->dcg = arcsec2deg(grab_i32(&buf) * 0.001);
entry->erg = arcsec2deg(grab_u16(&buf) * 0.0001);
entry->edg = arcsec2deg(grab_u16(&buf) * 0.0001);
entry->flg = grab_u8(&buf);
entry->nu = grab_u8(&buf);
entry->epu = grab_i16(&buf) * 0.001 + 1997.0;
entry->ira = arcsec2deg(grab_u32(&buf) * 0.001);
entry->idc = arcsec2deg(grab_i32(&buf) * 0.001);
entry->pmur = arcsec2deg(grab_i16(&buf) * 0.0001);
entry->pmud = arcsec2deg(grab_i16(&buf) * 0.0001);
entry->pmer = arcsec2deg(grab_u16(&buf) * 0.0001);
entry->pmed = arcsec2deg(grab_u16(&buf) * 0.0001);
// Apply proper motions
if (epoch) {
float dt = epoch - entry->epu;
double cosDec = cos(entry->idc*M_PI/180.0);
double dra = entry->pmur*(cosDec ? dt/cosDec : dt);
double ra = fmod(entry->ira + dra, 360.0);
double dec = entry->idc + entry->pmud*dt;
if (dec > 90.0) {
dec = 180.0 - dec;
ra = fmod(ra + 180.0, 360.0);
}
else if (dec < -90.0) {
dec = -180.0 - dec;
ra = fmod(ra + 180.0, 360.0);
}
entry->ra = ra;
entry->dec = dec;
}
else {
entry->ra = entry->ira;
entry->dec = entry->idc;
}
entry->gmag = grab_i16(&buf) * 0.001;
entry->umag = grab_i16(&buf) * 0.001;
entry->rmag = grab_i16(&buf) * 0.001;
entry->jmag = grab_i16(&buf) * 0.001;
entry->hmag = grab_i16(&buf) * 0.001;
entry->kmag = grab_i16(&buf) * 0.001;
return 0;
}
/*
# This file is part of the Astrometry.net suite.
# Licensed under a 3-clause BSD style license - see LICENSE
*/
// Convert UCAC5 z??? files to FITS
// Author: Vladimir Kouprianov, Skynet RTN, University of North Carolina at Chapel Hill
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <bzlib.h>
#include "ucac5-fits.h"
#include "ucac5.h"
#include "anqfits.h"
#include "healpix.h"
#include "healpix-utils.h"
#include "bl.h"
#include "starutil.h"
#include "fitsioutils.h"
#include "log.h"
#include "errors.h"
#include "boilerplate.h"
#define OPTIONS "ho:N:e:m:f:"
void print_help(char* progname) {
BOILERPLATE_HELP_HEADER(stdout);
printf("\nUsage:\n"
" %s -o <output-filename-template> (default: ucac5_%%02i.fits)\n"
" [-N <healpix-nside>] (default = 0)\n"
" [-e <epoch in years>] (default = UCAC epoch)\n"
" [-m <margin in degrees>] (default = 0)\n"
" [-f <1 = include tag-along data>] (default = 0)\n"
" <input-file> [<input-file> ...]\n"
"\n"
"The output-filename-template should contain a \"printf\" sequence like \"%%03i\";\n"
"we use \"sprintf(filename, output-filename-template, healpix)\"\n"
"to determine the filename to be used for each healpix.\n\n"
"-N 0 means output the whole catalog to a single all-sky healpix, which is useful\n"
"for large-scale indexes; in this case, margin is ignored.\n\n"
"\nNOTE: WE ASSUME THE UCAC5 FILES ARE GIVEN ON THE COMMAND LINE IN ORDER:\n"
"z001, z002, ..., z900.\n\n",
progname);
}
int main(int argc, char** args) {
char* outfn = "ucac5_%02i.fits";
int c;
int startoptind;
int nrecords, nfiles;
int Nside = 0;
float epoch = 0.0;
double margin = 0.0;
anbool full = FALSE;
ucac5_fits** ucacs;
int i, HP;
while ((c = getopt(argc, args, OPTIONS)) != -1) {
switch (c) {
case '?':
case 'h':
print_help(args[0]);
exit(0);
case 'N':
Nside = atoi(optarg);
break;
case 'e':
epoch = atof(optarg);
break;
case 'm':
margin = atof(optarg);
break;
case 'f':
full = atoi(optarg);
break;
case 'o':
outfn = optarg;
break;
}
}
log_init(LOG_MSG);
if (!outfn || (optind == argc)) {
print_help(args[0]);
exit(-1);
}
if (Nside < 0) {
fprintf(stderr, "Nside must be >= 0.\n");
print_help(args[0]);
exit(-1);
}
if (Nside) {
HP = 12 * Nside * Nside;
printf("Nside = %i, using %i healpixes.\n", Nside, HP);
}
else {
HP = 1;
printf("Using one all-sky healpix.\n");
}
ucacs = calloc(HP, sizeof(ucac5_fits*));
nrecords = 0;
nfiles = 0;
startoptind = optind;
for (; optind<argc; optind++) {
char* infn;
FILE* fid;
int i;
infn = args[optind];
printf("Reading %s\n", infn);
if ((optind > startoptind) && ((optind - startoptind) % 100 == 0)) {
printf("\nReading file %i of %i: %s\n", optind - startoptind,
argc - startoptind, infn);
}
fflush(stdout);
fid = fopen(infn, "rb");
if (!fid) {
SYSERROR("Couldn't open input file \"%s\"", infn);
exit(-1);
}
for (i=0;; i++) {
ucac5_entry entry;
il *hplist;
char buf[UCAC5_RECORD_SIZE];
int nr;
anbool eof = 0;
nr = fread(buf, UCAC5_RECORD_SIZE, 1, fid);
if (!nr) {
if (feof(fid))
eof = TRUE;
else {
SYSERROR("Error reading input file \"%s\".", infn);
exit(-1);
}
}
if (ucac5_parse_entry(&entry, buf, epoch)) {
ERROR("Failed to parse UCAC5 entry %i in file \"%s\".", i, infn);
exit(-1);
}
if (Nside) {
if (margin > 0.0)
hplist = healpix_rangesearch_radec(entry.ra, entry.dec, margin, Nside, NULL);
else {
int hp = radecdegtohealpix(entry.ra, entry.dec, Nside);
hplist = il_new(1);
il_append(hplist, hp);
}
}
else {
hplist = il_new(1);
il_append(hplist, 0);
}
for (int ihp=0; ihp<il_size(hplist); ihp++) {
int hp = il_get(hplist, ihp);
if (!ucacs[hp]) {
char fn[256];
sprintf(fn, outfn, hp);
ucacs[hp] = ucac5_fits_open_for_writing(fn, full);
if (!ucacs[hp]) {
ERROR("Failed to initialize FITS file %i (filename %s)", hp, fn);
exit(-1);
}
fits_header_add_int(ucacs[hp]->header, "HEALPIX", hp, "The healpix number of this catalog.");
fits_header_add_int(ucacs[hp]->header, "NSIDE", Nside ? Nside : 1, "The healpix resolution.");
BOILERPLATE_ADD_FITS_HEADERS(ucacs[hp]->header);
qfits_header_add(ucacs[hp]->header, "HISTORY", "Created by the program \"ucac5tofits\"", NULL, NULL);
qfits_header_add(ucacs[hp]->header, "HISTORY", "ucac5tofits command line:", NULL, NULL);
fits_add_args(ucacs[hp]->header, args, argc);
qfits_header_add(ucacs[hp]->header, "HISTORY", "(end of command line)", NULL, NULL);
if (ucac5_fits_write_headers(ucacs[hp])) {
ERROR("Failed to write header for FITS file %s", fn);
exit(-1);
}
}
if (ucac5_fits_write_entry(ucacs[hp], &entry)) {
ERROR("Failed to write FITS entry");
exit(-1);
}
nrecords++;
}
il_free(hplist);
if (eof)
break;
}
fclose(fid);
nfiles++;
printf("\n");
}
printf("\n");
// close all the files...
for (i=0; i<HP; i++) {
if (!ucacs[i])
continue;
if (ucac5_fits_fix_headers(ucacs[i]) ||
ucac5_fits_close(ucacs[i])) {
ERROR("Failed to close file %i", i);
}
}
printf("Read %u files, %u records.\n", nfiles, nrecords);
free(ucacs);
return 0;
}
......@@ -10,11 +10,11 @@
#include "os-features.h"
#include "scamp-catalog.h"
#include "usnob-fits.h"
//#include "healpix-utils.h"
#include "healpix.h"
#include "starutil.h"
#include "errors.h"
#include "log.h"
#include "mathutil.h"
const char* OPTIONS = "hu:o:A:D:r:n:RBNv";
......@@ -92,7 +92,7 @@ int main(int argc, char** args) {
}
log_init(loglvl);
if (ra == HUGE_VAL || dec == HUGE_VAL || !usnobpath || !scampref || radius == 0.0 || !nside) {
if (ra == LARGE_VAL || dec == LARGE_VAL || !usnobpath || !scampref || radius == 0.0 || !nside) {
print_help(args[0]);
printf("\n\nNeed RA, Dec, USNOB path, Nside, Scamp output file, and radius.\n");
exit(-1);
......
......@@ -127,6 +127,12 @@ use Fink you will need to add something like this in your
export CFLAGS="-I/usr/local/include -I/sw/include"
export LDFLAGS="-L/usr/local/lib -L/sw/lib"
Windows 10/11:
^^^^^^^^^^^^^^^^^^^^
Since there is `Windows Subsystem for Linux (WSL) <https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux>` compatibility layer available on Windows 10/11 OS, you can follow the WSL install `guide <https://docs.microsoft.com/en-us/windows/wsl/install>`.
Once WSL is installed, the build steps are the same as for Debian/Ubuntu-like systems. See above.
Getting/Building
----------------
......
......@@ -226,8 +226,9 @@ Copyrights and credits for the demo images are listed in the file
Note that you can also give solve-field a URL rather than a file as input::
$ solve-field --out apod1b http://antwrp.gsfc.nasa.gov/apod/image/0302/ngc2264_croman_c3.jpg
$ solve-field --out apod1b --downsample 2 http://antwrp.gsfc.nasa.gov/apod/image/0302/ngc2264_croman_c3.jpg
(this one will work with index file 4108).
If you don't have the netpbm tools (eg jpegtopnm), do this instead:
......
......@@ -30,11 +30,14 @@
int is_big_endian();
uint16_t u16_letoh(uint16_t i);
uint16_t u16_htole(uint16_t i);
uint32_t u32_letoh(uint32_t i);
uint32_t u32_htole(uint32_t i);
uint16_t u16_letoh(uint16_t i);
uint16_t u16_htole(uint16_t i);
uint64_t u64_letoh(uint64_t i);
uint64_t u64_htole(uint64_t i);
void v32_htole(void* p);
void v16_htole(void* p);
......
......@@ -11,8 +11,9 @@
#define KDTREE_MAX_LEVELS 1000
#define KDT_INFTY_DOUBLE HUGE_VAL
#define KDT_INFTY_FLOAT HUGE_VALF
// negatives of these values should be valid also
#define KDT_LARGEVAL 1e308
#define KDT_LARGEVALF 1e38
enum kd_rangesearch_options {
KD_OPTIONS_COMPUTE_DISTS = 0x1,
......@@ -73,20 +74,23 @@ enum kd_types {
KDT_DATA_FLOAT = 0x2,
KDT_DATA_U32 = 0x4,
KDT_DATA_U16 = 0x8,
KDT_DATA_U64 = 0x10,
KDT_TREE_NULL = 0,
KDT_TREE_DOUBLE = 0x100,
KDT_TREE_FLOAT = 0x200,
KDT_TREE_U32 = 0x400,
KDT_TREE_U16 = 0x800,
KDT_TREE_U64 = 0x1000,
KDT_EXT_NULL = 0,
KDT_EXT_DOUBLE = 0x10000,
KDT_EXT_FLOAT = 0x20000
KDT_EXT_FLOAT = 0x20000,
KDT_EXT_U64 = 0x40000
};
typedef enum kd_types kd_types;
#define KDT_DATA_MASK 0xf
#define KDT_TREE_MASK 0xf00
#define KDT_EXT_MASK 0x30000
#define KDT_DATA_MASK 0x1f
#define KDT_TREE_MASK 0x1f00
#define KDT_EXT_MASK 0x70000
/*
Possible values for the "treetype" member.
......@@ -97,6 +101,10 @@ typedef enum kd_types kd_types;
(c) the external type.
These are called the "data", "tree", and "ext" types.
For each of these entries, there is a kdint_XXX.c file with the implementation.
When adding a new one, you must also add it to KD_DECLARE and KD_DISPATCH in
kdtree_internal.h.
*/
enum kd_tree_types {
KDTT_NULL = 0,
......@@ -107,6 +115,9 @@ enum kd_tree_types {
/* "All floats, all the time". */
KDTT_FLOAT = KDT_EXT_FLOAT | KDT_DATA_FLOAT | KDT_TREE_FLOAT,
/* "All U64, all the time". */
KDTT_U64 = KDT_EXT_U64 | KDT_DATA_U64 | KDT_TREE_U64,
/* Data are "doubles", tree is u32. aka inttree. */
KDTT_DOUBLE_U32 = KDT_EXT_DOUBLE | KDT_DATA_DOUBLE | KDT_TREE_U32,
......@@ -184,6 +195,7 @@ struct kdtree {
union {
float* f;
double* d;
u64* l;
u32* u;
u16* s;
void* any;
......@@ -195,6 +207,7 @@ struct kdtree {
union {
float* f;
double* d;
u64* l;
u32* u;
u16* s;
void* any;
......@@ -212,6 +225,7 @@ struct kdtree {
union {
float* f;
double* d;
u64* l;
u32* u;
u16* s;
void* any;
......@@ -253,6 +267,7 @@ struct kdtree_qres {
union {
double* d;
float* f;
u64* l;
u32* u;
u16* s;
void* any;
......@@ -530,61 +545,56 @@ void kdtree_output_dot(FILE* fid, kdtree_t* kd);
When you're done with your tree, kdtree_free() it.
*/
kdtree_t* KDFUNC(kdtree_build)
(kdtree_t* kd, void *data, int N, int D, int Nleaf,
int treetype, unsigned int options);
kdtree_t* KDFUNC(kdtree_build_2)
(kdtree_t* kd, void *data, int N, int D, int Nleaf,
int treetype, unsigned int options,
double* minval, double* maxval);
/* Range seach for a single point.
kdtree_rangesearch()
kdtree_t* KDFUNC(kdtree_build_2)
(kdtree_t* kd, void *data, int N, int D, int Nleaf,
int treetype, unsigned int options,
double* minval, double* maxval);
/* Range seach for a single point.
kdtree_rangesearch()
kd: kd-tree object.
kd: kd-tree object.
pt: pointer to the query point -- the thing you are searching for.
The data type of this depends on the "treetype" of the kd-tree. For
a KDTT_DOUBLE, it must be a D-dimensional array of doubles. For
KDTT_FLOAT, an array of floats.
pt: pointer to the query point -- the thing you are searching for.
The data type of this depends on the "treetype" of the kd-tree. For
a KDTT_DOUBLE, it must be a D-dimensional array of doubles. For
KDTT_FLOAT, an array of floats.
maxd2: maximum distance-squared of the search.
maxd2: maximum distance-squared of the search.
The resulting kdtree_qres_t* object will be sorted by distance
(nearest first), and you can get the results. Again, the type
depends on the kd-tree's "treetype"; for KDTT_DOUBLE, the "results.d"
field contains the results; "nres" is the number of points within
range. "sdists" are the squared-distances, and "inds" are the
indices of the matches.
The resulting kdtree_qres_t* object will be sorted by distance
(nearest first), and you can get the results. Again, the type
depends on the kd-tree's "treetype"; for KDTT_DOUBLE, the "results.d"
field contains the results; "nres" is the number of points within
range. "sdists" are the squared-distances, and "inds" are the
indices of the matches.
Free the query results with kdtree_free_query().
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch)(const kdtree_t *kd, const void *pt, double maxd2);
Free the query results with kdtree_free_query().
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch)(const kdtree_t *kd, const void *pt, double maxd2);
/*
Like kdtree_rangesearch(), but don't sort the results by distance.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_nosort)(const kdtree_t *kd, const void *pt, double maxd2);
/*
Like kdtree_rangesearch(), but don't sort the results by distance.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_nosort)(const kdtree_t *kd, const void *pt, double maxd2);
/*
Like kdtree_rangesearch, but you get to call the shots; see
kd_rangesearch_options for what the "options" are.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_options)(const kdtree_t *kd, const void *pt, double maxd2, int options);
/*
Like kdtree_rangesearch, but you get to call the shots; see
kd_rangesearch_options for what the "options" are.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_options)(const kdtree_t *kd, const void *pt, double maxd2, int options);
/*
Like kdtree_rangesearch_options, except reuse a kdtree_qres_t* from a
previous call, to avoid a lot of freeing and allocating memory.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_options_reuse)(const kdtree_t *kd, kdtree_qres_t* res, const void *pt, double maxd2, int options);
/*
Like kdtree_rangesearch_options, except reuse a kdtree_qres_t* from a
previous call, to avoid a lot of freeing and allocating memory.
*/
kdtree_qres_t* KDFUNC(kdtree_rangesearch_options_reuse)(const kdtree_t *kd, kdtree_qres_t* res, const void *pt, double maxd2, int options);
#if !defined(KD_DIM)
#undef KD_DIM_GENERIC
......
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