[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master aa80ac4 112/113: Imported recent updates in ma
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master aa80ac4 112/113: Imported recent updates in master branch, minor conflict fixed |
Date: |
Fri, 16 Apr 2021 10:34:04 -0400 (EDT) |
branch: master
commit aa80ac478093ffd88965ca1a1e5c93a0057b0426
Merge: 6e11585 4137ccd
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Imported recent updates in master branch, minor conflict fixed
The minor conflict was in a paragraph in the book that has been easily
fixed.
---
.autom4te.cfg | 2 +-
.dir-locals.el | 2 +-
.gitignore | 10 +-
.mailmap | 2 +-
ChangeLog | 118 +-
Makefile.am | 94 +-
NEWS | 1327 +++-
README | 24 +-
README-hacking | 8 +-
THANKS | 29 +-
bin/TEMPLATE/Makefile.am | 23 +-
bin/TEMPLATE/TEMPLATE.c | 2 +-
bin/TEMPLATE/TEMPLATE.h | 2 +-
bin/TEMPLATE/args.h | 2 +-
bin/TEMPLATE/astTEMPLATE.conf | 4 +-
bin/TEMPLATE/authors-cite.h | 8 +-
bin/TEMPLATE/main.c | 2 +-
bin/TEMPLATE/main.h | 2 +-
bin/TEMPLATE/ui.c | 22 +-
bin/TEMPLATE/ui.h | 2 +-
bin/arithmetic/Makefile.am | 16 +-
bin/arithmetic/args.h | 8 +-
bin/arithmetic/arithmetic.c | 414 +-
bin/arithmetic/arithmetic.h | 6 +-
bin/arithmetic/astarithmetic.conf | 6 +-
bin/arithmetic/authors-cite.h | 8 +-
bin/arithmetic/main.c | 4 +-
bin/arithmetic/main.h | 12 +-
bin/arithmetic/operands.c | 254 +-
bin/arithmetic/operands.h | 5 +-
bin/arithmetic/ui.c | 77 +-
bin/arithmetic/ui.h | 2 +-
bin/buildprog/Makefile.am | 32 +-
bin/buildprog/args.h | 10 +-
bin/buildprog/astbuildprog.conf.in | 4 +-
bin/buildprog/authors-cite.h | 8 +-
bin/buildprog/buildprog.c | 12 +-
bin/buildprog/buildprog.h | 2 +-
bin/buildprog/main.c | 2 +-
bin/buildprog/main.h | 4 +-
bin/buildprog/ui.c | 46 +-
bin/buildprog/ui.h | 2 +-
bin/convertt/Makefile.am | 17 +-
bin/convertt/args.h | 4 +-
bin/convertt/astconvertt.conf | 4 +-
bin/convertt/authors-cite.h | 8 +-
bin/convertt/color.c | 19 +-
bin/convertt/color.h | 2 +-
bin/convertt/convertt.c | 12 +-
bin/convertt/convertt.h | 2 +-
bin/convertt/main.c | 2 +-
bin/convertt/main.h | 3 +-
bin/convertt/ui.c | 108 +-
bin/convertt/ui.h | 2 +-
bin/convolve/Makefile.am | 17 +-
bin/convolve/args.h | 6 +-
bin/convolve/astconvolve.conf | 4 +-
bin/convolve/authors-cite.h | 8 +-
bin/convolve/convolve.c | 43 +-
bin/convolve/convolve.h | 2 +-
bin/convolve/main.c | 2 +-
bin/convolve/main.h | 2 +-
bin/convolve/ui.c | 54 +-
bin/convolve/ui.h | 2 +-
bin/cosmiccal/Makefile.am | 17 +-
bin/cosmiccal/args.h | 102 +-
bin/cosmiccal/astcosmiccal.conf | 4 +-
bin/cosmiccal/authors-cite.h | 8 +-
bin/cosmiccal/cosmiccal.c | 13 +-
bin/cosmiccal/cosmiccal.h | 2 +-
bin/cosmiccal/main.c | 2 +-
bin/cosmiccal/main.h | 7 +-
bin/cosmiccal/ui.c | 142 +-
bin/cosmiccal/ui.h | 13 +-
bin/crop/Makefile.am | 17 +-
bin/crop/args.h | 41 +-
bin/crop/astcrop.conf | 4 +-
bin/crop/authors-cite.h | 8 +-
bin/crop/crop.c | 32 +-
bin/crop/crop.h | 2 +-
bin/crop/main.c | 2 +-
bin/crop/main.h | 10 +-
bin/crop/onecrop.c | 229 +-
bin/crop/onecrop.h | 7 +-
bin/crop/ui.c | 302 +-
bin/crop/ui.h | 6 +-
bin/crop/wcsmode.c | 30 +-
bin/crop/wcsmode.h | 2 +-
bin/fits/Makefile.am | 17 +-
bin/fits/args.h | 132 +-
bin/fits/astfits.conf | 4 +-
bin/fits/authors-cite.h | 8 +-
bin/fits/extension.c | 2 +-
bin/fits/extension.h | 2 +-
bin/fits/fits.c | 278 +-
bin/fits/fits.h | 2 +-
bin/fits/keywords.c | 491 +-
bin/fits/keywords.h | 2 +-
bin/fits/main.c | 2 +-
bin/fits/main.h | 51 +-
bin/fits/ui.c | 173 +-
bin/fits/ui.h | 48 +-
bin/gnuastro.conf | 21 +-
bin/match/Makefile.am | 17 +-
bin/match/args.h | 4 +-
bin/match/astmatch.conf | 6 +-
bin/match/authors-cite.h | 8 +-
bin/match/main.c | 2 +-
bin/match/main.h | 2 +-
bin/match/match.c | 40 +-
bin/match/match.h | 2 +-
bin/match/ui.c | 124 +-
bin/match/ui.h | 2 +-
bin/mkcatalog/Makefile.am | 17 +-
bin/mkcatalog/args.h | 504 +-
bin/mkcatalog/astmkcatalog.conf | 5 +-
bin/mkcatalog/authors-cite.h | 46 +-
bin/mkcatalog/columns.c | 804 +-
bin/mkcatalog/columns.h | 2 +-
bin/mkcatalog/main.c | 2 +-
bin/mkcatalog/main.h | 70 +-
bin/mkcatalog/mkcatalog.c | 162 +-
bin/mkcatalog/mkcatalog.h | 2 +-
bin/mkcatalog/parse.c | 739 +-
bin/mkcatalog/parse.h | 4 +-
bin/mkcatalog/ui.c | 583 +-
bin/mkcatalog/ui.h | 36 +-
bin/mkcatalog/upperlimit.c | 34 +-
bin/mkcatalog/upperlimit.h | 2 +-
bin/mknoise/Makefile.am | 18 +-
bin/mknoise/args.h | 17 +-
bin/mknoise/astmknoise.conf | 7 +-
bin/mknoise/authors-cite.h | 8 +-
bin/mknoise/main.c | 2 +-
bin/mknoise/main.h | 6 +-
bin/mknoise/mknoise.c | 86 +-
bin/mknoise/mknoise.h | 2 +-
bin/mknoise/ui.c | 84 +-
bin/mknoise/ui.h | 15 +-
bin/mkprof/Makefile.am | 17 +-
bin/mkprof/args.h | 39 +-
bin/mkprof/astmkprof-3d.conf | 6 +-
bin/mkprof/astmkprof.conf | 5 +-
bin/mkprof/authors-cite.h | 8 +-
bin/mkprof/main.c | 2 +-
bin/mkprof/main.h | 11 +-
bin/mkprof/mkprof.c | 141 +-
bin/mkprof/mkprof.h | 2 +-
bin/mkprof/oneprofile.c | 34 +-
bin/mkprof/oneprofile.h | 2 +-
bin/mkprof/profiles.c | 40 +-
bin/mkprof/profiles.h | 5 +-
bin/mkprof/ui.c | 361 +-
bin/mkprof/ui.h | 4 +-
bin/noisechisel/Makefile.am | 15 +-
bin/noisechisel/args.h | 8 +-
bin/noisechisel/astnoisechisel.conf | 10 +-
bin/noisechisel/authors-cite.h | 33 +-
bin/noisechisel/detection.c | 103 +-
bin/noisechisel/detection.h | 2 +-
bin/noisechisel/kernel-2d.h | 8 +-
bin/noisechisel/main.c | 2 +-
bin/noisechisel/main.h | 3 +-
bin/noisechisel/noisechisel.c | 44 +-
bin/noisechisel/noisechisel.h | 2 +-
bin/noisechisel/sky.c | 151 +-
bin/noisechisel/sky.h | 2 +-
bin/noisechisel/threshold.c | 107 +-
bin/noisechisel/threshold.h | 2 +-
bin/noisechisel/ui.c | 86 +-
bin/noisechisel/ui.h | 2 +-
bin/{convertt => query}/Makefile.am | 29 +-
bin/{crop => query}/args.h | 285 +-
bin/{fits/astfits.conf => query/astquery.conf} | 14 +-
bin/query/astron.c | 77 +
bin/{TEMPLATE/TEMPLATE.h => query/astron.h} | 14 +-
bin/{TEMPLATE => query}/authors-cite.h | 12 +-
bin/query/gaia.c | 122 +
bin/{TEMPLATE/TEMPLATE.h => query/gaia.h} | 14 +-
bin/{TEMPLATE => query}/main.c | 14 +-
bin/query/main.h | 78 +
bin/query/ned.c | 88 +
bin/{TEMPLATE/TEMPLATE.h => query/ned.h} | 14 +-
bin/query/query.c | 392 +
bin/{TEMPLATE/TEMPLATE.h => query/query.h} | 24 +-
bin/query/tap.c | 440 ++
bin/{TEMPLATE/TEMPLATE.h => query/tap.h} | 17 +-
bin/query/ui.c | 578 ++
bin/{table => query}/ui.h | 50 +-
bin/query/vizier.c | 179 +
bin/{TEMPLATE/TEMPLATE.h => query/vizier.h} | 14 +-
bin/script/Makefile.am | 19 +-
bin/script/make-ds9-reg.in | 326 +
bin/script/sort-by-night.in | 108 +-
bin/segment/Makefile.am | 17 +-
bin/segment/args.h | 8 +-
bin/segment/astsegment.conf | 4 +-
bin/segment/authors-cite.h | 33 +-
bin/segment/clumps.c | 86 +-
bin/segment/clumps.h | 4 +-
bin/segment/kernel-2d.h | 8 +-
bin/segment/main.c | 2 +-
bin/segment/main.h | 2 +-
bin/segment/segment.c | 614 +-
bin/segment/segment.h | 2 +-
bin/segment/ui.c | 110 +-
bin/segment/ui.h | 2 +-
bin/statistics/Makefile.am | 15 +-
bin/statistics/args.h | 81 +-
bin/statistics/aststatistics.conf | 9 +-
bin/statistics/authors-cite.h | 8 +-
bin/statistics/contour.c | 2 +-
bin/statistics/contour.h | 2 +-
bin/statistics/main.c | 2 +-
bin/statistics/main.h | 9 +-
bin/statistics/sky.c | 32 +-
bin/statistics/sky.h | 2 +-
bin/statistics/statistics.c | 263 +-
bin/statistics/statistics.h | 2 +-
bin/statistics/ui.c | 362 +-
bin/statistics/ui.h | 7 +-
bin/table/Makefile.am | 17 +-
bin/table/args.h | 173 +-
bin/table/arithmetic.c | 402 +-
bin/table/arithmetic.h | 14 +-
bin/table/asttable.conf | 7 +-
bin/table/authors-cite.h | 8 +-
bin/table/main.c | 2 +-
bin/table/main.h | 27 +-
bin/table/table.c | 707 +-
bin/table/table.h | 2 +-
bin/table/ui.c | 306 +-
bin/table/ui.h | 18 +-
bin/warp/Makefile.am | 17 +-
bin/warp/args.h | 2 +-
bin/warp/astwarp.conf | 4 +-
bin/warp/authors-cite.h | 8 +-
bin/warp/main.c | 2 +-
bin/warp/main.h | 2 +-
bin/warp/ui.c | 129 +-
bin/warp/ui.h | 2 +-
bin/warp/warp.c | 56 +-
bin/warp/warp.h | 2 +-
bootstrap.conf | 74 +-
bootstrapped/README | 4 +-
configure.ac | 377 +-
developer-build | 36 +-
doc/Makefile.am | 64 +-
doc/README | 16 +-
doc/announce-acknowledge.txt | 16 +-
doc/coming-soon.html | 99 +
doc/fdl.texi | 505 ++
doc/fonts.css | 2 +-
doc/formath.texi | 2 +-
doc/forwebpage | 28 +-
doc/genauthors | 20 +-
doc/gnuastro-figures/README | 4 +-
doc/gnuastro.en.html | 218 +-
doc/gnuastro.fr.html | 260 +-
doc/gnuastro.texi | 7995 ++++++++++++++------
doc/gnuastro.translist | 2 +-
doc/javascript.html | 37 +-
doc/plotsrc/Makefile | 53 +-
doc/plotsrc/README | 10 +-
doc/plotsrc/all.tex | 2 +-
doc/plotsrc/conversions.sh | 2 +-
doc/plotsrc/tex/flatplane.tex | 2 +-
doc/plotsrc/tex/iandtime.tex | 2 +-
doc/plotsrc/tex/samplingfreq.tex | 2 +-
doc/plotsrc/tex/sphereandplane.tex | 2 +-
doc/release-checklist.txt | 230 +-
doc/style.css | 8 +-
genauthors | 10 +-
lib/Makefile.am | 142 +-
lib/arithmetic-and.c | 6 +-
lib/arithmetic-bitand.c | 6 +-
lib/arithmetic-bitlsh.c | 6 +-
lib/arithmetic-bitor.c | 6 +-
lib/arithmetic-bitrsh.c | 6 +-
lib/arithmetic-bitxor.c | 6 +-
lib/arithmetic-divide.c | 6 +-
lib/arithmetic-eq.c | 6 +-
lib/arithmetic-ge.c | 6 +-
lib/arithmetic-gt.c | 6 +-
lib/arithmetic-le.c | 6 +-
lib/arithmetic-lt.c | 6 +-
lib/arithmetic-minus.c | 6 +-
lib/arithmetic-modulo.c | 6 +-
lib/arithmetic-multiply.c | 6 +-
lib/arithmetic-ne.c | 6 +-
lib/arithmetic-or.c | 6 +-
lib/arithmetic-plus.c | 6 +-
lib/arithmetic-set.c | 193 +
lib/arithmetic.c | 707 +-
lib/array.c | 2 +-
lib/binary.c | 147 +-
lib/blank.c | 247 +-
lib/box.c | 42 +-
lib/checkset.c | 332 +-
lib/convolve.c | 73 +-
lib/cosmology.c | 26 +-
lib/data.c | 230 +-
lib/dimension.c | 86 +-
lib/eps.c | 8 +-
lib/fits.c | 977 ++-
lib/git.c | 2 +-
lib/gnuastro-internal/README | 7 +-
lib/gnuastro-internal/arithmetic-and.h | 2 +-
lib/gnuastro-internal/arithmetic-binary.h | 8 +-
lib/gnuastro-internal/arithmetic-bitand.h | 2 +-
lib/gnuastro-internal/arithmetic-bitlsh.h | 2 +-
lib/gnuastro-internal/arithmetic-bitor.h | 2 +-
lib/gnuastro-internal/arithmetic-bitrsh.h | 2 +-
lib/gnuastro-internal/arithmetic-bitxor.h | 2 +-
lib/gnuastro-internal/arithmetic-divide.h | 2 +-
lib/gnuastro-internal/arithmetic-eq.h | 2 +-
lib/gnuastro-internal/arithmetic-ge.h | 2 +-
lib/gnuastro-internal/arithmetic-gt.h | 2 +-
lib/gnuastro-internal/arithmetic-internal.h | 14 +-
lib/gnuastro-internal/arithmetic-le.h | 2 +-
lib/gnuastro-internal/arithmetic-lt.h | 2 +-
lib/gnuastro-internal/arithmetic-minus.h | 2 +-
lib/gnuastro-internal/arithmetic-modulo.h | 2 +-
lib/gnuastro-internal/arithmetic-multiply.h | 2 +-
lib/gnuastro-internal/arithmetic-ne.h | 2 +-
lib/gnuastro-internal/arithmetic-or.h | 2 +-
lib/gnuastro-internal/arithmetic-plus.h | 2 +-
lib/gnuastro-internal/arithmetic-set.h | 51 +
lib/gnuastro-internal/checkset.h | 15 +-
lib/gnuastro-internal/commonopts.h | 14 +-
lib/gnuastro-internal/config.h.in | 7 +-
lib/gnuastro-internal/fixedstringmacros.h | 6 +-
lib/gnuastro-internal/options.h | 25 +-
lib/gnuastro-internal/tableintern.h | 12 +-
lib/gnuastro-internal/tile-internal.h | 22 +-
lib/gnuastro-internal/timing.h | 2 +-
.../pdf.h => gnuastro-internal/wcsdistortion.h} | 33 +-
lib/gnuastro.pc.in | 4 +-
lib/gnuastro/README | 6 +-
lib/gnuastro/arithmetic.h | 40 +-
lib/gnuastro/array.h | 2 +-
lib/gnuastro/binary.h | 8 +-
lib/gnuastro/blank.h | 19 +-
lib/gnuastro/box.h | 2 +-
lib/gnuastro/convolve.h | 2 +-
lib/gnuastro/cosmology.h | 8 +-
lib/gnuastro/data.h | 73 +-
lib/gnuastro/dimension.h | 52 +-
lib/gnuastro/eps.h | 2 +-
lib/gnuastro/fits.h | 67 +-
lib/gnuastro/git.h | 2 +-
lib/gnuastro/interpolate.h | 32 +-
lib/gnuastro/jpeg.h | 2 +-
lib/gnuastro/{jpeg.h => kdtree.h} | 35 +-
lib/gnuastro/label.h | 2 +-
lib/gnuastro/list.h | 2 +-
lib/gnuastro/match.h | 2 +-
lib/gnuastro/pdf.h | 2 +-
lib/gnuastro/permutation.h | 2 +-
lib/gnuastro/pointer.h | 11 +-
lib/gnuastro/polygon.h | 21 +-
lib/gnuastro/qsort.h | 2 +-
lib/gnuastro/speclines.h | 87 +-
lib/gnuastro/statistics.h | 15 +-
lib/gnuastro/table.h | 12 +-
lib/gnuastro/threads.h | 20 +-
lib/gnuastro/tiff.h | 2 +-
lib/gnuastro/tile.h | 68 +-
lib/gnuastro/txt.h | 9 +-
lib/gnuastro/type.h | 20 +-
.../arithmetic-internal.h => gnuastro/units.h} | 50 +-
lib/gnuastro/wcs.h | 71 +-
lib/interpolate.c | 129 +-
lib/jpeg.c | 10 +-
lib/kdtree.c | 594 ++
lib/label.c | 114 +-
lib/list.c | 13 +-
lib/match.c | 184 +-
lib/options.c | 675 +-
lib/pdf.c | 6 +-
lib/permutation.c | 14 +-
lib/pointer.c | 131 +-
lib/polygon.c | 489 +-
lib/qsort.c | 6 +-
lib/speclines.c | 102 +-
lib/statistics.c | 532 +-
lib/table.c | 89 +-
lib/tableintern.c | 61 +-
lib/threads.c | 65 +-
lib/tiff.c | 42 +-
lib/tile-internal.c | 608 +-
lib/tile.c | 175 +-
lib/timing.c | 14 +-
lib/txt.c | 541 +-
lib/type.c | 76 +-
lib/units.c | 333 +
lib/wcs.c | 1103 ++-
lib/wcsdistortion.c | 1978 +++++
tests/Makefile.am | 34 +-
tests/arithmetic/connected-components.sh | 4 +-
tests/arithmetic/onlynumbers.sh | 4 +-
tests/arithmetic/or.sh | 6 +-
tests/arithmetic/snimage.sh | 4 +-
tests/arithmetic/where.sh | 6 +-
tests/buildprog/simpleio.c | 2 +-
tests/buildprog/simpleio.sh | 17 +-
tests/convertt/blankch.sh | 4 +-
tests/convertt/fitstojpeg.sh | 4 +-
tests/convertt/fitstojpegcmyk.sh | 4 +-
tests/convertt/fitstopdf.sh | 4 +-
tests/convertt/fitstotxt.sh | 4 +-
tests/convertt/jpegtofits.sh | 4 +-
tests/convertt/jpegtotxt.sh | 4 +-
tests/convolve/frequency.sh | 4 +-
tests/convolve/spatial.sh | 4 +-
tests/cosmiccal/simpletest.sh | 4 +-
tests/crop/cat.txt | 2 +-
tests/crop/imgcat.sh | 4 +-
tests/crop/imgcenter.sh | 4 +-
tests/crop/imgcenternoblank.sh | 4 +-
tests/crop/imgpolygon.sh | 4 +-
tests/crop/{imgoutpolygon.sh => imgpolygonout.sh} | 6 +-
tests/crop/section.sh | 4 +-
tests/crop/wcscat.sh | 4 +-
tests/crop/wcscenter.sh | 4 +-
tests/crop/wcspolygon.sh | 4 +-
tests/during-dev.sh | 22 +-
tests/fits/copyhdu.sh | 4 +-
tests/fits/delete.sh | 4 +-
tests/fits/print.sh | 4 +-
tests/fits/update.sh | 4 +-
tests/fits/write.sh | 4 +-
tests/lib/multithread.c | 18 +-
tests/lib/multithread.sh | 4 +-
tests/lib/versioncxx.cpp | 2 +-
tests/lib/versioncxx.sh | 4 +-
tests/match/merged-cols.sh | 4 +-
tests/match/positions-1.txt | 2 +-
tests/match/positions-2.txt | 2 +-
tests/match/positions.sh | 4 +-
tests/mkcatalog/aperturephot.sh | 4 +-
tests/mkcatalog/detections.sh | 4 +-
tests/mkcatalog/objects-clumps.sh | 4 +-
tests/mknoise/addnoise-3d.sh | 3 +-
tests/mknoise/addnoise.sh | 9 +-
tests/mkprof/clearcanvas.sh | 4 +-
tests/mkprof/clearcanvas.txt | 4 +-
tests/mkprof/ellipticalmasks.sh | 4 +-
tests/mkprof/ellipticalmasks.txt | 2 +-
tests/mkprof/mkprofcat1.txt | 2 +-
tests/mkprof/mkprofcat2.txt | 2 +-
tests/mkprof/mkprofcat3.txt | 2 +-
tests/mkprof/mkprofcat4.txt | 2 +-
tests/mkprof/mosaic1.sh | 4 +-
tests/mkprof/mosaic2.sh | 4 +-
tests/mkprof/mosaic3.sh | 4 +-
tests/mkprof/mosaic4.sh | 4 +-
tests/mkprof/radeccat.sh | 4 +-
tests/mkprof/radeccat.txt | 2 +-
tests/noisechisel/noisechisel.sh | 6 +-
tests/prepconf.sh | 12 +-
tests/script/list-by-night.sh | 10 +-
tests/segment/segment.sh | 4 +-
tests/statistics/basicstats.sh | 4 +-
tests/statistics/estimate_sky.sh | 4 +-
tests/statistics/from-stdin.sh | 4 +-
tests/statistics/stdin-input.txt | 2 +-
tests/table/fits-ascii-to-txt.sh | 4 +-
tests/table/fits-binary-to-txt.sh | 4 +-
tests/table/table.txt | 6 +-
tests/table/txt-to-fits-ascii.sh | 4 +-
tests/table/txt-to-fits-binary.sh | 4 +-
tests/warp/homographic.sh | 4 +-
tests/warp/warp_scale.sh | 4 +-
474 files changed, 30074 insertions(+), 9204 deletions(-)
diff --git a/.autom4te.cfg b/.autom4te.cfg
index 462af1f..e6d125d 100644
--- a/.autom4te.cfg
+++ b/.autom4te.cfg
@@ -14,7 +14,7 @@
# directory within the bootstrapped directory to keep things on the
# top directory clean.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
diff --git a/.dir-locals.el b/.dir-locals.el
index 25774d2..6164933 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -9,7 +9,7 @@
;;
;; For more information see (info "(emacs) Directory Variables")
;;
-;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
;;
;; Copying and distribution of this file, with or without modification,
;; are permitted in any medium without royalty provided the copyright
diff --git a/.gitignore b/.gitignore
index b0ce3cc..26b30b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,7 @@
# To help readability, please add new files based on the length of the line
# you wish to add.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
@@ -85,6 +85,7 @@ stamp-h1
Makefile
asttable
astmatch
+astquery
ltmain.sh
.dirstamp
configure
@@ -99,10 +100,14 @@ astmknoise
config.sub
install-sh
aclocal.m4
+confdefs.h
+conftest.c
+.bootstrap*
astconvertt
astconvolve
test-driver
config.h.in
+conftest.err
lib/config.h
astcosmiccal
astmkcatalog
@@ -160,3 +165,6 @@ bin/buildprog/astbuildprog.conf
# directory, we have abandoned the convention above.
/bootstrapped/build-aux
+
+# vscode
+.vscode/
diff --git a/.mailmap b/.mailmap
index 90c7765..a012604 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1,6 +1,6 @@
# Map different emails to people in Git.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2020 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
diff --git a/ChangeLog b/ChangeLog
index c709bd8..6cae471 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,10 +87,10 @@
2015-09-17 Mohammad Akhlaghi <akhlaghi@gnu.org>
* bin/mkprof/mkprof.c (mkprof): Only print a log file if the
- `--nolog' option is not called.
+ '--nolog' option is not called.
* bin/imgcrop/imgcrop.c (imgcrop): Only print a log file if the
- `--nolog' option is not called.
+ '--nolog' option is not called.
* bin/mkprof/main.h (mkprofparams): Removed the p->dir0file1
parameter from the main structure.
@@ -113,8 +113,8 @@
blank. Before the blank fraction was ignored.
* bin/imgstat/imgstat.c (reportsimplestats): Now uses the value to
- the `--mirrordist' option instead of the fixed value of 1.5.
- (reportsimplestats): Report the `NOT ACCURATE' warning in a
+ the '--mirrordist' option instead of the fixed value of 1.5.
+ (reportsimplestats): Report the 'NOT ACCURATE' warning in a
separate line to make reading by AWK easier, also removed comma
between outputs for the same reason.
@@ -162,7 +162,7 @@
2015-07-22 Mohammad Akhlaghi <akhlaghi@gnu.org>
* bin/noisechisel/thresh.c (snthresh): Had mistakenly used
- `p->detquant', for both detection and segmentation! This is now
+ 'p->detquant', for both detection and segmentation! This is now
corrected.
* bin/mkcatalog/mkcatalog.c (secondpass): Sets the river flux to
@@ -180,10 +180,10 @@
2015-07-18 Mohammad Akhlaghi <akhlaghi@gnu.org>
* bin/noisechisel/segmentation.c (nextavailablelabel): Now
- accounts for the `--grownclumps' option.
+ accounts for the '--grownclumps' option.
* bin/noisechisel/args.h (options): Corrected the type of output
- for `--gthresh'. I had forgot to include any for it!
+ for '--gthresh'. I had forgot to include any for it!
2015-07-17 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -224,9 +224,9 @@
flux is subtracted here, not before.
* lib/fitsarrayvv.c: The numblank variable did not actually store
- the `number' of blank pixels, it was only a 0 or 1 value to
+ the 'number' of blank pixels, it was only a 0 or 1 value to
specify if there are any blank pixels or not. It is now changed to
- `anyblank' to be more clear and not confuse the readers. All the
+ 'anyblank' to be more clear and not confuse the readers. All the
Gnuastro programs that used this variable, were also corrected.
2015-07-06 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -389,13 +389,13 @@
2015-06-11 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * bin/noisechisel/args.h (options): `minbfrac' and `minnumfalse'
- options moved under the `Input' category from the detections
+ * bin/noisechisel/args.h (options): 'minbfrac' and 'minnumfalse'
+ options moved under the 'Input' category from the detections
category. This move was because these two options are used by both
the detection and segmentation steps and thus keeping them under
- detection would be confusing. Also `checkthresh' was changed to
- `checkthreshold'. Also, the option `numerosion' was changed to
- `erode' to be consistent with the opening and dilate options.
+ detection would be confusing. Also 'checkthresh' was changed to
+ 'checkthreshold'. Also, the option 'numerosion' was changed to
+ 'erode' to be consistent with the opening and dilate options.
2015-06-10 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -442,12 +442,12 @@
generator to ui.c to make things faster and more easier to
understand.
- * bin/mknoise/args.h (argp_option): Removed the `backgroundinmean'
+ * bin/mknoise/args.h (argp_option): Removed the 'backgroundinmean'
option, because I couldn't figure out what use it would have. If
it is needed we can add it again later!
- * bin/imgstat/args.h (argp_option): Changed `binonzero' option to
- the more general `onebinvalue' option.
+ * bin/imgstat/args.h (argp_option): Changed 'binonzero' option to
+ the more general 'onebinvalue' option.
* bin/convolve/convolve.c (removepaddingcorrectroundoff):
Corrected bug: would return *d in both cases! It is corrected now.
@@ -507,18 +507,18 @@
functions for the minimum and maximum values. NaN values will
automatically fail all comparisons.
- * lib/timing.c (reporttiming): Removed the `in' from reporting
+ * lib/timing.c (reporttiming): Removed the 'in' from reporting
seconds.
* include/timing.h (VERBMSGLENGTH_V): Changed to 45 from 40.
2015-05-27 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * bin/convolve/args.h (options): Remove the `noedgecorrection'
+ * bin/convolve/args.h (options): Remove the 'noedgecorrection'
option. Since it was useless. Also changed the old short option
- for spatial (`s') to `p'. Because `s' is now needed for the mesh
- size option. Also changed the old short option for khdu (`H') to
- `U', to make it similar to all the other programs that do
+ for spatial ('s') to 'p'. Because 's' is now needed for the mesh
+ size option. Also changed the old short option for khdu ('H') to
+ 'U', to make it similar to all the other programs that do
convolution.
* include/mesh.h (meshparams): the garrays are now only
@@ -529,13 +529,13 @@
2015-05-25 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * lib/mesh.c (operateonmesh): New name for `fillmesh'. Now the
+ * lib/mesh.c (operateonmesh): New name for 'fillmesh'. Now the
function that will be spinned off from each thread can be
specified from the outside.
2015-05-24 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * bin/imgcrop/crop.c (sectionparser): When only a `*' was given
+ * bin/imgcrop/crop.c (sectionparser): When only a '*' was given
with no positive or negative following number, a segmentation
fault would happen. This bug is now fixed.
@@ -548,8 +548,8 @@
the case when 2*mi is larger than size.
* bin/subtractsky/args.h: --numnearest and --kernelwidth moved to
- the `Mesh grid' part of the help output. --checksmoothing and
- --checkinterpolation also moved to the `Mesh grid' part.
+ the 'Mesh grid' part of the help output. --checksmoothing and
+ --checkinterpolation also moved to the 'Mesh grid' part.
* lib/mesh.c (checkgarray): Modified to show both the full, or
contiguous over full image, garray and the default one which is
@@ -642,7 +642,7 @@
* bin/mkprof/oneprofile.c (makepixbypix): Will only do monte carlo
integration when the profile is not a constant value.
- (setprofparams): Changed the function of point to `Fixed'.
+ (setprofparams): Changed the function of point to 'Fixed'.
* bin/mkprof/mkprof.c (write): Changed to replace and read from an
image and add profiles on that.
@@ -666,8 +666,8 @@
2015-04-06 Mohammad Akhlaghi <akhlaghi@gnu.org>
* bin/mkprof/mkprof.c: Corrected condition when a thread would
- finish `build' profiles but the last set of its profiles wouldn't
- pass onto `write'.
+ finish 'build' profiles but the last set of its profiles wouldn't
+ pass onto 'write'.
* bin/mknoise/: Changed background flux unit to magnitudes, not
flux.
@@ -676,13 +676,13 @@
2015-04-03 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * lib/fitsarrayvv.c: Changed all occurences of `nul' or `NUL' to
- `blank' or `BLANK'. The FITS standard defines a BLANK keyword for
+ * lib/fitsarrayvv.c: Changed all occurences of 'nul' or 'NUL' to
+ 'blank' or 'BLANK'. The FITS standard defines a BLANK keyword for
integer types.
(copyrightandend): Will now right extra headers.
(arraytofitsimg): Can now accept header to write to output.
- * include/fitsarrayvv.h: Changed all `NUL' macros to `BLANK'.
+ * include/fitsarrayvv.h: Changed all 'NUL' macros to 'BLANK'.
2015-04-02 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -729,8 +729,8 @@
* bin/convolve/ui.c (preparearrays): The flip parts was missing a
-1.
- * doc/gnuastro.texi: Changed all `gnuastro' occurrences in the
- text to `Gnuastro'.
+ * doc/gnuastro.texi: Changed all 'gnuastro' occurrences in the
+ text to 'Gnuastro'.
2015-03-14 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -845,8 +845,8 @@
2015-02-13 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * bin/convertt/args.h (argp_options): `convert` changed to
- `change`. Since the program name is also convert this could cause
+ * bin/convertt/args.h (argp_options): 'convert' changed to
+ 'change'. Since the program name is also convert this could cause
confusions.
* doc/gnuastro.texi (Invoking astconvertt): Option explanations.
@@ -890,8 +890,8 @@
2015-01-25 Mohammad Akhlaghi <akhlaghi@gnu.org>
- * ./*: In all files, the name `AstrUtils` was changed to
- `gnuastro` and the `astr` prefix was changed to `ast`.
+ * ./*: In all files, the name 'AstrUtils' was changed to
+ 'gnuastro' and the 'astr' prefix was changed to 'ast'.
2015-01-20 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -936,10 +936,10 @@
* bin/mkprof/mkprof.c (writelog): Added.
(write): Completed.
- * bin/mkprof/args.h (arg_option): Added `--nomerged`.
+ * bin/mkprof/args.h (arg_option): Added '--nomerged'.
- * lib/txtarrayvv.c (doformatting): Added option to use `f` in
- printf or `g`.
+ * lib/txtarrayvv.c (doformatting): Added option to use 'f' in
+ printf or 'g'.
2015-01-16 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -947,34 +947,34 @@
(saveindividual): Added.
(build): Is working until the profile is built.
- * bin/mkprof/ellipse.h: Function taken to `box.h`.
+ * bin/mkprof/ellipse.h: Function taken to 'box.h'.
- * bin/mkprof/ellipse.c: Function taken to `box.c`.
+ * bin/mkprof/ellipse.c: Function taken to 'box.c'.
- * bin/mkprof/args.h (argp_option): added `--numrandom`, changed
- `mginimg` to `psfinimg`.
+ * bin/mkprof/args.h (argp_option): added '--numrandom', changed
+ 'mginimg' to 'psfinimg'.
* bin/imgcrop/main.h (imgcropparams): iwidth is now a 2 element
array.
- * bin/imgcrop/crop.c: Removed `borderfromcenter` and
- `correctflpixels` to `lib/box.c`.
+ * bin/imgcrop/crop.c: Removed 'borderfromcenter' and
+ 'correctflpixels' to 'lib/box.c'.
- * lib/stats.h: Changed to `statistics.h`, all non-used functions
+ * lib/stats.h: Changed to 'statistics.h', all non-used functions
removed.
* lib/arraymanip.c: Removed all non-used functions.
- * include/stats.h: Changed to `statistics.h` and all non-used
+ * include/stats.h: Changed to 'statistics.h' and all non-used
functions removed.
* include/fixedstringmacros.h (ASTRUTILSBIBTEX): Added.
- * include/commonargs.h (argp_option): Added `--cite` option and
- added the `main.h` and `cite.h` header for each program to use
+ * include/commonargs.h (argp_option): Added '--cite' option and
+ added the 'main.h' and 'cite.h' header for each program to use
their names.
- * include/checkset.h: function name `nameiswritable` is changed to
+ * include/checkset.h: function name 'nameiswritable' is changed to
dir0file1 which is much more descriptive.
* include/arraymanip.h: Removed all the non-used functions from
@@ -1042,7 +1042,7 @@
* bin/imgcrop/args.h (parse_opt): Removed the check below.
* include/commonargs.h (cparse_opt): Added check for not calling
- `--setdirconf` and `--setusrconf` together.
+ '--setdirconf' and '--setusrconf' together.
2015-01-05 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -1064,8 +1064,8 @@
* include/commonparams.h (commonparams): Similar to the change in
commonargs.h.
- * include/commonargs.h (argp_option): `--dirdefaults` and
- `--userdefaults` changed to `--setdirconf` and `--setusrconf`.
+ * include/commonargs.h (argp_option): '--dirdefaults' and
+ '--userdefaults' changed to '--setdirconf' and '--setusrconf'.
* doc/astrutils.texi: Included formath.texi to display math
equations, updates to the text.
@@ -1094,7 +1094,7 @@
* lib/defaults.c (addhomedir): Now returns char *.
(writelocaldefaultstop): Informs the user of how to make the
- needed directory with `make -p`.
+ needed directory with 'make -p'.
* include/defaults.h (SAVE_LOCAL_DEFAULTS): changed addhomedir.
(CHECKSETDEFAULTS): A new macro to read defaults.
@@ -1103,11 +1103,11 @@
* doc/astrutils.texi: A lot of updates in the text! Listing them
all would be too much!
- * configure.ac: `--with-numthreads` and `--enable-progname` were
+ * configure.ac: '--with-numthreads' and '--enable-progname' were
created along with all their necessary checks.
* Makefile.am: Set conditional subdirectories. Added
- `basicchecks.sh` to the files to be distributed.
+ 'basicchecks.sh' to the files to be distributed.
2014-12-28 Mohammad Akhlaghi <akhlaghi@gnu.org>
@@ -1118,7 +1118,7 @@
;; coding: utf-8
;; End:
- Copyright (C) 2015-2019, Free Software Foundation, Inc.
+ Copyright (C) 2015-2021, Free Software Foundation, Inc.
This file is part of GNU Astronomy Utitlies (Gnuastro).
diff --git a/Makefile.am b/Makefile.am
index 49bda39..45b97af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -29,12 +29,12 @@
## ============================================
##
## These target(s) will be created before anything else when running
-## `make', `make check', or `make install', see the "Built sources" section
+## 'make', 'make check', or 'make install', see the "Built sources" section
## of the AUTOMAKE manual and the git-version-gen script comments for more
-## information. Note that AUTHORS depends on `$(top_srcdir)/.version', and
-## `$(top_srcdir)/.version' depends on $(top_srcdir)/configure'. So any
+## information. Note that AUTHORS depends on '$(top_srcdir)/.version', and
+## '$(top_srcdir)/.version' depends on $(top_srcdir)/configure'. So any
## time the version is updated, both of these will be re-built. But during
-## usual utility and library development, `$(top_srcdir)/configure' is not
+## usual utility and library development, '$(top_srcdir)/configure' is not
## commonly updated, so this will not slow down the process.
BUILT_SOURCES = $(top_srcdir)/AUTHORS
@@ -83,6 +83,9 @@ endif
if COND_NOISECHISEL
MAYBE_NOISECHISEL = bin/noisechisel
endif
+if COND_QUERY
+ MAYBE_QUERY = bin/query
+endif
if COND_SEGMENT
MAYBE_SEGMENT = bin/segment
endif
@@ -107,18 +110,18 @@ endif
## Subdirectories to build
## =======================
##
-## Note that by default `COND_TEMPLATE' is not set in configure, it is
+## Note that by default 'COND_TEMPLATE' is not set in configure, it is
## commented, and exists only as a template for you to copy and paste to
-## name your new utility. The same rule is applied here (in the `if'
-## conditions above). When `MAYBE_TEMPLATE' is not defined, then Make will
+## name your new utility. The same rule is applied here (in the 'if'
+## conditions above). When 'MAYBE_TEMPLATE' is not defined, then Make will
## see it as a blank string and igonore it, so there is no problem with
-## having an uncommented `MAYBE_TEMPLATE' as a value in `SUBDIRS'.
-SUBDIRS = bootstrapped/lib $(MAYBE_GNULIBCHECK) lib $(MAYBE_ARITHMETIC) \
- $(MAYBE_BUILDPROG) $(MAYBE_CONVERTT) $(MAYBE_CONVOLVE) \
- $(MAYBE_COSMICCAL) $(MAYBE_CROP) $(MAYBE_FITS) $(MAYBE_MATCH) \
+## having an uncommented 'MAYBE_TEMPLATE' as a value in 'SUBDIRS'.
+SUBDIRS = bootstrapped/lib $(MAYBE_GNULIBCHECK) lib $(MAYBE_ARITHMETIC) \
+ $(MAYBE_BUILDPROG) $(MAYBE_CONVERTT) $(MAYBE_CONVOLVE) \
+ $(MAYBE_COSMICCAL) $(MAYBE_CROP) $(MAYBE_FITS) $(MAYBE_MATCH) \
$(MAYBE_MKCATALOG) $(MAYBE_MKNOISE) $(MAYBE_MKPROF) $(MAYBE_NOISECHISEL) \
- $(MAYBE_SEGMENT) $(MAYBE_STATISTICS) $(MAYBE_TABLE) $(MAYBE_TEMPLATE) \
- $(MAYBE_WARP) bin/script doc tests
+ $(MAYBE_QUERY) $(MAYBE_SEGMENT) $(MAYBE_STATISTICS) $(MAYBE_TABLE) \
+ $(MAYBE_TEMPLATE) $(MAYBE_WARP) bin/script doc tests
@@ -143,9 +146,9 @@ dist_sysconf_DATA = bin/gnuastro.conf
## Files that are only distributed
## ===============================
##
-## Note that `COPYING' (containing the GNU GPL) is included in the
+## Note that 'COPYING' (containing the GNU GPL) is included in the
## distribution tarball by default in Automake, but not other license
-## files, so we have to manually add `COPYING.FDL'.
+## files, so we have to manually add 'COPYING.FDL'.
EXTRA_DIST = COPYING.FDL genauthors .dir-locals.el .version \
developer-build bootstrapped/README .autom4te.cfg
@@ -160,14 +163,27 @@ EXTRA_DIST = COPYING.FDL genauthors .dir-locals.el
.version \
##
## When running ./configure, the user can opt-out of these messages using
## the GUIDEMESSAGE variable that is set when they run ./configure with the
-## `--distable-guide-message' option.
+## '--distable-guide-message' option.
##
-## Note that all-local is a prerequisite of `make check' too, so we will
-## only print its message when `make' was called with no options. Make will
+## Note that all-local is a prerequisite of 'make check' too, so we will
+## only print its message when 'make' was called with no options. Make will
## set MAKECMDGOALS to blank if there are no arguments, however, the way
## Automake works, its value is set to "all-am".
all-local:
- @if [ x$(MAKECMDGOALS) = x"all-am" ] && [ x$(GUIDEMESSAGE) = xyes ];
then \
+
+ # If we are in static linking mode, correct the 'lib_dependencies'
+ # variable of 'libgnuastro.la'. Because by default it will not
+ # include static libraries!
+ @if [ "X$(MAKECMDGOALS)" = "Xall-am" ] && [ "X$(ENABLE_SHARED)" = "Xno"
]; then \
+ $(AWK) '/^dependency_libs/{print
"dependency_libs='\''$(CONFIG_LDADD)'\''"} \
+ !/^dependency_libs/{print}'
$(top_builddir)/lib/libgnuastro.la \
+ > $(top_builddir)/lib/libgnuastro_tmp.la; \
+ mv $(top_builddir)/lib/libgnuastro_tmp.la \
+ $(top_builddir)/lib/libgnuastro.la; \
+ fi
+
+ # Print a message if requested.
+ @if [ "X$(MAKECMDGOALS)" = "Xall-am" ] && [ x$(GUIDEMESSAGE) = xyes ];
then \
echo;
\
echo
"==================================================================="; \
echo
"==================================================================="; \
@@ -190,7 +206,7 @@ all-local:
## and all the variables that are supposed to be based on exec_prefix by
## default will actually change."
##
-## So actually, they can also do that after `make check'. Usually
+## So actually, they can also do that after 'make check'. Usually
## professional users would want to do such a thing, so they can ignore the
## NOTE. This note is mostly for beginners and it is not written to convey
## that this is the ONLY solution.
@@ -223,7 +239,7 @@ check-local:
echo;
\
fi
-## Note that the `\' characters in the GNU head here are not printed on the
+## Note that the '\' characters in the GNU head here are not printed on the
## command line. So we have to consider them. The ASCII GNU head is taken
## from: https://www.gnu.org/graphics/gnu-ascii.html
install-exec-local:
@@ -274,18 +290,18 @@ install-exec-local:
## ======================
##
## This file is created from the $(VERSION) variable which was defined by
-## the `git-version-gen' script (located at address below), which is run
-## when the `$(top_srcdir)/configure' script is being built by Autoconf.
+## the 'git-version-gen' script (located at address below), which is run
+## when the '$(top_srcdir)/configure' script is being built by Autoconf.
##
## $(top_srcdir)/bootstrapped/build-aux/git-version-gen
##
-## Note that contrary to what is proposed by `git-version-gen', here the
-## creation of `$(top_srcdir)/.version' depends on the
-## `$(top_srcdir)/configure' script. Therefore, anytime a the VERSION
-## variable is updated there, `$(top_srcdir)/.version' is also
+## Note that contrary to what is proposed by 'git-version-gen', here the
+## creation of '$(top_srcdir)/.version' depends on the
+## '$(top_srcdir)/configure' script. Therefore, anytime a the VERSION
+## variable is updated there, '$(top_srcdir)/.version' is also
## updated. During development, of the main functionality of Gnuastro
-## (utilities and libraries), the `$(top_srcdir/configure' script is rarely
-## updated, so `$(top_srcdir)/.version' will not be rebuilt and thus it
+## (utilities and libraries), the '$(top_srcdir/configure' script is rarely
+## updated, so '$(top_srcdir)/.version' will not be rebuilt and thus it
## won't harm the speed of tests during development.
$(top_srcdir)/.version: $(top_srcdir)/configure
echo $(VERSION) > $@-t && mv $@-t $@
@@ -300,18 +316,18 @@ $(top_srcdir)/.version: $(top_srcdir)/configure
## This file is generated automatically from the version controlled
## history. Note the following:
##
-## - `$(top_srcdir)/AUTHORS' is defined as a BUILT_SOURCES variable, so
+## - '$(top_srcdir)/AUTHORS' is defined as a BUILT_SOURCES variable, so
## it is the first thing that is built (even in multi-threaded runs).
##
-## - `$(top_srcdir)/AUTHORS' is updated only when
-## `$(top_srcdir)/.version' is updated. `$(top_srcdir)/.version' its
-## self is only updated when `$(top_srcdir)/configure' is updated. But
-## generally, the `$(top_srcdir)/configure' script is not updated
+## - '$(top_srcdir)/AUTHORS' is updated only when
+## '$(top_srcdir)/.version' is updated. '$(top_srcdir)/.version' its
+## self is only updated when '$(top_srcdir)/configure' is updated. But
+## generally, the '$(top_srcdir)/configure' script is not updated
## regularly during development and outside of version control.
##
-## - The `$(top_srcdir)/genauthors' script will not do anything
-## (make/update the `$(top_srcdir)AUTHORS' file) when there is no git
-## repository. `$(top_srcdir)/AUTHORS' is only necessary when building
+## - The '$(top_srcdir)/genauthors' script will not do anything
+## (make/update the '$(top_srcdir)AUTHORS' file) when there is no git
+## repository. '$(top_srcdir)/AUTHORS' is only necessary when building
## a tarball distribution.
$(top_srcdir)/AUTHORS: $(top_srcdir)/.version
$(top_srcdir)/genauthors $(top_srcdir)
@@ -324,7 +340,7 @@ $(top_srcdir)/AUTHORS: $(top_srcdir)/.version
## ================================
##
## These targets will be created when building a (tarball)
-## distribution. Note that AUTHORS depends on `.version'.
+## distribution. Note that AUTHORS depends on '.version'.
dist-hook: $(top_srcdir)/AUTHORS
echo $(VERSION) > $(distdir)/.tarball-version
diff --git a/NEWS b/NEWS
index 53cce0e..a5af946 100644
--- a/NEWS
+++ b/NEWS
@@ -1,14 +1,655 @@
GNU Astronomy Utilities NEWS -*- outline -*-
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021 Free Software Foundation, Inc.
See the end of the file for license conditions.
* Noteworthy changes in release X.X (library X.X.X) (XXXX-XX-XX) [stable]
** New features
+ New program:
+ - astscript-make-ds9-reg: Given a table (either as a file or from
+ standard input), create an SAO DS9 region file from the requested
+ positional columns (WCS or image coordinates). For example with the
+ command below you can select certain rows of a given table, and show
+ them over an image:
+ asttable table.fits --range=MAG,18:20 --column=RA,DEC \
+ | astscript-make-ds9-reg --column=1,2 --radius=0.5 \
+ --command="ds9 image.fits"
+
+ Arithmetic:
+ - New operators (the trigonometric/hyperbolic functions were previously
+ only avaialble in Table's column arithmetic, but they have been moved
+ into the Gnuastro library and are thus now available on images within
+ Arithmetic also):
+ - sin: Trigonometric sine (input in degrees).
+ - cos: Trigonometric cosine (input in degrees).
+ - tan: Trigonometric tangent (input in degrees).
+ - asin: Inverse of trigonometric sine (output in degrees).
+ - acos: Inverse of trigonometric cosine (output in degrees).
+ - atab: Inverse of trigonometric tangent (output in degrees).
+ - sinh: Hyperbolic sine.
+ - cosh: Hyperbolic cosine.
+ - tanh: Hyperbolic tangent.
+ - asinh: Inverse of hyperbolic sine.
+ - acosh: Inverse of hyperbolic cosine.
+ - atabh: Inverse of hyperbolic tangent.
+
+ Table:
+ - When given a value of '_all', the '--noblank' option (that will remove
+ all rows with a blank value in the given columns) will check all
+ columns of the final output table. This is handy when you want a
+ "clean" (no NaN values in any column) table, but the table has many
+ columns.
+ --rowlimit: new option to specify the positional interval of rows to
+ show. Until now the '--head' or '--tail' options would just allow
+ seeing the first or last few rows. You can use this to view a
+ contiguous set of rows in the middle of the table.
+ --rowrandom: Make a random selection of the rows. This option is useful
+ when you have a large dataset and just want to see a random sub-set of
+ the rows. It takes an integer, selects that many rows from the input
+ randomly.
+ - New column arithmetic operators:
+ - 'set-AAA' operator (which allows storing the popped operand into a
+ named variable for easy usage in complex operations) is also usable
+ in Table's column arithmetic. Until now this operator was only
+ available in the Arithmetic program (for operation on images).
+ - 'date-to-sec' Convert FITS date format ('YYYY-MM-DDThh:mm:ss') into
+ seconds from the Unix epoch (1970-01-01,00:00:00 UTC). This can be
+ very useful in combination with the new '--keyvalue' option of the
+ Fits program to sort your FITS images based on observation time.
+
+ Fits:
+ --keyvalue: Print only the values of the FITS keywords given to this
+ option in separate columns. This option can take multiple values and
+ many FITS files. Thus generating a table of keyword values (with one
+ row per file). Its output can thus either be piped to the Table
+ program for selecting a certain sub-set of your FITS files, or sorting
+ them for example.
+
+ Library:
+ - New arithmetic operator macros (for the 'gal_arithmetic' function):
+ - GAL_ARITHMETIC_OP_SIN: sine (input in deg).
+ - GAL_ARITHMETIC_OP_COS: cosine (input in deg).
+ - GAL_ARITHMETIC_OP_TAN: tangent (input in deg).
+ - GAL_ARITHMETIC_OP_ASIN: Inverse sine (output in deg).
+ - GAL_ARITHMETIC_OP_ACOS: Inverse cosine (output in deg).
+ - GAL_ARITHMETIC_OP_ATAN: Inverse tangent (output in deg)
+ - GAL_ARITHMETIC_OP_ATAN2: Inverse tangent (with two inputs, out deg).
+ - GAL_ARITHMETIC_OP_SINH: Hyperbolic sine.
+ - GAL_ARITHMETIC_OP_COSH: Hyperbolic cosine.
+ - GAL_ARITHMETIC_OP_TANH: Hyperbolic tangent.
+ - GAL_ARITHMETIC_OP_ASINH: Inverse hyperbolic sine.
+ - GAL_ARITHMETIC_OP_ACOSH: Inverse hyperbolic cosine.
+ - GAL_ARITHMETIC_OP_ATANH: Inverse hyperbolic tangent.
+
+** Removed features
+
+** Changed features
+
+ astscript-sort-by-night:
+ - Thanks to the new features in the Fits and Table programs (described
+ above), the efficiency of this script has improved dramatically (from
+ 19 seconds to 0.42 seconds for about 650 FITS files used in the
+ test!).
+ - The default end to a "night" is set to 11:00a.m. Until now it was
+ 9:00a.m. But in some cases, calibration images may be taken after
+ that. So to be safer in general it was incremented by 2 hours.
+
+ Library:
+ - gal_fits_key_write_wcsstr: also takes WCS structure as argument.
+ - gal_fits_key_read_from_ptr: providing a numerical datatype for the
+ desired keyword's value is no longer mandatory. When not given, the
+ smallest numeric datatype that can keep the value will be found and
+ used.
+
+** Bugs fixed
+ bug #60082: Arithmetic library crash for integer operators like modulo
+
+
+
+
+
+* Noteworthy changes in release 0.14 (library 12.0.0) (2021-01-25) [stable]
+
+** New features
+
+ Book:
+ - Tutorial on "Detecting large extended targets" improved with better
+ NoiseChisel configuration, and more clear description.
+ - New sub-section on "Memory management" in the "Common program
+ behavior" chapter. It fully describes how to optimally deal with large
+ datasets that may exceed your system's RAM.
+ - Examples and better description added to many operators in the
+ "Arithmetic operators" subsection of the Arithmetic program's section.
+
+ New program:
+ - Query ('astquery') is a new program to query to external datasets and
+ retrieve the resulting datasets from the command-line. It is possible
+ to get list of datasets or column names from the databases. The basic
+ spatial query (finding objects in the vicinity of a certain point) can
+ be managed without knowing the query language of the database: with
+ basic options (like '--center' with '--radius' or '--width'), or an
+ input image that has WCS. Currently Query supports VizieR (containing
+ +20500 datasets, making it the largest database in astronomy), NED, as
+ ESA's Gaia database and ASTRON. See the new "Query" section of the
+ book (under the "Data containers" chapter) for more.
+
+ All programs:
+ - Plain text table inputs can have floating point columns that are in
+ sexagesimal format of '_h_m_s' or '_d_m_s' (where '_' is a
+ number). These are the classical format to respectively represent
+ Right Ascension (RA) and Declination (Dec). They will be directly read
+ as a single floating point number (in units of degrees) into
+ memory. Therefore the same column of a plain-text table, can be
+ degrees in some rows and sexagesimal in others. Besides large tables,
+ with this feature, conversion to sexagesimal coordinates to degrees
+ becomes very easy, for example:
+ echo "7h34m35.5498 31d53m14.352s" | asttable
+ Recall that the inverse can also be done with the more general column
+ arithmetic:
+ echo "113.64812416667 31.88732" \
+ | asttable -c'arith $1 degree-to-ra $2 degree-to-dec'
+ - If input is a HEALpix grid (1D table column that represents the 2D
+ spherical representation of datasets), the programs will print a
+ warning, suggesting to use the 'HPXcvt' utility of WCSLIB.
+
+ Arithmetic:
+ - New operators:
+ - 'interpolate-maxofregion': interpolate connected blank regions with
+ the maximum value that is immediately touching it. This can be used
+ to fill the blank centers of saturated stars for example.
+ - 'interpolate-minofregion': similar to 'interpolate-maxofregion', but
+ for the minimum.
+ - 'makenew': new operator to create an empty (zero-valued) new dataset
+ with given dimension and size (given as operands).
+
+ Crop:
+ --primaryimghdu: Write the final cropped image into the primary (or
+ 0-th) extension of the output FITS file, so the output only has
+ one extension.
+
+ Fits:
+ - New '--skycoverage' option will report the area of the input image in
+ RA/Dec, both in units of center/width, and box minimum/maximum
+ format. This is paritcularly useful in combination with the new
+ 'astquery' option, to easily search the contents of external databases
+ within the image.
+
+ MakeCatalog:
+ --maximum: maximum value of labeled regions pixels (clump/object).
+ --areaarcsec2: area of labeled region (clump/object) in arcsec^2.
+ --surfacebrightness: the surface brightness of the labeled region.
+ --fwhm: observed FWHM in pixels (non-parametric), along the major axis.
+ --halfmaxarea: number of pixels with a value larger than half the maximum.
+ --halfmaxradius: radius of region that is larger than half the maximum.
+ --halfmaxsum: sum of pixels with a value larger than half the maximum.
+ --halfmaxsb: surf. brightness within half of the maximum.
+ --fracmax: fractions to use in '--fracmaxarea1' or '--fracmaxarea2'.
+ --fracmaxsum1: sum of pixels brighter than first given fraction of max.
+ --fracmaxsum2: sum of pixels brighter than second given fraction of max.
+ --fracmaxarea1: number of pixels brighter than first given fraction of max.
+ --fracmaxarea2: number of pixels brighter than second given fraction of max.
+ --fracmaxradius1: radius derived from '--fracmaxarea1'.
+ --fracmaxradius2: radius derived from '--fracmaxarea2'.
+ --halfsumsb: Surface brightness within area reported by '--halfsumarea'.
+ --halfsumarea: area containing half of the summed object or clump values.
+ --halfsumradius: radius derived from '--halfsumarea', underestimates r_e.
+ --areaminv: the number of pixels that are equal to the minimum value.
+ --areamaxv: the number of pixels that are equal to the maximum value.
+ - New columns to return the position of pixel with minimum or maximum
+ value: '--minvx', '--maxvx', '--minvy', '--maxvy', '--minvz',
+ '--maxvz'.
+
+ MakeNoise:
+ --bgisbrightness: new option to say that the value of '--background'
+ (used to simulate Poisson noise) should be interpreted as brightness,
+ not magnitude.
+
+ MakeProfiles:
+ - It is now possible to make any custom radial profile with the 'custom'
+ profile (with code '8'). A table should be given to the new
+ '--customtable' option which will define each radial interval and the
+ value to use for that radial interval. See the description of
+ '--customtable' for more.
+
+ Statistics:
+ - 2D histograms can now be built as a FITS image with a linear WCS that
+ contains axis values and box size. This allows using the power of FITS
+ viewers for plotting/inspecting distributions of two columns in a
+ table relative to each other (for example color-magnitude plots). You
+ can also convert these 2D histogram images to PDF or JPEG with
+ Gnuastro's ConvertType to directly use in your papers/reports (see the
+ newly added "2D histogram as an image" section of the book for more).
+
+ Table:
+ - New '--noblank' option will remove all rows in output table that have
+ at least one blank value in the specified columns. For example if
+ 'table.fits' has blank values (NaN in floating point types) in the
+ 'magnitude' and 'sn' columns, with '--noblank=magnitude,sn', you can
+ be sure that all rows with blank values in these columns have been
+ removed.
+ - New trigonometric operators for column-arithmetic (inputs in units of
+ degrees): 'sin', 'cos' and 'tan'. Their inverse trigonometric (outputs
+ in units of degrees) have also been added: 'asin', 'acos' and 'atan'.
+ The 'atan2' operator (inverse tangent that preserves the quadrant, see
+ its description in the book) is also now available.
+ - New hyperbolic operators for column-arithmetic: 'sinh', 'cosh' and
+ 'tanh'. Their inverse has also been added: 'asinh', 'acosh' and
+ 'atanh'.
+
+ Library:
+ - GAL_ARITHMETIC_OP_MAKENEW: new 'makenew' operator.
+ - gal_binary_connected_adjacency_list: finding connected components
+ without a square adjacency matrix (which can consume major RAM).
+ - gal_blank_flag_remove: Remove all flagged elements in a dataset.
+ - gal_blank_remove_rows: remove all rows that have at least one blank.
+ - gal_dimension_dist_elliptical: Elliptical dist. of a point from center.
+ - gal_fits_hdu_is_healpix: Return 1 if HDU is a HEALpix grid.
+ - gal_fits_hdu_datasum: calculate DATASUM of given HDU in given FITS file.
+ - gal_fits_hdu_datasum_ptr: calculate DATASUM of opened FITS file pointer.
+ - gal_fits_key_list_comment_add: add a COMMENT keyword to the keyword list.
+ - gal_fits_key_list_comment_add_end: add a COMMENT keyword to end of list.
+ - gal_pointer_allocate_ram_or_mmap: allocate in RAM or memory-mapped file.
+ - gal_pointer_mmap_free: "free" (actually delete) the memory-mapped file.
+ - gal_wcs_create: create WCSLIB-compatible WCS from raw values.
+ - gal_wcs_coverage: Return the sky coverage of given image HDU.
+ - gal_wcs_dimension_name: return the name of the requested WCS dim.
+
+** Removed features
+
+** Changed features
+
+ All programs:
+ - Memory management: Until now, an internal array was only allocated in
+ the RAM when its size was smaller (in bytes) than the value given to
+ the '--minmapsize' option. But this was annoying/buggy when the system
+ has enough RAM to keep large files. From this version, all Gnuastro
+ programs will first attempt to write the array in RAM, only when it
+ fails (there is no more RAM left), will they use a memory-mapped file
+ (which can dramatically slow down the program). Please see the newly
+ added "Memory management" section of the book for a complete
+ explanation of Gnuastro's new memory management strategy.
+ - When an array needs to be memory-mapped (read into a file on HDD/SSD,
+ not RAM, usually due to RAM limitations), it is written in a
+ 'gnuastro_mmap' directory of the running directory, not the hidden
+ '.gnuastro_mmap' directory. Since the files in this directory are
+ usually large, it is better that the user sees them by default (in
+ case the program crashes and they aren't deleted).
+ --interpnumngb: the default value has been increased to 15 (from 9). The
+ reason for this is that we now have a more robust outlier removal
+ algorithm (see description under "NoiseChisel & Statistics").
+
+ Crop:
+ - When cropping a single image in WCS mode, there is no longer any
+ limitation on the WCS. Until now for all WCS mode crops, it was
+ necessary for the WCS to be aligned to the celestial coordinates. But
+ from this version, this is only necessary when cropping from many
+ files (and stitching them together where necessary). For WCS-mode
+ crops of a single image, any WCS that is recognized by WCSLIB is fine.
+
+ Fits:
+ - The '--pixelscale' option also prints the pixel area (for 2D inputs,
+ or 2D slices of 3D inputs) and the voxel volume (for 3D inputs). Until
+ now, it would only print the pixel scale along each dimension.
+ - When printing FITS file HDU information (no options given), a new
+ "Comments" column may be printed for each HDU in the end of the line.
+ It will be printed if special situations are found (for example a 2D
+ HEALPix grid, that is usually stored as a 1D array/column).
+
+ NoiseChisel & Statistics:
+ - New algorithm used to reject outlying tiles. In NoiseChisel this is
+ done when estimating the quantile threshold, the pseudo-detection
+ threshold and the final Sky value. In Statistics, its just the Sky
+ value. Unlike the previous method that used the global distribution of
+ tile values to identify outliers, the new algorithm uses a relative
+ measure. See the book for more. Since outliers are now rejected more
+ robustly, the default value of '--meanmedqdiff' has been increased to
+ 0.01 (was 0.005) and '--outliersigma' has been decreased to '5' (was
+ 10). Also 'smoothwidth' has been increased from '3' to '5' to have
+ smoother tessellation values.
+
+ Statistics:
+ - The '--histogram2d' now takes a string argument: either 'image' or
+ 'table'. For the old behavior please use '--histogram2d=table'. See
+ the new features above for the 'image' mode.
+
+ Table:
+ - Column arithmetic operators 'degree-to-ra' and 'degree-to-dec' will
+ return the sexagesimal format of '_h_m_s' and '_d_m_s'
+ respectively. Until this version, they would both use colons as
+ delimiters ('_:_:_').
+
+ Library:
+ - gal_pointer_mmap_allocate: new name for 'gal_pointer_allocate_mmap'.
+ - gal_threads_dist_in_threads: now accounts for billions of threads,
+ thus includes memory management options.
+ - gal_threads_spin_off: now accounts for memory management.
+ - gal_units_degree_to_ra: new 'usecolon' argument to optionally format
+ output string with colons as delimiters ('_:_:_'). When this option is
+ zero, the string will be in the '_h_m_s' format.
+ - gal_units_degree_to_dec: similar to 'gal_units_degree_to_ra', but when
+ 'usecolon' is zero, the string will be in the '_d_m_s' format.
+
+** Bugs fixed
+ bug #59017: Segment's object IDs are not thread-safe (i.e., reproducible).
+ bug #59105: Column arithmetic operator degree-to-ra, returning to dec.
+ bug #59136: Makeprofiles with --replace is not thread-safe.
+ bug #59155: Match cannot find the proper row when coordinates have NaN.
+ bug #59371: MakeCatalog crash with clumps on non-contiguous object labels.
+ bug #59400: CosmicCalculator fails --printparams when redshift isn't given.
+ bug #59459: Unclear WCS when both PC and CD exist in input, but conflict.
+ bug #59625: MakeProfiles uses last --kernel, if it is called more than once.
+ bug #59700: Segment's excessive RAM usage when many clumps over a detection.
+ bug #59765: MakeCatalog crash when to-be-subtracted Sky is a single-element
+ per tile tessellation (e.g., NoiseChisel's '--oneelempertile').
+
+
+
+
+
+* Noteworthy changes in release 0.13 (library 11.0.0) (2020-09-06) [stable]
+
+** New features
+
+ All programs:
+ - When reading plain-text tables, the blank value for numeric columns
+ can be any string (specified in the special comment-line format
+ described in the "Gnuastro text table format" of the manual). Until
+ now, it had to be a number in the same type.
+
Arithmetic:
- - The new `add-dimension' operator will stack the popped operands in a
+ - New operators:
+ - interpolate-minngb: Fill blanks with minimum of nearest neighbors.
+ - interpolate-maxngb: Fill blanks with maximum of nearest neighbors.
+ This can be useful to fill the blank values of saturated stars
+ for example.
+ - To force integers to floats, you can also put a '.' or '.0' after
+ them. Until now, it was only possibly by putting an 'f' after
+ them. Hence while '5' will be read as an integer, '5.', '5.0' or '5f'
+ will be read as floating point. This also applies to column arithmetic
+ in Table.
+
+ ConvertType:
+ - New colormap: 'sls-inverse' is the inverse of the SLS color, good for
+ printing because of a white background.
+
+ CosmicCalculator:
+ --velocity: Velocity (in km/s) to use instead of input redshift.
+ --usedvelocity: Print the velocity (in km/s) at input redshift.
+ --listlinesatz: Print the wavelength of all pre-defined spectral lines
+ at given redshift as a simple table with the line names. This is very
+ convenient and can be used in conjunction with '--obsline' for example
+ to print the observed wavelength of all lines when Lyman-alpha is at
+ 4000 Angstroms with this simple command:
+ astcosmiccal --obsline=lyalpha,4000 --listlinesatz
+
+ FITS:
+ - New '--pixelscale' option will return the size of pixels in each
+ dimension in the "world coordinates".
+ - New '--wcsdistortion' option allows conversion between the various WCS
+ distortions. For example if you have a FITS image with the TPV-based
+ WCS distortion, and you would like to convert it to a SIP-based
+ distortion, you can simply run 'astfits --wcsdistortion=SIP' on the
+ file. The inverse conversion is also supported (from SIP to TPV).
+
+ Statistics
+ - New feature to create a 2D-histogram using two input columns (useful
+ when you have lots of points that are too dense and may hide important
+ features). This mode can be activated with the new '--histogram2d'
+ option. The binning of the first (X axis) column is specified with the
+ same 1D histogram options. The second column's binning is configured
+ with the following options:
+ --numbins2: Number of bins along the second column.
+ --greaterequal2: Only second column points that are larger than this.
+ --lessthan2; Only second column points that are less than this.
+ --onebinstart2: Make sure one bin starts at the value given here.
+
+ Table:
+ - New '--catcolumns' to specify which columns to concatenate (or append)
+ to the output. You can specify the file name containing the columns to
+ append with the '--catcolumnfile' option and '--catcolumnhdu' (see
+ changed features because until now they had different names).
+ - New '--catcolumnsrawname' will leave the name of concatenated
+ (appended) columns unchanged. By default the names of the appended
+ columns will be appended with a '-N' (where 'N' is a counter for the
+ file that is used to append columns). The default behavior is to avoid
+ multiple columns having the same name.
+ - New '--colmetadata' option to add/update column metadata (name, units
+ or comments) just before writing the output. This is a very useful
+ feature in combination with column arithmetic or column concatenation
+ because it will allow you to update the new column metadata in the
+ same command. See the manual for more.
+
+ Library:
+ - Spectral lines library: SiIII, OIII, CIV, NV and rest of Lyman series.
+ - GAL_CONFIG_HAVE_WCSLIB_DIS_H: if the host's WCSLIB supports distortions.
+ - GAL_CONFIG_HAVE_WCSLIB_MJDREF: if the host's WCSLIB reads MJDREF keyword.
+ - gal_cosmology_velocity_from_z: Calculate velocity from redshift.
+ - gal_cosmology_z_from_velocity: Calculate redshift from velocity.
+ - gal_data_array_ptr_calloc: Allocate array of pointers to gal_data_t
+ - gal_data_array_ptr_free: Free all the datasets within the array and
itself.
+ - gal_fits_key_list_title_add: Add a title key word to the list.
+ - gal_fits_key_list_title_add_end: Add a title key word to the list's end.
+ - GAL_INTERPOLATE_NEIGHBORS_METRIC_RADIAL: Radial metric for interpolation.
+ - GAL_INTERPOLATE_NEIGHBORS_METRIC_MANHATTAN: Mahattan distance.
+ - GAL_INTERPOLATE_NEIGHBORS_METRIC_INVALID: For error-handling/completeness.
+ - GAL_INTERPOLATE_NEIGHBORS_FUNC_MIN: Use minimum for interpolation.
+ - GAL_INTERPOLATE_NEIGHBORS_FUNC_MAX: Use maximum for interpolation.
+ - GAL_INTERPOLATE_NEIGHBORS_FUNC_MEDIAN: Use median for interpolation.
+ - GAL_INTERPOLATE_NEIGHBORS_FUNC_INVALID: for error-handling/completeness.
+ - gal_kdtree_create: Create a k-d tree for optimal spatial searching.
+ - gal_kdtree_nearest_neighbour: Find the nearest neighbor using a k-d tree.
+ - gal_statistics_histogram2d: Generate 2D histogram from two columns.
+ - GAL_WCS_FLTERROR: Limit to identify a floating point error for WCS.
+ - gal_wcs_write: Write the given WCS into a FITS extension with no data.
+ - gal_wcs_clean_errors: clean major WCS components from errors specified
+ by the FITS keyword 'CRDER', or floating point errors.
+ - gal_wcs_distortion_from_string: Return distortion string/name from ID.
+ - gal_wcs_distortion_to_string: Return distortion ID from string/name.
+ - gal_wcs_distortion_identify: Identify the distortion of given WCS.
+ - gal_wcs_distortion_convert: Convert between various WCS distortions.
+
+** Removed features
+
+** Changed features
+
+ Arithmetic:
+ - The 'pow' operator can also accept integer inputs. This also applies
+ to column arithmetic in Table.
+
+ MakeProfiles:
+ - The status of every created profile (along with the number of
+ remaining profiles) is no longer printed when there are more than 50
+ profiles. This is done because printing itself can slow down the
+ program an in a general/automated script this info is redundant.
+
+ Table:
+ --catcolumnfile ('-L') is new name for '--catcolumn' ('-C').
+ --catcolumnhdu is new name for '--catcolhdu' (short option name hasn't
+ changed).
+
+ Library:
+ - gal_fits_key_list_add: new 'ufree' argument to optionally free units.
+ - gal_fits_key_list_add_end: similar to 'gal_fits_key_list_add'.
+ - gal_interpolate_neighbors: new name for gal_interpolate_close_neighbors.
+ - gal_statistics_outlier_bydistance: new name for the old
+ 'gal_statistics_outlier_positive'. It can now use the same algorithm
+ for negative outliers with a new argument.
+ - gal_txt_write: Now accepts a new argument for keyword lists.
+ - gal_type_string_to_number: Numbers ending in '.' or '.0' will be
+ parsed as floating point. Until now, it would only parse numbers as
+ floating point if they had non-zero decimals.
+
+** Bugs fixed
+ bug #58434: MakeCatalog crash when ordering is required and no usable pixels.
+ bug #58455: Timezone is not portable and uses flag instead of seconds.
+ bug #58696: Warp with --centeroncorner --scale making wrong size.
+ bug #58774: Warp' s output on a cube is a 2D image or wrong size.
+ bug #58809: NoiseChisel not removing negative outlier tiles.
+ bug #58833: Segment crashes when detection map has blank pixels.
+ bug #58835: Floating point errors when comparing pixel scale in Crop.
+ bug #58898: Plain text string columns touching next, clear first character.
+ bug #58901: Blank values for non-standard integer types in FITS tables.
+ bug #58974: WCS conversion not reasonable on processed TPV data.
+ bug #59019: FITS Table crash when TFORM comes before TNULL.
+
+
+
+
+
+* Noteworthy changes in release 0.12 (library 10.0.0) (2020-05-20) [stable]
+
+** New features
+
+ Arithmetic:
+ - New 'quantile' operator for coadding datasets.
+ - New 'size' operator to report length of dataset in requested dimension.
+ - When '--wcsfile' is given the value 'none', output will not have any WCS.
+
+ CosmicCalculator:
+ --listlines: list the pre-defined spectral line wavelengths and names
+ (which you can use with the '--obsline' and '--lineatz' options). This
+ is convenient when you forget the specific name of the spectral line
+ used within Gnuastro.
+
+ Crop:
+ --polygon: can now also crop concave polygons (when atleast one inner
+ angle is more than 180 degrees). Concave polygons occur a lot in deep
+ astronomical imaging: in the shape of the deepest regions.
+ --polygonsort: Sort the given set of vertices to the '--polygon'
+ option. For a concave polyton, the sorting will be correct, but for a
+ convex polygon, there is no unique solution/sorting, so it may not be
+ what you expect, see the manual.
+
+ Fits:
+ --datasum: Calculate and print the given HDU's "datasum" to stdout.
+ --datetosec: Can also account for 'Z' in the end of the date-time
+ string. According to 'https://www.w3.org/TR/NOTE-datetime', a 'Z'
+ effectively means no time zone, or UTC time (which is the default in
+ FITS). It still doesn't account for time zone hours of the w3.org
+ standard.
+
+ MakeCatalog:
+ --sigmaclip: define sigma-clipping parameters for the new '--sigclip-*'
+ columns.
+ --forcereadstd: Read the standard deviation image even if not needed by
+ any columns. This is useful when you want the surface brightness
+ limit, but don't need any error-related columns.
+ New output columns:
+ --sigclip-number: Number of sigma-clipped pixels in object/clump.
+ --sigclip-median: Sigma-clipped median of pixels in object/clump.
+ --sigclip-mean: Sigma-clipped mean of pixels in object/clump.
+ --sigclip-std: Sigma-clipped standard deviation of pixels in object/clump.
+
+ Table:
+ --equal: Can now work on columns with string type also.
+ --notequal: Can now work on columns with string type also.
+ --polygon: Polygon to use in '--inpolygon' or '--outpolygon'.
+ --inpolygon: Select rows that are inside the polygon of '--polygon'.
+ --outpolygon: Select rows that are outside the polygon of '--polygon'.
+ --catcolumn: Concatenate tables by column (keeping number of rows fixed).
+ --catcolhdu: Specify the HDU/extension of the FITS files of --catcolumn.
+ - New operators in column arithmetic:
+ - 'ra-to-degree': Convert Right Ascension (HH:MM:SS) to degrees.
+ - 'dec-to-degree': Convert Declination (DD:MM:SS) to degrees.
+ - 'degree-to-ra': Convert degrees to Right Ascension (HH:MM:SS).
+ - 'degree-to-dec': Convert degrees to Declination (HH:MM:SS).
+ - 'distance-flat': Distance between two points, assuming flat space.
+
+ Library:
+ - GAL_SPECLINES_INVALID_MAX: Total number of spectral lines, plus 1.
+ - GAL_ARITHMETIC_OP_QUANTILE: operator for 'gal_arithmetic'.
+ - gal_txt_trim_space: trim white space before and after a string.
+ - gal_polygon_is_convex: identify if a polygon is convex or concave.
+ - gal_polygon_is_inside: if point is inside polygon (convex or concave).
+ - gal_polygon_is_counterclockwise: check if polygon is counter-clockwise.
+ - gal_polygon_to_counterclockwise: convert to counter-clockwise if it isn't.
+ - gal_polygon_vertices_sort: un-ordered vertices to concave/convext
polygons.
+ - gal_units_extract_decimal: Extract numbers from strings like "A:B:C".
+ - gal_units_ra_to_degree: Convert RA (HH:MM:SS) to degrees.
+ - gal_units_dec_to_degree: Convert Dec (DD:MM:SS) to degrees.
+ - gal_units_degree_to_ra: Convert degrees to RA (DD:MM:SS).
+ - gal_units_degree_to_dec: Convert degrees to Dec (DD:MM:SS).
+
+** Removed features
+
+** Changed features
+
+ All programs and libraries:
+ --minmapsize: Gnuastro's programs no longer attempt to write
+ memory-mapped files under '.gnuastro'. They will only attempt to write
+ them under the '.gnuastro_mmap' directory. Until now, when an internal
+ array needed to be memory-mapped, Gnuastro's programs (through the
+ 'pointer.h' library) would first try writing the mmap files in the
+ '.gnuastro' directory. When it failed it would attempt writing in the
+ '.gnuastro_mmap' directory. However, '.gnuastro' is also used to store
+ configuration files (which are hand-written and thus valuable). Mixing
+ the two types of source (configuration files) and automatically
+ generated (memory-mapped) files is very problematic.
+ - FITS ASCII tables: When a column has a floating point type, but its
+ ASCII string can't be parsed as a number, it will be read as a
+ NaN. Until now, the corresponding program/library would abort,
+ printing the problematic string and its location.
+
+ Crop:
+ --polygon: by default it will no longer attempt to sort the polygon
+ vertices, sorting can be requested with the new '--polygonsort' option.
+ --polygonout: is the new name for '--outpolygon'. Having 'polygon' at
+ the start of the option name, makes it easier to find in the help list
+ and also to understand generally.
+
+ MakeCatalog:
+ - Until now, if no standard deviation image was requested, MakeCatalog
+ wouldn't include any surface brightness limit metadata in its
+ output. Now, those two lines are filled, but with a notice on the
+ cause (that there is no standard deviation image), and suggesting
+ solutions.
+
+ NoiseChisel:
+ - Until now, when NoiseChisel didn't detect any pixels, it just printed
+ a message and wouldn't not make any output file. This was very
+ inconvenient in general scripts. From now on, in this scenario, an
+ output file will be created and the detection map will only have a
+ value of zero. As a result, the Sky and Sky standard deviation
+ extensions will be measured over all the tiles.
+
+ Table:
+ - In Column arithmetic, when columns must be specified by their number,
+ that number should be distinguished with a '$' before it (for example
+ '$1' means the first column). Until now, this character was 'c', but
+ the new identifying character is very similar to AWK, allowing easier
+ adoption and is also more clear. It is just important to put the total
+ 'arith' string within single quotes, not double quotes.
+ - Operators:
+ - 'distance-on-sphere': New name for old `angular-distance' operator.
+
+ Library:
+ - gal_polygon_is_inside_convex: new name for 'gal_polygon_pin'.
+
+** Bugs fixed
+ bug #57300: MakeCatalog memory crash when input dataset has units.
+ bug #57301: MakeCatalog using river sum instead of mean times by clump area.
+ bug #57921: Arithmetic's interpolation operator not reading metric.
+ bug #57989: Warp not accounting for translation in pixel grid.
+ bug #57995: Fits lib's date to second function affected by host's timezone.
+ bug #58315: Some NaNs with sigma-clip operators in Arithmetic and one input.
+ bug #58371: Table crashes with a commented newline in the columns.
+
+
+
+
+
+* Noteworthy changes in release 0.11 (library 9.0.0) (2019-11-25) [stable]
+
+** New features
+
+ Book:
+ - The "General program usage tutorial" now has a section on how to write
+ scripts effectively to automate your analysis.
+
+ Arithmetic:
+ - The new 'add-dimension' operator will stack the popped operands in a
higher-dimensional dataset. For example to build a 3D cube from
individual 2D images/slices.
--onedonstdout: when the output is one-dimensional, print the values on
@@ -17,12 +658,12 @@ See the end of the file for license conditions.
BuildProgram:
- Will use common environment variables like LDFLAGS, CPPFLAGS and CC to
help in customizing the build of your program.
- --cc: custom C compiler to use. Until now, `gcc' was hard-coded into the
+ --cc: custom C compiler to use. Until now, 'gcc' was hard-coded into the
source and there was no way to choose a custom C compiler.
--noenv: With this option, no environment variables will be read.
ConvertType:
- - New `viridis' colormap (value for the `--colormap' option). This is
+ - New 'viridis' colormap (value for the '--colormap' option). This is
the default colormap of Python's Matplotlib, and is available in many
other plotting tools like LaTeX's PGFPlots.
@@ -49,8 +690,17 @@ See the end of the file for license conditions.
--geow3: Geometric center in third WCS axis.
--clumpsw3: Flux wheighted center of all clumps in 3rd dim.
--clumpsgeow3: Geometric center of all clumps in 3rd dim.
- --areaxy: Projected area in first two dimentions.
+ --areaxy: Projected area in first two dimensions.
--geoareaxy: Projected geoarea in first two dimensions.
+ --inbetweenints: output will contain one row for all integers between 1
+ and the largest label in the input (irrespective of their existance in
+ the input image). This was the default/only behavior of MakeCatalog
+ until now. However, there are situations where the labeled input image
+ integers may not be contiguous. For example if the input's only
+ labeled pixel values are 11 and 13 from this release MakeCatalog's
+ output will only have two rows. If you want the old behavior (of one
+ row per integer, even if its not in the image), you can use this
+ option.
MakeProfiles:
- Can produce mock ellipsoids in a datacube (using X-Z-X Euler angles
@@ -59,13 +709,28 @@ See the end of the file for license conditions.
--p2col: Second Euler angle (X-Z-X order).
--p3col: Third Euler angle (X-Z-X order).
--q2col: Axis ratio (major/dim3 in 3D).
- - The `--kernel' option can build 3D kernels, see the description of
+ - The '--kernel' option can build 3D kernels, see the description of
this option in the book for examples and details on how to run it.
Match:
- Matching of catalogs now possible using 3 coordinates (on catalogs
generated from 3D data cubes), see book for more.
+ NoiseChisel:
+ - arXiv:1909.11230 added in papers to cite (with the '--cite' option):
+ this paper describes the major changes made to NoiseChisel in the last
+ 10 stable releases since the 2015 paper, most importantly how Segment
+ has been separated and the new growth strategy. It is therefore
+ necessary to cite it along with the initial 2015 paper when using
+ NoiseChisel.
+
+ Segment:
+ - arXiv:1909.11230 added in papers to cite (with the '--cite' option):
+ this paper describes why Segment has been separated from NoiseChisel
+ and some important updates to it compared to the 2015 paper, it is
+ therefore necessary to cite it along with that paper when using
+ Segment.
+
Statistics:
--contour: compute a contour plot which can be directly fed into the
PGFPlots package of LaTeX for plotting the contours. Support for more
@@ -73,20 +738,22 @@ See the end of the file for license conditions.
Table:
--equal: Output only rows that have a value equal to the given value in
- the given column. For example `--equal=ID,2,4,5' will select only rows
- that have a value of 2, 4 and 5 in the `ID' column.
+ the given column. For example '--equal=ID,2,4,5' will select only rows
+ that have a value of 2, 4 and 5 in the 'ID' column.
--notequal: Output only rows that have a different value compared to the
values given to this option in the given column.
- Column Arithmetic operators:
- - `angular-distance': a new operator to easily find the angular
+ - 'angular-distance': a new operator to easily find the angular
distance (along a great circle) between points in various table
columns, or the distances of all the points in the table rows with a
fixed point. See the book for examples and better explanation.
Library:
- gal_binary_connected_indexs: store indexs of connected components.
+ - gal_blank_remove_realloc: Remove blanks and shrink allocated space.
- gal_box_bound_ellipsoid_extent: Extent of 3D ellipsoid.
- gal_box_bound_ellipsoid: Bounding box for a 3D ellipsoid.
+ - gal_statistics_unique: Return unique (non-blank) elements of the input.
** Removed features
@@ -99,6 +766,10 @@ See the end of the file for license conditions.
bug #56999: Compilation error on macOS 10.9 not recognizing AT_FDCWD.
bug #57057: BuildProgram not using environment LDFLAGS or CPPFLAGS.
bug #57101: Crop segmentation fault when no overlap exists in image-mode.
+ bug #57164: MakeCatalog crashes when a label isn't in the dataset.
+ bug #57180: MakeCatalog reporting infinity S/N when --instd isn't an image.
+ bug #57200: Generated pkgconfig must request wcslib, not wcs.
+ bug #57293: NaN value for brightness-related columns when values have NaN.
@@ -111,8 +782,8 @@ See the end of the file for license conditions.
Installation:
- With the the following options at configure time, its possible to
build Gnuastro without the optional libraries (even if they are
- present on the host system): `--without-libjpeg', `--without-libtiff',
- `--without-libgit2'.
+ present on the host system): '--without-libjpeg', '--without-libtiff',
+ '--without-libgit2'.
All programs:
- When an array is memory-mapped to non-volatile space (like the
@@ -120,13 +791,13 @@ See the end of the file for license conditions.
its size. Later, when its deleted, a warning/message is also printed,
informing you that it has been deleted. These warnings can be very
useful when you actually have enough RAM, but forget to increase the
- `--minmapsize' value (therefore significantly slowing down the
+ '--minmapsize' value (therefore significantly slowing down the
program). When you don't have enough RAM, but don't want to be annoyed
- with the warnings, you can use the new `--quietmmap' option to disable
+ with the warnings, you can use the new '--quietmmap' option to disable
them.
Arithmetic:
- - `unique' operator removes all duplicate (and blank) elements from the
+ - 'unique' operator removes all duplicate (and blank) elements from the
dataset and returns a single-dimension output, containing only the
unique values in the dataset.
@@ -134,7 +805,7 @@ See the end of the file for license conditions.
- Can also crop 3D datasets (data cubes). A 3D crop has the same syntax
as the old 2D mode, only when the dataset is 3D, three coordinates
(values, ranges or catalog-columns) should be given to the relevant
- option. Just note that `--polygon' crops are still not supported in
+ option. Just note that '--polygon' crops are still not supported in
3D.
CosmicCalculator:
@@ -143,7 +814,7 @@ See the end of the file for license conditions.
and observed wavelength and the redshift to use will be calculated
internally. For many lines, it is possible to give the line name
instead of its rest-frame wavelength. For example
- `--obsline=lyalpha,6000' will use the redshift where the Lyman-alpha
+ '--obsline=lyalpha,6000' will use the redshift where the Lyman-alpha
line has been shifted to 6000 Angstroms.
--usedredshift: Print the used redshift as a "Specific calculation" (in
line with other single-valued calculations).
@@ -158,7 +829,7 @@ See the end of the file for license conditions.
measurement. Until now sigma-clipping results included a lot of
visually useful information, which also made automatic usage of
results hard. These options fix this issue. Please see the example in
- the book under `--sigclip-median' for a nice use case.
+ the book under '--sigclip-median' for a nice use case.
Table:
- Column arithmetic. It is now possible to apply many operations on the
@@ -166,21 +837,21 @@ See the end of the file for license conditions.
Arithmetic, but on table columns. The operators and notation is just
like the Arithmetic program. See the "Column Arithmetic" section of
the book for a detailed discussion and several examples.
- - WCS to Image coordinate conversion with `wcstoimg' and `imgtowcs'. For
- example if the input catalog has at least an `ID' column and two `RA'
- and `DEC' columns, the set of options below will produce 5 columns
+ - WCS to Image coordinate conversion with 'wcstoimg' and 'imgtowcs'. For
+ example if the input catalog has at least an 'ID' column and two 'RA'
+ and 'DEC' columns, the set of options below will produce 5 columns
where the last two columns are the image coordinates for each row
- based on the WCS in `a.fits':
- `-cID,RA,DEC -c"arith RA DEC wcstoimg" --wcsfile=a.fits'
+ based on the WCS in 'a.fits':
+ '-cID,RA,DEC -c"arith RA DEC wcstoimg" --wcsfile=a.fits'
--head: Only output the given number of rows from the top of columns.
--tail: Only output the given number of rows from the bottom of columns.
Library:
- - New `speclines.h' library functions and macros related to spectral
+ - New 'speclines.h' library functions and macros related to spectral
lines. It has many macros with line wavelengths, and several functions
for using them in combination with their names.
- list.h: Functions to return the last element in linked lists. For
- example `gal_list_sizet_last' or `gal_list_data_last'.
+ example 'gal_list_sizet_last' or 'gal_list_data_last'.
- gal_arithmetic_operator_string: Return operator string from code.
- gal_arithmetic_set_operator: Return operator code from string.
- gal_blank_initialize_array: Initialize an array with blank values.
@@ -189,46 +860,46 @@ See the end of the file for license conditions.
- gal_fits_img_info_dim: Only return the size information of a dataset.
- GAL_TYPE_INT: Corresponding to respective width based on system.
- GAL_TYPE_UINT: Corresponding to respective width based on system.
- - GAL_BLANK_INT: Blank value for `int' (can be 16-bit or 32-bit).
- - GAL_BLANK_UINT: Blank value for unsigned `int' (can be 16-bit or 32-bit).
+ - GAL_BLANK_INT: Blank value for 'int' (can be 16-bit or 32-bit).
+ - GAL_BLANK_UINT: Blank value for unsigned 'int' (can be 16-bit or 32-bit).
** Removed features
** Changed features
Installation:
- - Better `./configure' tests (using Gnulib's `AC_LIB_HAVE_LINKFLAGS') to
- avoid some crashes during `make' when the host had multiple
+ - Better './configure' tests (using Gnulib's 'AC_LIB_HAVE_LINKFLAGS') to
+ avoid some crashes during 'make' when the host had multiple
conflicting versions of some dependencies (GSL in particular).
Arithmetic:
- The output of co-adding operators is no longer the same type as the
- input in general. The output of the `min' and `max' operators are
- still the same type as the input. However the `number' and
- `sigclip-number' operators will output an unsigned 32-bit integer type
- and the rest (`sum', `mean', `std', `median', `sigclip-median',
- `sigclip-mean' and `sigclip-std') return 32-bit floating point
+ input in general. The output of the 'min' and 'max' operators are
+ still the same type as the input. However the 'number' and
+ 'sigclip-number' operators will output an unsigned 32-bit integer type
+ and the rest ('sum', 'mean', 'std', 'median', 'sigclip-median',
+ 'sigclip-mean' and 'sigclip-std') return 32-bit floating point
datasets
MakeCatalog:
- When a clumps catalog is requested, MakeCatalog will automatically
deduce the total number of clumps (at a small cost in
performance). Until now, it was mandatory for the clumps label dataset
- to contain the total number of clumps in the `NUMLABS' keyword.
+ to contain the total number of clumps in the 'NUMLABS' keyword.
Library:
- gal_statistics_outlier_flat_cfp: Improved implementation with new API.
- - New `quietmmap' argument added to the following functions (as the
- argument following `minmapsize'). For more, see the description above
- of the new similarly named option to all programs: `gal_array_read'
- `gal_array_read_to_type', `gal_array_read_one_ch',
- `gal_array_read_one_ch_to_type', `gal_data_alloc',
- `gal_data_initialize', `gal_fits_img_read',
- `gal_fits_img_read_to_type', `gal_fits_img_read_kernel',
- `gal_fits_tab_read', `gal_jpeg_read', `gal_label_indexs',
- `gal_list_data_add_alloc', `gal_match_coordinates',
- `gal_pointer_allocate_mmap', `gal_table_read', `gal_tiff_read' and
- `gal_txt_image_read'
+ - New 'quietmmap' argument added to the following functions (as the
+ argument following 'minmapsize'). For more, see the description above
+ of the new similarly named option to all programs: 'gal_array_read'
+ 'gal_array_read_to_type', 'gal_array_read_one_ch',
+ 'gal_array_read_one_ch_to_type', 'gal_data_alloc',
+ 'gal_data_initialize', 'gal_fits_img_read',
+ 'gal_fits_img_read_to_type', 'gal_fits_img_read_kernel',
+ 'gal_fits_tab_read', 'gal_jpeg_read', 'gal_label_indexs',
+ 'gal_list_data_add_alloc', 'gal_match_coordinates',
+ 'gal_pointer_allocate_mmap', 'gal_table_read', 'gal_tiff_read' and
+ 'gal_txt_image_read'
Book:
- The two larger tutorials ("General program usage tutorial", and
@@ -271,54 +942,54 @@ See the end of the file for license conditions.
option's value).
Arithmetic:
- - The new `tofile-' and `tofilefree-' operators will save the top
+ - The new 'tofile-' and 'tofilefree-' operators will save the top
operand into a file. They can be very handy in debugging/understanding
an Arithmetic command (especially as it gets complicated), or to
produce multiple files/extensions with a single call to Arithmetic.
- Four new operators have been added to allow coadding multiple datasets
- into one using sigma-clipping: `sigclip-number', `sigclip-mean',
- `sigclip-median', and `sigclip-std'. These are very useful when
+ into one using sigma-clipping: 'sigclip-number', 'sigclip-mean',
+ 'sigclip-median', and 'sigclip-std'. These are very useful when
several inputs have strong outliers that affect the median, or the
mean is required.
- Multithreaded operation for the following operators that
- combine/co-add multiple inputs into one output with same size: `min',
- `max', `number', `sum', `mean', `std', `median', `sigclip-number',
- `sigclip-median', `sigclip-mean', `sigclip-std'.
+ combine/co-add multiple inputs into one output with same size: 'min',
+ 'max', 'number', 'sum', 'mean', 'std', 'median', 'sigclip-number',
+ 'sigclip-median', 'sigclip-mean', 'sigclip-std'.
--wcsfile and --wcshdu: these two options can be used to specify a
different file for reading the WCS of the output. This is useful when
the default (the WCS of the first dataset that is read) is not the
required one.
--interpmetric: new option that is necessary with the
- `interpolate-medianngb' operator. For more, see the description of
+ 'interpolate-medianngb' operator. For more, see the description of
this option in NoiseChisel.
Fits:
- - Add "title" to group FITS keywords with `--write=/,"title name". This
+ - Add "title" to group FITS keywords with '--write=/,"title name". This
"title" is composed of two keyword records/lines: a blank one (all
- whitespace), followed by another starting with `/' and ending in any
+ whitespace), followed by another starting with '/' and ending in any
string given to this option. This visually separates the keywords and
acts as a title. Classifying the keywords into contextually similar
groups greatly helps in visual inspection and is encouraged.
- - Calculate and write `CHECKSUM' and `DATASUM' integrity keywords into
- the specified header using `--write=checksum' (for both) or
- `--write=datasum' (only for `DATASUM').
+ - Calculate and write 'CHECKSUM' and 'DATASUM' integrity keywords into
+ the specified header using '--write=checksum' (for both) or
+ '--write=datasum' (only for 'DATASUM').
--datetosec: Convert the FITS date format (old or new) to number of
seconds since since the Unix epoch time (1970-01-01,00:00:00). The
- FITS date format (for example `YYYY-MM-DDThh:mm:ss') is hard to use
+ FITS date format (for example 'YYYY-MM-DDThh:mm:ss') is hard to use
for automatic processing (requires calendar peculiarities like number
of days in each month, or leap years and etc). With this option a
single integer is returned that can be used for example to sort FITS
files by date keywords without worrying about calendar peculiarities.
- --verify: confirm if the `DATASUM' and `CHECKSUM' keyword values agree
+ --verify: confirm if the 'DATASUM' and 'CHECKSUM' keyword values agree
with the specified HDU's content and/or data.
--copykeys: Copy several keyword records (in a given range) from one
FITS HDU/extension into another (possibly in another file).
- --outhdu: The name/number of the output HDU (for `--copykeys').
+ --outhdu: The name/number of the output HDU (for '--copykeys').
Match:
- All the columns from one of the input catalogs can now be merged with
- any of the columns of the second using the special `_all' name of
- `--outcols'. For example the output of `--outcols=a_all,b5' will
+ any of the columns of the second using the special '_all' name of
+ '--outcols'. For example the output of '--outcols=a_all,b5' will
contain all the columns from the first input and the 5th column of the
second input. This greatly simplifies the merging of different table
columns into one.
@@ -349,39 +1020,39 @@ See the end of the file for license conditions.
image) to define separate pseudo-detections. If its stronger,
pseudo-detections that are touching on the corner will be identified
as one.
- --dopening: The number of openings to do after applying `--dthresh'.
- --dopeningngb: The connectivity (4 or 8) to use for `--dopening'.
+ --dopening: The number of openings to do after applying '--dthresh'.
+ --dopeningngb: The connectivity (4 or 8) to use for '--dopening'.
Statistics:
--interpmetric: Similar to NoiseChisel.
Table:
--range: Limit the output rows to those with a value within the given
- numeric range with this format: `--range=COL,low,high'. This is very
+ numeric range with this format: '--range=COL,low,high'. This is very
useful when only certain rows of the input are required not the
output. The advantage over piping to AWK is that you can save the
output directly to FITS (preserving the metadata). See the book for
more.
--sort: Sort the output rows based on the value of the given column in
ascending order.
- --descending: When called with `--sort', will arrange the output rows in
+ --descending: When called with '--sort', will arrange the output rows in
descending order.
Installed scripts:
With this release, Gnuastro also installs Bash scripts for common
higher-level usage of (possibly multiple) programs. These scripts have a
- `astscript-*' name, to easily show up on the command-line as Gnuastro
+ 'astscript-*' name, to easily show up on the command-line as Gnuastro
executables with the other Gnuastro programs, but are identifiable from
them. They support options just like the programs (which can be listed
- with `--help'). Please see the new "Installed scripts" chapter of the
+ with '--help'). Please see the new "Installed scripts" chapter of the
book for more.
- astscript-sort-by-night: New Gnuastro executable, using Gnuastro's
Fits program to identify files with dates in the same night (possibly
spanning two calendar dates).
Library:
- GAL_BLANK_LONG: new macro for the `long' type blank value.
- GAL_BLANK_ULONG: new macro for the `unsigned long' type blank value.
+ GAL_BLANK_LONG: new macro for the 'long' type blank value.
+ GAL_BLANK_ULONG: new macro for the 'unsigned long' type blank value.
gal_blank_number: Return the number of blank elements in a dataset.
gal_dimension_dist_radial: Radial distance between two coordinates.
gal_fits_key_date_to_struct_tm: FITS date format to C broken-down time.
@@ -398,14 +1069,14 @@ See the end of the file for license conditions.
** Changed features
Arithmetic:
- - `num' operator is renamed to `number'.
- - `numvalue' operator is renamed to `numbervalue'.
- - `--dontdelete' will append the output to any existing file. Note that
+ - 'num' operator is renamed to 'number'.
+ - 'numvalue' operator is renamed to 'numbervalue'.
+ - '--dontdelete' will append the output to any existing file. Note that
this change is only in Arithmetic, other programs will still just
complain and abort.
ConvertType:
- --forcemin & --forcemax: until now, `--flminbyte' and `--flmaxbyte' were
+ --forcemin & --forcemax: until now, '--flminbyte' and '--flmaxbyte' were
used to force the range of conversion to color channels (even if the
range is beyond the limits of the dataset). With the introduction of
color maps in Gnuastro 0.8, it is also necessary to force a range on
@@ -419,25 +1090,25 @@ See the end of the file for license conditions.
mean square (the correct definition of the Sky standard deviation).
NoiseChisel:
- --ignoreblankintiles: Until now `--ignoreblankinsky', would specify if
+ --ignoreblankintiles: Until now '--ignoreblankinsky', would specify if
blank values should also be written into the tiled Sky and Sky
standard deviation outputs. But NoiseChisel can optionally produce
- many more tiled outputs (for example with `--checkqthresh'). So the
- option was renamed to `--ignoreblankintiles' to highlight that the
+ many more tiled outputs (for example with '--checkqthresh'). So the
+ option was renamed to '--ignoreblankintiles' to highlight that the
status of blank elements can be set in all tiled outputs.
Statistics:
--ignoreblankintiles: similar to same option in NoiseChisel.
Table:
- --colinfoinstdout: now corresponds to the `-O' short option. Until this
- version, the `-s' short option was used for it. But with the new
- `--sort' option, `-s' may cause confusion.
+ --colinfoinstdout: now corresponds to the '-O' short option. Until this
+ version, the '-s' short option was used for it. But with the new
+ '--sort' option, '-s' may cause confusion.
Library
gal_arithmetic: new argument: number of threads to use (when relevant).
- gal_eps_write: new argument: optional bit-optimization with `dontoptimize'.
- gal_pdf_write: new argument: optional bit-optimization with `dontoptimize'.
+ gal_eps_write: new argument: optional bit-optimization with 'dontoptimize'.
+ gal_pdf_write: new argument: optional bit-optimization with 'dontoptimize'.
** Bugs fixed
bug #55313: Fits program writing --write values in reverse order
@@ -469,7 +1140,7 @@ See the end of the file for license conditions.
- Standard input (for example from pipes) is now available to feed input
to all programs that accept plain text input (ConvertType, Convolve,
Match, MakeProfiles, Statistics, Table).
- - Updated acknowledgment statement (output of `--cite' option).
+ - Updated acknowledgment statement (output of '--cite' option).
Arithmetic:
--onedasimage: write output as an image if it has one dimension, not table.
@@ -485,9 +1156,9 @@ See the end of the file for license conditions.
Convolve:
- Convolves 1D arrays (table columns, for example spectra)
- also. Therefore two new options have been added to it: `--column'
- (`-c', similar to other programs that read table columns), and
- `--kernelcolumn' (to specify the column of the kernel in its own
+ also. Therefore two new options have been added to it: '--column'
+ ('-c', similar to other programs that read table columns), and
+ '--kernelcolumn' (to specify the column of the kernel in its own
file/extension).
Fits:
@@ -500,7 +1171,7 @@ See the end of the file for license conditions.
pixel-value distribution test due to the flatness of the extended
profiles, can be identified and removed as outliers in comparison
with the other passed tiles. The outlier finding algorithm
- (`gal_statistics_outlier_positive': a new library function) uses the
+ ('gal_statistics_outlier_positive': a new library function) uses the
distribution of distances between the sorted elements and is
configured with these options.
--outliersclip: Sigma-clipping parameters for the process.
@@ -521,7 +1192,7 @@ See the end of the file for license conditions.
the Sky over the tiles that have a sufficiently large fraction of
undetected pixels. This is done to decrease the bias caused by
faint un-detected wings of bright galaxies or stars, see
- description of `--minskyfrac' for more. Until now the reference
+ description of '--minskyfrac' for more. Until now the reference
for this fraction was the whole tile size (irrespective of how
many blank elements it contains). With this option, it is now
possible to ask for ignoring blank pixels when calculating the
@@ -530,7 +1201,7 @@ See the end of the file for license conditions.
Statistics:
- If an input table has only one column, Statistics won't complain and
- abort when no `--column' (`-c') is given: there is only one column to
+ abort when no '--column' ('-c') is given: there is only one column to
use anyway, so it will be used. In the absence of which column to
use, it will still complain and abort if the input has more than one
column.
@@ -561,29 +1232,29 @@ See the end of the file for license conditions.
Arithmetic:
- If the output has one dimension, it will be written as a table, not a
- FITS image/array. This can be changed with the new `--onedasimage'
+ FITS image/array. This can be changed with the new '--onedasimage'
option.
Convolve:
- - The short option for `--numchannels' is now `-n'. Until now, it was
- `-c', but that would conflict with the short option used for
- `--column' in all the other programs that also read from a table.
+ - The short option for '--numchannels' is now '-n'. Until now, it was
+ '-c', but that would conflict with the short option used for
+ '--column' in all the other programs that also read from a table.
MakeProfiles:
- --mergedsize: new name for the old `--naxis' option. Since the option
+ --mergedsize: new name for the old '--naxis' option. Since the option
names and values are now written into the FITS header of the
output, this option's name would get confused with the mandatory
- FITS keyword `NAXIS'.
+ FITS keyword 'NAXIS'.
NoiseChisel:
- Until now, the mode's quantile was used to identify tiles with no
significant signal. But from this version, the mean's quantile in
each tile is used instead. The reason is that the mean is more
- sensitive to outliers (signal). Therefore the old `--modmedqdiff' is
- now called `--meanmedqdiff' .
+ sensitive to outliers (signal). Therefore the old '--modmedqdiff' is
+ now called '--meanmedqdiff' .
Statistics:
- --meanmedqdiff: new name for `--modmedqdiff'. Similar to NoiseChisel.
+ --meanmedqdiff: new name for '--modmedqdiff'. Similar to NoiseChisel.
Library:
- gal_array_read: list of strings (from standard input) acceptable.
@@ -608,7 +1279,7 @@ See the end of the file for license conditions.
bug #54579: NoiseChisel pseudo-detection failure when dataset is negative.
bug #54782: Segment's check image not removing sky clumps some tiles.
bug #54810: Arithmetic crash when previously named operand renamed.
- bug #55025: MakeCatalog's `--prepforconv' option being ignored.
+ bug #55025: MakeCatalog's '--prepforconv' option being ignored.
bug #55079: Blank EPS or PDF page when width options not given.
bug #55157: No sanity check on values given to Crop's --section.
bug #55295: Crash when more than one collapse operator called.
@@ -624,18 +1295,18 @@ See the end of the file for license conditions.
Installation:
--enable-debug: debugging flags, no optimization, no shared libraries.
- --enable-check-with-valgrind: Run `make check' tests within Valgrind.
+ --enable-check-with-valgrind: Run 'make check' tests within Valgrind.
Arithmetic:
- - `set-A': Set a name (`A' in this case) for the popped dataset. This
+ - 'set-A': Set a name ('A' in this case) for the popped dataset. This
allows only reading the dataset it into memory once and
possibly using it many times.
- - `fill-holes': Flip background (0) pixels surrounded by foreground (1).
- - `collapse-sum': collapse/remove a dimension by summing over it.
- - `collapse-min': collapse/remove a dimension by using minimum value.
- - `collapse-max': collapse/remove a dimension by using maximum value.
- - `collapse-mean': collapse/remove a dimension by averaging over it.
- - `collapse-number': Number of elements included in the collapse.
+ - 'fill-holes': Flip background (0) pixels surrounded by foreground (1).
+ - 'collapse-sum': collapse/remove a dimension by summing over it.
+ - 'collapse-min': collapse/remove a dimension by using minimum value.
+ - 'collapse-max': collapse/remove a dimension by using maximum value.
+ - 'collapse-mean': collapse/remove a dimension by averaging over it.
+ - 'collapse-number': Number of elements included in the collapse.
CosmicCalculator:
- Default cosmology set to Plank 2018 results (Paper VI).
@@ -665,12 +1336,12 @@ See the end of the file for license conditions.
--checkcenter: the units of value depend on mode (image or WCS).
MakeCatalog:
- - `--checkuplim': new name for `--checkupperlimit'.
- - `--brightnessnoriver': new name for `--noriverbrightness'.
+ - '--checkuplim': new name for '--checkupperlimit'.
+ - '--brightnessnoriver': new name for '--noriverbrightness'.
Library:
- - gal_txt_write: new `colinfoinstdout' argument.
- - gal_table_write: new `colinfoinstdout' argument.
+ - gal_txt_write: new 'colinfoinstdout' argument.
+ - gal_table_write: new 'colinfoinstdout' argument.
** Bugs fixed
@@ -752,7 +1423,7 @@ See the end of the file for license conditions.
--rawoutput: only output the detection labels and Sky and its STD.
--ignoreblankinsky: don't set the pixels that are blank in the input to
blank in the Sky and Sky standard deviation outputs (when
- `--oneelempertile' is not called).
+ '--oneelempertile' is not called).
--label: label the connected detections. Until now this was the default
behavior. However, from this release, NoiseChisel is only in charge
of detection. Segmentation is done by a new program (Segment). Since
@@ -767,7 +1438,7 @@ See the end of the file for license conditions.
Libraries:
gal_array_read: read array from any of known formats (FITS, TIFF,
JPEG,...).
- gal_array_read_to_type: similar to `gal_array_read', but to given type.
+ gal_array_read_to_type: similar to 'gal_array_read', but to given type.
gal_array_read_one_ch: Read a dataset, abort if it has multiple channels.
gal_array_read_one_ch_to_type: Make sure input is in one channel and type.
gal_binary_label_holes: label the holes within the foreground.
@@ -777,11 +1448,11 @@ See the end of the file for license conditions.
gal_eps_to_pt: Converts dataset size to PostScript points.
gal_eps_write: Writes a dataset into an EPS file.
gal_interpolate_1d_blank: Fill blank elements through interpolation.
- gal_interpolate_1d_make_gsl_spline: Allocate and initalize `gsl_spline'.
+ gal_interpolate_1d_make_gsl_spline: Allocate and initalize 'gsl_spline'.
gal_jpeg_name_is_jpeg: Returns 1 if given filename is JPEG.
gal_jpeg_suffix_is_jpeg: Returns 1 if given suffix is JPEG.
- gal_jpeg_read: Reads input JPEG image into `gal_data_t'.
- gal_jpeg_write: Writes a `gal_data_t' into a JPEG file.
+ gal_jpeg_read: Reads input JPEG image into 'gal_data_t'.
+ gal_jpeg_write: Writes a 'gal_data_t' into a JPEG file.
gal_label_grow_indexs: grow known indexs into desired areas.
gal_label_watershed: apply watershed algorithm on desired region.
gal_label_clump_significance: measure significance of all clumps in region.
@@ -796,7 +1467,7 @@ See the end of the file for license conditions.
gal_tiff_name_is_tiff: check if name contains a TIFF suffix.
gal_tiff_suffix_is_tiff: check if suffix is a TIFF suffix.
gal_tiff_dir_string_read: convert a string to a TIFF directory number.
- gal_tiff_read: Read the contents of a TIFF "directory" to `gal_data_t'.
+ gal_tiff_read: Read the contents of a TIFF "directory" to 'gal_data_t'.
** Removed features
@@ -812,10 +1483,10 @@ See the end of the file for license conditions.
--skysubtracted: no longer necessary, included in noise measuremnts.
Library:
- - The macros `GAL_STATISTICS_SORTED_NOT',
- `GAL_STATISTICS_SORTED_INVALID', `GAL_STATISTICS_SORTED_INCREASING',
- `GAL_STATISTICS_SORTED_DECREASING': these macros are removed because
- we already have the `GAL_DATA_FLAG_SORT*'' bit-flags in `gal_data_t'.
+ - The macros 'GAL_STATISTICS_SORTED_NOT',
+ 'GAL_STATISTICS_SORTED_INVALID', 'GAL_STATISTICS_SORTED_INCREASING',
+ 'GAL_STATISTICS_SORTED_DECREASING': these macros are removed because
+ we already have the 'GAL_DATA_FLAG_SORT*'' bit-flags in 'gal_data_t'.
** Changed features
@@ -830,9 +1501,9 @@ See the end of the file for license conditions.
--comment: can be called/written multiple times in one run.
MakeCatalog:
- - The `WCLUMPS' keyword in the objects labeled image is no longer used
+ - The 'WCLUMPS' keyword in the objects labeled image is no longer used
to see if a clumps catalog should also be made. To build a clumps
- catalog, you can now use the `--clumpscat' option.
+ catalog, you can now use the '--clumpscat' option.
- Estimation of noise-level is now done per-pixel over the whole
label. Until now the average noise level was used.
--objectsfile has been removed. The main input argument is now assumed
@@ -843,7 +1514,7 @@ See the end of the file for license conditions.
do segmentation any more. The new Segment program is in charge of
segmentation. Many of the changes below are due to this new limited
scope of NoiseChisel.
- --kernel: value `none' will disable convolution.
+ --kernel: value 'none' will disable convolution.
- Renamed options:
--convolvedhdu ==> --chdu
--wkhdu ==> --whdu
@@ -851,7 +1522,7 @@ See the end of the file for license conditions.
--checkdetsn ==> --checksn
--detquant ==> --snquant
- By default the output detection map is a binary image (values of 0 or 1).
- - With no output name, the output has a `_detected.fits' suffix.
+ - With no output name, the output has a '_detected.fits' suffix.
Segment:
- [Previously in NoiseChisel]: For finding true clumps, the difference
@@ -867,34 +1538,34 @@ See the end of the file for license conditions.
still acceptable also).
Libraries:
- gal_binary_holes_fill: new name for `gal_binary_fill_holes'.
- gal_dimension_is_different: new name for `gal_data_dsize_is_different'.
+ gal_binary_holes_fill: new name for 'gal_binary_fill_holes'.
+ gal_dimension_is_different: new name for 'gal_data_dsize_is_different'.
gal_fits_img_read: now only reads the data not the WCS, therefore it no
longer needs the last two arguments. A subsequent call to
- `gal_wcs_read' can be used to read the WCS information in the file.
- gal_pointer_increment: new name for `gal_data_ptr_increment'.
- gal_pointer_num_between: new name for `gal_data_ptr_dist'.
- gal_pointer_allocate: replaces `gal_data_malloc_array' and
- `gal_data_calloc_array', through an argument you can ask for the
+ 'gal_wcs_read' can be used to read the WCS information in the file.
+ gal_pointer_increment: new name for 'gal_data_ptr_increment'.
+ gal_pointer_num_between: new name for 'gal_data_ptr_dist'.
+ gal_pointer_allocate: replaces 'gal_data_malloc_array' and
+ 'gal_data_calloc_array', through an argument you can ask for the
allocated memory to be cleared or not.
gal_qsort_TYPE_i: new name for gal_qsort_TYPE_increasing.
gal_qsort_TYPE_d: new name for gal_qsort_TYPE_decreasing.
gal_statistics_is_sorted: can now also update the bit-flags regarding
the sorted nature of the input (to optimize future calls to the
function).
- gal_statistics_quantile_function: returns `inf' or `-inf' if the given
+ gal_statistics_quantile_function: returns 'inf' or '-inf' if the given
value is smaller than the minimum or larger than the maximum of the
input dataset's range. Until now, it would return blank in such
cases.
- gal_statistics_number: the output dataset now has a `size_t' type. Until
- now it was `uint64_t'.
+ gal_statistics_number: the output dataset now has a 'size_t' type. Until
+ now it was 'uint64_t'.
** Bugs fixed
bug #50957: --version output not possible on Mac OS X
bug #52979: Many unused result warnings for asprintf in some compilers.
bug #53122: Configure time CPPFLAGS and LDFLAGS don't pass to BuildProgram.
- bug #53142: Crash when printing values with the `--onlyversion' option.
+ bug #53142: Crash when printing values with the '--onlyversion' option.
bug #53147: NULL value of onlyversion option causing a crash.
bug #53226: Match output directory ignored when making multiple files.
bug #53230: Statistics program bad results on integer columns with limits.
@@ -924,68 +1595,68 @@ See the end of the file for license conditions.
New Program and library: Match is a new program that will match two given
inputs (currently catalogs). Its output is the re-arranged inputs with
the same number of rows/records such that all the rows match. The main
- work is also done with the new low-level `gal_match_catalog' library
+ work is also done with the new low-level 'gal_match_catalog' library
function which can also be used in more generic contexts.
- All programs: a value of `0' to the `--numthreads' option will use the
+ All programs: a value of '0' to the '--numthreads' option will use the
number of threads available to the system at run time.
- Arithmetic: The new operators `filter-median' and `filter-mean' can be
+ Arithmetic: The new operators 'filter-median' and 'filter-mean' can be
used to filter (smooth) the input. The size of the filter can be set as
the other operands to these operators.
- BuildProgram: The new `--la' option allows the identification of a
- different Libtool `.la' file for Libtool linking information.
+ BuildProgram: The new '--la' option allows the identification of a
+ different Libtool '.la' file for Libtool linking information.
- BuildProgram: The new `--deletecompiled' option will delete the compiled
+ BuildProgram: The new '--deletecompiled' option will delete the compiled
program after running it.
CosmicCalculator: all the various cosmological calculations can now be
requested individually in one line with a specific option added for each
- calculation (for example `--age' or `--luminositydist' for the age of the
+ calculation (for example '--age' or '--luminositydist' for the age of the
universe at a given redshift or the luminosity distance). Therefore the
- old `--onlyvolume' and `--onlyabsmagconv' options are now removed. To
+ old '--onlyvolume' and '--onlyabsmagconv' options are now removed. To
effectively use these new features, please review the "Invoking
CosmicCalculator" section of the book.
Fits: when an extension/HDU is identified on the command-line with the
- `--hdu' option and no operation is requested, the full list of header
- keywords in that HDU will be printed (as if only `--printallkeys' was
+ '--hdu' option and no operation is requested, the full list of header
+ keywords in that HDU will be printed (as if only '--printallkeys' was
called).
MakeCatalog: physical nature agnostic WCS column names. Previously the
first WCS axis was always assumed to be RA and the second DEC. So for
example even if you had a spectrum (with X and wavelength as the two WCS
- dimensions), you would have to ask for `--ra' and `--dec'. The new `--w1'
- and `--w2' options are now generic and don't assume any particular type
+ dimensions), you would have to ask for '--ra' and '--dec'. The new '--w1'
+ and '--w2' options are now generic and don't assume any particular type
only their order in the FITS header. MakeCatalog now also uses the CTYPE
and CUNIT keywords to set the names and units of its output columns. The
- `--ra' and `--dec' options are now just internal aliases for `--w1' or
- `--w2' which will be determined based on the input's CTYPE keyword. Also
- the new `--geow1', `--geow2', `--clumpsw1', `--clumpsw2',
- `--clumpsgeow1', `--clumpsgeow2' options replace the old options
- `--geora', `--geodec', `--clumpsra', `--clumpsdec', `--clumpsgeora',
- `--clumpsgeodec'. No alias is currently defined for the latter group.
-
- MakeCatalog: the new `--uprange' option allows you to specify a range for
+ '--ra' and '--dec' options are now just internal aliases for '--w1' or
+ '--w2' which will be determined based on the input's CTYPE keyword. Also
+ the new '--geow1', '--geow2', '--clumpsw1', '--clumpsw2',
+ '--clumpsgeow1', '--clumpsgeow2' options replace the old options
+ '--geora', '--geodec', '--clumpsra', '--clumpsdec', '--clumpsgeora',
+ '--clumpsgeodec'. No alias is currently defined for the latter group.
+
+ MakeCatalog: the new '--uprange' option allows you to specify a range for
the random values around each object. This is useful when the noise
properties of the dataset vary gradually and sampling from the whole
dataset might produce biased results.
- NoiseChisel: with the new `--convolved' and `--convolvedhdu' options,
+ NoiseChisel: with the new '--convolved' and '--convolvedhdu' options,
NoiseChisel will not convolve the input any more and use the given
dataset instead. In many cases, as the inputs get larger, convolution is
the most time consuming step of NoiseChisel. With this option, you can
greatly speed up your tests (to find the best parameters by varying them,
for a given analysis). See the book for more information and examples.
- NoiseChisel: with the new `--widekernel' option it is now possible to use
+ NoiseChisel: with the new '--widekernel' option it is now possible to use
a wider kernel to identify which tiles contain signal. The rest of the
steps (identifying the quantile threshold on the selected tiles and etc)
- are done on the dataset convolved with `--kernel' as they were
+ are done on the dataset convolved with '--kernel' as they were
before. Since it is time consuming, this is an optional feature.
- NoiseChisel: with the new `--qthreshtilequant' option, it is now possible
+ NoiseChisel: with the new '--qthreshtilequant' option, it is now possible
to discard high-valued (outlier) tiles before estimating qthresh over the
whole image. This can be useful in detecting very large diffuse/flat
regions that would otherwise be detected as background (and effectively
@@ -995,42 +1666,42 @@ See the end of the file for license conditions.
signal contiguity, not by blind dilation. The growth process is the same
as the growing of clumps to define objects. Only for true detections, the
growth occurs in the noise. You can configure this growth with the
- `--detgrowquant' and `--detgrowmaxholesize'. With this new feature it is
+ '--detgrowquant' and '--detgrowmaxholesize'. With this new feature it is
now possible to detect signal out to much lower surface brightness limits
and the detections don't look boxy any more.
Cosmology library: A new set of cosmology functions are now included in
- the library (declared in `gnuastro/cosmology.h'). These functions are
+ the library (declared in 'gnuastro/cosmology.h'). These functions are
also used in the CosmicCalculator program.
- `gal_table_read' can now return the number of columns matched with each
+ 'gal_table_read' can now return the number of columns matched with each
input column (for example with regular expressions), a new argument has
been added to allow this feature.
- `gal_fits_key_img_blank': returns the value that must be used in the
+ 'gal_fits_key_img_blank': returns the value that must be used in the
BLANK keyword for the given type as defined by the FITS standard.
- `gal_txt_write' and `gal_fits_tab_write' now accept an extension name as
+ 'gal_txt_write' and 'gal_fits_tab_write' now accept an extension name as
argument to allow a name for the FITS extension they write.
- `gal_box_bound_ellipse_extent' will return the maximum extent of an
+ 'gal_box_bound_ellipse_extent' will return the maximum extent of an
ellipse along each axis from the ellipse center in floating point.
** Removed features
- Installation: The `--enable-bin-op-*' configuration options that were
+ Installation: The '--enable-bin-op-*' configuration options that were
introduced in Gnuastro 0.3 have been removed. By managing the arithmetic
functions in a better manner (a separate source file for each operator),
compilation for all types (when done in parallel) takes about the same
time as it took with the default (only four) types until now.
- MakeCatalog: `--zeropoint' option doesn't have a short option name any
- more. Previously it was `-z' which was confusing because `-x' and `-y'
+ MakeCatalog: '--zeropoint' option doesn't have a short option name any
+ more. Previously it was '-z' which was confusing because '-x' and '-y'
were used to refer to image coordinate positions.
- NoiseChisel: The `--dilate' and `--dilatengb' options have been
+ NoiseChisel: The '--dilate' and '--dilatengb' options have been
removed. Growing of true detections is no longer done through dilation
- but through the `--detgrowquant' and `--detgrowmaxholesize' options (see
+ but through the '--detgrowquant' and '--detgrowmaxholesize' options (see
above).
** Changed features
@@ -1043,32 +1714,32 @@ See the end of the file for license conditions.
now, two separate FITS files would be created. Plain text outputs are the
same as before (two files will be created).
- `gal_binary_fill_holes' now accepts a `connectivity' and `maxsize'
+ 'gal_binary_fill_holes' now accepts a 'connectivity' and 'maxsize'
argument to specify the connectivity of the holes and the maximum size of
acceptable holes to fill.
- `gal_fits_img_read' and `gal_fits_img_read_to_type' now also read the WCS
+ 'gal_fits_img_read' and 'gal_fits_img_read_to_type' now also read the WCS
structure of the extension/HDU in a FITS file and have two extra
- arguments: `hstartwcs' and `hendwcs'. With these options it is possible
+ arguments: 'hstartwcs' and 'hendwcs'. With these options it is possible
to limit the range of header keywords to read the WCS, similar to how
- they are used in `gal_wcs_read'.
+ they are used in 'gal_wcs_read'.
- `gal_txt_write', `gal_table_write_log', `gal_fits_tab_write' and
- `gal_txt_write' don't have the `dontdelete' argument any more. The action
+ 'gal_txt_write', 'gal_table_write_log', 'gal_fits_tab_write' and
+ 'gal_txt_write' don't have the 'dontdelete' argument any more. The action
they take if the file already exists depends on the file: for FITS, a new
extension will be added and for text, they will abort with an error.
- `gal_tile_block_write_const_value' and `gal_tile_full_values_write' now
- accept a new `withblank' option to set all pixels that are blank in the
+ 'gal_tile_block_write_const_value' and 'gal_tile_full_values_write' now
+ accept a new 'withblank' option to set all pixels that are blank in the
tile's block to be blank in the check image.
- `gal_wcs_pixel_area_arcsec2' will return NaN (instead of aborting) when
+ 'gal_wcs_pixel_area_arcsec2' will return NaN (instead of aborting) when
input is unreasonable (not two dimensions or not in units of degrees).
- `gal_wcs_world_to_img' and `gal_wcs_img_to_world': Until now, these two
+ 'gal_wcs_world_to_img' and 'gal_wcs_img_to_world': Until now, these two
WCS conversion functions would explicitly assume RA and Dec and work
based on input arrays (so for example it was also necessary to give the
- number of elements and etc). They now accept `gal_data_t' as input for
+ number of elements and etc). They now accept 'gal_data_t' as input for
the input coordinates, thus their API has been greatly simplified and
their functionality increased.
@@ -1099,113 +1770,113 @@ See the end of the file for license conditions.
** New features
- All programs: `.fit' is now a recognized FITS file suffix.
+ All programs: '.fit' is now a recognized FITS file suffix.
All programs: ASCII text files (tables) created with CRLF line
terminators (for example text files created in MS Windows) are now also
readable as input when necessary.
- Arithmetic: now has a new `--globalhdu' (`-g') option which can be used
+ Arithmetic: now has a new '--globalhdu' ('-g') option which can be used
once for all the input images.
- MakeNoise: with the new `--sigma' (`-s') option, it is now possible to
+ MakeNoise: with the new '--sigma' ('-s') option, it is now possible to
directly request the noise sigma or standard deviation. When this option
- is called, the `--background', `--zeropoint' and other option values will
+ is called, the '--background', '--zeropoint' and other option values will
be ignored.
- MakeProfiles: the new `--kernel' option can make a kernel image without
+ MakeProfiles: the new '--kernel' option can make a kernel image without
the need to define a catalog. With this option, a catalog (or
accompanying background image) must not be given.
- MakeProfiles: the new `--pc', `--cunit' and `--ctype' options can be used
+ MakeProfiles: the new '--pc', '--cunit' and '--ctype' options can be used
to specify the PC matrix, CUNIT and CTYPE world coordinate system
keywords of the output FITS file.
- MakeProfiles: the new `distance' profile will save the radial distance of
+ MakeProfiles: the new 'distance' profile will save the radial distance of
each pixel. This may be used to define your own profiles that are not
currently supported in MakeProfiles.
- MakeProfiles: with the new `--mcolisbrightness' ("mcol-is-brightness")
- option, the `--mcol' values of the catalog will be interpretted as total
+ MakeProfiles: with the new '--mcolisbrightness' ("mcol-is-brightness")
+ option, the '--mcol' values of the catalog will be interpretted as total
brightness (sum of pixel values), not magnitude.
- NoiseChisel: with the new `--dilatengb' option, it is now possible to
+ NoiseChisel: with the new '--dilatengb' option, it is now possible to
identify the connectivity of the final dilation.
Library: Functions that read data from an ASCII text file
- (`gal_txt_table_info', `gal_txt_table_read', `gal_txt_image_read') now
+ ('gal_txt_table_info', 'gal_txt_table_read', 'gal_txt_image_read') now
also operate on files with CRLF line terminators.
** Removed features
** Changed features
- Crop: The new `--center' option is now used to define the center of a
- single crop. Hence the old `--ra', `--dec', `--xc', `--yc' have been
+ Crop: The new '--center' option is now used to define the center of a
+ single crop. Hence the old '--ra', '--dec', '--xc', '--yc' have been
removed. This new option can take multiple values (one value for each
dimension). Fractions are also acceptable.
- Crop: The new `--width' option is now used to define the width of a
- single crop. Hence the old `--iwidth', `--wwidth' were removed. The units
- to interpret the value to the option are specified by the `--mode'
- option. With the new `--width' option it is also possible to define a
+ Crop: The new '--width' option is now used to define the width of a
+ single crop. Hence the old '--iwidth', '--wwidth' were removed. The units
+ to interpret the value to the option are specified by the '--mode'
+ option. With the new '--width' option it is also possible to define a
non-square crop (different widths along each dimension). In WCS mode, its
units are no longer arcseconds but are the same units of the WCS (degrees
- for angles). `--width' can also accept fractions. So to set a width of 5
- arcseconds, you can give it a value of `5/3600' for the angular
+ for angles). '--width' can also accept fractions. So to set a width of 5
+ arcseconds, you can give it a value of '5/3600' for the angular
dimensions.
- Crop: The new `--coordcol' option is now used to determine the catalog
- columns that define coordinates. Hence the old `--racol', `--deccol',
- `--xcol', and `--ycol' have been removed. This new option can be called
+ Crop: The new '--coordcol' option is now used to determine the catalog
+ columns that define coordinates. Hence the old '--racol', '--deccol',
+ '--xcol', and '--ycol' have been removed. This new option can be called
multiple times and the order of its calling will be used for the column
containing the center in the respective dimension (in FITS format).
- MakeNoise: the old `--stdadd' (`-s') option has been renamed to
- `--instrumental' (`-i') to be more clear.
+ MakeNoise: the old '--stdadd' ('-s') option has been renamed to
+ '--instrumental' ('-i') to be more clear.
- MakeProfiles: The new `--naxis' and `--shift' options can take multiple
+ MakeProfiles: The new '--naxis' and '--shift' options can take multiple
values for each dimension (separated by a comma). This replaces the old
- `--naxis1', `--naxis2' and `--xshift' and `--yshift' options.
+ '--naxis1', '--naxis2' and '--xshift' and '--yshift' options.
- MakeProfiles: The new `--ccol' option can take the center coordinate
- columns of the catalog (in multiple calls) and the new `--mode' option is
+ MakeProfiles: The new '--ccol' option can take the center coordinate
+ columns of the catalog (in multiple calls) and the new '--mode' option is
used to identify what standard to interpret them in (image or
- WCS). Together, these replace the old `--xcol', `--ycol', `--racol' and
- `--deccol'.
+ WCS). Together, these replace the old '--xcol', '--ycol', '--racol' and
+ '--deccol'.
- MakeProfiles: The new `--crpix', `--crval' and `--cdelt' options now
+ MakeProfiles: The new '--crpix', '--crval' and '--cdelt' options now
accept multiple values separated by a comma. So they replace the old
- `--crpix1', `--crpix2', `--crval1', `--crval2' and `--resolution'
+ '--crpix1', '--crpix2', '--crval1', '--crval2' and '--resolution'
options.
- `gal_data_free_contents': when the input `gal_data_t' is a tile, its
- `array' element will not be freed. This enables safe usage of this
- function (and thus `gal_data_free') on tiles without worrying about the
+ 'gal_data_free_contents': when the input 'gal_data_t' is a tile, its
+ 'array' element will not be freed. This enables safe usage of this
+ function (and thus 'gal_data_free') on tiles without worrying about the
memory block associated with the tile.
- `gal_box_bound_ellipse' is the new name for the old
- `gal_box_ellipse_in_box' (to be more clear and avoid repetition of the
- term `box'). The input position angle is now also in degrees, not
+ 'gal_box_bound_ellipse' is the new name for the old
+ 'gal_box_ellipse_in_box' (to be more clear and avoid repetition of the
+ term 'box'). The input position angle is now also in degrees, not
radians.
- `gal_box_overlap' now works on data of any dimensionality and thus also
+ 'gal_box_overlap' now works on data of any dimensionality and thus also
needs the number of dimensions (elements in each input array).
- `gal_box_border_from_center' now accepts an array of coordinates as one
+ 'gal_box_border_from_center' now accepts an array of coordinates as one
argument and the number of dimensions as another. This allows it to work
on any dimensionality.
- `gal_fits_img_info' now also returns the name and units of the dataset
+ 'gal_fits_img_info' now also returns the name and units of the dataset
(if they aren't NULL). So it takes two extra arguments.
- `gal_wcs_pixel_scale' now replaces the old `gal_wcs_pixel_scale_deg',
+ 'gal_wcs_pixel_scale' now replaces the old 'gal_wcs_pixel_scale_deg',
since it doesn't only apply to degrees. The pixel scale units are defined
by the units of the WCS.
- `GAL_TILE_PARSE_OPERATE' (only when `OTHER' is given) can now parse and
+ 'GAL_TILE_PARSE_OPERATE' (only when 'OTHER' is given) can now parse and
operate on different datasets independent of the size of allocated block
- of memory (the tile sizes of `IN' and `OTHER' have to be identical, but
+ of memory (the tile sizes of 'IN' and 'OTHER' have to be identical, but
not their allocated blocks of memory). Until now, it was necessary for
the two blocks to have the same size and this is no longer the case.
@@ -1239,7 +1910,7 @@ See the end of the file for license conditions.
* Noteworthy changes in release 0.3 (library 1.0.0) (2017-06-01) [stable]
This is a full re-write of Gnuastro. Most importantly, Gnuastro now has a
- new generic data container (`gal_data_t'). This new container can now
+ new generic data container ('gal_data_t'). This new container can now
deal natively with all standard numeric data types, work in RAM or
HDD/SSD, keep data in any dimensions and has enabled many other very
useful features. Some of the most prominent of the new features are
@@ -1249,9 +1920,9 @@ See the end of the file for license conditions.
As discussed below, some program names have changed, if you have a
previous version of Gnuastro installed from source, it is recommended to
- uninstall it first (with `make uninstall' using the corresponding
+ uninstall it first (with 'make uninstall' using the corresponding
tarball), then install this new version. Building Gnuastro can be slow,
- so please build in parallel with Make's `-j8' option (to build on 8
+ so please build in parallel with Make's '-j8' option (to build on 8
threads).
** New programs or library features
@@ -1263,10 +1934,10 @@ See the end of the file for license conditions.
functions are shown below, also see the "Library demos" section of the
book for some complete working example:
- -- `gal_table_read' and `gal_table_write' will read and write data to
+ -- 'gal_table_read' and 'gal_table_write' will read and write data to
plain text, FITS ASCII and FITS Binary formats.
- -- `gal_fits_img_read' and `gal_fits_img_write' can read a FITS image
+ -- 'gal_fits_img_read' and 'gal_fits_img_write' can read a FITS image
to memory or write a FITS image from memory.
Gnuastro now defines a simple comment line format to keep basic
@@ -1285,24 +1956,24 @@ See the end of the file for license conditions.
in a FITS file along with basic information. It can copy a whole HDU to
another file, or delete a HDU from a FITS file. To get the previous
behavior of listing all the keywords in a FITS HDU, you can run it with
- the `-p' option.
+ the '-p' option.
All programs now write data into the second HDU of a FITS file to allow a
clean first HDU. Note that following CFITSIO, HDU counting still starts
from zero, so FITS images and tables written by Gnuastro in a new file
- can always be accessed with the `--hdu=1' option (which is now the
+ can always be accessed with the '--hdu=1' option (which is now the
default).
If any program is run within a Git version controlled directory, a
- `COMMIT' header keyword will be added to the created FITS files, see the
+ 'COMMIT' header keyword will be added to the created FITS files, see the
"Output headers" section of the book for a discussion on the usefulness
of this new feature.
BuildProgram: a new program to easily compile, link and run a C program
you have written with Gnuastro's libraries without having to worry about
which libraries (Gnuastro dependencies) your program needs. Debugging
- (`-g'), optimizations (`-O'), warnings (`-W'), include search path
- (`-I'), link search path (`-L'), and linked libraries (`-l') compiler
+ ('-g'), optimizations ('-O'), warnings ('-W'), include search path
+ ('-I'), link search path ('-L'), and linked libraries ('-l') compiler
options are also supported. BuildProgram will greatly facilitate the easy
usage of Gnuastro's libraries.
@@ -1322,7 +1993,7 @@ See the end of the file for license conditions.
All Gnuastro programs that read and write tables can now do so in plain
text table format or in FITS ASCII or FITS Binary tables. Depending on
- the filename or with the new `--tableformat' common option to all
+ the filename or with the new '--tableformat' common option to all
programs.
The option management system in all Gnuastro programs has been completely
@@ -1330,18 +2001,18 @@ See the end of the file for license conditions.
listed below. For developers, you will notice that there is no more usage
of macros and adding new options has become much more easier.
- -- All programs will now also look for a `gnuastro.conf' configuration
+ -- All programs will now also look for a 'gnuastro.conf' configuration
file to keep common options for all programs in every directory.
- -- The `--lastconfig' option can be used on the command-line or in any
+ -- The '--lastconfig' option can be used on the command-line or in any
configuration file to stop parsing any further configuration files.
- -- The `--config' option can now be used to identify any arbitrary
+ -- The '--config' option can now be used to identify any arbitrary
file to be parsed as a configuration file. Any file that is given
to this option is parsed immediately.
- -- The `--printparams' option now also prints the short documentation
- of each option (same description in `--help') after its value.
+ -- The '--printparams' option now also prints the short documentation
+ of each option (same description in '--help') after its value.
It is now possible to choose columns in tables based on column names as
well as column numbers. It is also possible to search for columns based
@@ -1349,22 +2020,22 @@ See the end of the file for license conditions.
counting now starts from 1 (one), not 0 (as before). See the new
"Selecting table columns" section for more on these new features.
- Where relevant, all programs now accept a `--type' option that you can
+ Where relevant, all programs now accept a '--type' option that you can
use to specify the numerical datatype of the output.
- With the new common option `--minmapsize', you can specify a minimum size
+ With the new common option '--minmapsize', you can specify a minimum size
of an array (in bytes) to store data in SSD/HDD and not in RAM. This can
be instrumental when you are dealing with large datasets, or even smaller
ones, but when your RAM is getting full.
Making a log file is now optional and users have to explicitly ask for it
- with the `--log' option.
+ with the '--log' option.
Slower building of Gnuastro: Binary operators (e.g., plus or multiply)
are now done in the native type of the input dataset. Doing so for all
the different combinations of types, greatly slows down the initial
- compilation of Gnuastro (after running `make'). So for every type there
- is now a `--enable-bin-op-*' configure time option. When the dataset's
+ compilation of Gnuastro (after running 'make'). So for every type there
+ is now a '--enable-bin-op-*' configure time option. When the dataset's
type isn't compiled (only for the binary operators), it will be converted
to a compiled type and then converted back in the end.
@@ -1379,9 +2050,9 @@ See the end of the file for license conditions.
and the modulo operator).
ConvertType: can also print the input dataset to the command-line
- (`stdout'). To use this feature set the output filename to `stdout'.
+ ('stdout'). To use this feature set the output filename to 'stdout'.
- Convolve now has the `--minsharpspec' option to specify the minimum
+ Convolve now has the '--minsharpspec' option to specify the minimum
spectrum value to use in deconvolution (matching PSFs).
Crop: when in WCS mode it can still only work on aligned images. However,
@@ -1400,19 +2071,19 @@ See the end of the file for license conditions.
pixel projected size, fully derived in the book), it now also reports the
surface brightness in magnitudes/arcsec^2 also.
- MakeProfiles: Profile codes now start from `1' (until now they started
- from `0').
+ MakeProfiles: Profile codes now start from '1' (until now they started
+ from '0').
MakeProfiles: now accepts the radial function of profiles as
human-readable strings instead of a code for each profile (which was very
cryptic, although codes are also still acceptable). For example in the
- profile column you can now write `sersic' instead of the code `1'.
+ profile column you can now write 'sersic' instead of the code '1'.
- NoiseChisel: the new `--cleandilated' option will remove dilated objects
+ NoiseChisel: the new '--cleandilated' option will remove dilated objects
that have a low S/N (it is mainly useful on very clean or mock images).
For non-clean noise, it will result in a decrease of completeness. With
this new option, NoiseChisel will also print detection S/N values when
- run with the `--checkdetsn' option.
+ run with the '--checkdetsn' option.
Statistics: now reads table columns as well as images and does basic
operations on them. It can also only work on a certain range of the data
@@ -1426,17 +2097,17 @@ See the end of the file for license conditions.
mode's quantile similar to what NoiseChisel does to find its initial
threshold.
- Statistics: has several new single valued calculations: `--quantile',
- `--quantfunc' (quantile function), `--mode', `--modequant', `--modesym',
- and `--modesymvalue'.
+ Statistics: has several new single valued calculations: '--quantile',
+ '--quantfunc' (quantile function), '--mode', '--modequant', '--modesym',
+ and '--modesymvalue'.
- Warp: align the image with the celestial coordinates using the `--align'
+ Warp: align the image with the celestial coordinates using the '--align'
option.
Warp: standard modular warpings can now be requested without an input
- matrix, using the following options: `--shear', `--flip', `--project',
- `--rotate', `--scale', `--translate'. Any number of these transformations
- (along with the `--align' option) can be called on the command-line and
+ matrix, using the following options: '--shear', '--flip', '--project',
+ '--rotate', '--scale', '--translate'. Any number of these transformations
+ (along with the '--align' option) can be called on the command-line and
they will be applied in the same order to create one warping matrix. By
default the WCS will also be corrected.
@@ -1444,49 +2115,49 @@ See the end of the file for license conditions.
Mask image options have been removed from all programs. Instead, all
programs can work directly on data with blank values. So when some pixels
- must be masked, the Arithmetic program's `where' operator can be used to
+ must be masked, the Arithmetic program's 'where' operator can be used to
select special pixels and set them to blank. In particular bit-wise
operations are now available in Arithmetic to use bit-mask
images. Managing all these different choices in every program would only
confuse the user (with too many options).
- Arithmetic: the `x' letter is now used to represent the multiplication
- operator. Previously it was `*' which needed quotation and was thus very
+ Arithmetic: the 'x' letter is now used to represent the multiplication
+ operator. Previously it was '*' which needed quotation and was thus very
inconvenient.
- Convolve: the old `--frequency' and `--spatial' options have been removed
- and are replaced by `--domain' which accepts values of `frequency' and
- `spatial'.
+ Convolve: the old '--frequency' and '--spatial' options have been removed
+ and are replaced by '--domain' which accepts values of 'frequency' and
+ 'spatial'.
- Convolve: the old `--viewfreqsteps' was changed to `--checkfreqsteps' to
+ Convolve: the old '--viewfreqsteps' was changed to '--checkfreqsteps' to
fit with the general style of such check images in all Gnuastro's
programs.
- Crop: `--section' syntax is now inclusive in both bounds.
+ Crop: '--section' syntax is now inclusive in both bounds.
Crop: only checks if the center of a crop is filled when the crop was
- defined by its center (for example with `--ra' and `--dec'). The verbose
+ defined by its center (for example with '--ra' and '--dec'). The verbose
outputs of Crop are also not cryptic 0s or 1s. The are human readable
text.
- Crop: doesn't have separate `--imgmode' and `--wcsmode' options any
- more. There is now a single `--mode' option which accepts values of `img'
- or `wcs'.
+ Crop: doesn't have separate '--imgmode' and '--wcsmode' options any
+ more. There is now a single '--mode' option which accepts values of 'img'
+ or 'wcs'.
- MakeProfiles: the old `--inputascanvas' is now called `--clearcanvas'.
+ MakeProfiles: the old '--inputascanvas' is now called '--clearcanvas'.
MakeProfiles: until now, it would abort with an error when the input
columns had blank values. But for masking, it might happen that you set a
blank magnitude. So this check has now been removed when reading the
magnitude column.
- NoiseChisel: default value of the `--minskyfrac' option (new name for the
- old `--minbfrac') is now 0.7 as opposed to 0.5. This will allow much
+ NoiseChisel: default value of the '--minskyfrac' option (new name for the
+ old '--minbfrac') is now 0.7 as opposed to 0.5. This will allow much
better estimation of noise properties (by default). It may be slightly
too high for a crowded field, but the users can change it on the
command-line (or in a configuration file) for such datasets.
- NoiseChisel: when it is run with any of the `--check' options, it will
+ NoiseChisel: when it is run with any of the '--check' options, it will
abort after all the check images have been created. This is very useful
for checking your parameters until each step and not be distracted (or
have to wait) for later steps to finish.
@@ -1495,35 +2166,35 @@ See the end of the file for license conditions.
calculate sigma-clipped results by default (with no options). It will
just print some basic information.
- Table: Previously, if a column was requested, the `-i' option would be
+ Table: Previously, if a column was requested, the '-i' option would be
ignored. But it often happens that the users forget a column name after
already typing several of their desired columns. So the opposite behavior
is preferred. Because when more than a couple of columns are needed, you
will probably forget the column identifiers of the last few and having to
- retype everything is very frustrating. Something like how `--help' takes
+ retype everything is very frustrating. Something like how '--help' takes
precedence over all other options.
Table: to select column(s) by regular expression searching, the name now
- has to be put in `/ /' (similar to AWK). If a value isn't in `/ /', the
+ has to be put in '/ /' (similar to AWK). If a value isn't in '/ /', the
programs will only select a column with the exact match.
Warp: when a 2 by 2 matrix is given, the FITS pixel positions (which
define the center of a pixel as an integer) are automatically implemented
internally, see "Invoking Warp" in the manual for more.
- Warp: the old `--nofitscorrect' option has been changed to
- `--centeroncorner' to be more clear. The new option is now more general
+ Warp: the old '--nofitscorrect' option has been changed to
+ '--centeroncorner' to be more clear. The new option is now more general
than before and also works on warping with a matrix, not just on modular
warpings.
- Warp: the old `--nowcscorrection' option has been given a more clear name
- of `--keepwcs'. With this option, Warp will not apply the warp the
+ Warp: the old '--nowcscorrection' option has been given a more clear name
+ of '--keepwcs'. With this option, Warp will not apply the warp the
input's WCS structure.
- Warp: the old `--maxblankfrac' option has been changed to
- `--coveredfrac'. Until now, Warp would only look for the fraction of
+ Warp: the old '--maxblankfrac' option has been changed to
+ '--coveredfrac'. Until now, Warp would only look for the fraction of
input blank/NaN pixel area over the output pixel. But this would be
- useless on the edges of the image. So the new `--coveredfrac' option
+ useless on the edges of the image. So the new '--coveredfrac' option
takes the acceptable fraction of output pixel area that must be covered
by input pixels in order to give that output pixel a value. You can use
this to set edge pixels that are not fully covered in the new grid to
@@ -1531,7 +2202,7 @@ See the end of the file for license conditions.
** Bugs fixed
- Using `%zu' to print `size_t' variables for clean build on 32-bit
+ Using '%zu' to print 'size_t' variables for clean build on 32-bit
systems.
Crash in Table for some operating systems due to memory is now fixed (bug
@@ -1584,12 +2255,12 @@ See the end of the file for license conditions.
Shared libraries and headers are now installed. The libraries can be used
in C and C++ programs. This release includes the following headers:
- `gnuastro.h', `array.h', `box.h', `fits.h', `linkedlist.h', `mesh.h',
- `polygon.h', `qsort.h', `spatialconvolve.h', `statistics.h', `threads.h',
- `wcs.h', `txtarray.h' (task #13765).
+ 'gnuastro.h', 'array.h', 'box.h', 'fits.h', 'linkedlist.h', 'mesh.h',
+ 'polygon.h', 'qsort.h', 'spatialconvolve.h', 'statistics.h', 'threads.h',
+ 'wcs.h', 'txtarray.h' (task #13765).
Gnuastro now comes with a script in its top source directory
- (`tmpfs-config-make') to configure and build it in the tmpfs (on the
+ ('tmpfs-config-make') to configure and build it in the tmpfs (on the
RAM), for those systems that have it. See the new "Configure and build in
RAM" section in the book for more (task #14100).
@@ -1598,27 +2269,27 @@ See the end of the file for license conditions.
MakeProfiles also accepts WCS positions (task #13566).
Flat profiles in MakeProfiles can be given a profile specific value. The
- new `--mforflatpix' option MakeProfile will use the value in the
+ new '--mforflatpix' option MakeProfile will use the value in the
magnitude column as a fixed value for each pixel. This can be very useful
in defining a mask, or creating segmentation maps or labeled images (task
#14115).
MakeProfiles can now use input image as canvas. Instead of specifying the
- WSC and image size parameters manually. With the new `--inputascanvas'
+ WSC and image size parameters manually. With the new '--inputascanvas'
option, MakeProfiles will get this information (along with blank pixels)
from an already existing image (task #14116).
Type of output in MakeProfiles and Arithmetic can be specified with the
- `--type' option.
+ '--type' option.
- Magnitude error column in MakeCatalog with the `--magnitudeerr' option.
+ Magnitude error column in MakeCatalog with the '--magnitudeerr' option.
Arithmetic now has new conditional (task #13870) and logical operators
(task #14153) along with an operator for actions only when conditions are
- true: `where'. The new `isblank' operator will also enable you to select
+ true: 'where'. The new 'isblank' operator will also enable you to select
blank, or masked, pixels (task #14146).
- The `--noerodequant' in NoiseChisel enables it to detect small and
+ The '--noerodequant' in NoiseChisel enables it to detect small and
sharper profiles by disabling erosion on pixels above a certain quantile
(task #14139).
@@ -1631,10 +2302,10 @@ See the end of the file for license conditions.
** Changes in behavior
- The two MakeProfiles options `--setconsttonan', `--setconsttomin' have
- been removed (see `--mforflatpix' above for their alternative).
+ The two MakeProfiles options '--setconsttonan', '--setconsttomin' have
+ been removed (see '--mforflatpix' above for their alternative).
- MakeCatalog makes clump catalog only when asked (when the `WCLUMPS'
+ MakeCatalog makes clump catalog only when asked (when the 'WCLUMPS'
header exists in the objects HDU). This can be very useful in cases like
aperture photometry, when the object labels are not generated by
NoiseChisel and so a clump image doesn't exist (task #14122).
@@ -1642,7 +2313,7 @@ See the end of the file for license conditions.
Default cosmological parameters in CosmicCalculator set to Plank 2015
results: A&A (2016), 594, A13 (arXiv 1502.01589).
- The `--envseed' option (to read random number generator type and seed
+ The '--envseed' option (to read random number generator type and seed
from the environment) to MakeProfiles and MakeNoise can also be given in
the configuration files.
@@ -1657,24 +2328,24 @@ See the end of the file for license conditions.
MakeCatalog's problem in checking the sizes of all input images is now
fixed.
- NoiseChisel's problem with reading the `--kernel' option is now
+ NoiseChisel's problem with reading the '--kernel' option is now
corrected (bug #46750).
lib/mesh.c's problem in correctly calculating the mesh sizes was
corrected (bug #47611).
- `make check' will not look into system utility configuration files. In
+ 'make check' will not look into system utility configuration files. In
the previous release, if Gnuastro was already installed, the
configuration files already present on the system would also be read. Now
only configuration files in the tested package are used (bug #47833).
Ghostscript's version is now checked at configure time after its
- existence. ConvertType uses the `-dPDFFitPage' option to Ghostscript
+ existence. ConvertType uses the '-dPDFFitPage' option to Ghostscript
which was introduced in version 9.10, so older versions would pass
- configure but at `make check' time, the PDF test would fail. Now this
+ configure but at 'make check' time, the PDF test would fail. Now this
test is skipped (bug #47868).
- Most tests would fail when `make check -jN' was run (to do the checks on
+ Most tests would fail when 'make check -jN' was run (to do the checks on
N threads). A dependency structure has now been defined to fix this
problem and greatly speed up the testing process (bug #47957).
@@ -1693,32 +2364,32 @@ See the end of the file for license conditions.
** New features
- All the utilities that would produce a log file now have a `--nolog'
+ All the utilities that would produce a log file now have a '--nolog'
option to avoid printing a log file.
- The tiled image compression convention (.fits.fz, created with `fpack')
+ The tiled image compression convention (.fits.fz, created with 'fpack')
files can now be used as input in the utilities.
ImageCrop can now also crop a polygon from the input image. The polygon
vertices can be given in the world or image coordinates. The simple
- `--polygon' option will keep the insides of the polygon while the
- `--outpolygon' will keep the outside of the polygon.
+ '--polygon' option will keep the insides of the polygon while the
+ '--outpolygon' will keep the outside of the polygon.
ImageCrop and ImageWarp can now read the WCS information of a FITS header
- from a specific region with the `--hstartwcs' and `--hendwcs'. In some
+ from a specific region with the '--hstartwcs' and '--hendwcs'. In some
older FITS images, when the WCS distortions were not as standardized as
now, there were cases which would confuse WCSLIB.
NoiseChisel can now save the grown clumps image instead of the original
- clumps image in the output with the `--grownclumps' option.
+ clumps image in the output with the '--grownclumps' option.
- Convolve can now do deconvolution with the `--makekernel' option.
+ Convolve can now do deconvolution with the '--makekernel' option.
- MakeProfiles now has a `--setconsttonan' option which will fill the
+ MakeProfiles now has a '--setconsttonan' option which will fill the
constant profiles with a NaN (blank) value, not a number, allowing the
creations of elliptical masked regions for example.
- Header can now import a keyword directly from a string with the `--asis'
+ Header can now import a keyword directly from a string with the '--asis'
option.
MakeCatalog can now output the geometric (average position independent of
@@ -1728,11 +2399,11 @@ See the end of the file for license conditions.
example semi-major axis, semi-minor axis, and position angle). This can
also be done both in standard flux weighted and geometric methods too.
- MakeCatalog now has a `--threshold' function to only use pixels above a
+ MakeCatalog now has a '--threshold' function to only use pixels above a
given threshold in each object or clump. This is useful to avoid diffuse
regions in calculations.
- MakeCatalog now has a `--noriverbrightness' option. With this option it
+ MakeCatalog now has a '--noriverbrightness' option. With this option it
is possible to calculate the clump flux without subtracting the river
pixels on its circumference.
@@ -1740,7 +2411,7 @@ See the end of the file for license conditions.
determined at run-time for each program. Therefore it is now easily
possible to built Gnuastro on one system to use on another (commonly done
in the GNU/Linux package managers). Therefore ./configure no longer has a
- `--with-numthreads' option.
+ '--with-numthreads' option.
Every commit in Gnuastro's history (after implementing this feature) can
now be given a unique version number. Since the version number is printed
@@ -1751,14 +2422,14 @@ See the end of the file for license conditions.
controlled history. Also all the authors that have contributed to
Gnuastro are included in the second (copyright) page of the PDF book.
- All the bootstrapped directories are now moved with a new `bootstrapped'
+ All the bootstrapped directories are now moved with a new 'bootstrapped'
directory in the top source directory. This significantly cleans up this
directory, allowing users to more easily find the hand-written Gnuastro
source files they like.
- A `bug-gnuastro' Info page was created so users can easily go to that
+ A 'bug-gnuastro' Info page was created so users can easily go to that
page for information on how to submit bug reports. It is accessible on
- the command line with the command `info bug-gnuastro'.
+ the command line with the command 'info bug-gnuastro'.
** Changes in behavior
@@ -1776,8 +2447,8 @@ See the end of the file for license conditions.
NoiseChisel no longer outputs a sky subtracted image. This job can now be
done with the new Arithmetic utility.
- NoiseChisel's `--segsnhistnbins' option was renamed to
- `--clumpsnhistnbins'.
+ NoiseChisel's '--segsnhistnbins' option was renamed to
+ '--clumpsnhistnbins'.
** Improvements
@@ -1790,8 +2461,8 @@ See the end of the file for license conditions.
were commonly not enough points in large mesh sizes and this would add
scatter. With ImageCrop's polygon capabilities, it is now easily possible
to cut out the region that has uniform noise properties (depth and
- correlated noise). Therefore the old `--checkdetectionsn' and
- `checkclumpsn' options are no longer present.
+ correlated noise). Therefore the old '--checkdetectionsn' and
+ 'checkclumpsn' options are no longer present.
When building from the version controlled source, the whole bootstrapping
process is done with one script. In the previous version, all the
@@ -1799,7 +2470,7 @@ See the end of the file for license conditions.
old manual).
All the build steps now report what was done and suggest the next
- step. This feature can be disabled with the `--disable-guide-message' at
+ step. This feature can be disabled with the '--disable-guide-message' at
configure time.
@@ -1807,7 +2478,7 @@ See the end of the file for license conditions.
* Copyright notice
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later
diff --git a/README b/README
index de215bf..03b6b93 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
GNU Astronomy Utilities
=======================
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
See the end of the file for license conditions.
GNU Astronomy Utilities (Gnuastro) is an official GNU package of programs
@@ -85,6 +85,10 @@ categories/chapters.
in noise (galaxies in the sky), using thresholds that are below the Sky
value (see arXiv:1505.01664).
+ - Query (astquery): High-level interface to query pre-defined remote, or
+ external, databases and directly download the required sub-tables on the
+ command-line.
+
- Segment (astsegment): Segment a detection based on the structure of
signal within it.
@@ -102,9 +106,13 @@ categories/chapters.
The programs listed above are designed to be highly modular and
generic. For higher-level operations (combining multiple programs, or
running a program in a special way), Gnuastro also installs Bash scripts
-(all prefixed with `astscript-'). They can be run like a program and behave
+(all prefixed with 'astscript-'). They can be run like a program and behave
very similarly (with minor differences, as explained in the book).
+ - astscript-make-ds9-reg: Given a table (either as a file or from
+ standard input), create an SAO DS9 region file from the requested
+ positional columns (WCS or image coordinates).
+
- astscript-sort-by-night: Given a list of FITS files, and a HDU and
keyword name for a date, this script separates the files in the same
night (possibly over two calendar days).
@@ -150,7 +158,7 @@ The optional dependencies are:
See the "Dependencies" section of the book for their detailed installation
guides and optional dependencies to enable extra features. Prior to
-installation, you can find it in the `doc/gnuastro.texi' file (source of
+installation, you can find it in the 'doc/gnuastro.texi' file (source of
the book), or on the web:
https://www.gnu.org/software/gnuastro/manual/html_node/Dependencies.html
@@ -171,7 +179,7 @@ the standard GNU Build system as shown below. After the
'./configure'
command, Gnuastro will print messages upon the successful completion of
each step, giving further information and suggestions for the next steps.
- tar xf gnuastro-latest.tar.lz # Also works for `tar.gz' files
+ tar xf gnuastro-latest.tar.lz # Also works for 'tar.gz' files
cd gnuastro-X.X
./configure
make
@@ -194,7 +202,7 @@ To access the appropriate section of the Gnuastro
book/documentation from
your command-line (in the middle of your work, without distracting your
self by having to move your hand off the keyboard), please run any of the
following two commands. Note that you can leave the Info environment by
-pressing the key `q'.
+pressing the key 'q'.
info ProgramName # For example 'info NoiseChisel'
info astprogname # For example 'info astnoisechisel'
@@ -223,7 +231,7 @@ Reporting bugs
The most effective way to report bugs is explained in the "Report a bug"
section of the documentation, after installation, you can read it by
-running (leave the Info environment by pressing the `q' key afterwards):
+running (leave the Info environment by pressing the 'q' key afterwards):
info bug-gnuastro
@@ -249,9 +257,9 @@ bug for a shorter and more relevant list to look into.
Copyright information
---------------------
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later
version published by the Free Software Foundation; with no Invariant
-Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
\ No newline at end of file
+Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
diff --git a/README-hacking b/README-hacking
index 97648a5..322325f 100644
--- a/README-hacking
+++ b/README-hacking
@@ -1,7 +1,7 @@
Hacking into GNU Astronomy Utilities
====================================
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
See the end of the file for license conditions.
This file is intended for those who are building and installing the version
@@ -50,7 +50,7 @@ already present in your operating system's package management
system.
the bootstrap script automatically. However, if you don't already have
them, we recommed to clone them separately as discussed below. They
should be in the same directory (let's call it 'DEVDIR', can be any
- directory). These packages are regularly updated, so run `git pull'
+ directory). These packages are regularly updated, so run 'git pull'
within the cloned directories to keep them up to date before
bootstrapping. See the "Bootstrapping dependencies" and "Bootstrapping"
sections of the book for more information.
@@ -114,9 +114,9 @@ be sure to keep this file where ever you want to run
'bootstrap'.
Copyright information
---------------------
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later
version published by the Free Software Foundation; with no Invariant
-Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
\ No newline at end of file
+Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
diff --git a/THANKS b/THANKS
index 0de4197..6d36246 100644
--- a/THANKS
+++ b/THANKS
@@ -1,14 +1,14 @@
GNU Astronomy Utilities Acknowledgments
=======================================
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
See the end of the file for license conditions.
The following people and institutions who contributed to Gnuastro
indirectly (not by actually submitting code) are listed here. For the list
of Gnuastro code/documentation authors (people who have contributed actual
code/text as commits in the version controlled history of Gnuastro), please
-see the `AUTHORS' file in the same directory.
+see the 'AUTHORS' file in the same directory.
People
@@ -20,6 +20,7 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Valentina Abril-melgarejo valentina.abril@lam.fr
Marjan Akbari mrjakbari@gmail.com
+ Carlos Allende Prieto callende@iac.es
Hamed Altafi hamed.altafi2@gmail.com
Roland Bacon roland.bacon@univ-lyon1.fr
Roberto Baena Gallé rbaena@iac.es
@@ -27,9 +28,11 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Karl Berry karl@gnu.org
Leindert Boogaard boogaard@strw.leidenuniv.nl
Nicolas Bouché nicolas.bouche@irap.omp.eu
+ Stefan Brüns stefan.bruens@rwth-aachen.de
Fernando Buitrago fbuitrago@oal.ul.pt
Adrian Bunk bunk@debian.org
Rosa Calvi rcalvi@iac.es
+ Mark Calabretta mcalabre@atnf.csiro.au
Nushkia Chamba chamba@iac.es
Benjamin Clement benjamin.clement@univ-lyon1.fr
Nima Dehdilani nimadehdilani@gmail.com
@@ -37,7 +40,9 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Alexey Dokuchaev danfe@freebsd.org
Pierre-Alain Duc pierre-alain.duc@astro.unistra.fr
Elham Eftekhari elhamea@iac.es
+ Paul Eggert eggert@cs.ucla.edu
Gaspar Galaz ggalaz@astro.puc.cl
+ Andrés GarcÃa-Serra Romero alu0101451923@ull.edu.es
Thérèse Godefroy godef.th@free.fr
Madusha Gunawardhana gunawardhana@strw.leidenuniv.nl
Bruno Haible bruno@clisp.org
@@ -52,22 +57,36 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Mohammad-Reza Khellat moha.khe@gmail.com
Johan Knapen jhk@iac.es
Geoffry Krouchi geoffrey.krouchi@etu.univ-lyon1.fr
+ Martin Kuemmel mkuemmel@usm.lmu.de
Floriane Leclercq floriane.leclercq@univ-lyon1.fr
Alan Lefor alefor@astr.tohoku.ac.jp
+ Javier Licandro jlicandr@iac.es
Sebastián Luna Valero sluna@iaa.es
+ Alberto Madrigal brt.madrigal@gmail.com
Guillaume Mahler guillaume.mahler@univ-lyon1.fr
+ Alireza Molaeinezhad amolaei@gmail.com
+ Javier Moldon jmoldon@iaa.es
Juan Molina Tobar juan.a.molina.t@gmail.com
Francesco Montanari francesco.montanari@openmailbox.org
+ Raphael Morales rmorales@iaa.es
+ Carlos Morales Socorro cmorsoc@gmail.com
+ Sylvain Mottet mottet@iap.fr
Dmitrii Oparin doparin2@gmail.com
Bertrand Pain bertrand.pain@inserm.fr
William Pence william.pence@nasa.gov
Mamta Pommier mamta.pommier@univ-lyon1.fr
+ Marcel Popescu mpopescu@iac.es
Bob Proulx bob@proulx.com
+ Joseph Putko josephputko@gmail.com
+ Samane Raji samaneraji@gmail.com
+ Francois Ochsenbein francois.ochsenbein@gmail.com
Teymoor Saifollahi teymur.saif@gmail.com
+ Joanna Sakowska js01093@surrey.ac.uk
Elham Saremi saremi@ipm.ir
Yahya Sefidbakht y.sefidbakht@gmail.com
Alejandro Serrano Borlaff asborlaff@ucm.es
Zahra Sharbaf samaeh.sharbaf2@yahoo.com
+ David Shupe shupe@ipac.caltech.edu
Jenny Sorce jenny.sorce@univ-lyon1.fr
Lee Spitler lee.spitler@mq.edu.au
Richard Stallman rms@gnu.org
@@ -82,6 +101,7 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
Aaron Watkins aaron.watkins@oulu.fi
Michael H.F. Wilkinson m.h.f.wilkinson@gmail.com
Christopher Willmer cnaw@as.arizona.edu
+ Xiuqin Wu xiuqin@ipac.caltech.edu
Sara Yousefi Taemeh s.yousefi.t@gmail.com
Johannes Zabl johannes.zabl@irap.omp.eu
@@ -104,14 +124,15 @@ Host institutions of Gnuastro's developers.
University of Salento, Lecce, Italy.
Centre de Recherche Astrophysique de Lyon (CRAL), Lyon, France.
Instituto de Astrofisica de Canarias (IAC), Tenerife, Spain.
+ Google Summer of Code(GSoC).
Copyright
---------
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later
version published by the Free Software Foundation; with no Invariant
-Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
\ No newline at end of file
+Sections, with no Front-Cover Texts, and with no Back-Cover Texts.
diff --git a/bin/TEMPLATE/Makefile.am b/bin/TEMPLATE/Makefile.am
index ee006da..dec0ad8 100644
--- a/bin/TEMPLATE/Makefile.am
+++ b/bin/TEMPLATE/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2016-2019, Free Software Foundation, Inc.
+## Copyright (C) 2016-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,24 +20,23 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astTEMPLATE
-## We are linking with `libgnu' first eventhough `libgnu' is already linked
-## to `libgnuastro'. The reason is that some linkers (Mac OS for example),
+## We are linking with 'libgnu' first eventhough 'libgnu' is already linked
+## to 'libgnuastro'. The reason is that some linkers (Mac OS for example),
## don't keep external variables (needed in Argp) after the first link. So
-## the `libgnu' (that is indirectly linked through `libgnuastro') can't see
-## those variables. We thus need to explicitly link with `libgnu' first.
-astTEMPLATE_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## the 'libgnu' (that is indirectly linked through 'libgnuastro') can't see
+## those variables. We thus need to explicitly link with 'libgnu' first.
+astTEMPLATE_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astTEMPLATE_SOURCES = main.c ui.c TEMPLATE.c
diff --git a/bin/TEMPLATE/TEMPLATE.c b/bin/TEMPLATE/TEMPLATE.c
index 69108aa..751efd9 100644
--- a/bin/TEMPLATE/TEMPLATE.c
+++ b/bin/TEMPLATE/TEMPLATE.c
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/TEMPLATE/TEMPLATE.h b/bin/TEMPLATE/TEMPLATE.h
index e75f578..c716269 100644
--- a/bin/TEMPLATE/TEMPLATE.h
+++ b/bin/TEMPLATE/TEMPLATE.h
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/TEMPLATE/args.h b/bin/TEMPLATE/args.h
index 0568f0a..ba47692 100644
--- a/bin/TEMPLATE/args.h
+++ b/bin/TEMPLATE/args.h
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/TEMPLATE/astTEMPLATE.conf b/bin/TEMPLATE/astTEMPLATE.conf
index d10efb4..34111fe 100644
--- a/bin/TEMPLATE/astTEMPLATE.conf
+++ b/bin/TEMPLATE/astTEMPLATE.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astTEMPLATE # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/TEMPLATE/authors-cite.h b/bin/TEMPLATE/authors-cite.h
index 9090793..8243324 100644
--- a/bin/TEMPLATE/authors-cite.h
+++ b/bin/TEMPLATE/authors-cite.h
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/TEMPLATE/main.c b/bin/TEMPLATE/main.c
index 22757cb..30c7104 100644
--- a/bin/TEMPLATE/main.c
+++ b/bin/TEMPLATE/main.c
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/TEMPLATE/main.h b/bin/TEMPLATE/main.h
index c3f8a08..6c3836f 100644
--- a/bin/TEMPLATE/main.h
+++ b/bin/TEMPLATE/main.h
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/TEMPLATE/ui.c b/bin/TEMPLATE/ui.c
index 717bf17..6d96430 100644
--- a/bin/TEMPLATE/ui.c
+++ b/bin/TEMPLATE/ui.c
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -143,18 +143,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct TEMPLATEparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -202,7 +202,7 @@ parse_opt(int key, char *arg, struct argp_state *state)
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct TEMPLATEparams *p)
{
@@ -226,8 +226,8 @@ ui_check_options_and_arguments(struct TEMPLATEparams *p)
/* If it is FITS, a HDU is also mandatory. */
if( gal_fits_name_is_fits(p->inputname) && p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the input is a FITS "
- "file, a HDU must also be specified, you can use the `--hdu' "
- "(`-h') option and give it the HDU number (starting from "
+ "file, a HDU must also be specified, you can use the '--hdu' "
+ "('-h') option and give it the HDU number (starting from "
"zero), extension name, or anything acceptable by CFITSIO");
}
else
@@ -289,9 +289,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
TEMPLATEparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/TEMPLATE/ui.h b/bin/TEMPLATE/ui.h
index 342508e..6b0f8f7 100644
--- a/bin/TEMPLATE/ui.h
+++ b/bin/TEMPLATE/ui.h
@@ -5,7 +5,7 @@ TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/arithmetic/Makefile.am b/bin/arithmetic/Makefile.am
index 22ccfd2..c73400c 100644
--- a/bin/arithmetic/Makefile.am
+++ b/bin/arithmetic/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,21 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
-
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astarithmetic
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
astarithmetic_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
- -lgnuastro $(MAYBE_NORPATH)
+ -lgnuastro $(CONFIG_LDADD)
astarithmetic_SOURCES = main.c ui.c arithmetic.c operands.c
diff --git a/bin/arithmetic/args.h b/bin/arithmetic/args.h
index 788a818..8e765ee 100644
--- a/bin/arithmetic/args.h
+++ b/bin/arithmetic/args.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -25,6 +25,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
+
+
/* Definition of program-specific options. */
struct argp_option program_options[] =
{
@@ -33,7 +35,7 @@ struct argp_option program_options[] =
UI_KEY_GLOBALHDU,
"STR",
0,
- "Use this HDU for all inputs, ignore `--hdu'.",
+ "Use this HDU for all inputs, ignore '--hdu'.",
GAL_OPTIONS_GROUP_INPUT,
&p->globalhdu,
GAL_TYPE_STRING,
@@ -44,7 +46,7 @@ struct argp_option program_options[] =
{
"wcsfile",
UI_KEY_WCSFILE,
- "STR",
+ "FITS",
0,
"File to use for output's WCS.",
GAL_OPTIONS_GROUP_INPUT,
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 82bbba3..3975a7a 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -77,6 +77,9 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
/* See if this operator needs any parameters. If so, pop them. */
switch(op)
{
+ case GAL_ARITHMETIC_OP_QUANTILE:
+ numparams=1;
+ break;
case GAL_ARITHMETIC_OP_SIGCLIP_STD:
case GAL_ARITHMETIC_OP_SIGCLIP_MEAN:
case GAL_ARITHMETIC_OP_SIGCLIP_MEDIAN:
@@ -93,15 +96,15 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
to the list. */
tmp=operands_pop(p, token_string);
if(tmp->size>1)
- error(EXIT_FAILURE, 0, "the %s popped operand of the \"%s\" "
+ error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' "
"operator must be a single number", cstring, token_string);
tmp=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
gal_list_data_add(params, tmp);
- /* A small sanity check (none of the parameters for sigma-clipping
- can be negative.. */
+ /* A small sanity check (none of the parameters for sigma-clipping,
+ or quantile estimation can be negative. */
if( ((float *)(tmp->array))[0]<=0.0 )
- error(EXIT_FAILURE, 0, "the %s popped operand of the \"%s\" "
+ error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' "
"operator cannot be negative", cstring, token_string);
/* Increment the counter string. */
@@ -111,7 +114,7 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
/* Check if its a number. */
numpop=operands_pop(p, token_string);
if(numpop->size>1)
- error(EXIT_FAILURE, 0, "the %s popped operand of the \"%s\" "
+ error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' "
"operator (number of input datasets) must be a number, not an "
"array", cstring, token_string);
@@ -133,7 +136,7 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
/* Floating point numbers are not acceptable in this context. */
case GAL_TYPE_FLOAT32:
case GAL_TYPE_FLOAT64:
- error(EXIT_FAILURE, 0, "the %s popped operand of the \"%s\" "
+ error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' "
"operator (number of input datasets) must be an integer type",
cstring, token_string);
@@ -144,7 +147,7 @@ pop_number_of_operands(struct arithmeticparams *p, int op,
char *token_string,
/* If control reaches here, then the number must have been a negative
value, so print an error. */
- error(EXIT_FAILURE, 0, "the %s popped operand of the \"%s\" operator "
+ error(EXIT_FAILURE, 0, "the %s popped operand of the '%s' operator "
"cannot be zero or a negative number", cstring,
token_string);
return 0;
@@ -219,7 +222,7 @@ arithmetic_filter(void *in_prm)
/* Go over all the pixels that were assigned to this thread. */
for(i=0; tprm->indexs[i] != GAL_BLANK_SIZE_T; ++i)
{
- /* For easy reading, put the index in `ind'. */
+ /* For easy reading, put the index in 'ind'. */
ind=tprm->indexs[i];
/* Get the coordinate of the pixel. */
@@ -289,7 +292,7 @@ arithmetic_filter(void *in_prm)
case ARITHMETIC_OP_FILTER_SIGCLIP_MEDIAN: sind = 1; break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at "
- "%s to fix the problem. The `afp->operator' value "
+ "%s to fix the problem. The 'afp->operator' value "
"%d is not recognized as sigma-clipped median or "
"mean", __func__, PACKAGE_BUGREPORT, afp->operator);
}
@@ -307,7 +310,7 @@ arithmetic_filter(void *in_prm)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s "
- "to fix the problem. `afp->operator' code %d is not "
+ "to fix the problem. 'afp->operator' code %d is not "
"recognized", PACKAGE_BUGREPORT, __func__,
afp->operator);
}
@@ -494,7 +497,7 @@ wrapper_for_filter(struct arithmeticparams *p, char *token,
int operator)
default:
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix "
- "the problem. The `operator' code %d is not recognized",
+ "the problem. The 'operator' code %d is not recognized",
PACKAGE_BUGREPORT, __func__, operator);
}
@@ -509,7 +512,8 @@ wrapper_for_filter(struct arithmeticparams *p, char *token,
int operator)
/* Spin off threads for each pixel. */
gal_threads_spin_off(arithmetic_filter, &afp, afp.input->size,
- p->cp.numthreads);
+ p->cp.numthreads, p->cp.minmapsize,
+ p->cp.quietmmap);
}
@@ -550,13 +554,13 @@ arithmetic_binary_sanity_checks(gal_data_t *in,
gal_data_t *conn,
{
int conn_int;
- /* Do proper sanity checks on `conn'. */
+ /* Do proper sanity checks on 'conn'. */
if(conn->size!=1)
- error(EXIT_FAILURE, 0, "the first popped operand to `%s' must be a "
+ error(EXIT_FAILURE, 0, "the first popped operand to '%s' must be a "
"single number. However, it has %zu elements", operator,
conn->size);
if(conn->type==GAL_TYPE_FLOAT32 || conn->type==GAL_TYPE_FLOAT64)
- error(EXIT_FAILURE, 0, "the first popped operand to `%s' is the "
+ error(EXIT_FAILURE, 0, "the first popped operand to '%s' is the "
"connectivity (a value between 1 and the number of dimensions) "
"therefore, it must NOT be a floating point", operator);
@@ -565,18 +569,18 @@ arithmetic_binary_sanity_checks(gal_data_t *in,
gal_data_t *conn,
conn=gal_data_copy_to_new_type_free(conn, GAL_TYPE_INT32);
conn_int = *((int32_t *)(conn->array));
if(conn_int>in->ndim)
- error(EXIT_FAILURE, 0, "the first popped operand of `%s' (%d) is "
+ error(EXIT_FAILURE, 0, "the first popped operand of '%s' (%d) is "
"larger than the number of dimensions in the second-popped "
"operand (%zu)", operator, conn_int, in->ndim);
/* Make sure the array has an unsigned 8-bit type. */
if(in->type!=GAL_TYPE_UINT8)
- error(EXIT_FAILURE, 0, "the second popped operand of `%s' doesn't "
+ error(EXIT_FAILURE, 0, "the second popped operand of '%s' doesn't "
"have an 8-bit unsigned integer type. It must be a binary "
"dataset (only being equal to zero is checked). You can use "
- "the `uint8' operator for type conversion", operator);
+ "the 'uint8' operator for type conversion", operator);
- /* Clean up and return the integer value of `conn'. */
+ /* Clean up and return the integer value of 'conn'. */
gal_data_free(conn);
return conn_int;
}
@@ -635,7 +639,7 @@ arithmetic_connected_components(struct arithmeticparams *p,
char *token)
/* Push the result onto the stack. */
operands_add(p, NULL, out);
- /* Clean up (`conn' was freed in the sanity check). */
+ /* Clean up ('conn' was freed in the sanity check). */
gal_data_free(in);
}
@@ -684,10 +688,10 @@ arithmetic_invert(struct arithmeticparams *p, char *token)
case GAL_TYPE_UINT32: do *u32 = UINT32_MAX-*u32; while(++u32<u32f); break;
case GAL_TYPE_UINT64: do *u64 = UINT64_MAX-*u64; while(++u64<u64f); break;
default:
- error(EXIT_FAILURE, 0, "`invert' operand has %s type. `invert' can "
+ error(EXIT_FAILURE, 0, "'invert' operand has %s type. 'invert' can "
"only take unsigned integer types.\n\nYou can use any of the "
- "`uint8', `uint16', `uint32', or `uint64' operators to chage "
- "the type before calling `invert'",
+ "'uint8', 'uint16', 'uint32', or 'uint64' operators to chage "
+ "the type before calling 'invert'",
gal_type_name(in->type, 1));
}
@@ -699,11 +703,145 @@ arithmetic_invert(struct arithmeticparams *p, char
*token)
+#define INTERPOLATE_REGION(TYPE,OP,FUNC) { \
+ TYPE mm, b, *a=in->array, *m=minmax->array; \
+ FUNC(in->type, &mm); \
+ gal_blank_write(&b, in->type); \
+ for(i=0;i<minmax->size;++i) m[i]=mm; \
+ for(i=0;i<in->size;++i) \
+ { \
+ if( l[i]>0 ) \
+ GAL_DIMENSION_NEIGHBOR_OP(i, in->ndim, in->dsize, in->ndim, \
+ dinc, \
+ { \
+ if(in->type==GAL_TYPE_FLOAT32 || in->type==GAL_TYPE_FLOAT64) \
+ { if( a[nind] OP m[l[i]] ) m[l[i]]=a[nind]; } \
+ else \
+ { if( a[nind]!=b && a[nind] OP m[l[i]] ) m[l[i]]=a[nind]; } \
+ }); \
+ } \
+ for(i=0;i<in->size;++i) if( l[i]>0 ) { a[i]=m[l[i]]; } \
+}
+#define INTERPOLATE_REGION_OP(TYPE) { \
+ switch(operator) \
+ { \
+ case ARITHMETIC_OP_INTERPOLATE_MINOFREGION: \
+ INTERPOLATE_REGION(TYPE,<,gal_type_max); break; \
+ case ARITHMETIC_OP_INTERPOLATE_MAXOFREGION: \
+ INTERPOLATE_REGION(TYPE,>,gal_type_min); break; \
+ default: \
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to " \
+ "fix the problem. The operator code %d isn't recognized", \
+ __func__, PACKAGE_BUGREPORT, operator); \
+ } \
+ }
+static void
+arithmetic_interpolate_region(struct arithmeticparams *p,
+ int operator, char *token)
+{
+ /* Pop the dataset to interpolate. */
+ int32_t *l;
+ gal_data_t *minmax;
+ gal_data_t *lab=NULL, *flag;
+ size_t i, *con, *dinc, numlabs;
+
+ /* First pop the number of nearby neighbors.*/
+ gal_data_t *connectivity = operands_pop(p, token);
+
+ /* Then pop the actual dataset to interpolate. */
+ gal_data_t *in = operands_pop(p, token);
+
+ /* Do proper sanity checks on 'con'. */
+ if(connectivity->size!=1)
+ error(EXIT_FAILURE, 0, "the first popped operand to the "
+ "'interpolate-XXXofregion' operators must be a single number. "
+ "However, it has %zu elements", connectivity->size);
+ if( connectivity->type==GAL_TYPE_FLOAT32
+ || connectivity->type==GAL_TYPE_FLOAT64)
+ error(EXIT_FAILURE, 0, "the first popped operand to "
+ "'interpolate-XXXofregion' operators is the connectivity to "
+ "define connected blank regions (a counter, an integer, with "
+ "a maximum of the number of dimensions of the input). It must "
+ "NOT be a floating point.\n\n"
+ "If its already an integer, but in a floating point container, "
+ "you can use the 'int32' operator to convert it to a 32-bit "
+ "integer for example");
+
+ /* Convert connectivity to an integer type and make sure its not larger
+ than dimensions of the input. */
+ connectivity=gal_data_copy_to_new_type_free(connectivity,
+ GAL_TYPE_SIZE_T);
+ con=connectivity->array;
+ if(con[0]>in->ndim)
+ error(EXIT_FAILURE, 0, "the first popped operand to "
+ "'interpolate-XXXofregion' operators must not be larger than "
+ "the number of dimensions of the input. The connectivity is "
+ "used to define connected blank regions. For example in a "
+ "2D dataset, a connectivity of 1 corresponds to 4-connected "
+ "neighbors and connectivity 2 corresponds to 8-connected "
+ "neighbors");
+
+ /* First make sure the input has blank values. If it doesn't, don't waste
+ time, just return it. */
+ if( gal_blank_present(in, 1)==0 )
+ { operands_add(p, NULL, in); return; }
+
+ /* Build a binary image with the blank regions masked and label them,
+ then free the flagged array. */
+ flag=gal_blank_flag(in);
+ numlabs=gal_binary_connected_components(flag, &lab, con[0]);
+ gal_data_free(flag);
+
+ /* Allocate array to keep maximum values for each region. Just note that
+ because we count the regions from 1, but the indexs from 0, we'll
+ allocate one extra point. */
+ ++numlabs;
+ minmax=gal_data_alloc(NULL, in->type, 1, &numlabs, NULL, 0, in->minmapsize,
+ in->quietmmap, NULL, NULL, NULL);
+
+ /* Parse the dataset elements for NaNs. */
+ l=lab->array;
+ dinc=gal_dimension_increment(in->ndim, in->dsize);
+ switch(in->type)
+ {
+ case GAL_TYPE_UINT8: INTERPOLATE_REGION_OP(uint8_t); break;
+ case GAL_TYPE_INT8: INTERPOLATE_REGION_OP(int8_t); break;
+ case GAL_TYPE_UINT16: INTERPOLATE_REGION_OP(uint16_t); break;
+ case GAL_TYPE_INT16: INTERPOLATE_REGION_OP(int16_t); break;
+ case GAL_TYPE_UINT32: INTERPOLATE_REGION_OP(uint32_t); break;
+ case GAL_TYPE_INT32: INTERPOLATE_REGION_OP(int32_t); break;
+ case GAL_TYPE_FLOAT32: INTERPOLATE_REGION_OP(float); break;
+ case GAL_TYPE_FLOAT64: INTERPOLATE_REGION_OP(double); break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+ "fix the problem. The code %d is not a recognized data "
+ "type", __func__, PACKAGE_BUGREPORT, in->type);
+ }
+
+ /* For tests.
+ gal_fits_img_write(lab, "test-out.fits", NULL, NULL);
+ gal_fits_img_write(in, "test-out.fits", NULL, NULL);
+ printf("\n...%s...\n", __func__); exit(0);
+ */
+
+ /* Clean up. */
+ gal_data_free(lab);
+ gal_data_free(minmax);
+ gal_data_free(connectivity);
+
+ /* Push the interpolated dataset onto the stack. */
+ operands_add(p, NULL, in);
+}
+
+
+
+
+
static void
-arithmetic_interpolate(struct arithmeticparams *p, char *token)
+arithmetic_interpolate(struct arithmeticparams *p, int operator, char *token)
{
- int num_int;
gal_data_t *interpolated;
+ int num_int, interpop=GAL_ARITHMETIC_OP_INVALID;
/* First pop the number of nearby neighbors.*/
gal_data_t *num = operands_pop(p, token);
@@ -711,27 +849,46 @@ arithmetic_interpolate(struct arithmeticparams *p, char
*token)
/* Then pop the actual dataset to interpolate. */
gal_data_t *in = operands_pop(p, token);
- /* Do proper sanity checks on `num'. */
+ /* Do proper sanity checks on 'num'. */
if(num->size!=1)
error(EXIT_FAILURE, 0, "the first popped operand to "
- "`interpolate-medianngb' must be a single number. However, "
- "it has %zu elements", num->size);
+ "'interpolate-XXXXXngb' operators must be a single number. "
+ "However, it has %zu elements", num->size);
if(num->type==GAL_TYPE_FLOAT32 || num->type==GAL_TYPE_FLOAT64)
error(EXIT_FAILURE, 0, "the first popped operand to "
- "`interpolate-medianngb' is the number of nearby neighbors (a "
- "counter, an integer). It must NOT be a floating point.\n\n"
+ "'interpolate-XXXXXngb' operators is the number of nearby "
+ "neighbors (a counter, an integer). It must NOT be a floating "
+ "point.\n\n"
"If its already an integer, but in a floating point container, "
- "you can use the `int32' operator to convert it to a 32-bit "
+ "you can use the 'int32' operator to convert it to a 32-bit "
"integer for example");
/* Convert the given number to a 32-bit integer and read it in. */
num=gal_data_copy_to_new_type_free(num, GAL_TYPE_INT32);
num_int = *((int32_t *)(num->array));
+ /* Set the interpolation operator. */
+ switch(operator)
+ {
+ case ARITHMETIC_OP_INTERPOLATE_MINNGB:
+ interpop=GAL_INTERPOLATE_NEIGHBORS_FUNC_MIN;
+ break;
+ case ARITHMETIC_OP_INTERPOLATE_MAXNGB:
+ interpop=GAL_INTERPOLATE_NEIGHBORS_FUNC_MAX;
+ break;
+ case ARITHMETIC_OP_INTERPOLATE_MEDIANNGB:
+ interpop=GAL_INTERPOLATE_NEIGHBORS_FUNC_MEDIAN;
+ break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
+ "the problem. The operator code %d isn't recognized",
+ __func__, PACKAGE_BUGREPORT, operator);
+ }
+
/* Call the interpolation function. */
- interpolated=gal_interpolate_close_neighbors(in, NULL, p->cp.interpmetric,
- num_int, p->cp.numthreads,
- 1, 0);
+ interpolated=gal_interpolate_neighbors(in, NULL, p->cp.interpmetric,
+ num_int, p->cp.numthreads,
+ 1, 0, interpop);
/* Clean up and push the interpolated array onto the stack. */
gal_data_free(in);
@@ -758,28 +915,28 @@ arithmetic_collapse(struct arithmeticparams *p, char
*token, int operator)
/* Small sanity check. */
if( dimension->ndim!=1 || dimension->size!=1)
- error(EXIT_FAILURE, 0, "first popped operand of `collapse-*' operators "
+ error(EXIT_FAILURE, 0, "first popped operand of 'collapse-*' operators "
"(dimension to collapse) must be a single number (single-element, "
"one-dimensional dataset). But it has %zu dimension(s) and %zu "
"element(s).", dimension->ndim, dimension->size);
if(dimension->type==GAL_TYPE_FLOAT32 || dimension->type==GAL_TYPE_FLOAT64)
- error(EXIT_FAILURE, 0, "first popped operand of `collapse-*' operators "
+ error(EXIT_FAILURE, 0, "first popped operand of 'collapse-*' operators "
"(dimension to collapse) must have an integer type, but it has "
- "a floating point type (`%s')", gal_type_name(dimension->type,1));
+ "a floating point type ('%s')", gal_type_name(dimension->type,1));
dimension=gal_data_copy_to_new_type_free(dimension, GAL_TYPE_LONG);
dim=((long *)(dimension->array))[0];
if(dim<0 || dim==0)
- error(EXIT_FAILURE, 0, "first popped operand of `collapse-*' operators "
+ error(EXIT_FAILURE, 0, "first popped operand of 'collapse-*' operators "
"(dimension to collapse) must be positive (larger than zero), it "
"is %ld", dim);
if(dim > input->ndim)
- error(EXIT_FAILURE, 0, "input dataset to `%s' has %zu dimension(s), "
- "but you have asked to collapse along dimension %zu", token,
+ error(EXIT_FAILURE, 0, "input dataset to '%s' has %zu dimension(s), "
+ "but you have asked to collapse along dimension %ld", token,
input->ndim, dim);
/* If a WCS structure has been read, we'll need to pass it to
- `gal_dimension_collapse', so it modifies it respectively. */
+ 'gal_dimension_collapse', so it modifies it respectively. */
if(p->wcs_collapsed==0)
{
p->wcs_collapsed=1;
@@ -818,9 +975,9 @@ arithmetic_collapse(struct arithmeticparams *p, char
*token, int operator)
/* If a WCS structure existed, a modified WCS is now present in
- `collapsed->wcs'. So we'll let the freeing of `input' free the old
- `p->refdata.wcs' structure and we'll put the new one there, then we'll
- set `collapsed->wcs' to `NULL', so the new one isn't freed. */
+ 'collapsed->wcs'. So we'll let the freeing of 'input' free the old
+ 'p->refdata.wcs' structure and we'll put the new one there, then we'll
+ set 'collapsed->wcs' to 'NULL', so the new one isn't freed. */
if(collapsed->wcs)
{
p->refdata.wcs = collapsed->wcs;
@@ -829,9 +986,9 @@ arithmetic_collapse(struct arithmeticparams *p, char
*token, int operator)
/* We'll also need to correct the size of the reference dataset if it
- hasn't been corrected yet. We'll use `memcpy' to write the new `dsize'
+ hasn't been corrected yet. We'll use 'memcpy' to write the new 'dsize'
values into the old ones. The dimensions have decreased, so we won't
- be writing outside of allocated space that `p->refdata.dsize' points
+ be writing outside of allocated space that 'p->refdata.dsize' points
to. */
if( p->refdata.ndim != collapsed->ndim )
{
@@ -863,7 +1020,7 @@ arithmetic_tofile(struct arithmeticparams *p, char *token,
int freeflag)
/* Save it to a file. */
popped->wcs=p->refdata.wcs;
if(popped->ndim==1 && p->onedasimage==0)
- gal_table_write(popped, NULL, p->cp.tableformat, filename,
+ gal_table_write(popped, NULL, NULL, p->cp.tableformat, filename,
"ARITHMETIC", 0);
else
gal_fits_img_write(popped, filename, NULL, PROGRAM_NAME);
@@ -882,53 +1039,11 @@ arithmetic_tofile(struct arithmeticparams *p, char
*token, int freeflag)
-/* Pull out unique elements */
-#define UNIQUE_BYTYPE(TYPE) { \
- size_t i, j; \
- TYPE *a=input->array, b; \
- \
- /* Write the blank value for this type into `b'. */ \
- gal_blank_write(&b, input->type); \
- \
- /* Go over the elements, and set the duplicates to blank. */ \
- /* Note that for integers and floats, the behavior of blank/NaN */ \
- /* differs: for floats (NaN), we can identify a blank using the */ \
- /* fact that by definition, NaN!=NaN. */ \
- if(b==b) \
- for(i=0;i<input->size;++i) \
- { if(a[i]!=b) for(j=i+1;j<input->size;++j) if(a[i]==a[j]) a[j]=b;} \
- else \
- for(i=0;i<input->size;++i) \
- { if(a[i]==a[i]) for(j=i+1;j<input->size;++j) if(a[i]==a[j]) a[j]=b;} \
- }
-
void
arithmetic_unique(struct arithmeticparams *p, char *token, int operator)
{
- gal_data_t *input = operands_pop(p, token);
-
- /* Remove the duplicates based on size. */
- switch(input->type)
- {
- case GAL_TYPE_UINT8: UNIQUE_BYTYPE( uint8_t ); break;
- case GAL_TYPE_INT8: UNIQUE_BYTYPE( int8_t ); break;
- case GAL_TYPE_UINT16: UNIQUE_BYTYPE( uint16_t ); break;
- case GAL_TYPE_INT16: UNIQUE_BYTYPE( int16_t ); break;
- case GAL_TYPE_UINT32: UNIQUE_BYTYPE( uint32_t ); break;
- case GAL_TYPE_INT32: UNIQUE_BYTYPE( int32_t ); break;
- case GAL_TYPE_UINT64: UNIQUE_BYTYPE( uint64_t ); break;
- case GAL_TYPE_INT64: UNIQUE_BYTYPE( int64_t ); break;
- case GAL_TYPE_FLOAT32: UNIQUE_BYTYPE( float ); break;
- case GAL_TYPE_FLOAT64: UNIQUE_BYTYPE( double ); break;
- default:
- error(EXIT_FAILURE, 0, "the `unique' operator doesn't support type "
- "code `%u'", input->type);
- }
-
- /* Remove all blank elements. */
- gal_blank_remove(input);
-
- /* Add the collapsed dataset to the top of the operands. */
+ /* Pass the popped operand to the statistics library. */
+ gal_data_t *input = gal_statistics_unique(operands_pop(p, token), 1);
operands_add(p, NULL, input);
}
@@ -945,10 +1060,10 @@ arithmetic_add_dimension(struct arithmeticparams *p,
char *token, int operator)
/* Make sure the first operand is a number. */
if(tmp->size!=1)
- error(EXIT_FAILURE, 0, "first popped operand to `%s' must be a "
+ error(EXIT_FAILURE, 0, "first popped operand to '%s' must be a "
"number (specifying how many datasets to use)", token);
- /* Put the value into `num'. */
+ /* Put the value into 'num'. */
tmp=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_SIZE_T);
num=*(size_t *)(tmp->array);
gal_data_free(tmp);
@@ -964,14 +1079,14 @@ arithmetic_add_dimension(struct arithmeticparams *p,
char *token, int operator)
{
/* Basic sanity checks. */
if(tmp->type!=out->type)
- error(EXIT_FAILURE, 0, "the operands to `%s' have to have the "
+ error(EXIT_FAILURE, 0, "the operands to '%s' have to have the "
"same data type (the inputs contain atleast two types: "
- "`%s' and `%s')", token, gal_type_name(tmp->type, 1),
+ "'%s' and '%s')", token, gal_type_name(tmp->type, 1),
gal_type_name(out->type, 1));
if( tmp->ndim!=out->ndim-1
|| tmp->dsize[0]!=out->dsize[1]
|| tmp->dsize[1]!=out->dsize[2] )
- error(EXIT_FAILURE, 0, "the operands to `%s' have to have the "
+ error(EXIT_FAILURE, 0, "the operands to '%s' have to have the "
"same size", token);
}
else /* First popped operand. */
@@ -979,7 +1094,7 @@ arithmetic_add_dimension(struct arithmeticparams *p, char
*token, int operator)
/* First popped operand, do necessary basic checks here. */
if(tmp->ndim!=2)
error(EXIT_FAILURE, 0, "currently only 2-dimensional datasets "
- "are acceptable for `%s', please get in touch with us at "
+ "are acceptable for '%s', please get in touch with us at "
"%s so we add functionality for different dimensions",
token, PACKAGE_BUGREPORT);
@@ -1058,8 +1173,16 @@ arithmetic_set_operator(char *string, size_t
*num_operands)
{ op=ARITHMETIC_OP_FILL_HOLES; *num_operands=0; }
else if (!strcmp(string, "invert"))
{ op=ARITHMETIC_OP_INVERT; *num_operands=0; }
+ else if (!strcmp(string, "interpolate-minngb"))
+ { op=ARITHMETIC_OP_INTERPOLATE_MINNGB; *num_operands=0; }
+ else if (!strcmp(string, "interpolate-maxngb"))
+ { op=ARITHMETIC_OP_INTERPOLATE_MAXNGB; *num_operands=0; }
else if (!strcmp(string, "interpolate-medianngb"))
{ op=ARITHMETIC_OP_INTERPOLATE_MEDIANNGB; *num_operands=0; }
+ else if (!strcmp(string, "interpolate-minofregion"))
+ { op=ARITHMETIC_OP_INTERPOLATE_MINOFREGION; *num_operands=0; }
+ else if (!strcmp(string, "interpolate-maxofregion"))
+ { op=ARITHMETIC_OP_INTERPOLATE_MAXOFREGION; *num_operands=0; }
else if (!strcmp(string, "collapse-sum"))
{ op=ARITHMETIC_OP_COLLAPSE_SUM; *num_operands=0; }
else if (!strcmp(string, "collapse-min"))
@@ -1075,7 +1198,7 @@ arithmetic_set_operator(char *string, size_t
*num_operands)
else if (!strcmp(string, "add-dimension"))
{ op=ARITHMETIC_OP_ADD_DIMENSION; *num_operands=0; }
else
- error(EXIT_FAILURE, 0, "the argument \"%s\" could not be "
+ error(EXIT_FAILURE, 0, "the argument '%s' could not be "
"interpretted as a file name, named dataset, number, "
"or operator", string);
}
@@ -1098,7 +1221,7 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
int flags = ( GAL_ARITHMETIC_INPLACE | GAL_ARITHMETIC_FREE
| GAL_ARITHMETIC_NUMOK );
- /* When `num_operands!=0', the operator is in the library. */
+ /* When 'num_operands!=0', the operator is in the library. */
if(num_operands)
{
/* Pop the necessary number of operators. Note that the
@@ -1128,7 +1251,7 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
operand. So except for sigma-clipping (that has other
parameters), the first popped operand must be an
integer number, we will use that to construct a linked
- list of any number of operands within the single `d1'
+ list of any number of operands within the single 'd1'
pointer. */
numop=pop_number_of_operands(p, operator, operator_string, &d2);
for(i=0;i<numop;++i)
@@ -1137,12 +1260,12 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
- "the problem. `%zu' is not recognized as an operand "
- "counter (with `%s')", __func__, PACKAGE_BUGREPORT,
+ "the problem. '%zu' is not recognized as an operand "
+ "counter (with '%s')", __func__, PACKAGE_BUGREPORT,
num_operands, operator_string);
}
- /* Run the arithmetic operation. Note that `gal_arithmetic'
+ /* Run the arithmetic operation. Note that 'gal_arithmetic'
is a variable argument function (like printf). So the
number of arguments it uses depend on the operator. So
when the operator doesn't need three operands, the extra
@@ -1181,8 +1304,15 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
arithmetic_invert(p, operator_string);
break;
+ case ARITHMETIC_OP_INTERPOLATE_MINNGB:
+ case ARITHMETIC_OP_INTERPOLATE_MAXNGB:
case ARITHMETIC_OP_INTERPOLATE_MEDIANNGB:
- arithmetic_interpolate(p, operator_string);
+ arithmetic_interpolate(p, operator, operator_string);
+ break;
+
+ case ARITHMETIC_OP_INTERPOLATE_MINOFREGION:
+ case ARITHMETIC_OP_INTERPOLATE_MAXOFREGION:
+ arithmetic_interpolate_region(p, operator, operator_string);
break;
case ARITHMETIC_OP_COLLAPSE_SUM:
@@ -1204,7 +1334,7 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
default:
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at "
"%s to fix the problem. The code %d is not "
- "recognized for `op'", __func__, PACKAGE_BUGREPORT,
+ "recognized for 'op'", __func__, PACKAGE_BUGREPORT,
operator);
}
}
@@ -1214,6 +1344,28 @@ arithmetic_operator_run(struct arithmeticparams *p, int
operator,
+/* Used by the 'set-' operator. */
+static int
+arithmetic_set_name_used_later(void *in, char *name)
+{
+ struct gal_arithmetic_set_params *p=(struct gal_arithmetic_set_params *)in;
+ gal_list_str_t *token, *tokens = (gal_list_str_t *)(p->tokens);
+
+ size_t counter=0;
+
+ /* If the name exists after the current token, then return 1. */
+ for(token=tokens;token!=NULL;token=token->next)
+ if( counter++ > p->tokencounter && !strcmp(token->v, name) )
+ return 1;
+
+ /* If we get to this point, it means that the name doesn't exist. */
+ return 0;
+}
+
+
+
+
+
/* This function implements the reverse polish algorithm as explained
in the Wikipedia page.
@@ -1228,16 +1380,19 @@ reversepolish(struct arithmeticparams *p)
char *hdu, *filename, *printnum;
int operator=GAL_ARITHMETIC_OP_INVALID;
-
/* Prepare the processing: */
- p->operands=NULL;
p->popcounter=0;
-
+ p->operands=NULL;
+ p->setprm.params=p;
+ p->setprm.tokencounter=0;
+ p->setprm.tokens=p->tokens;
+ p->setprm.pop=operands_pop_wrapper_set;
+ p->setprm.used_later=arithmetic_set_name_used_later;
/* Go over each input token and do the work. */
for(token=p->tokens;token!=NULL;token=token->next)
{
- /* The `tofile-' operator's string can end in a `.fits', similar to a
+ /* The 'tofile-' operator's string can end in a '.fits', similar to a
FITS file input file. So, it needs to be checked before checking
for a filename. If we have a name or number, then add it to the
operands linked list. Otherwise, pull out two members and do the
@@ -1249,14 +1404,21 @@ reversepolish(struct arithmeticparams *p)
else if( !strncmp(OPERATOR_PREFIX_TOFILEFREE, token->v,
OPERATOR_PREFIX_LENGTH_TOFILE) )
arithmetic_tofile(p, token->v, 1);
- else if( !strncmp(token->v, OPERATOR_PREFIX_SET,
- OPERATOR_PREFIX_LENGTH_SET) )
- operands_set_name(p, token->v);
- else if( gal_array_name_recognized(token->v)
- || operands_is_name(p, token->v) )
+ else if( !strncmp(token->v, GAL_ARITHMETIC_SET_PREFIX,
+ GAL_ARITHMETIC_SET_PREFIX_LENGTH) )
+ gal_arithmetic_set_name(&p->setprm, token->v);
+ else if( gal_array_name_recognized(token->v)
+ || gal_arithmetic_set_is_name(p->setprm.named, token->v) )
operands_add(p, token->v, NULL);
else if( (data=gal_data_copy_string_to_number(token->v)) )
- operands_add(p, NULL, data);
+ {
+ /* The 'minmapsize' and 'quietmmap' parameters should be passed
+ onto the library within numbers also (since they are the
+ only things that go in the library sometimes). */
+ data->quietmmap=p->cp.quietmmap;
+ data->minmapsize=p->cp.minmapsize;
+ operands_add(p, NULL, data);
+ }
/* Last option is an operator: the program will abort if the token
isn't an operator. */
else
@@ -1266,7 +1428,7 @@ reversepolish(struct arithmeticparams *p)
}
/* Increment the token counter. */
- ++p->tokencounter;
+ ++p->setprm.tokencounter;
}
@@ -1282,10 +1444,10 @@ reversepolish(struct arithmeticparams *p)
error(EXIT_FAILURE, 0, "too many operands");
- /* If the final operand has a filename, but its `data' element is NULL,
+ /* If the final operand has a filename, but its 'data' element is NULL,
then the file hasn't actually be read yet. In this case, we need to
read the contents of the file and put the resulting dataset into the
- operands `data' element. This can happen for example if no operators
+ operands 'data' element. This can happen for example if no operators
are called and there is only one filename as an argument (which can
happen in scripts). */
if(p->operands->data==NULL && p->operands->filename)
@@ -1305,8 +1467,8 @@ reversepolish(struct arithmeticparams *p)
}
else
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix "
- "the problem. While `operands->data' is NULL, the filename "
- "(`%s') is not recognized as a FITS file", __func__,
+ "the problem. While 'operands->data' is NULL, the filename "
+ "('%s') is not recognized as a FITS file", __func__,
PACKAGE_BUGREPORT, filename);
}
@@ -1326,10 +1488,10 @@ reversepolish(struct arithmeticparams *p)
else
{
/* Put a copy of the WCS structure from the reference image, it
- will be freed while freeing `data'. */
+ will be freed while freeing 'data'. */
data->wcs=p->refdata.wcs;
if(data->ndim==1 && p->onedasimage==0)
- gal_table_write(data, NULL, p->cp.tableformat,
+ gal_table_write(data, NULL, NULL, p->cp.tableformat,
p->onedonstdout ? NULL : p->cp.output,
"ARITHMETIC", 0);
else
@@ -1339,11 +1501,11 @@ reversepolish(struct arithmeticparams *p)
}
- /* Clean up, note that above, we copied the pointer to `refdata->wcs'
- into `data', so it is freed when freeing `data'. */
+ /* Clean up, note that above, we copied the pointer to 'refdata->wcs'
+ into 'data', so it is freed when freeing 'data'. */
gal_data_free(data);
free(p->refdata.dsize);
- gal_list_data_free(p->named);
+ gal_list_data_free(p->setprm.named);
/* Clean up. Note that the tokens were taken from the command-line
diff --git a/bin/arithmetic/arithmetic.h b/bin/arithmetic/arithmetic.h
index 4e90d99..fdf65f3 100644
--- a/bin/arithmetic/arithmetic.h
+++ b/bin/arithmetic/arithmetic.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -40,7 +40,11 @@ enum arithmetic_prog_operators
ARITHMETIC_OP_CONNECTED_COMPONENTS,
ARITHMETIC_OP_FILL_HOLES,
ARITHMETIC_OP_INVERT,
+ ARITHMETIC_OP_INTERPOLATE_MINNGB,
+ ARITHMETIC_OP_INTERPOLATE_MAXNGB,
ARITHMETIC_OP_INTERPOLATE_MEDIANNGB,
+ ARITHMETIC_OP_INTERPOLATE_MINOFREGION,
+ ARITHMETIC_OP_INTERPOLATE_MAXOFREGION,
ARITHMETIC_OP_COLLAPSE_SUM,
ARITHMETIC_OP_COLLAPSE_MIN,
ARITHMETIC_OP_COLLAPSE_MAX,
diff --git a/bin/arithmetic/astarithmetic.conf
b/bin/arithmetic/astarithmetic.conf
index 5baa1ab..9ce8f10 100644
--- a/bin/arithmetic/astarithmetic.conf
+++ b/bin/arithmetic/astarithmetic.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astarithmetic # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -20,4 +20,4 @@
# warranty.
# Inputs
- wcshdu 1
\ No newline at end of file
+ wcshdu 1
diff --git a/bin/arithmetic/authors-cite.h b/bin/arithmetic/authors-cite.h
index deb0bec..13588d7 100644
--- a/bin/arithmetic/authors-cite.h
+++ b/bin/arithmetic/authors-cite.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/arithmetic/main.c b/bin/arithmetic/main.c
index ff9da8b..f1e72f5 100644
--- a/bin/arithmetic/main.c
+++ b/bin/arithmetic/main.c
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -36,7 +36,7 @@ int
main (int argc, char *argv[])
{
struct timeval t1;
- struct arithmeticparams p={{{0},0},0};
+ struct arithmeticparams p={{{0},0},{0},0};
/* Set the starting time. */
time(&p.rawtime);
diff --git a/bin/arithmetic/main.h b/bin/arithmetic/main.h
index af1b9a0..f53c46a 100644
--- a/bin/arithmetic/main.h
+++ b/bin/arithmetic/main.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -27,6 +27,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gnuastro/list.h>
#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/arithmetic-set.h>
/* Progarm name macros: */
@@ -40,10 +41,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Constants: */
#define NEG_DASH_REPLACE 11 /* Vertical tab (ASCII=11) for negative dash */
-#define OPERATOR_PREFIX_SET "set-"
#define OPERATOR_PREFIX_TOFILE "tofile-"
#define OPERATOR_PREFIX_TOFILEFREE "tofilefree-"
-#define OPERATOR_PREFIX_LENGTH_SET strlen(OPERATOR_PREFIX_SET)
#define OPERATOR_PREFIX_LENGTH_TOFILE strlen(OPERATOR_PREFIX_TOFILE)
#define OPERATOR_PREFIX_LENGTH_TOFILEFREE strlen(OPERATOR_PREFIX_TOFILEFREE)
@@ -51,8 +50,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
-/* In every node of the operand linked list, only one of the `filename' or
- `data' should be non-NULL. Otherwise it will be a bug and will cause
+/* In every node of the operand linked list, only one of the 'filename' or
+ 'data' should be non-NULL. Otherwise it will be a bug and will cause
problems. All the operands operate on this premise. */
struct operand
{
@@ -71,6 +70,7 @@ struct arithmeticparams
{
/* Other structures: */
struct gal_options_common_params cp; /* Common parameters. */
+ struct gal_arithmetic_set_params setprm; /* Parameters for 'set-'. */
/* Input: */
gal_list_str_t *hdus; /* List of all given HDU strings. */
@@ -82,8 +82,6 @@ struct arithmeticparams
char *globalhdu; /* Single HDU for all inputs. */
uint8_t onedasimage; /* Write 1D outputs as an image not table. */
uint8_t onedonstdout; /* Write 1D outputs on stdout, not table. */
- gal_data_t *named; /* List containing variables. */
- size_t tokencounter; /* Counter for finding place in tokens. */
/* Operating mode: */
int wcs_collapsed; /* If the internal WCS is already collapsed.*/
diff --git a/bin/arithmetic/operands.c b/bin/arithmetic/operands.c
index 9b24ece..1c06500 100644
--- a/bin/arithmetic/operands.c
+++ b/bin/arithmetic/operands.c
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -34,6 +34,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gnuastro/tiff.h>
#include <gnuastro/array.h>
#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/arithmetic-set.h>
#include "main.h"
@@ -76,197 +77,12 @@ operands_num(struct arithmeticparams *p)
/**********************************************************************/
-/************ Named operands ***************/
-/**********************************************************************/
-static int
-operands_name_is_used_later(struct arithmeticparams *p, char *name)
-{
- size_t counter=0;
- gal_list_str_t *token;
-
- /* If the name indeed exists afterwards, then just return 1. */
- for(token=p->tokens;token!=NULL;token=token->next)
- if( counter++ > p->tokencounter && !strcmp(token->v, name) )
- return 1;
-
- /* If we get to this point, it means that the name doesn't exist. */
- return 0;
-}
-
-
-
-
-
-/* Remove a name from the list of names and return the dataset it points
- to. */
-static gal_data_t *
-operands_remove_name(struct arithmeticparams *p, char *name)
-{
- gal_data_t *tmp, *removed=NULL, *prev=NULL;
-
- /* Go over all the given names. */
- for(tmp=p->named;tmp!=NULL;tmp=tmp->next)
- {
- if( !strcmp(tmp->name, name) )
- {
- removed=tmp;
- if(prev) prev->next = tmp->next;
- else p->named = tmp->next;
- }
-
- /* Set this node as the `prev' pointer. */
- prev=tmp;
- }
-
- /* A small sanity check. */
- if(removed==NULL)
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
- "problem. `removed' must not be NULL at this point", __func__,
- PACKAGE_BUGREPORT);
-
- /* Nothing in the list points to it now. So we can safely modify and
- return it. */
- free(removed->name);
- removed->next=NULL;
- removed->name=NULL;
- return removed;
-}
-
-
-
-
-
-/* Pop a dataset and keep it in the `named' list for later use. */
-void
-operands_set_name(struct arithmeticparams *p, char *token)
-{
- gal_data_t *tmp, *tofree;
- char *varname=&token[ OPERATOR_PREFIX_LENGTH_SET ];
-
- /* If a dataset with this name already exists, it will be removed/deleted
- so we can use the name for the newly designated dataset. */
- for(tmp=p->named; tmp!=NULL; tmp=tmp->next)
- if( !strcmp(varname, tmp->name) )
- {
- tofree=operands_remove_name(p, varname);
- gal_data_free(tofree);
-
- /* IMPORTANT: we MUST break here! `tmp' does't point to the right
- place any more. We can define a `prev' node and modify it on
- every attempt, but since there is only one dataset with a given
- name, that is redundant and will just make the program slow. */
- break;
- }
-
- /* Pop the top operand, then add it to the list of named datasets, but
- only if it is used in later tokens. If it isn't, free the popped
- dataset. The latter case (to define a name, but not use it), is
- obviously a redundant operation, but that is upto the user, we
- shouldn't worry about it here. We should just have everything in
- place, so no crashes occur or no extra memory is consumed. */
- if( operands_name_is_used_later(p, varname) )
- {
- /* Add the top popped operand to the list of names. */
- gal_list_data_add(&p->named, operands_pop(p, "set"));
-
- /* Write the requested name into this dataset. But note that `name'
- MUST be already empty. So to be safe, we'll do a sanity check. */
- if(p->named->name)
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
- "the problem. The `name' element should be NULL at this "
- "point, but it isn't", __func__, PACKAGE_BUGREPORT);
- gal_checkset_allocate_copy(varname, &p->named->name);
- }
- else
- {
- /* Pop the top operand, then free it. */
- tmp=operands_pop(p, "set");
- gal_data_free(tmp);
- }
-}
-
-
-
-
-
-/* See if a given token is the name of a variable. */
-int
-operands_is_name(struct arithmeticparams *p, char *token)
-{
- gal_data_t *tmp;
-
- /* Make sure the variable name hasn't been set before. */
- for(tmp=p->named; tmp!=NULL; tmp=tmp->next)
- if( !strcmp(token, tmp->name) )
- return 1;
-
- /* If control reaches here, then there was no match*/
- return 0;
-}
-
-
-
-
-
-/* Return a copy of the named dataset. */
-static gal_data_t *
-operands_copy_named(struct arithmeticparams *p, char *name)
-{
- gal_data_t *out=NULL, *tmp;
-
- /* Find the proper named element to use. */
- for(tmp=p->named;tmp!=NULL;tmp=tmp->next)
- if( !strcmp(tmp->name, name) )
- {
- /* If the named operand is used later, then copy it into the
- output. */
- if( operands_name_is_used_later(p, name) )
- {
- out=gal_data_copy(tmp);
- free(out->name);
- out->name=NULL;
- out->next=NULL;
- }
- /* The named operand is not used any more. Remove it from the list
- of named datasets and continue. */
- else out=operands_remove_name(p, name);
- }
-
- /* A small sanity check. */
- if(out==NULL)
- error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix the "
- "problem. The requested name `%s' couldn't be found in the list",
- __func__, PACKAGE_BUGREPORT, name);
-
- /* Return. */
- return out;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/**********************************************************************/
/************ Adding to and popping from stack ***************/
/**********************************************************************/
void
operands_add(struct arithmeticparams *p, char *filename, gal_data_t *data)
{
+ int readwcs;
size_t ndim, *dsize;
struct operand *newnode;
@@ -279,15 +95,15 @@ operands_add(struct arithmeticparams *p, char *filename,
gal_data_t *data)
errno=0;
newnode=malloc(sizeof *newnode);
if(newnode==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `newnode'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'newnode'",
__func__, sizeof *newnode);
- /* If the `filename' is the name of a dataset, then use a copy of it.
+ /* If the 'filename' is the name of a dataset, then use a copy of it.
otherwise, do the basic analysis. */
- if( filename && operands_is_name(p, filename) )
+ if( filename && gal_arithmetic_set_is_name(p->setprm.named, filename) )
{
newnode->filename=NULL;
- newnode->data=operands_copy_named(p, filename);
+ newnode->data=gal_arithmetic_set_copy_named(&p->setprm, filename);
}
else
{
@@ -308,15 +124,33 @@ operands_add(struct arithmeticparams *p, char *filename,
gal_data_t *data)
/* If no WCS is set yet, use the WCS of this image and remove
possibly extra dimensions if necessary. */
- if(p->refdata.wcs==NULL)
+ readwcs = (p->wcsfile && !strcmp(p->wcsfile,"none")) ? 0 : 1;
+ if(readwcs && p->refdata.wcs==NULL)
{
- dsize=gal_fits_img_info_dim(filename, newnode->hdu, &ndim);
+ /* If the HDU is an image, read its size. */
+ dsize = ( gal_fits_hdu_format(filename,
+ newnode->hdu)==IMAGE_HDU
+ ? gal_fits_img_info_dim(filename,
+ newnode->hdu, &ndim)
+ : NULL);
+
+ /* Read the WCS. */
p->refdata.wcs=gal_wcs_read(filename, newnode->hdu, 0, 0,
&p->refdata.nwcs);
- ndim=gal_dimension_remove_extra(ndim, dsize, p->refdata.wcs);
+
+ /* Remove extra (length of 1) dimensions (if we had an
+ image HDU). */
+ if(dsize)
+ {
+ ndim=gal_dimension_remove_extra(ndim, dsize,
+ p->refdata.wcs);
+ free(dsize);
+ }
+
+ /* Let the user know that the WCS is read. */
if(p->refdata.wcs && !p->cp.quiet)
- printf(" - WCS: %s (hdu %s).\n", filename, newnode->hdu);
- free(dsize);
+ printf(" - WCS: %s (hdu %s).\n", filename,
+ newnode->hdu);
}
}
else newnode->hdu=NULL;
@@ -343,7 +177,7 @@ operands_pop(struct arithmeticparams *p, char *operator)
/* If the operand linked list has finished, then give an error and
exit. */
if(operands==NULL)
- error(EXIT_FAILURE, 0, "not enough operands for the \"%s\" operator",
+ error(EXIT_FAILURE, 0, "not enough operands for the '%s' operator",
operator);
/* Set the dataset. If filename is present then read the file
@@ -359,11 +193,14 @@ operands_pop(struct arithmeticparams *p, char *operator)
p->cp.quietmmap);
data->ndim=gal_dimension_remove_extra(data->ndim, data->dsize, NULL);
- /* Arithmetic changes the contents of a dataset, so the existing name
- (in the FITS `EXTNAME' keyword) should not be passed on beyond
- this point. Also, in Arithmetic, the `name' element is used to
- identify variables. */
- if(data->name) { free(data->name); data->name=NULL; }
+ /* Arithmetic changes the contents of a dataset, so the old name and
+ metadata (in the FITS 'EXTNAME' keyword for example) must not be
+ used beyond this point. Furthermore, in Arithmetic, the 'name'
+ element is used to identify variables (with the 'set-'
+ operator). */
+ if(data->name) { free(data->name); data->name=NULL; }
+ if(data->unit) { free(data->unit); data->unit=NULL; }
+ if(data->comment) { free(data->comment); data->comment=NULL; }
/* When the reference data structure's dimensionality is non-zero, it
means that this is not the first image read. So, write its basic
@@ -406,3 +243,16 @@ operands_pop(struct arithmeticparams *p, char *operator)
free(operands);
return data;
}
+
+
+
+
+/* Wrapper to use the 'operands_pop' function with the 'set-' operator. */
+gal_data_t *
+operands_pop_wrapper_set(void *in)
+{
+ struct gal_arithmetic_set_params *tprm
+ = (struct gal_arithmetic_set_params *)in;
+ struct arithmeticparams *p=(struct arithmeticparams *)tprm->params;
+ return operands_pop(p, "set");
+}
diff --git a/bin/arithmetic/operands.h b/bin/arithmetic/operands.h
index fcf6453..2c9d62d 100644
--- a/bin/arithmetic/operands.h
+++ b/bin/arithmetic/operands.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -32,6 +32,9 @@ operands_add(struct arithmeticparams *p, char *filename,
gal_data_t *data);
gal_data_t *
operands_pop(struct arithmeticparams *p, char *operator);
+gal_data_t *
+operands_pop_wrapper_set(void *in);
+
void
operands_set_name(struct arithmeticparams *p, char *token);
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 95f23aa..93dcbba 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -69,20 +69,20 @@ doc[] = GAL_STRINGS_TOP_HELP_INFO PROGRAM_NAME" will do
arithmetic "
"operations on one or multiple images and numbers. Simply put, the name "
"of the image along with the arithmetic operators and possible numbers "
"are given as arguments. The extensions of each input are specified with "
- "(possibly multiple) calls to the `--hdu' option."
+ "(possibly multiple) calls to the '--hdu' option."
"\n\nCurrently "PROGRAM_NAME" only supports postfix or reverse polish "
- "notation. For example to get the result of `5+6', you should write "
- "`5 6 +', or to get the average of two images, you should write `a.fits "
- "b.fits + 2 /' (or more simply use the `average' operator with "
- "`a.fits b.fits average'). Please see the manual for more information. "
+ "notation. For example to get the result of '5+6', you should write "
+ "'5 6 +', or to get the average of two images, you should write 'a.fits "
+ "b.fits + 2 /' (or more simply use the 'average' operator with "
+ "'a.fits b.fits average'). Please see the manual for more information. "
"\n\n"PROGRAM_NAME" recognizes a large collection of standard operators, "
"including basic arithmetic (e.g., +, -, x, /), mathematical (e.g., abs, "
"pow, sqrt, log), statistical (minvalue, min, max, average), comparison "
"(e.g., lt, le, gt), logical (e.g., and, or, not), the full set of bitwise "
"operators, and numeric type conversion operators to all known types. "
"Please run the command below for a complete list describing all "
- "operators (press the `SPACE' keyboard key, or arrow keys, to go down "
- "and `q' to return to the command-line):\n\n"
+ "operators (press the 'SPACE' keyboard key, or arrow keys, to go down "
+ "and 'q' to return to the command-line):\n\n"
" $ info gnuastro \"Arithmetic operators\"\n"
GAL_STRINGS_MORE_HELP_INFO
/* After the list of options: */
@@ -157,8 +157,8 @@ ui_initialize_options(struct arithmeticparams *p,
switch(cp->coptions[i].group)
{
case GAL_OPTIONS_GROUP_TESSELLATION:
- cp->coptions[i].doc=NULL; /* Necessary to remove title. */
- cp->coptions[i].flags=OPTION_HIDDEN;
+ if(cp->coptions[i].key!=GAL_OPTIONS_KEY_INTERPMETRIC)
+ cp->coptions[i].flags=OPTION_HIDDEN;
break;
}
}
@@ -174,18 +174,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct arithmeticparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -232,15 +232,15 @@ parse_opt(int key, char *arg, struct argp_state *state)
static void
ui_read_check_only_options(struct arithmeticparams *p)
{
- if(p->wcsfile)
+ if(p->wcsfile && strcmp(p->wcsfile,"none"))
{
if(gal_fits_name_is_fits(p->wcsfile)==0)
- error(EXIT_FAILURE, 0, "%s: file given to `--wcsfile' must be in "
+ error(EXIT_FAILURE, 0, "%s: file given to '--wcsfile' must be in "
"FITS format with a recognizable FITS format suffix.",
p->wcsfile);
if(p->wcshdu==NULL)
error(EXIT_FAILURE, 0, "%s: no HDU/extension specified (file given "
- "to `--wcsfile')! Please use `--wcshdu' to specify a "
+ "to '--wcsfile')! Please use '--wcshdu' to specify a "
"HDU/extension to read from", p->wcsfile);
}
}
@@ -250,7 +250,7 @@ ui_read_check_only_options(struct arithmeticparams *p)
/* Sanity check on options AND arguments. If only option values are to be
- checked, use `ui_read_check_only_options'. */
+ checked, use 'ui_read_check_only_options'. */
static void
ui_check_options_and_arguments(struct arithmeticparams *p)
{
@@ -272,11 +272,11 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
/* The input tokens are put in a lastin-firstout (simple) linked list, so
change them to the correct order so the order we pop a token is the
same order that the user input a value. Note that for the options this
- was done in `gal_options_read_config_set'. */
+ was done in 'gal_options_read_config_set'. */
gal_list_str_reverse(&p->tokens);
- /* To allow adding extensions to existing files, let the `keep' flag be
- the same as the `dontdelete'. */
+ /* To allow adding extensions to existing files, let the 'keep' flag be
+ the same as the 'dontdelete'. */
cp->keep=cp->dontdelete;
/* Set the output file name (if any is needed). Note that since the lists
@@ -286,7 +286,7 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
list. */
for(token=p->tokens; token!=NULL; token=token->next)
{
- /* Strings given to the `tofile' operator are also considered as
+ /* Strings given to the 'tofile' operator are also considered as
outputs and we should delete them before starting the parse. */
if( strncmp(OPERATOR_PREFIX_TOFILE, token->v,
OPERATOR_PREFIX_LENGTH_TOFILE) )
@@ -298,8 +298,8 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
if( gal_array_name_recognized(token->v) )
{
/* Increment the counter for FITS files (if they are
- input). Recall that the `tofile' operator can also have
- `.fits' suffixes (they are the names of the output
+ input). Recall that the 'tofile' operator can also have
+ '.fits' suffixes (they are the names of the output
files). */
if( gal_array_name_recognized_multiext(token->v) )
++nummultiext;
@@ -318,13 +318,13 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
}
/* This token is a number. Check if a negative dash was present that
- has been temporarily replaced with `NEG_DASH_REPLACE' before
+ has been temporarily replaced with 'NEG_DASH_REPLACE' before
option parsing. */
else if(token->v[0]==NEG_DASH_REPLACE && isdigit(token->v[1]) )
token->v[0]='-';
}
- /* We are on the `tofile' operator. */
+ /* We are on the 'tofile' operator. */
else
{
filename=&token->v[ OPERATOR_PREFIX_LENGTH_TOFILE ];
@@ -332,6 +332,15 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
}
}
+ /* In case no output name has been given (can happen with operators like
+ 'makenew' when the user doesn't set an output name explicity), use a
+ default name. */
+ if(p->cp.output==NULL)
+ {
+ gal_checkset_allocate_copy("arithmetic.fits", &p->cp.output);
+ gal_checkset_writable_remove(p->cp.output, cp->keep, cp->dontdelete);
+ }
+
/* Count the number of HDU values (if globalhdu isn't given) and check if
its not less than the number of input FITS images. */
if(p->globalhdu)
@@ -342,10 +351,10 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
if(numhdus<nummultiext)
error(EXIT_FAILURE, 0, "not enough HDUs. There are %zu input "
"files in formats that may contain multiple extensions (for "
- "example FITS or TIFF). Therefore, the `--hdu' (`-h') option "
+ "example FITS or TIFF). Therefore, the '--hdu' ('-h') option "
"must be called atleaset %zu times (once for each "
"multi-extension file). If the HDU value is the same for all "
- "the files, you may use `--globalhdu' (`-g') to specify a "
+ "the files, you may use '--globalhdu' ('-g') to specify a "
"single HDU to be used for any number of input files",
nummultiext, nummultiext);
}
@@ -362,7 +371,7 @@ ui_preparations(struct arithmeticparams *p)
/* In case a file is specified to read the WCS from (and ignore input
datasets), read the WCS prior to starting parsing of the arguments. */
- if(p->wcsfile)
+ if(p->wcsfile && strcmp(p->wcsfile,"none"))
{
/* Read the number of dimensions and the size of each. */
dsize=gal_fits_img_info_dim(p->wcsfile, p->wcshdu, &ndim);
@@ -377,10 +386,10 @@ ui_preparations(struct arithmeticparams *p)
}
else
fprintf(stderr, "WARNING: %s (hdu %s) didn't contain a "
- "(readable by WCSLIB) WCS.", p->wcsfile, p->wcshdu);
+ "(readable by WCSLIB) WCS.\n", p->wcsfile, p->wcshdu);
/* Correct the WCS dimensions if necessary. Note that we don't need
- the `ndim' or `dsize' any more. */
+ the 'ndim' or 'dsize' any more. */
ndim=gal_dimension_remove_extra(ndim, dsize, p->refdata.wcs);
/* Clean up. */
@@ -417,9 +426,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
arithmeticparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/arithmetic/ui.h b/bin/arithmetic/ui.h
index 6bbe04c..8a74d81 100644
--- a/bin/arithmetic/ui.h
+++ b/bin/arithmetic/ui.h
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/buildprog/Makefile.am b/bin/buildprog/Makefile.am
index fd3f917..cd29e8d 100644
--- a/bin/buildprog/Makefile.am
+++ b/bin/buildprog/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2017-2019, Free Software Foundation, Inc.
+## Copyright (C) 2017-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -24,22 +24,22 @@
## Buildprog will also need some system-specific information that is
## gathered at compile time (for example the library installation directory
## (LIBDIR) and the executive file suffix (EXEEXT).
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib \
- -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" \
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib \
+ -DLIBDIR=\"$(libdir)\" \
+ -DINCLUDEDIR=\"$(includedir)\" \
-DEXEEXT=\"$(EXEEXT)\"
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astbuildprog
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astbuildprog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astbuildprog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
# Basic program sources.
astbuildprog_SOURCES = main.c ui.c buildprog.c
@@ -56,11 +56,11 @@ EXTRA_DIST = main.h authors-cite.h args.h ui.h buildprog.h
astbuildprog.conf.in
# directories in these variables will be written into the final
# BuildProgram configuration file.
#
-# The user might give non-`-I' arguments to CPPFLAGS and non-`-L' arguments
+# The user might give non-'-I' arguments to CPPFLAGS and non-'-L' arguments
# to LDFLAGS (see bug #54346). But here, we only want these two options,
-# and nothing else. To make the check, we'll see if `$i' (the input string)
-# is the same as `$v' or not. If the string starts with `-I' or `-L', it
-# will change between the two (the `-I' or `-L' have been removed), so it
+# and nothing else. To make the check, we'll see if '$i' (the input string)
+# is the same as '$v' or not. If the string starts with '-I' or '-L', it
+# will change between the two (the '-I' or '-L' have been removed), so it
# shouldn't be the same.
astbuildprog.conf: $(top_srcdir)/bin/buildprog/astbuildprog.conf.in
cat $< > $@
@@ -93,10 +93,10 @@ astbuildprog.conf:
$(top_srcdir)/bin/buildprog/astbuildprog.conf.in
## The configuration file in BuildProgram must be built on the users's
-## system (see above). The built configuration file is needed during `make
+## system (see above). The built configuration file is needed during 'make
## check'. But the (built) configuration file should NOT be distributed in a
## tarball. Since all built files are distributed, the only way to avoid
-## the configuration file being distributed it so use a `nodist_' prefix.
+## the configuration file being distributed it so use a 'nodist_' prefix.
##
## NOTE: the man page is created in doc/Makefile.am
nodist_sysconf_DATA = astbuildprog.conf
diff --git a/bin/buildprog/args.h b/bin/buildprog/args.h
index 87872e9..4e1ba77 100644
--- a/bin/buildprog/args.h
+++ b/bin/buildprog/args.h
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -50,7 +50,7 @@ struct argp_option program_options[] =
UI_KEY_INCLUDE,
"STR",
0,
- "Directories to search for `#include's.",
+ "Directories to search for '#include's.",
GAL_OPTIONS_GROUP_INPUT,
&p->include,
GAL_TYPE_STRLL,
@@ -78,7 +78,7 @@ struct argp_option program_options[] =
UI_KEY_LINKLIB,
"STR",
0,
- "Link libraries, e.g., for libgsl: `-lgsl'.",
+ "Link libraries, e.g., for libgsl: '-lgsl'.",
GAL_OPTIONS_GROUP_INPUT,
&p->linklib,
GAL_TYPE_STRLL,
@@ -92,7 +92,7 @@ struct argp_option program_options[] =
UI_KEY_LA,
"STR",
0,
- "Libtool `.la' to use instead of default.",
+ "Libtool '.la' to use instead of default.",
GAL_OPTIONS_GROUP_INPUT,
&p->la,
GAL_TYPE_STRING,
@@ -106,7 +106,7 @@ struct argp_option program_options[] =
UI_KEY_TAG,
"STR",
0,
- "Libtool `--tag': programming language.",
+ "Libtool '--tag': programming language.",
GAL_OPTIONS_GROUP_INPUT,
&p->tag,
GAL_TYPE_STRING,
diff --git a/bin/buildprog/astbuildprog.conf.in
b/bin/buildprog/astbuildprog.conf.in
index 6d3f3cd..9788628 100644
--- a/bin/buildprog/astbuildprog.conf.in
+++ b/bin/buildprog/astbuildprog.conf.in
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astbuildprog # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/buildprog/authors-cite.h b/bin/buildprog/authors-cite.h
index 50b4df4..80cb0a6 100644
--- a/bin/buildprog/authors-cite.h
+++ b/bin/buildprog/authors-cite.h
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/buildprog/buildprog.c b/bin/buildprog/buildprog.c
index 8a67871..1542121 100644
--- a/bin/buildprog/buildprog.c
+++ b/bin/buildprog/buildprog.c
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -45,7 +45,7 @@ buildprog_as_one_string(char *opt, gal_list_str_t *list)
/* Only if we have a list. */
if(list)
{
- /* For every node in the list, we want the `opt' and a space along with
+ /* For every node in the list, we want the 'opt' and a space along with
the actual string. */
for(tmp=list; tmp!=NULL; tmp=tmp->next)
len += 1 + (opt ? strlen(opt) : 0) + strlen(tmp->v);
@@ -71,7 +71,7 @@ buildprog_as_one_string(char *opt, gal_list_str_t *list)
int
buildprog(struct buildprogparams *p)
{
- /* Note that the first node of `sourceargs' is the acutal source and the
+ /* Note that the first node of 'sourceargs' is the acutal source and the
rest are arguments to be run later. */
int retval;
char *fullla;
@@ -104,7 +104,7 @@ buildprog(struct buildprogparams *p)
if( asprintf(&optimize, "-O%s", p->optimize)<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- /* Libtool `.la' file: */
+ /* Libtool '.la' file: */
if(p->la) fullla=p->la;
else
if( asprintf(&fullla, "%s/libgnuastro.la", LIBDIR)<0 )
@@ -122,10 +122,10 @@ buildprog(struct buildprogparams *p)
warning ? warning : "",
p->debug ? "-g" : "",
optimize ? optimize : "",
- cppflags ? cppflags : "",
include ? include : "",
- ldflags ? ldflags : "",
+ cppflags ? cppflags : "",
linkdir ? linkdir : "",
+ ldflags ? ldflags : "",
p->sourceargs->v,
linklib ?linklib : "",
INCLUDEDIR,
diff --git a/bin/buildprog/buildprog.h b/bin/buildprog/buildprog.h
index d6ba191..2e7918e 100644
--- a/bin/buildprog/buildprog.h
+++ b/bin/buildprog/buildprog.h
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/buildprog/main.c b/bin/buildprog/main.c
index b7b868f..354f044 100644
--- a/bin/buildprog/main.c
+++ b/bin/buildprog/main.c
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/buildprog/main.h b/bin/buildprog/main.h
index 0a43dc0..a2dcbe2 100644
--- a/bin/buildprog/main.h
+++ b/bin/buildprog/main.h
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -48,7 +48,7 @@ struct buildprogparams
gal_list_str_t *include; /* Libraries to link against. */
gal_list_str_t *linkdir; /* Libraries to link against. */
gal_list_str_t *linklib; /* Libraries to link against. */
- char *la; /* Libtool `.la' instead of default. */
+ char *la; /* Libtool '.la' instead of default. */
char *cc; /* C compiler to use. */
uint8_t noenv;
diff --git a/bin/buildprog/ui.c b/bin/buildprog/ui.c
index 83e2ef4..56d635e 100644
--- a/bin/buildprog/ui.c
+++ b/bin/buildprog/ui.c
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -65,7 +65,7 @@ doc[] = GAL_STRINGS_TOP_HELP_INFO PROGRAM_NAME" will compile
and run a "
"depends on. Hence you do not have to worry about explicitly linking "
"with CFITSIO for example if you want to work on a FITS file, or with "
"GSL if you want to use GNU Scientific Library's functions. The standard "
- "compiler options of `-I', `-L', and `-l' are also available for further "
+ "compiler options of '-I', '-L', and '-l' are also available for further "
"customization of the build.\n"
GAL_STRINGS_MORE_HELP_INFO
/* After the list of options: */
@@ -130,9 +130,9 @@ ui_initialize_options(struct buildprogparams *p,
cp->coptions[i].mandatory=GAL_OPTIONS_NOT_MANDATORY;
break;
- /* `--ignorecase's default short format is `I', but here we want to
- follow the compiler format, hence we need `I' for
- `include'. Therefore, here, we'll change the key for `include'
+ /* '--ignorecase's default short format is 'I', but here we want to
+ follow the compiler format, hence we need 'I' for
+ 'include'. Therefore, here, we'll change the key for 'include'
to some large number just to avoid confusion.*/
case GAL_OPTIONS_KEY_IGNORECASE:
cp->coptions[i].key=20000;
@@ -163,18 +163,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct buildprogparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -219,21 +219,21 @@ parse_opt(int key, char *arg, struct argp_state *state)
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct buildprogparams *p)
{
size_t len;
- /* If an `.la' file is given, make sure it has the correct suffix. */
+ /* If an '.la' file is given, make sure it has the correct suffix. */
if(p->la)
{
len=strlen(p->la);
if(len>=4)
if(strcmp(&p->la[len-3], ".la"))
- error(EXIT_FAILURE, 0, "`%s' is not a Libtool control file name "
- "(with a `.la' suffix). The file name given to the `--la' "
- "(`-a') option must be a Libtool control file", p->la);
+ error(EXIT_FAILURE, 0, "'%s' is not a Libtool control file name "
+ "(with a '.la' suffix). The file name given to the '--la' "
+ "('-a') option must be a Libtool control file", p->la);
}
}
@@ -279,23 +279,23 @@ ui_preparations(struct buildprogparams *p)
options.c). */
gal_list_str_reverse(&p->sourceargs);
- /* Set the final output name. `EXEEXT' comes from the configuration
- script (given by BuildProgram's `Makefile.am'). */
+ /* Set the final output name. 'EXEEXT' comes from the configuration
+ script (given by BuildProgram's 'Makefile.am'). */
if(p->cp.output==NULL)
p->cp.output=gal_checkset_automatic_output(&p->cp, p->sourceargs->v,
EXEEXT);
- /* Set the C compiler. Later we can add a check to make sure that `cc' is
+ /* Set the C compiler. Later we can add a check to make sure that 'cc' is
actually in the PATH. */
if(p->cc==NULL)
{ /* No C compiler chosen. */
if(p->noenv==0)
{
- p->cc=getenv("CC"); /* First check for `CC'. */
+ p->cc=getenv("CC"); /* First check for 'CC'. */
if(p->cc==NULL)
- p->cc=getenv("GCC"); /* Then check for `GCC'. */
+ p->cc=getenv("GCC"); /* Then check for 'GCC'. */
}
- if(p->cc==NULL) p->cc="gcc"; /* Default: `gcc'. */
+ if(p->cc==NULL) p->cc="gcc"; /* Default: 'gcc'. */
}
}
@@ -327,9 +327,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
buildprogparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/buildprog/ui.h b/bin/buildprog/ui.h
index 53d9f64..64c8519 100644
--- a/bin/buildprog/ui.h
+++ b/bin/buildprog/ui.h
@@ -5,7 +5,7 @@ BuildProgram is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convertt/Makefile.am b/bin/convertt/Makefile.am
index 1935ff1..33f2b3c 100644
--- a/bin/convertt/Makefile.am
+++ b/bin/convertt/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astconvertt
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astconvertt_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astconvertt_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astconvertt_SOURCES = main.c ui.c convertt.c color.c
diff --git a/bin/convertt/args.h b/bin/convertt/args.h
index 4618a33..5f66e04 100644
--- a/bin/convertt/args.h
+++ b/bin/convertt/args.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -191,7 +191,7 @@ struct argp_option program_options[] =
UI_KEY_CHANGE,
"STR",
0,
- "Change pixel values `from_1:to_1,from_2:to_2`.",
+ "Change pixel values 'from_1:to_1,from_2:to_2'.",
UI_GROUP_FLUX,
&p->changestr,
GAL_TYPE_STRING,
diff --git a/bin/convertt/astconvertt.conf b/bin/convertt/astconvertt.conf
index 07603d3..be36603 100644
--- a/bin/convertt/astconvertt.conf
+++ b/bin/convertt/astconvertt.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astconvertt # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/convertt/authors-cite.h b/bin/convertt/authors-cite.h
index 7470718..df6fa87 100644
--- a/bin/convertt/authors-cite.h
+++ b/bin/convertt/authors-cite.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/convertt/color.c b/bin/convertt/color.c
index bd34cb7..f9731c7 100644
--- a/bin/convertt/color.c
+++ b/bin/convertt/color.c
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -109,7 +109,7 @@ color_from_mono_hsv(struct converttparams *p)
channel->dsize, channel->wcs, 0, p->cp.minmapsize,
p->cp.quietmmap, "BLUE", NULL, "Blue color channel.");
- /* Start the conversion. Note that the "Choroma" (`C') is fixed by our
+ /* Start the conversion. Note that the "Choroma" ('C') is fixed by our
definition. */
r=R->array;
g=G->array;
@@ -195,7 +195,7 @@ color_from_mono_sls(struct converttparams *p)
channel->dsize, channel->wcs, 0, p->cp.minmapsize,
p->cp.quietmmap, "BLUE", NULL, "Blue color channel.");
- /* Start the conversion. Note that the "Choroma" (`C') is fixed by our
+ /* Start the conversion. Note that the "Choroma" ('C') is fixed by our
definition. */
r=R->array;
g=G->array;
@@ -206,7 +206,9 @@ color_from_mono_sls(struct converttparams *p)
if(isnan(*f))
*r=*g=*b=0.0;
else
- switch( (int)((*f-min)/(max-min)*200) )
+ switch( p->colormap->status==COLOR_SLS
+ ? (int)((*f-min)/(max-min)*200)
+ : 200 - (int)((*f-min)/(max-min)*200) )
{
case 0: *r=0.000000; *g=0.000000; *b=0.000000; break;
case 1: *r=0.043442; *g=0.000000; *b=0.052883; break;
@@ -463,7 +465,7 @@ color_from_mono_viridis(struct converttparams *p)
channel->dsize, channel->wcs, 0, p->cp.minmapsize,
p->cp.quietmmap, "BLUE", NULL, "Blue color channel.");
- /* Start the conversion. Note that the "Choroma" (`C') is fixed by our
+ /* Start the conversion. Note that the "Choroma" ('C') is fixed by our
definition. */
r=R->array;
g=G->array;
@@ -764,9 +766,10 @@ color_map_prepare(struct converttparams *p)
switch(p->colormap->status)
{
case COLOR_HSV: color_from_mono_hsv(p); break;
- case COLOR_SLS: color_from_mono_sls(p); break;
case COLOR_VIRIDIS: color_from_mono_viridis(p); break;
case COLOR_GRAY: convertt_scale_to_uchar(p); break;
+ case COLOR_SLS:
+ case COLOR_SLS_INVERSE: color_from_mono_sls(p); break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
"the problem. The value %d is not a recognized color-space "
@@ -869,12 +872,12 @@ color_rgb_to_hsv(struct converttparams *p)
if( *h<0.0 ) *h += 360.0;
}
else
- /* When `max==0', then *r=*g=*b=0, so s=h=0. */
+ /* When 'max==0', then *r=*g=*b=0, so s=h=0. */
*s=*h=0.0;
}
else
/* When there is no difference, then its actually a grayscale
- dataset, so `*v' is the only parameter that matters. */
+ dataset, so '*v' is the only parameter that matters. */
*s=*h=0.0;
diff --git a/bin/convertt/color.h b/bin/convertt/color.h
index 7b477ea..54655ea 100644
--- a/bin/convertt/color.h
+++ b/bin/convertt/color.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convertt/convertt.c b/bin/convertt/convertt.c
index 513f593..64bdd45 100644
--- a/bin/convertt/convertt.c
+++ b/bin/convertt/convertt.c
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -71,7 +71,7 @@ convertt_change(struct converttparams *p)
for(channel=p->chll; channel!=NULL; channel=channel->next)
{
/* Make a condition array: all pixels with a value equal to
- `change->from' will be set as 1 in this array. */
+ 'change->from' will be set as 1 in this array. */
cond=gal_arithmetic(GAL_ARITHMETIC_OP_EQ, 1, GAL_ARITHMETIC_NUMOK,
channel, change->from);
@@ -103,7 +103,7 @@ convertt_trunc_function(int operator, gal_data_t *data,
gal_data_t *value)
/* Make a condition array: all pixels with a value equal to
- `change->from' will be set as 1 in this array. */
+ 'change->from' will be set as 1 in this array. */
cond=gal_arithmetic(operator, 1, GAL_ARITHMETIC_NUMOK, data, value);
@@ -115,7 +115,7 @@ convertt_trunc_function(int operator, gal_data_t *data,
gal_data_t *value)
data structure must not have changed. */
if(out!=data)
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to solve the "
- "problem. The `out' and `data' pointers are the same", __func__,
+ "problem. The 'out' and 'data' pointers are the same", __func__,
PACKAGE_BUGREPORT);
@@ -246,7 +246,7 @@ convertt_scale_to_uchar(struct converttparams *p)
{
if(channel->status==0)
{
- /* Convert the values into a range between `0' and `maxbyte'. */
+ /* Convert the values into a range between '0' and 'maxbyte'. */
ff=(f=channel->array)+size;
if(p->invert)
{
@@ -337,7 +337,7 @@ convertt(struct converttparams *p)
/* Plain text: only one channel is acceptable. */
case OUT_FORMAT_TXT:
gal_checkset_writable_remove(p->cp.output, 0, p->cp.dontdelete);
- gal_txt_write(p->chll, NULL, p->cp.output, 0);
+ gal_txt_write(p->chll, NULL, NULL, p->cp.output, 0);
break;
/* JPEG: */
diff --git a/bin/convertt/convertt.h b/bin/convertt/convertt.h
index d693421..96e2bb7 100644
--- a/bin/convertt/convertt.h
+++ b/bin/convertt/convertt.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convertt/main.c b/bin/convertt/main.c
index 06976c3..6935f9b 100644
--- a/bin/convertt/main.c
+++ b/bin/convertt/main.c
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convertt/main.h b/bin/convertt/main.h
index e051602..0d5cda6 100644
--- a/bin/convertt/main.h
+++ b/bin/convertt/main.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -56,6 +56,7 @@ enum colorspace_names
COLOR_RGB,
COLOR_HSV,
COLOR_SLS,
+ COLOR_SLS_INVERSE,
COLOR_VIRIDIS,
COLOR_GRAY,
};
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index f5f1df7..d6e306b 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -172,18 +172,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct converttparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -242,17 +242,19 @@ ui_colormap_sanity_check(struct converttparams *p)
else if( !strcmp(strarr[0],"viridis")) { ccode=COLOR_VIRIDIS; nparams=0; }
else if( !strcmp(strarr[0],"gray") || !strcmp(strarr[0],"grey"))
{ ccode=COLOR_GRAY; nparams=0; }
+ else if( !strcmp(strarr[0],"sls-inverse"))
+ { ccode=COLOR_SLS_INVERSE; nparams=0; }
else
- error(EXIT_FAILURE, 0, "`%s' not recognized as a colormap given "
- "to `--colormap'", strarr[0]);
+ error(EXIT_FAILURE, 0, "'%s' not recognized as a colormap given "
+ "to '--colormap'", strarr[0]);
p->colormap->status=ccode;
/* Check if the proper number of parameters are given for this color
space. Note that the actual colorspace name is the first element in
- `monotocolor'. */
+ 'monotocolor'. */
if(p->colormap->size!=1 && p->colormap->size != (nparams+1) )
- error(EXIT_FAILURE, 0, "%zu parameters given to `--monotocolor' for "
- "the `%s' color space (which needs %zu)",
+ error(EXIT_FAILURE, 0, "%zu parameters given to '--monotocolor' for "
+ "the '%s' color space (which needs %zu)",
p->colormap->size-1, strarr[0], nparams);
/* Allocate the necessary space for the parameters (when
@@ -272,7 +274,7 @@ ui_colormap_sanity_check(struct converttparams *p)
case COLOR_HSV: farray[0]=0; farray[1]=360; break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at "
- "%s to fix the problem. The value `%d' is not "
+ "%s to fix the problem. The value '%d' is not "
"recognized for a color space that needs default "
"parameters", __func__, PACKAGE_BUGREPORT,
p->colormap->status);
@@ -282,8 +284,8 @@ ui_colormap_sanity_check(struct converttparams *p)
{
/* Increment the array pointer (temporarily) so we can read
the rest of the parameters as float32. Note that we can't
- use `+=' because it is a `void *' pointer. We'll have to
- use `strarry', because its type is defined. */
+ use '+=' because it is a 'void *' pointer. We'll have to
+ use 'strarry', because its type is defined. */
p->colormap->size-=1;
p->colormap->array = strarr + 1;
p->colormap->next=gal_data_copy_to_new_type(p->colormap,
@@ -309,7 +311,7 @@ ui_colormap_sanity_check(struct converttparams *p)
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct converttparams *p)
{
@@ -321,7 +323,7 @@ ui_read_check_only_options(struct converttparams *p)
{
p->fluxlow=gal_data_copy_string_to_number(p->fluxlowstr);
if(p->fluxlow==NULL)
- error(EXIT_FAILURE, 0, "value to the `--fluxlow' (`-L', %s) "
+ error(EXIT_FAILURE, 0, "value to the '--fluxlow' ('-L', %s) "
"couldn't be read as a number", p->fluxlowstr);
}
@@ -329,7 +331,7 @@ ui_read_check_only_options(struct converttparams *p)
{
p->fluxhigh=gal_data_copy_string_to_number(p->fluxhighstr);
if(p->fluxhigh==NULL)
- error(EXIT_FAILURE, 0, "value to the `--fluxhigh' (`-H', %s) "
+ error(EXIT_FAILURE, 0, "value to the '--fluxhigh' ('-H', %s) "
"couldn't be read as a number", p->fluxhighstr);
}
@@ -339,8 +341,8 @@ ui_read_check_only_options(struct converttparams *p)
p->fluxhigh, p->fluxlow);
if( *((unsigned char *)cond->array) == 0 )
- error(EXIT_FAILURE, 0, "The value of `--fluxlow' must be less "
- "than `--fluxhigh'");
+ error(EXIT_FAILURE, 0, "The value of '--fluxlow' must be less "
+ "than '--fluxhigh'");
gal_data_free(cond);
}
@@ -357,8 +359,8 @@ ui_read_check_only_options(struct converttparams *p)
static void
ui_check_options_and_arguments(struct converttparams *p)
{
- /* Reverse the `inputnames' linked list if it was given (recall that we
- also accept input from the standard input). Note that the `hdu' linked
+ /* Reverse the 'inputnames' linked list if it was given (recall that we
+ also accept input from the standard input). Note that the 'hdu' linked
list was reversed during option parsing, so we don't need to do it
here any more. */
gal_list_str_reverse(&p->inputnames);
@@ -394,7 +396,7 @@ ui_make_change_struct(char *arg)
size_t len=0, counter=0;
struct change *out=NULL, *last=NULL, *ch;
- /* First set all the delimiters to `\0' and count the number of
+ /* First set all the delimiters to '\0' and count the number of
characters in the full string. */
while(*p!='\0')
{
@@ -415,11 +417,11 @@ ui_make_change_struct(char *arg)
++counter;
data=gal_data_copy_string_to_number(p);
if(data==NULL)
- error(EXIT_FAILURE, 0, "`%s' (input number %zu to the "
- "`--change' option) couldn't be read as a number", p,
+ error(EXIT_FAILURE, 0, "'%s' (input number %zu to the "
+ "'--change' option) couldn't be read as a number", p,
counter);
- /* Go to the end of this number (until you reach a `\0'). */
+ /* Go to the end of this number (until you reach a '\0'). */
while(*p!='\0') {++p; continue;}
/* Put the data structure in the correct place. When the counter is
@@ -430,15 +432,15 @@ ui_make_change_struct(char *arg)
errno=0;
ch=malloc(sizeof *ch);
if(ch==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `ch'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'ch'",
__func__, sizeof *ch);
/* If the last structure has already been defined (!=NULL)
- then we should set its next element to `ch' and change it
- to point to `ch'. On the other hand, when this is the
- first structure to be created, then `last==NULL', so to
- start off the process, we should put `ch' into both the
- `out' and `last' lists.. */
+ then we should set its next element to 'ch' and change it
+ to point to 'ch'. On the other hand, when this is the
+ first structure to be created, then 'last==NULL', so to
+ start off the process, we should put 'ch' into both the
+ 'out' and 'last' lists.. */
if(last)
{
last->next=ch;
@@ -447,7 +449,7 @@ ui_make_change_struct(char *arg)
else
out=last=ch;
- /* Put `data' in the `from' element, and since this is the
+ /* Put 'data' in the 'from' element, and since this is the
last structure, set its next element to NULL. */
last->from=data;
last->next=NULL;
@@ -520,7 +522,7 @@ ui_make_channels_ll(struct converttparams *p)
hdu=gal_list_str_pop(&p->hdus);
else
error(EXIT_FAILURE, 0, "not enough HDUs. Every input FITS image "
- "needs a HDU, you can use the `--hdu' (`-h') option once "
+ "needs a HDU, you can use the '--hdu' ('-h') option once "
"for each input FITS image (in the same order)");
/* Read in the array and its WCS information. */
@@ -639,15 +641,15 @@ ui_prepare_input_channels(struct converttparams *p)
/* If there are multiple color channels, then ignore the monotocolor
option if it is given. But if there is only one, make sure that the
- `colormap' option is actually given.*/
+ 'colormap' option is actually given.*/
if( p->numch==1 )
{
if( p->colormap==NULL )
error(EXIT_FAILURE, 0, "no colormap! When there is only one input "
"channel, it is necessary to specify a color map. For "
- "example `gray', `hsv', `viridis' or `sls'.\n\n"
+ "example 'gray', 'hsv', 'viridis' or 'sls'.\n\n"
"For more on ConvertType's color mapping, see the "
- "description under `--colormap' in the Gnuastro book:\n\n"
+ "description under '--colormap' in the Gnuastro book:\n\n"
" $ info astconvertt");
}
else if( p->numch>1 && p->colormap )
@@ -728,7 +730,7 @@ ui_prepare_input_channels(struct converttparams *p)
}
/* This is the final (to be used) data structure, so keep its pointer
- in case the next one is blank and this structure's `next' element
+ in case the next one is blank and this structure's 'next' element
must be corrected. */
prev=tmp;
}
@@ -738,7 +740,7 @@ ui_prepare_input_channels(struct converttparams *p)
-/* We know cp->output is a known suffix, we just don't know if it has a `.`
+/* We know cp->output is a known suffix, we just don't know if it has a '.'
before it or not. If it doesn't, one will be added to it and the output
name will be set using the automatic output function. */
void
@@ -755,7 +757,7 @@ ui_add_dot_use_automatic_output(struct converttparams *p)
break;
}
- /* If the suffix does not start with a `.', put one there. */
+ /* If the suffix does not start with a '.', put one there. */
if(suffix[0]!='.')
{
if( asprintf(&tmp, ".%s", suffix)<0 )
@@ -773,7 +775,7 @@ ui_add_dot_use_automatic_output(struct converttparams *p)
/* Set output name, not that for ConvertType, the output option value is
- mandatory (in `args.h'). So by the time the program reaches here, we
+ mandatory (in 'args.h'). So by the time the program reaches here, we
know it exists. */
static void
ui_set_output(struct converttparams *p)
@@ -793,11 +795,11 @@ ui_set_output(struct converttparams *p)
{
/* Small sanity checks. */
if(p->quality == GAL_BLANK_UINT8)
- error(EXIT_FAILURE, 0, "the `--quality' (`-u') option is necessary "
+ error(EXIT_FAILURE, 0, "the '--quality' ('-u') option is necessary "
"for jpeg outputs, but it has not been given");
if(p->quality > 100)
- error(EXIT_FAILURE, 0, "`%u' is larger than 100. The value to the "
- "`--quality' (`-u') option must be between 1 and 100 "
+ error(EXIT_FAILURE, 0, "'%u' is larger than 100. The value to the "
+ "'--quality' ('-u') option must be between 1 and 100 "
"(inclusive)", p->quality);
/* Preparations. */
@@ -816,8 +818,8 @@ ui_set_output(struct converttparams *p)
else if(gal_eps_name_is_eps(cp->output))
{
if(p->borderwidth==0 && p->widthincm==0)
- error(EXIT_FAILURE, 0, "at least one of `--widthincm' (`-u'), or "
- "`--borderwidth (`-b') options are necessary for an EPS "
+ error(EXIT_FAILURE, 0, "at least one of '--widthincm' ('-u'), or "
+ "'--borderwidth ('-b') options are necessary for an EPS "
"output");
p->outformat=OUT_FORMAT_EPS;
if( gal_eps_suffix_is_eps(cp->output) )
@@ -828,8 +830,8 @@ ui_set_output(struct converttparams *p)
else if(gal_pdf_name_is_pdf(cp->output))
{
if(p->borderwidth==0 && p->widthincm==0)
- error(EXIT_FAILURE, 0, "at least one of `--widthincm' (`-u'), or "
- "`--borderwidth (`-b') options are necessary for a PDF "
+ error(EXIT_FAILURE, 0, "at least one of '--widthincm' ('-u'), or "
+ "'--borderwidth ('-b') options are necessary for a PDF "
"output");
p->outformat=OUT_FORMAT_PDF;
if( gal_pdf_suffix_is_pdf(cp->output) )
@@ -841,7 +843,7 @@ ui_set_output(struct converttparams *p)
{
p->outformat=OUT_FORMAT_TXT;
- /* If the given value is `stdout', then set p->cp.output to NULL, so
+ /* If the given value is 'stdout', then set p->cp.output to NULL, so
the result will be printed to the standard output. */
if( !strcmp(p->cp.output, "stdout") )
{
@@ -851,8 +853,8 @@ ui_set_output(struct converttparams *p)
else
{
/* Plain text files don't have any unique set of suffixes. So,
- here, we will just adopt two of the most common ones: `txt' or
- `dat'. If the output is just one of these two suffixes, then
+ here, we will just adopt two of the most common ones: 'txt' or
+ 'dat'. If the output is just one of these two suffixes, then
we will use automatic output to generate the full name,
otherwise, we'll just take the user's given value as the
filename. */
@@ -863,7 +865,7 @@ ui_set_output(struct converttparams *p)
/* If output type is not an image, there should only be one color
channel: */
if(p->numch>1)
- error(EXIT_FAILURE, 0, "text output (`--output=%s`) can only be "
+ error(EXIT_FAILURE, 0, "text output ('--output=%s') can only be "
"completed with one input color channel. You have given "
"%zu. Note that some formats (for example JPEG) can have "
"more than one color channel in each file. You can first "
@@ -923,9 +925,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
converttparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/convertt/ui.h b/bin/convertt/ui.h
index c31a8e6..f1deb68 100644
--- a/bin/convertt/ui.h
+++ b/bin/convertt/ui.h
@@ -5,7 +5,7 @@ ConvertType is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convolve/Makefile.am b/bin/convolve/Makefile.am
index a5c42a3..1721343 100644
--- a/bin/convolve/Makefile.am
+++ b/bin/convolve/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astconvolve
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astconvolve_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astconvolve_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astconvolve_SOURCES = main.c ui.c convolve.c
diff --git a/bin/convolve/args.h b/bin/convolve/args.h
index 193b439..08654f0 100644
--- a/bin/convolve/args.h
+++ b/bin/convolve/args.h
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -35,7 +35,7 @@ struct argp_option program_options[] =
{
"kernel",
UI_KEY_KERNEL,
- "STR",
+ "FITS",
0,
"File name of kernel for convolution.",
GAL_OPTIONS_GROUP_INPUT,
@@ -166,7 +166,7 @@ struct argp_option program_options[] =
UI_KEY_DOMAIN,
"STR",
0,
- "Convolution domain: `spatial', `frequency'.",
+ "Convolution domain: 'spatial', 'frequency'.",
GAL_OPTIONS_GROUP_OPERATING_MODE,
&p->domainstr,
GAL_TYPE_STRING,
diff --git a/bin/convolve/astconvolve.conf b/bin/convolve/astconvolve.conf
index fd78edc..fa4876b 100644
--- a/bin/convolve/astconvolve.conf
+++ b/bin/convolve/astconvolve.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astconvolve # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/convolve/authors-cite.h b/bin/convolve/authors-cite.h
index 4f842f5..69df96c 100644
--- a/bin/convolve/authors-cite.h
+++ b/bin/convolve/authors-cite.h
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/convolve/convolve.c b/bin/convolve/convolve.c
index 8db100b..881dcae 100644
--- a/bin/convolve/convolve.c
+++ b/bin/convolve/convolve.c
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -77,7 +77,7 @@ complextoreal(double *c, size_t size, int action, double
**output)
break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s so we can "
- "correct it. The `action' code %d is not recognized", __func__,
+ "correct it. The 'action' code %d is not recognized", __func__,
PACKAGE_BUGREPORT, action);
}
}
@@ -245,7 +245,7 @@ frequency_make_padded_complex(struct convolveparams *p)
roundoff errors.
NOTE: The padding to the input image (on the first axis for example)
- was `p->kernel->dsize[0]-1'. Since `p->kernel->dsize[0]' is
+ was 'p->kernel->dsize[0]-1'. Since 'p->kernel->dsize[0]' is
always odd, the padding will always be even. */
void
removepaddingcorrectroundoff(struct convolveparams *p)
@@ -274,7 +274,7 @@ removepaddingcorrectroundoff(struct convolveparams *p)
hi1 = ( p->kernel->dsize[1] - 1 )/2;
}
- /* To start with, `start' points to the first pixel in the final
+ /* To start with, 'start' points to the first pixel in the final
image: */
start=&rpad[hi0*ps1+hi1];
for(i=0;i<isize[0];++i)
@@ -373,21 +373,21 @@ correctdeconvolve(struct convolveparams *p, double
**spatial)
errno=0;
n=malloc(ps0*ps1*sizeof *n);
if(n==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `n'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'n'",
__func__, ps0*ps1*sizeof *n);
/* Put the elements in their proper place: For example in one
- dimention where the values are actually the true distances:
+ dimension where the values are actually the true distances:
s[0]=0, s[1]=1, s[2]=2, s[3]=3, s[4]=4, s[5]=5
- We want the value 0 to be in the `center'. Note that `s' is
+ We want the value 0 to be in the 'center'. Note that 's' is
periodic, for example the next 6 elements have distances:
s[6]=0, s[7]=1, s[8]=2, s[9]=3, s[10]=4, s[11]=5
- So a `center'ed array would be like:
+ So a 'center'ed array would be like:
s[0]=4, s[1]=5, s[2]=0, s[3]=1, s[4]=2, s[5]=3
@@ -520,6 +520,7 @@ twodimensionfft(struct convolveparams *p, struct
fftonthreadparams *fp,
{
int err;
pthread_t t; /* All thread ids saved in this, not used. */
+ char *mmapname=NULL;
pthread_attr_t attr;
pthread_barrier_t b;
size_t i, nb, *indexs, thrdcols;
@@ -531,7 +532,7 @@ twodimensionfft(struct convolveparams *p, struct
fftonthreadparams *fp,
else if(forward1backwardn1==-1) multiple=1;
else
error(EXIT_FAILURE, 0, "%s: a bug! The value of the variable "
- "`forward1backwardn1' is %d not 1 or 2. Please contact us at %s "
+ "'forward1backwardn1' is %d not 1 or 2. Please contact us at %s "
"so we can find the cause of the problem and fix it", __func__,
forward1backwardn1, PACKAGE_BUGREPORT);
@@ -539,7 +540,10 @@ twodimensionfft(struct convolveparams *p, struct
fftonthreadparams *fp,
/* ==================== */
/* 1D FFT on each row. */
/* ==================== */
- gal_threads_dist_in_threads(multiple*p->ps0, nt, &indexs, &thrdcols);
+ mmapname=gal_threads_dist_in_threads(multiple*p->ps0, nt,
+ p->input->minmapsize,
+ p->cp.quietmmap,
+ &indexs, &thrdcols);
if(nt==1)
{
fp[0].stride=1;
@@ -577,15 +581,21 @@ twodimensionfft(struct convolveparams *p, struct
fftonthreadparams *fp,
pthread_attr_destroy(&attr);
pthread_barrier_destroy(&b);
}
- free(indexs);
+
+ /* Clean up. */
+ if(mmapname) gal_pointer_mmap_free(&mmapname, p->cp.quietmmap);
+ else free(indexs);
/* ====================== */
/* 1D FFT on each column. */
/* ====================== */
- /* No comments, exact duplicate, except the p->ps1s! */
- gal_threads_dist_in_threads(multiple*p->ps1, nt, &indexs, &thrdcols);
+ /* No comments, exact duplicate of above, except the p->ps1s! */
+ mmapname=gal_threads_dist_in_threads(multiple*p->ps1, nt,
+ p->input->minmapsize,
+ p->cp.quietmmap,
+ &indexs, &thrdcols);
if(nt==1)
{
fp[0].stride=p->ps1;
@@ -614,7 +624,10 @@ twodimensionfft(struct convolveparams *p, struct
fftonthreadparams *fp,
pthread_attr_destroy(&attr);
pthread_barrier_destroy(&b);
}
- free(indexs);
+
+ /* Clean up, note that 'indexs' may be memory-mapped. */
+ if(mmapname) gal_pointer_mmap_free(&mmapname, p->cp.quietmmap);
+ else free(indexs);
}
@@ -800,7 +813,7 @@ convolve(struct convolveparams *p)
/* Save the output (which is in p->input) array. */
if(p->input->ndim==1)
- gal_table_write(p->input, NULL, p->cp.tableformat, p->cp.output,
+ gal_table_write(p->input, NULL, NULL, p->cp.tableformat, p->cp.output,
"CONVOLVED", 0);
else
gal_fits_img_write_to_type(p->input, cp->output, NULL, PROGRAM_NAME,
diff --git a/bin/convolve/convolve.h b/bin/convolve/convolve.h
index fcd4c67..27f2771 100644
--- a/bin/convolve/convolve.h
+++ b/bin/convolve/convolve.h
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convolve/main.c b/bin/convolve/main.c
index f2eb0c5..877130d 100644
--- a/bin/convolve/main.c
+++ b/bin/convolve/main.c
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convolve/main.h b/bin/convolve/main.h
index 5fca63c..83888f0 100644
--- a/bin/convolve/main.h
+++ b/bin/convolve/main.h
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index c6c4f2e..e466975 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -147,18 +147,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct convolveparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -217,8 +217,8 @@ ui_read_check_only_options(struct convolveparams *p)
else if( !strcmp("frequency", p->domainstr) )
p->domain=CONVOLVE_DOMAIN_FREQUENCY;
else
- error(EXIT_FAILURE, 0, "domain value `%s' not recognized. Please use "
- "either `spatial' or `frequency'", p->domainstr);
+ error(EXIT_FAILURE, 0, "domain value '%s' not recognized. Please use "
+ "either 'spatial' or 'frequency'", p->domainstr);
/* If we are in the spatial domain, make sure that the necessary
@@ -227,10 +227,10 @@ ui_read_check_only_options(struct convolveparams *p)
if( cp->tl.tilesize==NULL || cp->tl.numchannels==NULL )
{
if( cp->tl.tilesize==NULL && cp->tl.numchannels==NULL )
- error(EXIT_FAILURE, 0, "in spatial convolution, `--numchannels' "
- "and `--tilesize' are mandatory");
+ error(EXIT_FAILURE, 0, "in spatial convolution, '--numchannels' "
+ "and '--tilesize' are mandatory");
else
- error(EXIT_FAILURE, 0, "in spatial convolution, `--%s' is "
+ error(EXIT_FAILURE, 0, "in spatial convolution, '--%s' is "
"mandatory: you should use it to set the %s",
cp->tl.tilesize ? "numchannels" : "tilesize",
( cp->tl.tilesize
@@ -258,7 +258,7 @@ ui_check_options_and_arguments(struct convolveparams *p)
if( p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the input is a "
"FITS file, a HDU must also be specified, you can use "
- "the `--hdu' (`-h') option and give it the HDU number "
+ "the '--hdu' ('-h') option and give it the HDU number "
"(starting from zero), extension name, or anything "
"acceptable by CFITSIO");
@@ -267,7 +267,7 @@ ui_check_options_and_arguments(struct convolveparams *p)
p->hdu_type=gal_fits_hdu_format(p->filename, p->cp.hdu);
if(p->hdu_type==IMAGE_HDU && p->column)
error(EXIT_FAILURE, 0, "%s (hdu: %s): is a FITS image "
- "extension. The `--column' option is only applicable "
+ "extension. The '--column' option is only applicable "
"to tables.", p->filename, p->cp.hdu);
}
}
@@ -281,7 +281,7 @@ ui_check_options_and_arguments(struct convolveparams *p)
if( p->khdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the kernel is a "
"FITS file, a HDU must also be specified, you can use "
- "the `--khdu' (`-u') option and give it the HDU number "
+ "the '--khdu' ('-u') option and give it the HDU number "
"(starting from zero), extension name, or anything "
"acceptable by CFITSIO");
@@ -290,7 +290,7 @@ ui_check_options_and_arguments(struct convolveparams *p)
kernel_type=gal_fits_hdu_format(p->kernelname, p->khdu);
if(kernel_type==IMAGE_HDU && p->kernelcolumn)
error(EXIT_FAILURE, 0, "%s (hdu: %s): is a FITS image "
- "extension. The `--kernelcolumn' option is only "
+ "extension. The '--kernelcolumn' option is only "
"applicable to tables.", p->kernelname, p->khdu);
}
}
@@ -357,13 +357,13 @@ ui_read_column(struct convolveparams *p, int i0k1)
error(EXIT_FAILURE, 0, "%s is a table containing more than one "
"column. However, the specific column to work on isn't "
"specified.\n\n"
- "Please use the `--column' (`-c') or `--kernelcolumn' "
+ "Please use the '--column' ('-c') or '--kernelcolumn' "
"options (depending on which dataset it is) to specify a "
"column. You can either give it the column number "
"(couting from 1), or a match/search in its meta-data (e.g., "
"column names).\n\n"
"For more information, please run the following command "
- "(press the `SPACE' key to go down and `q' to return to the "
+ "(press the 'SPACE' key to go down and 'q' to return to the "
"command-line):\n\n"
" $ info gnuastro \"Selecting table columns\"\n",
( filename
@@ -455,7 +455,7 @@ ui_read_input(struct convolveparams *p)
-/* Read the kernel. VERY IMPORTANT: We can't use the `fits_img_read_kernel'
+/* Read the kernel. VERY IMPORTANT: We can't use the 'fits_img_read_kernel'
because the Convolve program also does de-convolution. */
static void
ui_read_kernel(struct convolveparams *p)
@@ -524,12 +524,12 @@ ui_preparations(struct convolveparams *p)
if( gal_blank_present(p->input, 1) )
fprintf(stderr, "\n----------------------------------------\n"
"######## %s WARNING ########\n"
- "There are blank pixels in `%s' (hdu: `%s') and you have "
+ "There are blank pixels in '%s' (hdu: '%s') and you have "
"asked for frequency domain convolution. As a result, all "
- "the pixels in the output (`%s') will be blank. Only "
+ "the pixels in the output ('%s') will be blank. Only "
"spatial domain convolution can account for blank pixels "
"in the input data. You can run %s again with "
- "`--domain=spatial'\n"
+ "'--domain=spatial'\n"
"----------------------------------------\n\n",
PROGRAM_NAME, p->filename, cp->hdu, cp->output,
PROGRAM_NAME);
@@ -537,7 +537,7 @@ ui_preparations(struct convolveparams *p)
/* Frequency domain is only implemented in 2D. */
if( p->input->ndim==1 )
error(EXIT_FAILURE, 0, "Frequency domain convolution is currently "
- "not implemented on 1D datasets. Please use `--domain=spatial' "
+ "not implemented on 1D datasets. Please use '--domain=spatial' "
"to convolve this dataset");
}
else
@@ -554,7 +554,7 @@ ui_preparations(struct convolveparams *p)
{
/* Currently this is not implemented in 1D. */
if(p->kernel->ndim==1)
- error(EXIT_FAILURE, 0, "`--makekernel' is currently not available "
+ error(EXIT_FAILURE, 0, "'--makekernel' is currently not available "
"on 1D datasets");
else
{
@@ -564,9 +564,9 @@ ui_preparations(struct convolveparams *p)
/* Make sure the size of the kernel is the same as the input */
if( p->input->dsize[0]!=p->kernel->dsize[0]
|| p->input->dsize[1]!=p->kernel->dsize[1] )
- error(EXIT_FAILURE, 0, "with the `--makekernel' (`-m') option, "
+ error(EXIT_FAILURE, 0, "with the '--makekernel' ('-m') option, "
"the input image and the image specified with the "
- "`--kernel' (`-k') option should have the same size. The "
+ "'--kernel' ('-k') option should have the same size. The "
"lower resolution input image (%s) has %zux%zu pixels "
"while the sharper image (%s) specified with the kernel "
"option has %zux%zu pixels", p->filename,
@@ -704,9 +704,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
convolveparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/convolve/ui.h b/bin/convolve/ui.h
index 4e71766..bdf95c7 100644
--- a/bin/convolve/ui.h
+++ b/bin/convolve/ui.h
@@ -5,7 +5,7 @@ Convolve is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/cosmiccal/Makefile.am b/bin/cosmiccal/Makefile.am
index 984a93a..9ad628c 100644
--- a/bin/cosmiccal/Makefile.am
+++ b/bin/cosmiccal/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2016-2019, Free Software Foundation, Inc.
+## Copyright (C) 2016-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astcosmiccal
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astcosmiccal_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astcosmiccal_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astcosmiccal_SOURCES = main.c ui.c cosmiccal.c
diff --git a/bin/cosmiccal/args.h b/bin/cosmiccal/args.h
index 1876746..7c7f7bf 100644
--- a/bin/cosmiccal/args.h
+++ b/bin/cosmiccal/args.h
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -45,6 +45,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET
},
{
+ "velocity",
+ UI_KEY_VELOCITY,
+ "FLT",
+ 0,
+ "Velocity of interest in km/s.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->velocity,
+ GAL_TYPE_FLOAT64,
+ GAL_OPTIONS_RANGE_GE_0,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
"obsline",
UI_KEY_OBSLINE,
"STR,FLT",
@@ -114,10 +127,12 @@ struct argp_option program_options[] =
+
+ /* Basic cosmology */
{
0, 0, 0, 0,
- "Specific calculations",
- UI_GROUP_SPECIFIC
+ "Basic cosmology calculations",
+ UI_GROUP_BASIC
},
{
"usedredshift",
@@ -125,7 +140,7 @@ struct argp_option program_options[] =
0,
0,
"Used redshift in this run.",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -139,7 +154,7 @@ struct argp_option program_options[] =
0,
0,
"Age of universe now (Ga: Giga Annum).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -153,7 +168,7 @@ struct argp_option program_options[] =
0,
0,
"Critical density now (g/cm^3).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -167,7 +182,7 @@ struct argp_option program_options[] =
0,
0,
"Proper distance to z (Mpc).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -181,7 +196,7 @@ struct argp_option program_options[] =
0,
0,
"Angular diameter distance (Mpc).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -195,7 +210,7 @@ struct argp_option program_options[] =
0,
0,
"Tangential dist. covered by 1arcsec at z (kpc).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -209,7 +224,7 @@ struct argp_option program_options[] =
0,
0,
"Luminosity distance to z (Mpc).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -223,7 +238,7 @@ struct argp_option program_options[] =
0,
0,
"Distance modulus at z (no units).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -237,7 +252,7 @@ struct argp_option program_options[] =
0,
0,
"Conversion to absolute magnitude (no unit).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -251,7 +266,7 @@ struct argp_option program_options[] =
0,
0,
"Age of universe at z (Ga: Giga Annum).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -265,7 +280,7 @@ struct argp_option program_options[] =
0,
0,
"Look back time to z (Ga: Giga Annum).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -279,7 +294,7 @@ struct argp_option program_options[] =
0,
0,
"Critical density at z (g/cm^3).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -293,7 +308,21 @@ struct argp_option program_options[] =
0,
0,
"Comoving volume (4pi str) to z (Mpc^3).",
- UI_GROUP_SPECIFIC,
+ UI_GROUP_BASIC,
+ &p->specific,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_add_to_single_value,
+ },
+ {
+ "usedvelocity",
+ UI_KEY_USEDVELOCITY,
+ 0,
+ 0,
+ "Used velocity (in km/s) for this run.",
+ UI_GROUP_BASIC,
&p->specific,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -301,13 +330,50 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET,
ui_add_to_single_value,
},
+
+
+
+
+
+ /* Spectral line options. */
+ {
+ 0, 0, 0, 0,
+ "Spectral lines",
+ UI_GROUP_SPECTRAL_LINES
+ },
+ {
+ "listlines",
+ UI_KEY_LISTLINES,
+ 0,
+ 0,
+ "List known lines and rest frame wavelength.",
+ UI_GROUP_SPECTRAL_LINES,
+ &p->listlines,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "listlinesatz",
+ UI_KEY_LISTLINESATZ,
+ 0,
+ 0,
+ "List known spectral lines at given redshift.",
+ UI_GROUP_SPECTRAL_LINES,
+ &p->listlinesatz,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
{
"lineatz",
UI_KEY_LINEATZ,
"STR/FLT",
0,
- "Wavelength of given line at chosen redshift",
- UI_GROUP_SPECIFIC,
+ "Wavelength of line (name or wavelength) at z.",
+ UI_GROUP_SPECTRAL_LINES,
&p->specific,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
diff --git a/bin/cosmiccal/astcosmiccal.conf b/bin/cosmiccal/astcosmiccal.conf
index e40222e..6b040c8 100644
--- a/bin/cosmiccal/astcosmiccal.conf
+++ b/bin/cosmiccal/astcosmiccal.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astcosmiccal # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/cosmiccal/authors-cite.h b/bin/cosmiccal/authors-cite.h
index 4ebebd6..e752c6e 100644
--- a/bin/cosmiccal/authors-cite.h
+++ b/bin/cosmiccal/authors-cite.h
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/cosmiccal/cosmiccal.c b/bin/cosmiccal/cosmiccal.c
index b42ec7d..15efffe 100644
--- a/bin/cosmiccal/cosmiccal.c
+++ b/bin/cosmiccal/cosmiccal.c
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -72,7 +72,7 @@ cosmiccal_print_input(struct cosmiccalparams *p)
static void
cosmiccal_printall(struct cosmiccalparams *p)
{
- double ad, ld, vz, pd, absmagconv;
+ double ad, ld, vz, pd, vel, absmagconv;
double curage, ccritd, distmod, outage, zcritd;
/* The user wants everything, do all the calculations and print
@@ -104,6 +104,8 @@ cosmiccal_printall(struct cosmiccalparams *p)
zcritd=gal_cosmology_critical_density(p->redshift, p->H0, p->olambda,
p->omatter, p->oradiation);
+ vel=gal_cosmology_velocity_from_z(p->redshift);
+
vz=gal_cosmology_comoving_volume(p->redshift, p->H0, p->olambda, p->omatter,
p->oradiation);
@@ -115,6 +117,7 @@ cosmiccal_printall(struct cosmiccalparams *p)
printf( " ------------\n");
printf(FLTFORMAT, "Age of Universe now (Ga*):", curage);
printf(EXPFORMAT, "Critical density now (g/cm^3):", ccritd);
+ printf(FLTFORMAT, "Velocity at z (km/s):", vel);
printf(FLTFORMAT, "Proper distance to z (Mpc):", pd);
printf(FLTFORMAT, "Angular diameter distance to z (Mpc):", ad);
printf(FLTFORMAT, "Tangential distance covered by 1 arcsec at z (Kpc):",
@@ -155,7 +158,7 @@ cosmiccal(struct cosmiccalparams *p)
if(isnan(p->redshift))
{
cosmiccal_print_input(p);
- printf("\n\nPlease specify a redshift with the `--redshift' (or `-z') "
+ printf("\n\nPlease specify a redshift with the '--redshift' (or '-z') "
"option.\n");
return;
}
@@ -256,6 +259,10 @@ cosmiccal(struct cosmiccalparams *p)
p->oradiation));
break;
+ case UI_KEY_USEDVELOCITY:
+ printf("%g", gal_cosmology_velocity_from_z(p->redshift));
+ break;
+
case UI_KEY_LINEATZ:
printf("%g", gal_list_f64_pop(&p->specific_arg)*(1+p->redshift));
break;
diff --git a/bin/cosmiccal/cosmiccal.h b/bin/cosmiccal/cosmiccal.h
index 64ca8e0..a648b08 100644
--- a/bin/cosmiccal/cosmiccal.h
+++ b/bin/cosmiccal/cosmiccal.h
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/cosmiccal/main.c b/bin/cosmiccal/main.c
index 5dcce1a..1194783 100644
--- a/bin/cosmiccal/main.c
+++ b/bin/cosmiccal/main.c
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/cosmiccal/main.h b/bin/cosmiccal/main.h
index 0801aa6..a1f6344 100644
--- a/bin/cosmiccal/main.h
+++ b/bin/cosmiccal/main.h
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -47,11 +47,14 @@ struct cosmiccalparams
/* Input: */
double redshift; /* Redshift of interest. */
+ gal_data_t *obsline; /* Observed wavelength of a line. */
+ double velocity; /* Velocity of interest. */
double H0; /* Current expansion rate (km/sec/Mpc). */
double olambda; /* Current cosmological constant dens. */
double omatter; /* Current matter density. */
double oradiation; /* Current radiation density. */
- gal_data_t *obsline; /* Observed wavelength of a line. */
+ uint8_t listlines; /* List the known spectral lines. */
+ uint8_t listlinesatz; /* List the known spectral lines. */
/* Outputs. */
gal_list_i32_t *specific; /* Codes for single row calculations. */
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 0340ae7..5d516ec 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -116,6 +116,7 @@ ui_initialize_options(struct cosmiccalparams *p,
/* Program specific initializations. */
p->redshift = NAN;
+ p->velocity = NAN;
/* Modify the common options. */
for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
@@ -158,18 +159,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct cosmiccalparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -207,22 +208,22 @@ ui_add_to_single_value(struct argp_option *option, char
*arg,
/* In case of printing the option values. */
if(lineno==-1)
error(EXIT_FAILURE, 0, "currently the options to be printed in one row "
- "(like `--age', `--luminositydist', and etc) do not support "
- "printing with the `--printparams' (`-P'), or writing into "
+ "(like '--age', '--luminositydist', and etc) do not support "
+ "printing with the '--printparams' ('-P'), or writing into "
"configuration files due to lack of time when implementing "
"these features. You can put them into configuration files "
- "manually. Please get in touch with us at `%s', so we can "
+ "manually. Please get in touch with us at '%s', so we can "
"implement it", PACKAGE_BUGREPORT);
- /* If this option is given in a configuration file, then `arg' will not
- be NULL and we don't want to do anything if it is `0'. */
+ /* If this option is given in a configuration file, then 'arg' will not
+ be NULL and we don't want to do anything if it is '0'. */
switch(option->key)
{
/* Options with arguments. */
case UI_KEY_LINEATZ:
/* Make sure an argument is given. */
if(arg==NULL)
- error(EXIT_FAILURE, 0, "option `--lineatz' needs an argument");
+ error(EXIT_FAILURE, 0, "option '--lineatz' needs an argument");
/* If the argument is a number, read it, if not, see if its a known
specral line name. */
@@ -231,7 +232,7 @@ ui_add_to_single_value(struct argp_option *option, char
*arg,
{
linecode=gal_speclines_line_code(arg);
if(linecode==GAL_SPECLINES_INVALID)
- error(EXIT_FAILURE, 0, "`%s' not a known spectral line name",
+ error(EXIT_FAILURE, 0, "'%s' not a known spectral line name",
arg);
val=gal_speclines_line_angstrom(linecode);
}
@@ -242,11 +243,11 @@ ui_add_to_single_value(struct argp_option *option, char
*arg,
default:
if(arg)
{
- /* Make sure the value is only `0' or `1'. */
+ /* Make sure the value is only '0' or '1'. */
if( arg[1]!='\0' && *arg!='0' && *arg!='1' )
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "the `--%s' "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "the '--%s' "
"option takes no arguments. In a configuration "
- "file it can only have the values `1' or `0', "
+ "file it can only have the values '1' or '0', "
"indicating if it should be used or not",
option->name);
@@ -278,7 +279,7 @@ ui_parse_obsline(struct argp_option *option, char *arg,
/* We want to print the stored values. */
if(lineno==-1)
{
- /* Set the value pointer to `obsline'. */
+ /* Set the value pointer to 'obsline'. */
obsline=*(gal_data_t **)(option->value);
dptr = obsline->array;
@@ -297,7 +298,7 @@ ui_parse_obsline(struct argp_option *option, char *arg,
}
else
{
- /* The first part of `arg' (before the first comma) is not
+ /* The first part of 'arg' (before the first comma) is not
necessarily a number. So we need to separate the first part from
the rest.*/
linename=arg;
@@ -310,7 +311,7 @@ ui_parse_obsline(struct argp_option *option, char *arg,
/* Only one number must be given as second argument. */
if(obsline==NULL || obsline->size!=1)
- error(EXIT_FAILURE, 0, "Wrong format given to `--obsline'. Only "
+ error(EXIT_FAILURE, 0, "Wrong format given to '--obsline'. Only "
"two values (line name/wavelengh, and observed wavelengh) "
"must be given to it");
@@ -318,14 +319,14 @@ ui_parse_obsline(struct argp_option *option, char *arg,
put that number in a second element of the array. */
dptr=&manualwl;
if( gal_type_from_string((void **)(&dptr), linename, GAL_TYPE_FLOAT64) )
- { /* `linename' isn't a number. */
+ { /* 'linename' isn't a number. */
obsline->status=gal_speclines_line_code(linename);
if(obsline->status==GAL_SPECLINES_INVALID)
- error(EXIT_FAILURE, 0, "`%s' not recognized as a standard spectral
"
+ error(EXIT_FAILURE, 0, "'%s' not recognized as a standard spectral
"
"line name", linename);
}
else
- { /* `linename' is a number. */
+ { /* 'linename' is a number. */
/* Allocate the new space. */
tobsline=gal_data_alloc(NULL, GAL_TYPE_FLOAT64, 1, &two, NULL,
@@ -343,7 +344,7 @@ ui_parse_obsline(struct argp_option *option, char *arg,
obsline=tobsline;
}
- /* Point `option->value' to the dataset. */
+ /* Point 'option->value' to the dataset. */
*(gal_data_t **)(option->value) = obsline;
/* Our job is done, return NULL. */
@@ -374,24 +375,45 @@ ui_parse_obsline(struct argp_option *option, char *arg,
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct cosmiccalparams *p)
{
+ int hasobsline=p->obsline!=NULL;
+ int hasredshift=!isnan(p->redshift);
+ int hasvelocity=!isnan(p->velocity);
double sum = p->olambda + p->omatter + p->oradiation;
/* Check if the density fractions add up to 1 (within floating point
error). */
if( sum > (1+1e-8) || sum < (1-1e-8) )
error(EXIT_FAILURE, 0, "sum of fractional densities is not 1, but %.8f. "
- "The cosmological constant (`olambda'), matter (`omatter') "
- "and radiation (`oradiation') densities are given as %.8f, %.8f, "
+ "The cosmological constant ('olambda'), matter ('omatter') "
+ "and radiation ('oradiation') densities are given as %.8f, %.8f, "
"%.8f", sum, p->olambda, p->omatter, p->oradiation);
- /* Make sure that `--redshift' and `--obsline' aren't called together. */
- if(!isnan(p->redshift) && p->obsline)
- error(EXIT_FAILURE, 0, "`--redshift' and `--obsline' cannot be called "
- "together");
+ /* Make sure that '--listlines' and '--listlinesatz' aren't called
+ together. */
+ if(p->listlines && p->listlinesatz)
+ error(EXIT_FAILURE, 0, "'--listlines' and '--listlinesatz' can't be "
+ "called together");
+
+ /* Make sure that atleast one of '--redshift', '--obsline', or
+ '--velocity' are given (different ways to set/estimate the
+ redshift). However, when '--listlines' and/or '--printparams' are
+ called (i.e., when they have a non-zero value) we don't need a
+ redshift all and the program can run without any of the three options
+ above. */
+ if(isnan(p->redshift) && p->obsline==NULL && isnan(p->velocity)
+ && p->listlines==0 && p->cp.printparams==0)
+ error(EXIT_FAILURE, 0, "no redshift/velocity specified! Please use "
+ "'--redshift', '--velocity' (in km/s), or '--obsline' to specify "
+ "a redshift, run with '--help' for more");
+
+ /* Make sure that '--redshift' and '--obsline' aren't called together. */
+ if( (hasredshift + hasvelocity + hasobsline) > 1 )
+ error(EXIT_FAILURE, 0, "only one of '--redshift', '--velocity', or "
+ "'--obsline' can be called in each run");
}
@@ -417,23 +439,75 @@ ui_read_check_only_options(struct cosmiccalparams *p)
/*************** Preparations *******************/
/**************************************************************/
static void
+ui_list_lines(struct cosmiccalparams *p)
+{
+ size_t i;
+
+ /* Print basic information. Note that '--listlinesatz' is requested, also
+ print the redshift used. */
+ printf("# %s\n", PROGRAM_STRING);
+ if(p->listlinesatz)
+ printf("# Assumed redshift: %g\n", p->redshift);
+
+ /* Print column metadata. */
+ printf("# Column 1: Wavelength [Angstrom,f32] %s.\n",
+ ( p->listlinesatz
+ ? "Line wavelength at assumed redshift"
+ : "Rest frame wavelength of the line"));
+ printf("# Column 2: Name [name, str10] Line name in Gnuastro.\n");
+
+ /* Print the line information. */
+ for(i=1;i<GAL_SPECLINES_INVALID_MAX;++i)
+ printf("%-15g%s\n",
+ ( p->listlinesatz
+ ? ( gal_speclines_line_angstrom(i) * (1+p->redshift) )
+ : gal_speclines_line_angstrom(i) ),
+ gal_speclines_line_name(i));
+
+ /* Abort the program. */
+ exit(EXIT_SUCCESS);
+}
+
+
+
+
+
+static void
ui_preparations(struct cosmiccalparams *p)
{
double *obsline = p->obsline ? p->obsline->array : NULL;
- /* If `--obsline' has been given, set the redshift based on it. */
+ /* If '--listlines' is given, print them and abort the program
+ successfully, don't continue with the preparations. Note that
+ '--listlines' is the rest-frame lines. So we don't need any
+ redshift. */
+ if(p->listlines)
+ ui_list_lines(p);
+
+ /* If '--obsline' has been given, set the redshift based on it (it can't
+ be called with '--velocity'). */
if(p->obsline)
p->redshift = ( (p->obsline->status==GAL_SPECLINES_INVALID)
? gal_speclines_line_redshift(obsline[0], obsline[1])
: gal_speclines_line_redshift_code(obsline[0],
p->obsline->status) );
+ /* If '--velocity' has been given, set the redshift based on it (it can't
+ be called with '--obsline'). */
+ if( !isnan(p->velocity) )
+ p->redshift = gal_cosmology_z_from_velocity(p->velocity);
+
/* Currently GSL will fail for z=0. So if a value of zero is given (bug
#56299). As a work-around, in such cases, we'll change it to an
- extremely small value. NOTE: This has to be after the `obsline'
+ extremely small value. NOTE: This has to be after the 'obsline'
check.*/
if(p->redshift==0.0f) p->redshift=MAIN_REDSHIFT_ZERO;
+ /* Now that we have the redshift, we can print the 'listlinesatz'
+ option. */
+ if(p->listlinesatz)
+ ui_list_lines(p);
+
/* The list is filled out in a first-in-last-out order. By the time
control reaches here, the list is finalized. So we should just reverse
it so the user gets values in the same order they requested them. */
@@ -469,9 +543,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
cosmiccalparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/cosmiccal/ui.h b/bin/cosmiccal/ui.h
index 0b36e52..fe12cf9 100644
--- a/bin/cosmiccal/ui.h
+++ b/bin/cosmiccal/ui.h
@@ -5,7 +5,7 @@ CosmicCalculator is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,7 +33,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Option groups particular to this program. */
enum program_args_groups
{
- UI_GROUP_SPECIFIC = GAL_OPTIONS_GROUP_AFTER_COMMON,
+ UI_GROUP_BASIC = GAL_OPTIONS_GROUP_AFTER_COMMON,
+ UI_GROUP_SPECTRAL_LINES,
};
@@ -42,13 +43,14 @@ enum program_args_groups
/* Available letters for short options:
- f j k n p t w x y
- B E J Q R W X Y
+ f j k n p t w x
+ B E J Q R W X
*/
enum option_keys_enum
{
/* With short-option version. */
UI_KEY_REDSHIFT = 'z',
+ UI_KEY_VELOCITY = 'y',
UI_KEY_OBSLINE = 'O',
UI_KEY_H0 = 'H',
UI_KEY_OLAMBDA = 'l',
@@ -68,10 +70,13 @@ enum option_keys_enum
UI_KEY_LOOKBACKTIME = 'b',
UI_KEY_CRITICALDENSITY = 'c',
UI_KEY_VOLUME = 'v',
+ UI_KEY_USEDVELOCITY = 'Y',
UI_KEY_LINEATZ = 'i',
/* Only with long version (start with a value 1000, the rest will be set
automatically). */
+ UI_KEY_LISTLINES = 1000,
+ UI_KEY_LISTLINESATZ,
};
diff --git a/bin/crop/Makefile.am b/bin/crop/Makefile.am
index b644d67..c4a5450 100644
--- a/bin/crop/Makefile.am
+++ b/bin/crop/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astcrop
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astcrop_SOURCES = main.c ui.c crop.c wcsmode.c onecrop.c
diff --git a/bin/crop/args.h b/bin/crop/args.h
index 27ab92d..7eddd38 100644
--- a/bin/crop/args.h
+++ b/bin/crop/args.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -36,7 +36,7 @@ struct argp_option program_options[] =
UI_KEY_MODE,
"STR",
0,
- "Coordinate mode `img' or `wcs'.",
+ "Coordinate mode 'img' or 'wcs'.",
GAL_OPTIONS_GROUP_INPUT,
&p->mode,
GAL_TYPE_STRING,
@@ -90,6 +90,19 @@ struct argp_option program_options[] =
/* Output. */
{
+ "primaryimghdu",
+ UI_KEY_PRIMARYIMGHDU,
+ 0,
+ 0,
+ "Write crop in primary/zero-th HDU of output.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->primaryimghdu,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
"noblank",
UI_KEY_NOBLANK,
0,
@@ -182,7 +195,7 @@ struct argp_option program_options[] =
{
"catalog",
UI_KEY_CATALOG,
- "STR",
+ "FITS/TXT",
0,
"Input catalog filename.",
UI_GROUP_CENTER_CATALOG,
@@ -265,16 +278,30 @@ struct argp_option program_options[] =
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_SET,
+ gal_options_parse_colon_sep_csv
},
{
- "outpolygon",
- UI_KEY_OUTPOLYGON,
+ "polygonout",
+ UI_KEY_POLYGONOUT,
0,
0,
"Keep the polygon's outside, mask the inside.",
UI_GROUP_REGION,
- &p->outpolygon,
+ &p->polygonout,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "polygonsort",
+ UI_KEY_POLYGONSORT,
+ 0,
+ 0,
+ "Sort polygon vertices as counter-clockwise.",
+ UI_GROUP_REGION,
+ &p->polygonsort,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
diff --git a/bin/crop/astcrop.conf b/bin/crop/astcrop.conf
index 07f701d..b3c45f8 100644
--- a/bin/crop/astcrop.conf
+++ b/bin/crop/astcrop.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astcrop # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/crop/authors-cite.h b/bin/crop/authors-cite.h
index b910952..a31f3cf 100644
--- a/bin/crop/authors-cite.h
+++ b/bin/crop/authors-cite.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/crop/crop.c b/bin/crop/crop.c
index 88802a9..1bc2183 100644
--- a/bin/crop/crop.c
+++ b/bin/crop/crop.c
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -31,6 +31,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gnuastro/fits.h>
#include <gnuastro/threads.h>
+#include <gnuastro/pointer.h>
#include <gnuastro-internal/timing.h>
#include <gnuastro-internal/checkset.h>
@@ -115,7 +116,7 @@ crop_verbose_final(struct cropparams *p)
case 3:
/* When the center wasn't checked it has a value of -1, and
when it was checked and the center was filled, it has a
- value of 1. So if `array[i]==0', we know that the file was
+ value of 1. So if 'array[i]==0', we know that the file was
removed. */
for(i=0;i<p->numout;++i)
{
@@ -184,7 +185,7 @@ crop_write_to_log(struct onecropparams *crp)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
- "the problem. The value of %zu is not valid for `counter'",
+ "the problem. The value of %zu is not valid for 'counter'",
__func__, PACKAGE_BUGREPORT, counter);
}
}
@@ -225,7 +226,7 @@ crop_mode_img(void *inparam)
onecrop(crp);
/* If there was no overlap, then no FITS pointer is created, so
- `numimg' should be set to zero. */
+ 'numimg' should be set to zero. */
if(crp->outfits==NULL) crp->numimg=0;
/* Check the final output: */
@@ -312,10 +313,12 @@ crop_mode_wcs(void *inparam)
if(crp->name==NULL) onecrop_name(crp);
/* Increment the number of images used (necessary for the
- header keywords that are written in `onecrop'). Then do the
- crop. */
+ header keywords that are written in 'onecrop'). Then do the
+ crop. However, the previously WCS-based overlap can be
+ slightly different from the final overlap, so if we finally
+ don't find any overlap we'll decrement the 'numimg'. */
++crp->numimg;
- onecrop(crp);
+ if( onecrop(crp)==0 ) --crp->numimg;
/* Close the file. */
status=0;
@@ -325,9 +328,9 @@ crop_mode_wcs(void *inparam)
while ( ++(crp->in_ind) < p->numin );
- /* Correct in_ind. The loop above went until `in_ind' is one more
+ /* Correct in_ind. The loop above went until 'in_ind' is one more
than the index for the last input image (that is how it exited the
- loop). But `crp->in_ind' is needed later, so correct it here. */
+ loop). But 'crp->in_ind' is needed later, so correct it here. */
--crp->in_ind;
@@ -402,6 +405,7 @@ crop(struct cropparams *p)
int err=0;
char *tmp;
pthread_t t; /* We don't use the thread id, so all are saved here. */
+ char *mmapname;
pthread_attr_t attr;
pthread_barrier_t b;
struct onecropparams *crp;
@@ -420,14 +424,15 @@ crop(struct cropparams *p)
errno=0;
crp=malloc(nt*sizeof *crp);
if(crp==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `crp'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'crp'",
__func__, nt*sizeof *crp);
/* Distribute the indexs into the threads (for clarity, this is needed
even if we only have one object). */
- gal_threads_dist_in_threads(p->catname ? p->numout : 1, nt,
- &indexs, &thrdcols);
+ mmapname=gal_threads_dist_in_threads(p->catname ? p->numout : 1, nt,
+ p->cp.minmapsize, p->cp.quietmmap,
+ &indexs, &thrdcols);
/* Run the job, if there is only one thread, don't go through the
@@ -485,7 +490,8 @@ crop(struct cropparams *p)
}
/* Print the final verbose info, save log, and clean up: */
+ if(mmapname) gal_pointer_mmap_free(&mmapname, p->cp.quietmmap);
+ else free(indexs);
crop_verbose_final(p);
- free(indexs);
free(crp);
}
diff --git a/bin/crop/crop.h b/bin/crop/crop.h
index d9f6fd2..5d7fbba 100644
--- a/bin/crop/crop.h
+++ b/bin/crop/crop.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/crop/main.c b/bin/crop/main.c
index a303b3f..16693dc 100644
--- a/bin/crop/main.c
+++ b/bin/crop/main.c
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/crop/main.h b/bin/crop/main.h
index 528645e..f18a88c 100644
--- a/bin/crop/main.h
+++ b/bin/crop/main.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -85,9 +85,10 @@ struct cropparams
size_t hendwcs; /* Header keyword No. to end read WCS. */
int mode; /* Image or WCS mode. */
uint8_t zeroisnotblank; /* ==1: In float or double, keep 0.0. */
+ uint8_t primaryimghdu; /* ==1: write in primary/0-th HDU. */
uint8_t noblank; /* ==1: no blank (out of image) pixels. */
char *suffix; /* Ending of output file name. */
- gal_data_t *incheckcenter; /* Value given to `--checkcenter'. */
+ gal_data_t *incheckcenter; /* Value given to '--checkcenter'. */
gal_data_t *center; /* Center position of crop. */
gal_data_t *width; /* Width of crop when defined by center. */
char *catname; /* Name of input catalog. */
@@ -95,8 +96,9 @@ struct cropparams
char *namecol; /* Filename (without suffix) of crop col.*/
gal_list_str_t *coordcol; /* Column in cat containing coordinates. */
char *section; /* Section string. */
- char *polygon; /* Input string of polygon vertices. */
- uint8_t outpolygon; /* ==1: Keep the inner polygon region. */
+ gal_data_t *polygon; /* Input string of polygon vertices. */
+ uint8_t polygonout; /* ==1: Keep the inner polygon region. */
+ uint8_t polygonsort; /* Don't sort polygon vertices. */
/* Internal */
size_t numin; /* Number of input images. */
diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index 55c85cd..470e966 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -91,8 +91,8 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
p->checkcenter=0;
- /* Initialize the fpixel and lpixel arrays (note that `section' is only
- defined in image mode, so there will only be one element in `imgs'. */
+ /* Initialize the fpixel and lpixel arrays (note that 'section' is only
+ defined in image mode, so there will only be one element in 'imgs'. */
for(i=0;i<ndim;++i)
{
fpixel[i] = 1;
@@ -100,7 +100,7 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
}
- /* Parse the string: `forl': "first-or-last". */
+ /* Parse the string: 'forl': "first-or-last". */
while(*pt!='\0')
{
add=0;
@@ -109,7 +109,7 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
case ',':
++dim;
if(dim>=ndim)
- error(EXIT_FAILURE, 0, "Extra `,` in `%s`", p->section);
+ error(EXIT_FAILURE, 0, "Extra ',' in '%s'", p->section);
forl='f';
++pt;
break;
@@ -119,7 +119,7 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
break;
case '.':
error(EXIT_FAILURE, 0, "the numbers in the argument to "
- "`--section` (`-s') have to be integers. You input "
+ "'--section' ('-s') have to be integers. You input "
"includes a float number: %s", p->section);
break;
case ' ': case '\t':
@@ -138,10 +138,10 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
/* An un-recognized character should crash the program. */
default:
- error(EXIT_FAILURE, 0, "value to `--section' must only contain "
+ error(EXIT_FAILURE, 0, "value to '--section' must only contain "
"integer numbers and these special characters between them: "
- "`,', `:', `*' when necessary. But it is `%s' (the first "
- "non-acceptable character is `%c').\n\n"
+ "',', ':', '*' when necessary. But it is '%s' (the first "
+ "non-acceptable character is '%c').\n\n"
"Please run the command below to learn more about this "
"option in Gnuastro's Crop program:\n\n"
" $ info gnuastro \"Crop section syntax\"\n", p->section,
@@ -159,7 +159,7 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
/* Make sure if a number was read at all? */
if(tailptr==pt) /* No number was read! */
{
- if(add) read=0; /* We have a * followed by `:' or `,'. */
+ if(add) read=0; /* We have a * followed by ':' or ','. */
else continue;
}
@@ -195,112 +195,6 @@ onecrop_parse_section(struct cropparams *p, size_t *dsize,
-
-void
-onecrop_parse_polygon(struct cropparams *p)
-{
- size_t dim=0;
- char *tailptr;
- char *pt=p->polygon;
- double read, *array;
- gal_list_f64_t *vertices=NULL;
-
- /* If control reached here, then the cropped region is not defined by its
- center. So it makes no sense to check if the center is blank. */
- p->checkcenter=0;
-
- /* Parse the string. */
- while(*pt!='\0')
- {
- switch(*pt)
- {
- case ',':
- ++dim;
- if(dim==2)
- error(EXIT_FAILURE, 0, "Extra `,` in `%s`", p->polygon);
- ++pt;
- break;
- case ':':
- if(dim==0)
- error(EXIT_FAILURE, 0, "not enough coordinates for at least "
- "one polygon vertex (in %s)", p->polygon);
- dim=0;
- ++pt;
- break;
- default:
- break;
- }
-
- /* strtod will skip white spaces if they are before a number,
- but not when they are before a : or ,. So we need to remove
- all white spaces. White spaces are usually put beside each
- other, so if one is encountered, go along the string until
- the white space characters finish. */
- if(isspace(*pt))
- ++pt;
- else
- {
- /* Read the number: */
- read=strtod(pt, &tailptr);
-
- /* Check if there actually was a number.
- printf("\n\n------\n%zu: %f (%s)\n", dim, read, tailptr);
- */
-
- /* Make sure if a number was read at all? */
- if(tailptr==pt) /* No number was read! */
- error(EXIT_FAILURE, 0, "%s could not be parsed as a floating "
- "point number", tailptr);
-
- /* Check if there are no extra characters in the number, for
- example we don't have a case like `1.00132.17', or
- 1.01i:2.0. Such errors are not uncommon when typing large
- numbers, and if ignored, they can lead to unpredictable
- results, so its best to abort and inform the user. */
- if( *tailptr!='\0'
- && !isspace(*tailptr)
- && strchr(":,", *tailptr)==NULL )
- error(EXIT_FAILURE, 0, "'%s' is an invalid floating point number "
- "sequence in the value to the `--polygon' option, error "
- "detected at '%s'", pt, tailptr);
-
- /* Add the read coordinate to the list of coordinates. */
- gal_list_f64_add(&vertices, read);
-
- /* The job here is done, start from tailptr */
- pt=tailptr;
- }
- }
-
- /* Put the coordinates into an array while reversing their order so they
- correspond to the user's order, then put it in the right place.*/
- array=gal_list_f64_to_array(vertices, 1, &p->nvertices);
- if(p->mode==IMGCROP_MODE_IMG) { p->ipolygon=array; p->wpolygon=NULL; }
- else { p->ipolygon=NULL; p->wpolygon=array; }
-
- /* The number of vertices is actually the number of nodes in the list
- divided by the dimension of the dataset (note that we were counting
- the dimension from 0. */
- p->nvertices/=(dim+1);
-
- /* For a check:
- {
- size_t i;
- double *polygon=p->mode==IMGCROP_MODE_IMG?p->ipolygon:p->wpolygon;
- for(i=0;i<p->nvertices;++i)
- printf("(%f, %f)\n", polygon[i*2], polygon[i*2+1]);
- }
- exit(0);
- */
-
- /* Clean up: */
- gal_list_f64_free(vertices);
-}
-
-
-
-
-
static void
onecrop_ipolygon_fl(double *ipolygon, size_t nvertices, long *fpixel,
long *lpixel)
@@ -334,7 +228,7 @@ onecrop_ipolygon_fl(double *ipolygon, size_t nvertices,
long *fpixel,
for(i=0;i<size;++i) \
{ \
point[0]=i%s1+1; point[1]=i/s1+1; \
- if(gal_polygon_pin(ipolygon, point, nvertices)==outpolygon) \
+ if((*isinside)(ipolygon, point, nvertices)==polygonout) \
ba[i]=*bb; \
} \
free(bb); \
@@ -347,10 +241,10 @@ polygonmask(struct onecropparams *crp, void *array, long
*fpixel_i,
{
int type=crp->p->type;
double *ipolygon, point[2];
- int outpolygon=crp->p->outpolygon;
+ int polygonout=crp->p->polygonout;
+ int (*isinside)(double *, double *, size_t);
size_t i, *ordinds, size=s0*s1, nvertices=crp->p->nvertices;
-
/* First of all, allocate enough space to put a copy of the input
coordinates (we will be using that after sorting in an
anti-clickwise manner.) */
@@ -363,17 +257,49 @@ polygonmask(struct onecropparams *crp, void *array, long
*fpixel_i,
error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for ordinds",
__func__, nvertices*sizeof *ordinds);
+ /* If the user wants to sort the edges, do it. If not, make sure its in
+ counter-clockwise orientation. */
+ if(crp->p->polygonsort)
+ gal_polygon_vertices_sort(crp->ipolygon, nvertices, ordinds);
+ else
+ {
+ /* Keep the original order of the vertices, just make it
+ counter-clockwise. */
+ for(i=0;i<nvertices;++i) ordinds[i]=i;
+ gal_polygon_to_counterclockwise(crp->ipolygon, nvertices);
+ }
- /* Find the order of the polygons and put the elements in the proper
- order. Also subtract the fpixel_i coordinates from all the
- vertices to bring them into the crop image coordinates.*/
- gal_polygon_ordered_corners(crp->ipolygon, crp->p->nvertices, ordinds);
- for(i=0;i<crp->p->nvertices;++i)
+ /* Fill the final polygon vertice positions within 'ipolygon' and also
+ the fpixel_i coordinates from all the vertices to bring them into the
+ crop image coordinates. */
+ for(i=0;i<nvertices;++i)
{
ipolygon[i*2 ] = crp->ipolygon[ordinds[i]*2] - fpixel_i[0];
ipolygon[i*2+1] = crp->ipolygon[ordinds[i]*2+1] - fpixel_i[1];
}
+ /* Print a warning if we done the sorting, _and_ the sorted polygon is
+ concave, _and_ the user hasn't activated the quiet mode. Note that we
+ could'n do this immediately after calling 'gal_polygon_vertices_sort'
+ because that function doesn't touch the actual vertice values, it only
+ fills 'ordinds'. */
+ if(crp->p->polygonsort
+ && !crp->p->cp.quiet
+ && !gal_polygon_is_convex(ipolygon, nvertices) )
+ error(0, 0, "%s: warning: the given vertices belong to a concave "
+ "polygon, but there is no unique solution to the sorting of "
+ "concave polygons. Please check the cropped image, if it doesn't "
+ "correspond to your desired polygon, sort the vertices yourself "
+ "in counter-clockwise order _and_ don't use the '--polygonsort' "
+ "option", __func__);
+
+ /* Set the function for checking if a point is inside the polygon. For
+ concave polygons the process is more complex and thus
+ slower. Therefore when the polygon is convex, its better to use the
+ simpler/faster function. */
+ isinside = ( gal_polygon_is_convex(ipolygon, nvertices)
+ ? gal_polygon_is_inside_convex
+ : gal_polygon_is_inside );
/* Go over all the pixels in the image and if they are within the
polygon keep them if the user has asked for it.*/
@@ -521,7 +447,7 @@ onecrop_flpixel(struct onecropparams *crp)
onecrop_parse_section(p, dsize, fpixel, lpixel);
else if(p->polygon) /* Defined by a polygon. */
{
- if(p->outpolygon==0)
+ if(p->polygonout==0)
onecrop_ipolygon_fl(p->ipolygon, p->nvertices, fpixel, lpixel);
}
else /* Defined by its center. */
@@ -537,12 +463,12 @@ onecrop_flpixel(struct onecropparams *crp)
{
/* Fill crp->ipolygon in wcspolygonpixel, then set flpixel*/
fillcrpipolygon(crp);
- if(p->outpolygon==0)
+ if(p->polygonout==0)
onecrop_ipolygon_fl(crp->ipolygon, p->nvertices, fpixel, lpixel);
}
else
{
- /* Convert `crp->world' (in WCS) into `pixcrd' (image coord). */
+ /* Convert 'crp->world' (in WCS) into 'pixcrd' (image coord). */
if(wcss2p(p->imgs[crp->in_ind].wcs, ncoord, ndim, crp->world,
phi, theta, imgcrd, pixcrd, &status) )
if(status)
@@ -564,7 +490,7 @@ onecrop_flpixel(struct onecropparams *crp)
/* If the user only wants regions outside to the polygon, then set
the fpixel and lpixel to cover the full input image. */
- if(p->polygon && p->outpolygon)
+ if(p->polygon && p->polygonout)
{
crp->fpixel[0]=crp->fpixel[1]=1;
crp->lpixel[0]=dsize[1];
@@ -622,14 +548,17 @@ onecrop_make_array(struct onecropparams *crp, long
*fpixel_i,
/* Create the FITS file with a blank first extension, then close it, so
- with the next `fits_open_file', we build the image in the second
+ with the next 'fits_open_file', we build the image in the second
extension. This way, atleast for Gnuastro's outputs, we can
- consistently use `-h1' (something like how you count columns, or
+ consistently use '-h1' (something like how you count columns, or
generally everything from 1). */
if(fits_create_file(&ofp, outname, &status))
gal_fits_io_error(status, "creating file");
- fits_create_img(ofp, SHORT_IMG, 0, naxes, &status);
- fits_close_file(ofp, &status);
+ if(crp->p->primaryimghdu==0)
+ {
+ fits_create_img(ofp, SHORT_IMG, 0, naxes, &status);
+ fits_close_file(ofp, &status);
+ }
/* Create the output crop image. */
@@ -643,7 +572,7 @@ onecrop_make_array(struct onecropparams *crp, long
*fpixel_i,
/* When CFITSIO creates a FITS extension it adds two comments linking to
the FITS paper. Since we are mentioning the version of CFITSIO and
only use its routines to read/write from/to FITS files, this is
- redundant. If `status!=0', then `gal_fits_io_error' will abort, but in
+ redundant. If 'status!=0', then 'gal_fits_io_error' will abort, but in
case CFITSIO doesn't write the comments, status will become
non-zero. So we are resetting it to zero after these (because not
being able to delete them isn't an error). */
@@ -664,7 +593,7 @@ onecrop_make_array(struct onecropparams *crp, long
*fpixel_i,
&status);
gal_fits_io_error(status, "writing BUNIT");
}
- rkey->name=NULL; /* `name' wasn't allocated. */
+ rkey->name=NULL; /* 'name' wasn't allocated. */
gal_data_free(rkey);
@@ -720,31 +649,32 @@ onecrop_make_array(struct onecropparams *crp, long
*fpixel_i,
/* The starting and ending points are set in the onecropparams structure
for one crop from one image. Crop that region out of the input.
- On`basekeyname': To be safe, GCC 8.1 (and persumably later versions)
+ On'basekeyname': To be safe, GCC 8.1 (and persumably later versions)
assumes that we are writing the full statically allocated space into
- `regioinkey'! So it prints a warning that you may be writing outside the
+ 'regioinkey'! So it prints a warning that you may be writing outside the
allocated space! With these variables, we are ultimately just writing
the file counters, so we can never (with current techologies!!!) exceed
- `FLEN_KEYWORD' (which is 75 characters). To avoid compiler warnings, we
- are just removing a few characters (`FLEN_KEYWORD-5') to allow the
+ 'FLEN_KEYWORD' (which is 75 characters). To avoid compiler warnings, we
+ are just removing a few characters ('FLEN_KEYWORD-5') to allow the
suffix and remove the warnings. */
-void
+int
onecrop(struct onecropparams *crp)
{
struct cropparams *p=crp->p;
struct inputimgs *img=&p->imgs[crp->in_ind];
void *array;
+ int returnvalue=1;
int status=0, anynul=0;
fitsfile *ifp=crp->infits, *ofp;
- char basekeyname[FLEN_KEYWORD-5]; /* `-5': avoid gcc 8.1+ warnings! */
+ char basekeyname[FLEN_KEYWORD-5]; /* '-5': avoid gcc 8.1+ warnings! */
gal_fits_list_key_t *headers=NULL; /* See above comment for more. */
size_t i, j, cropsize=1, ndim=img->ndim;
char region[FLEN_VALUE], regionkey[FLEN_KEYWORD];
long fpixel_o[MAXDIM], lpixel_o[MAXDIM], inc[MAXDIM];
long naxes[MAXDIM], fpixel_i[MAXDIM], lpixel_i[MAXDIM];
- /* Fill the `naxes' and `inc' arrays. */
+ /* Fill the 'naxes' and 'inc' arrays. */
for(i=0;i<ndim;++i)
{
inc[ i ] = 1;
@@ -753,7 +683,7 @@ onecrop(struct onecropparams *crp)
/* Find the first and last pixel of this crop box from this input
- image. Then copy the first and last pixels into the `_i' arrays.*/
+ image. Then copy the first and last pixels into the '_i' arrays.*/
onecrop_flpixel(crp);
memcpy(fpixel_i, crp->fpixel, ndim*sizeof *fpixel_i);
memcpy(lpixel_i, crp->lpixel, ndim*sizeof *lpixel_i);
@@ -815,7 +745,7 @@ onecrop(struct onecropparams *crp)
/* Write the selected region of this image as a string to include as
- a FITS keyword. Then we want to delete the last coma `,'.*/
+ a FITS keyword. Then we want to delete the last coma ','.*/
j=0;
for(i=0;i<ndim;++i)
j += sprintf(®ion[j], "%ld:%ld,", fpixel_i[i], lpixel_i[i]);
@@ -829,7 +759,7 @@ onecrop(struct onecropparams *crp)
sprintf(regionkey, "%sPIX", basekeyname);
gal_fits_key_list_add_end(&headers, GAL_TYPE_STRING, regionkey,
0, region, 0, "Range of pixels used for "
- "this output.", 0, NULL);
+ "this output.", 0, NULL, 0);
gal_fits_key_write_in_ptr(&headers, ofp);
@@ -837,11 +767,14 @@ onecrop(struct onecropparams *crp)
free(array);
}
else
- if(p->polygon && p->outpolygon==0 && p->mode==IMGCROP_MODE_WCS)
- free(crp->ipolygon);
+ {
+ returnvalue=0;
+ if(p->polygon && p->polygonout==0 && p->mode==IMGCROP_MODE_WCS)
+ free(crp->ipolygon);
+ }
/* The crop is complete. */
- return;
+ return returnvalue;
}
@@ -934,7 +867,7 @@ onecrop_center_filled(struct onecropparams *crp)
free(array);
/* CFITSIO already checks if there are any blank pixels. If there are,
- then `anynul' will be 1, if there aren't it will be 0. So the output
+ then 'anynul' will be 1, if there aren't it will be 0. So the output
of this function is just the inverse of that number. */
return !anynul;
}
diff --git a/bin/crop/onecrop.h b/bin/crop/onecrop.h
index 8c32101..b89e477 100644
--- a/bin/crop/onecrop.h
+++ b/bin/crop/onecrop.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -60,12 +60,9 @@ struct onecropparams
};
void
-onecrop_parse_polygon(struct cropparams *p);
-
-void
onecrop_name(struct onecropparams *crp);
-void
+int
onecrop(struct onecropparams *crp);
int
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index e2dd9de..a1bc980 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -173,18 +173,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct cropparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -229,14 +229,14 @@ ui_parse_coordinate_mode(struct argp_option *option, char
*arg,
if (!strcmp(arg, "img")) *(int *)(option->value)=IMGCROP_MODE_IMG;
else if (!strcmp(arg, "wcs")) *(int *)(option->value)=IMGCROP_MODE_WCS;
else
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' (value to "
- "`--mode') not recognized as an input mode. "
- "Recognized values are `img' and `wcs'. This option "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' (value to "
+ "'--mode') not recognized as an input mode. "
+ "Recognized values are 'img' and 'wcs'. This option "
"is necessary to identify the nature of your input "
"coordinates.\n\n"
"Please run the following command for more "
- "information (press the `SPACE' key to go down and "
- "`q' to return to the command-line):\n\n"
+ "information (press the 'SPACE' key to go down and "
+ "'q' to return to the command-line):\n\n"
" $ info gnuastro \"Crop modes\"\n", arg);
return NULL;
}
@@ -265,7 +265,7 @@ ui_parse_coordinate_mode(struct argp_option *option, char
*arg,
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct cropparams *p)
{
@@ -281,8 +281,8 @@ ui_read_check_only_options(struct cropparams *p)
{
case 0:
error(EXIT_FAILURE, 0, "no crop definition. You can use any of the "
- "following options to define the crop(s): `--center', "
- "`--catalog', `--section', or `--polygon'. Please run this "
+ "following options to define the crop(s): '--center', "
+ "'--catalog', '--section', or '--polygon'. Please run this "
"command for more information:\n\n"
" $ info gnuastro \"Crop modes\"\n");
case 1:
@@ -293,10 +293,10 @@ ui_read_check_only_options(struct cropparams *p)
"run, only one crop definition is acceptable on the "
"command-line or in configuration files. You have called: "
"%s%s%s%s\b\b.",
- p->center!=NULL ? "`--center', " : "",
- p->catname!=NULL ? "`--catalog', " : "",
- p->section!=NULL ? "`--section', " : "",
- p->polygon!=NULL ? "`--polygon', " : "");
+ p->center!=NULL ? "'--center', " : "",
+ p->catname!=NULL ? "'--catalog', " : "",
+ p->section!=NULL ? "'--section', " : "",
+ p->polygon!=NULL ? "'--polygon', " : "");
}
@@ -306,7 +306,7 @@ ui_read_check_only_options(struct cropparams *p)
darray=p->width->array;
for(i=0;i<p->width->size;++i)
if(darray[i]<=0.0f)
- error(EXIT_FAILURE, 0, "%g is <=0. The values to the `--width' "
+ error(EXIT_FAILURE, 0, "%g is <=0. The values to the '--width' "
"option must be larger than zero. %g is input number %d to "
"this option", darray[i], darray[i], i+1);
}
@@ -317,23 +317,23 @@ ui_read_check_only_options(struct cropparams *p)
{
/* We only want a single number. */
if(p->incheckcenter->size>1)
- error(EXIT_FAILURE, 0, "%zu values given to `--checkcenter'. This "
+ error(EXIT_FAILURE, 0, "%zu values given to '--checkcenter'. This "
"option only takes one value currently",
p->incheckcenter->size);
darray=p->incheckcenter->array;
if(*darray<0.0f)
error(EXIT_FAILURE, 0, "negative value (%f) given to "
- "`--checkcenter'. This option only takes positive values",
+ "'--checkcenter'. This option only takes positive values",
*darray);
}
/* Section is currently only defined in Image mode. */
if(p->section && p->mode!=IMGCROP_MODE_IMG)
- error(EXIT_FAILURE, 0, "The `--section' option is only available in "
+ error(EXIT_FAILURE, 0, "The '--section' option is only available in "
"image coordinate mode, currently it doesn't work with WCS mode. "
- "Please run with `--mode=img' and if necessary, change the "
+ "Please run with '--mode=img' and if necessary, change the "
"values accordingly");
@@ -343,15 +343,15 @@ ui_read_check_only_options(struct cropparams *p)
/* If the searchin option has been given. */
if(p->cp.searchin==GAL_TABLE_SEARCH_INVALID)
error(EXIT_FAILURE, 0, "%s: no field specified to search for "
- "columns. Please use the `--searchin' option to specify "
- "which column meta-data you would like to search in: `name', "
- "`unit' and `comment'. You may also select columns by their "
+ "columns. Please use the '--searchin' option to specify "
+ "which column meta-data you would like to search in: 'name', "
+ "'unit' and 'comment'. You may also select columns by their "
"number, which won't use this option, but for complentess its "
"best for this option to have a value", p->catname);
/* If it is a FITS file, we need the HDU. */
if( gal_fits_name_is_fits(p->catname) && p->cathdu==NULL )
- error(EXIT_FAILURE, 0, "%s: no hdu given. Please use the `--cathdu' "
+ error(EXIT_FAILURE, 0, "%s: no hdu given. Please use the '--cathdu' "
"option to specify which extension contains the table",
p->catname);
@@ -360,7 +360,7 @@ ui_read_check_only_options(struct cropparams *p)
given, so we only need to check one of the two in each couple. */
if(p->coordcol==NULL)
error(EXIT_FAILURE, 0, "no crop center columns given to read from "
- "the input catalog (`%s'). Please use `--coordcol' several "
+ "the input catalog ('%s'). Please use '--coordcol' several "
"times (depending on dimensionality) to specify the column "
"keeping the center position the respective dimension.\n\n"
"For more information on how to select columns in Gnuastro, "
@@ -373,16 +373,32 @@ ui_read_check_only_options(struct cropparams *p)
in the proper format. */
if(p->polygon)
{
- onecrop_parse_polygon(p);
+ /* The number of vertices is half the total number of given values
+ (currently only 2D spaces are considered so each vertice has 2
+ coordinates. */
+ p->nvertices=p->polygon->size/2;
+
+ /* Basic sanity checks. */
if(p->nvertices<3)
error(EXIT_FAILURE, 0, "a polygon has to have 3 or more vertices, "
- "you have only given %zu (%s)", p->nvertices, p->polygon);
- if(p->outpolygon && p->numin>1)
- error(EXIT_FAILURE, 0, "currently in WCS mode, outpolygon can only "
- "be set to zero when there is one image, you have given %zu "
- "images. For multiple images the region will be very large. "
- "It is best if you first crop out the larger region you want "
- "into one image, then mask the polygon", p->numin);
+ "you have only given %zu", p->nvertices);
+ if(p->polygonout && p->numin>1)
+ error(EXIT_FAILURE, 0, "currently in WCS mode, '--polygonout' can "
+ "only be set to zero when there is one image, you have given "
+ "%zu images. For multiple images the region will be very "
+ "large. It is best if you first crop out the larger region "
+ "you want into one image, then mask the polygon", p->numin);
+
+ /* Put the coordinates into an array while reversing their order so
+ they correspond to the user's order, then put it in the right
+ place.*/
+ darray=p->polygon->array;
+ if(p->mode==IMGCROP_MODE_IMG) {p->ipolygon=darray; p->wpolygon=NULL; }
+ else {p->ipolygon=NULL; p->wpolygon=darray;}
+
+ /* We know that the cropped region is not defined by its center. So
+ it makes no sense to check if the center is blank. */
+ p->checkcenter=0;
}
else
p->wpolygon=p->ipolygon=NULL;
@@ -390,7 +406,7 @@ ui_read_check_only_options(struct cropparams *p)
/* If we are in WCS mode, noblanks must be off */
if(p->mode==IMGCROP_MODE_WCS && p->noblank)
- error(EXIT_FAILURE, 0, "`--noblanks` (`-b`) is only for image mode. "
+ error(EXIT_FAILURE, 0, "'--noblanks' ('-b') is only for image mode. "
"You have called it with WCS mode");
}
@@ -408,8 +424,8 @@ ui_check_options_and_arguments(struct cropparams *p)
/* Make sure that a HDU is also given. */
if(p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the input is a FITS "
- "file, a HDU must also be specified, you can use the `--hdu' "
- "(`-h') option and give it the HDU number (starting from "
+ "file, a HDU must also be specified, you can use the '--hdu' "
+ "('-h') option and give it the HDU number (starting from "
"zero), extension name, or anything acceptable by CFITSIO");
/* If in image mode, there should only be one input image. */
@@ -426,14 +442,14 @@ ui_check_options_and_arguments(struct cropparams *p)
if(p->catname)
{
/* When multiple threads need to access a file, CFITSIO needs to be
- configured with the `--enable-reentrant` option and we can only
- know from the `fits_is_reentrant' function that came from CFITSIO
+ configured with the '--enable-reentrant' option and we can only
+ know from the 'fits_is_reentrant' function that came from CFITSIO
version 3.30. */
#if GAL_CONFIG_HAVE_FITS_IS_REENTRANT == 1
if(p->cp.numthreads>1 && fits_is_reentrant()==0)
{
fprintf(stderr, "WARNING: CFITSIO was not configured with the "
- "`--enable-reentrant' option but you have asked to crop "
+ "'--enable-reentrant' option but you have asked to crop "
"on %zu threads. Therefore only one thread will be used.\n\n"
"Please run the following command to learn more about "
"configuring CFITSIO:\n\n"
@@ -444,11 +460,11 @@ ui_check_options_and_arguments(struct cropparams *p)
if(p->cp.numthreads>1)
{
fprintf(stderr, "WARNING: the installed CFITSIO version doesn't "
- "have `fits_is_reentrant' function (it is older than "
+ "have 'fits_is_reentrant' function (it is older than "
"version 3.30). But you have asked to crop on %zu threads."
"Therefore only one thread will be used.\n\n"
"To avoid this warning, you can set the number of threads "
- "to one with `-N1' or update your installation of CFITSIO.",
+ "to one with '-N1' or update your installation of CFITSIO.",
p->cp.numthreads);
p->cp.numthreads=1;
}
@@ -500,13 +516,13 @@ ui_set_img_sizes(struct cropparams *p)
/* Make sure a width value is actually given. */
if(p->width==NULL)
error(EXIT_FAILURE, 0, "no crop width specified. When crops are "
- "defined by their center (with `--center' or `--catalog') a "
- "width is necessary (using the `--width' option)");
+ "defined by their center (with '--center' or '--catalog') a "
+ "width is necessary (using the '--width' option)");
/* Make sure that the width array only has one element or the same number
of elements as the input's dimensions. */
if(p->width->size!=ndim && p->width->size!=1)
- error(EXIT_FAILURE, 0, "%zu values give to `--width', but input is %zu "
+ error(EXIT_FAILURE, 0, "%zu values give to '--width', but input is %zu "
"dimensions. It can only take either one value (same width in all "
"dimensions), or the same number as the input's dimensions",
p->width->size, ndim);
@@ -538,7 +554,7 @@ ui_set_img_sizes(struct cropparams *p)
{
/* Convert the width in units of the input's WCS into pixels. */
pwidth = warray[i]/p->pixscale[i];
- if(pwidth<3 || pwidth>50000)
+ if(pwidth<1 || pwidth>50000)
error(EXIT_FAILURE, 0, "value %g (requested width along "
"dimension %zu) translates to %.0f pixels on this "
"dataset. This is probably not what you wanted. Note "
@@ -547,7 +563,7 @@ ui_set_img_sizes(struct cropparams *p)
"You can do the conversion to the dataset's WCS units "
"prior to calling Crop. Alternatively, you can specify "
"all the coordinates/sizes in image (not WCS) units and "
- "use the `--mode=img' option", warray[i], i+1, pwidth,
+ "use the '--mode=img' option", warray[i], i+1, pwidth,
p->pixscale[i]);
/* Write the single valued width in WCS and the image width for
@@ -594,7 +610,7 @@ ui_set_img_sizes(struct cropparams *p)
/* Convert the floating point value to an integer. */
p->checkcenter=GAL_DIMENSION_FLT_TO_INT(pcheckcenter);
- /* If `checkcenter' isn't zero, but is even, convert it to an odd
+ /* If 'checkcenter' isn't zero, but is even, convert it to an odd
number (so the actual center can be checked). */
if(p->checkcenter && p->checkcenter%2==0) p->checkcenter += 1;
}
@@ -625,9 +641,9 @@ ui_read_cols(struct cropparams *p)
as the number of dimensions in the input dataset(s). */
ncoordcols=gal_list_str_number(p->coordcol);
if( ncoordcols < ndim)
- error(EXIT_FAILURE, 0, "`--coordcol' was called %zu times, but the "
+ error(EXIT_FAILURE, 0, "'--coordcol' was called %zu times, but the "
"input dataset%s %zu dimensions. Recall that through "
- "`--coordcol' you are specifying the columns containing the "
+ "'--coordcol' you are specifying the columns containing the "
"coordinates of the center of the crop in a catalog",
ncoordcols, (p->numin==1?" has":"s have"), ndim);
@@ -636,7 +652,7 @@ ui_read_cols(struct cropparams *p)
else if( ncoordcols > ndim )
{
/* Go over the columns find the last, but first initialize the
- two (`lastcolstr' to avoid compiler warnings). */
+ two ('lastcolstr' to avoid compiler warnings). */
lastcolstr=extracolstr=p->coordcol;
for(i=0;i<ndim;++i)
{
@@ -647,7 +663,7 @@ ui_read_cols(struct cropparams *p)
extracolstr=extracolstr->next;
}
- /* Set the `next' element of the last node to NULL and free the
+ /* Set the 'next' element of the last node to NULL and free the
extra ones. */
lastcolstr->next=NULL;
gal_list_str_free(extracolstr, 1);
@@ -657,7 +673,7 @@ ui_read_cols(struct cropparams *p)
error(EXIT_FAILURE, 0, "no coordinate columns specified. When a catalog"
"is given, it is necessary to identify which columns identify "
"the coordinate values in which dimension.\n\n"
- "You can do this by calling `--coordcol' multiple times, the "
+ "You can do this by calling '--coordcol' multiple times, the "
"order must be in the same order as the input's dimensions. "
"For more information on how to select columns in Gnuastro, "
"please run the following command:\n\n"
@@ -695,7 +711,7 @@ ui_read_cols(struct cropparams *p)
gal_tableintern_error_col_selection(p->catname, p->cathdu, "too many "
"columns were selected by the given "
"values to the options ending in "
- "`col'.");
+ "'col'.");
/* Put the information in each column in the proper place. */
@@ -731,7 +747,7 @@ ui_read_cols(struct cropparams *p)
}
/* Sanity check and clean up. Note that it might happen that the
- input structure is already freed. In that case, `corrtype' will be
+ input structure is already freed. In that case, 'corrtype' will be
NULL. */
if(corrtype)
{
@@ -742,8 +758,8 @@ ui_read_cols(struct cropparams *p)
gal_fits_name_save_as_string(p->catname, p->cathdu),
colname);
- /* Free the unnecessary sturcture information. The correct-type
- (`corrtype') data structure's array is necessary for later
+ /* Free the unnecessary structure information. The correct-type
+ ('corrtype') data structure's array is necessary for later
steps, so its pointer has been copied in the main program's
structure. Hence, we should set the structure's pointer to
NULL so the important data isn't freed.*/
@@ -768,10 +784,9 @@ ui_prepare_center(struct cropparams *p)
errno=0;
p->centercoords=malloc(ndim*sizeof *p->centercoords);
if( p->centercoords==NULL )
- error(EXIT_FAILURE, 0, "%s: %zu bytes for `p->centercoords'",
+ error(EXIT_FAILURE, 0, "%s: %zu bytes for 'p->centercoords'",
__func__, ndim*sizeof *p->centercoords);
-
/* Set the integer widths of the crop(s) when defined by center. */
ui_set_img_sizes(p);
@@ -832,16 +847,146 @@ ui_make_log(struct cropparams *p)
+/* When there is a single image, to avoid complications in the WCS checks,
+ simply convert all the values to pixels and switch to image mode. */
+void
+ui_preparations_to_img_mode(struct cropparams *p)
+{
+ size_t i;
+ int nwcs;
+ double *darr, *pixscale;
+ struct wcsprm *wcs=gal_wcs_read(p->inputs->v, p->cp.hdu, p->hstartwcs,
+ p->hendwcs, &nwcs);
+
+ /* Make sure a WCS actually exists. */
+ if(wcs==NULL)
+ error(EXIT_FAILURE, 0, "%s (hdu %s): the WCS structure is not "
+ "recognized or isn't present. Hence the WCS mode cannot be "
+ "used as input coordinates. You can try with pixel coordinates "
+ "using '--mode=img'", p->inputs->v, p->cp.hdu);
+
+ /* If the coordinates are in galactic mode, inform the user. */
+ if( !p->cp.quiet
+ && (strcmp(wcs->lngtyp, "RA") || strcmp(wcs->lattyp,"DEC")) )
+ error(EXIT_SUCCESS, 0, "%s (hdu %s): uses the Galactic "
+ "coordinate system for its WCS. If your given point(s) "
+ "are in the Equatorial coordinate system (RA, Dec), you "
+ "will get wrong results. You can suppress this warning "
+ "with '--quiet'", p->inputs->v, p->cp.hdu);
+
+ /* Convert the given coordinates. */
+ if(p->center || p->catname)
+ {
+ /* Check the requested width and convert it to pixels. */
+ darr=p->width->array;
+ if(wcs->naxis<p->width->size)
+ error(EXIT_FAILURE, 0, "%s (hdu %s): its WCS has %d dimensions "
+ "but %zu dimensions given to '--width'", p->inputs->v,
+ p->cp.hdu, wcs->naxis, p->width->size);
+ pixscale=gal_wcs_pixel_scale(wcs);
+ for(i=0;i<p->width->size;++i) darr[i] /= pixscale[i];
+ free(pixscale);
+ }
+
+ /* Switch the mode and return. */
+ p->mode=IMGCROP_MODE_IMG;
+ wcsfree(wcs);
+}
+
+
+
+
+
+static void
+ui_preparations_to_img_mode_values(struct cropparams *p)
+{
+ struct wcsprm *wcs=p->imgs[0].wcs;
+
+ int i, status, *stat=NULL;
+ gal_data_t *tmp, *coords=NULL;
+ size_t ndim=wcs->naxis, plysize=p->nvertices;
+ double *phi=NULL, *theta=NULL, *pixcrd=NULL, *imgcrd=NULL;
+
+ /* When central coordinates (either from '--center' or '--catalog' are
+ given). */
+ if(p->centercoords)
+ {
+ /* Put the coordinate arrays in a list (note that they are in reverse
+ mode). */
+ for(i=ndim-1;i>=0;--i)
+ gal_list_data_add_alloc(&coords, p->centercoords[i],
+ GAL_TYPE_FLOAT64, 1, &p->numout, NULL,
+ 0, p->cp.minmapsize, p->cp.quietmmap,
+ NULL, NULL, NULL);
+
+ /* Convert the world coordinates to image coordinates. */
+ gal_wcs_world_to_img(coords, wcs, 1);
+
+ /* Clean up: we want the 'array' elements, so we'll set them to
+ NULL first, then clean up the list. */
+ for(tmp=coords;tmp!=NULL;tmp=tmp->next) tmp->array=NULL;
+ gal_list_data_free(coords);
+ }
+ else if (p->wpolygon)
+ {
+ /* Allocate the necessary arrays, directly calling WCSLIB is easier
+ in this case, because the polygon array for all the points is a
+ single array, not many columns. */
+ phi = gal_pointer_allocate(GAL_TYPE_FLOAT64, plysize, 0,
+ __func__, "phi");
+ stat = gal_pointer_allocate(GAL_TYPE_INT32, plysize, 1,
+ __func__, "stat");
+ theta = gal_pointer_allocate(GAL_TYPE_FLOAT64, plysize, 0,
+ __func__, "theta");
+ imgcrd = gal_pointer_allocate(GAL_TYPE_FLOAT64, ndim*plysize, 0,
+ __func__, "imgcrd");
+ pixcrd = gal_pointer_allocate(GAL_TYPE_FLOAT64, ndim*plysize, 0,
+ __func__, "pixcrd");
+
+ /* Do the conversion. */
+ status=wcss2p(wcs, plysize, ndim, p->wpolygon, phi, theta, imgcrd,
+ pixcrd, stat);
+ if(status)
+ error(EXIT_FAILURE, 0, "%s: wcss2p ERROR %d: %s", __func__, status,
+ wcs_errmsg[status]);
+
+ /* Replace the arrays. */
+ p->ipolygon=pixcrd;
+ free(p->wpolygon);
+ p->wpolygon=NULL;
+
+ /* Clean up. */
+ free(phi);
+ free(stat);
+ free(theta);
+ free(imgcrd);
+ }
+ else
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
+ "the problem. the centercoords and wpolygon are both NULL",
+ __func__, PACKAGE_BUGREPORT);
+}
+
+
void
ui_preparations(struct cropparams *p)
{
fitsfile *tmpfits;
+ int internalimgmode=0;
struct inputimgs *img;
int status, firsttype=0;
size_t input_counter, firstndim=0;
+ /* If there is only one dataset, convert the given coordinates to pixels
+ and switch to image mode. */
+ if(p->numin==1 && p->mode==IMGCROP_MODE_WCS)
+ {
+ internalimgmode=1;
+ ui_preparations_to_img_mode(p);
+ }
+
/* For polygon and section, there should be no center checking. */
if(p->polygon || p->section)
p->checkcenter=0;
@@ -862,7 +1007,7 @@ ui_preparations(struct cropparams *p)
__func__, p->numin*sizeof *p->imgs);
- /* Fill in the WCS information of each image. */
+ /* Do basic checks of all input images. */
input_counter=p->numin;
while(p->inputs)
{
@@ -885,10 +1030,11 @@ ui_preparations(struct cropparams *p)
}
else
if(p->mode==IMGCROP_MODE_WCS)
- error(EXIT_FAILURE, 0, "the WCS structure of %s (hdu: %s) "
- "image is not recognized. So WCS mode cannot be used "
- "as input coordinates. You can try with pixel coordinates "
- "with `--mode=img'", img->name, p->cp.hdu);
+ error(EXIT_FAILURE, 0, "%s (hdu %s): the WCS structure is "
+ "not recognized or isn't present. Hence the WCS mode "
+ "cannot be used as input coordinates. You can try with "
+ "pixel coordinates using '--mode=img'", img->name,
+ p->cp.hdu);
fits_close_file(tmpfits, &status);
gal_fits_io_error(status, NULL);
@@ -911,17 +1057,17 @@ ui_preparations(struct cropparams *p)
correspond to the dimensionality of the data. */
if(p->center && p->center->size!=firstndim)
error(EXIT_FAILURE, 0, "%s (hdu %s) has %zu dimensions, but "
- "%zu coordinates were given to `--center'", img->name,
+ "%zu coordinates were given to '--center'", img->name,
p->cp.hdu, firstndim, p->center->size);
}
else
{
if(firsttype!=p->type)
- error(EXIT_FAILURE, 0, "%s: type is `%s' while previous input(s) "
- "were `%s' type. All inputs must have the same pixel data "
+ error(EXIT_FAILURE, 0, "%s: type is '%s' while previous input(s) "
+ "were '%s' type. All inputs must have the same pixel data "
"type.\n\nYou can use Gnuastro's Arithmetic program to "
- "convert `%s' to `%s', please run this command for more "
- "information (press `SPACE' for going down and `q' to "
+ "convert '%s' to '%s', please run this command for more "
+ "information (press 'SPACE' for going down and 'q' to "
"return to the command-line):\n\n"
" $ info Arithmetic\n",
img->name, gal_type_name(p->type, 1),
@@ -946,16 +1092,22 @@ ui_preparations(struct cropparams *p)
p->imgs->name, p->imgs->ndim);
- /* Unify central crop methods into `p->centercoords'. */
+ /* Unify central crop methods into 'p->centercoords'. */
if(p->catname || p->center)
ui_prepare_center(p);
- /* `ui_read_cols' set the number of output crops when a catalog was
+ /* 'ui_read_cols' set the number of output crops when a catalog was
given, in all other cases, we only have one output. */
if(p->catname==NULL) p->numout=1;
+ /* If there was only one input file and the WCS-mode was internally
+ changed to image-mode, then convert the coordinates too. */
+ if(internalimgmode)
+ ui_preparations_to_img_mode_values(p);
+
+
/* Prepare the log file if the user has asked for it. */
ui_make_log(p);
}
@@ -991,9 +1143,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
cropparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/crop/ui.h b/bin/crop/ui.h
index de2cbae..9a34fa2 100644
--- a/bin/crop/ui.h
+++ b/bin/crop/ui.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -68,8 +68,10 @@ enum option_keys_enum
UI_KEY_CATHDU = 1000,
UI_KEY_HSTARTWCS,
UI_KEY_HENDWCS,
- UI_KEY_OUTPOLYGON,
+ UI_KEY_POLYGONOUT,
+ UI_KEY_POLYGONSORT,
UI_KEY_CHECKCENTER,
+ UI_KEY_PRIMARYIMGHDU,
};
diff --git a/bin/crop/wcsmode.c b/bin/crop/wcsmode.c
index f57ef3d..a980f11 100644
--- a/bin/crop/wcsmode.c
+++ b/bin/crop/wcsmode.c
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -95,8 +95,8 @@ wcsmode_check_prepare(struct cropparams *p, struct inputimgs
*img)
if( strcmp(wcs->ctype[0], "RA---TAN")
|| strcmp(wcs->ctype[1], "DEC--TAN") )
error(EXIT_FAILURE, 0, "currently the only WCS types usable are "
- "`RA---TAN' and `DEC--TAN' for the first and second axises "
- "respectively. The WCS types of `%s' (hdu %s) are `%s' and `%s' "
+ "'RA---TAN' and 'DEC--TAN' for the first and second axises "
+ "respectively. The WCS types of '%s' (hdu %s) are '%s' and '%s' "
"respectively", img->name, p->cp.hdu, wcs->ctype[0], wcs->ctype[1]);
@@ -116,7 +116,7 @@ wcsmode_check_prepare(struct cropparams *p, struct
inputimgs *img)
if(p->pixscale)
{
for(i=0;i<ndim;++i)
- if(p->pixscale[i] != pixscale[i])
+ if(fabs(p->pixscale[i]-pixscale[i])>1e-10) /* Floating point errors. */
error(EXIT_FAILURE, 0, "%s (hdu %s): has resolution of %g along "
"dimension %d. However, previously checked input(s) had "
"a resolution of %g in this dimension", img->name, p->cp.hdu,
@@ -127,7 +127,7 @@ wcsmode_check_prepare(struct cropparams *p, struct
inputimgs *img)
p->pixscale=pixscale;
- /* Set the coordinates of the dataset's corners. Note that `dsize' is in
+ /* Set the coordinates of the dataset's corners. Note that 'dsize' is in
C order, while pixcrd is in FITS order.*/
switch(ndim)
{
@@ -168,8 +168,8 @@ wcsmode_check_prepare(struct cropparams *p, struct
inputimgs *img)
/* Fill in the size of the dataset in WCS from the first pixel in the
- image. Note that `dsize' is in C axises, while the `pixscale',
- `corners' and `sized' are in FITS axises. */
+ image. Note that 'dsize' is in C axises, while the 'pixscale',
+ 'corners' and 'sized' are in FITS axises. */
if(ndim==2)
{
img->sized[0] = ( img->dsize[1] * p->pixscale[0]
@@ -187,17 +187,17 @@ wcsmode_check_prepare(struct cropparams *p, struct
inputimgs *img)
/* In case the image crosses the equator, we will calculate these values
here so later on, we don't have to calculate them on every check. See
- the explanation above `point_in_dataset'.
+ the explanation above 'point_in_dataset'.
Note that in both 2D and 3D data, the declination is in the second
coordinate (index 1). */
if( img->corners[1] * (img->corners[1]+img->sized[1]) < 0 )
{
- /* re in the comments above `point_in_dataset'. */
+ /* re in the comments above 'point_in_dataset'. */
img->equatorcorr[0]=img->corners[0]
-0.5*img->sized[0]*(1-cos(img->corners[1]*M_PI/180));
- /* sre in the comments above `point_in_dataset'. */
+ /* sre in the comments above 'point_in_dataset'. */
img->equatorcorr[1]=img->sized[0]*cos(img->corners[1]*M_PI/180);
}
@@ -385,14 +385,14 @@ wcsmode_crop_corners(struct onecropparams *crp)
/* In case the crop crosses the equator, then we need these two
- corrections. See the complete explanations above `point_in_dataset'. */
+ corrections. See the complete explanations above 'point_in_dataset'. */
if(crp->corners[1]*(crp->corners[1]+crp->sized[1]) < 0 )
{
- /* re in the explanations above `point_in_dataset'. */
+ /* re in the explanations above 'point_in_dataset'. */
crp->equatorcorr[0]=crp->corners[0]
-0.5*crp->sized[0]*(1-cos(crp->corners[1]*M_PI/180));
- /* sre in the explanations above `point_in_dataset'. */
+ /* sre in the explanations above 'point_in_dataset'. */
crp->equatorcorr[1]=crp->sized[0]*cos(crp->corners[1]*M_PI/180);
}
@@ -559,7 +559,7 @@ fillcrpipolygon(struct onecropparams *crp)
dp>=d1 && dp<=d1+sd
For RA, things become a little more complicated (recall that
- r1>r3). `n` is defined as half of the extra space between the top
+ r1>r3). 'n' is defined as half of the extra space between the top
and bottom lines of the two trapezoids.
(North) n=0.5*sr*(1/cos(dp-d1)-1) ==> rp<=r1+n && rp>=r1-sr-n
@@ -572,7 +572,7 @@ fillcrpipolygon(struct onecropparams *crp)
-------------------------
When d1*(d1+sd)<0, the image crosses the equator (d1 is negative
- and d1+sd is positive). In this case, we define `re` and `sre` as
+ and d1+sd is positive). In this case, we define 're' and 'sre' as
an equivalent of r1 and sr but on the equator:
re=r1-0.5*sr*(1-cos(d1)) && sre=sr*cos(d1)
diff --git a/bin/crop/wcsmode.h b/bin/crop/wcsmode.h
index 989a6e9..cb3ac23 100644
--- a/bin/crop/wcsmode.h
+++ b/bin/crop/wcsmode.h
@@ -5,7 +5,7 @@ Crop is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/Makefile.am b/bin/fits/Makefile.am
index a112c75..869cbc1 100644
--- a/bin/fits/Makefile.am
+++ b/bin/fits/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astfits
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astfits_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astfits_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astfits_SOURCES = main.c ui.c extension.c fits.c keywords.c
diff --git a/bin/fits/args.h b/bin/fits/args.h
index b4c6584..af1d90c 100644
--- a/bin/fits/args.h
+++ b/bin/fits/args.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -31,11 +31,71 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Array of acceptable options. */
struct argp_option program_options[] =
{
- /* Input options */
{
0, 0, 0, 0,
- "HDUs (extensions):",
- UI_GROUP_EXTENSION
+ "HDU (extension) information:",
+ UI_GROUP_EXTENSION_INFORMATION
+ },
+ {
+ "numhdus",
+ UI_KEY_NUMHDUS,
+ 0,
+ 0,
+ "Print number of HDUs in the given FITS file.",
+ UI_GROUP_EXTENSION_INFORMATION,
+ &p->numhdus,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "datasum",
+ UI_KEY_DATASUM,
+ 0,
+ 0,
+ "Calculate HDU's datasum and print in stdout.",
+ UI_GROUP_EXTENSION_INFORMATION,
+ &p->datasum,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "pixelscale",
+ UI_KEY_PIXELSCALE,
+ 0,
+ 0,
+ "Return the pixel-scale of the HDU's WCS.",
+ UI_GROUP_EXTENSION_INFORMATION,
+ &p->pixelscale,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "skycoverage",
+ UI_KEY_SKYCOVERAGE,
+ 0,
+ 0,
+ "Image coverage in the WCS coordinates.",
+ UI_GROUP_EXTENSION_INFORMATION,
+ &p->skycoverage,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+
+
+
+
+ {
+ 0, 0, 0, 0,
+ "HDU (extension) manipulation:",
+ UI_GROUP_EXTENSION_MANIPULATION
},
{
"remove",
@@ -43,7 +103,7 @@ struct argp_option program_options[] =
"STR",
0,
"Remove extension from input file.",
- UI_GROUP_EXTENSION,
+ UI_GROUP_EXTENSION_MANIPULATION,
&p->remove,
GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
@@ -56,7 +116,7 @@ struct argp_option program_options[] =
"STR",
0,
"Copy extension to output file.",
- UI_GROUP_EXTENSION,
+ UI_GROUP_EXTENSION_MANIPULATION,
&p->copy,
GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
@@ -69,7 +129,7 @@ struct argp_option program_options[] =
"STR",
0,
"Copy extension to output and remove from input.",
- UI_GROUP_EXTENSION,
+ UI_GROUP_EXTENSION_MANIPULATION,
&p->cut,
GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
@@ -77,25 +137,12 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET
},
{
- "numhdus",
- UI_KEY_NUMHDUS,
- 0,
- 0,
- "Print number of HDUs in the given FITS file.",
- UI_GROUP_EXTENSION,
- &p->numhdus,
- GAL_OPTIONS_NO_ARG_TYPE,
- GAL_OPTIONS_RANGE_0_OR_1,
- GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
- },
- {
"primaryimghdu",
UI_KEY_PRIMARYIMGHDU,
0,
0,
"Copy/cut image HDUs to primary/zero-th HDU.",
- UI_GROUP_EXTENSION,
+ UI_GROUP_EXTENSION_MANIPULATION,
&p->primaryimghdu,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
@@ -117,7 +164,7 @@ struct argp_option program_options[] =
UI_KEY_ASIS,
"STR",
0,
- "Write the argument string as is into the header.",
+ "Write value as-is (may corrupt FITS file).",
UI_GROUP_KEYWORD,
&p->asis,
GAL_TYPE_STRLL,
@@ -126,6 +173,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET
},
{
+ "keyvalue",
+ UI_KEY_KEYVALUE,
+ "STR[,STR,...]",
+ 0,
+ "Only print the value of requested keyword(s).",
+ UI_GROUP_KEYWORD,
+ &p->keyvalue,
+ GAL_TYPE_STRLL,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
"delete",
UI_KEY_DELETE,
"STR",
@@ -268,6 +328,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "wcsdistortion",
+ UI_KEY_WCSDISTORTION,
+ "STR",
+ 0,
+ "Convert WCS distortion to another type.",
+ UI_GROUP_KEYWORD,
+ &p->wcsdistortion,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
@@ -287,6 +360,21 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "colinfoinstdout",
+ UI_KEY_COLINFOINSTDOUT,
+ 0,
+ 0,
+ "Column info/metadata when printing to stdout.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->colinfoinstdout,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+
+
diff --git a/bin/fits/astfits.conf b/bin/fits/astfits.conf
index a69b5d9..f8f6add 100644
--- a/bin/fits/astfits.conf
+++ b/bin/fits/astfits.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astfits # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/fits/authors-cite.h b/bin/fits/authors-cite.h
index 9ae97d0..b0932a2 100644
--- a/bin/fits/authors-cite.h
+++ b/bin/fits/authors-cite.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/fits/extension.c b/bin/fits/extension.c
index b9325bc..a9c6423 100644
--- a/bin/fits/extension.c
+++ b/bin/fits/extension.c
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/extension.h b/bin/fits/extension.h
index b54ff6a..709c7a3 100644
--- a/bin/fits/extension.h
+++ b/bin/fits/extension.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/fits.c b/bin/fits/fits.c
index 6ecb6d6..19a7a1b 100644
--- a/bin/fits/fits.c
+++ b/bin/fits/fits.c
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -27,10 +27,12 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <string.h>
#include <unistd.h>
+#include <gnuastro/wcs.h>
#include <gnuastro/list.h>
#include <gnuastro/fits.h>
#include <gnuastro/blank.h>
#include <gnuastro/pointer.h>
+#include <gnuastro/statistics.h>
#include <gnuastro-internal/timing.h>
#include <gnuastro-internal/checkset.h>
@@ -58,8 +60,8 @@ fits_has_error(struct fitsparams *p, int actioncode, char
*string, int status)
case FITS_ACTION_REMOVE: action="removed"; break;
default:
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at `%s' so we "
- "can fix this problem. The value of `actioncode' must not be %d",
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at '%s' so we "
+ "can fix this problem. The value of 'actioncode' must not be %d",
__func__, PACKAGE_BUGREPORT, actioncode);
}
@@ -86,17 +88,18 @@ fits_print_extension_info(struct fitsparams *p)
{
uint16_t *ui16;
fitsfile *fptr;
- gal_data_t *cols=NULL, *tmp;
- char **tstra, **estra, **sstra;
size_t i, numext, *dsize, ndim;
+ int hascomments=0, hasblankname=0;
+ char **tstra, **estra, **sstra, **cmstra;
int j, nc, numhdu, hdutype, status=0, type;
+ gal_data_t *tmp, *cols=NULL, *sizecol, *commentscol;
char *msg, *tstr=NULL, sstr[1000], extname[FLEN_VALUE];
/* Open the FITS file and read the first extension type, upon moving to
the next extension, we will read its type, so for the first we will
need to do it explicitly. */
- fptr=gal_fits_hdu_open(p->filename, "0", READONLY);
+ fptr=gal_fits_hdu_open(p->input->v, "0", READONLY);
if (fits_get_hdu_type(fptr, &hdutype, &status) )
gal_fits_io_error(status, "reading first extension");
@@ -110,11 +113,13 @@ fits_print_extension_info(struct fitsparams *p)
/* Allocate all the columns (in reverse order, since this is a simple
linked list). */
gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
+ -1, 1, "HDU_COMMENT", "note", "Possible comment");
+ gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-1, 1, "HDU_SIZE", "name", "Size of image or table "
"number of rows and columns.");
gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-1, 1, "HDU_TYPE", "name", "Image data type or "
- "`table' format (ASCII or binary).");
+ "'table' format (ASCII or binary).");
gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-1, 1, "EXTNAME", "name", "Extension name of this "
"HDU (EXTNAME in FITS).");
@@ -127,7 +132,12 @@ fits_print_extension_info(struct fitsparams *p)
ui16 = cols->array;
estra = cols->next->array;
tstra = cols->next->next->array;
- sstra = cols->next->next->next->array;
+
+ sizecol = cols->next->next->next;
+ sstra = sizecol->array;
+
+ commentscol = cols->next->next->next->next;
+ cmstra = commentscol->array;
cols->next->disp_width=15;
cols->next->next->disp_width=15;
@@ -154,7 +164,7 @@ fits_print_extension_info(struct fitsparams *p)
break;
default:
- error(EXIT_FAILURE, 0, "%s: a bug! the `hdutype' code %d not "
+ error(EXIT_FAILURE, 0, "%s: a bug! the 'hdutype' code %d not "
"recognized", __func__, hdutype);
}
@@ -169,6 +179,7 @@ fits_print_extension_info(struct fitsparams *p)
case KEY_NO_EXIST:
sprintf(extname, "%s", GAL_BLANK_STRING);
+ hasblankname=1;
status=0;
break;
@@ -178,9 +189,19 @@ fits_print_extension_info(struct fitsparams *p)
status=0;
- /* Write the size into a string. `sprintf' returns the number of
- written characters (excluding the `\0'). So for each dimension's
- size that is written, we add to `nc' (the number of
+ /* Check if its a healpix grid. */
+ if( gal_fits_hdu_is_healpix(fptr) )
+ {
+ hascomments=1;
+ gal_checkset_allocate_copy("HEALpix", cmstra+i);
+ }
+ else
+ gal_checkset_allocate_copy(GAL_BLANK_STRING, cmstra+i);
+
+
+ /* Write the size into a string. 'sprintf' returns the number of
+ written characters (excluding the '\0'). So for each dimension's
+ size that is written, we add to 'nc' (the number of
characters). Note that FITS allows blank extensions, in those
cases, return "0". */
if(ndim>0)
@@ -225,21 +246,33 @@ fits_print_extension_info(struct fitsparams *p)
/* Close the file. */
fits_close_file(fptr, &status);
+ /* If there weren't any comments, don't print the comment column. */
+ if(hascomments==0)
+ {
+ sizecol->next=NULL;
+ gal_data_free(commentscol);
+ }
/* Print the results. */
if(!p->cp.quiet)
{
printf("%s\nRun on %s-----\n", PROGRAM_STRING, ctime(&p->rawtime));
- printf("HDU (extension) information: `%s'.\n", p->filename);
- printf(" Column 1: Index (counting from 0, usable with `--hdu').\n");
- printf(" Column 2: Name (`EXTNAME' in FITS standard, usable with "
- "`--hdu').\n");
- printf(" Column 3: Image data type or `table' format (ASCII or "
+ printf("HDU (extension) information: '%s'.\n", p->input->v);
+ printf(" Column 1: Index (counting from 0, usable with '--hdu').\n");
+ printf(" Column 2: Name ('EXTNAME' in FITS standard, usable with "
+ "'--hdu').\n");
+ if(hasblankname)
+ printf(" ('%s' means that no name is specified for this "
+ "HDU)\n", GAL_BLANK_STRING);
+ printf(" Column 3: Image data type or 'table' format (ASCII or "
"binary).\n");
printf(" Column 4: Size of data in HDU.\n");
+ if(hascomments)
+ printf(" Column 5: Comments about the HDU (e.g., if its HEALpix, or "
+ "etc).\n");
printf("-----\n");
}
- gal_table_write(cols, NULL, GAL_TABLE_FORMAT_TXT, NULL, NULL, 0);
+ gal_table_write(cols, NULL, NULL, GAL_TABLE_FORMAT_TXT, NULL, NULL, 0);
gal_list_data_free(cols);
}
@@ -254,7 +287,7 @@ fits_hdu_number(struct fitsparams *p)
int numhdu, status=0;
/* Read the first extension (necessary for reading the rest). */
- fptr=gal_fits_hdu_open(p->filename, "0", READONLY);
+ fptr=gal_fits_hdu_open(p->input->v, "0", READONLY);
/* Get the number of HDUs. */
if( fits_get_num_hdus(fptr, &numhdu, &status) )
@@ -272,6 +305,195 @@ fits_hdu_number(struct fitsparams *p)
static void
+fits_datasum(struct fitsparams *p)
+{
+ printf("%ld\n", gal_fits_hdu_datasum(p->input->v, p->cp.hdu));
+}
+
+
+
+
+
+static void
+fits_pixelscale(struct fitsparams *p)
+{
+ int nwcs=0;
+ size_t i, ndim=0;
+ struct wcsprm *wcs;
+ double multip, *pixelscale;
+
+ /* Read the desired WCS. */
+ wcs=gal_wcs_read(p->input->v, p->cp.hdu, 0, 0, &nwcs);
+
+ /* If a WCS doesn't exist, let the user know and return. */
+ if(wcs)
+ ndim=wcs->naxis;
+ else
+ error(EXIT_FAILURE, 0, "%s (hdu %s): no WCS could be read by WCSLIB, "
+ "hence the pixel-scale cannot be determined", p->input->v,
+ p->cp.hdu);
+
+ /* Calculate the pixel-scale in each dimension. */
+ pixelscale=gal_wcs_pixel_scale(wcs);
+
+ /* If not in quiet-mode, print some extra information. We don't want the
+ last number to have a space after it, so we'll write the last one
+ outside the loop.*/
+ if(p->cp.quiet==0)
+ {
+ printf("Basic information for --pixelscale (remove extra info "
+ "with '--quiet' or '-q')\n");
+ printf(" Input: %s (hdu %s) has %zu dimensions.\n", p->input->v,
+ p->cp.hdu, ndim);
+ printf(" Pixel scale in each FITS dimension:\n");
+ for(i=0;i<ndim;++i)
+ {
+ if( !strcmp(wcs->cunit[i], "deg") )
+ printf(" %zu: %g (%s/pixel) = %g (arcsec/pixel)\n", i+1,
+ pixelscale[i], wcs->cunit[i], pixelscale[i]*3600);
+ else
+ printf(" %zu: %g (%s/slice)\n", i+1,
+ pixelscale[i], wcs->cunit[i]);
+ }
+
+ /* Pixel area/volume. */
+ if(ndim>=2)
+ {
+ /* Multiply the values in each dimension. */
+ multip=pixelscale[0]*pixelscale[1];
+
+ /* Pixel scale (applicable to 2 or 3 dimensions). */
+ printf(" Pixel area%s:\n", ndim==2?"":" (on each 2D slice) ");
+ if( strcmp(wcs->cunit[0], wcs->cunit[1]) )
+ printf(" %g (%s*%s)\n", multip, wcs->cunit[0],
+ wcs->cunit[1]);
+ else
+ if( strcmp(wcs->cunit[0], "deg") )
+ printf(" %g (%s^2)\n", multip, wcs->cunit[0]);
+ else
+ printf(" %g (deg^2) = %g (arcsec^2)\n",
+ multip, multip*3600*3600 );
+
+ /* For a 3 dimensional dataset, we need need extra info. */
+ if(ndim>=3)
+ {
+ multip*=pixelscale[2];
+ printf(" Voxel volume:\n");
+ if( strcmp(wcs->cunit[0], wcs->cunit[1]) )
+ printf(" %g (%s*%s*%s)\n", multip, wcs->cunit[0],
+ wcs->cunit[1], wcs->cunit[2]);
+ else
+ if( strcmp(wcs->cunit[0], "deg") )
+ printf(" %g (%s^2*%s)\n", multip, wcs->cunit[0],
+ wcs->cunit[2]);
+ else
+ {
+ if( strcmp(wcs->cunit[2], "m") )
+ printf(" %g (deg^2*%s) = %g (arcsec^2*%s)\n",
+ multip, wcs->cunit[2], multip*3600*3600,
+ wcs->cunit[2]);
+ else
+ printf(" %g (deg^2*m) = %g (arcsec^2*m) = "
+ "%g (arcsec^2*A)\n", multip, multip*3600*3600,
+ multip*3600*3600*1e10);
+ }
+ }
+ }
+ }
+ else
+ {
+ multip=1;
+ for(i=0;i<ndim;++i)
+ {
+ multip*=pixelscale[i];
+ printf("%g ", pixelscale[i]);
+ }
+ switch(ndim)
+ {
+ case 2: printf("%g\n", multip); break;
+ case 3: printf("%g %g\n", pixelscale[0]*pixelscale[1], multip); break;
+ }
+ }
+
+ /* Clean up. */
+ wcsfree(wcs);
+ free(pixelscale);
+}
+
+
+
+
+
+static void
+fits_skycoverage(struct fitsparams *p)
+{
+ int nwcs=0;
+ size_t i, ndim;
+ struct wcsprm *wcs;
+ double *center, *width, *min, *max;
+
+ /* Find the coverage. */
+ if( gal_wcs_coverage(p->input->v, p->cp.hdu, &ndim,
+ ¢er, &width, &min, &max)==0 )
+ error(EXIT_FAILURE, 0, "%s (hdu %s): is not usable for finding "
+ "sky coverage (either doesn't have a WCS, or isn't an image "
+ "or cube HDU with 2 or 3 dimensions", p->input->v, p->cp.hdu);
+
+ /* Inform the user. */
+ if(p->cp.quiet)
+ {
+ /* First print the center and full-width. */
+ for(i=0;i<ndim;++i) printf("%-15.10g ", center[i]);
+ for(i=0;i<ndim;++i) printf("%-15.10g ", width[i]);
+ printf("\n");
+
+ /* Then print the range in coordinates. */
+ for(i=0;i<ndim;++i) printf("%-15.10g %-15.10g ", min[i], max[i]);
+ printf("\n");
+ }
+ else
+ {
+ printf("Input file: %s (hdu: %s)\n", p->input->v, p->cp.hdu);
+ printf("\nSky coverage by center and (full) width:\n");
+ switch(ndim)
+ {
+ case 2:
+ printf(" Center: %-15.10g%-15.10g\n", center[0], center[1]);
+ printf(" Width: %-15.10g%-15.10g\n", width[0], width[1]);
+ break;
+ case 3:
+ printf(" Center: %-15.10g%-15.10g%-15.10g\n", center[0],
+ center[1], center[2]);
+ printf(" width: %-15.10g%-15.10g%-15.10g\n", width[0],
+ width[1], width[2]);
+ break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
+ "the problem. 'ndim' value %zu is not recognized", __func__,
+ PACKAGE_BUGREPORT, ndim);
+ }
+
+ /* For the range type of coverage. */
+ wcs=gal_wcs_read(p->input->v, p->cp.hdu, 0, 0, &nwcs);
+ printf("\nSky coverage by range along dimensions:\n");
+ for(i=0;i<ndim;++i)
+ printf(" %-8s %-15.10g%-15.10g\n", gal_wcs_dimension_name(wcs, i),
+ min[i], max[i]);
+ wcsfree(wcs);
+ }
+
+ /* Clean up. */
+ free(min);
+ free(max);
+ free(width);
+ free(center);
+}
+
+
+
+
+
+static void
fits_hdu_remove(struct fitsparams *p, int *r)
{
char *hdu;
@@ -284,7 +506,7 @@ fits_hdu_remove(struct fitsparams *p, int *r)
hdu=gal_list_str_pop(&p->remove);
/* Open the FITS file at the specified HDU. */
- fptr=gal_fits_hdu_open(p->filename, hdu, READWRITE);
+ fptr=gal_fits_hdu_open(p->input->v, hdu, READWRITE);
/* Delete the extension. */
if( fits_delete_hdu(fptr, &hdutype, &status) )
@@ -300,7 +522,7 @@ fits_hdu_remove(struct fitsparams *p, int *r)
-/* This is similar to the library's `gal_fits_open_to_write', except that
+/* This is similar to the library's 'gal_fits_open_to_write', except that
it won't create an empty first extension.*/
fitsfile *
fits_open_to_write_no_blank(char *filename)
@@ -346,12 +568,12 @@ fits_hdu_copy(struct fitsparams *p, int cut1_copy0, int
*r)
hdu=gal_list_str_pop(&list);
/* Open the FITS file at the specified HDU. */
- in=gal_fits_hdu_open(p->filename, hdu,
+ in=gal_fits_hdu_open(p->input->v, hdu,
cut1_copy0 ? READWRITE : READONLY);
/* If the output isn't opened yet, open it. */
if(out==NULL)
- out = ( ( gal_fits_hdu_format(p->filename, hdu)==IMAGE_HDU
+ out = ( ( gal_fits_hdu_format(p->input->v, hdu)==IMAGE_HDU
&& p->primaryimghdu )
? fits_open_to_write_no_blank(p->cp.output)
: gal_fits_open_to_write(p->cp.output) );
@@ -362,7 +584,7 @@ fits_hdu_copy(struct fitsparams *p, int cut1_copy0, int *r)
*r=fits_has_error(p, FITS_ACTION_COPY, hdu, status);
status=0;
- /* If this is a `cut' operation, then remove the extension. */
+ /* If this is a 'cut' operation, then remove the extension. */
if(cut1_copy0)
{
if( fits_delete_hdu(in, &hdutype, &status) )
@@ -389,7 +611,7 @@ fits(struct fitsparams *p)
switch(p->mode)
{
- /* Keywords, we have a separate set of functions in `keywords.c'. */
+ /* Keywords, we have a separate set of functions in 'keywords.c'. */
case FITS_MODE_KEY:
r=keywords(p);
break;
@@ -398,8 +620,10 @@ fits(struct fitsparams *p)
case FITS_MODE_HDU:
/* Options that must be called alone. */
- if(p->numhdus)
- fits_hdu_number(p);
+ if(p->numhdus) fits_hdu_number(p);
+ else if(p->datasum) fits_datasum(p);
+ else if(p->pixelscale) fits_pixelscale(p);
+ else if(p->skycoverage) fits_skycoverage(p);
/* Options that can be called together. */
else
diff --git a/bin/fits/fits.h b/bin/fits/fits.h
index 06f461c..10a10fe 100644
--- a/bin/fits/fits.h
+++ b/bin/fits/fits.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index f7346ff..9a325f6 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -28,7 +28,9 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <string.h>
#include <stdlib.h>
+#include <gnuastro/wcs.h>
#include <gnuastro/fits.h>
+#include <gnuastro/pointer.h>
#include <gnuastro-internal/timing.h>
#include <gnuastro-internal/checkset.h>
@@ -51,7 +53,7 @@ static void
keywords_open(struct fitsparams *p, fitsfile **fptr, int iomode)
{
if(*fptr==NULL)
- *fptr=gal_fits_hdu_open(p->filename, p->cp.hdu, iomode);
+ *fptr=gal_fits_hdu_open(p->input->v, p->cp.hdu, iomode);
}
@@ -92,7 +94,7 @@ keywords_rename_keys(struct fitsparams *p, fitsfile **fptr,
int *r)
str=gal_list_str_pop(&p->rename);
/* Take a copy of the input string for error reporting, because
- `strtok' will write into the array. */
+ 'strtok' will write into the array. */
gal_checkset_allocate_copy(str, ©);
/* Tokenize the input. */
@@ -101,18 +103,18 @@ keywords_rename_keys(struct fitsparams *p, fitsfile
**fptr, int *r)
/* Make sure both elements were read. */
if(from==NULL || to==NULL)
- error(EXIT_FAILURE, 0, "`%s' could not be tokenized in order to "
+ error(EXIT_FAILURE, 0, "'%s' could not be tokenized in order to "
"complete rename. There should be a space character "
"or a comma (,) between the two keyword names. If you have "
"used the space character, be sure to enclose the value to "
- "the `--rename' option in double quotation marks", copy);
+ "the '--rename' option in double quotation marks", copy);
/* Rename the keyword */
fits_modify_name(*fptr, from, to, &status);
if(status) *r=fits_has_error(p, FITS_ACTION_RENAME, from, status);
status=0;
- /* Clean up the user's input string. Note that `strtok' just changes
+ /* Clean up the user's input string. Note that 'strtok' just changes
characters within the allocated string, no extra allocation is
done. */
free(str);
@@ -140,7 +142,7 @@ keywords_write_set_value(struct fitsparams *p, fitsfile
**fptr,
return 1;
else
{
- /* Calculate and write the `CHECKSUM' and `DATASUM' keywords. */
+ /* Calculate and write the 'CHECKSUM' and 'DATASUM' keywords. */
if( fits_write_chksum(*fptr, &status) )
gal_fits_io_error(status, NULL);
@@ -161,7 +163,7 @@ keywords_write_set_value(struct fitsparams *p, fitsfile
**fptr,
}
else
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
- "fix the problem. The `keyname' value `%s' is not "
+ "fix the problem. The 'keyname' value '%s' is not "
"recognized as one with no value", __func__,
PACKAGE_BUGREPORT, keyll->keyname);
@@ -236,9 +238,9 @@ keywords_write_update(struct fitsparams *p, fitsfile **fptr,
gal_fits_io_error(status, NULL);
}
else
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at `%s' so "
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at '%s' so "
"we can fix this problem. The value %d is not valid for "
- "`u1w2'", __func__, PACKAGE_BUGREPORT, u1w2);
+ "'u1w2'", __func__, PACKAGE_BUGREPORT, u1w2);
/* Add the unit (if one was given). */
if(keyll->unit
@@ -314,13 +316,13 @@ keywords_verify(struct fitsparams *p, fitsfile **fptr)
"Checking integrity of %s (hdu %s)\n"
"%s"
"--------\n"
- "Basic info (remove all extra info with `--quiet'):\n"
+ "Basic info (remove all extra info with '--quiet'):\n"
" - DATASUM: verifies only the data (not keywords).\n"
" - CHECKSUM: verifies data and keywords.\n"
"They can be added-to/updated-in an extension/HDU with:\n"
" $ astfits %s -h%s --write=checksum\n"
- "--------\n", PROGRAM_STRING, p->filename, p->cp.hdu,
- ctime(&p->rawtime), p->filename, p->cp.hdu);
+ "--------\n", PROGRAM_STRING, p->input->v, p->cp.hdu,
+ ctime(&p->rawtime), p->input->v, p->cp.hdu);
/* Print the verification result. */
printf("DATASUM: %s\n",
@@ -345,13 +347,13 @@ keywords_copykeys(struct fitsparams *p, char *inkeys,
size_t numinkeys)
long initial;
fitsfile *fptr;
- /* Initial sanity check. Since `numinkeys' includes `END' (counting from
+ /* Initial sanity check. Since 'numinkeys' includes 'END' (counting from
1, as we do here), the first keyword must not be larger OR EQUAL to
- `numinkeys'. */
+ 'numinkeys'. */
if(p->copykeysrange[0]>=numinkeys)
error(EXIT_FAILURE, 0, "%s (hdu %s): first keyword number give to "
- "`--copykeys' (%ld) is larger than the number of keywords in this "
- "header (%zu, including the `END' keyword)", p->filename, p->cp.hdu,
+ "'--copykeys' (%ld) is larger than the number of keywords in this "
+ "header (%zu, including the 'END' keyword)", p->input->v, p->cp.hdu,
p->copykeysrange[0], numinkeys);
/* If the user wanted to count from the end (by giving a negative value),
@@ -365,16 +367,16 @@ keywords_copykeys(struct fitsparams *p, char *inkeys,
size_t numinkeys)
/* Sanity check. */
if(p->copykeysrange[0]>=p->copykeysrange[1])
error(EXIT_FAILURE, 0, "%s (hdu %s): the last keyword given to "
- "`--copykeys' (%ld, or %ld after counting from the bottom) "
- "is earlier than the first (%ld)", p->filename, p->cp.hdu,
+ "'--copykeys' (%ld, or %ld after counting from the bottom) "
+ "is earlier than the first (%ld)", p->input->v, p->cp.hdu,
initial, p->copykeysrange[1], p->copykeysrange[0]);
}
/* Final sanity check (on range limit). */
if(p->copykeysrange[1]>=numinkeys)
error(EXIT_FAILURE, 0, "%s (hdu %s): second keyword number give to "
- "`--copykeys' (%ld) is larger than the number of keywords in this "
- "header (%zu, including the `END' keyword)", p->filename, p->cp.hdu,
+ "'--copykeys' (%ld) is larger than the number of keywords in this "
+ "header (%zu, including the 'END' keyword)", p->input->v, p->cp.hdu,
p->copykeysrange[1], numinkeys);
@@ -403,28 +405,447 @@ keywords_date_to_seconds(struct fitsparams *p, fitsfile
*fptr)
int status=0;
double subsec;
size_t seconds;
- char *subsecstr;
+ char *subsecstr=NULL;
char fitsdate[FLEN_KEYWORD];
/* Read the requested FITS keyword. */
if( fits_read_key(fptr, TSTRING, p->datetosec, &fitsdate, NULL, &status) )
gal_fits_io_error(status, NULL);
- /* Return the number of seconds (and subseconds) that it corresponds
- to. */
+ /* Return the number of seconds (and subseconds).*/
seconds=gal_fits_key_date_to_seconds(fitsdate, &subsecstr, &subsec);
+ if(seconds==GAL_BLANK_SIZE_T)
+ error(EXIT_FAILURE, 0, "the time string couldn't be interpretted");
/* Print the result (for the sub-seconds, print everything after the */
if( !p->cp.quiet )
{
- printf("%s (hdu %s), key `%s': %s\n", p->filename, p->cp.hdu,
+ printf("%s (hdu %s), key '%s': %s\n", p->input->v, p->cp.hdu,
p->datetosec, fitsdate);
printf("Seconds since 1970/01/01 (00:00:00): %zu%s\n\n", seconds,
- subsecstr);
- printf("(To suppress verbose output, run with `-q')\n");
+ subsecstr?subsecstr:"");
+ printf("(To suppress verbose output, run with '-q')\n");
}
else
- printf("%zu%s\n", seconds, subsecstr);
+ printf("%zu%s\n", seconds, subsecstr?subsecstr:"");
+
+ /* Clean up. */
+ if(subsecstr) free(subsecstr);
+}
+
+
+
+
+
+static void
+keywords_distortion_wcs(struct fitsparams *p)
+{
+ int nwcs;
+ size_t ndim, *insize;
+ char *suffix, *output;
+ gal_data_t *data=NULL;
+ struct wcsprm *inwcs, *outwcs;
+ size_t *dsize, defaultsize[2]={2000,2000};
+
+ /* If the extension has any data, read it, otherwise just make an empty
+ array. */
+ if(gal_fits_hdu_format(p->input->v, p->cp.hdu)==IMAGE_HDU)
+ {
+ /* Read the size of the dataset (we don't need the actual size!). */
+ insize=gal_fits_img_info_dim(p->input->v, p->cp.hdu, &ndim);
+ free(insize);
+
+ /* If the number of dimensions is two, then read the dataset,
+ otherwise, ignore it. */
+ if(ndim==2)
+ data=gal_fits_img_read(p->input->v, p->cp.hdu, p->cp.minmapsize,
+ p->cp.quietmmap);
+ }
+
+ /* Read the input's WCS and make sure one exists. */
+ inwcs=gal_wcs_read(p->input->v, p->cp.hdu, 0, 0, &nwcs);
+ if(inwcs==NULL)
+ error(EXIT_FAILURE, 0, "%s (hdu %s): doesn't have any WCS structure "
+ "for converting its distortion",
+ p->input->v, p->cp.hdu);
+
+ /* In case there is no dataset and the conversion is between TPV to SIP,
+ we need to set a default size and use that for the conversion, but we
+ also need to warn the user. */
+ if(data==NULL)
+ {
+ if( !p->cp.quiet
+ && gal_wcs_distortion_identify(inwcs)==GAL_WCS_DISTORTION_TPV
+ && p->distortionid==GAL_WCS_DISTORTION_SIP )
+ error(0, 0, "no data associated with WCS for distortion "
+ "conversion.\n\n"
+ "The requested conversion can't be done analytically, so a "
+ "solution has to be found by fitting the parameters over a "
+ "grid of pixels. We will use a default grid of %zux%zu pixels "
+ "and will proceed with the conversion. But it would be more "
+ "accurate if it is the size of the image that this WCS is "
+ "associated with",
+ defaultsize[1], defaultsize[0]);
+ dsize=defaultsize;
+ }
+ else dsize=data->dsize;
+
+ /* Do the conversion. */
+ outwcs=gal_wcs_distortion_convert(inwcs, p->distortionid, dsize);
+
+ /* Set the output filename. */
+ if(p->cp.output)
+ output=p->cp.output;
+ else
+ {
+ if( asprintf(&suffix, "-%s.fits", p->wcsdistortion)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ output=gal_checkset_automatic_output(&p->cp, p->input->v, suffix);
+ }
+ gal_checkset_writable_remove(output, 0, p->cp.dontdelete);
+
+ /* Write the output file. */
+ if(data)
+ {
+ /* Add the output WCS to the dataset and write it. */
+ data->wcs=outwcs;
+ gal_fits_img_write(data, output, NULL, PROGRAM_NAME);
+
+ /* Clean up, but remove the pointer first (so it doesn't free it
+ here). */
+ data->wcs=NULL;
+ gal_data_free(data);
+ }
+ else
+ gal_wcs_write(outwcs, output, p->wcsdistortion, NULL, PROGRAM_NAME);
+
+ /* Clean up. */
+ wcsfree(inwcs);
+ wcsfree(outwcs);
+ if(output!=p->cp.output) free(output);
+}
+
+
+
+
+
+static void
+keywords_value_in_output_copy(gal_data_t *write, gal_data_t *key,
+ size_t in_counter)
+{
+ char **strarrk, **strarrw;
+
+ /* Small sanity check. */
+ if(write->type != key->type)
+ error(EXIT_FAILURE, 0, "%s: the input datasets must have "
+ "the same data type. The 'write' and 'key' arguments "
+ "are respectively '%s' and '%s'", __func__,
+ gal_type_name(write->type, 1),
+ gal_type_name(key->type, 1));
+
+ /* Copy the value. */
+ if(key->type==GAL_TYPE_STRING)
+ {
+ strarrk=key->array;
+ strarrw=write->array;
+ strarrw[ in_counter ] = strarrk[0];
+ strarrk[0]=NULL;
+ }
+ else
+ memcpy(gal_pointer_increment(write->array, in_counter,
+ write->type),
+ key->array, gal_type_sizeof(write->type));
+}
+
+
+
+
+
+/* Write the value in the first row. The first row is unique here: if there
+ is only one input dataset, the dataset name will not be in the
+ output. But when there is more than one dataset, we include a column for
+ the name of the dataset. */
+static gal_data_t *
+keywords_value_in_output_first(struct fitsparams *p, gal_data_t *topout,
+ char *filename, gal_data_t *keysll,
+ size_t ninput)
+{
+ char **strarr;
+ gal_data_t *out=NULL;
+ gal_data_t *write, *key;
+ size_t in_counter=0; /* This function is only for the first row. */
+
+ /* If a name column is necessary. */
+ if(topout)
+ {
+ /* Small sanity check. */
+ if(topout->next)
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+ "fix the problem. The 'next' pointer of 'topout' should "
+ "be NULL", __func__, PACKAGE_BUGREPORT);
+
+ /* The size of the output should be the same as 'ninput'. */
+ if(topout->size!=ninput)
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+ "fix the problem. The number of elements in 'topout' "
+ "(%zu) is different from 'ninput' (%zu)", __func__,
+ PACKAGE_BUGREPORT, out->size, ninput);
+
+ /* Write the filename. */
+ strarr=topout->array;
+ gal_checkset_allocate_copy(filename, &strarr[in_counter]);
+ }
+
+ /* Add the new columns into the raw output (only keyword values). */
+ for(key=keysll; key!=NULL; key=key->next)
+ {
+ /* If the keyword couldn't be read for any reason then 'key->status'
+ will be non-zero. In this case, return a string type and put a
+ blank string value. */
+ if( key->status )
+ {
+ key->type=GAL_TYPE_STRING;
+ if(p->cp.quiet==0)
+ error(EXIT_SUCCESS, 0, "%s (hdu %s): does not contain a "
+ "keyword '%s'", filename, p->cp.hdu, key->name);
+ }
+
+ /* Allocate the full column for this key and add it to the end of
+ the existing output list of columns: IMPORTANT NOTE: it is
+ necessary to initialize the values because we may need to
+ change the types before fully writing values within it. */
+ write=gal_data_alloc(NULL, key->type, 1, &ninput, NULL,
+ 1, p->cp.minmapsize, p->cp.quietmmap,
+ key->name, key->unit, key->comment);
+
+ /* Copy the value of this key into the output. Note that for strings,
+ the arrays are initialized to NULL. */
+ if( key->status )
+ {
+ strarr=write->array;
+ gal_checkset_allocate_copy(GAL_BLANK_STRING,
+ &strarr[in_counter]);
+ }
+ else
+ keywords_value_in_output_copy(write, key, in_counter);
+
+ /* Put the allocated column into the output list. */
+ gal_list_data_add(&out, write);
+ }
+
+ /* Reverse the list (to be the same order as the user's request). */
+ gal_list_data_reverse(&out);
+
+ /* If a first row (containing the filename) is given, then add the
+ allocated datasets to its end */
+ if(topout) { topout->next=out; out=topout; }
+
+ /* Return the output. */
+ return out;
+}
+
+
+
+
+
+static void
+keywords_value_in_output_rest_replace(gal_data_t *list, gal_data_t *old,
+ gal_data_t *new)
+{
+ gal_data_t *parse;
+ new->next=old->next;
+ for(parse=list; parse!=NULL; parse=parse->next)
+ if(parse->next==old)
+ {
+ gal_data_free(old);
+ parse->next=new;
+ break;
+ }
+}
+
+
+
+
+
+/* This function is for the case that we have more than one row. In this
+ case, we always want the input file's name to be printed. */
+static void
+keywords_value_in_output_rest(struct fitsparams *p, gal_data_t *out,
+ char *filename, gal_data_t *keysll,
+ size_t in_counter)
+{
+ int goodtype;
+ char **strarr;
+ gal_data_t *write, *key;
+ gal_data_t *goodkey, *goodwrite;
+
+ /* Write the file name in the first column. */
+ strarr=out->array;
+ gal_checkset_allocate_copy(filename, &strarr[in_counter]);
+
+ /* Go over all the keys are write them in. */
+ write=out;
+ for(key=keysll; key!=NULL; key=key->next)
+ {
+ /* Increment the write column also. */
+ write=write->next;
+
+ /* If the status is non-zero then the keyword couldn't be read. In
+ this case, put a blank value in this row. */
+ if(key->status)
+ {
+ gal_blank_write(gal_pointer_increment(write->array, in_counter,
+ write->type),
+ write->type);
+ if(p->cp.quiet==0)
+ error(EXIT_SUCCESS, 0, "%s (hdu %s): does not contain a "
+ "keyword '%s'", filename, p->cp.hdu, key->name);
+ continue;
+ }
+
+ /* This key is good and the type is string (which is the type for a
+ key that doesn't exist in the previous file(s)). In this case,
+ check if all the previous rows are blank. If they are all blank
+ then this keyword didn't exist in any of the previous files and
+ this is the first one that has the keyword. So change the type of
+ the column to the final type. */
+ else
+ {
+ if( write->type==GAL_TYPE_STRING
+ && write->type!=key->type
+ && gal_blank_number(write, 1)==write->size )
+ {
+ goodwrite=gal_data_alloc(NULL, key->type, 1, out->dsize,
+ NULL, 0, p->cp.minmapsize,
+ p->cp.quietmmap, key->name,
+ key->unit, key->comment);
+ gal_blank_initialize(goodwrite);
+ keywords_value_in_output_rest_replace(out, write,
+ goodwrite);
+ write=goodwrite;
+ }
+ }
+
+ /* If the previous files didn't have metadata for this keyword but
+ this file does, use the metadata here. */
+ if(write->unit==NULL && key->unit)
+ { write->unit=key->unit; key->unit=NULL; }
+ if(write->comment==NULL && key->comment)
+ { write->comment=key->comment; key->comment=NULL; }
+
+ /* If the column types are the same, then put them in. */
+ if(key->type==write->type)
+ keywords_value_in_output_copy(write, key, in_counter);
+ else
+ {
+ /* Find the most inclusive type. */
+ goodtype=gal_type_out(key->type, write->type);
+
+ /* Convert each of the two into the same type. */
+ goodkey = ( key->type==goodtype
+ ? key
+ : gal_data_copy_to_new_type(key, goodtype) );
+ goodwrite = ( write->type==goodtype
+ ? write
+ : gal_data_copy_to_new_type(write, goodtype) );
+
+ /* Copy the row into the output. */
+ keywords_value_in_output_copy(goodwrite, goodkey, in_counter);
+
+ /* If the "good" writing dataset has been changed, then
+ replace it in the output (correct its 'next' pointer, and
+ set the previous column to point to it. */
+ if(goodwrite!=write)
+ {
+ keywords_value_in_output_rest_replace(out, write,
+ goodwrite);
+ write=goodwrite;
+ }
+
+ /* If a different key has been used, clean it. */
+ if(goodkey!=key) gal_data_free(goodkey);
+ }
+ }
+}
+
+
+
+
+
+static void
+keywords_value(struct fitsparams *p)
+{
+ int status;
+ fitsfile *fptr=NULL;
+ gal_list_str_t *input, *tmp;
+ size_t i, ii=0, ninput, nkeys;
+ gal_data_t *out=NULL, *keysll=NULL;
+
+ /* Count how many inputs there are and allocate the first column with the
+ name. */
+ ninput=gal_list_str_number(p->input);
+ if(ninput>1)
+ out=gal_data_alloc(NULL, GAL_TYPE_STRING, 1, &ninput, NULL, 0,
+ p->cp.minmapsize, p->cp.quietmmap, "FILENAME",
+ "name", "Name of input file.");
+
+ /* Allocate the structure to host the desired keywords read from each
+ FITS file and their values. But first convert the list of strings (for
+ keyword names), (where each string can be a comma-separated list) into
+ a list with a single value per string. */
+ gal_options_merge_list_of_csv(&p->keyvalue);
+ nkeys=gal_list_str_number(p->keyvalue);
+
+ /* Parse each input file, read the keywords and put them in the output
+ list. */
+ for(input=p->input; input!=NULL; input=input->next)
+ {
+ /* Open the input FITS file. */
+ fptr=gal_fits_hdu_open(input->v, p->cp.hdu, READONLY);
+
+ /* Allocate the array to keep the keys. */
+ i=0;
+ keysll=gal_data_array_calloc(nkeys);
+ for(tmp=p->keyvalue; tmp!=NULL; tmp=tmp->next)
+ {
+ if(tmp->next) keysll[i].next=&keysll[i+1];
+ keysll[i].name=tmp->v;
+ ++i;
+ }
+
+ /* Read the keys. Note that we only need the comments and units if
+ '--colinfoinstdout' is called. */
+ gal_fits_key_read_from_ptr(fptr, keysll, p->colinfoinstdout,
+ p->colinfoinstdout);
+
+ /* Close the input FITS file. */
+ status=0;
+ if(fits_close_file(fptr, &status))
+ gal_fits_io_error(status, NULL);
+
+ /* Write the values of this column into the final output. */
+ if(ii==0)
+ {
+ ++ii;
+ out=keywords_value_in_output_first(p, out, input->v,
+ keysll, ninput);
+ }
+ else
+ keywords_value_in_output_rest(p, out, input->v, keysll,
+ ii++);
+
+ /* Clean up. */
+ for(i=0;i<nkeys;++i) keysll[i].name=NULL;
+ gal_data_array_free(keysll, nkeys, 1);
+ }
+
+ /* Write the values. */
+ gal_checkset_writable_remove(p->cp.output, 0, p->cp.dontdelete);
+ gal_table_write(out, NULL, NULL, p->cp.tableformat,
+ p->cp.output, "KEY-VALUES", p->colinfoinstdout);
+
+ /* Clean up. */
+ gal_list_str_free(p->keyvalue, 0);
}
@@ -451,12 +872,12 @@ keywords_date_to_seconds(struct fitsparams *p, fitsfile
*fptr)
/***********************************************************************/
/* NOTE ON CALLING keywords_open FOR EACH OPERATION:
- `keywords_open' is being called individually for each separate operation
+ 'keywords_open' is being called individually for each separate operation
because the necessary permissions differ: when the user only wants to
read keywords, they don't necessarily need write permissions. So if they
haven't asked for any writing/editing operation, we shouldn't open in
write-mode. Because the user might not have the permissions to write and
- they might not want to write. `keywords_open' will only open the file
+ they might not want to write. 'keywords_open' will only open the file
once (if the pointer is already allocated, it won't do anything). */
int
keywords(struct fitsparams *p)
@@ -467,6 +888,10 @@ keywords(struct fitsparams *p)
gal_list_str_t *tstll;
int status=0, numinkeys;
+ /* Print the requested keywords. Note that this option isn't called with
+ the rest. It is independent of them. */
+ if(p->keyvalue)
+ keywords_value(p);
/* Delete the requested keywords. */
if(p->delete)
@@ -597,7 +1022,7 @@ keywords(struct fitsparams *p)
/* Close the FITS file */
- if(fits_close_file(fptr, &status))
+ if(fptr && fits_close_file(fptr, &status))
gal_fits_io_error(status, NULL);
@@ -608,6 +1033,10 @@ keywords(struct fitsparams *p)
free(inkeys);
}
+ /* Convert the input's distortion to the desired output distortion. */
+ if(p->wcsdistortion)
+ keywords_distortion_wcs(p);
+
/* Return. */
return r;
}
diff --git a/bin/fits/keywords.h b/bin/fits/keywords.h
index 9d95675..be29916 100644
--- a/bin/fits/keywords.h
+++ b/bin/fits/keywords.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/main.c b/bin/fits/main.c
index 7eda419..e105fcb 100644
--- a/bin/fits/main.c
+++ b/bin/fits/main.c
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/fits/main.h b/bin/fits/main.h
index 6b50be2..9c66221 100644
--- a/bin/fits/main.h
+++ b/bin/fits/main.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -54,30 +54,37 @@ struct fitsparams
{
/* From the environment. */
struct gal_options_common_params cp; /* Common parameters. */
- int hdu_in_commandline; /* HDU wasn't given in config. file. */
- char *filename; /* Name of input file. */
- char *outhdu; /* HDU of output (only when necessary). */
- gal_list_str_t *remove; /* Remove extensions from a file. */
- gal_list_str_t *copy; /* Copy extensions to output. */
- gal_list_str_t *cut; /* Copy ext. to output and remove. */
- uint8_t numhdus; /* Print number of HDUs in FITS file. */
- uint8_t primaryimghdu; /* Copy/cut HDU into primary HDU. */
- uint8_t printallkeys; /* Print all the header keywords. */
- uint8_t date; /* Set DATE to current time. */
- gal_list_str_t *asis; /* Strings to write asis. */
- gal_list_str_t *delete; /* Keywords to remove. */
- gal_list_str_t *rename; /* Rename a keyword. */
- gal_list_str_t *update; /* For keywords to update. */
- gal_list_str_t *write; /* Full arg. for keywords to add. */
- gal_list_str_t *history; /* HISTORY value. */
- gal_list_str_t *comment; /* COMMENT value. */
- uint8_t *verify; /* Verify the CHECKSUM and DATASUM keys. */
- char *copykeys; /* Range of keywords to copy in output. */
- char *datetosec; /* Convert FITS date to seconds. */
- uint8_t quitonerror; /* Quit if an error occurs. */
+ int hdu_in_commandline; /* HDU wasn't given in config. file. */
+ gal_list_str_t *input; /* Name of input file. */
+ char *outhdu; /* HDU of output (only when necessary). */
+ gal_list_str_t *remove; /* Remove extensions from a file. */
+ gal_list_str_t *copy; /* Copy extensions to output. */
+ gal_list_str_t *cut; /* Copy ext. to output and remove. */
+ uint8_t numhdus; /* Print number of HDUs in FITS file. */
+ uint8_t datasum; /* Calculate and print HDU's datasum. */
+ uint8_t pixelscale; /* Calculate and print HDU's pixelscale. */
+ uint8_t skycoverage; /* Calculate and image coverage in WCS. */
+ uint8_t primaryimghdu; /* Copy/cut HDU into primary HDU. */
+ uint8_t printallkeys; /* Print all the header keywords. */
+ uint8_t date; /* Set DATE to current time. */
+ gal_list_str_t *asis; /* Strings to write asis. */
+ gal_list_str_t *keyvalue; /* Strings to write asis. */
+ gal_list_str_t *delete; /* Keywords to remove. */
+ gal_list_str_t *rename; /* Rename a keyword. */
+ gal_list_str_t *update; /* For keywords to update. */
+ gal_list_str_t *write; /* Full arg. for keywords to add. */
+ gal_list_str_t *history; /* HISTORY value. */
+ gal_list_str_t *comment; /* COMMENT value. */
+ uint8_t *verify; /* Verify the CHECKSUM and DATASUM keys. */
+ char *copykeys; /* Range of keywords to copy in output. */
+ char *datetosec; /* Convert FITS date to seconds. */
+ char *wcsdistortion; /* WCS distortion to write in output. */
+ uint8_t quitonerror; /* Quit if an error occurs. */
+ uint8_t colinfoinstdout; /* Print column info in output. */
/* Internal: */
int mode; /* Operating on HDUs or keywords. */
+ int distortionid; /* ID of desired distortion. */
long copykeysrange[2]; /* Start and end of copy. */
gal_fits_list_key_t *write_keys; /* Keys to write in the header. */
gal_fits_list_key_t *update_keys; /* Keys to update in the header. */
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index ca86eee..c9cbc63 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -28,6 +28,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <stdio.h>
#include <string.h>
+#include <gnuastro/wcs.h>
#include <gnuastro/fits.h>
#include <gnuastro-internal/options.h>
@@ -119,7 +120,6 @@ ui_initialize_options(struct fitsparams *p,
case GAL_OPTIONS_KEY_SEARCHIN:
case GAL_OPTIONS_KEY_IGNORECASE:
case GAL_OPTIONS_KEY_TYPE:
- case GAL_OPTIONS_KEY_TABLEFORMAT:
case GAL_OPTIONS_KEY_DONTDELETE:
case GAL_OPTIONS_KEY_LOG:
case GAL_OPTIONS_KEY_NUMTHREADS:
@@ -153,18 +153,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct fitsparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -176,12 +176,7 @@ parse_opt(int key, char *arg, struct argp_state *state)
case ARGP_KEY_ARG:
/* Only FITS files are acceptable. */
if( gal_fits_name_is_fits(arg) )
- {
- if(p->filename)
- argp_error(state, "only one input file should be given");
- else
- p->filename=arg;
- }
+ gal_list_str_add(&p->input, arg, 1);
else
argp_error(state, "%s is not a recognized FITS file", arg);
break;
@@ -228,13 +223,13 @@ ui_check_copykeys(struct fitsparams *p)
/* For copykeys, an output filename is mandatory. */
if(p->cp.output==NULL || p->outhdu==NULL)
error(EXIT_FAILURE, 0, "an output FITS extension (in an existing "
- "FITS file, specified with the `--output' and `--outhdu') are "
- "mandatory for running `--copykeys'");
+ "FITS file, specified with the '--output' and '--outhdu') are "
+ "mandatory for running '--copykeys'");
/* Initialize the values. */
p->copykeysrange[0]=p->copykeysrange[1]=GAL_BLANK_LONG;
- /* Parse the string: `forl': "first-or-last". */
+ /* Parse the string: 'forl': "first-or-last". */
while(*pt!='\0')
{
switch(*pt)
@@ -245,7 +240,7 @@ ui_check_copykeys(struct fitsparams *p)
break;
case '.':
error(EXIT_FAILURE, 0, "the numbers in the argument to "
- "`--section` (`-s') have to be integers. You input "
+ "'--section' ('-s') have to be integers. You input "
"includes a float number: %s", p->copykeys);
break;
case ' ': case '\t':
@@ -268,10 +263,10 @@ ui_check_copykeys(struct fitsparams *p)
break;
*/
default:
- error(EXIT_FAILURE, 0, "value to `--copykeys' must only contain "
+ error(EXIT_FAILURE, 0, "value to '--copykeys' must only contain "
"integer numbers and these special characters between them: "
- "`:' when necessary. But it is `%s' (the first "
- "non-acceptable character is `%c').\n", p->copykeys, *pt);
+ "':' when necessary. But it is '%s' (the first "
+ "non-acceptable character is '%c').\n", p->copykeys, *pt);
break;
}
@@ -292,17 +287,17 @@ ui_check_copykeys(struct fitsparams *p)
/* Basic sanity checks. */
if( p->copykeysrange[1]==GAL_BLANK_LONG )
- error(EXIT_FAILURE, 0, "no ending keyword number given to `--copykeys'. "
+ error(EXIT_FAILURE, 0, "no ending keyword number given to '--copykeys'. "
"If you want to copy all the keywords after a certain one "
- "(without worrying about how many there are), you can use `-1'.\n\n"
+ "(without worrying about how many there are), you can use '-1'.\n\n"
"For example if you want to copy all the keywords after the 20th, "
- "you can use `--copykeys=20,-1'. Generally, you can use negative "
+ "you can use '--copykeys=20,-1'. Generally, you can use negative "
"numbers for the last keyword number to count from the end.");
if( p->copykeysrange[0]<=0 )
- error(EXIT_FAILURE, 0, "the first number given to `--copykeys' must be "
+ error(EXIT_FAILURE, 0, "the first number given to '--copykeys' must be "
"positive");
if( p->copykeysrange[1]>=0 && p->copykeysrange[0]>=p->copykeysrange[1] )
- error(EXIT_FAILURE, 0, "the first number (%ld) given to `--copykeys' "
+ error(EXIT_FAILURE, 0, "the first number (%ld) given to '--copykeys' "
"must be smaller than the second (%ld)", p->copykeysrange[0],
p->copykeysrange[1]);
@@ -317,63 +312,100 @@ ui_check_copykeys(struct fitsparams *p)
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct fitsparams *p)
{
+ int checkkeys;
+ uint8_t stdoutcheck=0;
+
/* If any of the keyword manipulation options are requested, then set the
mode flag to keyword-mode. */
- if( p->date || p->comment || p->history || p->asis || p->delete
- || p->rename || p->update || p->write || p->verify || p->printallkeys
- || p->copykeys || p->datetosec )
+ if( p->date || p->comment || p->history || p->asis || p->keyvalue
+ || p->delete || p->rename || p->update || p->write || p->verify
+ || p->printallkeys || p->copykeys || p->datetosec
+ || p->wcsdistortion )
{
- /* Set the mode. */
- p->mode=FITS_MODE_KEY;
-
/* Check if a HDU is given. */
if(p->cp.hdu==NULL)
- error(EXIT_FAILURE, 0, "a HDU (extension) is necessary for keywrod "
+ error(EXIT_FAILURE, 0, "a HDU (extension) is necessary for keyword "
"related options but none was defined. Please use the "
- "`--hdu' (or `-h') option to select one");
+ "'--hdu' (or '-h') option to select one");
/* If Copy keys has been given, read it and make sure its setup. */
if(p->copykeys)
ui_check_copykeys(p);
+
+ /* Keyword-related options that must be called alone. */
+ checkkeys = ( (p->keyvalue!=NULL)
+ + (p->datetosec!=NULL)
+ + (p->wcsdistortion!=NULL) );
+ if( ( checkkeys
+ && ( p->date || p->comment || p->history || p->asis
+ || p->delete || p->rename || p->update || p->write
+ || p->verify || p->printallkeys || p->copykeys ) )
+ || checkkeys>1 )
+ error(EXIT_FAILURE, 0, "'--keyvalue', '--datetosec' and "
+ "'--wcsdistortion' cannot currently be called with "
+ "any other option");
+
+ /* Identify the requested distortion. Note that this also acts as a
+ sanity check because it will crash with an error if the given
+ string isn't recognized. */
+ if(p->wcsdistortion)
+ p->distortionid=gal_wcs_distortion_from_string(p->wcsdistortion);
+
+ /* Set the operating mode. */
+ p->mode=FITS_MODE_KEY;
}
/* Same for the extension-related options */
- if( p->remove || p->copy || p->cut || p->numhdus)
+ if( p->remove || p->copy || p->cut || p->numhdus || p->datasum
+ || p->pixelscale || p->skycoverage )
{
/* A small sanity check. */
if(p->mode!=FITS_MODE_INVALID)
error(EXIT_FAILURE, 0, "extension and keyword manipulation options "
"cannot be called together");
- /* Unlike the rest of the HDU-related options, `--numhdus' must be
- called alone. */
- if(p->numhdus==1 && (p->remove || p->copy || p->cut) )
- error(EXIT_FAILURE, 0, "`--numhdus' option must be called alone (it "
- "cannot be called with other extension or keyword options)");
+ /* Some HDU options cannot be called with other options. */
+ stdoutcheck = p->numhdus + p->datasum + p->pixelscale + p->skycoverage;
+
+ /* Make sure if an output file is needed. */
+ if(stdoutcheck)
+ {
+ /* Make sure the other HDU-related options aren't called. */
+ if(p->remove || p->copy || p->cut)
+ error(EXIT_FAILURE, 0, "'--numhdus', '--datasum', '--pixelscale' "
+ "or '--skycoverage' options cannot be called with any of "
+ "the '--remove', '--copy' or '--cut' options");
+
+ /* Make sure these options are called alone. */
+ if(stdoutcheck>1)
+ error(EXIT_FAILURE, 0, "'--numhdus', '--datasum', '--pixelscale' "
+ "or '--skycoverage' options cannot be called together, "
+ "only one at a time");
+
+ /* Make sure the HDU is given if any of the options except
+ '--numhdus' are called. */
+ if( stdoutcheck-p->numhdus && p->cp.hdu==NULL )
+ error(EXIT_FAILURE, 0, "a HDU (extension) is necessary for the "
+ "'--datasum', '--pixelscale' or '--skycoverage' options. "
+ "Please use the '--hdu' (or '-h') option to select one");
+ }
+ else
+ {
+ if(p->cp.output)
+ gal_checkset_writable_remove(p->cp.output, 1, p->cp.dontdelete);
+ else
+ p->cp.output=gal_checkset_automatic_output(&p->cp, p->input->v,
+ "_ext.fits");
+ }
/* Set the operating mode. */
p->mode=FITS_MODE_HDU;
-
- /* Make sure the output name is set. */
- if(p->cp.output)
- gal_checkset_writable_remove(p->cp.output, 1, p->cp.dontdelete);
- else
- p->cp.output=gal_checkset_automatic_output(&p->cp, p->filename,
- "_ext.fits");
}
- /* Currently `datetosec' must be called alone. */
- if( p->datetosec
- && (p->date || p->comment || p->history || p->asis || p->delete
- || p->rename || p->update || p->write || p->verify
- || p->printallkeys || p->copykeys || p->mode==FITS_MODE_HDU) )
- error(EXIT_FAILURE, 0, "`--datetosec' cannot currently be called with "
- "any other option");
-
/* If no options are given, go into HDU mode, which will print the HDU
information when nothing is asked. */
if(p->mode==FITS_MODE_INVALID)
@@ -397,8 +429,15 @@ ui_check_options_and_arguments(struct fitsparams *p)
{
/* Make sure an input file name was given and if it was a FITS file, that
a HDU is also given. */
- if(p->filename==NULL)
+ if(p->input==NULL)
error(EXIT_FAILURE, 0, "no input file is specified");
+ gal_list_str_reverse(&p->input);
+
+ /* More than one input is currently only acceptable with the '--keyvalue'
+ option. */
+ if( gal_list_str_number(p->input) > 1 && p->keyvalue==NULL)
+ error(EXIT_FAILURE, 0, "one input file is expected but %zu input "
+ "files are given", gal_list_str_number(p->input));
}
@@ -423,9 +462,9 @@ ui_check_options_and_arguments(struct fitsparams *p)
/**************************************************************/
/***************** Preparations ********************/
/**************************************************************/
-/* The `--update' and `--write' options take multiple values for each
+/* The '--update' and '--write' options take multiple values for each
keyword, so here, we tokenize them and put them into a
- `gal_fits_list_key_t' list. */
+ 'gal_fits_list_key_t' list. */
static void
ui_fill_fits_headerll(gal_list_str_t *input, gal_fits_list_key_t **output,
char *option_name)
@@ -443,12 +482,12 @@ ui_fill_fits_headerll(gal_list_str_t *input,
gal_fits_list_key_t **output,
i=0;
tailptr=NULL;
- /* `c' is created in case of an error, so the input value can be
+ /* 'c' is created in case of an error, so the input value can be
reported. */
errno=0;
original=malloc(strlen(tmp->v)+1);
if(original==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `original'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'original'",
__func__, strlen(tmp->v)+1);
strcpy(original, tmp->v);
@@ -505,14 +544,14 @@ ui_fill_fits_headerll(gal_list_str_t *input,
gal_fits_list_key_t **output,
/* Make sure the keyname and value (if necessary) is given. */
if( keyname==NULL || (needsvalue && value==NULL) )
- error(EXIT_FAILURE, 0, "`--%s' option string (%s) can't be parsed. "
+ error(EXIT_FAILURE, 0, "'--%s' option string (%s) can't be parsed. "
"The general expected format is (a comment string and unit "
"are optional):\n\n"
" --%s=KEYWORD,value,\"a comment string\",unit\n\n"
"Any space characters around the the comma (,) characters "
"will be seen as part of the respective token.\n\n"
"Note that there are some exceptions (where no value is need)"
- "please see the manual for more (`$ info astfits')",
+ "please see the manual for more ('$ info astfits')",
option_name, original, option_name);
/*
printf("\n\n-%s-\n-%s-\n-%s-\n-%s-\n", keyname, value, comment, unit);
@@ -531,7 +570,7 @@ ui_fill_fits_headerll(gal_list_str_t *input,
gal_fits_list_key_t **output,
errno=0;
fvalue=lp=malloc(sizeof *lp);
if(lp==NULL)
- error(EXIT_FAILURE, errno, "%s: %zu bytes for `lp'",
+ error(EXIT_FAILURE, errno, "%s: %zu bytes for 'lp'",
__func__, sizeof *lp);
*lp=l;
}
@@ -547,7 +586,7 @@ ui_fill_fits_headerll(gal_list_str_t *input,
gal_fits_list_key_t **output,
fvalue=dp=malloc(sizeof *dp);
if(dp==NULL)
error(EXIT_FAILURE, errno, "%s: allocating %zu bytes "
- "for `dp'", __func__, sizeof *dp);
+ "for 'dp'", __func__, sizeof *dp);
*dp=d;
}
else
@@ -562,7 +601,7 @@ ui_fill_fits_headerll(gal_list_str_t *input,
gal_fits_list_key_t **output,
/* Add it to the list of keywords. */
gal_fits_key_list_add(output, type, keyname, 0, fvalue, vfree,
- comment, 0, unit);
+ comment, 0, unit, 0);
free(original);
}
@@ -612,9 +651,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
fitsparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/fits/ui.h b/bin/fits/ui.h
index 4249fb4..4ee5333 100644
--- a/bin/fits/ui.h
+++ b/bin/fits/ui.h
@@ -5,7 +5,7 @@ Fits is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,7 +33,8 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Option groups particular to this program. */
enum program_args_groups
{
- UI_GROUP_EXTENSION = GAL_OPTIONS_GROUP_AFTER_COMMON,
+ UI_GROUP_EXTENSION_INFORMATION = GAL_OPTIONS_GROUP_AFTER_COMMON,
+ UI_GROUP_EXTENSION_MANIPULATION,
UI_GROUP_KEYWORD,
};
@@ -43,36 +44,41 @@ enum program_args_groups
/* Available letters for short options:
- b e f g i j l m x y z
- A B E G J L O W X Y
+ b e f g i j m x y z
+ A B E G J L W X Y
*/
enum option_keys_enum
{
/* With short-option version. */
- UI_KEY_REMOVE = 'R',
- UI_KEY_COPY = 'C',
- UI_KEY_CUT = 'k',
- UI_KEY_NUMHDUS = 'n',
- UI_KEY_PRINTALLKEYS = 'p',
- UI_KEY_ASIS = 'a',
- UI_KEY_DELETE = 'd',
- UI_KEY_RENAME = 'r',
- UI_KEY_UPDATE = 'u',
- UI_KEY_WRITE = 'w',
- UI_KEY_COMMENT = 'c',
- UI_KEY_HISTORY = 'H',
- UI_KEY_DATE = 't',
- UI_KEY_VERIFY = 'v',
- UI_KEY_QUITONERROR = 'Q',
- UI_KEY_DATETOSEC = 's',
-
+ UI_KEY_REMOVE = 'R',
+ UI_KEY_COPY = 'C',
+ UI_KEY_CUT = 'k',
+ UI_KEY_NUMHDUS = 'n',
+ UI_KEY_PRINTALLKEYS = 'p',
+ UI_KEY_ASIS = 'a',
+ UI_KEY_KEYVALUE = 'l',
+ UI_KEY_DELETE = 'd',
+ UI_KEY_RENAME = 'r',
+ UI_KEY_UPDATE = 'u',
+ UI_KEY_WRITE = 'w',
+ UI_KEY_COMMENT = 'c',
+ UI_KEY_HISTORY = 'H',
+ UI_KEY_DATE = 't',
+ UI_KEY_VERIFY = 'v',
+ UI_KEY_QUITONERROR = 'Q',
+ UI_KEY_DATETOSEC = 's',
+ UI_KEY_COLINFOINSTDOUT = 'O',
/* Only with long version (start with a value 1000, the rest will be set
automatically). */
UI_KEY_TITLE = 1000,
+ UI_KEY_DATASUM,
+ UI_KEY_PIXELSCALE,
+ UI_KEY_SKYCOVERAGE,
UI_KEY_OUTHDU,
UI_KEY_COPYKEYS,
UI_KEY_PRIMARYIMGHDU,
+ UI_KEY_WCSDISTORTION,
};
diff --git a/bin/gnuastro.conf b/bin/gnuastro.conf
index 115b78e..6c180c0 100644
--- a/bin/gnuastro.conf
+++ b/bin/gnuastro.conf
@@ -4,15 +4,15 @@
# Use the long option name of each paramter followed by
# a value. The name and value should be separated by
# atleast one of the following charaacters:
-# space, `,`, `=` or `:`
+# space, ',', '=' or ':'
#
-# Run with `--help` option or read the manual for a full
+# Run with '--help' option or read the manual for a full
# explanation of what each option means.
#
# NOTE I: All counting is from zero, not one.
-# NOTE II: Lines starting with `#` are ignored.
+# NOTE II: Lines starting with '#' are ignored.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
@@ -31,7 +31,7 @@
remainderfrac 0.1
workoverch 0
interpmetric radial
- interpnumngb 9
+ interpnumngb 15
interponlyblank 0
# Output:
@@ -39,4 +39,13 @@
# Operating mode
quietmmap 0
- minmapsize 2000000000
+
+ # The default 'minmapsize' is set to the maximum possible value for signed
+ # 64-bit integers (half the full logical size of a 64-bit system, which is
+ # larger than 9 x 10^18 bytes). Effectively, this means that forced
+ # memory-mapping will be disabled. Therefore memory-mapping will only
+ # happen when memory cannot be allocated with the RAM (for any reason,
+ # mainly not having enough space). On 32-bit systems, this will
+ # automatically be read by the C library as the largest possible memory in
+ # those systems (~4.3 x 10^9 bytes).
+ minmapsize 9223372036854775807
diff --git a/bin/match/Makefile.am b/bin/match/Makefile.am
index 9e9fe33..75f3413 100644
--- a/bin/match/Makefile.am
+++ b/bin/match/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2017-2019, Free Software Foundation, Inc.
+## Copyright (C) 2017-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astmatch
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmatch_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astmatch_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astmatch_SOURCES = main.c ui.c match.c
diff --git a/bin/match/args.h b/bin/match/args.h
index 5dd2424..67515d1 100644
--- a/bin/match/args.h
+++ b/bin/match/args.h
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -81,7 +81,7 @@ struct argp_option program_options[] =
UI_KEY_OUTCOLS,
"STR",
0,
- "Out cols in CSV, `a': first, `b': second input.",
+ "Out cols in CSV, 'a': first, 'b': second input.",
GAL_OPTIONS_GROUP_OUTPUT,
&p->outcols,
GAL_OPTIONS_NO_ARG_TYPE,
diff --git a/bin/match/astmatch.conf b/bin/match/astmatch.conf
index 5e269f0..6e64203 100644
--- a/bin/match/astmatch.conf
+++ b/bin/match/astmatch.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astmatch # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -22,4 +22,4 @@
# Input
hdu2 1
-# Catalog matching
\ No newline at end of file
+# Catalog matching
diff --git a/bin/match/authors-cite.h b/bin/match/authors-cite.h
index 7625dbf..9f7ffd8 100644
--- a/bin/match/authors-cite.h
+++ b/bin/match/authors-cite.h
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/match/main.c b/bin/match/main.c
index f89132b..3fa4836 100644
--- a/bin/match/main.c
+++ b/bin/match/main.c
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/match/main.h b/bin/match/main.h
index 1e776a6..d9d0c5b 100644
--- a/bin/match/main.h
+++ b/bin/match/main.h
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/match/match.c b/bin/match/match.c
index a1f6eac..ec23d1c 100644
--- a/bin/match/match.c
+++ b/bin/match/match.c
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -79,7 +79,7 @@ match_add_all_cols(char *filename, char *extname,
gal_list_str_t *stdinlines,
}
/* If a new list of columns is ready, re-order tham and write
- them in. Note that there may be multiple `_all' terms, so we
+ them in. Note that there may be multiple '_all' terms, so we
need to do this after parsing all the requested columns. */
gal_list_str_reverse(&finalcols);
@@ -111,12 +111,12 @@ match_cat_from_coord(struct matchparams *p,
gal_list_str_t *cols,
colcounter=0;
for(col=cols;col!=NULL;col=col->next)
{
- /* In `ui_preparations_out_cols', we have done the necessary sanity
+ /* In 'ui_preparations_out_cols', we have done the necessary sanity
checks, so we can safely use the values. */
rptr=gal_type_string_to_number(col->v, &readtype);
if(readtype!=GAL_TYPE_UINT8)
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
- "the problem. The given string didn't have a `uint8' type",
+ "the problem. The given string didn't have a 'uint8' type",
__func__, PACKAGE_BUGREPORT);
read=*((uint8_t *)rptr);
@@ -172,13 +172,13 @@ match_catalog_read_write_all(struct matchparams *p,
size_t *permutation,
if(p->outcols)
{
/* As a special situation, the user can ask to incude all of the
- columns from one of the inputs with the special `_all' name. So,
+ columns from one of the inputs with the special '_all' name. So,
we'll check if that is the case and write in all the columns where
they are requested.*/
for(tcol=incols; tcol!=NULL; tcol=tcol->next)
if(!strcmp(tcol->v,"_all")) { hasall=1; break; }
- /* If atleast one instance of `_all' is present, then reset the list
+ /* If atleast one instance of '_all' is present, then reset the list
of columns to include in output. */
if(hasall)
{
@@ -200,8 +200,8 @@ match_catalog_read_write_all(struct matchparams *p, size_t
*permutation,
else cols=incols;
- /* Read the full table. NOTE that with `--coord', for the second input,
- both `filename' and `p->stdinlines' will be NULL. */
+ /* Read the full table. NOTE that with '--coord', for the second input,
+ both 'filename' and 'p->stdinlines' will be NULL. */
if(filename || p->stdinlines)
cat=gal_table_read(filename, hdu, filename ? NULL : p->stdinlines, cols,
p->cp.searchin, p->cp.ignorecase, p->cp.minmapsize,
@@ -238,7 +238,7 @@ match_catalog_read_write_all(struct matchparams *p, size_t
*permutation,
else
tmp->size=tmp->dsize[0]=nummatched;
}
- /* If no match was found (`permutation==NULL'), and the matched columns
+ /* If no match was found ('permutation==NULL'), and the matched columns
are requested, empty all the columns that are to be written (only
keeping the meta-data). */
else
@@ -259,12 +259,13 @@ match_catalog_read_write_all(struct matchparams *p,
size_t *permutation,
else if(cat)
{
/* Write the catalog to a file. */
- gal_table_write(cat, NULL, p->cp.tableformat, outname, extname, 0);
+ gal_table_write(cat, NULL, NULL, p->cp.tableformat, outname,
+ extname, 0);
- /* Correct arrays and sizes (when `notmatched' was called). The
- `array' element has to be corrected for later freeing.
+ /* Correct arrays and sizes (when 'notmatched' was called). The
+ 'array' element has to be corrected for later freeing.
- IMPORTANT: `--notmatched' cannot be called with `--outcols'. So
+ IMPORTANT: '--notmatched' cannot be called with '--outcols'. So
you don't have to worry about the checks here being done later. */
if(p->notmatched)
{
@@ -334,13 +335,14 @@ match_catalog_write_one(struct matchparams *p, gal_data_t
*a, gal_data_t *b,
/* A small sanity check. */
if(a || b)
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us to fix the problem. "
- "The two `a' and `b' arrays must be NULL by this point: "
- "`a' %s NULL, `b' %s NULL", __func__, a?"is not":"is",
+ "The two 'a' and 'b' arrays must be NULL by this point: "
+ "'a' %s NULL, 'b' %s NULL", __func__, a?"is not":"is",
b?"is not":"is");
/* Reverse the table and write it out. */
gal_list_data_reverse(&cat);
- gal_table_write(cat, NULL, p->cp.tableformat, p->out1name, "MATCHED", 0);
+ gal_table_write(cat, NULL, NULL, p->cp.tableformat, p->out1name,
+ "MATCHED", 0);
}
@@ -366,7 +368,7 @@ match_catalog(struct matchparams *p)
{
/* Read (and possibly write) the outputs. Note that we only need to
read the table when it is necessary for the output (the user might
- have asked for `--outcols', only with columns of one of the two
+ have asked for '--outcols', only with columns of one of the two
inputs). */
if(p->outcols==NULL || p->acols)
a=match_catalog_read_write_all(p, mcols?mcols->array:NULL,
@@ -401,7 +403,7 @@ match_catalog(struct matchparams *p)
mcols=tmp;
/* We also want everything to be incremented by one. In a C
- program, counting starts with zero, so `gal_match_coordinates'
+ program, counting starts with zero, so 'gal_match_coordinates'
will return indexs starting from zero. But outside a C
program, on the command-line people expect counting to start
from 1 (for example with AWK). */
@@ -423,7 +425,7 @@ match_catalog(struct matchparams *p)
"from 1).";
/* Write them into the table. */
- gal_table_write(mcols, NULL, p->cp.tableformat, p->logname,
+ gal_table_write(mcols, NULL, NULL, p->cp.tableformat, p->logname,
"LOG_INFO", 0);
/* Set the comment pointer to NULL: they weren't allocated. */
diff --git a/bin/match/match.h b/bin/match/match.h
index 6e399e2..d22f615 100644
--- a/bin/match/match.h
+++ b/bin/match/match.h
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/match/ui.c b/bin/match/ui.c
index dacb0d3..31d1ee2 100644
--- a/bin/match/ui.c
+++ b/bin/match/ui.c
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -145,18 +145,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct matchparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -210,12 +210,12 @@ parse_opt(int key, char *arg, struct argp_state *state)
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct matchparams *p)
{
if(p->outcols && p->notmatched)
- error(EXIT_FAILURE, 0, "`--outcols' and `--notmatched' cannot be called "
+ error(EXIT_FAILURE, 0, "'--outcols' and '--notmatched' cannot be called "
"at the same time. The former is only for cases when the matches "
"are required");
}
@@ -225,38 +225,38 @@ ui_read_check_only_options(struct matchparams *p)
/* Two necessary catalogs: First: Standard input, or a file.
- Second: `--coord', or a file.
+ Second: '--coord', or a file.
*/
static void
ui_check_options_and_arguments(struct matchparams *p)
{
- /* When `--coord' is given, there should be no second catalog
+ /* When '--coord' is given, there should be no second catalog
(argument). */
if(p->coord)
{
/* Make sure no second argument is given. */
if(p->input2name)
error(EXIT_FAILURE, 0, "only one argument can be given with the "
- "`--coord' option");
+ "'--coord' option");
- /* No need for `p->input2name' or `p->ccol2'. */
+ /* No need for 'p->input2name' or 'p->ccol2'. */
gal_data_free(p->ccol2);
p->ccol2=NULL;
}
- /* `--coord' is not given. */
+ /* '--coord' is not given. */
else
{
- /* Without `coord' atleast one input is necessary. */
+ /* Without 'coord' atleast one input is necessary. */
if(p->input1name==NULL)
error(EXIT_FAILURE, 0, "no inputs!\n\n"
"Two inputs are necessary. The first can be a file, or from "
"the standard input (e.g., a pipe). The second can be a "
"file, or its coordinates can be directly specified on the "
- "command-line with `--coord'");
+ "command-line with '--coord'");
/* If the first input should be read from the standard input, the
- contents of `input1name' actually belong to `input2name'. */
+ contents of 'input1name' actually belong to 'input2name'. */
if(p->input2name==NULL)
{
p->input2name=p->input1name;
@@ -271,14 +271,14 @@ ui_check_options_and_arguments(struct matchparams *p)
&& p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU for first input. When the input is "
"a FITS file, a HDU must also be specified, you can use the "
- "`--hdu' (`-h') option and give it the HDU number (starting "
+ "'--hdu' ('-h') option and give it the HDU number (starting "
"from zero), extension name, or anything acceptable by "
"CFITSIO");
if( p->input2name
&& gal_fits_name_is_fits(p->input2name)
&& p->hdu2==NULL )
error(EXIT_FAILURE, 0, "no HDU for second input. Please use "
- "the `--hdu2' (`-H') option and give it the HDU number "
+ "the '--hdu2' ('-H') option and give it the HDU number "
"(starting from zero), extension name, or anything "
"acceptable by CFITSIO");
}
@@ -313,7 +313,7 @@ ui_set_mode(struct matchparams *p)
/* We will base the mode on the first input, then check with the
second. Note that when the first is from standard input (it is
- `NULL'), then we go into catalog mode because currently we assume
+ 'NULL'), then we go into catalog mode because currently we assume
standard input is only for plain text and WCS matching is not defined
on plain text. */
if( p->input1name && gal_fits_name_is_fits(p->input1name) )
@@ -330,13 +330,13 @@ ui_set_mode(struct matchparams *p)
/* Necessary sanity checks. */
if(p->mode==MATCH_MODE_CATALOG && p->cp.searchin==0)
- error(EXIT_FAILURE, 0, "no `--searchin' option specified. Please run "
+ error(EXIT_FAILURE, 0, "no '--searchin' option specified. Please run "
"the following command for more information:\n\n"
" $ info gnuastro \"selecting table columns\"\n");
/* Now that the mode is set, do some sanity checks on the second
- catalog. Recall that when `--coord' is given, there is no second input
+ catalog. Recall that when '--coord' is given, there is no second input
file.*/
if(p->input2name)
{
@@ -365,10 +365,10 @@ ui_set_mode(struct matchparams *p)
}
else
{
- /* When there is no second-input file name (`--coord' is given), we
+ /* When there is no second-input file name ('--coord' is given), we
cannot be in WCS mode (requiring a FITS file). */
if(p->mode==MATCH_MODE_WCS)
- error(EXIT_FAILURE, 0, "%s is an image, while `--coord' is only "
+ error(EXIT_FAILURE, 0, "%s is an image, while '--coord' is only "
"meaningful for catalogs",
gal_checkset_dataset_name(p->input1name, p->cp.hdu));
}
@@ -393,10 +393,10 @@ ui_read_columns_aperture_2d(struct matchparams *p)
/* A general sanity check: the first two elements of aperture cannot be
zero or negative. */
if( oaper[0]<=0 )
- error(EXIT_FAILURE, 0, "the first value of `--aperture' cannot be "
+ error(EXIT_FAILURE, 0, "the first value of '--aperture' cannot be "
"zero or negative");
if( p->aperture->size>1 && oaper[1]<=0 )
- error(EXIT_FAILURE, 0, "the second value of `--aperture' cannot be "
+ error(EXIT_FAILURE, 0, "the second value of '--aperture' cannot be "
"zero or negative");
/* Will be needed in more than one case. */
@@ -424,13 +424,13 @@ ui_read_columns_aperture_2d(struct matchparams *p)
case 3:
if(oaper[1]>1)
- error(EXIT_FAILURE, 0, "second value to `--aperture' is larger "
+ error(EXIT_FAILURE, 0, "second value to '--aperture' is larger "
"than one. When three numbers are given to this option, the "
"second is the axis ratio (which must always be less than 1).");
break;
default:
- error(EXIT_FAILURE, 0, "%zu values given to `--aperture'. In 2D, this "
+ error(EXIT_FAILURE, 0, "%zu values given to '--aperture'. In 2D, this "
"option can only take 1, 2, or 3 values", p->aperture->size);
}
@@ -465,10 +465,10 @@ ui_read_columns_aperture_3d(struct matchparams *p)
/* A general sanity check: the first two elements of aperture cannot be
zero or negative. */
if( oaper[0]<=0 )
- error(EXIT_FAILURE, 0, "the first value of `--aperture' cannot be "
+ error(EXIT_FAILURE, 0, "the first value of '--aperture' cannot be "
"zero or negative");
if( p->aperture->size>2 && (oaper[1]<=0 || oaper[2]<=0) )
- error(EXIT_FAILURE, 0, "the second and third values of `--aperture' "
+ error(EXIT_FAILURE, 0, "the second and third values of '--aperture' "
"cannot be zero or negative");
/* Will be needed in more than one case. */
@@ -498,8 +498,8 @@ ui_read_columns_aperture_3d(struct matchparams *p)
naper[3] = naper[4] = naper[5] = 0;
}
- /* Major axis is along the second dimension. So we want `X' to be in
- the direction of `y'. Therefore, just the first Eurler ZXZ
+ /* Major axis is along the second dimension. So we want 'X' to be in
+ the direction of 'y'. Therefore, just the first Eurler ZXZ
rotation is necessary by 90 degrees. Here is how the rotated
coordinates (X,Y,Z) look like (after one rotation about Z).
@@ -511,7 +511,7 @@ ui_read_columns_aperture_3d(struct matchparams *p)
x /
You see how the major axis (X) now lies in the second original
- direction (y). The length along `x' is now along `Y' and the third
+ direction (y). The length along 'x' is now along 'Y' and the third
hasn't changed. Note that we are talking about the semi-axis
lengths (a scalar, not a vector), so +- is irrelevant. */
else if(oaper[1]>=oaper[0] && oaper[1]>=oaper[2])
@@ -523,8 +523,8 @@ ui_read_columns_aperture_3d(struct matchparams *p)
naper[4] = naper[5] = 0;
}
- /* The major axis is along the third dimension. So we want `X' to
- point in the direction of `z'. To get to that point, we need 90
+ /* The major axis is along the third dimension. So we want 'X' to
+ point in the direction of 'z'. To get to that point, we need 90
degree rotations in all three Euler ZXZ rotations.
|z (before) z'| /y' |y'' |X
@@ -552,13 +552,13 @@ ui_read_columns_aperture_3d(struct matchparams *p)
case 6:
if(oaper[1]>1 || oaper[2]>1)
error(EXIT_FAILURE, 0, "atleast one of the second or third values "
- "to `--aperture' is larger than one. When size numbers are "
+ "to '--aperture' is larger than one. When size numbers are "
"given to this option (in 3D), the second and third are the "
"axis ratios (which must always be less than 1).");
break;
default:
- error(EXIT_FAILURE, 0, "%zu values given to `--aperture'. In 3D, this "
+ error(EXIT_FAILURE, 0, "%zu values given to '--aperture'. In 3D, this "
"option can only take 1, 3, or 6 values. See the description of "
"this option in the book for more with this command:\n\n"
" $ info astmatch\n", p->aperture->size);
@@ -586,13 +586,13 @@ ui_set_columns_sanity_check_read_aperture(struct
matchparams *p)
if(p->coord)
{
if(p->ccol1==NULL)
- error(EXIT_FAILURE, 0, "no value given to `--ccol1' (necessary with "
- "`--coord')");
+ error(EXIT_FAILURE, 0, "no value given to '--ccol1' (necessary with "
+ "'--coord')");
}
else
{
if(p->ccol1==NULL || p->ccol2==NULL)
- error(EXIT_FAILURE, 0, "both `--ccol1' and `--ccol2' must be given. "
+ error(EXIT_FAILURE, 0, "both '--ccol1' and '--ccol2' must be given. "
"They specify the columns containing the coordinates to match");
}
@@ -600,9 +600,9 @@ ui_set_columns_sanity_check_read_aperture(struct
matchparams *p)
ccol1n = p->ccol1->size;
ccol2n = p->coord ? p->coord->size : p->ccol2->size;
if(ccol1n!=ccol2n)
- error(EXIT_FAILURE, 0, "number of coordinates given to `--ccol1' "
- "(%zu) and `--%s' (%zu) must be equal.\n\n"
- "If you didn't call these options, run with `--checkconfig' to "
+ error(EXIT_FAILURE, 0, "number of coordinates given to '--ccol1' "
+ "(%zu) and '--%s' (%zu) must be equal.\n\n"
+ "If you didn't call these options, run with '--checkconfig' to "
"see which configuration file is responsible. You can always "
"override the configuration file values by calling the option "
"manually on the command-line",
@@ -614,7 +614,7 @@ ui_set_columns_sanity_check_read_aperture(struct
matchparams *p)
{
case 1:
if(p->aperture->size>1)
- error(EXIT_FAILURE, 0, "%zu values given to `--aperture'. In a 1D "
+ error(EXIT_FAILURE, 0, "%zu values given to '--aperture'. In a 1D "
"match, this option can only take one value",
p->aperture->size);
break;
@@ -625,11 +625,11 @@ ui_set_columns_sanity_check_read_aperture(struct
matchparams *p)
error(EXIT_FAILURE, 0, "%zu dimensional matches are not currently "
"supported (maximum is 2 dimensions). The number of "
"dimensions is deduced from the number of values given to "
- "`--ccol1' (or `--coord') and `--ccol2'", ccol1n);
+ "'--ccol1' (or '--coord') and '--ccol2'", ccol1n);
}
else
error(EXIT_FAILURE, 0, "no matching aperture specified. Please use "
- "the `--aperture' option to define the acceptable aperture for "
+ "the '--aperture' option to define the acceptable aperture for "
"matching the coordinates (in the same units as each "
"dimension). Please run the following command for more "
"information.\n\n $ info %s\n", PROGRAM_EXEC);
@@ -642,7 +642,7 @@ ui_set_columns_sanity_check_read_aperture(struct
matchparams *p)
-/* Save the manually given coordinates (with `--coord') in column format (a
+/* Save the manually given coordinates (with '--coord') in column format (a
list of datasets). */
static gal_data_t *
ui_set_columns_from_coord(struct matchparams *p)
@@ -678,8 +678,8 @@ ui_read_columns_to_double(struct matchparams *p, char
*filename, char *hdu,
gal_data_t *tmp, *ttmp, *tout, *out=NULL;
struct gal_options_common_params *cp=&p->cp;
char *diff_cols_error="%s: the number of columns matched (%zu) "
- "differs from the number of usable calls to `--ccol1' (%zu). "
- "Please give more specific values to `--ccol1' (column "
+ "differs from the number of usable calls to '--ccol1' (%zu). "
+ "Please give more specific values to '--ccol1' (column "
"numberes are the only identifiers guaranteed to be unique).";
/* Read the columns. Note that the first input's name can be NULL (if the
@@ -705,7 +705,7 @@ ui_read_columns_to_double(struct matchparams *p, char
*filename, char *hdu,
tmp=tout;
while(tmp!=NULL)
{
- /* We need ot set the `next' pointer */
+ /* We need ot set the 'next' pointer */
ttmp=tmp->next;
tmp->next=NULL;
@@ -717,11 +717,11 @@ ui_read_columns_to_double(struct matchparams *p, char
*filename, char *hdu,
gal_data_copy_to_new_type_free(tmp,
GAL_TYPE_FLOAT64) );
- /* Set `tmp' to the initial `next pointer. */
+ /* Set 'tmp' to the initial 'next pointer. */
tmp=ttmp;
}
- /* The `out' above is in reverse, so correct it and return */
+ /* The 'out' above is in reverse, so correct it and return */
gal_list_data_reverse(&out);
return out;
}
@@ -789,7 +789,7 @@ ui_preparations_out_cols(struct matchparams *p)
{
case 'a': gal_list_str_add(&p->acols, col+1, 0); break;
case 'b':
- /* With `--coord', only numbers that are smaller than the number
+ /* With '--coord', only numbers that are smaller than the number
of the dimensions are acceptable. */
if(p->coord)
{
@@ -809,10 +809,10 @@ ui_preparations_out_cols(struct matchparams *p)
}
if(goodvalue==0)
error(EXIT_FAILURE, 0, "bad value to second catalog "
- "column (%s) of `--outcols'.\n\n"
- "With the `--coord' option, the second catalog is "
+ "column (%s) of '--outcols'.\n\n"
+ "With the '--coord' option, the second catalog is "
"assumed to have a single row and the given number "
- "of columns. Therefore when using `--outcols', only "
+ "of columns. Therefore when using '--outcols', only "
"integers that are less than the number of "
"dimensions (%zu in this case) are acceptable", col+1,
ndim);
@@ -820,10 +820,10 @@ ui_preparations_out_cols(struct matchparams *p)
gal_list_str_add(&p->bcols, col+1, 0);
break;
default:
- error(EXIT_FAILURE, 0, "`%s' is not a valid value for "
- "`--outcols'.\n\n"
+ error(EXIT_FAILURE, 0, "'%s' is not a valid value for "
+ "'--outcols'.\n\n"
"The first character of each value to this option must be "
- "either `a' or `b'. The former specifies a column from the "
+ "either 'a' or 'b'. The former specifies a column from the "
"first input and the latter a column from the second. The "
"characters after them can be any column identifier (number, "
"name, or regular expression). For more on column selection, "
@@ -886,7 +886,7 @@ ui_preparations_out_name(struct matchparams *p)
}
else
{
- /* Set `p->out1name' and `p->out2name'. */
+ /* Set 'p->out1name' and 'p->out2name'. */
if(p->cp.output)
{
if( gal_fits_name_is_fits(p->cp.output) )
@@ -899,7 +899,7 @@ ui_preparations_out_name(struct matchparams *p)
/* Here, we are be using the output name as input to the
automatic output generating function (usually it is
the input name, not the output name). Therefore, the
- `keepinputdir' variable should be 1. So we will
+ 'keepinputdir' variable should be 1. So we will
temporarily change it here, then set it back to what
it was. */
keepinputdir_orig=p->cp.keepinputdir;
@@ -998,9 +998,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
matchparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/match/ui.h b/bin/match/ui.h
index 6d66082..2c172fd 100644
--- a/bin/match/ui.h
+++ b/bin/match/ui.h
@@ -5,7 +5,7 @@ Match is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkcatalog/Makefile.am b/bin/mkcatalog/Makefile.am
index 19b30f3..be06118 100644
--- a/bin/mkcatalog/Makefile.am
+++ b/bin/mkcatalog/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astmkcatalog
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmkcatalog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astmkcatalog_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astmkcatalog_SOURCES = main.c ui.c mkcatalog.c columns.c upperlimit.c parse.c
diff --git a/bin/mkcatalog/args.h b/bin/mkcatalog/args.h
index 1a2ad60..6582d38 100644
--- a/bin/mkcatalog/args.h
+++ b/bin/mkcatalog/args.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -35,7 +35,7 @@ struct argp_option program_options[] =
{
"clumpsfile",
UI_KEY_CLUMPSFILE,
- "STR",
+ "FITS",
0,
"Dataset containing clump labels.",
GAL_OPTIONS_GROUP_INPUT,
@@ -61,7 +61,7 @@ struct argp_option program_options[] =
{
"valuesfile",
UI_KEY_VALUESFILE,
- "STR",
+ "FITS",
0,
"Values/brightness dataset.",
GAL_OPTIONS_GROUP_INPUT,
@@ -87,9 +87,9 @@ struct argp_option program_options[] =
{
"insky",
UI_KEY_INSKY,
- "STR/FLT",
+ "FITS/FLT",
0,
- "Input Sky value or dataset.",
+ "Input Sky value or file.",
GAL_OPTIONS_GROUP_INPUT,
&p->skyfile,
GAL_TYPE_STRING,
@@ -163,6 +163,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET
},
{
+ "forcereadstd",
+ UI_KEY_FORCEREADSTD,
+ 0,
+ 0,
+ "Read STD even if no columns need it.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->forcereadstd,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
"zeropoint",
UI_KEY_ZEROPOINT,
"FLT",
@@ -175,6 +188,20 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "sigmaclip",
+ UI_KEY_SIGMACLIP,
+ "FLT,FLT",
+ 0,
+ "Sigma-clip column multiple and tolerance.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->sigmaclip,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ gal_options_read_sigma_clip
+ },
@@ -244,6 +271,21 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "inbetweenints",
+ UI_KEY_INBETWEENINTS,
+ 0,
+ 0,
+ "Keep rows (integer ids) with no labels.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->inbetweenints,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+
+
@@ -256,7 +298,7 @@ struct argp_option program_options[] =
{
"upmaskfile",
UI_KEY_UPMASKFILE,
- "STR",
+ "FITS",
0,
"Mask image file name only for upper limit.",
UI_GROUP_UPPERLIMIT,
@@ -365,13 +407,38 @@ struct argp_option program_options[] =
+ /* Other column configurations. */
+ {
+ 0, 0, 0, 0,
+ "Settings for other columns:",
+ UI_GROUP_OTHERSETTINGS
+ },
+ {
+ "fracmax",
+ UI_KEY_FRACMAX,
+ "FLT[,FLT]",
+ 0,
+ "Fraction(s) in --fracmaxarea1 or --fracmaxarea2.",
+ UI_GROUP_OTHERSETTINGS,
+ &p->fracmax,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ gal_options_parse_csv_float64
+ },
+
+
+
+
+
/* ID related columns. */
{
0, 0, 0, 0,
"Identifier columns",
UI_GROUP_COLUMNS_IDS
},
- { /* `ids' is not a unique column, it is a combination of several
+ { /* 'ids' is not a unique column, it is a combination of several
columns. */
"ids",
UI_KEY_IDS,
@@ -524,11 +591,95 @@ struct argp_option program_options[] =
ui_column_codes_ll
},
{
+ "minvx",
+ UI_KEY_MINVX,
+ 0,
+ 0,
+ "Minimum value's X axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "maxvx",
+ UI_KEY_MAXVX,
+ 0,
+ 0,
+ "Maximum value's X axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "minvy",
+ UI_KEY_MINVY,
+ 0,
+ 0,
+ "Minimum value's Y axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "maxvy",
+ UI_KEY_MAXVY,
+ 0,
+ 0,
+ "Maximum value's Y axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "minvz",
+ UI_KEY_MINVZ,
+ 0,
+ 0,
+ "Minimum value's Z axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "maxvz",
+ UI_KEY_MAXVZ,
+ 0,
+ 0,
+ "Maximum value's Z axis position",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
"minx",
UI_KEY_MINX,
0,
0,
- "Minimum first FITS axis position.",
+ "Minimum X axis position.",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -542,7 +693,7 @@ struct argp_option program_options[] =
UI_KEY_MAXX,
0,
0,
- "Maximum first FITS axis position.",
+ "Maximum X axis position.",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -556,7 +707,7 @@ struct argp_option program_options[] =
UI_KEY_MINY,
0,
0,
- "Minimum second FITS axis position.",
+ "Minimum Y axis position.",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -570,7 +721,7 @@ struct argp_option program_options[] =
UI_KEY_MAXY,
0,
0,
- "Maximum second FITS axis position.",
+ "Maximum Y axis position.",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -584,7 +735,7 @@ struct argp_option program_options[] =
UI_KEY_MINZ,
0,
0,
- "Minimum third FITS axis position.",
+ "Minimum Z axis position",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -598,7 +749,7 @@ struct argp_option program_options[] =
UI_KEY_MAXZ,
0,
0,
- "Maximum third FITS axis position.",
+ "Maximum Z axis position.",
UI_GROUP_COLUMNS_POSITION_PIXEL,
0,
GAL_TYPE_INVALID,
@@ -994,6 +1145,20 @@ struct argp_option program_options[] =
ui_column_codes_ll
},
{
+ "maximum",
+ UI_KEY_MAXIMUM,
+ 0,
+ 0,
+ "Maximum value (mean of top three pixels)",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
"magnitude",
UI_KEY_MAGNITUDE,
0,
@@ -1189,6 +1354,62 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET,
ui_column_codes_ll
},
+ {
+ "sigclip-number",
+ UI_KEY_SIGCLIPNUMBER,
+ 0,
+ 0,
+ "Number of pixels in Sigma-clipped measurement.",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "sigclip-median",
+ UI_KEY_SIGCLIPMEDIAN,
+ 0,
+ 0,
+ "Median after Sigma-clipping",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "sigclip-mean",
+ UI_KEY_SIGCLIPMEAN,
+ 0,
+ 0,
+ "Mean after Sigma-clipping",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "sigclip-std",
+ UI_KEY_SIGCLIPSTD,
+ 0,
+ 0,
+ "Standard deviation after Sigma-clipping",
+ UI_GROUP_COLUMNS_BRIGHTNESS,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
@@ -1228,11 +1449,67 @@ struct argp_option program_options[] =
ui_column_codes_ll
},
{
+ "areaarcsec2",
+ UI_KEY_AREAARCSEC2,
+ 0,
+ 0,
+ "Area of labeled region in arcsec^2.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "areaminv",
+ UI_KEY_MINVNUM,
+ 0,
+ 0,
+ "Number of pixels with minimum value.",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "areamaxv",
+ UI_KEY_MAXVNUM,
+ 0,
+ 0,
+ "Number of pixels with maximum value.",
+ UI_GROUP_COLUMNS_POSITION_PIXEL,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "surfacebrightness",
+ UI_KEY_SURFACEBRIGHTNESS,
+ 0,
+ 0,
+ "Surface brightness (mag/arcsec^2).",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
"areaxy",
UI_KEY_AREAXY,
0,
0,
- "Projected area in first two dimentions.",
+ "Projected area in first two dimensions.",
UI_GROUP_COLUMNS_MORPHOLOGY,
0,
GAL_TYPE_INVALID,
@@ -1409,6 +1686,205 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET,
ui_column_codes_ll
},
+ {
+ "fwhm",
+ UI_KEY_FWHM,
+ 0,
+ 0,
+ "Full width at half max (non-parametric).",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfmaxarea",
+ UI_KEY_HALFMAXAREA,
+ 0,
+ 0,
+ "No. pixels valued above half the max.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfmaxradius",
+ UI_KEY_HALFMAXRADIUS,
+ 0,
+ 0,
+ "Radius at half the maximum (non-parametric).",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfmaxsum",
+ UI_KEY_HALFMAXSUM,
+ 0,
+ 0,
+ "Sum of pixels above half the maximum.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfmaxsb",
+ UI_KEY_HALFMAXSB,
+ 0,
+ 0,
+ "Surface brightness within half the maximum.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfsumarea",
+ UI_KEY_HALFSUMAREA,
+ 0,
+ 0,
+ "Area containing half of --brightness.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfsumsb",
+ UI_KEY_HALFSUMSB,
+ 0,
+ 0,
+ "Surface brightness within --halfsumarea.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "halfsumradius",
+ UI_KEY_HALFSUMRADIUS,
+ 0,
+ 0,
+ "Radius calculated from --halfsumarea.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxsum1",
+ UI_KEY_FRACMAXSUM1,
+ 0,
+ 0,
+ "Sum of pixels brighter than 1st frac. of max.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxsum2",
+ UI_KEY_FRACMAXSUM2,
+ 0,
+ 0,
+ "Sum of pixels brighter than 2nd frac. of max.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxarea1",
+ UI_KEY_FRACMAXAREA1,
+ 0,
+ 0,
+ "Area containing 1st fraction of maximum.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxarea2",
+ UI_KEY_FRACMAXAREA2,
+ 0,
+ 0,
+ "Area containing 2nd fraction of maximum.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxradius1",
+ UI_KEY_FRACMAXRADIUS1,
+ 0,
+ 0,
+ "Radius calculated from --fracmaxarea1.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+ {
+ "fracmaxradius2",
+ UI_KEY_FRACMAXRADIUS2,
+ 0,
+ 0,
+ "Radius calculated from --fracmaxarea2.",
+ UI_GROUP_COLUMNS_MORPHOLOGY,
+ 0,
+ GAL_TYPE_INVALID,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
+ ui_column_codes_ll
+ },
+
+
+
{0}
diff --git a/bin/mkcatalog/astmkcatalog.conf b/bin/mkcatalog/astmkcatalog.conf
index 19c417a..6815d2e 100644
--- a/bin/mkcatalog/astmkcatalog.conf
+++ b/bin/mkcatalog/astmkcatalog.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astmkcatalog # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -26,6 +26,7 @@
skyhdu SKY
stdhdu SKY_STD
zeropoint 0.0
+ sigmaclip 3,0.2
# Output:
sfmagnsigma 1
diff --git a/bin/mkcatalog/authors-cite.h b/bin/mkcatalog/authors-cite.h
index 6d08bca..cdb8f44 100644
--- a/bin/mkcatalog/authors-cite.h
+++ b/bin/mkcatalog/authors-cite.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,28 +26,28 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
-
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
-
-#define PROGRAM_BIBTEX \
- "Description of MakeCatalog\n" \
- "--------------------------\n" \
- "@ARTICLE{2016arXiv161106387A,\n" \
- " author = {{Akhlaghi}, M.},\n" \
- " title = \"{Separating detection and catalog production}\",\n" \
- " journal = {ASP Conf. Ser. (in press)},\n" \
- "archivePrefix = \"arXiv\",\n" \
- " eprint = {1611.06387},\n" \
- "primaryClass = \"astro-ph.IM\",\n" \
- " keywords = {Astrophysics - Instrumentation and Methods for " \
- "Astrophysics},\n" \
- " year = 2016,\n" \
- " month = nov,\n" \
- " adsurl = {http://adsabs.harvard.edu/abs/2016arXiv161106387A},\n" \
- " adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n" \
- "};\n"
+ put a row of '-' with the same length and then put the BibTeX.
+
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
+
+#define PROGRAM_BIBTEX \
+ "Description of MakeCatalog\n" \
+ "--------------------------\n" \
+ "@ARTICLE{makecatalog,\n" \
+ " author = {{Akhlaghi}, Mohammad},\n" \
+ " title = \"{Separating Detection and Catalog Production}\",\n" \
+ " journal = {ASPC},\n" \
+ " year = \"2019\",\n" \
+ " month = \"Oct\",\n" \
+ " volume = {521},\n" \
+ " pages = {299},\n" \
+ "archivePrefix = {arXiv},\n" \
+ " eprint = {1611.06387},\n" \
+ " primaryClass = {astro-ph.IM},\n" \
+ " adsurl = {https://ui.adsabs.harvard.edu/abs/2019ASPC..521..299A},\n"
\
+ " adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n" \
+ "}\n"
#define PROGRAM_AUTHORS "Mohammad Akhlaghi"
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index 6fac3a7..e94bb79 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -30,6 +30,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <string.h>
#include <pthread.h>
+#include <gnuastro/wcs.h>
#include <gnuastro/pointer.h>
#include <gnuastro-internal/checkset.h>
@@ -52,7 +53,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
requested first or Dec or if they are requested multiple times. So
before the allocation, we'll check the first one.
- The space that is allocated in `columns_define_alloc' is for the final
+ The space that is allocated in 'columns_define_alloc' is for the final
values that are written in the output file. */
static void
columns_alloc_radec(struct mkcatalogparams *p)
@@ -78,7 +79,7 @@ columns_alloc_radec(struct mkcatalogparams *p)
-/* Similar to `columns_alloc_radec'. */
+/* Similar to 'columns_alloc_radec'. */
static void
columns_alloc_georadec(struct mkcatalogparams *p)
{
@@ -103,7 +104,7 @@ columns_alloc_georadec(struct mkcatalogparams *p)
-/* Similar to `columns_alloc_radec'. */
+/* Similar to 'columns_alloc_radec'. */
static void
columns_alloc_clumpsradec(struct mkcatalogparams *p)
{
@@ -120,7 +121,7 @@ columns_alloc_clumpsradec(struct mkcatalogparams *p)
-/* Similar to `columns_alloc_radec'. */
+/* Similar to 'columns_alloc_radec'. */
static void
columns_alloc_clumpsgeoradec(struct mkcatalogparams *p)
{
@@ -189,6 +190,7 @@ static void
columns_wcs_preparation(struct mkcatalogparams *p)
{
size_t i;
+ double *pixscale;
gal_list_i32_t *colcode;
int continue_wcs_check=1;
@@ -202,6 +204,10 @@ columns_wcs_preparation(struct mkcatalogparams *p)
/* High-level. */
case UI_KEY_RA:
case UI_KEY_DEC:
+ case UI_KEY_HALFMAXSB:
+ case UI_KEY_HALFSUMSB:
+ case UI_KEY_AREAARCSEC2:
+ case UI_KEY_SURFACEBRIGHTNESS:
/* Low-level. */
case UI_KEY_W1:
@@ -246,6 +252,16 @@ columns_wcs_preparation(struct mkcatalogparams *p)
"the WCS axis types (CTYPE)", p->objectsfile, p->cp.hdu,
colcode->v==UI_KEY_RA ? "RA" : "DEC");
break;
+
+ /* Calculate the pixel area if necessary. */
+ case UI_KEY_HALFMAXSB:
+ case UI_KEY_HALFSUMSB:
+ case UI_KEY_AREAARCSEC2:
+ case UI_KEY_SURFACEBRIGHTNESS:
+ pixscale=gal_wcs_pixel_scale(p->objects->wcs);
+ p->pixelarcsecsq=pixscale[0]*pixscale[1]*3600.0f*3600.0f;
+ free(pixscale);
+ break;
}
}
@@ -265,6 +281,23 @@ columns_sanity_check(struct mkcatalogparams *p)
based on it (for units and names). */
columns_wcs_preparation(p);
+ /* If sigma-clipping measurements are requested, make sure the necessary
+ parameters are provided. */
+ for(colcode=p->columnids; colcode!=NULL; colcode=colcode->next)
+ switch(colcode->v)
+ {
+ case UI_KEY_SIGCLIPSTD:
+ case UI_KEY_SIGCLIPMEAN:
+ case UI_KEY_SIGCLIPNUMBER:
+ case UI_KEY_SIGCLIPMEDIAN:
+ if(isnan(p->sigmaclip[0]) || isnan(p->sigmaclip[1]))
+ error(EXIT_FAILURE, 0, "no sigma-clip defined! When any of the "
+ "sigma-clipping columns are requested, it is necessary to "
+ "specify the necessary sigma-clipping parameters with the "
+ "'--sigmaclip' option");
+ break;
+ }
+
/* Check for dimension-specific columns. */
switch(p->objects->ndim)
{
@@ -301,6 +334,9 @@ columns_sanity_check(struct mkcatalogparams *p)
case UI_KEY_GEOSEMIMAJOR:
case UI_KEY_GEOSEMIMINOR:
case UI_KEY_GEOAXISRATIO:
+ case UI_KEY_HALFSUMRADIUS:
+ case UI_KEY_FRACMAXRADIUS1:
+ case UI_KEY_FRACMAXRADIUS2:
case UI_KEY_GEOPOSITIONANGLE:
error(EXIT_FAILURE, 0, "columns requiring second moment "
"calculations (like semi-major, semi-minor, axis ratio "
@@ -350,8 +386,8 @@ columns_define_alloc(struct mkcatalogparams *p)
for(colcode=p->columnids; colcode!=NULL; colcode=colcode->next)
{
/* Set the column-specific parameters, please follow the same order
- as `args.h'. IMPORTANT: we want the names to be the same as the
- option names. Note that zero `disp_' variables will be
+ as 'args.h'. IMPORTANT: we want the names to be the same as the
+ option names. Note that zero 'disp_' variables will be
automatically determined.*/
switch(colcode->v)
{
@@ -420,6 +456,33 @@ columns_define_alloc(struct mkcatalogparams *p)
oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
break;
+ case UI_KEY_AREAARCSEC2:
+ name = "AREA_ARCSEC2";
+ unit = "arcsec2";
+ ocomment = "Number of non-blank pixels in arcsec^2";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ break;
+
+ case UI_KEY_SURFACEBRIGHTNESS:
+ name = "SURFACE_BRIGHTNESS";
+ unit = "mag/arcsec^2";
+ ocomment = "Surface brightness (magnitude of
brightness/area).";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ break;
+
case UI_KEY_AREAXY:
name = "AREAXY";
unit = "counter";
@@ -658,6 +721,116 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_precision = 3;
oiflag[ OCOL_C_GZ ] = 1;
+ case UI_KEY_MINVX:
+ name = "MIN_V_X";
+ unit = "pixel";
+ ocomment = "Minimum value X pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MINVX ] = ciflag[ CCOL_MINVX ] = 1;
+ oiflag[ OCOL_MINVNUM ] = ciflag[ CCOL_MINVNUM ] = 1;
+ break;
+
+ case UI_KEY_MAXVX:
+ name = "MAX_V_X";
+ unit = "pixel";
+ ocomment = "Maximum value X pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MAXVX ] = ciflag[ CCOL_MAXVX ] = 1;
+ oiflag[ OCOL_MAXVNUM ] = ciflag[ CCOL_MAXVNUM ] = 1;
+ break;
+
+ case UI_KEY_MINVY:
+ name = "MIN_V_Y";
+ unit = "pixel";
+ ocomment = "Minimum value Y pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MINVY ] = ciflag[ CCOL_MINVY ] = 1;
+ oiflag[ OCOL_MINVNUM ] = ciflag[ CCOL_MINVNUM ] = 1;
+ break;
+
+ case UI_KEY_MAXVY:
+ name = "MAX_V_Y";
+ unit = "pixel";
+ ocomment = "Maximum value Y pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MAXVY ] = ciflag[ CCOL_MAXVY ] = 1;
+ oiflag[ OCOL_MAXVNUM ] = ciflag[ CCOL_MAXVNUM ] = 1;
+ break;
+
+ case UI_KEY_MINVZ:
+ name = "MIN_V_Z";
+ unit = "pixel";
+ ocomment = "Minimum value Z pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MINVZ ] = ciflag[ CCOL_MINVZ ] = 1;
+ oiflag[ OCOL_MINVNUM ] = ciflag[ CCOL_MINVNUM ] = 1;
+ break;
+
+ case UI_KEY_MAXVZ:
+ name = "MAX_V_Z";
+ unit = "pixel";
+ ocomment = "Maximum value Z pixel position.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MAXVZ ] = ciflag[ CCOL_MAXVZ ] = 1;
+ oiflag[ OCOL_MAXVNUM ] = ciflag[ CCOL_MAXVNUM ] = 1;
+ break;
+
+ case UI_KEY_MINVNUM:
+ name = "MIN_V_NUM";
+ unit = "counter";
+ ocomment = "Number of pixels with the minimum value.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_UINT32;
+ ctype = GAL_TYPE_UINT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MINVNUM ] = ciflag[ CCOL_MINVNUM ] = 1;
+ break;
+
+ case UI_KEY_MAXVNUM:
+ name = "MAX_V_NUM";
+ unit = "counter";
+ ocomment = "Number of pixels with the maximum value..";
+ ccomment = ocomment;
+ otype = GAL_TYPE_UINT32;
+ ctype = GAL_TYPE_UINT32;
+ disp_fmt = 0;
+ disp_width = 10;
+ disp_precision = 0;
+ oiflag[ OCOL_MAXVNUM ] = ciflag[ CCOL_MAXVNUM ] = 1;
+ break;
+
case UI_KEY_MINX:
name = "MIN_X";
unit = "pixel";
@@ -669,6 +842,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MINX ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_MAXX:
@@ -682,6 +856,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MAXX ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_MINY:
@@ -695,6 +870,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MINY ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_MAXY:
@@ -708,6 +884,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MAXY ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_MINZ:
@@ -721,6 +898,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MINZ ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_MAXZ:
@@ -734,6 +912,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_width = 10;
disp_precision = 0;
ciflag[ CCOL_MAXZ ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
break;
case UI_KEY_W1:
@@ -1075,6 +1254,84 @@ columns_define_alloc(struct mkcatalogparams *p)
ciflag[ CCOL_RIV_SUM ] = 1;
break;
+ case UI_KEY_MAXIMUM:
+ name = "MAXIMUM";
+ unit = MKCATALOG_NO_UNIT;
+ ocomment = "Maximum of sky subtracted values.";
+ ccomment = "Maximum of pixels subtracted by rivers.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 5;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_MAXIMUM ] = ciflag[ CCOL_MAXIMUM ] = 1;
+ break;
+
+ case UI_KEY_SIGCLIPNUMBER:
+ name = "SIGCLIP-NUMBER";
+ unit = "counter";
+ ocomment = "Number of pixels in Sigma-clipped object";
+ ccomment = "Number of pixels in Sigma-clipped clump.";
+ otype = GAL_TYPE_INT32;
+ ctype = GAL_TYPE_INT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SIGCLIPNUM ] = ciflag[ CCOL_SIGCLIPNUM ] = 1;
+ ciflag[ CCOL_RIV_NUM ] = 1;
+ ciflag[ CCOL_RIV_SUM ] = 1;
+ break;
+
+ case UI_KEY_SIGCLIPMEDIAN:
+ name = "SIGCLIP-MEDIAN";
+ unit = MKCATALOG_NO_UNIT;
+ ocomment = "Sigma-clipped median of object pixels.";
+ ccomment = "Sigma-clipped median of clump pixels.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 5;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SIGCLIPMEDIAN ] = ciflag[ CCOL_SIGCLIPMEDIAN ] = 1;
+ ciflag[ CCOL_RIV_NUM ] = 1;
+ ciflag[ CCOL_RIV_SUM ] = 1;
+ break;
+
+ case UI_KEY_SIGCLIPMEAN:
+ name = "SIGCLIP-MEAN";
+ unit = MKCATALOG_NO_UNIT;
+ ocomment = "Sigma-clipped mean of object pixels.";
+ ccomment = "Sigma-clipped mean of clump pixels.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 5;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SIGCLIPMEAN ] = ciflag[ CCOL_SIGCLIPMEAN ] = 1;
+ ciflag[ CCOL_RIV_NUM ] = 1;
+ ciflag[ CCOL_RIV_SUM ] = 1;
+ break;
+
+ case UI_KEY_SIGCLIPSTD:
+ name = "SIGCLIP-STD";
+ unit = MKCATALOG_NO_UNIT;
+ ocomment = "Sigma-clipped standard deviation of object
pixels.";
+ ccomment = "Sigma-clipped standard deviation of clump pixels.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 5;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SIGCLIPSTD ] = ciflag[ CCOL_SIGCLIPSTD ] = 1;
+ ciflag[ CCOL_RIV_NUM ] = 1;
+ ciflag[ CCOL_RIV_SUM ] = 1;
+ break;
+
case UI_KEY_MAGNITUDE:
name = "MAGNITUDE";
unit = "log";
@@ -1257,6 +1514,7 @@ columns_define_alloc(struct mkcatalogparams *p)
disp_precision = 3;
oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
oiflag[ OCOL_SUM_VAR ] = ciflag[ CCOL_SUM_VAR ] = 1;
+ ciflag[ CCOL_NUM ] = 1;
ciflag[ CCOL_RIV_NUM ] = 1;
ciflag[ CCOL_RIV_SUM ] = 1;
ciflag[ CCOL_RIV_SUM_VAR ] = 1;
@@ -1458,6 +1716,180 @@ columns_define_alloc(struct mkcatalogparams *p)
oiflag[ OCOL_GXY ] = ciflag[ CCOL_GXY ] = 1;
break;
+ case UI_KEY_HALFSUMAREA:
+ name = "HALF_SUM_AREA";
+ unit = "counter";
+ ocomment = "Number of brightest pixels containing half of
total sum.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_INT32;
+ ctype = GAL_TYPE_INT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ oiflag[ OCOL_HALFSUMNUM ] = ciflag[ CCOL_HALFSUMNUM ] = 1;
+ break;
+
+ case UI_KEY_HALFMAXAREA:
+ name = "HALF_MAX_AREA";
+ unit = "counter";
+ ocomment = "Number of pixels with a value larger than half the
maximum.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_INT32;
+ ctype = GAL_TYPE_INT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_HALFMAXNUM ] = ciflag[ CCOL_HALFMAXNUM ] = 1;
+ break;
+
+ case UI_KEY_HALFMAXSUM:
+ name = "HALF_MAX_SUM";
+ unit = MKCATALOG_NO_UNIT;
+ ocomment = "Sum of pixels with a value larger than half the
maximum.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_HALFMAXSUM ] = ciflag[ CCOL_HALFMAXSUM ] = 1;
+ break;
+
+ case UI_KEY_HALFMAXSB:
+ name = "HALF_MAX_SB";
+ unit = "mag/arcsec^2";
+ ocomment = "Brightness within half the maximum, divided by its
area.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_HALFMAXNUM ] = ciflag[ CCOL_HALFMAXNUM ] = 1;
+ oiflag[ OCOL_HALFMAXSUM ] = ciflag[ CCOL_HALFMAXSUM ] = 1;
+ break;
+
+ case UI_KEY_HALFSUMSB:
+ name = "HALF_SUM_SB";
+ unit = "mag/arcsec^2";
+ ocomment = "Half the brightness, divided by its area.";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 5;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ oiflag[ OCOL_HALFSUMNUM ] = ciflag[ CCOL_HALFSUMNUM ] = 1;
+ break;
+
+ case UI_KEY_FRACMAXSUM1:
+ case UI_KEY_FRACMAXSUM2:
+ name = ( colcode->v==UI_KEY_FRACMAXSUM1
+ ? "FRAC_MAX_SUM_1"
+ : "FRAC_MAX_SUM_2" );
+ unit = MKCATALOG_NO_UNIT;
+ ccomment = ocomment;
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ if(colcode->v==UI_KEY_FRACMAXSUM1)
+ {
+ ocomment = "Sum of pixels brighter than 1st fraction of
maximum.";
+ oiflag[ OCOL_FRACMAX1SUM ] = ciflag[ CCOL_FRACMAX1SUM ] = 1;
+ }
+ else
+ {
+ ocomment = "Sum of pixels brighter than 2nd fraction of
maximum.";
+ oiflag[ OCOL_FRACMAX2SUM ] = ciflag[ CCOL_FRACMAX2SUM ] = 1;
+ }
+ break;
+
+ case UI_KEY_FRACMAXAREA1:
+ case UI_KEY_FRACMAXAREA2:
+ name = ( colcode->v==UI_KEY_FRACMAXAREA1
+ ? "FRAC_MAX_AREA_1"
+ : "FRAC_MAX_AREA_2" );
+ unit = "counter";
+ ocomment = "Number of pixels brighter than given fraction of
maximum value.";
+ ccomment = ocomment;
+ otype = GAL_TYPE_INT32;
+ ctype = GAL_TYPE_INT32;
+ disp_fmt = 0;
+ disp_width = 6;
+ disp_precision = 0;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1;
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ if(colcode->v==UI_KEY_FRACMAXAREA1)
+ oiflag[ OCOL_FRACMAX1NUM ] = ciflag[ CCOL_FRACMAX1NUM ] = 1;
+ else
+ oiflag[ OCOL_FRACMAX2NUM ] = ciflag[ CCOL_FRACMAX2NUM ] = 1;
+ break;
+
+ case UI_KEY_FWHM:
+ case UI_KEY_HALFMAXRADIUS:
+ case UI_KEY_HALFSUMRADIUS:
+ case UI_KEY_FRACMAXRADIUS1:
+ case UI_KEY_FRACMAXRADIUS2:
+ unit = "pixels";
+ otype = GAL_TYPE_FLOAT32;
+ ctype = GAL_TYPE_FLOAT32;
+ disp_fmt = GAL_TABLE_DISPLAY_FMT_GENERAL;
+ disp_width = 10;
+ disp_precision = 3;
+ oiflag[ OCOL_NUM ] = ciflag[ CCOL_NUM ] = 1; /*
halfsumarea */
+ oiflag[ OCOL_SUM ] = ciflag[ CCOL_SUM ] = 1;
+ oiflag[ OCOL_SUMWHT ] = ciflag[ CCOL_SUMWHT ] = 1; /*
axisratio. */
+ oiflag[ OCOL_VX ] = ciflag[ CCOL_VX ] = 1;
+ oiflag[ OCOL_VY ] = ciflag[ CCOL_VY ] = 1;
+ oiflag[ OCOL_VXX ] = ciflag[ CCOL_VXX ] = 1;
+ oiflag[ OCOL_VYY ] = ciflag[ CCOL_VYY ] = 1;
+ oiflag[ OCOL_VXY ] = ciflag[ CCOL_VXY ] = 1;
+ oiflag[ OCOL_NUMALL ] = ciflag[ CCOL_NUMALL ] = 1;
+ oiflag[ OCOL_GX ] = ciflag[ CCOL_GX ] = 1;
+ oiflag[ OCOL_GY ] = ciflag[ CCOL_GY ] = 1;
+ oiflag[ OCOL_GXX ] = ciflag[ CCOL_GXX ] = 1;
+ oiflag[ OCOL_GYY ] = ciflag[ CCOL_GYY ] = 1;
+ oiflag[ OCOL_GXY ] = ciflag[ CCOL_GXY ] = 1;
+ switch(colcode->v)
+ {
+ case UI_KEY_FWHM:
+ name="FWHM";
+ oiflag[ OCOL_HALFMAXNUM ] = ciflag[ CCOL_HALFMAXNUM ] = 1;
+ ocomment = "Full width at half maximum (accounting for
ellipticity).";
+ break;
+ case UI_KEY_HALFMAXRADIUS:
+ name="HALF_MAX_RADIUS";
+ oiflag[ OCOL_HALFMAXNUM ] = ciflag[ CCOL_HALFMAXNUM ] = 1;
+ ocomment = "Radius at half of maximum (accounting for
ellipticity).";
+ break;
+ case UI_KEY_HALFSUMRADIUS:
+ name="HALF_SUM_RADIUS";
+ oiflag[ OCOL_HALFSUMNUM ] = ciflag[ CCOL_HALFSUMNUM ] = 1;
+ ocomment = "Radius at half of total sum (accounting for
ellipticity).";
+ break;
+ case UI_KEY_FRACMAXRADIUS1:
+ name="FRAC_MAX_RADIUS_1";
+ oiflag[ OCOL_FRACMAX1NUM ] = ciflag[ CCOL_FRACMAX1NUM ] = 1;
+ ocomment = "Radius derived from area of 1st fraction of
maximum.";
+ break;
+ case UI_KEY_FRACMAXRADIUS2:
+ name="FRAC_MAX_RADIUS_2";
+ oiflag[ OCOL_FRACMAX2NUM ] = ciflag[ CCOL_FRACMAX2NUM ] = 1;
+ ocomment = "Radius derived from area of 2nd fraction of
maximum.";
+ break;
+ }
+ break;
+
default:
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix "
"the problem. The code %d is not an internally recognized "
@@ -1465,8 +1897,8 @@ columns_define_alloc(struct mkcatalogparams *p)
}
- /* If this is an objects column, add it to the list of columns. We
- will be using the `status' element to keep the MakeCatalog code
+ /* If this is an object's column, add it to the list of columns. We
+ will be using the 'status' element to keep the MakeCatalog code
for the columns. */
if(otype!=GAL_TYPE_INVALID)
{
@@ -1504,7 +1936,7 @@ columns_define_alloc(struct mkcatalogparams *p)
the user.
We'll just ignore the clump-specific ID-related columns,
- because the `--ids' (generic for both objects and clumps) is a
+ because the '--ids' (generic for both objects and clumps) is a
simple generic solution for identifiers. Also, ultimately,
they aren't measurements. */
else if( otype==GAL_TYPE_INVALID
@@ -1516,14 +1948,14 @@ columns_define_alloc(struct mkcatalogparams *p)
/* If the user has asked for clump-only columns, but no clumps catalog is
- to be created (the `--clumpscat' option was not given or there were no
+ to be created (the '--clumpscat' option was not given or there were no
clumps in the specified image), then print an informative message that
the columns in question will be ignored. */
if(noclumpimg)
{
gal_list_str_reverse(&noclumpimg);
fprintf(stderr, "WARNING: the following column(s) are unique to "
- "clumps (not objects), but the `--clumpscat' option has not "
+ "clumps (not objects), but the '--clumpscat' option has not "
"been called, or there were no clumps in the clumps labeled "
"image. Hence, these columns will be ignored in the "
"output.\n\n");
@@ -1563,7 +1995,10 @@ columns_define_alloc(struct mkcatalogparams *p)
/********** Column calculation ***************/
/******************************************************************/
#define MKC_RATIO(TOP,BOT) ( (BOT)!=0.0f ? (TOP)/(BOT) : NAN )
-#define MKC_MAG(B) ( ((B)>0) ? -2.5f * log10(B) + p->zeropoint : NAN )
+#define MKC_MAG(B) ( ((B)>0) ? -2.5f * log10(B) + p->zeropoint : NAN )
+#define MKC_SB(B, A) ( ((B)>0 && (A)>0) \
+ ? MKC_MAG(B) + 2.5f * log10((A) * p->pixelarcsecsq) \
+ : NAN )
@@ -1591,8 +2026,10 @@ columns_sn(struct mkcatalogparams *p, double *row, int
o0c1)
/* When grown clumps are requested from NoiseChisel, some "clumps" will
completely cover their objects and there will be no rivers. So if this
is a clump, and the river area is 0, we should treat the S/N as a an
- object. */
- double O = (o0c1 && row[ CCOL_RIV_NUM ]) ? row[ CCOL_RIV_SUM ] : 0.0 ;
+ object (and set the outer flux to 0.0). */
+ double O = ( (o0c1 && row[ CCOL_RIV_NUM ])
+ ? (row[ CCOL_NUM ]*row[ CCOL_RIV_SUM ]/row[ CCOL_RIV_NUM ])
+ : 0.0 );
/* Return the derived value. */
return sqrt(1/p->cpscorr) * (I-O) / columns_brightness_error(p, row, o0c1);
@@ -1721,13 +2158,14 @@ columns_clump_brightness(double *ci)
/* Measure the minimum and maximum positions. */
static uint32_t
-columns_xy_extrema(struct mkcatalog_passparams *pp, size_t *coord, int key)
+columns_xy_extrema(struct mkcatalog_passparams *pp, double *oi,
+ size_t *coord, int key)
{
size_t ndim=pp->tile->ndim;
gal_data_t *tile=pp->tile, *block=tile->block;
- /* We only want to do the coordinate estimation once: in `columns_fill',
- we initialized the coordinates with `GAL_BLANK_SIZE_T'. When the
+ /* We only want to do the coordinate estimation once: in 'columns_fill',
+ we initialized the coordinates with 'GAL_BLANK_SIZE_T'. When the
coordinate has already been measured already, it won't have this value
any more. */
if(coord[0]==GAL_BLANK_SIZE_T)
@@ -1736,21 +2174,25 @@ columns_xy_extrema(struct mkcatalog_passparams *pp,
size_t *coord, int key)
block->type),
block->ndim, block->dsize, coord);
- /* Return the proper value: note that `coord' is in C standard: starting
+ /* Return the proper value: note that 'coord' is in C standard: starting
from the slowest dimension and counting from zero. */
- switch(key)
- {
- case UI_KEY_MINX: return coord[ndim-1] + 1; break;
- case UI_KEY_MAXX: return coord[ndim-1] + tile->dsize[ndim-1]; break;
- case UI_KEY_MINY: return coord[ndim-2] + 1; break;
- case UI_KEY_MAXY: return coord[ndim-2] + tile->dsize[ndim-2]; break;
- case UI_KEY_MINZ: return coord[ndim-3] + 1; break;
- case UI_KEY_MAXZ: return coord[ndim-3] + tile->dsize[ndim-3]; break;
- default:
- error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
- "problem. The value %d is not a recognized value", __func__,
- PACKAGE_BUGREPORT, key);
- }
+ if(oi[OCOL_NUMALL])
+ switch(key)
+ {
+ case UI_KEY_MINX: return coord[ndim-1] + 1; break;
+ case UI_KEY_MAXX: return coord[ndim-1] + tile->dsize[ndim-1]; break;
+ case UI_KEY_MINY: return coord[ndim-2] + 1; break;
+ case UI_KEY_MAXY: return coord[ndim-2] + tile->dsize[ndim-2]; break;
+ case UI_KEY_MINZ: return coord[ndim-3] + 1; break;
+ case UI_KEY_MAXZ: return coord[ndim-3] + tile->dsize[ndim-3]; break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
+ "problem. The value %d is not a recognized value", __func__,
+ PACKAGE_BUGREPORT, key);
+ }
+ else
+ return 0;
+
/* Control should not reach here. */
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to fix the "
@@ -1766,28 +2208,28 @@ columns_xy_extrema(struct mkcatalog_passparams *pp,
size_t *coord, int key)
/* The magnitude error is directly derivable from the S/N:
To derive the error in measuring the magnitude from the S/N, let's take
- `F' as the flux, `Z' is the zeropoint, `M' is the magnitude, `S' is the
- S/N, and `D' to stand for capital delta (or error in a value) then from
+ 'F' as the flux, 'Z' is the zeropoint, 'M' is the magnitude, 'S' is the
+ S/N, and 'D' to stand for capital delta (or error in a value) then from
- `M = -2.5*log10(F) + Z'
+ 'M = -2.5*log10(F) + Z'
we get the following equation after calculating the derivative with
respect to F.
- `dM/df = -2.5 * ( 1 / ( F * ln(10) ) )'
+ 'dM/df = -2.5 * ( 1 / ( F * ln(10) ) )'
- From the Tailor series, `DM' can be written as:
+ From the Tailor series, 'DM' can be written as:
- `DM = dM/dF * DF'
+ 'DM = dM/dF * DF'
So
- `DM = |-2.5/ln(10)| * DF/F'
+ 'DM = |-2.5/ln(10)| * DF/F'
- But `DF/F' is just the inverse of the Signal to noise ratio, or
- `1/S'. So
+ But 'DF/F' is just the inverse of the Signal to noise ratio, or
+ '1/S'. So
- `DM = 2.5 / ( S * ln(10) )' */
+ 'DM = 2.5 / ( S * ln(10) )' */
#define MAG_ERROR(P,ROW,O0C1) ( 2.5f \
/ ( ( columns_sn((P),(ROW),(O0C1)) > 0 \
? columns_sn((P),(ROW),(O0C1)) \
@@ -1801,7 +2243,7 @@ columns_xy_extrema(struct mkcatalog_passparams *pp,
size_t *coord, int key)
/* All the raw first and second pass information has been collected, now
write them into the output columns. The list of columns here is in the
- same order as `columns_alloc_set_out_cols', see there for the type of
+ same order as 'columns_alloc_set_out_cols', see there for the type of
each column. */
#define POS_V_G(ARRAY, SUMWHT_COL, NUMALL_COL, V_COL, G_COL) \
( (ARRAY)[ SUMWHT_COL ]>0 \
@@ -1817,12 +2259,21 @@ columns_fill(struct mkcatalog_passparams *pp)
void *colarr;
gal_data_t *column;
double *ci, *oi=pp->oi;
+ size_t tmpind=GAL_BLANK_SIZE_T;
size_t coord[3]={GAL_BLANK_SIZE_T, GAL_BLANK_SIZE_T, GAL_BLANK_SIZE_T};
- size_t sr=pp->clumpstartindex, cind, coind;
- size_t oind=pp->object-1; /* IDs start from 1, indexs from 0. */
+ size_t i, cind, coind, sr=pp->clumpstartindex, oind=GAL_BLANK_SIZE_T;
double **vo=NULL, **vc=NULL, **go=NULL, **gc=NULL, **vcc=NULL, **gcc=NULL;
+ /* Find the object's index in final catalog. */
+ if(p->outlabs)
+ {
+ for(i=0;i<p->numobjects;++i)
+ if(p->outlabs[i]==pp->object)
+ { oind=i; break; }
+ }
+ else oind=pp->object-1;
+
/* If a WCS column is requested (check will be done inside the function),
then set the pointers. */
columns_set_wcs_pointers(p, &vo, &vc, &go, &gc, &vcc, &gcc);
@@ -1854,6 +2305,14 @@ columns_fill(struct mkcatalog_passparams *pp)
((int32_t *)colarr)[oind] = oi[OCOL_NUM];
break;
+ case UI_KEY_AREAARCSEC2:
+ ((float *)colarr)[oind] = oi[OCOL_NUM]*p->pixelarcsecsq;
+ break;
+
+ case UI_KEY_SURFACEBRIGHTNESS:
+ ((float *)colarr)[oind] = MKC_SB(oi[OCOL_SUM], oi[OCOL_NUM]);
+ break;
+
case UI_KEY_AREAXY:
((int32_t *)colarr)[oind] = oi[OCOL_NUMXY];
break;
@@ -1930,13 +2389,45 @@ columns_fill(struct mkcatalog_passparams *pp)
((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_C_GZ],
oi[OCOL_C_NUMALL] );
+ case UI_KEY_MINVX:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MINVX],
oi[OCOL_MINVNUM] );
+ break;
+
+ case UI_KEY_MAXVX:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MAXVX],
oi[OCOL_MAXVNUM] );
+ break;
+
+ case UI_KEY_MINVY:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MINVY],
oi[OCOL_MINVNUM] );
+ break;
+
+ case UI_KEY_MAXVY:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MAXVY],
oi[OCOL_MAXVNUM] );
+ break;
+
+ case UI_KEY_MINVZ:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MINVZ],
oi[OCOL_MINVNUM] );
+ break;
+
+ case UI_KEY_MAXVZ:
+ ((float *)colarr)[oind] = MKC_RATIO( oi[OCOL_MAXVZ],
oi[OCOL_MAXVNUM] );
+ break;
+
+ case UI_KEY_MINVNUM:
+ ((uint32_t *)colarr)[oind] = oi[OCOL_MINVNUM];
+ break;
+
+ case UI_KEY_MAXVNUM:
+ ((uint32_t *)colarr)[oind] = oi[OCOL_MAXVNUM];
+ break;
+
case UI_KEY_MINX:
case UI_KEY_MAXX:
case UI_KEY_MINY:
case UI_KEY_MAXY:
case UI_KEY_MINZ:
case UI_KEY_MAXZ:
- ((uint32_t *)colarr)[oind]=columns_xy_extrema(pp, coord, key);
+ ((uint32_t *)colarr)[oind]=columns_xy_extrema(pp, oi, coord, key);
break;
case UI_KEY_W1:
@@ -2011,6 +2502,26 @@ columns_fill(struct mkcatalog_passparams *pp)
: NAN );
break;
+ case UI_KEY_MAXIMUM:
+ ((float *)colarr)[oind] = oi[ OCOL_MAXIMUM ];
+ break;
+
+ case UI_KEY_SIGCLIPNUMBER:
+ ((int32_t *)colarr)[oind] = oi[ OCOL_SIGCLIPNUM ];
+ break;
+
+ case UI_KEY_SIGCLIPMEDIAN:
+ ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPMEDIAN ];
+ break;
+
+ case UI_KEY_SIGCLIPMEAN:
+ ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPMEAN ];
+ break;
+
+ case UI_KEY_SIGCLIPSTD:
+ ((float *)colarr)[oind] = oi[ OCOL_SIGCLIPSTD ];
+ break;
+
case UI_KEY_MAGNITUDE:
((float *)colarr)[oind] = ( oi[ OCOL_NUM ]>0.0f
? MKC_MAG(oi[ OCOL_SUM ])
@@ -2056,12 +2567,12 @@ columns_fill(struct mkcatalog_passparams *pp)
break;
case UI_KEY_SKY:
- ((float *)colarr)[oind] = MKC_RATIO(oi[OCOL_SUMSKY], oi[OCOL_NUM]);
+ ((float *)colarr)[oind] = MKC_RATIO(oi[OCOL_SUMSKY],
oi[OCOL_NUMSKY]);
break;
case UI_KEY_STD:
((float *)colarr)[oind] = sqrt( MKC_RATIO( oi[ OCOL_SUMVAR ],
- oi[ OCOL_NUM ]) );
+ oi[ OCOL_NUMVAR ]) );
break;
case UI_KEY_SEMIMAJOR:
@@ -2100,6 +2611,68 @@ columns_fill(struct mkcatalog_passparams *pp)
((float *)colarr)[oind] = columns_second_order(pp, oi, key, 0);
break;
+ case UI_KEY_HALFSUMAREA:
+ ((int32_t *)colarr)[oind] = oi[OCOL_HALFSUMNUM];
+ break;
+
+ case UI_KEY_HALFMAXAREA:
+ ((int32_t *)colarr)[oind] = oi[OCOL_HALFMAXNUM];
+ break;
+
+ case UI_KEY_HALFMAXSUM:
+ ((float *)colarr)[oind] = oi[OCOL_HALFMAXNUM];
+ break;
+
+ case UI_KEY_HALFMAXSB:
+ ((float *)colarr)[oind] = MKC_SB( oi[OCOL_HALFMAXSUM],
+ oi[OCOL_HALFMAXNUM] );
+ break;
+
+ case UI_KEY_FRACMAXSUM1:
+ ((float *)colarr)[oind] = oi[OCOL_FRACMAX1SUM];
+ break;
+
+ case UI_KEY_FRACMAXSUM2:
+ ((float *)colarr)[oind] = oi[OCOL_FRACMAX2SUM];
+ break;
+
+ case UI_KEY_FRACMAXAREA1:
+ ((int32_t *)colarr)[oind] = oi[OCOL_FRACMAX1NUM];
+ break;
+
+ case UI_KEY_FRACMAXAREA2:
+ ((int32_t *)colarr)[oind] = oi[OCOL_FRACMAX2NUM];
+ break;
+
+ case UI_KEY_HALFSUMSB:
+ ((float *)colarr)[oind] = MKC_SB( oi[OCOL_SUM]/2.0f,
+ oi[OCOL_HALFSUMNUM] );
+ break;
+
+ case UI_KEY_FWHM:
+ case UI_KEY_HALFMAXRADIUS:
+ case UI_KEY_HALFSUMRADIUS:
+ case UI_KEY_FRACMAXRADIUS1:
+ case UI_KEY_FRACMAXRADIUS2:
+ /* First derive the axis ratio (as 'tmp'), then set the index to
+ use and calculate the radius from the area and axis ratio. */
+ tmp = ( columns_second_order(pp, oi, UI_KEY_SEMIMINOR, 0)
+ / columns_second_order(pp, oi, UI_KEY_SEMIMAJOR, 0) );
+ switch(key)
+ {
+ case UI_KEY_FWHM: tmpind=OCOL_HALFMAXNUM; break;
+ case UI_KEY_HALFMAXRADIUS: tmpind=OCOL_HALFMAXNUM; break;
+ case UI_KEY_HALFSUMRADIUS: tmpind=OCOL_HALFSUMNUM; break;
+ case UI_KEY_FRACMAXRADIUS1: tmpind=OCOL_FRACMAX1NUM; break;
+ case UI_KEY_FRACMAXRADIUS2: tmpind=OCOL_FRACMAX2NUM; break;
+ }
+ tmp = sqrt( oi[tmpind]/(tmp*M_PI) );
+ if(key==UI_KEY_FWHM)
+ ((float *)colarr)[oind] = tmp<1e-6 ? NAN : (tmp*2);
+ else
+ ((float *)colarr)[oind] = tmp<1e-6 ? NAN : tmp;
+ break;
+
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
"solve the problem. the output column code %d not recognized "
@@ -2111,8 +2684,8 @@ columns_fill(struct mkcatalog_passparams *pp)
for(column=p->clumpcols; column!=NULL; column=column->next)
for(coind=0;coind<pp->clumpsinobj;++coind)
{
- /* `coind': clump-in-object-index.
- `cind': clump-index (over all the catalog). */
+ /* 'coind': clump-in-object-index.
+ 'cind': clump-index (over all the catalog). */
cind = sr + coind;
colarr = column->array;
key = column->status;
@@ -2138,6 +2711,14 @@ columns_fill(struct mkcatalog_passparams *pp)
((int32_t *)colarr)[cind]=ci[CCOL_NUM];
break;
+ case UI_KEY_AREAARCSEC2:
+ ((float *)colarr)[cind]=ci[CCOL_NUM]*p->pixelarcsecsq;
+ break;
+
+ case UI_KEY_SURFACEBRIGHTNESS:
+ ((float *)colarr)[cind]=MKC_SB(ci[CCOL_SUM], ci[CCOL_NUM]);
+ break;
+
case UI_KEY_AREAXY:
((int32_t *)colarr)[cind]=ci[CCOL_NUMXY];
break;
@@ -2183,30 +2764,45 @@ columns_fill(struct mkcatalog_passparams *pp)
((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_GZ],
ci[CCOL_NUMALL] );
- case UI_KEY_MINX:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MINX];
+ case UI_KEY_MINVX:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MINVX],
ci[CCOL_MINVNUM] );
break;
- case UI_KEY_MAXX:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MAXX];
+ case UI_KEY_MAXVX:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MAXVX],
ci[CCOL_MAXVNUM] );
break;
- case UI_KEY_MINY:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MINY];
+ case UI_KEY_MINVY:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MINVY],
ci[CCOL_MINVNUM] );
break;
- case UI_KEY_MAXY:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MAXY];
+ case UI_KEY_MAXVY:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MAXVY],
ci[CCOL_MAXVNUM] );
break;
- case UI_KEY_MINZ:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MINZ];
+ case UI_KEY_MINVZ:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MINVZ],
ci[CCOL_MINVNUM] );
break;
- case UI_KEY_MAXZ:
- ((uint32_t *)colarr)[cind] = ci[CCOL_MAXZ];
+ case UI_KEY_MAXVZ:
+ ((float *)colarr)[cind] = MKC_RATIO( ci[CCOL_MAXVZ],
ci[CCOL_MAXVNUM] );
break;
+ case UI_KEY_MINVNUM:
+ ((uint32_t *)colarr)[cind] = ci[CCOL_MINVNUM];
+ break;
+
+ case UI_KEY_MAXVNUM:
+ ((uint32_t *)colarr)[cind] = ci[CCOL_MAXVNUM];
+ break;
+
+ case UI_KEY_MINX: ((uint32_t *)colarr)[cind] = ci[CCOL_MINX];
break;
+ case UI_KEY_MAXX: ((uint32_t *)colarr)[cind] = ci[CCOL_MAXX];
break;
+ case UI_KEY_MINY: ((uint32_t *)colarr)[cind] = ci[CCOL_MINY];
break;
+ case UI_KEY_MAXY: ((uint32_t *)colarr)[cind] = ci[CCOL_MAXY];
break;
+ case UI_KEY_MINZ: ((uint32_t *)colarr)[cind] = ci[CCOL_MINZ];
break;
+ case UI_KEY_MAXZ: ((uint32_t *)colarr)[cind] = ci[CCOL_MAXZ];
break;
+
case UI_KEY_W1:
case UI_KEY_W2:
case UI_KEY_W3:
@@ -2253,6 +2849,26 @@ columns_fill(struct mkcatalog_passparams *pp)
? ci[ CCOL_MEDIAN ] : NAN );
break;
+ case UI_KEY_MAXIMUM:
+ ((float *)colarr)[cind] = ci[ CCOL_MAXIMUM ];
+ break;
+
+ case UI_KEY_SIGCLIPNUMBER:
+ ((int32_t *)colarr)[cind] = ci[ CCOL_SIGCLIPNUM ];
+ break;
+
+ case UI_KEY_SIGCLIPMEDIAN:
+ ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPMEDIAN ];
+ break;
+
+ case UI_KEY_SIGCLIPMEAN:
+ ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPMEAN ];
+ break;
+
+ case UI_KEY_SIGCLIPSTD:
+ ((float *)colarr)[cind] = ci[ CCOL_SIGCLIPSTD ];
+ break;
+
case UI_KEY_MAGNITUDE: /* Similar: brightness for clumps */
tmp = ( ci[ CCOL_RIV_NUM ]
? ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]*ci[ CCOL_NUM ]
@@ -2305,12 +2921,12 @@ columns_fill(struct mkcatalog_passparams *pp)
case UI_KEY_SKY:
((float *)colarr)[cind] = MKC_RATIO( ci[ CCOL_SUMSKY],
- ci[ CCOL_NUM] );
+ ci[ CCOL_NUMSKY] );
break;
case UI_KEY_STD:
((float *)colarr)[cind] = sqrt( MKC_RATIO( ci[ CCOL_SUMVAR ],
- ci[ CCOL_NUM ] ));
+ ci[ CCOL_NUMVAR ] ));
break;
case UI_KEY_SEMIMAJOR:
@@ -2349,6 +2965,66 @@ columns_fill(struct mkcatalog_passparams *pp)
((float *)colarr)[cind] = columns_second_order(pp, ci, key, 1);
break;
+ case UI_KEY_HALFSUMAREA:
+ ((int32_t *)colarr)[cind] = ci[CCOL_HALFSUMNUM];
+ break;
+
+ case UI_KEY_HALFMAXAREA:
+ ((int32_t *)colarr)[cind] = ci[CCOL_HALFMAXNUM];
+ break;
+
+ case UI_KEY_HALFMAXSUM:
+ ((float *)colarr)[cind] = ci[CCOL_HALFMAXSUM];
+ break;
+
+ case UI_KEY_HALFMAXSB:
+ ((float *)colarr)[cind] = MKC_SB( ci[CCOL_HALFMAXSUM],
+ ci[CCOL_HALFMAXNUM] );
+ break;
+
+ case UI_KEY_FRACMAXSUM1:
+ ((int32_t *)colarr)[cind] = ci[CCOL_FRACMAX1SUM];
+ break;
+
+ case UI_KEY_FRACMAXSUM2:
+ ((int32_t *)colarr)[cind] = ci[CCOL_FRACMAX2SUM];
+ break;
+
+ case UI_KEY_FRACMAXAREA1:
+ ((int32_t *)colarr)[cind] = ci[CCOL_FRACMAX1NUM];
+ break;
+
+ case UI_KEY_FRACMAXAREA2:
+ ((int32_t *)colarr)[cind] = ci[CCOL_FRACMAX2NUM];
+ break;
+
+ case UI_KEY_HALFSUMSB:
+ ((float *)colarr)[cind] = MKC_SB( ci[CCOL_SUM]/2.0f,
+ ci[CCOL_HALFSUMNUM] );
+ break;
+
+ case UI_KEY_FWHM:
+ case UI_KEY_HALFMAXRADIUS:
+ case UI_KEY_HALFSUMRADIUS:
+ case UI_KEY_FRACMAXRADIUS1:
+ case UI_KEY_FRACMAXRADIUS2:
+ tmp = ( columns_second_order( pp, ci, UI_KEY_SEMIMINOR, 1)
+ / columns_second_order(pp, ci, UI_KEY_SEMIMAJOR, 1) );
+ switch(key)
+ {
+ case UI_KEY_FWHM: tmpind=CCOL_HALFMAXNUM; break;
+ case UI_KEY_HALFMAXRADIUS: tmpind=CCOL_HALFMAXNUM; break;
+ case UI_KEY_HALFSUMRADIUS: tmpind=CCOL_HALFSUMNUM; break;
+ case UI_KEY_FRACMAXRADIUS1: tmpind=CCOL_FRACMAX1NUM; break;
+ case UI_KEY_FRACMAXRADIUS2: tmpind=CCOL_FRACMAX2NUM; break;
+ }
+ tmp = sqrt( ci[tmpind]/(tmp*M_PI) );
+ if(key==UI_KEY_FWHM)
+ ((float *)colarr)[cind] = tmp<1e-6 ? NAN : (tmp*2);
+ else
+ ((float *)colarr)[cind] = tmp<1e-6 ? NAN : tmp;
+ break;
+
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
"solve the problem. The output column code %d not "
diff --git a/bin/mkcatalog/columns.h b/bin/mkcatalog/columns.h
index 723cd7c..6f65d8f 100644
--- a/bin/mkcatalog/columns.h
+++ b/bin/mkcatalog/columns.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkcatalog/main.c b/bin/mkcatalog/main.c
index c24fb2d..c244333 100644
--- a/bin/mkcatalog/main.c
+++ b/bin/mkcatalog/main.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkcatalog/main.h b/bin/mkcatalog/main.h
index 00eba86..11d7ff4 100644
--- a/bin/mkcatalog/main.h
+++ b/bin/mkcatalog/main.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -70,21 +70,36 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
the FITS standard (fastest dimension is first). */
enum objectcols
{
- OCOL_NUMALL, /* Number of all pixels with this label. */
- OCOL_NUMALLXY, /* Number of all pixels in first two dims. */
- OCOL_NUM, /* Number of values used in this object. */
+ OCOL_NUMALL, /* Area/number of all pixels with this label.*/
+ OCOL_NUMALLXY, /* Area/Number in first two dimensions. */
+ OCOL_NUM, /* Area/Number of values used in this object.*/
OCOL_NUMXY, /* Number of values in the first two dims. */
OCOL_SUM, /* Sum of (value-sky) in object. */
- OCOL_SUM_VAR, /* Varience of sum (for brightness error). */
- OCOL_MEDIAN, /* Median of value in object. */
+ OCOL_SUM_VAR, /* Variance including values (not just sky). */
+ OCOL_MEDIAN, /* Median of values in object. */
+ OCOL_MAXIMUM, /* Maximum value in object. */
+ OCOL_SIGCLIPNUM, /* Sigma-clipped mean of this object. */
+ OCOL_SIGCLIPSTD, /* Sigma-clipped mean of this object. */
+ OCOL_SIGCLIPMEAN, /* Sigma-clipped mean of this object. */
+ OCOL_SIGCLIPMEDIAN, /* Sigma-clipped mean of this object. */
OCOL_VX, /* Sum of (value-sky) * x. */
OCOL_VY, /* Sum of (value-sky) * y. */
OCOL_VZ, /* Sum of (value-sky) * z. */
OCOL_VXX, /* Sum of (value-sky) * x * x. */
OCOL_VYY, /* Sum of (value-sky) * y * y. */
OCOL_VXY, /* Sum of (value-sky) * x * y. */
+ OCOL_MINVX, /* X of minimum pixel in values file. */
+ OCOL_MAXVX, /* X of maximum pixel in values file. */
+ OCOL_MINVY, /* Y of minimum pixel in values file. */
+ OCOL_MAXVY, /* Y of maximum pixel in values file. */
+ OCOL_MINVZ, /* Z of minimum pixel in values file. */
+ OCOL_MAXVZ, /* Z of maximum pixel in values file. */
+ OCOL_MINVNUM, /* Number of pixels with minimum value. */
+ OCOL_MAXVNUM, /* Number of pixels with maximum value. */
OCOL_SUMSKY, /* Sum of sky value on this object. */
+ OCOL_NUMSKY, /* Number of sky value on this object. */
OCOL_SUMVAR, /* Sum of sky variance value on this object. */
+ OCOL_NUMVAR, /* Number of sky value on this object. */
OCOL_SUMWHT, /* Sum of positive image pixels. */
OCOL_NUMWHT, /* Number of positive pixels used for wht. */
OCOL_GX, /* Geometric center of object in X. */
@@ -97,6 +112,13 @@ enum objectcols
OCOL_UPPERLIMIT_S, /* Upper limit one-sigma value. */
OCOL_UPPERLIMIT_Q, /* Quantile of object in random distribution.*/
OCOL_UPPERLIMIT_SKEW,/* (Mean-Median)/STD of random distribution. */
+ OCOL_HALFMAXNUM, /* Area/Number of pixels above half of max. */
+ OCOL_HALFMAXSUM, /* Sum of pixels above half of max. */
+ OCOL_HALFSUMNUM, /* Area/Number containing half of total sum. */
+ OCOL_FRACMAX1NUM, /* Area/Number containing frac of maximum. */
+ OCOL_FRACMAX1SUM, /* Sum containing frac of maximum. */
+ OCOL_FRACMAX2NUM, /* Area/Number containing frac of maximum. */
+ OCOL_FRACMAX2SUM, /* Sum containing frac of maximum. */
OCOL_C_NUMALL, /* Value independent no. of pixels in clumps.*/
OCOL_C_NUM, /* Area of clumps in this object. */
OCOL_C_SUM, /* Brightness in object clumps. */
@@ -119,8 +141,13 @@ enum clumpcols
CCOL_NUM, /* Number of values used in clump. */
CCOL_NUMXY, /* Number of values only in first two dims. */
CCOL_SUM, /* River subtracted brightness. */
- CCOL_SUM_VAR, /* Variance of sum (for brightness error). */
+ CCOL_SUM_VAR, /* Variance including values (not just sky). */
CCOL_MEDIAN, /* Median of values in clump. */
+ CCOL_MAXIMUM, /* Maximum value in clump. */
+ CCOL_SIGCLIPNUM, /* Sigma-clipped mean of this clump. */
+ CCOL_SIGCLIPSTD, /* Sigma-clipped mean of this clump. */
+ CCOL_SIGCLIPMEAN, /* Sigma-clipped mean of this clump. */
+ CCOL_SIGCLIPMEDIAN, /* Sigma-clipped mean of this clump. */
CCOL_RIV_NUM, /* Num river pixels around this clump. */
CCOL_RIV_SUM, /* Sum of rivers around clump. */
CCOL_RIV_SUM_VAR, /* Variance of sum (for error measurements). */
@@ -130,8 +157,18 @@ enum clumpcols
CCOL_VXX, /* Sum of flux*x*x of this clump. */
CCOL_VYY, /* Sum of flux*y*y of this clump. */
CCOL_VXY, /* Sum of flux*x*y of this clump. */
- CCOL_SUMSKY, /* Sum of sky value on this object. */
- CCOL_SUMVAR, /* Sum of sky variance value on this object. */
+ CCOL_MINVX, /* X of minimum pixel in values array. */
+ CCOL_MAXVX, /* X of maximum pixel in values array. */
+ CCOL_MINVY, /* Y of minimum pixel in values array. */
+ CCOL_MAXVY, /* Y of maximum pixel in values array. */
+ CCOL_MINVZ, /* Z of minimum pixel in values array. */
+ CCOL_MAXVZ, /* Z of maximum pixel in values array. */
+ CCOL_MINVNUM, /* Number of pixels with minimum value. */
+ CCOL_MAXVNUM, /* Number of pixels with maximum value. */
+ CCOL_SUMSKY, /* Sum of sky value on this clump. */
+ CCOL_NUMSKY, /* Number of sky value on this clump. */
+ CCOL_SUMVAR, /* Sum of sky variance value on this clump. */
+ CCOL_NUMVAR, /* Number of sky variance value on this clump.*/
CCOL_SUMWHT, /* Sum of positive image pixels for wht. */
CCOL_NUMWHT, /* Num of positive image pixels for wht. */
CCOL_GX, /* Geometric center of clump in X. */
@@ -150,6 +187,13 @@ enum clumpcols
CCOL_UPPERLIMIT_S, /* Upper limit one-sigma value. */
CCOL_UPPERLIMIT_Q, /* Quantile of object in random distribution.*/
CCOL_UPPERLIMIT_SKEW,/* (Mean-Median)/STD of random distribution. */
+ CCOL_HALFMAXNUM, /* Area/Number of pixels above half of max. */
+ CCOL_HALFMAXSUM, /* Sum of pixels above half of max. */
+ CCOL_HALFSUMNUM, /* Area/Number containing half of total sum. */
+ CCOL_FRACMAX1NUM, /* Area/Number containing frac of maximum. */
+ CCOL_FRACMAX1SUM, /* Sum containing frac of maximum. */
+ CCOL_FRACMAX2NUM, /* Area/Number containing frac of maximum. */
+ CCOL_FRACMAX2SUM, /* Sum containing frac of maximum. */
CCOL_NUMCOLS, /* SHOULD BE LAST: total number of columns. */
};
@@ -180,10 +224,13 @@ struct mkcatalogparams
uint8_t noclumpsort; /* Don't sort the clumps catalog. */
float zeropoint; /* Zero-point magnitude of object. */
uint8_t variance; /* Input STD file is actually variance. */
+ uint8_t forcereadstd; /* Read STD even if not needed. */
uint8_t subtractsky; /* ==1: subtract the Sky from values. */
float sfmagnsigma; /* Surface brightness multiple of sigma.*/
float sfmagarea; /* Surface brightness area (arcsec^2). */
uint8_t spectrum; /* Object spectrum for 3D datasets. */
+ uint8_t inbetweenints; /* Keep rows (integer ids) with no labels. */
+ double sigmaclip[2]; /* Sigma clip column settings. */
char *upmaskfile; /* Name of upper limit mask file. */
char *upmaskhdu; /* HDU of upper limit mask file. */
@@ -194,6 +241,8 @@ struct mkcatalogparams
float upnsigma; /* Multiple of sigma to define up-lim. */
int32_t checkuplim[2]; /* Object & clump ID to check dist. */
+ gal_data_t *fracmax; /* Fractions to use in --fracsumarea. */
+
/* Internal. */
char *relabclumps; /* Name of new file for clump labels. */
time_t rawtime; /* Starting time of the program. */
@@ -205,6 +254,8 @@ struct mkcatalogparams
gal_data_t *upmask; /* Upper limit magnitude mask. */
float medstd; /* Median standard deviation value. */
float cpscorr; /* Counts-per-second correction. */
+ int32_t *outlabs; /* Labels in output catalog (when necessary) */
+ int32_t *outlabsinv; /* Inverse of the 'outlabs' array. */
size_t numobjects; /* Number of object labels in image. */
float clumpsn; /* Clump S/N threshold. */
size_t numclumps; /* Number of clumps in image. */
@@ -228,6 +279,7 @@ struct mkcatalogparams
size_t *numclumps_c; /* To sort the clumps table by Obj.ID. */
gal_data_t *specsliceinfo; /* Slice information for spectra. */
gal_data_t *spectra; /* Array of datasets containing spectra.*/
+ double pixelarcsecsq; /* Area of input's pixels in arcsec^2. */
char *usedvaluesfile; /* Ptr to final name used for values. */
char *usedclumpsfile; /* Ptr to final name used for clumps. */
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index 5d12634..e3e75b7 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -134,22 +134,23 @@ mkcatalog_single_object(void *in_prm)
NULL, NULL, NULL);
/* Set the blank checked flag to 1. By definition, this dataset won't
- have any blank values. Also `flag' is initialized to `0'. So we
- just have to set the checked flag (`GAL_DATA_FLAG_BLANK_CH') to
+ have any blank values. Also 'flag' is initialized to '0'. So we
+ just have to set the checked flag ('GAL_DATA_FLAG_BLANK_CH') to
one to inform later steps that there are no blank values. */
pp.up_vals->flag |= GAL_DATA_FLAG_BLANK_CH;
}
else
pp.up_vals=NULL;
-
/* Fill the desired columns for all the objects given to this thread. */
for(i=0; tprm->indexs[i]!=GAL_BLANK_SIZE_T; ++i)
{
/* For easy reading. Note that the object IDs start from one while
the array positions start from 0. */
pp.ci = NULL;
- pp.object = tprm->indexs[i] + 1;
+ pp.object = ( p->outlabs
+ ? p->outlabs[ tprm->indexs[i] ]
+ : tprm->indexs[i] + 1 );
pp.tile = &p->tiles[ tprm->indexs[i] ];
pp.spectrum = &p->spectra[ tprm->indexs[i] ];
@@ -177,9 +178,20 @@ mkcatalog_single_object(void *in_prm)
parse_clumps(&pp);
}
- /* If the median is requested, another pass is necessary. */
- if( p->oiflag[ OCOL_MEDIAN ] )
- parse_median(&pp);
+ /* If an order-based calculation is requested, another pass is
+ necessary. */
+ if( p->oiflag[ OCOL_MEDIAN ]
+ || p->oiflag[ OCOL_MAXIMUM ]
+ || p->oiflag[ OCOL_HALFMAXSUM ]
+ || p->oiflag[ OCOL_HALFMAXNUM ]
+ || p->oiflag[ OCOL_HALFSUMNUM ]
+ || p->oiflag[ OCOL_SIGCLIPNUM ]
+ || p->oiflag[ OCOL_SIGCLIPSTD ]
+ || p->oiflag[ OCOL_SIGCLIPMEAN ]
+ || p->oiflag[ OCOL_FRACMAX1NUM ]
+ || p->oiflag[ OCOL_FRACMAX2NUM ]
+ || p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+ parse_order_based(&pp);
/* Calculate the upper limit magnitude (if necessary). */
if(p->upperlimit) upperlimit_calculate(&pp);
@@ -268,8 +280,8 @@ mkcatalog_wcs_conversion(struct mkcatalogparams *p)
/* Definitions */
c=NULL;
- /* Set `c' for the columns that must be corrected. Note that this
- `switch' statement doesn't need any `default', because there are
+ /* Set 'c' for the columns that must be corrected. Note that this
+ 'switch' statement doesn't need any 'default', because there are
probably columns that don't need any correction. */
switch(column->status)
{
@@ -300,8 +312,8 @@ mkcatalog_wcs_conversion(struct mkcatalogparams *p)
/* Definitions */
c=NULL;
- /* Set `c' for the columns that must be corrected. Note that this
- `switch' statement doesn't need any `default', because there are
+ /* Set 'c' for the columns that must be corrected. Note that this
+ 'switch' statement doesn't need any 'default', because there are
probably columns that don't need any correction. */
switch(column->status)
{
@@ -435,7 +447,7 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p, int
o0c1,
gal_list_str_add(&comments, str, 0);
}
- /* Write the date. However, `ctime' is going to put a new-line character
+ /* Write the date. However, 'ctime' is going to put a new-line character
in the end of its string, so we are going to remove it manually. */
if( asprintf(&str, "%s started on %s", PROGRAM_NAME, ctime(&p->rawtime))<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
@@ -447,14 +459,15 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p,
int o0c1,
mkcatalog_write_inputs_in_comments(p, &comments, 1, 1);
- /* Write other supplimentary information. */
+ /* Write other supplementary information. */
if(p->cp.tableformat==GAL_TABLE_FORMAT_TXT)
{
- if( asprintf(&str, "--------- Supplimentary information ---------")<0 )
+ if( asprintf(&str, "--------- Supplementary information ---------")<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_list_str_add(&comments, str, 0);
}
+ /* Pixel area. */
if(p->objects->wcs)
{
pixarea=gal_wcs_pixel_area_arcsec2(p->objects->wcs);
@@ -466,6 +479,7 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p, int
o0c1,
}
}
+ /* Zeropoint magnitude */
if(p->hasmag)
{
if( asprintf(&str, "Zeropoint magnitude: %.4f", p->zeropoint)<0 )
@@ -474,49 +488,53 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p,
int o0c1,
}
/* Print surface brightness limits. */
- if( !isnan(p->medstd) && !isnan(p->zeropoint) && !isnan(p->sfmagnsigma) )
+ if( !isnan(p->medstd) && !isnan(p->sfmagnsigma) )
{
- /* Per pixel. */
- if( asprintf(&str, "%g sigma surface brightness (magnitude/pixel): "
- "%.3f", p->sfmagnsigma, ( -2.5f
- *log10( p->sfmagnsigma
- * p->medstd )
- + p->zeropoint ) )<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- gal_list_str_add(&comments, str, 0);
-
- /* Requested projected area: if a pixel area could be measured (a WCS
- was given), then also estimate the surface brightness over one
- arcsecond^2. From the pixel area, we know how many pixels are
- necessary to fill the requested projected area (in
- arcsecond^2). We also know that as the number of samples (pixels)
- increases (to N), the noise increases by sqrt(N), see the full
- discussion in the book. */
- if(!isnan(pixarea) && !isnan(p->sfmagarea))
+ /* Only print magnitudes if a zeropoint is given. */
+ if( !isnan(p->zeropoint) )
{
- /* Prepare the comment/information. */
- if(p->sfmagarea==1.0f)
- tstr=NULL;
- else
- if( asprintf(&tstr, "%g-", p->sfmagarea)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- if( asprintf(&str, "%g sigma surface brightness "
- "(magnitude/%sarcsec^2): %.3f", p->sfmagnsigma,
- tstr ? tstr : "",
- ( -2.5f * log10( p->sfmagnsigma
- * p->medstd
- * sqrt( p->sfmagarea / pixarea) )
- + p->zeropoint ) )<0 )
+ /* Per pixel. */
+ if( asprintf(&str, "%g sigma surface brightness (magnitude/pixel): "
+ "%.3f", p->sfmagnsigma, ( -2.5f
+ *log10( p->sfmagnsigma
+ * p->medstd )
+ + p->zeropoint ) )<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
-
- /* Add the final string/line to the catalog comments. */
gal_list_str_add(&comments, str, 0);
- /* Clean up (if necessary). */
- if (tstr)
+ /* Requested projected area: if a pixel area could be measured (a
+ WCS was given), then also estimate the surface brightness over
+ one arcsecond^2. From the pixel area, we know how many pixels
+ are necessary to fill the requested projected area (in
+ arcsecond^2). We also know that as the number of samples
+ (pixels) increases (to N), the noise increases by sqrt(N), see
+ the full discussion in the book. */
+ if(!isnan(pixarea) && !isnan(p->sfmagarea))
{
- free(tstr);
- tstr=NULL;
+ /* Prepare the comment/information. */
+ if(p->sfmagarea==1.0f)
+ tstr=NULL;
+ else
+ if( asprintf(&tstr, "%g-", p->sfmagarea)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ if( asprintf(&str, "%g sigma surface brightness "
+ "(magnitude/%sarcsec^2): %.3f", p->sfmagnsigma,
+ tstr ? tstr : "",
+ ( -2.5f * log10( p->sfmagnsigma
+ * p->medstd
+ * sqrt( p->sfmagarea / pixarea) )
+ + p->zeropoint ) )<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+
+ /* Add the final string/line to the catalog comments. */
+ gal_list_str_add(&comments, str, 0);
+
+ /* Clean up (if necessary). */
+ if (tstr)
+ {
+ free(tstr);
+ tstr=NULL;
+ }
}
}
@@ -527,7 +545,17 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p,
int o0c1,
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_list_str_add(&comments, str, 0);
}
+ else
+ {
+ gal_checkset_allocate_copy("No surface brightness calcuations "
+ "because no STD image used.", &str);
+ gal_list_str_add(&comments, str, 0);
+ gal_checkset_allocate_copy("Ask for column that uses the STD image, "
+ "or '--forcereadstd'.", &str);
+ gal_list_str_add(&comments, str, 0);
+ }
+ /* The count-per-second correction. */
if(p->cpscorr>1.0f)
{
if( asprintf(&str, "Counts-per-second correction: %.3f", p->cpscorr)<0 )
@@ -535,11 +563,11 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p,
int o0c1,
gal_list_str_add(&comments, str, 0);
}
+ /* Print upper-limit parameters. */
if(p->upperlimit)
upperlimit_write_comments(p, &comments, 1);
-
-
+ /* Start column metadata. */
if(p->cp.tableformat==GAL_TABLE_FORMAT_TXT)
{
if( asprintf(&str, "--------- Table columns ---------")<0 )
@@ -569,7 +597,7 @@ sort_clumps_by_objid(struct mkcatalogparams *p)
/* Make sure everything is fine. */
if(p->hostobjid_c==NULL || p->numclumps_c==NULL)
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix the "
- "problem. `p->hostobjid_c' and `p->numclumps_c' must not be "
+ "problem. 'p->hostobjid_c' and 'p->numclumps_c' must not be "
"NULL.", __func__, PACKAGE_BUGREPORT);
@@ -592,7 +620,9 @@ sort_clumps_by_objid(struct mkcatalogparams *p)
i=0;
while(i<p->numclumps)
{
- o=p->hostobjid_c[i]-1;
+ o = ( p->outlabsinv
+ ? (p->outlabsinv[ p->hostobjid_c[i] ] + 1)
+ : p->hostobjid_c[i] ) - 1;
for(j=0; j<p->numclumps_c[o]; ++j)
permute[i++] = rowstart[o] + j;
}
@@ -628,7 +658,7 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
/* Reverse the comments list (so it is printed in the same order
here), write the objects catalog and free the comments. */
gal_list_str_reverse(&comments);
- gal_table_write(p->objectcols, comments, p->cp.tableformat,
+ gal_table_write(p->objectcols, NULL, comments, p->cp.tableformat,
p->objectsout, "OBJECTS", 0);
gal_list_str_free(comments, 1);
@@ -645,7 +675,7 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
Reverse the comments list (so it is printed in the same order
here), write the objects catalog and free the comments. */
gal_list_str_reverse(&comments);
- gal_table_write(p->clumpcols, comments, p->cp.tableformat,
+ gal_table_write(p->clumpcols, NULL, comments, p->cp.tableformat,
p->clumpsout, "CLUMPS", 0);
gal_list_str_free(comments, 1);
}
@@ -660,7 +690,7 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
printf(" - Catalog(s) complete, writing spectra.\n");
/* Start counting and writing the files. Note that due to some
- conditions (for example in debugging), a `p->spectra[i]' may not
+ conditions (for example in debugging), a 'p->spectra[i]' may not
actually contain any data. So we'll also count the number of
spectra that are written. */
scounter=0;
@@ -675,7 +705,8 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
{
/* Write the table. */
sprintf(str, "SPECTRUM_%zu", i+1);
- gal_table_write(&p->spectra[i], NULL, GAL_TABLE_FORMAT_BFITS,
+ gal_table_write(&p->spectra[i], NULL, NULL,
+ GAL_TABLE_FORMAT_BFITS,
p->objectsout, str, 0);
}
else
@@ -683,7 +714,7 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
sprintf(str, "-spec-%zu.txt", i+1);
fname=gal_checkset_automatic_output(&p->cp, p->objectsout,
str);
- gal_table_write(&p->spectra[i], NULL, GAL_TABLE_FORMAT_TXT,
+ gal_table_write(&p->spectra[i], NULL, NULL,
GAL_TABLE_FORMAT_TXT,
fname, NULL, 0);
free(fname);
}
@@ -720,14 +751,14 @@ mkcatalog_write_outputs(struct mkcatalogparams *p)
if(outisfits)
{
if(p->objectcols)
- printf(" - Spectra in %zu extensions named `SPECTRUM_NN'.\n",
+ printf(" - Spectra in %zu extensions named 'SPECTRUM_NN'.\n",
p->numobjects);
else
printf(" - Output: %s (Spectra in %zu extensions named "
- "`SPECTRUM_NN').\n)", p->objectsout, p->numobjects);
+ "'SPECTRUM_NN').\n)", p->objectsout, p->numobjects);
}
else
- printf(" - Spectra in %zu files with `-spec-NN.txt' suffix.\n",
+ printf(" - Spectra in %zu files with '-spec-NN.txt' suffix.\n",
p->numobjects);
}
}
@@ -764,7 +795,8 @@ mkcatalog(struct mkcatalogparams *p)
/* Do the processing on each thread. */
gal_threads_spin_off(mkcatalog_single_object, p, p->numobjects,
- p->cp.numthreads);
+ p->cp.numthreads, p->cp.minmapsize,
+ p->cp.quietmmap);
/* Post-thread processing, for example to convert image coordinates to RA
and Dec. */
diff --git a/bin/mkcatalog/mkcatalog.h b/bin/mkcatalog/mkcatalog.h
index 730274b..9cbdbd8 100644
--- a/bin/mkcatalog/mkcatalog.h
+++ b/bin/mkcatalog/mkcatalog.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkcatalog/parse.c b/bin/mkcatalog/parse.c
index 1229de9..375d72c 100644
--- a/bin/mkcatalog/parse.c
+++ b/bin/mkcatalog/parse.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2018-2019, Free Software Foundation, Inc.
+Copyright (C) 2018-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -169,7 +169,7 @@ parse_spectrum_pepare(struct mkcatalog_passparams *pp,
size_t *start_end_inc,
p->values->unit, "Error in SUM_OTHER column.");
/* Fill up the contents of the first element (note that the first
- `gal_data_t' is actually in an array, so the skeleton is already
+ 'gal_data_t' is actually in an array, so the skeleton is already
allocated, we just have to allocate its contents. */
gal_data_initialize(pp->spectrum, NULL, p->specsliceinfo->type, 1,
&numslices, NULL, 0, p->cp.minmapsize,
@@ -252,8 +252,8 @@ parse_spectrum_end(struct mkcatalog_passparams *pp,
gal_data_t *xybin)
osearr[i] = sqrt( osearr[i] );
}
- /* Convert the `double' type columns to `float'. The extra precision of
- `double' was necessary when we were summing values in each slice. But
+ /* Convert the 'double' type columns to 'float'. The extra precision of
+ 'double' was necessary when we were summing values in each slice. But
afterwards, it is not necessary at all (the measurement error is much
larger than a double-precision floating point number (15
decimals). But the extra space gained (double) is very useful in not
@@ -271,7 +271,7 @@ parse_spectrum_end(struct mkcatalog_passparams *pp,
gal_data_t *xybin)
parse_spectrum_uint32_to_best_type(&oarea);
/* List the datasets and write them into the pointer for this object
- (exact copy of the statement in `parse_spectrum_pepare'). */
+ (exact copy of the statement in 'parse_spectrum_pepare'). */
pp->spectrum->next->next = area;
area->next = sum;
area->next->next = esum;
@@ -325,14 +325,14 @@ parse_spectrum(struct mkcatalog_passparams *pp,
gal_data_t *xybin)
osarr = area->next->next->next->next->next->next->array;
osearr = area->next->next->next->next->next->next->next->array;
- /* If tile-id isn't necessary, set `tid' to a blank value. */
+ /* If tile-id isn't necessary, set 'tid' to a blank value. */
tid = (p->std && p->std->size>1 && st_std == NULL) ? 0 : GAL_BLANK_SIZE_T;
/* Parse each contiguous patch of memory covered by this object. */
while( start_end_inc[0] + increment <= start_end_inc[1] )
{
/* Set the contiguous range to parse. The pixel-to-pixel counting
- along the fastest dimension will be done over the `O' pointer. */
+ along the fastest dimension will be done over the 'O' pointer. */
if( p->values ) V = st_v + increment;
if( p->std && st_std ) ST = st_std + increment;
OO = ( O = st_o + increment ) + pp->tile->dsize[ndim-1];
@@ -357,7 +357,7 @@ parse_spectrum(struct mkcatalog_passparams *pp, gal_data_t
*xybin)
/* Get the error associated with this voxel. Note that if
we are given a variance dataset already, there is no
- need to use `st*st', we can directly use `sval'. */
+ need to use 'st*st', we can directly use 'sval'. */
sval = st_std ? *ST : (p->std->size>1?std[tid]:std[0]);
st = p->variance ? sqrt(sval) : sval;
var = (p->variance ? sval : st*st) + fabs(*V);
@@ -365,8 +365,8 @@ parse_spectrum(struct mkcatalog_passparams *pp, gal_data_t
*xybin)
else var = NAN;
- /* Projected spectra: see if we have a value of `2' in the
- `xybin' array (showing that there is atleast one non-blank
+ /* Projected spectra: see if we have a value of '2' in the
+ 'xybin' array (showing that there is atleast one non-blank
element there over the whole spectrum. */
++nproj;
parr [ sind ] += *V;
@@ -402,8 +402,8 @@ parse_spectrum(struct mkcatalog_passparams *pp, gal_data_t
*xybin)
increment += ( gal_tile_block_increment(p->objects, tsize,
num_increment++, NULL) );
- /* Increment the slice number, `sind', and reset the projection (2D)
- index `pind' if we have just finished parsing a slice. */
+ /* Increment the slice number, 'sind', and reset the projection (2D)
+ index 'pind' if we have just finished parsing a slice. */
if( (num_increment-1)%pp->tile->dsize[1]==0 )
{
/* If there was no measurement, set NaN for the values and their
@@ -422,7 +422,7 @@ parse_spectrum(struct mkcatalog_passparams *pp, gal_data_t
*xybin)
free(tsize);
/* For a check.
- gal_table_write(pp->spectrum, NULL, GAL_TABLE_FORMAT_BFITS,
+ gal_table_write(pp->spectrum, NULL, NULL, GAL_TABLE_FORMAT_BFITS,
"spectrum.fits", "SPECTRUM", 0);
*/
}
@@ -441,13 +441,14 @@ parse_objects(struct mkcatalog_passparams *pp)
double *oi=pp->oi;
gal_data_t *xybin=NULL;
size_t *tsize=pp->tile->dsize;
- uint8_t *xybinarr=NULL, *u, *uf;
- float var, sval, *V=NULL, *SK=NULL, *ST=NULL;
+ uint8_t *u, *uf, goodvalue, *xybinarr=NULL;
+ double minima_v=FLT_MAX, maxima_v=-FLT_MAX;
size_t d, pind=0, increment=0, num_increment=1;
int32_t *O, *OO, *C=NULL, *objarr=p->objects->array;
+ float var, sval, varval, skyval, *V=NULL, *SK=NULL, *ST=NULL;
float *std=p->std?p->std->array:NULL, *sky=p->sky?p->sky->array:NULL;
- /* If tile processing isn't necessary, set `tid' to a blank value. */
+ /* If tile processing isn't necessary, set 'tid' to a blank value. */
size_t tid = ( ( (p->sky && p->sky->size>1 && pp->st_sky == NULL )
|| ( p->std && p->std->size>1 && pp->st_std == NULL ) )
? 0 : GAL_BLANK_SIZE_T );
@@ -461,15 +462,23 @@ parse_objects(struct mkcatalog_passparams *pp)
/* If any coordinate columns are requested. */
size_t *c = (
/* Coordinate-related columns. */
- ( oif[ OCOL_GX ]
- || oif[ OCOL_GY ]
- || oif[ OCOL_GZ ]
- || oif[ OCOL_VX ]
- || oif[ OCOL_VY ]
- || oif[ OCOL_VZ ]
- || oif[ OCOL_C_GX ]
- || oif[ OCOL_C_GY ]
- || oif[ OCOL_C_GZ ]
+ ( oif[ OCOL_GX ]
+ || oif[ OCOL_GY ]
+ || oif[ OCOL_GZ ]
+ || oif[ OCOL_VX ]
+ || oif[ OCOL_VY ]
+ || oif[ OCOL_VZ ]
+ || oif[ OCOL_C_GX ]
+ || oif[ OCOL_C_GY ]
+ || oif[ OCOL_C_GZ ]
+ || oif[ OCOL_MINVX ]
+ || oif[ OCOL_MAXVX ]
+ || oif[ OCOL_MINVY ]
+ || oif[ OCOL_MAXVY ]
+ || oif[ OCOL_MINVZ ]
+ || oif[ OCOL_MAXVZ ]
+ || oif[ OCOL_MINVNUM ]
+ || oif[ OCOL_MAXVNUM ]
|| sc
/* When the sky and its STD are tiles, we'll also need
the coordinate to find which tile a pixel belongs
@@ -478,7 +487,6 @@ parse_objects(struct mkcatalog_passparams *pp)
? gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 0, __func__, "c")
: NULL );
-
/* If an XY projection area is necessary, we'll need to allocate an array
to keep the projected space. */
if( p->spectrum
@@ -491,12 +499,11 @@ parse_objects(struct mkcatalog_passparams *pp)
xybinarr=xybin->array;
}
-
/* Parse each contiguous patch of memory covered by this object. */
while( pp->start_end_inc[0] + increment <= pp->start_end_inc[1] )
{
/* Set the contiguous range to parse. The pixel-to-pixel counting
- along the fastest dimension will be done over the `O' pointer. */
+ along the fastest dimension will be done over the 'O' pointer. */
if( p->clumps ) C = pp->st_c + increment;
if( p->values ) V = pp->st_v + increment;
if( p->sky && pp->st_sky ) SK = pp->st_sky + increment;
@@ -563,12 +570,16 @@ parse_objects(struct mkcatalog_passparams *pp)
/* Value related measurements. */
+ goodvalue=0;
if( p->values && !( p->hasblank && isnan(*V) ) )
{
+ /* For the standard-deviation measurements later. */
+ goodvalue=1;
+
/* General flux summations. */
if(xybin) xybinarr[ pind ]=2;
- if(oif[ OCOL_NUM ]) oi[ OCOL_NUM ]++;
- if(oif[ OCOL_SUM ]) oi[ OCOL_SUM ] += *V;
+ if(oif[ OCOL_NUM ]) oi[ OCOL_NUM ]++;
+ if(oif[ OCOL_SUM ]) oi[ OCOL_SUM ] += *V;
/* Get the necessary clump information. */
if(p->clumps && *C>0)
@@ -577,6 +588,50 @@ parse_objects(struct mkcatalog_passparams *pp)
if(oif[ OCOL_C_SUM ]) oi[ OCOL_C_SUM ] += *V;
}
+ /* Get the extrema of the values. Note that if the minima
+ or maxima value's coordinates are requested in any
+ dimension, then 'OCOL_MINVNUM' or 'OCOL_MAXVNUM' will
+ be activated). */
+ if( oif[ OCOL_MINVNUM ] && *V<=minima_v )
+ {
+ /* If the value is smaller than the smallest found so
+ far, reset the counter to one, and reset the sum
+ of positions this one's position. */
+ if( *V<minima_v )
+ {
+ minima_v = *V;
+ oi[ OCOL_MINVNUM ]=1;
+ if(oif[OCOL_MINVX]) oi[ OCOL_MINVX ] = c[ ndim-1 ]+1;
+ if(oif[OCOL_MINVY]) oi[ OCOL_MINVY ] = c[ ndim-2 ]+1;
+ if(oif[OCOL_MINVZ]) oi[ OCOL_MINVZ ] = c[ ndim-3 ]+1;
+ }
+ else
+ {
+ oi[ OCOL_MINVNUM ]++;
+ if(oif[OCOL_MINVX]) oi[ OCOL_MINVX ] += c[ ndim-1
]+1;
+ if(oif[OCOL_MINVY]) oi[ OCOL_MINVY ] += c[ ndim-2
]+1;
+ if(oif[OCOL_MINVZ]) oi[ OCOL_MINVZ ] += c[ ndim-3
]+1;
+ }
+ }
+ if( oif[ OCOL_MAXVNUM ] && *V>=maxima_v )
+ {
+ if( *V>maxima_v )
+ {
+ maxima_v = *V;
+ oi[ OCOL_MAXVNUM ]=1;
+ if(oif[OCOL_MAXVX]) oi[ OCOL_MAXVX ] = c[ ndim-1 ]+1;
+ if(oif[OCOL_MAXVY]) oi[ OCOL_MAXVY ] = c[ ndim-2 ]+1;
+ if(oif[OCOL_MAXVZ]) oi[ OCOL_MAXVZ ] = c[ ndim-3 ]+1;
+ }
+ else
+ {
+ oi[ OCOL_MAXVNUM ]++;
+ if(oif[OCOL_MAXVX]) oi[ OCOL_MAXVX ] += c[ ndim-1
]+1;
+ if(oif[OCOL_MAXVY]) oi[ OCOL_MAXVY ] += c[ ndim-2
]+1;
+ if(oif[OCOL_MAXVZ]) oi[ OCOL_MAXVZ ] += c[ ndim-3
]+1;
+ }
+ }
+
/* For flux weighted centers, we can only use positive
values, so do those measurements here. */
if( *V > 0.0f )
@@ -608,13 +663,19 @@ parse_objects(struct mkcatalog_passparams *pp)
/* Sky value based measurements. */
- if(p->sky)
- if(oif[ OCOL_SUMSKY ])
- oi[ OCOL_SUMSKY ] += ( pp->st_sky
- ? *SK /* Full array */
- : ( p->sky->size>1
- ? sky[tid] /* Tile */
- : sky[0] ) ); /* Single value */
+ if(p->sky && oif[ OCOL_SUMSKY ])
+ {
+ skyval = ( pp->st_sky
+ ? (isnan(*SK)?0:*SK) /* Full array
*/
+ : ( p->sky->size>1
+ ? (isnan(sky[tid])?0:sky[tid]) /* Tile
*/
+ : sky[0] ) ); /* Single
value*/
+ if(!isnan(skyval))
+ {
+ oi[ OCOL_NUMSKY ]++;
+ oi[ OCOL_SUMSKY ] += skyval;
+ }
+ }
/* Sky standard deviation based measurements.*/
@@ -622,20 +683,26 @@ parse_objects(struct mkcatalog_passparams *pp)
{
sval = pp->st_std ? *ST : (p->std->size>1?std[tid]:std[0]);
var = p->variance ? sval : sval*sval;
- if(oif[ OCOL_SUMVAR ]) oi[ OCOL_SUMVAR ] += var;
+ if(oif[ OCOL_SUMVAR ] && (!isnan(var)))
+ {
+ oi[ OCOL_NUMVAR ]++;
+ oi[ OCOL_SUMVAR ] += var;
+ }
/* For each pixel, we have a sky contribution to the
counts and the signal's contribution. The standard
- deviation in the sky is simply `sval', but the
+ deviation in the sky is simply 'sval', but the
standard deviation of the signal (independent of the
- sky) is `sqrt(*V)'. Therefore the total variance of
+ sky) is 'sqrt(*V)'. Therefore the total variance of
this pixel is the variance of the sky added with the
absolute value of its sky-subtracted flux. We use the
absolute value, because especially as the signal gets
noisy there will be negative values, and we don't want
them to decrease the variance. */
- if(oif[ OCOL_SUM_VAR ])
- oi[ OCOL_SUM_VAR ] += ( (p->variance ? var : sval)
- + fabs(*V) );
+ if(oif[ OCOL_SUM_VAR ] && goodvalue)
+ {
+ varval=p->variance ? var : sval;
+ if(!isnan(varval)) oi[ OCOL_SUM_VAR ] += varval +
fabs(*V);
+ }
}
}
@@ -653,7 +720,7 @@ parse_objects(struct mkcatalog_passparams *pp)
num_increment++, NULL) );
/* If a 2D projection is requested, see if we should initialize (set
- to zero) the projection-index (`pind') not. */
+ to zero) the projection-index ('pind') not. */
if(xybin && (num_increment-1)%tsize[1]==0 )
pind=0;
}
@@ -694,6 +761,43 @@ parse_objects(struct mkcatalog_passparams *pp)
+/* To keep the main function easier to read. */
+static void *
+parse_init_extrema(uint8_t *cif, uint8_t type, size_t num, int max1min0)
+{
+ void *out;
+ double *out_d;
+ size_t i, *out_s;
+
+ /* Allocate the array. */
+ out=gal_pointer_allocate(type, num, 0, __func__, "out");
+
+ /* Initialize the array. */
+ switch(type)
+ {
+ case GAL_TYPE_FLOAT64:
+ out_d=out;
+ for(i=0;i<num;++i) out_d[i]= max1min0 ? -FLT_MAX : FLT_MAX;
+ break;
+ case GAL_TYPE_SIZE_T:
+ out_s=out;
+ for(i=0;i<num;++i) out_s[i]= max1min0 ? 0 : GAL_BLANK_SIZE_T;
+ break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
+ "the problem. Type code %d isn't recognized", __func__,
+ PACKAGE_BUGREPORT, type);
+ }
+
+ /* Return the allocated array. */
+ return out;
+}
+
+
+
+
+
+
/* Macro to help in finding the minimum and maximum coordinates. */
#define CMIN(COL, DIM) ( ci[ CCOL_NUMALL ]==1.0f \
? (c[ DIM ]+1) \
@@ -704,9 +808,6 @@ parse_objects(struct mkcatalog_passparams *pp)
: ( (c[ DIM ]+1) > ci[ COL ] \
? (c[ DIM ]+1) : ci[ COL ] ) )
-
-
-
/* Parse over the clumps within an object. */
void
parse_clumps(struct mkcatalog_passparams *pp)
@@ -716,16 +817,17 @@ parse_clumps(struct mkcatalog_passparams *pp)
double *ci, *cir;
gal_data_t *xybin=NULL;
- size_t *tsize=pp->tile->dsize;
int32_t *O, *OO, *C=NULL, nlab;
- uint8_t *u, *uf, *cif=p->ciflag;
- float var, sval, *V=NULL, *SK=NULL, *ST=NULL;
+ size_t cind, *tsize=pp->tile->dsize;
+ double *minima_v=NULL, *maxima_v=NULL;
+ uint8_t *u, *uf, goodvalue, *cif=p->ciflag;
size_t nngb=gal_dimension_num_neighbors(ndim);
size_t i, ii, d, pind=0, increment=0, num_increment=1;
+ float var, sval, varval, skyval, *V=NULL, *SK=NULL, *ST=NULL;
int32_t *objects=p->objects->array, *clumps=p->clumps->array;
float *std=p->std?p->std->array:NULL, *sky=p->sky?p->sky->array:NULL;
- /* If tile processing isn't necessary, set `tid' to a blank value. */
+ /* If tile processing isn't necessary, set 'tid' to a blank value. */
size_t tid = ( ( (p->sky && p->sky->size>1 && pp->st_sky == NULL )
|| ( p->std && p->std->size>1 && pp->st_std == NULL ) )
? 0 : GAL_BLANK_SIZE_T );
@@ -737,18 +839,26 @@ parse_clumps(struct mkcatalog_passparams *pp)
: NULL );
/* If any coordinate columns are requested. */
- size_t *c = ( ( cif[ CCOL_GX ]
- || cif[ CCOL_GY ]
- || cif[ CCOL_GZ ]
- || cif[ CCOL_VX ]
- || cif[ CCOL_VY ]
- || cif[ CCOL_VZ ]
- || cif[ CCOL_MINX ]
- || cif[ CCOL_MAXX ]
- || cif[ CCOL_MINY ]
- || cif[ CCOL_MAXY ]
- || cif[ CCOL_MINZ ]
- || cif[ CCOL_MAXZ ]
+ size_t *c = ( ( cif[ CCOL_GX ]
+ || cif[ CCOL_GY ]
+ || cif[ CCOL_GZ ]
+ || cif[ CCOL_VX ]
+ || cif[ CCOL_VY ]
+ || cif[ CCOL_VZ ]
+ || cif[ CCOL_MINX ]
+ || cif[ CCOL_MAXX ]
+ || cif[ CCOL_MINY ]
+ || cif[ CCOL_MAXY ]
+ || cif[ CCOL_MINZ ]
+ || cif[ CCOL_MAXZ ]
+ || cif[ CCOL_MINVX ]
+ || cif[ CCOL_MAXVX ]
+ || cif[ CCOL_MINVY ]
+ || cif[ CCOL_MAXVY ]
+ || cif[ CCOL_MINVZ ]
+ || cif[ CCOL_MAXVZ ]
+ || cif[ CCOL_MINVNUM ]
+ || cif[ CCOL_MAXVNUM ]
|| sc
|| tid==GAL_BLANK_SIZE_T )
? gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 0, __func__,
@@ -776,12 +886,19 @@ parse_clumps(struct mkcatalog_passparams *pp)
NULL, NULL, NULL);
}
+ /* For the extrema columns. */
+ if( cif[ CCOL_MINVNUM ] || cif[ CCOL_MINVX ]
+ || cif[ CCOL_MINVX ] || cif[ CCOL_MINVZ ] )
+ minima_v=parse_init_extrema(cif, GAL_TYPE_FLOAT64, pp->clumpsinobj, 0);
+ if( cif[ CCOL_MAXVNUM ] || cif[ CCOL_MAXVX ]
+ || cif[ CCOL_MAXVY ] || cif[ CCOL_MAXVZ ] )
+ maxima_v=parse_init_extrema(cif, GAL_TYPE_FLOAT64, pp->clumpsinobj, 1);
/* Parse each contiguous patch of memory covered by this object. */
while( pp->start_end_inc[0] + increment <= pp->start_end_inc[1] )
{
/* Set the contiguous range to parse. The pixel-to-pixel counting
- along the fastest dimension will be done over the `O' pointer. */
+ along the fastest dimension will be done over the 'O' pointer. */
C = pp->st_c + increment;
if( p->values ) V = pp->st_v + increment;
if( p->sky && pp->st_sky ) SK = pp->st_sky + increment;
@@ -800,7 +917,8 @@ parse_clumps(struct mkcatalog_passparams *pp)
{
/* Pointer to make things easier. Note that the clump
labels start from 1, but the array indexs from 0.*/
- ci=&pp->ci[ (*C-1) * CCOL_NUMCOLS ];
+ cind = *C-1;
+ ci=&pp->ci[ cind * CCOL_NUMCOLS ];
/* Add to the area of this object. */
if( cif[ CCOL_NUMALL ]
@@ -809,7 +927,7 @@ parse_clumps(struct mkcatalog_passparams *pp)
|| cif[ CCOL_MINZ ] || cif[ CCOL_MAXZ ] )
ci[ CCOL_NUMALL ]++;
if(cif[ CCOL_NUMALLXY ])
- ((uint8_t *)(xybin[*C-1].array))[ pind ] = 1;
+ ((uint8_t *)(xybin[cind].array))[ pind ] = 1;
/* Raw-position related measurements. */
if(c)
@@ -853,15 +971,59 @@ parse_clumps(struct mkcatalog_passparams *pp)
}
}
- /* Value related measurements, see `parse_objects' for
+ /* Value related measurements, see 'parse_objects' for
comments. */
+ goodvalue=0;
if( p->values && !( p->hasblank && isnan(*V) ) )
{
+ /* For the standard-deviation measurement. */
+ goodvalue=1;
+
/* Fill in the necessary information. */
if(cif[ CCOL_NUM ]) ci[ CCOL_NUM ]++;
if(cif[ CCOL_SUM ]) ci[ CCOL_SUM ] += *V;
if(cif[ CCOL_NUMXY ])
- ((uint8_t *)(xybin[*C-1].array))[ pind ] = 2;
+ ((uint8_t *)(xybin[cind].array))[ pind ] = 2;
+
+ /* Minimum/maximum pixel positions. */
+ if( cif[ CCOL_MINVNUM ] && *V<=minima_v[cind] )
+ {
+ if( *V<minima_v[cind] )
+ {
+ minima_v[cind] = *V;
+ ci[ CCOL_MINVNUM ]=1;
+ if(cif[CCOL_MINVX]) ci[ CCOL_MINVX ] = c[ ndim-1
]+1;
+ if(cif[CCOL_MINVY]) ci[ CCOL_MINVY ] = c[ ndim-2
]+1;
+ if(cif[CCOL_MINVZ]) ci[ CCOL_MINVZ ] = c[ ndim-3
]+1;
+ }
+ else
+ {
+ ci[ CCOL_MINVNUM ]++;
+ if(cif[CCOL_MINVX]) ci[ CCOL_MINVX ] += c[
ndim-1 ]+1;
+ if(cif[CCOL_MINVY]) ci[ CCOL_MINVY ] += c[
ndim-2 ]+1;
+ if(cif[CCOL_MINVZ]) ci[ CCOL_MINVZ ] += c[
ndim-3 ]+1;
+ }
+ }
+ if( cif[ CCOL_MAXVNUM ] && *V>=maxima_v[cind] )
+ {
+ if( *V>maxima_v[cind] )
+ {
+ maxima_v[cind] = *V;
+ ci[ CCOL_MAXVNUM ]=1;
+ if(cif[CCOL_MAXVX]) ci[ CCOL_MAXVX ] = c[ ndim-1
]+1;
+ if(cif[CCOL_MAXVY]) ci[ CCOL_MAXVY ] = c[ ndim-2
]+1;
+ if(cif[CCOL_MAXVZ]) ci[ CCOL_MAXVZ ] = c[ ndim-3
]+1;
+ }
+ else
+ {
+ ci[ CCOL_MAXVNUM ]++;
+ if(cif[CCOL_MAXVX]) ci[ CCOL_MAXVX ] += c[
ndim-1 ]+1;
+ if(cif[CCOL_MAXVY]) ci[ CCOL_MAXVY ] += c[
ndim-2 ]+1;
+ if(cif[CCOL_MAXVZ]) ci[ CCOL_MAXVZ ] += c[
ndim-3 ]+1;
+ }
+ }
+
+ /* Columns that need positive values. */
if( *V > 0.0f )
{
if(cif[ CCOL_NUMWHT ]) ci[ CCOL_NUMWHT ]++;
@@ -882,26 +1044,39 @@ parse_clumps(struct mkcatalog_passparams *pp)
}
/* Sky based measurements. */
- if(p->sky)
- if(cif[ CCOL_SUMSKY ])
- ci[ CCOL_SUMSKY ] += ( pp->st_sky
- ? *SK /* Full */
- : ( p->sky->size>1
- ? sky[tid] /* Tile */
- : sky[0] ) ); /* 1 value */
+ if(p->sky && cif[ CCOL_SUMSKY ])
+ {
+ skyval = ( pp->st_sky
+ ? *SK /* Full. */
+ : ( p->sky->size>1
+ ? sky[tid] /* Tile. */
+ : sky[0] ) ); /* 1 value. */
+ if(!isnan(skyval))
+ {
+ ci[ CCOL_NUMSKY ]++;
+ ci[ CCOL_SUMSKY ] += skyval;
+ }
+ }
/* Sky Standard deviation based measurements, see
- `parse_objects' for comments. */
+ 'parse_objects' for comments. */
if(p->std)
{
sval = ( pp->st_std
? *ST
: (p->std->size>1 ? std[tid] : std[0]) );
var = p->variance ? sval : sval*sval;
- if(cif[ CCOL_SUMVAR ]) ci[ CCOL_SUMVAR ] += var;
- if(cif[ CCOL_SUM_VAR ])
- ci[ CCOL_SUM_VAR ] += ( (p->variance ? var : sval)
- + fabs(*V) );
+ if(cif[ CCOL_SUMVAR ] && (!isnan(var)))
+ {
+ ci[ CCOL_NUMVAR ]++;
+ ci[ CCOL_SUMVAR ] += var;
+ }
+ if(cif[ CCOL_SUM_VAR ] && goodvalue)
+ {
+ varval=p->variance ? var : sval;
+ if(!isnan(varval))
+ ci[ CCOL_SUM_VAR ] += varval + fabs(*V);
+ }
}
}
@@ -914,10 +1089,10 @@ parse_clumps(struct mkcatalog_passparams *pp)
/* We are on a diffuse (possibly a river) pixel. So the
value of this pixel has to be added to any of the
clumps in touches. But since it might touch a labeled
- region more than once, we use `ngblabs' to keep track
+ region more than once, we use 'ngblabs' to keep track
of which label we have already added its value
- to. `ii' is the number of different labels this river
- pixel has already been considered for. `ngblabs' will
+ to. 'ii' is the number of different labels this river
+ pixel has already been considered for. 'ngblabs' will
keep the list labels. */
ii=0;
memset(ngblabs, 0, nngb*sizeof *ngblabs);
@@ -986,42 +1161,169 @@ parse_clumps(struct mkcatalog_passparams *pp)
num_increment++, NULL) );
/* If a 2D projection is requested, see if we should initialize (set
- to zero) the projection-index (`pind') not. */
+ to zero) the projection-index ('pind') not. */
if(xybin && (num_increment-1) % tsize[1]==0 )
pind=0;
}
- /* Write the projected area columns. */
- if(xybin)
- for(i=0;i<pp->clumpsinobj;++i)
- {
- /* Pointer to make things easier. */
- ci=&pp->ci[ i * CCOL_NUMCOLS ];
-
- /* Any non-zero pixel must be set for NUMALLXY. */
- uf=(u=xybin[i].array)+xybin[i].size;
- do
- if(*u)
- {
- if(cif[ CCOL_NUMALLXY ] ) ci[ CCOL_NUMALLXY ]++;
- if(cif[ CCOL_NUMXY ] && *u==2 ) ci[ CCOL_NUMXY ]++;
- }
- while(++u<uf);
+ /* Write the higher-level columns. */
+ for(i=0;i<pp->clumpsinobj;++i)
+ {
+ /* Pointer to make things easier. */
+ ci=&pp->ci[ i * CCOL_NUMCOLS ];
- /* For a check on the projected 2D areas. */
- if(xybin && pp->object==2)
- gal_fits_img_write(&xybin[i], "xybin.fits", NULL, NULL);
+ /* Write the XY projection columns. */
+ if(xybin)
+ {
+ /* Any non-zero pixel must be set for NUMALLXY. */
+ uf=(u=xybin[i].array)+xybin[i].size;
+ do
+ if(*u)
+ {
+ if(cif[ CCOL_NUMALLXY ] ) ci[ CCOL_NUMALLXY ]++;
+ if(cif[ CCOL_NUMXY ] && *u==2 ) ci[ CCOL_NUMXY ]++;
+ }
+ while(++u<uf);
+
+ /* For a check on the projected 2D areas. */
+ if(xybin && pp->object==2)
+ gal_fits_img_write(&xybin[i], "xybin.fits", NULL, NULL);
- }
+ }
+ }
/* Clean up. */
- if(c) free(c);
- if(sc) free(sc);
- if(dinc) free(dinc);
+ if(c) free(c);
+ if(sc) free(sc);
+ if(dinc) free(dinc);
if(ngblabs) free(ngblabs);
- if(xybin) gal_data_array_free(xybin, pp->clumpsinobj, 1);
+ if(minima_v) free(minima_v);
+ if(maxima_v) free(maxima_v);
+ if(xybin) gal_data_array_free(xybin, pp->clumpsinobj, 1);
+}
+
+
+
+
+
+static size_t
+parse_frac_find(gal_data_t *sorted_d, double value, double frac, int dosum)
+{
+ size_t i;
+ double check=0.0f;
+ double *sorted=sorted_d->array;
+
+ /* Parse over the sorted array and find the index. */
+ for(i=0;i<sorted_d->size;++i)
+ if(dosum)
+ { if( (check+=sorted[i]) > value*frac ) break; }
+ else
+ { if( sorted[i] < value*frac ) break; }
+
+ /* Return the final value. Note that if the index is zero, we should
+ actually return 1, because we are starting with the maximum. */
+ return i==0 ? 1 : i;
+}
+
+
+
+
+
+static double
+parse_frac_sum(gal_data_t *sorted_d, double value, double frac, int dosum)
+{
+ double sum=0.0f, *sorted=sorted_d->array;
+ size_t i, ind=parse_frac_find(sorted_d, value, frac, 0);
+
+ for(i=0;i<ind;++i) sum+=sorted[i];
+ return sum;
+}
+
+
+
+
+
+static void
+parse_area_of_frac_sum(struct mkcatalog_passparams *pp, gal_data_t *values,
+ double *outarr, int o1c0)
+{
+ struct mkcatalogparams *p=pp->p;
+
+ double max, *sorted;
+ gal_data_t *sorted_d;
+ uint8_t *flag = o1c0 ? p->oiflag : p->ciflag;
+ double *fracmax = p->fracmax ? p->fracmax->array : NULL;
+ double sumlab = o1c0 ? outarr[OCOL_SUM] : outarr[CCOL_SUM];
+
+ /* Allocate the array to use. */
+ sorted_d = ( values->type==GAL_TYPE_FLOAT64
+ ? values
+ : gal_data_copy_to_new_type(values, GAL_TYPE_FLOAT64) );
+
+ /* Sort the desired labels and find the number of elements where we reach
+ half the total sum. */
+ gal_statistics_sort_decreasing(sorted_d);
+
+ /* Set the required fractions. */
+ if(flag[ o1c0 ? OCOL_HALFSUMNUM : CCOL_HALFSUMNUM ])
+ outarr[ o1c0 ? OCOL_HALFSUMNUM : CCOL_HALFSUMNUM ]
+ = parse_frac_find(sorted_d, sumlab, 0.5f, 1);
+
+ /* Values related to the maximum. */
+ if( flag[ o1c0 ? OCOL_MAXIMUM : CCOL_MAXIMUM ]
+ || flag[ o1c0 ? OCOL_HALFMAXNUM : CCOL_HALFMAXNUM ]
+ || flag[ o1c0 ? OCOL_HALFMAXSUM : CCOL_HALFMAXSUM ]
+ || flag[ o1c0 ? OCOL_FRACMAX1NUM : CCOL_FRACMAX1NUM ]
+ || flag[ o1c0 ? OCOL_FRACMAX1SUM : CCOL_FRACMAX1SUM ]
+ || flag[ o1c0 ? OCOL_FRACMAX2NUM : CCOL_FRACMAX2NUM ]
+ || flag[ o1c0 ? OCOL_FRACMAX2SUM : CCOL_FRACMAX2SUM ] )
+ {
+ /* Set the array and maximum value. We'll use the median of the top
+ three pixels for the maximum (to avoid noise) */
+ sorted=sorted_d->array;
+ max = ( sorted_d->size>3
+ ? (sorted[0]+sorted[1]+sorted[2])/3
+ : sorted[0] );
+
+ /* If we want the maximum value, then write it in. */
+ if(flag[ o1c0 ? OCOL_MAXIMUM : CCOL_MAXIMUM ])
+ outarr[ o1c0 ? OCOL_MAXIMUM : CCOL_MAXIMUM ] = max;
+
+ /* The number of pixels within half the maximum. */
+ if(flag[ o1c0 ? OCOL_HALFMAXNUM : CCOL_HALFMAXNUM ])
+ outarr[ o1c0 ? OCOL_HALFMAXNUM : CCOL_HALFMAXNUM ]
+ = parse_frac_find(sorted_d, max, 0.5f, 0);
+
+ /* The number of pixels within the first requested fraction of maximum */
+ if(flag[ o1c0 ? OCOL_FRACMAX1NUM : CCOL_FRACMAX1NUM ])
+ outarr[ o1c0 ? OCOL_FRACMAX1NUM : CCOL_FRACMAX1NUM ]
+ = parse_frac_find(sorted_d, max, fracmax[0], 0);
+
+ /* The number of pixels within the first requested fraction of maximum */
+ if(flag[ o1c0 ? OCOL_FRACMAX2NUM : CCOL_FRACMAX2NUM ])
+ outarr[ o1c0 ? OCOL_FRACMAX2NUM : CCOL_FRACMAX2NUM ]
+ = parse_frac_find(sorted_d, max, fracmax[1], 0);
+
+ /* The sum of the pixels within the given fraction of the maximum. */
+ if( flag[ o1c0 ? OCOL_HALFMAXSUM : CCOL_HALFMAXSUM ] )
+ outarr[ o1c0 ? OCOL_HALFMAXSUM : CCOL_HALFMAXSUM ]
+ = parse_frac_sum(sorted_d, max, 0.5f, 0);
+
+ /* Sum of the pixels within the 1st given fraction of the maximum. */
+ if( flag[ o1c0 ? OCOL_FRACMAX1SUM : CCOL_FRACMAX1SUM ] )
+ outarr[ o1c0 ? OCOL_FRACMAX1SUM : CCOL_FRACMAX1SUM ]
+ = parse_frac_sum(sorted_d, max, fracmax[0], 0);
+
+ /* Sum of the pixels within the 1st given fraction of the maximum. */
+ if( flag[ o1c0 ? OCOL_FRACMAX2SUM : CCOL_FRACMAX2SUM ] )
+ outarr[ o1c0 ? OCOL_FRACMAX2SUM : CCOL_FRACMAX2SUM ]
+ = parse_frac_sum(sorted_d, max, fracmax[1], 0);
+ }
+
+ /* Clean up and return. */
+ if(sorted_d!=values) gal_data_free(sorted_d);
}
@@ -1029,41 +1331,84 @@ parse_clumps(struct mkcatalog_passparams *pp)
void
-parse_median(struct mkcatalog_passparams *pp)
+parse_order_based(struct mkcatalog_passparams *pp)
{
struct mkcatalogparams *p=pp->p;
float *V;
double *ci;
- gal_data_t *median;
+ float *sigcliparr;
+ gal_data_t *result;
int32_t *O, *OO, *C=NULL;
- gal_data_t **clumpsmed=NULL;
size_t i, increment=0, num_increment=1;
+ gal_data_t *objvals=NULL, **clumpsvals=NULL;
size_t *tsize=pp->tile->dsize, ndim=p->objects->ndim;
size_t counter=0, *ccounter=NULL, tmpsize=pp->oi[OCOL_NUM];
- gal_data_t *objmed=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL,
- 0, p->cp.minmapsize, p->cp.quietmmap,
- NULL, NULL, NULL);
- /* Allocate space for the clump medians. */
+ /* It may happen that there are no usable pixels for this object (and
+ thus its possible clumps). In this case `tmpsize' will be zero and we
+ can just write NaN values for the necessary columns. */
+ if(tmpsize==0)
+ {
+ if(p->oiflag[ OCOL_MEDIAN ]) pp->oi[ OCOL_MEDIAN ] = NAN;
+ if(p->oiflag[ OCOL_MAXIMUM ]) pp->oi[ OCOL_MAXIMUM ] = NAN;
+ if(p->oiflag[ OCOL_HALFMAXSUM ]) pp->oi[ OCOL_HALFMAXSUM ] = NAN;
+ if(p->oiflag[ OCOL_HALFMAXNUM ]) pp->oi[ OCOL_HALFMAXNUM ] = 0;
+ if(p->oiflag[ OCOL_HALFSUMNUM ]) pp->oi[ OCOL_HALFSUMNUM ] = 0;
+ if(p->oiflag[ OCOL_FRACMAX1NUM ]) pp->oi[ OCOL_FRACMAX1NUM ] = 0;
+ if(p->oiflag[ OCOL_FRACMAX2NUM ]) pp->oi[ OCOL_FRACMAX2NUM ] = 0;
+ if(p->oiflag[ OCOL_SIGCLIPNUM ]) pp->oi[ OCOL_SIGCLIPNUM ] = 0;
+ if(p->oiflag[ OCOL_SIGCLIPSTD ]) pp->oi[ OCOL_SIGCLIPSTD ] = 0;
+ if(p->oiflag[ OCOL_SIGCLIPMEAN ]) pp->oi[ OCOL_SIGCLIPMEAN ] = NAN;
+ if(p->oiflag[ OCOL_SIGCLIPMEDIAN ]) pp->oi[ OCOL_SIGCLIPMEDIAN] = NAN;
+ if(p->clumps)
+ for(i=0;i<pp->clumpsinobj;++i)
+ {
+ ci=&pp->ci[ i * CCOL_NUMCOLS ];
+ if(p->ciflag[ CCOL_MEDIAN ]) ci[ CCOL_MEDIAN ] = NAN;
+ if(p->ciflag[ CCOL_MAXIMUM ]) ci[ CCOL_MAXIMUM ] = NAN;
+ if(p->ciflag[ CCOL_HALFMAXSUM ]) ci[ CCOL_HALFMAXSUM ] = NAN;
+ if(p->ciflag[ CCOL_HALFMAXNUM ]) ci[ CCOL_HALFMAXNUM ] = 0;
+ if(p->ciflag[ CCOL_HALFSUMNUM ]) ci[ CCOL_HALFSUMNUM ] = 0;
+ if(p->ciflag[ CCOL_FRACMAX1NUM ]) ci[ CCOL_FRACMAX1NUM ] = 0;
+ if(p->ciflag[ CCOL_FRACMAX2NUM ]) ci[ CCOL_FRACMAX2NUM ] = 0;
+ if(p->ciflag[ CCOL_SIGCLIPNUM ]) ci[ CCOL_SIGCLIPNUM ] = 0;
+ if(p->ciflag[ CCOL_SIGCLIPSTD ]) ci[ CCOL_SIGCLIPSTD ] = 0;
+ if(p->ciflag[ CCOL_SIGCLIPMEAN ]) ci[ CCOL_SIGCLIPMEAN ] = NAN;
+ if(p->ciflag[ CCOL_SIGCLIPMEDIAN ]) ci[ CCOL_SIGCLIPMEDIAN] = NAN;
+ }
+ return;
+ }
+
+ /* We know we have pixels to use, so allocate space for the values within
+ the object. */
+ objvals=gal_data_alloc(NULL, p->values->type, 1, &tmpsize, NULL, 0,
+ p->cp.minmapsize, p->cp.quietmmap, NULL, NULL,
+ NULL);
+
+ /* Clump preparations. */
if(p->clumps)
{
+ /* Allocate the necessary space. */
errno=0;
- clumpsmed=malloc(pp->clumpsinobj * sizeof *clumpsmed);
- if(clumpsmed==NULL)
- error(EXIT_FAILURE, errno, "%s: couldn't allocate `clumpsmed' for "
+ clumpsvals=malloc(pp->clumpsinobj * sizeof *clumpsvals);
+ if(clumpsvals==NULL)
+ error(EXIT_FAILURE, errno, "%s: couldn't allocate 'clumpsvals' for "
"%zu clumps", __func__, pp->clumpsinobj);
-
/* Allocate the array necessary to keep the values of each clump. */
ccounter=gal_pointer_allocate(GAL_TYPE_SIZE_T, pp->clumpsinobj, 1,
__func__, "ccounter");
for(i=0;i<pp->clumpsinobj;++i)
{
tmpsize=pp->ci[ i * CCOL_NUMCOLS + CCOL_NUM ];
- clumpsmed[i]=gal_data_alloc(NULL, p->values->type, 1, &tmpsize,
- NULL, 0, p->cp.minmapsize,
- p->cp.quietmmap, NULL, NULL, NULL);
+ clumpsvals[i] = ( tmpsize
+ ? gal_data_alloc(NULL, p->values->type, 1,
+ &tmpsize, NULL, 0,
+ p->cp.minmapsize,
+ p->cp.quietmmap,
+ NULL, NULL, NULL)
+ : NULL );
}
}
@@ -1072,7 +1417,7 @@ parse_median(struct mkcatalog_passparams *pp)
while( pp->start_end_inc[0] + increment <= pp->start_end_inc[1] )
{
/* Set the contiguous range to parse. The pixel-to-pixel counting
- along the fastest dimension will be done over the `O' pointer. */
+ along the fastest dimension will be done over the 'O' pointer. */
V = pp->st_v + increment;
if(p->clumps) C = pp->st_c + increment;
OO = ( O = pp->st_o + increment ) + tsize[ndim-1];
@@ -1081,20 +1426,20 @@ parse_median(struct mkcatalog_passparams *pp)
do
{
/* If this pixel belongs to the requested object, then do the
- processing. `hasblank' is constant, so when the values doesn't
- have any blank values, the `isnan' will never be checked. */
+ processing. 'hasblank' is constant, so when the values doesn't
+ have any blank values, the 'isnan' will never be checked. */
if( *O==pp->object && !( p->hasblank && isnan(*V) ) )
{
/* Copy the value for the whole object. */
- memcpy( gal_pointer_increment(objmed->array, counter++,
+ memcpy( gal_pointer_increment(objvals->array, counter++,
p->values->type), V,
gal_type_sizeof(p->values->type) );
/* We are also on a clump. */
- if(p->clumps && *C>0)
- memcpy( gal_pointer_increment(clumpsmed[*C-1]->array,
- ccounter[*C-1]++,
- p->values->type), V,
+ if(p->clumps && *C>0 && clumpsvals[*C-1]!=NULL)
+ memcpy( gal_pointer_increment(clumpsvals[*C-1]->array,
+ ccounter[*C-1]++,
+ p->values->type), V,
gal_type_sizeof(p->values->type) );
}
@@ -1110,28 +1455,134 @@ parse_median(struct mkcatalog_passparams *pp)
}
- /* Calculate the final medians for objects. */
- median=gal_data_copy_to_new_type_free(gal_statistics_median(objmed, 1),
- GAL_TYPE_FLOAT64);
- pp->oi[OCOL_MEDIAN]=*((double *)(median->array));
- gal_data_free(objmed);
- gal_data_free(median);
+ /* Calculate the necessary values for the objects. */
+ if(p->oiflag[ OCOL_MEDIAN ])
+ {
+ result=gal_data_copy_to_new_type_free(gal_statistics_median(objvals, 1),
+ GAL_TYPE_FLOAT64);
+ pp->oi[OCOL_MEDIAN]=*((double *)(result->array));
+ gal_data_free(result);
+ }
+ if(p->oiflag[ OCOL_SIGCLIPNUM ]
+ || p->oiflag[ OCOL_SIGCLIPSTD ]
+ || p->oiflag[ OCOL_SIGCLIPMEAN ]
+ || p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+ {
+ /* Calculate the sigma-clipped results and write them in any
+ requested column. */
+ result=gal_statistics_sigma_clip(objvals, p->sigmaclip[0],
+ p->sigmaclip[1], 1, 1);
+ sigcliparr=result->array;
+ if(p->oiflag[ OCOL_SIGCLIPNUM ])
+ pp->oi[OCOL_SIGCLIPNUM]=sigcliparr[0];
+ if(p->oiflag[ OCOL_SIGCLIPSTD ])
+ pp->oi[OCOL_SIGCLIPSTD]=sigcliparr[3];
+ if(p->oiflag[ OCOL_SIGCLIPMEAN ])
+ pp->oi[OCOL_SIGCLIPMEAN]=sigcliparr[2];
+ if(p->oiflag[ OCOL_SIGCLIPMEDIAN ])
+ pp->oi[OCOL_SIGCLIPMEDIAN]=sigcliparr[1];
+
+ /* Clean up the sigma-clipped values. */
+ gal_data_free(result);
+ }
+ /* Fractional values. */
+ if( p->oiflag[ OCOL_MAXIMUM ]
+ || p->oiflag[ OCOL_HALFMAXNUM ]
+ || p->oiflag[ OCOL_HALFMAXSUM ]
+ || p->oiflag[ OCOL_HALFSUMNUM ]
+ || p->oiflag[ OCOL_FRACMAX1NUM ]
+ || p->oiflag[ OCOL_FRACMAX2NUM ] )
+ parse_area_of_frac_sum(pp, objvals, pp->oi, 1);
- /* Calculate the median for clumps. */
+ /* Clean up the object values. */
+ gal_data_free(objvals);
+
+
+ /* Calculate the necessary value for clumps. */
if(p->clumps)
{
for(i=0;i<pp->clumpsinobj;++i)
{
+ /* Set the main row to fill. */
ci=&pp->ci[ i * CCOL_NUMCOLS ];
- median=gal_statistics_median(clumpsmed[i], 1);
- median=gal_data_copy_to_new_type_free(median, GAL_TYPE_FLOAT64);
- ci[ CCOL_MEDIAN ] = ( *((double *)(median->array))
- - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM ]) );
- gal_data_free(clumpsmed[i]);
- gal_data_free(median);
+
+ /* Median. */
+ if(p->ciflag[ CCOL_MEDIAN ])
+ {
+ if(clumpsvals[i])
+ {
+ result=gal_statistics_median(clumpsvals[i], 1);
+ result=gal_data_copy_to_new_type_free(result,
GAL_TYPE_FLOAT64);
+ ci[ CCOL_MEDIAN ] = ( *((double *)(result->array))
+ - (ci[ CCOL_RIV_SUM ]/ci[ CCOL_RIV_NUM
]) );
+ gal_data_free(result);
+ }
+ else ci[ CCOL_MEDIAN ] = NAN;
+ }
+
+ /* Sigma-clipping measurements. */
+ if(p->ciflag[ CCOL_SIGCLIPNUM ]
+ || p->ciflag[ CCOL_SIGCLIPSTD ]
+ || p->ciflag[ CCOL_SIGCLIPMEAN ]
+ || p->ciflag[ CCOL_SIGCLIPMEDIAN ])
+ {
+ if(clumpsvals[i])
+ {
+ result=gal_statistics_sigma_clip(clumpsvals[i],
p->sigmaclip[0],
+ p->sigmaclip[1], 1, 1);
+ sigcliparr=result->array;
+ if(p->ciflag[ CCOL_SIGCLIPNUM ])
+ ci[CCOL_SIGCLIPNUM]=sigcliparr[0];
+ if(p->ciflag[ CCOL_SIGCLIPSTD ])
+ ci[CCOL_SIGCLIPSTD]=( sigcliparr[3]
+ - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ if(p->ciflag[ CCOL_SIGCLIPMEAN ])
+ ci[CCOL_SIGCLIPMEAN]=( sigcliparr[2]
+ - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ if(p->ciflag[ CCOL_SIGCLIPMEDIAN ])
+ ci[CCOL_SIGCLIPMEDIAN]=( sigcliparr[1]
+ - (ci[ CCOL_RIV_SUM ]/ci[
CCOL_RIV_NUM ]));
+ gal_data_free(result);
+ }
+ else
+ {
+ if(p->ciflag[ CCOL_SIGCLIPNUM ]) ci[ CCOL_SIGCLIPNUM
]=NAN;
+ if(p->ciflag[ CCOL_SIGCLIPSTD ]) ci[ CCOL_SIGCLIPSTD
]=NAN;
+ if(p->ciflag[ CCOL_SIGCLIPMEAN ]) ci[ CCOL_SIGCLIPMEAN
]=NAN;
+ if(p->ciflag[ CCOL_SIGCLIPMEDIAN ])
ci[CCOL_SIGCLIPMEDIAN]=NAN;
+ }
+ }
+
+ /* Estimate half of the total sum. */
+ if( p->ciflag[ CCOL_MAXIMUM ]
+ || p->ciflag[ CCOL_HALFMAXNUM ]
+ || p->ciflag[ CCOL_HALFMAXSUM ]
+ || p->ciflag[ CCOL_HALFSUMNUM ]
+ || p->ciflag[ CCOL_FRACMAX1NUM ]
+ || p->ciflag[ CCOL_FRACMAX1SUM ]
+ || p->ciflag[ CCOL_FRACMAX2NUM ]
+ || p->ciflag[ CCOL_FRACMAX2SUM ] )
+ {
+ if(clumpsvals[i])
+ parse_area_of_frac_sum(pp, clumpsvals[i], ci, 0);
+ else
+ {
+ if( p->ciflag[ CCOL_MAXIMUM ]) ci[ CCOL_MAXIMUM
]=NAN;
+ if( p->ciflag[ CCOL_HALFMAXNUM ]) ci[ CCOL_HALFMAXNUM
]=NAN;
+ if( p->ciflag[ CCOL_HALFMAXSUM ]) ci[ CCOL_HALFMAXSUM
]=NAN;
+ if( p->ciflag[ CCOL_HALFSUMNUM ]) ci[ CCOL_HALFSUMNUM
]=NAN;
+ if( p->ciflag[ CCOL_FRACMAX1NUM ]) ci[ CCOL_FRACMAX1NUM
]=NAN;
+ if( p->ciflag[ CCOL_FRACMAX1SUM ]) ci[ CCOL_FRACMAX1SUM
]=NAN;
+ if( p->ciflag[ CCOL_FRACMAX2NUM ]) ci[ CCOL_FRACMAX2NUM
]=NAN;
+ if( p->ciflag[ CCOL_FRACMAX2SUM ]) ci[ CCOL_FRACMAX2SUM
]=NAN;
+ }
+ }
+
+ /* Clean up this clump's values. */
+ gal_data_free(clumpsvals[i]);
}
- free(clumpsmed);
+ free(clumpsvals);
free(ccounter);
}
}
diff --git a/bin/mkcatalog/parse.h b/bin/mkcatalog/parse.h
index 6b197a0..bcaa91f 100644
--- a/bin/mkcatalog/parse.h
+++ b/bin/mkcatalog/parse.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2018-2019, Free Software Foundation, Inc.
+Copyright (C) 2018-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,6 +33,6 @@ void
parse_clumps(struct mkcatalog_passparams *pp);
void
-parse_median(struct mkcatalog_passparams *pp);
+parse_order_based(struct mkcatalog_passparams *pp);
#endif
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index fcdae2a..37bef56 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -126,6 +126,9 @@ ui_initialize_options(struct mkcatalogparams *p,
p->sfmagarea = NAN;
p->upnsigma = NAN;
p->zeropoint = NAN;
+ p->sigmaclip[0] = NAN;
+ p->sigmaclip[1] = NAN;
+ p->pixelarcsecsq = NAN;
p->upsigmaclip[0] = NAN;
p->upsigmaclip[1] = NAN;
p->checkuplim[0] = GAL_BLANK_INT32;
@@ -166,18 +169,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct mkcatalogparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -207,7 +210,7 @@ parse_opt(int key, char *arg, struct argp_state *state)
/* Read the user's desired columns. Because the types of these options are
- `GAL_TYPE_INVALID', this function will not be called when printing the
+ 'GAL_TYPE_INVALID', this function will not be called when printing the
full list of parameters and their values. */
void *
ui_column_codes_ll(struct argp_option *option, char *arg,
@@ -222,17 +225,17 @@ ui_column_codes_ll(struct argp_option *option, char *arg,
{
if( arg[0]=='0' && arg[1]=='\0' ) return NULL;
else if ( !(arg[0]=='1' && arg[1]=='\0') )
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' is not a "
- "valid value to the `%s' option: (\"%s\").\n\n`%s' is "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' is not a "
+ "valid value to the '%s' option: ('%s').\n\n'%s' is "
"an on/off option specifying if you want this column "
"in the output catalog, it doesn't take any "
"arguments. In a configuration file, it can only take "
- "a value of `0' (to be ignored) or `1'", arg,
+ "a value of '0' (to be ignored) or '1'", arg,
option->name, option->doc, option->name);
}
- /* The user wants this column, so add it to the list. Note that the `ids'
+ /* The user wants this column, so add it to the list. Note that the 'ids'
column means three columns. */
if(option->key==UI_KEY_IDS)
{
@@ -287,8 +290,8 @@ ui_check_upperlimit(struct argp_option *option, char *arg,
/* Make sure there is at most only two numbers given. */
if(raw->size>2)
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' (value to "
- "`--%s') contains %zu numbers, but only one or two "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' (value to "
+ "'--%s') contains %zu numbers, but only one or two "
"are acceptable.\n\n"
"With this option MakeCatalog will write all the "
"positions and values of the random distribution for "
@@ -309,13 +312,13 @@ ui_check_upperlimit(struct argp_option *option, char *arg,
{
if( ceil(d[i]) != d[i])
error_at_line(EXIT_FAILURE, 0, filename, lineno, "%g (value "
- "number %zu given to `--%s') is not an "
+ "number %zu given to '--%s') is not an "
"integer. The value(s) to this option are "
"object/clump labels/identifiers, so they must be "
"integers", d[i], i+1, option->name);
if( d[i]<=0 )
error_at_line(EXIT_FAILURE, 0, filename, lineno, "%g (value "
- "number %zu given to `--%s') is not positive. "
+ "number %zu given to '--%s') is not positive. "
"The value(s) to this option are object/clump "
"labels/identifiers, so they must be positive "
"integers", d[i], i+1, option->name);
@@ -354,29 +357,31 @@ ui_check_upperlimit(struct argp_option *option, char *arg,
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct mkcatalogparams *p)
{
float tmp;
- size_t one=1;
+ double *darr;
char *tailptr;
+ size_t i, one=1;
+ gal_list_i32_t *colcode;
/* If an upper-limit check table is requested with a specific clump, but
no clump catalog has been requested, then abort and inform the
user. */
if( p->checkuplim[1]!=GAL_BLANK_INT32 && p->clumpscat==0 )
error(EXIT_FAILURE, 0, "no clumps catalog is requested, hence "
- "`--checkuplim' is only available for objects (one value "
+ "'--checkuplim' is only available for objects (one value "
"must be given to it).\n\n"
- "To ask for a clumps catalog, please append `--clumpscat' to the "
+ "To ask for a clumps catalog, please append '--clumpscat' to the "
"command calling MakeCatalog.\n\n"
"If you want the upperlimit check table for an object, only give "
- "one value (the object's label) to `--checkuplim'.");
+ "one value (the object's label) to '--checkuplim'.");
- /* See if `--skyin' is a filename or a value. When the string is ONLY a
- number (and nothing else), `tailptr' will point to the end of the
- string (`\0'). */
+ /* See if '--skyin' is a filename or a value. When the string is ONLY a
+ number (and nothing else), 'tailptr' will point to the end of the
+ string ('\0'). */
if(p->skyfile)
{
tmp=strtod(p->skyfile, &tailptr);
@@ -405,6 +410,38 @@ ui_read_check_only_options(struct mkcatalogparams *p)
*((float *)(p->std->array))=tmp;
}
}
+
+ /* Make sure that '--fracmax' is given if necessary and that the fracsum
+ values are less than one. */
+ for(colcode=p->columnids; colcode!=NULL; colcode=colcode->next)
+ if( (colcode->v==UI_KEY_FRACMAXAREA1 || colcode->v==UI_KEY_FRACMAXAREA2)
+ && p->fracmax==NULL )
+ error(EXIT_FAILURE, 0, "please specify your required fractions for "
+ "'--fracmaxarea' using the '--fracmax' option (for example "
+ "'--fracmax=0.25,0.75' for two columns)");
+ if(p->fracmax)
+ {
+ /* Currently only 2 fracsums are accepted. */
+ if(p->fracmax->size>2)
+ error(EXIT_FAILURE, 0, "%zu values given to '--fracmax', only two "
+ "values are currently supported", p->fracmax->size);
+
+ /* Check the values. */
+ darr=p->fracmax->array;
+ for(i=0;i<p->fracmax->size;++i)
+ if(darr[i]<=0.0f || darr[i]>=1.0f)
+ error(EXIT_FAILURE, 0, "%g is not acceptable for '--fracmax', "
+ "values should be larger than 0 and less than 1", darr[i]);
+
+ /* If a second fracum column is necessary, make sure two values are
+ given to --fracmax. */
+ for(colcode=p->columnids; colcode!=NULL; colcode=colcode->next)
+ if(colcode->v==UI_KEY_FRACMAXAREA2 && p->fracmax->size==1)
+ error(EXIT_FAILURE, 0, "only one value given to '--fracmax', "
+ "but '--fracmaxarea2' was requested! You need to give "
+ "the requested fraction as a second value to '--fracmax', "
+ "separated by a comma (,)");
+ }
}
@@ -419,8 +456,8 @@ ui_check_options_and_arguments(struct mkcatalogparams *p)
{
if( gal_fits_name_is_fits(p->objectsfile) && p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the input is a FITS "
- "file, a HDU must also be specified, you can use the `--hdu' "
- "(`-h') option and give it the HDU number (starting from "
+ "file, a HDU must also be specified, you can use the '--hdu' "
+ "('-h') option and give it the HDU number (starting from "
"zero), extension name, or anything acceptable by CFITSIO");
}
@@ -511,13 +548,13 @@ ui_wcs_info(struct mkcatalogparams *p)
errno=0;
p->ctype=malloc(p->objects->ndim * sizeof *p->ctype);
if(p->ctype==NULL)
- error(EXIT_FAILURE, 0, "%s: %zu bytes for `p->ctype'", __func__,
+ error(EXIT_FAILURE, 0, "%s: %zu bytes for 'p->ctype'", __func__,
p->objects->ndim * sizeof *p->ctype);
/* Fill in the values. */
for(i=0;i<p->objects->ndim;++i)
{
- /* CTYPE might contain `-' characters, we just want the first
+ /* CTYPE might contain '-' characters, we just want the first
non-dash characters. The loop will either stop either at the end
or where there is a dash. So we can just replace it with an
end-of-string character. */
@@ -535,6 +572,7 @@ ui_wcs_info(struct mkcatalogparams *p)
static size_t
ui_num_clumps(struct mkcatalogparams *p)
{
+ int32_t olab;
char *basename;
int keepinputdir;
size_t i, counter, numclumps=0;
@@ -546,7 +584,7 @@ ui_num_clumps(struct mkcatalogparams *p)
labsinobj=calloc(p->numobjects+1, sizeof *labsinobj);
if(labsinobj==NULL)
error(EXIT_FAILURE, 0, "%s: couldn't allocate %zu bytes for "
- "`labsinobj'", __func__, p->numobjects * sizeof *labsinobj);
+ "'labsinobj'", __func__, p->numobjects * sizeof *labsinobj);
/* Go over each pixel and find the unique clump labels within each
object. */
@@ -556,13 +594,14 @@ ui_num_clumps(struct mkcatalogparams *p)
if(*o>0 && *c>0)
{
/* See if the label has already been found. */
- for(tmp=labsinobj[*o];tmp!=NULL;tmp=tmp->next) if(tmp->v==*c) break;
+ olab = p->outlabsinv ? p->outlabsinv[*o] : *o;
+ for(tmp=labsinobj[olab];tmp!=NULL;tmp=tmp->next) if(tmp->v==*c)
break;
- /* When it wasn't found, `tmp==NULL'. */
+ /* When it wasn't found, 'tmp==NULL'. */
if(tmp==NULL)
{
++numclumps;
- gal_list_i32_add(&labsinobj[*o], *c);
+ gal_list_i32_add(&labsinobj[olab], *c);
}
}
@@ -581,7 +620,8 @@ ui_num_clumps(struct mkcatalogparams *p)
if(*o>0 && *c>0)
{
counter=0;
- for(tmp=labsinobj[*o];tmp!=NULL;tmp=tmp->next)
+ olab = p->outlabsinv ? p->outlabsinv[*o] : *o;
+ for(tmp=labsinobj[olab];tmp!=NULL;tmp=tmp->next)
{ counter++; if(tmp->v==*c) {*c=counter; break;} }
}
@@ -612,6 +652,160 @@ ui_num_clumps(struct mkcatalogparams *p)
+/* To make the catalog processing more scalable (and later allow for
+ over-lappping regions), we will define a tile for each object. */
+static void
+ui_one_tile_per_object_correct_numobjects(struct mkcatalogparams *p)
+{
+ size_t ndim=p->objects->ndim;
+
+ uint8_t *rarray=NULL;
+ int32_t *l, *lf, *start;
+ gal_data_t *rowsremove=NULL;
+ size_t i, j, d, no, *min, *max, exists, width=2*ndim;
+ size_t *minmax=gal_pointer_allocate(GAL_TYPE_SIZE_T,
+ width*p->numobjects, 0, __func__,
+ "minmax");
+ size_t *coord=gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 0, __func__,
+ "coord");
+
+ /* Initialize the minimum and maximum position for each tile/object. So,
+ we'll initialize the minimum coordinates to the maximum possible
+ 'size_t' value (in 'GAL_BLANK_SIZE_T') and the maximums to zero. */
+ for(i=0;i<p->numobjects;++i)
+ for(d=0;d<ndim;++d)
+ {
+ minmax[ i * width + d ] = GAL_BLANK_SIZE_T; /* Minimum. */
+ minmax[ i * width + ndim + d ] = 0; /* Maximum. */
+ }
+
+ /* Go over the objects label image and correct the minimum and maximum
+ coordinates. */
+ start=p->objects->array;
+ lf=(l=p->objects->array)+p->objects->size;
+ do
+ if(*l>0)
+ {
+ /* Get the coordinates of this pixel. */
+ gal_dimension_index_to_coord(l-start, ndim, p->objects->dsize,
+ coord);
+
+ /* Check to see this coordinate is the smallest/largest found so
+ far for this label. Note that labels start from 1, while indexs
+ here start from zero. */
+ min = &minmax[ (*l-1) * width ];
+ max = &minmax[ (*l-1) * width + ndim ];
+ for(d=0;d<ndim;++d)
+ {
+ if( coord[d] < min[d] ) min[d] = coord[d];
+ if( coord[d] > max[d] ) max[d] = coord[d];
+ }
+ }
+ while(++l<lf);
+
+ /* If a label doesn't exist in the image, then write over it and define
+ the unique labels to use for the next steps. To over-write, we have
+ two counters: 'i' (for the position in the input array) and 'no' (or
+ 'num-objects' for the counter in the output table). In the end, 'no'
+ counts the total number of unique labels in the input. */
+ no=0;
+ for(i=0;i<p->numobjects;++i)
+ {
+ /* Make sure a pixel with this label exists in all dimensions. */
+ exists=0;
+ for(d=0;d<ndim;++d)
+ if ( minmax[ i * width + d ] == GAL_BLANK_SIZE_T
+ && minmax[ i * width + ndim + d ] == 0 )
+ {
+ /* When the object doesn't exist, but the user wants a row
+ anyway, make all the minimums and maximums of all
+ coordinates 0, note that the maximum is already zero. */
+ if(p->inbetweenints)
+ minmax[ i * width + d ] = 0;
+ }
+ else
+ {
+ /* Write over the blank elements when necessary
+ (i!=j). When i==j, then these statements are
+ redundant. */
+ minmax[no*width+d]=minmax[i*width+d];
+ minmax[no*width+ndim+d]=minmax[i*width+ndim+d];
+
+ /* Set the checked flag. */
+ exists=1;
+ }
+
+ /* If it does (or if the user wants to keep all integers), then
+ increment the output counter.*/
+ if(p->inbetweenints || exists) ++no;
+ else
+ {
+ /* If 'rarray' isn't defined yet, define it. */
+ if(rarray==NULL)
+ {
+ /* Note that by initializing with zeros, all (the possibly
+ existing) previous rows that shouldn't be removed are
+ flagged as zero in this array. */
+ rowsremove=gal_data_alloc(NULL, GAL_TYPE_UINT8, 1,
+ &p->numobjects, NULL, 1,
+ p->cp.minmapsize, p->cp.quietmmap,
+ NULL, NULL, NULL);
+ rarray=rowsremove->array;
+ }
+ rarray[i]=1;
+ }
+ }
+
+ /* If 'rarray!=NULL', then there are elements to remove and we need to
+ make some modifications/corrections. */
+ if(rarray)
+ {
+ /* Build an array to keep the real ID of each tile. */
+ j=0;
+ p->outlabs=gal_pointer_allocate(GAL_TYPE_INT32, no, 0, __func__,
+ "p->outlabs");
+ for(i=0;i<p->numobjects;++i) if(rarray[i]==0) p->outlabs[j++]=i+1;
+
+ /* Allocate an array for easy finding of the proper label and fill it
+ with the new labels. This array should have an element for each of
+ the original labels (that are not contiguous). */
+ if(p->clumpscat)
+ {
+ p->outlabsinv=gal_pointer_allocate(GAL_TYPE_UINT32,
+ p->numobjects+1, 1,
+ __func__, "p->outlabsinv");
+ for(i=0;i<no;++i) p->outlabsinv[ p->outlabs[i] ] = i;
+ }
+
+ /* Correct numobjects and clean up. */
+ p->numobjects=no;
+ gal_data_free(rowsremove);
+
+ /* For a check:
+ for(i=0;i<p->numobjects;++i)
+ printf("outlabs[%zu]: %d\n", i, p->outlabs[i]);
+ */
+ }
+
+ /* For a check.
+ for(i=0;i<p->numobjects;++i)
+ printf("%zu: (%zu, %zu) --> (%zu, %zu)\n",
+ p->outlabs ? p->outlabs[i] : i+1, minmax[i*width],
+ minmax[i*width+1], minmax[i*width+2], minmax[i*width+3]);
+ */
+
+ /* Make the tiles. */
+ p->tiles=gal_tile_series_from_minmax(p->objects, minmax, p->numobjects);
+
+ /* Clean up. */
+ free(coord);
+ free(minmax);
+}
+
+
+
+
+
/* The only mandatory input is the objects image, so first read that and
make sure its type is correct. */
static void
@@ -630,7 +824,7 @@ ui_read_labels(struct mkcatalogparams *p)
ui_check_type_int(p->objectsfile, p->cp.hdu, p->objects->type);
- /* Convert it to `int32' type (if it already isn't). */
+ /* Convert it to 'int32' type (if it already isn't). */
p->objects=gal_data_copy_to_new_type_free(p->objects, GAL_TYPE_INT32);
@@ -640,12 +834,13 @@ ui_read_labels(struct mkcatalogparams *p)
"currently only supports 2D or 3D datasets", p->objectsfile,
p->cp.hdu, p->objects->ndim);
- /* Make sure the `--spectrum' option is not given on a 2D image. */
+ /* Make sure the '--spectrum' option is not given on a 2D image. */
if(p->spectrum && p->objects->ndim!=3)
- error(EXIT_FAILURE, 0, "%s (hdu %s) has %zu dimensions, but `--spectrum' "
+ error(EXIT_FAILURE, 0, "%s (hdu %s) has %zu dimensions, but '--spectrum' "
"is currently only defined on 3D datasets", p->objectsfile,
p->cp.hdu, p->objects->ndim);
+
/* See if the total number of objects is given in the header keywords. */
keys[0].name="NUMLABS";
keys[0].type=GAL_TYPE_SIZE_T;
@@ -658,6 +853,7 @@ ui_read_labels(struct mkcatalogparams *p)
gal_data_free(tmp);
}
+
/* If there were no objects in the input, then inform the user with an
error (it is pointless to build a catalog). */
if(p->numobjects==0)
@@ -675,17 +871,22 @@ ui_read_labels(struct mkcatalogparams *p)
ui_wcs_info(p);
+ /* Make the tiles that cover each object and also correct the total
+ number of objects based on the parsing of the image. */
+ ui_one_tile_per_object_correct_numobjects(p);
+
+
/* Read the clumps array if necessary. */
if(p->clumpscat)
{
/* Make sure the HDU is also given. */
if(p->clumpshdu==NULL)
error(EXIT_FAILURE, 0, "%s: no HDU/extension provided for the "
- "CLUMPS dataset. Please use the `--clumpshdu' option to "
+ "CLUMPS dataset. Please use the '--clumpshdu' option to "
"give a specific HDU using its number (counting from zero) "
"or name. If the dataset is in another file, please use "
- "`--clumpsfile' to give the filename. If you don't want any "
- "clumps catalog output, remove the `--clumpscat' option from "
+ "'--clumpsfile' to give the filename. If you don't want any "
+ "clumps catalog output, remove the '--clumpscat' option from "
"the command-line or give it a value of zero in a "
"configuration file", p->usedclumpsfile);
@@ -698,7 +899,7 @@ ui_read_labels(struct mkcatalogparams *p)
/* Check its size. */
if( gal_dimension_is_different(p->objects, p->clumps) )
- error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
+ error(EXIT_FAILURE, 0, "'%s' (hdu: %s) and '%s' (hdu: %s) have a"
"different dimension/size", p->usedclumpsfile, p->clumpshdu,
p->objectsfile, p->cp.hdu);
@@ -722,14 +923,14 @@ ui_read_labels(struct mkcatalogparams *p)
if(p->numclumps==0)
{
/* Just as a sanity check, see if there are any clumps (positive
- valued pixels) in the array. If there are, then `NUMCLUMPS'
+ valued pixels) in the array. If there are, then 'NUMCLUMPS'
wasn't set properly and we should abort with an error. */
tmp=gal_statistics_maximum(p->clumps);
if( *((int32_t *)(p->clumps->array))>0 )
- error(EXIT_FAILURE, 0, "%s (hdu: %s): the `NUMCLUMPS' header "
+ error(EXIT_FAILURE, 0, "%s (hdu: %s): the 'NUMCLUMPS' header "
"keyword has a value of zero, but there are positive "
"pixels in the array, showing that there are clumps in "
- "image. This is a wrong usage of the `NUMCLUMPS' keyword."
+ "image. This is a wrong usage of the 'NUMCLUMPS' keyword."
"It must contain the total number of clumps (irrespective "
"of how many objects there are). Please correct this issue "
"and run MakeCatalog again", p->usedclumpsfile,
@@ -747,7 +948,6 @@ ui_read_labels(struct mkcatalogparams *p)
}
}
-
/* Clean up. */
keys[0].name=keys[1].name=NULL;
keys[0].array=keys[1].array=NULL;
@@ -761,19 +961,21 @@ ui_read_labels(struct mkcatalogparams *p)
/* See which inputs are necessary. Ultimate, there are only three extra
inputs: a values image, a sky image and a sky standard deviation
image. However, there are many raw column measurements. So to keep
- things clean, we'll just put a value of `1' in the three `values', `sky'
- and `std' pointers everytime a necessary input is found. */
+ things clean, we'll just put a value of '1' in the three 'values', 'sky'
+ and 'std' pointers everytime a necessary input is found. */
static void
ui_necessary_inputs(struct mkcatalogparams *p, int *values, int *sky,
int *std)
{
size_t i;
+ /* Set necessary inputs based on options. */
+ if(p->forcereadstd) *std=1;
if(p->upperlimit) *values=1;
- if(p->spectrum) *values=*std=1;
+ if(p->spectrum) *values=*std=1;
/* Go over all the object columns. Note that the objects and clumps (if
- the `--clumpcat' option is given) inputs are mandatory and it is not
+ the '--clumpcat' option is given) inputs are mandatory and it is not
necessary to specify it here. */
for(i=0; i<OCOL_NUMCOLS; ++i)
if(p->oiflag[i])
@@ -786,12 +988,25 @@ ui_necessary_inputs(struct mkcatalogparams *p, int
*values, int *sky,
case OCOL_SUM: *values = 1; break;
case OCOL_SUM_VAR: *values = *std = 1; break;
case OCOL_MEDIAN: *values = 1; break;
+ case OCOL_MAXIMUM: *values = 1; break;
+ case OCOL_SIGCLIPNUM: *values = 1; break;
+ case OCOL_SIGCLIPMEDIAN: *values = 1; break;
+ case OCOL_SIGCLIPMEAN: *values = 1; break;
+ case OCOL_SIGCLIPSTD: *values = 1; break;
case OCOL_VX: *values = 1; break;
case OCOL_VY: *values = 1; break;
case OCOL_VZ: *values = 1; break;
case OCOL_VXX: *values = 1; break;
case OCOL_VYY: *values = 1; break;
case OCOL_VXY: *values = 1; break;
+ case OCOL_MINVX: *values = 1; break;
+ case OCOL_MAXVX: *values = 1; break;
+ case OCOL_MINVY: *values = 1; break;
+ case OCOL_MAXVY: *values = 1; break;
+ case OCOL_MINVZ: *values = 1; break;
+ case OCOL_MAXVZ: *values = 1; break;
+ case OCOL_MINVNUM: *values = 1; break;
+ case OCOL_MAXVNUM: *values = 1; break;
case OCOL_SUMSKY: *sky = 1; break;
case OCOL_SUMVAR: *std = 1; break;
case OCOL_SUMWHT: *values = 1; break;
@@ -806,6 +1021,13 @@ ui_necessary_inputs(struct mkcatalogparams *p, int
*values, int *sky,
case OCOL_UPPERLIMIT_S: *values = 1; break;
case OCOL_UPPERLIMIT_Q: *values = 1; break;
case OCOL_UPPERLIMIT_SKEW: *values = 1; break;
+ case OCOL_HALFMAXNUM: *values = 1; break;
+ case OCOL_HALFMAXSUM: *values = 1; break;
+ case OCOL_HALFSUMNUM: *values = 1; break;
+ case OCOL_FRACMAX1NUM: *values = 1; break;
+ case OCOL_FRACMAX1SUM: *values = 1; break;
+ case OCOL_FRACMAX2NUM: *values = 1; break;
+ case OCOL_FRACMAX2SUM: *values = 1; break;
case OCOL_C_NUMALL: /* Only clump labels. */ break;
case OCOL_C_NUM: *values = 1; break;
case OCOL_C_SUM: *values = 1; break;
@@ -837,6 +1059,11 @@ ui_necessary_inputs(struct mkcatalogparams *p, int
*values, int *sky,
case CCOL_SUM: *values = 1; break;
case CCOL_SUM_VAR: *values = *std = 1; break;
case CCOL_MEDIAN: *values = 1; break;
+ case CCOL_MAXIMUM: *values = 1; break;
+ case CCOL_SIGCLIPNUM: *values = 1; break;
+ case CCOL_SIGCLIPMEDIAN: *values = 1; break;
+ case CCOL_SIGCLIPMEAN: *values = 1; break;
+ case CCOL_SIGCLIPSTD: *values = 1; break;
case CCOL_RIV_NUM: /* Only clump labels. */ break;
case CCOL_RIV_SUM: *values = 1; break;
case CCOL_RIV_SUM_VAR: *values = *std = 1; break;
@@ -846,6 +1073,14 @@ ui_necessary_inputs(struct mkcatalogparams *p, int
*values, int *sky,
case CCOL_VXX: *values = 1; break;
case CCOL_VYY: *values = 1; break;
case CCOL_VXY: *values = 1; break;
+ case CCOL_MINVX: *values = 1; break;
+ case CCOL_MINVY: *values = 1; break;
+ case CCOL_MINVZ: *values = 1; break;
+ case CCOL_MAXVX: *values = 1; break;
+ case CCOL_MAXVY: *values = 1; break;
+ case CCOL_MAXVZ: *values = 1; break;
+ case CCOL_MINVNUM: *values = 1; break;
+ case CCOL_MAXVNUM: *values = 1; break;
case CCOL_SUMSKY: *sky = 1; break;
case CCOL_SUMVAR: *std = 1; break;
case CCOL_SUMWHT: *values = 1; break;
@@ -866,6 +1101,13 @@ ui_necessary_inputs(struct mkcatalogparams *p, int
*values, int *sky,
case CCOL_UPPERLIMIT_S: *values = 1; break;
case CCOL_UPPERLIMIT_Q: *values = 1; break;
case CCOL_UPPERLIMIT_SKEW: *values = 1; break;
+ case CCOL_HALFMAXNUM: *values = 1; break;
+ case CCOL_HALFMAXSUM: *values = 1; break;
+ case CCOL_HALFSUMNUM: *values = 1; break;
+ case CCOL_FRACMAX1NUM: *values = 1; break;
+ case CCOL_FRACMAX1SUM: *values = 1; break;
+ case CCOL_FRACMAX2NUM: *values = 1; break;
+ case CCOL_FRACMAX2SUM: *values = 1; break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
"fix the problem. The code %zu is not a recognized "
@@ -890,8 +1132,8 @@ ui_preparation_check_size_read_tiles(struct
mkcatalogparams *p,
/* See if we should treat this dataset as tile values or not. */
if( gal_dimension_is_different(p->objects, in) )
{
- /* The `tl' structure is initialized here. But this function may be
- called multiple times. So, first check if the `tl' structure has
+ /* The 'tl' structure is initialized here. But this function may be
+ called multiple times. So, first check if the 'tl' structure has
already been initialized and if so, don't repeat it. */
if(tl->ndim==0)
{
@@ -901,20 +1143,20 @@ ui_preparation_check_size_read_tiles(struct
mkcatalogparams *p,
gal_tile_full_permutation(tl);
}
- /* See if the size of the `in' dataset corresponds to the
+ /* See if the size of the 'in' dataset corresponds to the
tessellation. */
if(in->size!=tl->tottiles)
error(EXIT_FAILURE, 0, "%s (hdu: %s): doesn't have the right "
"size (%zu elements or pixels).\n\n"
- "It must either be the same size as `%s' (hdu: `%s'), or "
+ "It must either be the same size as '%s' (hdu: '%s'), or "
"it must have the same number of elements as the total "
"number of tiles in the tessellation (%zu). In the latter "
"case, each pixel is assumed to be a fixed value for a "
"complete tile.\n\n"
- "Run with `-P' to see the (tessellation) options/settings "
+ "Run with '-P' to see the (tessellation) options/settings "
"and their values). For more information on tessellation in "
"Gnuastro, please run the following command (use the arrow "
- "keys for up and down and press `q' to return to the "
+ "keys for up and down and press 'q' to return to the "
"command-line):\n\n"
" $ info gnuastro tessellation",
filename, hdu, in->size, p->objectsfile, p->cp.hdu,
@@ -926,7 +1168,7 @@ ui_preparation_check_size_read_tiles(struct
mkcatalogparams *p,
-/* Subtract `sky' from the input dataset depending on its size (it may be
+/* Subtract 'sky' from the input dataset depending on its size (it may be
the whole array or a tile-values array).. */
static void
ui_subtract_sky(struct mkcatalogparams *p)
@@ -955,7 +1197,7 @@ ui_subtract_sky(struct mkcatalogparams *p)
tile=&tl->tiles[tid];
/* Subtract the Sky value from the input image. */
- GAL_TILE_PARSE_OPERATE(tile, NULL, 0, 0, {*i-=skyarr[tid];});
+ GAL_TILE_PARSE_OPERATE(tile, p->values, 1, 0, {*o-=skyarr[tid];});
}
}
@@ -965,10 +1207,6 @@ ui_subtract_sky(struct mkcatalogparams *p)
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
"the problem. For some reason, the size doesn't match", __func__,
PACKAGE_BUGREPORT);
-
- /* Inform the user that this operation is done (if necessary). */
- if(!p->cp.quiet)
- printf(" - Sky subtracted from input values.\n");
}
@@ -995,9 +1233,9 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
if(p->valueshdu==NULL)
error(EXIT_FAILURE, 0, "%s: no HDU/extension provided for the "
"VALUES dataset. Atleast one column needs this dataset. "
- "Please use the `--valueshdu' option to give a specific HDU "
+ "Please use the '--valueshdu' option to give a specific HDU "
"using its number (counting from zero) or name. If the "
- "dataset is in another file, please use `--valuesfile' to "
+ "dataset is in another file, please use '--valuesfile' to "
"give the filename", p->usedvaluesfile);
/* Read the values dataset. */
@@ -1010,14 +1248,14 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
/* Make sure it has the correct size. */
if( gal_dimension_is_different(p->objects, p->values) )
- error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
+ error(EXIT_FAILURE, 0, "'%s' (hdu: %s) and '%s' (hdu: %s) have a"
"different dimension/size", p->usedvaluesfile, p->valueshdu,
p->objectsfile, p->cp.hdu);
- /* Initially, `p->hasblank' was set based on the objects image, but
+ /* Initially, 'p->hasblank' was set based on the objects image, but
it may happen that the objects image only has zero values for
blank pixels, so we'll also do a check on the input image. */
- p->hasblank = gal_blank_present(p->objects, 1);
+ p->hasblank = gal_blank_present(p->values, 1);
/* Reset the units of the value-based columns if the input dataset
has defined units. */
@@ -1025,10 +1263,12 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
{
for(column=p->objectcols; column!=NULL; column=column->next)
if( !strcmp(column->unit, MKCATALOG_NO_UNIT) )
- { free(column->unit); column->unit=p->values->unit; }
+ { free(column->unit);
+ gal_checkset_allocate_copy(p->values->unit, &column->unit); }
for(column=p->clumpcols; column!=NULL; column=column->next)
if( !strcmp(column->unit, MKCATALOG_NO_UNIT) )
- { free(column->unit); column->unit=p->values->unit; }
+ { free(column->unit);
+ gal_checkset_allocate_copy(p->values->unit, &column->unit); }
}
}
@@ -1045,9 +1285,9 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
error(EXIT_FAILURE, 0, "%s: no HDU/extension provided for the "
"SKY dataset. Atleast one column needs this dataset, or "
"you have asked to subtract the Sky from the values.\n\n"
- "Please use the `--skyhdu' option to give a specific HDU "
+ "Please use the '--skyhdu' option to give a specific HDU "
"using its number (counting from zero) or name. If the "
- "dataset is in another file, please use `--skyin' to "
+ "dataset is in another file, please use '--skyin' to "
"give the filename", p->usedskyfile);
/* Read the Sky dataset. */
@@ -1077,9 +1317,9 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
error(EXIT_FAILURE, 0, "%s: no HDU/extension provided for the "
"SKY STANDARD DEVIATION dataset.\n\n"
"Atleast one column needs this dataset. Please use the "
- "`--stdhdu' option to give a specific HDU using its number "
+ "'--stdhdu' option to give a specific HDU using its number "
"(counting from zero) or name. If the dataset is in another "
- "file, please use `--stdin' to give the filename",
+ "file, please use '--stdin' to give the filename",
p->usedstdfile);
/* Read the Sky standard deviation image into memory. */
@@ -1104,7 +1344,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
if(p->checkuplim[0] != GAL_BLANK_INT32
&& p->checkuplim[0] > p->numobjects)
error(EXIT_FAILURE, 0, "%d (object identifier for the "
- "`--checkuplim' option) is larger than the number of "
+ "'--checkuplim' option) is larger than the number of "
"objects in the input labels (%zu)", p->checkuplim[0],
p->numobjects);
@@ -1114,7 +1354,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
/* Make sure the HDU for the mask image is given. */
if(p->upmaskhdu==NULL)
error(EXIT_FAILURE, 0, "%s: no HDU/extension provided, please "
- "use the `--upmaskhdu' option to specify a specific HDU "
+ "use the '--upmaskhdu' option to specify a specific HDU "
"using its number (counting from zero) or name",
p->upmaskfile);
@@ -1128,7 +1368,7 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
/* Check its size. */
if( gal_dimension_is_different(p->objects, p->upmask) )
- error(EXIT_FAILURE, 0, "`%s' (hdu: %s) and `%s' (hdu: %s) have a"
+ error(EXIT_FAILURE, 0, "'%s' (hdu: %s) and '%s' (hdu: %s) have a"
"different dimension/size", p->upmaskfile, p->upmaskhdu,
p->objectsfile, p->cp.hdu);
@@ -1166,41 +1406,49 @@ ui_preparations_read_inputs(struct mkcatalogparams *p)
static void
ui_preparations_read_keywords(struct mkcatalogparams *p)
{
- float minstd;
gal_data_t *tmp;
+ float std, minstd;
gal_data_t *keys=NULL;
- /* When a Sky standard deviation dataset (not number) is given. */
- if(p->std && p->std->size>1)
+ /* Set the counts-per-second correction. */
+ if(p->std)
{
- /* Read the keywords from the standard deviation image. */
- keys=gal_data_array_calloc(2);
- keys[0].next=&keys[1];
- keys[0].name="MINSTD"; keys[1].name="MEDSTD";
- keys[0].type=GAL_TYPE_FLOAT32; keys[1].type=GAL_TYPE_FLOAT32;
- keys[0].array=&minstd; keys[1].array=&p->medstd;
- gal_fits_key_read(p->usedstdfile, p->stdhdu, keys, 0, 0);
-
- /* If the two keywords couldn't be read. We don't want to slow down
- the user for the median (which needs sorting). So we'll just
- calculate the minimum which is necessary for the `p->cpscorr'. */
- if(keys[1].status) p->medstd=NAN;
- if(keys[0].status)
+ if(p->std->size>1)
{
- /* Calculate the minimum STD. */
- tmp=gal_statistics_minimum(p->std);
- minstd=*((float *)(tmp->array));
- gal_data_free(tmp);
+ /* Read the keywords from the standard deviation image. */
+ keys=gal_data_array_calloc(2);
+ keys[0].next=&keys[1];
+ keys[0].name="MINSTD"; keys[1].name="MEDSTD";
+ keys[0].type=GAL_TYPE_FLOAT32; keys[1].type=GAL_TYPE_FLOAT32;
+ keys[0].array=&minstd; keys[1].array=&p->medstd;
+ gal_fits_key_read(p->usedstdfile, p->stdhdu, keys, 0, 0);
+
+ /* If the two keywords couldn't be read. We don't want to slow down
+ the user for the median (which needs sorting). So we'll just
+ calculate the minimum which is necessary for the 'p->cpscorr'. */
+ if(keys[1].status) p->medstd=NAN;
+ if(keys[0].status)
+ {
+ /* Calculate the minimum STD. */
+ tmp=gal_statistics_minimum(p->std);
+ minstd=*((float *)(tmp->array));
+ gal_data_free(tmp);
- /* If the units are in variance, then take the square root. */
- if(p->variance) minstd=sqrt(minstd);
- }
- p->cpscorr = minstd>1 ? 1.0f : minstd;
+ /* If the units are in variance, then take the square root. */
+ if(p->variance) minstd=sqrt(minstd);
+ }
+ p->cpscorr = minstd>1 ? 1.0f : minstd;
- /* Clean up. */
- keys[0].name=keys[1].name=NULL;
- keys[0].array=keys[1].array=NULL;
- gal_data_array_free(keys, 2, 1);
+ /* Clean up. */
+ keys[0].name=keys[1].name=NULL;
+ keys[0].array=keys[1].array=NULL;
+ gal_data_array_free(keys, 2, 1);
+ }
+ else
+ {
+ std=((float *)(p->std->array))[0];
+ p->cpscorr=std>1 ? 1.0f : std;
+ }
}
}
@@ -1223,7 +1471,7 @@ ui_preparations_both_names(struct mkcatalogparams *p)
{
/* When the user has specified a name, any possible directories in
that name must be respected. So we have kept the actual
- `keepinputdir' value in a temporary variable above and set it to 1
+ 'keepinputdir' value in a temporary variable above and set it to 1
only for this operation. Later we set it back to what it was. */
p->cp.keepinputdir=1;
@@ -1234,8 +1482,8 @@ ui_preparations_both_names(struct mkcatalogparams *p)
if( gal_fits_name_is_fits(p->cp.output) )
{
/* The output file name that the user has given supersedes the
- `tableformat' argument. In this case, the filename is a FITS
- file, so if `tableformat' is a text file, we will change it to
+ 'tableformat' argument. In this case, the filename is a FITS
+ file, so if 'tableformat' is a text file, we will change it to
a default binary FITS table. */
if( p->cp.tableformat==GAL_TABLE_FORMAT_TXT )
p->cp.tableformat=GAL_TABLE_FORMAT_BFITS;
@@ -1264,7 +1512,7 @@ ui_preparations_both_names(struct mkcatalogparams *p)
p->clumpsout=p->objectsout;
}
- /* Revert `keepinputdir' to what it was. */
+ /* Revert 'keepinputdir' to what it was. */
p->cp.keepinputdir=keepinputdir;
}
@@ -1283,9 +1531,9 @@ ui_preparations_outnames(struct mkcatalogparams *p)
if(p->cp.output)
{
/* If the output name is a FITS file, then
- `gal_tableintern_check_fits_format' will see if the tableformat
+ 'gal_tableintern_check_fits_format' will see if the tableformat
corresponds to a FITS table or not. If the output name isn't a
- FITS file then the current value of `p->cp.tableformat' is
+ FITS file then the current value of 'p->cp.tableformat' is
irrelevant and it must be set to text. We use this value in the
end to determine specific features. */
if( gal_fits_name_is_fits(p->cp.output) )
@@ -1333,11 +1581,11 @@ ui_preparations_outnames(struct mkcatalogparams *p)
: p->objectsfile),
suffix);
- /* Set `keepinputdir' to what it was before. */
+ /* Set 'keepinputdir' to what it was before. */
p->cp.keepinputdir=keepinputdir;
}
- /* Just to avoid bugs (`p->cp.output' must no longer be used), we'll free
+ /* Just to avoid bugs ('p->cp.output' must no longer be used), we'll free
it and set it to NULL.*/
free(p->cp.output);
p->cp.output=NULL;
@@ -1347,73 +1595,6 @@ ui_preparations_outnames(struct mkcatalogparams *p)
-/* To make the catalog processing more scalable (and later allow for
- over-lappping regions), we will define a tile for each object. */
-void
-ui_one_tile_per_object(struct mkcatalogparams *p)
-{
- size_t ndim=p->objects->ndim;
-
- int32_t *l, *lf, *start;
- size_t i, d, *min, *max, width=2*ndim;
- size_t *minmax=gal_pointer_allocate(GAL_TYPE_SIZE_T,
- width*p->numobjects, 0, __func__,
- "minmax");
- size_t *coord=gal_pointer_allocate(GAL_TYPE_SIZE_T, ndim, 0, __func__,
- "coord");
-
-
- /* Initialize the minimum and maximum position for each tile/object. So,
- we'll initialize the minimum coordinates to the maximum possible
- `size_t' value (in `GAL_BLANK_SIZE_T') and the maximums to zero. */
- for(i=0;i<p->numobjects;++i)
- for(d=0;d<ndim;++d)
- {
- minmax[ i * width + d ] = GAL_BLANK_SIZE_T; /* Minimum. */
- minmax[ i * width + ndim + d ] = 0; /* Maximum. */
- }
-
- /* Go over the objects label image and correct the minimum and maximum
- coordinates. */
- start=p->objects->array;
- lf=(l=p->objects->array)+p->objects->size;
- do
- if(*l>0)
- {
- /* Get the coordinates of this pixel. */
- gal_dimension_index_to_coord(l-start, ndim, p->objects->dsize, coord);
-
- /* Check to see this coordinate is the smallest/largest found so
- far for this label. Note that labels start from 1, while indexs
- here start from zero. */
- min = &minmax[ (*l-1) * width ];
- max = &minmax[ (*l-1) * width + ndim ];
- for(d=0;d<ndim;++d)
- {
- if( coord[d] < min[d] ) min[d] = coord[d];
- if( coord[d] > max[d] ) max[d] = coord[d];
- }
- }
- while(++l<lf);
-
- /* For a check.
- for(i=0;i<p->numobjects;++i)
- printf("%zu: (%zu, %zu) --> (%zu, %zu)\n", i+1, minmax[i*width],
- minmax[i*width+1], minmax[i*width+2], minmax[i*width+3]);
- */
-
- /* Make the tiles. */
- p->tiles=gal_tile_series_from_minmax(p->objects, minmax, p->numobjects);
-
- /* Clean up. */
- free(coord);
- free(minmax);
-}
-
-
-
-
-
/* When a spectrum is requested, the slice information (slice number and
slice WCS) is common to all different spectra. So instead of calculating
it every time, we'll just make it once here, then copy it for every
@@ -1434,12 +1615,12 @@ ui_preparations_spectrum_wcs(struct mkcatalogparams *p)
/* A small sanity check. */
if(p->objects->ndim!=3)
- error(EXIT_FAILURE, 0, "%s (hdu %s) is a %zuD dataset, but `--spectrum' "
+ error(EXIT_FAILURE, 0, "%s (hdu %s) is a %zuD dataset, but '--spectrum' "
"is currently only defined on 3D datasets", p->objectsfile,
p->cp.hdu, p->objects->ndim);
/* Allocate space for the slice number as well as the X and Y positions
- for WCS conversion. Note that the `z' axis is going to be converted to
+ for WCS conversion. Note that the 'z' axis is going to be converted to
WCS later, so we'll just give it the basic information now.*/
x=gal_data_alloc(NULL, GAL_TYPE_FLOAT64, 1, &numslices, NULL, 0,
p->cp.minmapsize, p->cp.quietmmap, NULL, NULL, NULL);
@@ -1478,15 +1659,15 @@ ui_preparations_spectrum_wcs(struct mkcatalogparams *p)
else
for(i=0;i<numslices;++i) ((uint32_t *)(p->specsliceinfo->array))[i]=i+1;
- /* Set the slice WCS column information. Note that `z' is now the WCS
+ /* Set the slice WCS column information. Note that 'z' is now the WCS
coordinate value of the third dimension, and to avoid wasting extra
space (this column is repeated one very object's spectrum), we'll
convert it to a 32-bit floating point dataset. */
p->specsliceinfo->next=gal_data_copy_to_new_type(z, GAL_TYPE_FLOAT32);
/* For a final check.
- gal_table_write(p->specsliceinfo, NULL, GAL_TABLE_FORMAT_BFITS,
- "specsliceinfo.fits", "test-debug",0);
+ gal_table_write(p->specsliceinfo, NULL, NULL, GAL_TABLE_FORMAT_BFITS,
+ "specsliceinfo.fits", "test-debug", 0);
*/
/* Clean up. */
@@ -1511,19 +1692,19 @@ ui_preparations_upperlimit(struct mkcatalogparams *p)
{
for(i=0;p->uprange[i]!=-1;++i) ++c;
if(c!=p->objects->ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--uprange', but input "
+ error(EXIT_FAILURE, 0, "%zu values given to '--uprange', but input "
"has %zu dimensions", c, p->objects->ndim);
}
/* Check the number of random samples. */
if( p->upnum < MKCATALOG_UPPERLIMIT_MINIMUM_NUM )
- error(EXIT_FAILURE, 0, "%zu not acceptable as `--upnum'. The minimum "
+ error(EXIT_FAILURE, 0, "%zu not acceptable as '--upnum'. The minimum "
"acceptable number of random samples for the upper limit "
"magnitude is %d", p->upnum, MKCATALOG_UPPERLIMIT_MINIMUM_NUM);
/* Check if sigma-clipping parameters have been given. */
if( isnan(p->upsigmaclip[0]) )
- error(EXIT_FAILURE, 0, "`--upsigmaclip' is mandatory for measuring "
+ error(EXIT_FAILURE, 0, "'--upsigmaclip' is mandatory for measuring "
"the upper-limit magnitude. It takes two numbers separated by "
"a comma. The first is the multiple of sigma and the second is "
"the aborting criteria: <1: tolerance level, >1: number of "
@@ -1531,7 +1712,7 @@ ui_preparations_upperlimit(struct mkcatalogparams *p)
/* Check if the sigma multiple is given. */
if( isnan(p->upnsigma) )
- error(EXIT_FAILURE, 0, "`--upnsigma' is mandatory for measuring the "
+ error(EXIT_FAILURE, 0, "'--upnsigma' is mandatory for measuring the "
"upperlimit magnitude. Its value is the multiple of final sigma "
"that is reported as the upper-limit");
@@ -1557,7 +1738,7 @@ ui_preparations(struct mkcatalogparams *p)
/* If no columns are requested, then inform the user. */
if(p->columnids==NULL && p->spectrum==0)
error(EXIT_FAILURE, 0, "no measurements requested! Please run again "
- "with `--help' for the possible list of measurements");
+ "with '--help' for the possible list of measurements");
/* Set the actual filenames to use. */
@@ -1585,10 +1766,6 @@ ui_preparations(struct mkcatalogparams *p)
ui_preparations_outnames(p);
- /* Make the tiles that cover each object. */
- ui_one_tile_per_object(p);
-
-
/* If a spectrum is requested, generate the two WCS columns. */
if(p->spectrum)
{
@@ -1599,7 +1776,7 @@ ui_preparations(struct mkcatalogparams *p)
/* Allocate the reference random number generator and seed values. It
will be cloned once for every thread. If the user hasn't called
- `envseed', then we want it to be different for every run, so we need
+ 'envseed', then we want it to be different for every run, so we need
to re-set the seed. */
if(p->upperlimit) ui_preparations_upperlimit(p);
@@ -1612,7 +1789,7 @@ ui_preparations(struct mkcatalogparams *p)
separately (and not using the actual output columns that have the same
values), because playing with the output columns can cause bad
bugs. If the user wants performance, they are encouraged to run
- MakeCatalog with `--noclumpsort' and avoid the whole process all
+ MakeCatalog with '--noclumpsort' and avoid the whole process all
together. */
if(p->clumps && !p->noclumpsort && p->cp.numthreads>1)
{
@@ -1654,9 +1831,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
mkcatalogparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
@@ -1728,16 +1905,20 @@ ui_read_check_inputs_setup(int argc, char *argv[],
struct mkcatalogparams *p)
if(p->subtractsky || p->sky)
{
if(p->sky->size==1)
- printf(" - Sky: %g\n", *((float *)(p->sky->array)) );
+ printf(" - Sky: %g (single value for all pixels)\n",
+ *((float *)(p->sky->array)) );
else
printf(" - Sky: %s (hdu: %s)\n", p->usedskyfile, p->skyhdu);
+ if(p->subtractsky)
+ printf(" - Sky has been subtracted from values internally.\n");
}
if(p->std)
{
tmp = p->variance ? "VAR" : "STD";
if(p->std->size==1)
- printf(" - Sky %s: %g\n", tmp, *((float *)(p->std->array)) );
+ printf(" - Sky %s: %g (single value for all pixels)\n", tmp,
+ *((float *)(p->std->array)) );
else
printf(" - Sky %s: %s (hdu: %s)\n", tmp, p->usedstdfile,
p->stdhdu);
@@ -1825,7 +2006,11 @@ ui_free_report(struct mkcatalogparams *p, struct timeval
*t1)
gal_data_free(p->upmask);
gal_data_free(p->clumps);
gal_data_free(p->objects);
+ if(p->outlabs) free(p->outlabs);
+ gal_list_data_free(p->clumpcols);
+ gal_list_data_free(p->objectcols);
gal_list_data_free(p->specsliceinfo);
+ if(p->outlabsinv) free(p->outlabsinv);
if(p->upcheckout) free(p->upcheckout);
gal_data_array_free(p->tiles, p->numobjects, 0);
@@ -1834,7 +2019,7 @@ ui_free_report(struct mkcatalogparams *p, struct timeval
*t1)
{
/* Note that each element of the array is the first node in a list of
datasets. So we can't free the first one with
- `gal_list_data_free', we'll delete all the nodes after it in the
+ 'gal_list_data_free', we'll delete all the nodes after it in the
loop. */
for(i=0;i<p->numobjects;++i)
{
@@ -1847,7 +2032,7 @@ ui_free_report(struct mkcatalogparams *p, struct timeval
*t1)
/* If the Sky or its STD image were given in tiles, then we defined a
tile structure to deal with them. The initialization of the tile
- structure is checked with its `ndim' element. */
+ structure is checked with its 'ndim' element. */
if(p->cp.tl.ndim) gal_tile_full_free_contents(&p->cp.tl);
/* If an upper limit range warning is necessary, print it here. */
@@ -1861,7 +2046,7 @@ ui_free_report(struct mkcatalogparams *p, struct timeval
*t1)
"input is less than double their length. If the input is taken "
"from a larger dataset, this issue can be solved by using a "
"larger part of it. You can also run MakeCatalog with "
- "`--checkuplim' to see the distribution for a special "
+ "'--checkuplim' to see the distribution for a special "
"object or clump as a table and personally inspect its "
"reliability. \n\n");
diff --git a/bin/mkcatalog/ui.h b/bin/mkcatalog/ui.h
index f4d2f05..572720e 100644
--- a/bin/mkcatalog/ui.h
+++ b/bin/mkcatalog/ui.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -34,6 +34,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
enum program_args_groups
{
UI_GROUP_UPPERLIMIT = GAL_OPTIONS_GROUP_AFTER_COMMON,
+ UI_GROUP_OTHERSETTINGS,
UI_GROUP_COLUMNS_IDS,
UI_GROUP_COLUMNS_POSITION_PIXEL,
UI_GROUP_COLUMNS_POSITION_WCS,
@@ -86,12 +87,15 @@ enum option_keys_enum
UI_KEY_SKYHDU,
UI_KEY_STDHDU,
UI_KEY_WITHCLUMPS,
+ UI_KEY_FORCEREADSTD,
UI_KEY_ZEROPOINT,
+ UI_KEY_SIGMACLIP,
UI_KEY_VARIANCE,
UI_KEY_SUBTRACTSKY,
UI_KEY_SFMAGNSIGMA,
UI_KEY_SFMAGAREA,
UI_KEY_SPECTRUM,
+ UI_KEY_INBETWEENINTS,
UI_KEY_UPMASKFILE,
UI_KEY_UPMASKHDU,
UI_KEY_UPNUM,
@@ -100,9 +104,12 @@ enum option_keys_enum
UI_KEY_UPNSIGMA,
UI_KEY_CHECKUPLIM,
UI_KEY_NOCLUMPSORT,
+ UI_KEY_FRACMAX,
UI_KEY_OBJID, /* Catalog columns. */
UI_KEY_IDINHOSTOBJ,
+ UI_KEY_AREAARCSEC2,
+ UI_KEY_SURFACEBRIGHTNESS,
UI_KEY_AREAXY,
UI_KEY_CLUMPSAREA,
UI_KEY_WEIGHTAREA,
@@ -111,6 +118,14 @@ enum option_keys_enum
UI_KEY_GEOX,
UI_KEY_GEOY,
UI_KEY_GEOZ,
+ UI_KEY_MINVX,
+ UI_KEY_MAXVX,
+ UI_KEY_MINVY,
+ UI_KEY_MAXVY,
+ UI_KEY_MINVZ,
+ UI_KEY_MAXVZ,
+ UI_KEY_MINVNUM,
+ UI_KEY_MAXVNUM,
UI_KEY_CLUMPSX,
UI_KEY_CLUMPSY,
UI_KEY_CLUMPSZ,
@@ -140,6 +155,7 @@ enum option_keys_enum
UI_KEY_BRIGHTNESSNORIVER,
UI_KEY_MEAN,
UI_KEY_MEDIAN,
+ UI_KEY_MAXIMUM,
UI_KEY_CLUMPSMAGNITUDE,
UI_KEY_UPPERLIMIT,
UI_KEY_UPPERLIMITONESIGMA,
@@ -150,10 +166,28 @@ enum option_keys_enum
UI_KEY_RIVERNUM,
UI_KEY_SKY,
UI_KEY_STD,
+ UI_KEY_SIGCLIPNUMBER,
+ UI_KEY_SIGCLIPMEDIAN,
+ UI_KEY_SIGCLIPMEAN,
+ UI_KEY_SIGCLIPSTD,
UI_KEY_GEOSEMIMAJOR,
UI_KEY_GEOSEMIMINOR,
UI_KEY_GEOAXISRATIO,
UI_KEY_GEOPOSITIONANGLE,
+ UI_KEY_FWHM,
+ UI_KEY_HALFMAXAREA,
+ UI_KEY_HALFMAXRADIUS,
+ UI_KEY_HALFMAXSUM,
+ UI_KEY_HALFMAXSB,
+ UI_KEY_HALFSUMAREA,
+ UI_KEY_HALFSUMSB,
+ UI_KEY_HALFSUMRADIUS,
+ UI_KEY_FRACMAXSUM1,
+ UI_KEY_FRACMAXSUM2,
+ UI_KEY_FRACMAXAREA1,
+ UI_KEY_FRACMAXAREA2,
+ UI_KEY_FRACMAXRADIUS1,
+ UI_KEY_FRACMAXRADIUS2,
};
diff --git a/bin/mkcatalog/upperlimit.c b/bin/mkcatalog/upperlimit.c
index 7e3c5ad..b1b27bc 100644
--- a/bin/mkcatalog/upperlimit.c
+++ b/bin/mkcatalog/upperlimit.c
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -63,7 +63,7 @@ upperlimit_make_clump_tiles(struct mkcatalog_passparams *pp)
/* Initialize the minimum and maximum position for each tile/clump. So,
we'll initialize the minimum coordinates to the maximum possible
- `size_t' value (in `GAL_BLANK_SIZE_T') and the maximums to zero. */
+ 'size_t' value (in 'GAL_BLANK_SIZE_T') and the maximums to zero. */
for(i=0;i<pp->clumpsinobj;++i)
for(d=0;d<ndim;++d)
{
@@ -173,7 +173,7 @@ upperlimit_random_range(struct mkcatalog_passparams *pp,
gal_data_t *tile,
just use the full possible range. */
if( p->uprange && p->uprange[d] )
{
- /* Set the minimum of the random range. Since `size_t' is always
+ /* Set the minimum of the random range. Since 'size_t' is always
positive, to make sure the difference isn't negative, we need
to convert them to integer first. */
if( (int)coord[d] - ((int)p->uprange[d])/2 > 0 )
@@ -200,7 +200,7 @@ upperlimit_random_range(struct mkcatalog_passparams *pp,
gal_data_t *tile,
- (dsize[d] - tile->dsize[d]) );
}
- /* `minadd' and `maxadd' were defined to account for the removed
+ /* 'minadd' and 'maxadd' were defined to account for the removed
smaller range when an object is on the edge. Their role is to
add to the other side of the range as much as possible when
one side is decreased on an edge. */
@@ -215,7 +215,7 @@ upperlimit_random_range(struct mkcatalog_passparams *pp,
gal_data_t *tile,
/* We are positioning the FIRST pixel of the tile, not the
center. So, the minimum possible value is zero, and in order
to not push out of the image, the maximum is the
- `tile->dsize[d]' away from the edge. */
+ 'tile->dsize[d]' away from the edge. */
min[d]=0;
max[d]=dsize[d]-tile->dsize[d]-1;
}
@@ -249,7 +249,7 @@ upperlimit_random_position(struct mkcatalog_passparams *pp,
gal_data_t *tile,
size_t r;
struct mkcatalogparams *p=pp->p;
- /* `gsl_rng_get' returns an inclusive value between the minimum and
+ /* 'gsl_rng_get' returns an inclusive value between the minimum and
maximum of the particular generator. It may happen that the labeled
region extends the full range of a dimension. In that case, the only
possible starting point would be 0. */
@@ -311,7 +311,7 @@ upperlimit_write_comments(struct mkcatalogparams *p,
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
"address the problem. The value %zu is not recognized for "
- "`p->input->ndim'", __func__, PACKAGE_BUGREPORT,
+ "'p->input->ndim'", __func__, PACKAGE_BUGREPORT,
p->objects->ndim);
}
gal_list_str_add(comments, str, 0);
@@ -401,11 +401,11 @@ upperlimit_write_check(struct mkcatalogparams *p,
gal_list_sizet_t *check_x,
"Z-axis position of random footprint's first pixel.");
s=gal_data_alloc(sarr, GAL_TYPE_FLOAT32, 1, &num, NULL, 0, p->cp.minmapsize,
p->cp.quietmmap, "RANDOM_SUM",
- p->values->unit ? p->values->unit : "input-units",
+ p->values->unit ? p->values->unit : MKCATALOG_NO_UNIT,
"Sum of pixel values over random footprint.");
- /* If `size_t' isn't 32-bit on this system, then convert the unsigned
+ /* If 'size_t' isn't 32-bit on this system, then convert the unsigned
64-bit values to 32-bit because the FITS table format doesn't
recognize 64-bit integers.*/
if( GAL_TYPE_SIZE_T != GAL_TYPE_UINT32 )
@@ -446,7 +446,7 @@ upperlimit_write_check(struct mkcatalogparams *p,
gal_list_sizet_t *check_x,
if(check_z) { y->next=z; z->next=s; }
else { y->next=s; }
gal_list_str_reverse(&comments);
- gal_table_write(x, comments, p->cp.tableformat, p->upcheckout,
+ gal_table_write(x, NULL, comments, p->cp.tableformat, p->upcheckout,
"UPPERLIMIT_CHECK", 0);
/* Inform the user. */
@@ -513,7 +513,7 @@ upperlimit_measure(struct mkcatalog_passparams *pp, int32_t
clumplab,
col = clumplab ? CCOL_UPPERLIMIT_S : OCOL_UPPERLIMIT_S;
o[col] = scarr[3];
- /* sigma multiplied by `upnsigma'. */
+ /* sigma multiplied by 'upnsigma'. */
col = clumplab ? CCOL_UPPERLIMIT_B : OCOL_UPPERLIMIT_B;
o[col] = scarr[3] * p->upnsigma;
@@ -611,8 +611,8 @@ upperlimit_one_tile(struct mkcatalog_passparams *pp,
gal_data_t *tile,
upperlimit_random_range(pp, tile, min, max, clumplab);
- /* `se_inc' is just used temporarily, the important thing here is
- `st_oo'. */
+ /* 'se_inc' is just used temporarily, the important thing here is
+ 'st_oo'. */
st_oo = ( clumplab
? gal_tile_start_end_ind_inclusive(tile, p->objects, se_inc)
: pp->st_o );
@@ -632,7 +632,7 @@ upperlimit_one_tile(struct mkcatalog_passparams *pp,
gal_data_t *tile,
p->objects->type);
/* Starting and ending coordinates for this random position, note
- that in `pp' we have the starting and ending coordinates of the
+ that in 'pp' we have the starting and ending coordinates of the
actual tile. */
increment = 0;
num_increment = 1;
@@ -689,7 +689,7 @@ upperlimit_one_tile(struct mkcatalog_passparams *pp,
gal_data_t *tile,
/* Further processing is only necessary if this random tile was fully
- parsed. If it was, we must reset `nfailed' to zero again. */
+ parsed. If it was, we must reset 'nfailed' to zero again. */
if(continueparse)
{
nfailed=0;
@@ -717,7 +717,7 @@ upperlimit_one_tile(struct mkcatalog_passparams *pp,
gal_data_t *tile,
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s "
- "to fix the problem. `ndim' value of %zu is not "
+ "to fix the problem. 'ndim' value of %zu is not "
"recognized", __func__, PACKAGE_BUGREPORT, ndim);
}
gal_list_f32_add(&check_s, continueparse ? sum : NAN);
@@ -784,7 +784,7 @@ upperlimit_calculate(struct mkcatalog_passparams *pp)
&& p->checkuplim[1] != GAL_BLANK_INT32
&& p->checkuplim[1] > pp->clumpsinobj )
error(EXIT_FAILURE, 0, "object %d has %zu clumps, but an upperlimit "
- "check table (using the `--checkuplim' option) has been "
+ "check table (using the '--checkuplim' option) has been "
"requested for clump %d", pp->object, pp->clumpsinobj,
p->checkuplim[1]);
diff --git a/bin/mkcatalog/upperlimit.h b/bin/mkcatalog/upperlimit.h
index b25589d..666c3a0 100644
--- a/bin/mkcatalog/upperlimit.h
+++ b/bin/mkcatalog/upperlimit.h
@@ -5,7 +5,7 @@ MakeCatalog is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mknoise/Makefile.am b/bin/mknoise/Makefile.am
index 555f7fd..1b22a4c 100644
--- a/bin/mknoise/Makefile.am
+++ b/bin/mknoise/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astmknoise
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmknoise_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astmknoise_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astmknoise_SOURCES = main.c ui.c mknoise.c
@@ -41,7 +40,6 @@ EXTRA_DIST = main.h authors-cite.h args.h ui.h mknoise.h
-
## The configuration file (distribute and install).
## NOTE: the man page is created in doc/Makefile.am
dist_sysconf_DATA = astmknoise.conf
diff --git a/bin/mknoise/args.h b/bin/mknoise/args.h
index 719a561..4c5f262 100644
--- a/bin/mknoise/args.h
+++ b/bin/mknoise/args.h
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -64,7 +64,7 @@ struct argp_option program_options[] =
0,
"Fixed background magnitude for whole input.",
GAL_OPTIONS_GROUP_INPUT,
- &p->background_mag,
+ &p->background,
GAL_TYPE_FLOAT64,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
@@ -83,6 +83,19 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+ {
+ "bgisbrightness",
+ UI_KEY_BGISBRIGHTNESS,
+ 0,
+ 0,
+ "Background is brightness, not magnitude.",
+ GAL_OPTIONS_GROUP_OPERATING_MODE,
+ &p->bgisbrightness,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
diff --git a/bin/mknoise/astmknoise.conf b/bin/mknoise/astmknoise.conf
index 5748e2f..b28237f 100644
--- a/bin/mknoise/astmknoise.conf
+++ b/bin/mknoise/astmknoise.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astmknoise # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -20,9 +20,6 @@
# warranty.
# Input:
- background -10.00
- instrumental 0.000
- zeropoint 0.00
# Output:
type float32
diff --git a/bin/mknoise/authors-cite.h b/bin/mknoise/authors-cite.h
index ba297a8..47e931e 100644
--- a/bin/mknoise/authors-cite.h
+++ b/bin/mknoise/authors-cite.h
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/mknoise/main.c b/bin/mknoise/main.c
index 5e5ae13..373b49d 100644
--- a/bin/mknoise/main.c
+++ b/bin/mknoise/main.c
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mknoise/main.h b/bin/mknoise/main.h
index c315b4b..48a2326 100644
--- a/bin/mknoise/main.h
+++ b/bin/mknoise/main.h
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2016-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -47,12 +47,12 @@ struct mknoiseparams
double sigma; /* Total noise sigma (ignoring others). */
double instrumental; /* Standard deviation constants. */
double zeropoint; /* Zeropoint magnitude of image. */
- double background_mag; /* Background in magnitudes. */
+ double background; /* Background in magnitudes. */
+ uint8_t bgisbrightness; /* Background is brightness, not magnitude. */
uint8_t envseed; /* ==1, generate a random seed. */
/* Internal */
gal_data_t *input; /* Input image data in double precision. */
- double background; /* Background in units of brightness. */
gsl_rng *rng; /* Main instance of random number generator.*/
const char *rng_name; /* The type/name of the Random number gen. */
unsigned long rng_seed; /* Seed of Random number generator. */
diff --git a/bin/mknoise/mknoise.c b/bin/mknoise/mknoise.c
index 27c5735..6731ed7 100644
--- a/bin/mknoise/mknoise.c
+++ b/bin/mknoise/mknoise.c
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -35,6 +35,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gsl/gsl_randist.h> /* To make noise. */
#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
#include "main.h"
@@ -54,53 +55,66 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
void
convertsaveoutput(struct mknoiseparams *p)
{
- char keyname1[FLEN_KEYWORD];
+ double tmp;
+ char *keyname;
gal_fits_list_key_t *headers=NULL;
- char keyname2[FLEN_KEYWORD], keyname3[FLEN_KEYWORD];
- char keyname4[FLEN_KEYWORD], keyname5[FLEN_KEYWORD];
-
/* Add the proper information to the header of the output: */
gal_fits_key_write_filename("INF", p->inputname, &headers, 0);
- if( !isnan(p->background_mag) )
+ if( !isnan(p->background) )
{
- strcpy(keyname1, "BCKGRND");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname1, 0,
- &p->background_mag, 0, "Background "
- "value (in magnitude) for noise.",
- 0, NULL);
- strcpy(keyname2, "BZRPNT");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname2, 0,
- &p->zeropoint, 0,
- "Zeropoint magnitude of image.", 0, NULL);
- strcpy(keyname3, "INSTRU");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname3, 0,
- &p->instrumental, 0,
- "Instrumental noise in units of flux.",
- 0, NULL);
+ gal_checkset_allocate_copy("BCKGRND", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname, 1,
+ &p->background, 0,
+ "Background value for Poisson noise.",
+ 0, NULL, 0);
+ if( !isnan(p->zeropoint) )
+ {
+ tmp=-2.5 * log10(p->background) + p->zeropoint;
+ gal_checkset_allocate_copy("BCKGMAG", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname, 1,
+ &tmp, 0,
+ "Background value in magnitudes",
+ 0, NULL, 0);
+ gal_checkset_allocate_copy("BCKGZP", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname, 1,
+ &p->zeropoint, 0,
+ "Zeropoint for interpreting magnitudes.",
+ 0, NULL, 0);
+ }
+ if( !isnan(p->instrumental) )
+ {
+ gal_checkset_allocate_copy("INSTRU", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname, 1,
+ &p->instrumental, 0,
+ "Instrumental noise in units of flux.",
+ 0, NULL, 0);
+ }
}
else
{
- strcpy(keyname1, "SIGMA");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname1, 0,
- &p->sigma, 0, "Total noise sigma", 0, NULL);
+ gal_checkset_allocate_copy("SIGMA", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_FLOAT64, keyname, 1,
+ &p->sigma, 0, "Total noise sigma", 0,
+ NULL, 0);
}
- strcpy(keyname4, "RNGTYPE");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_STRING, keyname4, 0,
+ gal_checkset_allocate_copy("RNGTYPE", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_STRING, keyname, 1,
(void *)(p->rng_name), 0,
"Random number generator (by GSL) type.",
- 0, NULL);
- strcpy(keyname5, "RNGSEED");
- gal_fits_key_list_add_end(&headers, GAL_TYPE_ULONG, keyname5, 0,
+ 0, NULL, 0);
+ gal_checkset_allocate_copy("RNGSEED", &keyname);
+ gal_fits_key_list_add_end(&headers, GAL_TYPE_ULONG, keyname, 1,
&p->rng_seed, 0,
"Random number generator (by GSL) seed.",
- 0, NULL);
+ 0, NULL, 0);
- /* Save the output: */
+ /* Save the output: first convert it to the desired type, */
+ if(p->input->name) { free(p->input->name); p->input->name=NULL; }
p->input=gal_data_copy_to_new_type_free(p->input, p->cp.type);
p->input->name="NOISED";
gal_fits_img_write(p->input, p->cp.output, headers, PROGRAM_NAME);
- p->input->name=NULL;
+ p->input->name=NULL; /* because we didn't allocate it. */
/* Write the configuration keywords. */
gal_fits_key_write_filename("input", p->inputname, &p->cp.okeys, 1);
@@ -115,8 +129,10 @@ convertsaveoutput(struct mknoiseparams *p)
void
mknoise(struct mknoiseparams *p)
{
- double *d, *df, background=p->background;
- double instpowtwo = p->instrumental*p->instrumental;
+ double *d, *df, back=p->background;
+ double inst = ( isnan(p->instrumental)
+ ? 0.0f
+ : p->instrumental*p->instrumental );
/* Add the noise: */
df=(d=p->input->array)+p->input->size;
@@ -129,9 +145,7 @@ mknoise(struct mknoiseparams *p)
else
{
do
- *d += ( background
- + gsl_ran_gaussian(p->rng,
- sqrt( instpowtwo + background + *d )) );
+ *d += back + gsl_ran_gaussian(p->rng, sqrt( inst + back + *d ));
while(++d<df);
}
diff --git a/bin/mknoise/mknoise.h b/bin/mknoise/mknoise.h
index 5d144be..dc10361 100644
--- a/bin/mknoise/mknoise.h
+++ b/bin/mknoise/mknoise.h
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index b1f775d..f39bbc9 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -116,7 +116,8 @@ ui_initialize_options(struct mknoiseparams *p,
/* Initialize options for this program. */
p->sigma = NAN;
p->zeropoint = NAN;
- p->background_mag = NAN;
+ p->background = NAN;
+ p->instrumental = NAN;
/* Modify common options. */
@@ -158,18 +159,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct mknoiseparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -217,23 +218,46 @@ parse_opt(int key, char *arg, struct argp_state *state)
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct mknoiseparams *p)
{
- /* At leaset one of `--sigma' or `--background' are necessary. */
- if( isnan(p->sigma) && isnan(p->background_mag) )
- error(EXIT_FAILURE, 0, "at least one of `--sigma' or `--background' "
- "must be given to identify the noise level");
-
-
- /* If a background magnitude is given (and the user hasn't given a
- `--sigma'), the zeropoint is necessary. */
- if( isnan(p->sigma) && !isnan(p->background_mag) && isnan(p->zeropoint) )
- error(EXIT_FAILURE, 0, "no zeropoint magnitude given. When the noise is "
- "identified by the background magnitude, a zeropoint magnitude "
- "is mandatory. Please use the `--zeropoint' option to specify "
- "a zeropoint magnitude");
+ /* At leaset one of '--sigma' or '--background' are necessary. */
+ if( isnan(p->sigma) && isnan(p->background) )
+ error(EXIT_FAILURE, 0, "noise not defined: please define the noise "
+ "level with either '--sigma' (for a fixed noise STD for all "
+ "the pixels, irrespective of their value) or '--background' "
+ "(to use in a Poisson noise model, where the noise will differ "
+ "based on pixel value)");
+
+
+ /* If a background magnitude is given ('--bgbrightness' hasn't been
+ called), the zeropoint is necessary. */
+ if( !isnan(p->background) )
+ {
+ /* Make sure that the background can be interpretted properly. */
+ if( p->bgisbrightness==0 && isnan(p->zeropoint) )
+ error(EXIT_FAILURE, 0, "missing background information. When the "
+ "noise is identified by the background, a zeropoint magnitude "
+ "is mandatory. Please use the '--zeropoint' option to specify "
+ "a zeropoint magnitude. Alternatively, if your background value "
+ "is brightness (which is in linear scale and doesn't need a "
+ "zeropoint), please use '--bgisbrightness'");
+
+ /* If the background is in units of magnitudes, convert it to
+ brightness. */
+ if( p->bgisbrightness==0 )
+ p->background = pow(10, (p->zeropoint-p->background)/2.5f);
+
+ /* Make sure that the background is larger than 1 (where Poisson
+ noise is actually defined). */
+ if( p->background < 1 )
+ error(EXIT_FAILURE, 0, "background value is smaller than 1. "
+ "Poisson noise is only defined on a positive distribution "
+ "with values larger than 1. You can use the '--sigma' "
+ "option to add a fixed noise level (with any positive value) "
+ "to any pixel.");
+ }
}
@@ -249,8 +273,8 @@ ui_check_options_and_arguments(struct mknoiseparams *p)
{
if( gal_fits_name_is_fits(p->inputname) && p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified. When the input is a FITS "
- "file, a HDU must also be specified, you can use the `--hdu' "
- "(`-h') option and give it the HDU number (starting from "
+ "file, a HDU must also be specified, you can use the '--hdu' "
+ "('-h') option and give it the HDU number (starting from "
"zero), extension name, or anything acceptable by CFITSIO");
}
@@ -305,16 +329,6 @@ ui_preparations(struct mknoiseparams *p)
p->cp.output=gal_checkset_automatic_output(&p->cp, p->inputname,
"_noised.fits");
-
- /* Convert the background value from magnitudes to flux. Note that
- magnitudes are actually calculated from the ratio of brightness, not
- flux. But in the context of MakeNoise where everything is done on
- pixels independently, brightness and flux are the same (flux is
- multiplied by the area of one pixel (=1) to give brightness).*/
- if( !isnan(p->background_mag) )
- p->background=pow(10, (p->zeropoint-p->background_mag)/2.5f);
-
-
/* Allocate the random number generator: */
p->rng=gal_checkset_gsl_rng(p->envseed, &p->rng_name, &p->rng_seed);
}
@@ -348,9 +362,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
mknoiseparams *p)
char message[GAL_TIMING_VERB_MSG_LENGTH_V];
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/mknoise/ui.h b/bin/mknoise/ui.h
index b21e0e4..a2a5684 100644
--- a/bin/mknoise/ui.h
+++ b/bin/mknoise/ui.h
@@ -5,7 +5,7 @@ MakeNoise is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,16 +33,17 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* Available letters for short options:
a c d f g j k l m n p r t u v w x y
- A B C E G H J L O Q R W X Y
+ A C E G H J L O Q R W X Y
*/
enum option_keys_enum
{
/* With short-option version. */
- UI_KEY_SIGMA = 's',
- UI_KEY_INSTRUMENTAL = 'i',
- UI_KEY_BACKGROUND = 'b',
- UI_KEY_ZEROPOINT = 'z',
- UI_KEY_ENVSEED = 'e',
+ UI_KEY_SIGMA = 's',
+ UI_KEY_INSTRUMENTAL = 'i',
+ UI_KEY_BACKGROUND = 'b',
+ UI_KEY_ZEROPOINT = 'z',
+ UI_KEY_ENVSEED = 'e',
+ UI_KEY_BGISBRIGHTNESS = 'B',
/* Only with long version (start with a value 1000, the rest will be set
automatically). */
diff --git a/bin/mkprof/Makefile.am b/bin/mkprof/Makefile.am
index 884a270..ca0a5c8 100644
--- a/bin/mkprof/Makefile.am
+++ b/bin/mkprof/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2015-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astmkprof
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astmkprof_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astmkprof_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
astmkprof_SOURCES = main.c ui.c mkprof.c oneprofile.c profiles.c
diff --git a/bin/mkprof/args.h b/bin/mkprof/args.h
index be1039c..c0d05fe 100644
--- a/bin/mkprof/args.h
+++ b/bin/mkprof/args.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,7 +33,7 @@ struct argp_option program_options[] =
{
"background",
UI_KEY_BACKGROUND,
- "STR",
+ "FITS",
0,
"A background image to make the profiles on.",
GAL_OPTIONS_GROUP_INPUT,
@@ -83,6 +83,32 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET,
ui_parse_kernel
},
+ {
+ "customtable",
+ UI_KEY_CUSTOMTABLE,
+ "FITS/TXT",
+ 0,
+ "File for 'custom' profile.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->customname,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+ {
+ "customtablehdu",
+ UI_KEY_CUSTOMTABLEHDU,
+ "INT/STR",
+ 0,
+ "HDU of table given to '--customtable'.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->customhdu,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
@@ -169,7 +195,7 @@ struct argp_option program_options[] =
UI_KEY_MODE,
"STR",
0,
- "Mode of `--ccol': `img' or `wcs'.",
+ "Mode of '--ccol': 'img' or 'wcs'.",
UI_GROUP_PROFILES,
&p->mode,
GAL_TYPE_STRING,
@@ -342,7 +368,7 @@ struct argp_option program_options[] =
{
0, 0, 0, 0,
- "Columns, by info (see `--searchin'), or number (starting from 1):",
+ "Columns, by info (see '--searchin'), or number (starting from 1):",
UI_GROUP_CATALOG
},
{
@@ -364,7 +390,8 @@ struct argp_option program_options[] =
"STR/INT",
0,
"sersic (1), moffat (2), gaussian (3), point (4), "
- "flat (5), circumference (6), distance (7).",
+ "flat (5), circumference (6), distance (7), "
+ "radial-table (8)",
UI_GROUP_CATALOG,
&p->fcol,
GAL_TYPE_STRING,
@@ -560,7 +587,7 @@ struct argp_option program_options[] =
UI_KEY_CUNIT,
"STR[, ... ]",
0,
- "Units of the WCS coordinates (e.g., `deg').",
+ "Units of the WCS coordinates (e.g., 'deg').",
UI_GROUP_WCS,
&p->cunit,
GAL_TYPE_FLOAT64,
diff --git a/bin/mkprof/astmkprof-3d.conf b/bin/mkprof/astmkprof-3d.conf
index 9ccb1d0..d6f07a3 100644
--- a/bin/mkprof/astmkprof-3d.conf
+++ b/bin/mkprof/astmkprof-3d.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,6 +12,8 @@
# $ info astmkprof # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
+# Copyright (C) 2019-2021, Free Software Foundation, Inc.
+#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any
@@ -54,4 +56,4 @@
cdelt 0.2/3600,0.2/3600,1.25e-10
pc -1,0,0,0,1,0,0,0,1
cunit deg,deg,m
- ctype RA---TAN,DEC--TAN,AWAV
\ No newline at end of file
+ ctype RA---TAN,DEC--TAN,AWAV
diff --git a/bin/mkprof/astmkprof.conf b/bin/mkprof/astmkprof.conf
index 53c05e8..371b534 100644
--- a/bin/mkprof/astmkprof.conf
+++ b/bin/mkprof/astmkprof.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astmkprof # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -21,6 +21,7 @@
#input
backhdu 1
+ customtablehdu 1
# Output:
mergedsize 1000,1000
diff --git a/bin/mkprof/authors-cite.h b/bin/mkprof/authors-cite.h
index 777969a..ec51735 100644
--- a/bin/mkprof/authors-cite.h
+++ b/bin/mkprof/authors-cite.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/mkprof/main.c b/bin/mkprof/main.c
index 630b415..66c618d 100644
--- a/bin/mkprof/main.c
+++ b/bin/mkprof/main.c
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkprof/main.h b/bin/mkprof/main.h
index 832b1c6..7440f8c 100644
--- a/bin/mkprof/main.h
+++ b/bin/mkprof/main.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -66,6 +66,7 @@ enum profile_types
PROFILE_FLAT, /* Flat profile. */
PROFILE_CIRCUMFERENCE, /* Circumference profile. */
PROFILE_DISTANCE, /* Elliptical radius of pixel. */
+ PROFILE_CUSTOM, /* Radial prof. in file/table. */
PROFILE_MAXIMUM_CODE, /* Just for a sanity check. */
};
@@ -114,6 +115,8 @@ struct mkprofparams
char *backname; /* Name of background image file name. */
char *catname; /* Name of catalog of parameters. */
char *backhdu; /* HDU of background image. */
+ char *customname; /* Table to use for radial profile. */
+ char *customhdu; /* HDU of table to use for radial profile. */
size_t *dsize; /* Size of the output image. */
uint8_t clearcanvas; /* Pixels in background image set to zero. */
gal_data_t *kernel; /* Parameters to define a kernel. */
@@ -188,10 +191,12 @@ struct mkprofparams
char *wcsheader; /* The WCS header information for main img. */
int wcsnkeyrec; /* The number of keywords in the WCS header.*/
char *mergedimgname; /* Name of merged image. */
+ gal_data_t *custom; /* Table containing custom values. */
+ double customregular[2]; /* Non-NaN if input table is regular. */
int nwcs; /* for WCSLIB: no. coord. representations. */
struct wcsprm *wcs; /* WCS information for this dataset. */
- size_t ndim; /* Number of dimensions (for `nomerged'). */
- /* We can't put it in `out' because it is */
+ size_t ndim; /* Number of dimensions (for 'nomerged'). */
+ /* We can't put it in 'out' because it is */
/* meaning ful there. */
};
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index 2d30e99..60d188b 100644
--- a/bin/mkprof/mkprof.c
+++ b/bin/mkprof/mkprof.c
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -78,7 +78,7 @@ builtqueue_addempty(struct builtqueue **bq)
errno=0;
tbq=malloc(sizeof *tbq);
if(tbq==NULL)
- error(EXIT_FAILURE, 0, "%s: allocating %zu bytes for `tbq'",
+ error(EXIT_FAILURE, 0, "%s: allocating %zu bytes for 'tbq'",
__func__, sizeof *tbq);
/* Initialize the values (same order as in structure definition). */
@@ -134,8 +134,8 @@ saveindividual(struct mkonthread *mkp)
char *filename, *jobname, *outdir=p->outdir;
- /* Write the name and remove a similarly named file when the `--kernel'
- option wasn't called. If `--kernel' is called, then we should just use
+ /* Write the name and remove a similarly named file when the '--kernel'
+ option wasn't called. If '--kernel' is called, then we should just use
the final merged filename. */
if(p->kernel)
filename=p->mergedimgname;
@@ -154,7 +154,7 @@ saveindividual(struct mkonthread *mkp)
else
{
/* Allocate space for the corrected crpix and fill it in. Both
- `crpix' and `fpixel_i' are in FITS order. */
+ 'crpix' and 'fpixel_i' are in FITS order. */
crpix=gal_pointer_allocate(GAL_TYPE_FLOAT64, ndim, 0, __func__,
"crpix");
for(i=0;i<ndim;++i)
@@ -171,95 +171,98 @@ saveindividual(struct mkonthread *mkp)
/* Write profile settings into the FITS file. */
gal_fits_key_list_add(&keys, GAL_TYPE_STRING, "PROFILE", 0,
ui_profile_name_write(mkp->func), 0,
- "Radial function", 0, NULL);
+ "Radial function", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT64, "XCENTER", 0,
&p->x[id], 0, "Center of profile in catalog "
- "(FITS axis 1)", 0, NULL);
+ "(FITS axis 1)", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT64, "YCENTER", 0,
&p->y[id], 0, "Center of profile in catalog "
- "(FITS axis 2)", 0, NULL);
+ "(FITS axis 2)", 0, NULL, 0);
if(ndim==3)
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT64, "ZCENTER", 0,
&p->z[id], 0, "Center of profile in catalog "
- "(FITS axis 3)", 0, NULL);
+ "(FITS axis 3)", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "RADIUS", 0,
&p->r[id], 0, "Radial parameter in catalog",
- 0, NULL);
+ 0, NULL, 0);
if( mkp->func==PROFILE_SERSIC || mkp->func==PROFILE_MOFFAT )
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "PINDEX", 0,
&p->r[id], 0, "Index (Sersic or Moffat) of profile"
- "in catalog", 0, NULL);
+ "in catalog", 0, NULL, 0);
if(ndim==2)
{
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "PA_DEG", 0,
&p->p1[id], 0, "Position angle of profile in "
- "catalog", 0, "deg");
+ "catalog", 0, "deg", 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "AXISRATIO", 0,
&p->q1[id], 0, "Axis ratio of profile in catalog",
- 0, NULL);
+ 0, NULL, 0);
}
else
{
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "PA1_DEG", 0,
&p->p1[id], 0, "First X-Z-X Euler angle in 3D", 0,
- "deg");
+ "deg", 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "PA2_DEG", 0,
&p->p2[id], 0, "Second X-Z-X Euler angle in 3D", 0,
- "deg");
+ "deg", 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "PA3_DEG", 0,
&p->p3[id], 0, "Third X-Z-X Euler angle in 3D", 0,
- "deg");
+ "deg", 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "AXISRATIO1", 0,
&p->q1[id], 0, "Axis ratio along second dim",
- 0, NULL);
+ 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "AXISRATIO2", 0,
&p->q2[id], 0, "Axis ratio along third dim",
- 0, NULL);
+ 0, NULL, 0);
}
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MAGNITUDE", 0,
&p->m[id], 0, "Magnitude of profile in catalog",
- 0, NULL);
+ 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "TRUNCATION", 0,
&p->t[id], 0, "Truncation of profile in catalog",
- 0, NULL);
+ 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_STRING, "RNGNAME", 0,
(void *)(p->rng_name), 0,
- "Name of random number generator", 0, NULL);
+ "Name of random number generator", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_ULONG, "RNGSEED", 0,
&mkp->rng_seed, 0, "Seed of random number generator",
- 0, NULL);
+ 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_SIZE_T, "NUMRANDOM", 0,
&p->numrandom, 0,
- "Number of random points in central pixels", 0, NULL);
+ "Number of random points in central pixels", 0,
+ NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "TOLERANCE", 0,
&p->tolerance, 0,
"Tolerance level to stop random integration",
- 0, NULL);
+ 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_STRING, "MODE", 0,
p->mode==MKPROF_MODE_IMG?"img":"wcs", 0,
- "Coordinates in image or WCS units", 0, NULL);
+ "Coordinates in image or WCS units", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_UINT8, "OVERSAMPLE", 0,
- &p->oversample, 0, "Oversampling factor", 0, NULL);
+ &p->oversample, 0, "Oversampling factor", 0,
+ NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_UINT8, "TUNITINP", 0,
&p->tunitinp, 0, "Truncation is in units of pixels, "
- "not radius", 0, NULL);
+ "not radius", 0, NULL, 0);
if( !isnan(p->zeropoint) )
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "ZEROPOINT", 0,
- &p->zeropoint, 0, "Zeropoint magnitude", 0, NULL);
+ &p->zeropoint, 0, "Zeropoint magnitude", 0,
+ NULL, 0);
if( mkp->func==PROFILE_CIRCUMFERENCE )
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "CIRCUMWIDTH", 0,
&p->circumwidth, 0, "Width of circumference "
- "(inward) profiles", 0, NULL);
+ "(inward) profiles", 0, NULL, 0);
if( mkp->func==PROFILE_FLAT || mkp->func==PROFILE_CIRCUMFERENCE )
gal_fits_key_list_add(&keys, GAL_TYPE_UINT8, "MFORFLATPIX", 0,
&p->mforflatpix, 0, "Magnitude is flat pixel "
- "value", 0, NULL);
+ "value", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_UINT8, "MCOLISBRIGHTNESS", 0,
&p->mcolisbrightness, 0, "Catalog's magnitude is "
- "actually brightness", 0, NULL);
+ "actually brightness", 0, NULL, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_UINT8, "MAGATPEAK", 0,
&p->magatpeak, 0, "Magnitude is for peak pixel, "
- "not full profile", 0, NULL);
+ "not full profile", 0, NULL, 0);
gal_fits_key_list_reverse(&keys);
gal_fits_key_write_config(&keys, "Profile configuration", "PROFILE-CONFIG",
@@ -345,7 +348,7 @@ mkprof_build_single(struct mkonthread *mkp, long *fpixel_i,
long *lpixel_i,
overlapping region. */
if(p->out)
{
- /* Note that `fpixel_i' and `lpixel_o' were in the un-oversampled
+ /* Note that 'fpixel_i' and 'lpixel_o' were in the un-oversampled
image, they are also in the FITS coordinates. */
for(i=0;i<ndim;++i)
{
@@ -413,10 +416,10 @@ mkprof_add_built_to_write_queue(struct mkonthread *mkp,
p->bq=ibq;
/* If the list was empty when you locked the mutex, then either
- `mkprof_write` is waiting behind a condition variable for you to
+ 'mkprof_write' is waiting behind a condition variable for you to
fill it up or not (either it hasn't got to setting the condition
variable yet (this function locked the mutex before
- `mkprof_write`) or it just got the list to be made and is busy
+ 'mkprof_write') or it just got the list to be made and is busy
writing the arrays in the output). In either case,
pthread_cond_signal will work. */
if((*fbq)->next==NULL)
@@ -457,13 +460,13 @@ mkprof_add_built_to_write_queue(struct mkonthread *mkp,
About the Central x and y of each profile:
The user has asked for the profile to be built on the coordinates
- (real numbers) of `x` and `y` in an output image in the FITS
+ (real numbers) of 'x' and 'y' in an output image in the FITS
format. We are building the full image for each galaxy separately
in an array with an odd number of sides which maybe oversampled.
In the FITS format, the pixel centers have an integer value. So for
example in 1D, a pixel whose center value is 10.00 covers the area
- of: [9.5,10.5). We want the fractional part of `x` (don't forget,
+ of: [9.5,10.5). We want the fractional part of 'x' (don't forget,
this example is 1D) to be in the central pixel of this separate
array (with odd sides) that we will be building.
@@ -489,19 +492,19 @@ mkprof_build(void *inparam)
/* Make each profile that was specified for this thread. */
for(i=0; mkp->indexs[i]!=GAL_BLANK_SIZE_T; ++i)
{
- /* Create a new builtqueue element with all the information. `fbq'
- will be used when we want to add `ibq' to `p->bq'. It is defined
- so we don't have to waste time traversing the `ibq'. Its
- characteristic compared to the other elements of `ibq' is that
- `fbq->next==NULL'. So to add ibq to p->bq, we just have to set
- `fbq->next=p->bq' and then set `p->bq' to `ibq'.*/
+ /* Create a new builtqueue element with all the information. 'fbq'
+ will be used when we want to add 'ibq' to 'p->bq'. It is defined
+ so we don't have to waste time traversing the 'ibq'. Its
+ characteristic compared to the other elements of 'ibq' is that
+ 'fbq->next==NULL'. So to add ibq to p->bq, we just have to set
+ 'fbq->next=p->bq' and then set 'p->bq' to 'ibq'.*/
builtqueue_addempty(&mkp->ibq);
ibq=mkp->ibq;
id=ibq->id=mkp->indexs[i];
if(fbq==NULL) fbq=ibq;
- /* Write the necessary parameters for this profile into `mkp'.*/
+ /* Write the necessary parameters for this profile into 'mkp'.*/
oneprofile_set_prof_params(mkp);
@@ -528,7 +531,7 @@ mkprof_build(void *inparam)
default:
error(EXIT_FAILURE, 0, "%s: a bug! please contact us at %s to "
- "address the issue. %zu is not recognized for `ndim'",
+ "address the issue. %zu is not recognized for 'ndim'",
__func__, PACKAGE_BUGREPORT, ndim);
}
@@ -629,7 +632,7 @@ mkprof_write(struct mkprofparams *p)
array. */
if(ibq->overlaps && out)
GAL_TILE_PO_OISET(float,float,ibq->overlap_i,ibq->overlap_m,1,0, {
- *o = p->replace ? ( *i==0.0f ? *o : *i ) : (*i + *o);
+ *o = p->replace ? ( *i>*o ? *i : *o ) : (*i + *o);
sum += *i;
});
@@ -693,8 +696,8 @@ mkprof_write(struct mkprofparams *p)
if(!p->cp.quiet) gettimeofday(&t1, NULL);
/* Write the final image into a FITS file with the requested
- type. Until now, we were using `p->wcs' for the WCS, but from now
- on, will put it in `out' to also free it while freeing `out'. */
+ type. Until now, we were using 'p->wcs' for the WCS, but from now
+ on, will put it in 'out' to also free it while freeing 'out'. */
out->wcs=p->wcs;
gal_fits_img_write_to_type(out, p->mergedimgname, NULL,
PROGRAM_NAME, p->cp.type);
@@ -744,13 +747,14 @@ mkprof_write(struct mkprofparams *p)
void
mkprof(struct mkprofparams *p)
{
- int err;
- char *tmp;
pthread_t t; /* Thread id not used, all are saved here. */
pthread_attr_t attr;
pthread_barrier_t b;
+ size_t numforprint=50;
struct mkonthread *mkp;
+ char *tmp, *mmapname=NULL;
gal_list_str_t *comments=NULL;
+ int err, origquiet=p->cp.quiet;
size_t i, fi, *indexs, thrdcols;
long *onaxes=NULL, os=p->oversample;
size_t nb, ndim=p->ndim, nt=p->cp.numthreads;
@@ -761,17 +765,19 @@ mkprof(struct mkprofparams *p)
errno=0;
mkp=malloc(nt*sizeof *mkp);
if(mkp==NULL)
- error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for `mkp'",
+ error(EXIT_FAILURE, errno, "%s: allocating %zu bytes for 'mkp'",
__func__, (nt-1)*sizeof *mkp);
/* Distribute the different profiles for different threads. Note
that one thread is left out for writing, while nt-1 are left
for building. */
- gal_threads_dist_in_threads(p->num, nt, &indexs, &thrdcols);
+ mmapname=gal_threads_dist_in_threads(p->num, nt,
+ p->cp.minmapsize, p->cp.quietmmap,
+ &indexs, &thrdcols);
- /* `onaxes' are size of the merged output image without over-sampling or
+ /* 'onaxes' are size of the merged output image without over-sampling or
shifting in FITS order. When no output merged image is needed, we can
ignore it. */
if(p->out)
@@ -829,8 +835,27 @@ mkprof(struct mkprofparams *p)
}
- /* Write the created arrays into the image. */
+ /* If there are too many profiles, don't print the fact that a profile
+ has been built. */
+ if(p->num>numforprint)
+ {
+ /* Let the user know that building is ongoing. */
+ if(p->cp.quiet==0)
+ printf(" ---- Building %zu profiles... ", p->num);
+
+ /* Disable the quiet flag.*/
+ p->cp.quiet=1;
+ }
+
+
+ /* Write the created arrays into the image. Set the original quiet flag
+ and let the user know that its done. */
mkprof_write(p);
+ if(p->num>numforprint)
+ {
+ p->cp.quiet=origquiet;
+ if(p->cp.quiet==0) printf("done.\n");
+ }
/* Write the log file. */
@@ -857,9 +882,13 @@ mkprof(struct mkprofparams *p)
pthread_mutex_destroy(&p->qlock);
}
+ /* If a merged image was created, let the user know.... */
+ if(p->mergedimgname)
+ printf(" -- Output: %s\n", p->mergedimgname);
/* Clean up. */
- free(mkp);
- free(indexs);
+ if(mmapname) gal_pointer_mmap_free(&mmapname, p->cp.quietmmap);
+ else free(indexs);
if(onaxes) free(onaxes);
+ free(mkp);
}
diff --git a/bin/mkprof/mkprof.h b/bin/mkprof/mkprof.h
index 8ddfe01..8411b10 100644
--- a/bin/mkprof/mkprof.h
+++ b/bin/mkprof/mkprof.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkprof/oneprofile.c b/bin/mkprof/oneprofile.c
index 0aacb3c..caa3140 100644
--- a/bin/mkprof/oneprofile.c
+++ b/bin/mkprof/oneprofile.c
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -55,7 +55,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
************** Radial distance ******************
****************************************************************/
/* Set the center position of the profile in the oversampled image. Note
- that `mkp->width' is in the non-oversampled scale. IMPORTANT: the
+ that 'mkp->width' is in the non-oversampled scale. IMPORTANT: the
ordering is in FITS coordinate order. */
static void
oneprofile_center_oversampled(struct mkonthread *mkp)
@@ -92,7 +92,7 @@ oneprofile_set_coord(struct mkonthread *mkp, size_t index)
gal_dimension_index_to_coord(index, ndim, dsize, coord_c);
/* Convert these coordinates to one where the profile center is at the
- center and the image is not over-sampled. Note that only `coord_c' is
+ center and the image is not over-sampled. Note that only 'coord_c' is
in C order.*/
for(i=0;i<ndim;++i)
mkp->coord[i] = ( coord_c[ndim-i-1] - mkp->center[i] )/os;
@@ -135,7 +135,7 @@ oneprofile_r_el(struct mkonthread *mkp)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
"the problem. The value %zu is not recognized for "
- "`mkp->p->ndim'", __func__, PACKAGE_BUGREPORT, mkp->p->ndim);
+ "'mkp->p->ndim'", __func__, PACKAGE_BUGREPORT, mkp->p->ndim);
}
}
@@ -218,7 +218,7 @@ oneprofile_randompoints(struct mkonthread *mkp)
in checks), but since it has a very negligible cost (compared to the
random checks above) cost, its good to reset it to help in debugging
when necessary (avoid confusion when un-commenting the checks in
- `oneprofile_pix_by_pix'). */
+ 'oneprofile_pix_by_pix'). */
mkp->r=r_before;
mkp->coord[0]=coord_before[0];
mkp->coord[1]=coord_before[1];
@@ -325,7 +325,7 @@ integ2d(struct mkonthread *mkp)
/************ Pixel by pixel building *************/
/********* Positions are in C not FITS *********/
/**************************************************************/
-/* `oneprofile_center_oversampled' stored the center of the profile in
+/* 'oneprofile_center_oversampled' stored the center of the profile in
floating point coordinates. This function will convert that into a
pixel index. */
static size_t
@@ -335,9 +335,9 @@ oneprofile_center_pix_index(struct mkonthread *mkp)
size_t *dsize=mkp->ibq->image->dsize;
size_t i, coord[3], ndim=mkp->p->ndim;
- /* Find the coordinates of the center point. Note `mkp->center' is in
+ /* Find the coordinates of the center point. Note 'mkp->center' is in
FITS coordinates, while coord must be in C coordinates (to be used in
- `gal_dimension_coord_to_index'). */
+ 'gal_dimension_coord_to_index'). */
for(i=0;i<ndim;++i)
{
pixfrac = modf(mkp->center[i], &intpart);
@@ -379,7 +379,7 @@ oneprofile_pix_by_pix(struct mkonthread *mkp)
if(mkp->func==PROFILE_POINT)
{ array[p]=1; return; }
- /* Allocate the `byt' array. It is used as a flag to make sure that we
+ /* Allocate the 'byt' array. It is used as a flag to make sure that we
don't re-calculate the profile value on a pixel more than once. */
byt = gal_pointer_allocate(GAL_TYPE_UINT8,
gal_dimension_total_size(ndim, dsize), 1,
@@ -585,8 +585,8 @@ oneprofile_set_prof_params(struct mkonthread *mkp)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
- "address the problem. The value `%zu' is not recognized for "
- "`ndim'", __func__, PACKAGE_BUGREPORT, ndim);
+ "address the problem. The value '%zu' is not recognized for "
+ "'ndim'", __func__, PACKAGE_BUGREPORT, ndim);
}
@@ -694,6 +694,14 @@ oneprofile_set_prof_params(struct mkonthread *mkp)
+ case PROFILE_CUSTOM:
+ mkp->profile = profiles_custom_table;
+ mkp->truncr = tp ? p->t[id] : p->t[id]*p->r[id];
+ mkp->correction = 0;
+ break;
+
+
+
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us so we can "
"correct this problem. The profile code %u is not recognized.",
@@ -772,8 +780,8 @@ oneprofile_make(struct mkonthread *mkp)
mkp->ibq->accufrac /= sum;
/* Correct all the profile pixels. Note that ideally, if a user wants
- a NaN valued profile, they should use the `flat' profile with
- `--mforflatpix', which won't need this correction. However, it
+ a NaN valued profile, they should use the 'flat' profile with
+ '--mforflatpix', which won't need this correction. However, it
might happen that they forget the later, or the catalog might be
generated by a script that gives a NaN value for the magnitude
with any kind of profile. In such cases if we don't check the NaN
diff --git a/bin/mkprof/oneprofile.h b/bin/mkprof/oneprofile.h
index e38b61e..eb83697 100644
--- a/bin/mkprof/oneprofile.h
+++ b/bin/mkprof/oneprofile.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/mkprof/profiles.c b/bin/mkprof/profiles.c
index f838eb9..ebd69ac 100644
--- a/bin/mkprof/profiles.c
+++ b/bin/mkprof/profiles.c
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -41,7 +41,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/****************************************************************
***************** Profiles: ********************
****************************************************************/
-/* The Gaussian function at a point. */
+/* The distance of this pixel. */
double
profiles_radial_distance(struct mkonthread *mkp)
{
@@ -52,6 +52,42 @@ profiles_radial_distance(struct mkonthread *mkp)
+/* Read the values based on the distance from a table. */
+double
+profiles_custom_table(struct mkonthread *mkp)
+{
+ double out;
+ long i; /* May become negative. */
+ double *reg=mkp->p->customregular;
+ double *min=mkp->p->custom->array;
+ double *max=mkp->p->custom->next->array;
+ double *value=mkp->p->custom->next->next->array;
+
+ /* If the table isn't regular ('reg[0]' isn't NaN), then we have to parse
+ over the whole table. However, if its regular, we can find the proper
+ value much more easily. */
+ if( isnan(reg[0]) )
+ {
+ out=0;
+ for(i=0;i<mkp->p->custom->size;++i)
+ if( mkp->r >= min[i] && mkp->r < max[i] )
+ { out=value[i]; break; }
+ }
+ else
+ {
+ i=(mkp->r - reg[0])/reg[1];
+ if(i<0 || i>mkp->p->custom->size) out=0;
+ else out=value[i];
+ }
+
+ /* Return the output value. */
+ return isnan(out) ? 0 : out;
+}
+
+
+
+
+
/* The integral of the Gaussian from -inf to +inf equals the square root of
PI. So from zero to +inf it equals half of that.*/
double
diff --git a/bin/mkprof/profiles.h b/bin/mkprof/profiles.h
index 4ba0916..72c7b9b 100644
--- a/bin/mkprof/profiles.h
+++ b/bin/mkprof/profiles.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -27,6 +27,9 @@ double
profiles_radial_distance(struct mkonthread *mkp);
double
+profiles_custom_table(struct mkonthread *mkp);
+
+double
profiles_gaussian_total(double q);
double
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index ce000ab..5e1ad36 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -5,7 +5,7 @@ Arithmetic is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -124,17 +124,20 @@ ui_profile_name_read(char *string, size_t row)
else if ( !strcmp("distance", string) )
return PROFILE_DISTANCE;
+ else if ( !strcmp("custom", string) )
+ return PROFILE_CUSTOM;
+
else if ( !strcmp(GAL_BLANK_STRING, string) )
error(EXIT_FAILURE, 0, "atleast one profile function is blank");
else
{
if(row)
- error(EXIT_FAILURE, 0, "`%s' not recognized as a profile function "
+ error(EXIT_FAILURE, 0, "'%s' not recognized as a profile function "
"name in row %zu", string, row);
else
- error(EXIT_FAILURE, 0, "`%s' not recognized as a profile function "
- "name in values to `--kernel' option", string);
+ error(EXIT_FAILURE, 0, "'%s' not recognized as a profile function "
+ "name in values to '--kernel' option", string);
}
return PROFILE_INVALID;
@@ -187,6 +190,9 @@ ui_initialize_options(struct mkprofparams *p,
cp->numthreads = gal_threads_number();
cp->coptions = gal_commonopts_options;
+ p->customregular[0] = NAN;
+ p->customregular[1] = NAN;
+
/* Default program parameters. */
p->zeropoint = NAN;
p->cp.type = GAL_TYPE_FLOAT32;
@@ -232,18 +238,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct mkprofparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -326,17 +332,30 @@ ui_parse_kernel(struct argp_option *option, char *arg,
}
else
{
- /* The first part of `arg' (before the first comma) is not
+ /* If the kernel has already been given, ignore it (the previously
+ read value has higher precedence). */
+ if( *(gal_data_t **)(option->value) ) return NULL;
+
+ /* The first part of 'arg' (before the first comma) is not
necessarily a number. So we need to separate the first part from
the rest.*/
c=arg;while(*c!='\0' && *c!=',') ++c;
profile=arg;
- arg = (*c=='\0') ? NULL : c+1; /* the `point' profile doesn't need */
+ arg = (*c=='\0') ? NULL : c+1; /* the 'point' profile doesn't need */
*c='\0'; /* any numbers. */
+ /* Make sure something exists after the name of the profile. */
+ if(arg==NULL)
+ error(EXIT_FAILURE, 0, "the kernel option value couldn't be "
+ "parsed in the expected format: one name (of a profile), "
+ "followed by some numbers defining that profile. See the "
+ "description of '--kernel' in the manual (with the 'info "
+ "astmkprof' command) for the meaning of the numbers");
/* Read the parameters. */
kernel=gal_options_parse_list_of_numbers(arg, filename, lineno);
+
+ /* Put the kernel dataset into the main program structure. */
*(gal_data_t **)(option->value) = kernel;
@@ -345,13 +364,13 @@ ui_parse_kernel(struct argp_option *option, char *arg,
for(i=0;i<kernel->size;++i)
if(darray[i]<=0)
error(EXIT_FAILURE, 0, "value number %zu (%g) in the given list "
- "of kernel parameters (`%s') is not acceptable. All "
- "parameters to the `--kernel' option must be non-zero and "
+ "of kernel parameters ('%s') is not acceptable. All "
+ "parameters to the '--kernel' option must be non-zero and "
"positive", i+1, darray[i], arg);
/* See if a 2D kernel is requested or a 3D kernel and keep the value
- in `kernel->flag'. If no dimensionality is defined, then by
+ in 'kernel->flag'. If no dimensionality is defined, then by
default, we'll assume it is 2D.*/
c=profile;while(*c!='\0' && *c!='-') ++c;
if(*c=='\0')
@@ -361,9 +380,9 @@ ui_parse_kernel(struct argp_option *option, char *arg,
*c='\0';
dstr=c+1;
if( (dstr[1]!='d' && dstr[1]!='D') || dstr[2]!='\0')
- error(EXIT_FAILURE, 0, "bad formatting in `--kernel' "
+ error(EXIT_FAILURE, 0, "bad formatting in '--kernel' "
"dimensionality. The dimensionality suffix must be either "
- "2d, 3d (not case sensitive). You have given `%s'", dstr);
+ "2d, 3d (not case sensitive). You have given '%s'", dstr);
switch(dstr[0])
{
case '2': kernel->flag=2; break;
@@ -376,21 +395,21 @@ ui_parse_kernel(struct argp_option *option, char *arg,
}
- /* Write the profile type code into `kernel->status'. If it starts
+ /* Write the profile type code into 'kernel->status'. If it starts
with a digit, then the user might have given the code of the
profile directly. In that case, parse the number. Otherwise,
- let `ui_profile_name_read' find the value. */
+ let 'ui_profile_name_read' find the value. */
if( isdigit(*profile) )
{
profcode=strtol(profile, &tailptr, 0);
if(*tailptr!='\0')
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' "
"couldn't be read as a profile code", profile);
if(profcode<=0 || profcode>=PROFILE_MAXIMUM_CODE)
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' "
"isn't a valid profile code. Please run with "
- "`--help' and see the acceptable codes in "
- "explanation of the `--fcol' option", profile);
+ "'--help' and see the acceptable codes in "
+ "explanation of the '--fcol' option", profile);
kernel->status=profcode;
}
else
@@ -420,8 +439,8 @@ ui_parse_kernel(struct argp_option *option, char *arg,
are needed. */
if( kernel->size != need )
error_at_line(EXIT_FAILURE, 0, filename, lineno, "as a %uD kernel, "
- "a `%s' profile needs %zu parameters, but %zu "
- "parameter%s given to `--kernel'", kernel->flag,
+ "a '%s' profile needs %zu parameters, but %zu "
+ "parameter%s given to '--kernel'", kernel->flag,
ui_profile_name_write(kernel->status), need,
kernel->size, kernel->size>1?"s are":" is");
@@ -456,9 +475,9 @@ ui_parse_coordinate_mode(struct argp_option *option, char
*arg,
else if (!strcmp(arg, "wcs"))
*(uint8_t *)(option->value)=MKPROF_MODE_WCS;
else
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "`%s' (value to "
- "`--mode') not recognized as a coordinate standard "
- "mode. Recognized values are `img' and `wcs'. This "
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "'%s' (value to "
+ "'--mode') not recognized as a coordinate standard "
+ "mode. Recognized values are 'img' and 'wcs'. This "
"option is necessary to identify the nature of your "
"input coordinates", arg);
return NULL;
@@ -487,7 +506,7 @@ ui_parse_coordinate_mode(struct argp_option *option, char
*arg,
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct mkprofparams *p)
{
@@ -495,7 +514,7 @@ ui_read_check_only_options(struct mkprofparams *p)
/* When a no-merged image is to be created, type is necessary. */
if( p->cp.type==GAL_TYPE_INVALID && p->nomerged==0)
- error(EXIT_FAILURE, 0, "an output type `--type' is necessary when a "
+ error(EXIT_FAILURE, 0, "an output type '--type' is necessary when a "
"merged image is to be built.");
/* Check if one of the coordinate columns has been given, the other is
@@ -507,26 +526,26 @@ ui_read_check_only_options(struct mkprofparams *p)
if(p->kernel==NULL)
{
if(p->mode==0)
- error(EXIT_FAILURE, 0, "the `--mode' option is necessary when "
+ error(EXIT_FAILURE, 0, "the '--mode' option is necessary when "
"building profiles from a catalog. It can take two values: "
- "`img' or `wcs' which specify how to interpret the "
+ "'img' or 'wcs' which specify how to interpret the "
"coordinate columns");
}
- /* The zeropoint magnitude is only necessary when `mcolisbrightness' is
+ /* The zeropoint magnitude is only necessary when 'mcolisbrightness' is
not called. */
if( p->mcolisbrightness==0 && isnan(p->zeropoint) )
error(EXIT_FAILURE, 0, "no zeropoint magnitude given. A zeropoint "
- "magnitude is necessary when `--mcolisbrightness' is not called "
- "(i.e., when the contents of `--mcol' must be interpretted as "
+ "magnitude is necessary when '--mcolisbrightness' is not called "
+ "(i.e., when the contents of '--mcol' must be interpretted as "
"a magnitude, not brightness).");
- /* Make sure no zero value is given for the `--mergedsize' option (only
+ /* Make sure no zero value is given for the '--mergedsize' option (only
when it is necessary). */
if(p->dsize && p->backname==NULL)
for(i=0;p->dsize[i]!=GAL_BLANK_SIZE_T;++i)
if(p->dsize[i]==0)
- error(EXIT_FAILURE, 0, "values to `--mergedsize' option must not "
+ error(EXIT_FAILURE, 0, "values to '--mergedsize' option must not "
"be zero");
}
@@ -535,7 +554,7 @@ ui_read_check_only_options(struct mkprofparams *p)
/* Sanity check on options AND arguments. If only option values are to be
- checked, use `ui_read_check_only_options'. */
+ checked, use 'ui_read_check_only_options'. */
static void
ui_check_options_and_arguments(struct mkprofparams *p)
{
@@ -544,14 +563,14 @@ ui_check_options_and_arguments(struct mkprofparams *p)
/* If no kernel is given, make sure an input catalog is given, and if it
is FITS, that the HDU is also provided. When a kernel option, we will
- set a fiducial catalog name called `kernel.txt' to automatic output
+ set a fiducial catalog name called 'kernel.txt' to automatic output
filename generation. */
if(p->kernel)
{
if(p->catname)
- error(EXIT_FAILURE, 0, "`--kernel' cannot be called with an input "
- "catalog (`%s'). The parameters necessary to build a single "
- "kernel output should be given to `--kernel', not in a "
+ error(EXIT_FAILURE, 0, "'--kernel' cannot be called with an input "
+ "catalog ('%s'). The parameters necessary to build a single "
+ "kernel output should be given to '--kernel', not in a "
"catalog", p->catname);
p->catname="kernel.option";
}
@@ -560,7 +579,7 @@ ui_check_options_and_arguments(struct mkprofparams *p)
if(p->catname)
{
if( gal_fits_name_is_fits(p->catname) && p->cp.hdu==NULL)
- error(EXIT_FAILURE, 0, "no `hdu' specified for the input FITS "
+ error(EXIT_FAILURE, 0, "no 'hdu' specified for the input FITS "
"table '%s', to ", p->catname);
}
}
@@ -594,7 +613,7 @@ ui_check_options_and_arguments(struct mkprofparams *p)
p->basename=gal_checkset_not_dir_part(p->mergedimgname);
- /* If a merged image is requested (or `--kernel' the option is called),
+ /* If a merged image is requested (or '--kernel' the option is called),
then delete the final filename if it exists. */
if(p->nomerged==0 && p->kernel)
gal_checkset_writable_remove(p->mergedimgname, p->cp.keep,
@@ -662,8 +681,8 @@ ui_read_cols_2d(struct mkprofparams *p)
/* The name of the input catalog is only for informative steps from now
on (we won't be dealing with the actual file any more). So if the
- standard input was used (therefore `catname==NULL', set it to
- `stdin'). */
+ standard input was used (therefore 'catname==NULL', set it to
+ 'stdin'). */
if(p->catname==NULL)
gal_checkset_allocate_copy("standard-input", &p->catname);
@@ -686,8 +705,8 @@ ui_read_cols_2d(struct mkprofparams *p)
case 1:
case 2:
colname = ( counter==1
- ? "first coordinate column (`--coordcol')"
- : "second coordinate column (`--coordcol')" );
+ ? "first coordinate column ('--coordcol')"
+ : "second coordinate column ('--coordcol')" );
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT64);
switch(counter)
{
@@ -711,7 +730,7 @@ ui_read_cols_2d(struct mkprofparams *p)
else
{
/* Read the user's profile codes. */
- colname="profile function code (`fcol')";
+ colname="profile function code ('fcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_UINT8);
p->f=corrtype->array;
@@ -720,12 +739,12 @@ ui_read_cols_2d(struct mkprofparams *p)
if(p->f[i]<=PROFILE_INVALID || p->f[i]>=PROFILE_MAXIMUM_CODE)
error(EXIT_FAILURE, 0, "%s: row %zu, the function "
"code is %u. It should be >%d and <%d. Please run "
- "again with `--help' and check the acceptable "
+ "again with '--help' and check the acceptable "
"codes.\n\nAlternatively, you can use alphabetic "
"strings to specify the profile functions, see the "
- "explanations under `fcol' from the command "
- "below (press the `SPACE' key to go down, and the "
- "`q' to return back to the command-line):\n\n"
+ "explanations under 'fcol' from the command "
+ "below (press the 'SPACE' key to go down, and the "
+ "'q' to return back to the command-line):\n\n"
" $ info %s\n", p->catname, i+1, p->f[i],
PROFILE_INVALID, PROFILE_MAXIMUM_CODE, PROGRAM_EXEC);
}
@@ -733,7 +752,7 @@ ui_read_cols_2d(struct mkprofparams *p)
case 4:
- colname="radius (`rcol')";
+ colname="radius ('rcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->r=corrtype->array;
@@ -741,28 +760,28 @@ ui_read_cols_2d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if(p->f[i]!=PROFILE_POINT && p->r[i]<=0.0f)
error(EXIT_FAILURE, 0, "%s: row %zu, the radius value %g is "
- "not acceptable for a `%s' profile. It has to be larger "
+ "not acceptable for a '%s' profile. It has to be larger "
"than 0", p->catname, i+1, p->r[i],
ui_profile_name_write(p->f[i]));
break;
case 5:
- colname="index (`ncol')";
+ colname="index ('ncol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->n=corrtype->array;
break;
case 6:
- colname="position angle (`pcol')";
+ colname="position angle ('pcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->p1=corrtype->array;
break;
case 7:
- colname="axis ratio (`qcol')";
+ colname="axis ratio ('qcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->q1=corrtype->array;
@@ -770,14 +789,14 @@ ui_read_cols_2d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if( p->f[i]!=PROFILE_POINT && (p->q1[i]<=0.0f || p->q1[i]>1.0f) )
error(EXIT_FAILURE, 0, "%s: row %zu, the axis ratio value %g "
- "is not acceptable for a `%s' profile. It has to be >0 "
+ "is not acceptable for a '%s' profile. It has to be >0 "
"and <=1", p->catname, i+1, p->q1[i],
ui_profile_name_write(p->f[i]));
break;
case 8:
- colname="magnitude (`mcol')";
+ colname="magnitude ('mcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->m=corrtype->array;
checkblank=0; /* Magnitude can be NaN: to mask regions. */
@@ -785,7 +804,7 @@ ui_read_cols_2d(struct mkprofparams *p)
case 9:
- colname="truncation (`tcol')";
+ colname="truncation ('tcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->t=corrtype->array;
@@ -793,7 +812,7 @@ ui_read_cols_2d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if(p->f[i]!=PROFILE_POINT && p->t[i]<=0.0f)
error(EXIT_FAILURE, 0, "%s: row %zu, the truncation radius "
- "value %g is not acceptable for a `%s' profile. It has "
+ "value %g is not acceptable for a '%s' profile. It has "
"to be larger than 0", p->catname, i+1, p->t[i],
ui_profile_name_write(p->f[i]));
break;
@@ -805,11 +824,11 @@ ui_read_cols_2d(struct mkprofparams *p)
gal_tableintern_error_col_selection(p->catname, p->cp.hdu, "too "
"many columns were selected "
"by the given values to the "
- "options ending in `col'.");
+ "options ending in 'col'.");
}
/* Sanity check and clean up. Note that it might happen that the
- input structure is already freed. In that case, `corrtype' will be
+ input structure is already freed. In that case, 'corrtype' will be
NULL. */
if(corrtype)
{
@@ -819,7 +838,7 @@ ui_read_cols_2d(struct mkprofparams *p)
"Input columns cannot contain blank values", colname);
/* Free the unnecessary sturcture information. The correct-type
- (`corrtype') data structure's array is necessary for later
+ ('corrtype') data structure's array is necessary for later
steps, so its pointer has been copied in the main program's
structure. Hence, we should set the structure's pointer to
NULL so the important data isn't freed.*/
@@ -838,12 +857,12 @@ ui_read_cols_2d(struct mkprofparams *p)
{
error(0, 0, "WARNING: atleast one single-valued profile (point, "
"flat, or circumference profiles) has a magnitude column "
- "value of 0.0 while `--mforflatpix' or "
- "`--mcolforbrightness' have also been given. In such cases "
+ "value of 0.0 while '--mforflatpix' or "
+ "'--mcolforbrightness' have also been given. In such cases "
"the profile's pixels will have a value of zero and thus "
"they will not be identifiable from the zero-valued "
"background. If this behavior is intended, this warning "
- "can be suppressed with the `--quiet' (or `-q') option.\n");
+ "can be suppressed with the '--quiet' (or '-q') option.\n");
break;
}
}
@@ -862,11 +881,11 @@ ui_read_cols_3d(struct mkprofparams *p)
gal_data_t *cols, *tmp, *corrtype=NULL;
gal_list_str_t *lines, *ccol, *colstrs=NULL;
- /* The 3D-specific columns are not mandatory in `args.h', so we need to
+ /* The 3D-specific columns are not mandatory in 'args.h', so we need to
check here if they are given or not before starting to read them. */
if(p->p2col==NULL || p->p3col==NULL || p->q2col==NULL)
- error(EXIT_FAILURE, 0, "at least one of `--p2col', `--p3col', or "
- "`--q2col' have not been identified. When building a 3D profile, "
+ error(EXIT_FAILURE, 0, "at least one of '--p2col', '--p3col', or "
+ "'--q2col' have not been identified. When building a 3D profile, "
"these three columns are also mandatory");
/* The coordinate columns are a linked list of strings. */
@@ -920,10 +939,10 @@ ui_read_cols_3d(struct mkprofparams *p)
case 2:
case 3:
colname = ( counter==1
- ? "first coordinate column (`--coordcol')"
+ ? "first coordinate column ('--coordcol')"
: ( counter==2
- ? "second coordinate column (`--coordcol')"
- : "third coordinate column (`--coordcol')" ) );
+ ? "second coordinate column ('--coordcol')"
+ : "third coordinate column ('--coordcol')" ) );
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT64);
switch(counter)
{
@@ -947,7 +966,7 @@ ui_read_cols_3d(struct mkprofparams *p)
else
{
/* Read the user's profile codes. */
- colname="profile function code (`fcol')";
+ colname="profile function code ('fcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_UINT8);
p->f=corrtype->array;
@@ -956,19 +975,19 @@ ui_read_cols_3d(struct mkprofparams *p)
if(p->f[i]<=PROFILE_INVALID || p->f[i]>=PROFILE_MAXIMUM_CODE)
error(EXIT_FAILURE, 0, "%s: row %zu, the function "
"code is %u. It should be >%d and <%d. Please run "
- "again with `--help' and check the acceptable "
+ "again with '--help' and check the acceptable "
"codes.\n\nAlternatively, you can use alphabetic "
"strings to specify the profile functions, see the "
- "explanations under `fcol' from the command "
- "below (press the `SPACE' key to go down, and the "
- "`q' to return back to the command-line):\n\n"
+ "explanations under 'fcol' from the command "
+ "below (press the 'SPACE' key to go down, and the "
+ "'q' to return back to the command-line):\n\n"
" $ info %s\n", p->catname, i+1, p->f[i],
PROFILE_INVALID, PROFILE_MAXIMUM_CODE, PROGRAM_EXEC);
}
break;
case 5:
- colname="radius (`rcol')";
+ colname="radius ('rcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->r=corrtype->array;
@@ -976,37 +995,37 @@ ui_read_cols_3d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if(p->f[i]!=PROFILE_POINT && p->r[i]<=0.0f)
error(EXIT_FAILURE, 0, "%s: row %zu, the radius value %g is "
- "not acceptable for a `%s' profile. It has to be larger "
+ "not acceptable for a '%s' profile. It has to be larger "
"than 0", p->catname, i+1, p->r[i],
ui_profile_name_write(p->f[i]));
break;
case 6:
- colname="index (`ncol')";
+ colname="index ('ncol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->n=corrtype->array;
break;
case 7:
- colname="first euler angle (`pcol')";
+ colname="first euler angle ('pcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->p1=corrtype->array;
break;
case 8:
- colname="second euler angle (`p2col')";
+ colname="second euler angle ('p2col')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->p2=corrtype->array;
break;
case 9:
- colname="third euler angle (`p3col')";
+ colname="third euler angle ('p3col')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->p3=corrtype->array;
break;
case 10:
- colname="axis ratio 1 (`qcol')";
+ colname="axis ratio 1 ('qcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->q1=corrtype->array;
@@ -1014,13 +1033,13 @@ ui_read_cols_3d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if( p->f[i]!=PROFILE_POINT && (p->q1[i]<=0.0f || p->q1[i]>1.0f) )
error(EXIT_FAILURE, 0, "%s: row %zu, the first axis ratio "
- "value %g is not acceptable for a `%s' profile. It has "
+ "value %g is not acceptable for a '%s' profile. It has "
"to be >0 and <=1", p->catname, i+1, p->q1[i],
ui_profile_name_write(p->f[i]));
break;
case 11:
- colname="axis ratio 2 (`q2col')";
+ colname="axis ratio 2 ('q2col')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->q2=corrtype->array;
@@ -1028,20 +1047,20 @@ ui_read_cols_3d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if( p->f[i]!=PROFILE_POINT && (p->q2[i]<=0.0f || p->q2[i]>1.0f) )
error(EXIT_FAILURE, 0, "%s: row %zu, the second axis ratio "
- "value %g is not acceptable for a `%s' profile. It has "
+ "value %g is not acceptable for a '%s' profile. It has "
"to be >0 and <=1", p->catname, i+1, p->q2[i],
ui_profile_name_write(p->f[i]));
break;
case 12:
- colname="magnitude (`mcol')";
+ colname="magnitude ('mcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->m=corrtype->array;
checkblank=0; /* Magnitude can be NaN: to mask regions. */
break;
case 13:
- colname="truncation (`tcol')";
+ colname="truncation ('tcol')";
corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_FLOAT32);
p->t=corrtype->array;
@@ -1049,7 +1068,7 @@ ui_read_cols_3d(struct mkprofparams *p)
for(i=0;i<p->num;++i)
if(p->f[i]!=PROFILE_POINT && p->t[i]<=0.0f)
error(EXIT_FAILURE, 0, "%s: row %zu, the truncation radius "
- "value %g is not acceptable for a `%s' profile. It has "
+ "value %g is not acceptable for a '%s' profile. It has "
"to be larger than 0", p->catname, i+1, p->t[i],
ui_profile_name_write(p->f[i]));
break;
@@ -1060,11 +1079,11 @@ ui_read_cols_3d(struct mkprofparams *p)
gal_tableintern_error_col_selection(p->catname, p->cp.hdu, "too "
"many columns were selected "
"by the given values to the "
- "options ending in `col'.");
+ "options ending in 'col'.");
}
/* Sanity check and clean up. Note that it might happen that the
- input structure is already freed. In that case, `corrtype' will be
+ input structure is already freed. In that case, 'corrtype' will be
NULL. */
if(corrtype)
{
@@ -1074,7 +1093,7 @@ ui_read_cols_3d(struct mkprofparams *p)
"Input columns cannot contain blank values", colname);
/* Free the unnecessary sturcture information. The correct-type
- (`corrtype') data structure's array is necessary for later
+ ('corrtype') data structure's array is necessary for later
steps, so its pointer has been copied in the main program's
structure. Hence, we should set the structure's pointer to
NULL so the important data isn't freed.*/
@@ -1089,10 +1108,11 @@ ui_read_cols_3d(struct mkprofparams *p)
/* It is possible to define the internal catalog through a catalog or the
- `--kernel' option. This function will do the job. */
+ '--kernel' option. This function will do the job. */
static void
ui_prepare_columns(struct mkprofparams *p)
{
+ size_t i;
double *karr;
float r, n, t, q2;
@@ -1161,7 +1181,7 @@ ui_prepare_columns(struct mkprofparams *p)
}
/* 3rd-dim axis ratio <=1: No extra rotation is necessary and
- `q2'can simply be put in the respective column. */
+ 'q2'can simply be put in the respective column. */
else
{
p->q2[0] = q2;
@@ -1173,11 +1193,11 @@ ui_prepare_columns(struct mkprofparams *p)
{
/* Make sure the number of coordinate columns and number of
dimensions in outputs are the same. There is no problem if it is
- more than `ndim'. In that case, the last values (possibly in
+ more than 'ndim'. In that case, the last values (possibly in
configuration files) will be ignored. */
if( gal_list_str_number(p->ccol) < p->ndim )
error(EXIT_FAILURE, 0, "%zu coordinate columns (calls to "
- "`--coordcol') given but output has %zu dimensions",
+ "'--coordcol') given but output has %zu dimensions",
gal_list_str_number(p->ccol), p->ndim);
/* Call the respective function. */
@@ -1187,10 +1207,25 @@ ui_prepare_columns(struct mkprofparams *p)
case 3: ui_read_cols_3d(p); break;
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
- "resolve the issue. %zu not recognized for `p->ndim'",
+ "resolve the issue. %zu not recognized for 'p->ndim'",
__func__, PACKAGE_BUGREPORT, p->ndim);
}
}
+
+ /* If a custom profile is requested, make sure that a custom file is
+ given. */
+ for(i=0;i<p->num;++i)
+ if(p->f[i]==PROFILE_CUSTOM)
+ {
+ if(p->customname==NULL)
+ error(EXIT_FAILURE, 0, "at least one custom profile requested "
+ "(first occurrence in row %zu), but no file/table was given "
+ "to the '--customtable' option. See the description of "
+ "this '--customtable' for more information on the "
+ "desired format", i+1);
+ break;
+ }
+
}
@@ -1209,7 +1244,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->crpix)
{
if(p->crpix->size!=ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--crpix'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--crpix'. This must be "
"the same as the output dimension (%zu)", p->crpix->size, ndim);
return 0;
}
@@ -1218,7 +1253,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->crval)
{
if(p->crval->size!=ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--crval'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--crval'. This must be "
"the same as the output dimension (%zu)", p->crval->size, ndim);
return 0;
}
@@ -1227,7 +1262,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->cdelt)
{
if(p->cdelt->size!=ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--cdelt'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--cdelt'. This must be "
"the same as the output dimension (%zu)", p->cdelt->size, ndim);
return 0;
}
@@ -1236,7 +1271,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->pc)
{
if(p->pc->size!=ndim*ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--pc'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--pc'. This must be "
"the square as the output dimension (%zu)", p->pc->size,
ndim*ndim);
return 0;
@@ -1246,7 +1281,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->cunit)
{
if(p->cunit->size!=ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--cunit'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--cunit'. This must be "
"the same as the output dimension (%zu)", p->cunit->size, ndim);
return 0;
}
@@ -1255,7 +1290,7 @@ ui_wcs_sanity_check(struct mkprofparams *p)
if(p->ctype)
{
if(p->ctype->size!=ndim)
- error(EXIT_FAILURE, 0, "%zu values given to `--ctype'. This must be "
+ error(EXIT_FAILURE, 0, "%zu values given to '--ctype'. This must be "
"the same as the output dimension (%zu)", p->ctype->size, ndim);
return 0;
}
@@ -1309,7 +1344,7 @@ ui_prepare_wcs(struct mkprofparams *p)
/* IMPORTANT: At this point, we don't want the WCS to be over-sampled
because if the user has given RA and Dec for the profiles, they
need to be converted to non-oversampled and shifted image
- coordinates. After the conversion (in `ui_finalize_coordinates')
+ coordinates. After the conversion (in 'ui_finalize_coordinates')
we are going to correct for the oversampling in the WCS.*/
wcs->crpix[i] = crpix[i];
wcs->crval[i] = crval[i];
@@ -1347,7 +1382,7 @@ ui_prepare_canvas(struct mkprofparams *p)
/* Read in the background image and its coordinates, note that when
no merged image is desired, we just need the WCS information of
the background image and the number of its dimensions. So
- `ndim==0' and what `dsize' points to is irrelevant. */
+ 'ndim==0' and what 'dsize' points to is irrelevant. */
tdsize=gal_fits_img_info_dim(p->backname, p->backhdu, &tndim);
p->wcs=gal_wcs_read(p->backname, p->backhdu, 0, 0, &p->nwcs);
tndim=gal_dimension_remove_extra(tndim, tdsize, p->wcs);
@@ -1357,7 +1392,7 @@ ui_prepare_canvas(struct mkprofparams *p)
/* If p->dsize was given as an option, free it. */
if( p->dsize ) free(p->dsize);
- /* Write the size of the background image into `dsize'. */
+ /* Write the size of the background image into 'dsize'. */
p->dsize=gal_pointer_allocate(GAL_TYPE_SIZE_T, p->ndim, 0,
__func__, "p->dsize");
for(i=0;i<p->ndim;++i) p->dsize[i] = p->out->dsize[i];
@@ -1388,13 +1423,13 @@ ui_prepare_canvas(struct mkprofparams *p)
/* Make sure it has the same number of elements as naxis. */
if(p->ndim!=nshift)
- error(EXIT_FAILURE, 0, "%zu and %zu elements given to `--ndim' "
- "and `--shift' respectively. These two numbers must be the "
+ error(EXIT_FAILURE, 0, "%zu and %zu elements given to '--ndim' "
+ "and '--shift' respectively. These two numbers must be the "
"same", p->ndim, nshift);
}
else
{
- /* `prepforconv' is only valid when xshift and yshift are both
+ /* 'prepforconv' is only valid when xshift and yshift are both
zero. Also, a PSF profile should exist in the image. */
if(p->prepforconv)
{
@@ -1516,15 +1551,15 @@ ui_finalize_coordinates(struct mkprofparams *p)
double *cdelt=p->wcs->cdelt, *crpix=p->wcs->crpix;
/* When the user specified RA and Dec columns, the respective values
- where stored in the `p->x' and `p->y' arrays. So before proceeding, we
+ where stored in the 'p->x' and 'p->y' arrays. So before proceeding, we
need to change them into actual image coordinates. */
if(p->mode==MKPROF_MODE_WCS)
{
- /* Make list of coordinates for input of `gal_wcs_world_to_img'. */
+ /* Make list of coordinates for input of 'gal_wcs_world_to_img'. */
for(i=0;i<ndim;++i)
{
/* Set the array pointer. Note that we read the WCS columns into
- the `p->x', `p->y' and `p->z' arrays temporarily before. Here, we
+ the 'p->x', 'p->y' and 'p->z' arrays temporarily before. Here, we
will convert them to image coordinates in place. */
switch(i)
{
@@ -1557,7 +1592,7 @@ ui_finalize_coordinates(struct mkprofparams *p)
"(%f, %f) coordinates into image coordinates", i, p->x[i],
p->y[i]);
- /* We want the actual arrays of each `coords' column. So, first we'll
+ /* We want the actual arrays of each 'coords' column. So, first we'll
set all the array elements to NULL, then free it. */
for(tmp=coords;tmp!=NULL;tmp=tmp->next) tmp->array=NULL;
gal_list_data_free(coords);
@@ -1569,7 +1604,7 @@ ui_finalize_coordinates(struct mkprofparams *p)
non-over-sampled image.*/
for(i=0;i<p->ndim;++i)
{
- /* Oversampling has already been applied in `p->shift'. Also note
+ /* Oversampling has already been applied in 'p->shift'. Also note
that shift is in the C dimension ordring, while crpix is in FITS
ordering. */
crpix[i] = crpix[i]*os + p->shift[ndim-i-1] - os/2;
@@ -1637,6 +1672,83 @@ ui_make_log(struct mkprofparams *p)
+/* Read the input radial table. */
+static void
+ui_read_custom_table(struct mkprofparams *p)
+{
+ size_t i;
+ double diff;
+ int isregular;
+ gal_data_t *cols;
+ double *min, *max;
+
+ /* Read the input radial table. */
+ cols=gal_table_read(p->customname, p->customhdu,
+ NULL, NULL, p->cp.searchin, p->cp.ignorecase,
+ p->cp.minmapsize, p->cp.quietmmap, NULL);
+
+ /* Make sure the table only has three columns. */
+ if(gal_list_data_number(cols) != 3 )
+ error(EXIT_FAILURE, 0, "%s: has %zu columns, but it should only have "
+ "three columns. Column1: the radial interval's lower value. "
+ "Column 2: the radial interval's higher value. Column 3: the value "
+ "to use for pixels within that radius interval",
+ gal_fits_name_save_as_string(p->customname, p->customhdu),
+ gal_list_data_number(cols));
+
+ /* Make sure none of the three columns are string type. */
+ if( cols->type==GAL_TYPE_STRING
+ || cols->next->type==GAL_TYPE_STRING
+ || cols->next->next->type==GAL_TYPE_STRING )
+ error(EXIT_FAILURE, 0, "%s: the columns should only have numeric "
+ "data types", gal_fits_name_save_as_string(p->customname,
+ p->customhdu));
+
+ /* Fill the final table as a double type. */
+ p->custom=gal_data_copy_to_new_type(cols, GAL_TYPE_FLOAT64);
+ p->custom->next=gal_data_copy_to_new_type(cols->next,
+ GAL_TYPE_FLOAT64);
+ p->custom->next->next=gal_data_copy_to_new_type(cols->next->next,
+ GAL_TYPE_FLOAT64);
+
+ /* Make sure the first column values are smaller than the second column's
+ values. */
+ min=p->custom->array;
+ max=p->custom->next->array;
+ for(i=0;i<p->custom->size;++i)
+ if(min[i]>=max[i])
+ error(EXIT_FAILURE, 0, "%s: the first column of row %zu (with value "
+ "%g) is larger or equal to the second column (with value %g). "
+ "However, the first column is the lower-limit of the radial "
+ "interval and the second column is the upper-limit. So the "
+ "first column must have a lower value",
+ gal_fits_name_save_as_string(p->customname,
+ p->customhdu), i+1,
+ min[i], max[i]);
+
+ /* Check if the input table is regular and sorted (which can greatly
+ speed up its usage). */
+ isregular=1;
+ diff=max[0]-min[0];
+ for(i=1;i<p->custom->size;++i)
+ if( min[i]<min[i-1]
+ || min[i] != max[i-1]
+ || max[i]-min[i] != diff )
+ isregular=0;
+ if(isregular)
+ {
+ p->customregular[0]=min[0];
+ p->customregular[1]=diff;
+ }
+
+ /* Clean up. */
+ gal_list_data_free(cols);
+}
+
+
+
+
+
static void
ui_read_ndim(struct mkprofparams *p)
{
@@ -1649,7 +1761,7 @@ ui_read_ndim(struct mkprofparams *p)
/* Make sure the kernel and background are not given together. */
if(p->backname)
- error(EXIT_FAILURE, 0, "the `--kernel' and `--background' options "
+ error(EXIT_FAILURE, 0, "the '--kernel' and '--background' options "
"cannot be called together");
}
else
@@ -1660,10 +1772,10 @@ ui_read_ndim(struct mkprofparams *p)
/* Small sanity check. */
if(p->backhdu==NULL)
error(EXIT_FAILURE, 0, "no hdu specified for the background "
- "image %s. Please run again `--backhdu' option",
+ "image %s. Please run again '--backhdu' option",
p->backname);
- /* If `--nomerged' is given, we don't actually need to load the
+ /* If '--nomerged' is given, we don't actually need to load the
image, we just need its WCS later. */
if(p->nomerged)
{
@@ -1699,7 +1811,7 @@ ui_read_ndim(struct mkprofparams *p)
/* Make sure the dimensionality is supported. */
if(p->ndim!=2 && p->ndim!=3)
- error(EXIT_FAILURE, 0, "%zu values given to `--mergedsize'. "
+ error(EXIT_FAILURE, 0, "%zu values given to '--mergedsize'. "
"Currently only 2 or 3 dimensional outputs can be produced",
p->ndim);
}
@@ -1717,10 +1829,13 @@ ui_preparations(struct mkprofparams *p)
use). */
ui_read_ndim(p);
- /* Read in all the columns (necessary for `--prepforconf' when we want to
+ /* Read in all the columns (necessary for '--prepforconf' when we want to
build the profiles). */
ui_prepare_columns(p);
+ /* Read the radial table. */
+ if(p->customname) ui_read_custom_table(p);
+
/* If the kernel option was given, some parameters need to be
over-written: */
if(p->kernel)
@@ -1845,9 +1960,9 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct
mkprofparams *p)
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
diff --git a/bin/mkprof/ui.h b/bin/mkprof/ui.h
index 4b0898c..33bbb93 100644
--- a/bin/mkprof/ui.h
+++ b/bin/mkprof/ui.h
@@ -5,7 +5,7 @@ MakeProfiles is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -93,6 +93,8 @@ enum option_keys_enum
UI_KEY_PC,
UI_KEY_CUNIT,
UI_KEY_CTYPE,
+ UI_KEY_CUSTOMTABLE,
+ UI_KEY_CUSTOMTABLEHDU,
};
diff --git a/bin/noisechisel/Makefile.am b/bin/noisechisel/Makefile.am
index 86633b1..56d429d 100644
--- a/bin/noisechisel/Makefile.am
+++ b/bin/noisechisel/Makefile.am
@@ -3,7 +3,7 @@
## Original author:
## Mohammad Akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2016-2019, Free Software Foundation, Inc.
+## Copyright (C) 2016-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,20 +20,19 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
bin_PROGRAMS = astnoisechisel
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
astnoisechisel_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
- -lgnuastro $(MAYBE_NORPATH)
+ -lgnuastro $(CONFIG_LDADD)
astnoisechisel_SOURCES = main.c ui.c detection.c noisechisel.c sky.c \
threshold.c
diff --git a/bin/noisechisel/args.h b/bin/noisechisel/args.h
index 63560d2..4f51411 100644
--- a/bin/noisechisel/args.h
+++ b/bin/noisechisel/args.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -36,7 +36,7 @@ struct argp_option program_options[] =
{
"kernel",
UI_KEY_KERNEL,
- "STR",
+ "FITS",
0,
"Filename of kernel to convolve with input",
GAL_OPTIONS_GROUP_INPUT,
@@ -62,7 +62,7 @@ struct argp_option program_options[] =
{
"convolved",
UI_KEY_CONVOLVED,
- "STR",
+ "FITS",
0,
"Convolved image file to avoid convolution.",
GAL_OPTIONS_GROUP_INPUT,
@@ -88,7 +88,7 @@ struct argp_option program_options[] =
{
"widekernel",
UI_KEY_WIDEKERNEL,
- "STR",
+ "FITS",
0,
"Filename of wider kernel for better qthresh",
GAL_OPTIONS_GROUP_INPUT,
diff --git a/bin/noisechisel/astnoisechisel.conf
b/bin/noisechisel/astnoisechisel.conf
index edbadcc..f57f788 100644
--- a/bin/noisechisel/astnoisechisel.conf
+++ b/bin/noisechisel/astnoisechisel.conf
@@ -3,7 +3,7 @@
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
@@ -12,7 +12,7 @@
# $ info astnoisechisel # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2015-2021, Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
@@ -28,11 +28,11 @@
largetilesize 200,200
# Detection:
- meanmedqdiff 0.005
+ meanmedqdiff 0.01
qthresh 0.3
- outliersigma 10
+ outliersigma 5
outliersclip 3,0.2
- smoothwidth 3
+ smoothwidth 5
erode 2
erodengb 4
noerodequant 0.99
diff --git a/bin/noisechisel/authors-cite.h b/bin/noisechisel/authors-cite.h
index b7c5acb..6476187 100644
--- a/bin/noisechisel/authors-cite.h
+++ b/bin/noisechisel/authors-cite.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2017-2019, Free Software Foundation, Inc.
+Copyright (C) 2017-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,12 +26,31 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
-
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
-
-#define PROGRAM_BIBTEX ""
+ put a row of '-' with the same length and then put the BibTeX.
+
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
+
+#define PROGRAM_BIBTEX "" \
+ "Paper on NoiseChisel improvements since 2015\n" \
+ "--------------------------------------------\n" \
+ "@ARTICLE{noisechisel_segment_2019,\n" \
+ " author = {{Akhlaghi}, Mohammad},\n" \
+ " title = \"{Carving out the low surface brightness universe with
NoiseChisel}\",\n" \
+ " journal = {arXiv e-prints},\n" \
+ " keywords = {Astrophysics - Instrumentation and Methods for
Astrophysics,\n" \
+ " Astrophysics - Astrophysics of Galaxies,\n" \
+ " Computer Science - Computer Vision and Pattern
Recognition},\n" \
+ " year = \"2019\",\n" \
+ " month = \"Sep\",\n" \
+ " eid = {arXiv:1909.11230},\n" \
+ " pages = {arXiv:1909.11230},\n" \
+ " archivePrefix = {arXiv},\n" \
+ " eprint = {1909.11230},\n" \
+ " primaryClass = {astro-ph.IM},\n" \
+ " adsurl =
{https://ui.adsabs.harvard.edu/abs/2019arXiv190911230A},\n" \
+ " adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n" \
+ "}\n"
#define PROGRAM_AUTHORS "Mohammad Akhlaghi"
diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index 6baa8c4..66154dd 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -296,7 +296,7 @@ detection_fill_holes_open(void *in_prm)
tile->block=fho_prm->workbin;
/* Copy the tile into the contiguous patch of memory to work on, but
- first reset the size element so `gal_data_copy_to_allocated' knows
+ first reset the size element so 'gal_data_copy_to_allocated' knows
there is enough space. */
copy->flag=0;
copy->size=p->maxltcontig;
@@ -378,8 +378,8 @@ detection_pseudo_find(struct noisechiselparams *p,
gal_data_t *workbin,
/* Allocate the space necessary to work on each tile (to avoid having to
allocate it it separately for each tile and within each
- thread. `maxltcontig' is the maximum contiguous patch of memory needed
- to store all tiles. Finally, since we are working on a `uint8_t' type,
+ thread. 'maxltcontig' is the maximum contiguous patch of memory needed
+ to store all tiles. Finally, since we are working on a 'uint8_t' type,
the size of each element is only 1 byte. */
fho_prm.copyspace=gal_pointer_allocate(GAL_TYPE_UINT8,
p->cp.numthreads*p->maxltcontig, 0,
@@ -400,7 +400,7 @@ detection_pseudo_find(struct noisechiselparams *p,
gal_data_t *workbin,
/* Do each step. */
while(fho_prm.step<3)
{
- /* Put a copy of `workbin' into `bin' for every step (only
+ /* Put a copy of 'workbin' into 'bin' for every step (only
necessary for the second step and after). For the first time
it was already copied.*/
if(fho_prm.step>1)
@@ -408,7 +408,8 @@ detection_pseudo_find(struct noisechiselparams *p,
gal_data_t *workbin,
/* Do the respective step. */
gal_threads_spin_off(detection_fill_holes_open, &fho_prm,
- p->ltl.tottiles, p->cp.numthreads);
+ p->ltl.tottiles, p->cp.numthreads,
+ p->cp.minmapsize, p->cp.quietmmap);
/* Reset the blank values (if they were changed). */
if( p->blankasforeground==0 && gal_blank_present(p->input,0) )
@@ -440,12 +441,12 @@ detection_pseudo_find(struct noisechiselparams *p,
gal_data_t *workbin,
++fho_prm.step;
}
- /* Clean up: the array in `bin' should just be replaced with that in
- `workbin' because it is used in later steps. */
+ /* Clean up: the array in 'bin' should just be replaced with that in
+ 'workbin' because it is used in later steps. */
if(workbin->mmapname)
{
- /* Delete the memory mapped file and set the filename of `bin'
- for `workbin'. */
+ /* Delete the memory mapped file and set the filename of 'bin'
+ for 'workbin'. */
remove(workbin->mmapname);
free(workbin->mmapname);
workbin->mmapname=bin->mmapname;
@@ -459,14 +460,15 @@ detection_pseudo_find(struct noisechiselparams *p,
gal_data_t *workbin,
}
else
gal_threads_spin_off(detection_fill_holes_open, &fho_prm,
- p->ltl.tottiles, p->cp.numthreads);
+ p->ltl.tottiles, p->cp.numthreads,
+ p->cp.minmapsize, p->cp.quietmmap);
/* Clean up. */
free(fho_prm.copyspace);
/* Label all regions, but first, deal with the blank pixels in the
- `workbin' dataset when working on the Sky. Recall that in this case,
+ 'workbin' dataset when working on the Sky. Recall that in this case,
the blank pixels are the detections. On the Sky image, blank should be
set to 1 (because we want the detected objects to have the same labels
as the pseudo-detections that cover them). This will allow us to later
@@ -493,8 +495,8 @@ detection_sn_write_to_file(struct noisechiselparams *p,
gal_data_t *sn,
gal_list_str_t *comments=NULL;
/* Comment for extension on further explanation. */
- if( asprintf(&str, "See also: `%s' HDU of output with "
- "`--checkdetection'", ( s0d1D2<2
+ if( asprintf(&str, "See also: '%s' HDU of output with "
+ "'--checkdetection'", ( s0d1D2<2
? "PSEUDOS-FOR-SN": "DILATED" ))<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
gal_list_str_add(&comments, str, 0);
@@ -558,7 +560,7 @@ detection_sn(struct noisechiselparams *p, gal_data_t
*worklab, size_t num,
/* Allocate all the necessary arrays, note that since we want to put each
object's information into the same index, the number of allocated
- spaces has to be `tablen=num+1'. */
+ spaces has to be 'tablen=num+1'. */
area = gal_pointer_allocate(GAL_TYPE_SIZE_T, tablen, 1, __func__,
"area");
brightness = gal_pointer_allocate(GAL_TYPE_FLOAT64, tablen, 1, __func__,
@@ -807,10 +809,10 @@ detection_pseudo_real(struct noisechiselparams *p)
if( sn->size < p->minnumfalse)
error(EXIT_FAILURE, 0, "only %zu pseudo-detections could be found "
"over the sky region to estimate an S/N. This is less than "
- "%zu (value to `--minnumfalse' option). Please adjust "
- "parameters like `--dthresh', `--snminarea', or make sure "
+ "%zu (value to '--minnumfalse' option). Please adjust "
+ "parameters like '--dthresh', '--snminarea', or make sure "
"that there actually is sufficient sky area after initial "
- "detection. You can use `--checkdetection' to see every step "
+ "detection. You can use '--checkdetection' to see every step "
"until this point", sn->size, p->minnumfalse);
@@ -928,12 +930,12 @@ detection_remove_false_initial(struct noisechiselparams
*p,
"newlabels");
/* Find the new labels for all the existing labels. Recall that
- `newlabels' was initialized to zero, so any label that is not given a
+ 'newlabels' was initialized to zero, so any label that is not given a
new label here will be automatically removed. After the first pixel of
a label overlaps with dbyt[i], we don't need to check the rest of that
object's pixels. At this point, tokeep is only binary: 0 or 1.
- Note that the zeroth element of `tokeep' can also be non zero, this is
+ Note that the zeroth element of 'tokeep' can also be non zero, this is
because the holes of the labeled regions might be filled during
filling the holes, but have not been filled in the original labeled
array. They are not important so you can just ignore them. */
@@ -965,7 +967,7 @@ detection_remove_false_initial(struct noisechiselparams *p,
asked for growth, if the edges of the objects in the image are sharp
enough, no growth will be necessary (and thus the labeled image won't
be re-written during growth). So it is necessary to check for growth
- here and later do it in `detection_quantile_expand'. */
+ here and later do it in 'detection_quantile_expand'. */
p->numexpand=0;
b=workbin->array;
l=p->olabel->array;
@@ -1025,7 +1027,7 @@ detection_remove_false_initial(struct noisechiselparams
*p,
/* Expand the initial detections based on the quantile threshold and then
label the connected regions. If expansion is not possible, then return
- the `GAL_BLANK_SIZET'.*/
+ the 'GAL_BLANK_SIZET'.*/
static size_t
detection_quantile_expand(struct noisechiselparams *p, gal_data_t *workbin)
{
@@ -1186,32 +1188,39 @@ detection(struct noisechiselparams *p)
if(!p->cp.quiet) gettimeofday(&t1, NULL);
if(p->detgrowquant!=1.0f)
{
+ /* Grow the detections and report the number of expanded (if
+ necessary). */
num_expanded=detection_quantile_expand(p, workbin);
if(num_expanded!=GAL_BLANK_SIZE_T)
- num_true_initial=num_expanded;
- }
-
-
- /* Update the user on the progress, if necessary. */
- if(!p->cp.quiet && p->detgrowquant!=1.0f && num_expanded!=GAL_BLANK_SIZE_T )
- {
- /* If the user hasn't asked for a labeled image, then don't confuse
- them with the number of detections, just let them know that growth
- is complete. */
- if(p->label)
- {
- if( asprintf(&msg, "%zu detections after growth to %.3f "
- "quantile.", num_true_initial, p->detgrowquant)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- }
- else
{
- if( asprintf(&msg, "Growth to %.3f quantile complete.",
- p->detgrowquant)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ /* Set the number of expanded objects. */
+ num_true_initial=num_expanded;
+
+ /* If not in quiet-mode, let the user know how its going. */
+ if(!p->cp.quiet)
+ {
+ /* If the user hasn't asked for a labeled image, then don't
+ confuse them with the number of detections, just let them
+ know that growth is complete. */
+ if(p->label)
+ {
+ if( asprintf(&msg, "%zu detections after growth to %.3f "
+ "quantile.", num_true_initial,
+ p->detgrowquant)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation",
+ __func__);
+ }
+ else
+ {
+ if( asprintf(&msg, "Growth to %.3f quantile complete.",
+ p->detgrowquant)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation",
+ __func__);
+ }
+ gal_timing_report(&t1, msg, 2);
+ free(msg);
+ }
}
- gal_timing_report(&t1, msg, 2);
- free(msg);
}
@@ -1251,8 +1260,8 @@ detection(struct noisechiselparams *p)
/* p->binary was used to keep the initial pseudo-detection threshold. But
- we don't need it any more, so we'll just free it and put the `workbin'
- array in its place. Note that `workbin' has a map of all the detected
+ we don't need it any more, so we'll just free it and put the 'workbin'
+ array in its place. Note that 'workbin' has a map of all the detected
objects, which is still necessary during NoiseChisel. */
gal_data_free(p->binary);
p->binary=workbin;
@@ -1265,7 +1274,7 @@ detection(struct noisechiselparams *p)
/* If the user wanted to check the threshold and hasn't called
- `continueaftercheck', then stop NoiseChisel. */
+ 'continueaftercheck', then stop NoiseChisel. */
if(p->detectionname && !p->continueaftercheck)
ui_abort_after_check(p, p->detectionname, NULL,
"showing all detection steps");
diff --git a/bin/noisechisel/detection.h b/bin/noisechisel/detection.h
index 6613f75..c56d7e1 100644
--- a/bin/noisechisel/detection.h
+++ b/bin/noisechisel/detection.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/noisechisel/kernel-2d.h b/bin/noisechisel/kernel-2d.h
index 5afcf2a..d9ac583 100644
--- a/bin/noisechisel/kernel-2d.h
+++ b/bin/noisechisel/kernel-2d.h
@@ -5,7 +5,7 @@ This is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2018-2019, Free Software Foundation, Inc.
+Copyright (C) 2018-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -48,7 +48,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
Convert it to C code
--------------------
- Put the following C program into a file called `kernel.c'.
+ Put the following C program into a file called 'kernel.c'.
#include <stdio.h>
#include <stdlib.h>
@@ -74,7 +74,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
if(i % img->dsize[1] == 0 ) printf("\n\n");
}
- // We cannot use `\b' here, since we are writing directly
+ // We cannot use '\b' here, since we are writing directly
// to the command-line, so we'll first write the number,
// then decide if any subsequent character (a comma)
// should be written.
@@ -96,7 +96,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
-----------------
We can now compile and run that C program and put the outputs in
- `kernel.c'. Once its created, copy the contents of `kernel-2d.h' after
+ 'kernel.c'. Once its created, copy the contents of 'kernel-2d.h' after
these comments.
$ astbuildprog -q kernel.c > kernel-2d.h
diff --git a/bin/noisechisel/main.c b/bin/noisechisel/main.c
index 6161371..8c34330 100644
--- a/bin/noisechisel/main.c
+++ b/bin/noisechisel/main.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/noisechisel/main.h b/bin/noisechisel/main.h
index f0d62c5..63aba20 100644
--- a/bin/noisechisel/main.h
+++ b/bin/noisechisel/main.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -106,6 +106,7 @@ struct noisechiselparams
gal_data_t *olabel; /* Labels of objects in the detection. */
gal_data_t *expand_thresh; /* Quantile threshold to expand per tile. */
gal_data_t *exp_thresh_full; /* Full array containing growth thresh. */
+ gal_data_t *noskytiles; /* Tiles to not use for Sky. */
gal_data_t *sky; /* Mean of undetected pixels, per tile. */
gal_data_t *std; /* STD of undetected pixels, per tile. */
size_t maxtcontig; /* Maximum contiguous space for a tile. */
diff --git a/bin/noisechisel/noisechisel.c b/bin/noisechisel/noisechisel.c
index 1227e06..1d347b2 100644
--- a/bin/noisechisel/noisechisel.c
+++ b/bin/noisechisel/noisechisel.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -160,11 +160,11 @@ noisechisel_output(struct noisechiselparams *p)
/* Write the detected pixels and useful information into it's header. */
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "DETSN", 0, &p->detsnthresh,
0, "Minimum S/N of true pseudo-detections", 0,
- "ratio");
+ "ratio", 0);
if(p->label)
gal_fits_key_list_add(&keys, GAL_TYPE_SIZE_T, "NUMLABS", 0,
&p->numdetections, 0, "Total number of labels "
- "(inclusive)", 0, "counter");
+ "(inclusive)", 0, "counter", 0);
gal_fits_key_list_reverse(&keys);
if(p->label)
{
@@ -193,13 +193,13 @@ noisechisel_output(struct noisechiselparams *p)
p->std->name="SKY_STD";
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MAXSTD", 0, &p->maxstd, 0,
"Maximum raw tile standard deviation", 0,
- p->input->unit);
+ p->input->unit, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MINSTD", 0, &p->minstd, 0,
"Minimum raw tile standard deviation", 0,
- p->input->unit);
+ p->input->unit, 0);
gal_fits_key_list_add(&keys, GAL_TYPE_FLOAT32, "MEDSTD", 0, &p->medstd, 0,
"Median raw tile standard deviation", 0,
- p->input->unit);
+ p->input->unit, 0);
gal_tile_full_values_write(p->std, &p->cp.tl, !p->ignoreblankintiles,
p->cp.output, keys, PROGRAM_NAME);
p->std->name=NULL;
@@ -213,7 +213,7 @@ noisechisel_output(struct noisechiselparams *p)
/* Let the user know that the output is written. */
if(!p->cp.quiet)
- printf(" - Output written to `%s'.\n", p->cp.output);
+ printf(" - Output written to '%s'.\n", p->cp.output);
}
@@ -248,28 +248,14 @@ noisechisel(struct noisechiselparams *p)
/* Remove false detections. */
detection(p);
- /* If we have any detections, find the Sky value and subtract it from the
- input and convolved images. */
- if(p->numdetections)
- {
- /* Find the final Sky and Sky STD values. */
- sky_and_std(p, p->skyname);
+ /* Find the final Sky and Sky STD values. */
+ sky_and_std(p, p->skyname);
- /* Abort if the user only wanted to see until this point.*/
- if(p->skyname && !p->continueaftercheck)
- ui_abort_after_check(p, p->skyname, NULL,
- "derivation of final Sky (and its STD) value");
+ /* Abort if the user only wanted to see until this point.*/
+ if(p->skyname && !p->continueaftercheck)
+ ui_abort_after_check(p, p->skyname, NULL,
+ "derivation of final Sky (and its STD) value");
- /* Write the output. */
- noisechisel_output(p);
- }
- else
- {
- if(p->cp.quiet)
- error(0, 0, "no output file created: no detections could found "
- "in `%s' with given parameters", p->inputname);
- else
- gal_timing_report(NULL, "NO OUTPUT FILE CREATED (try with "
- "`--checkdetection' to see why)", 1);
- }
+ /* Write the output. */
+ noisechisel_output(p);
}
diff --git a/bin/noisechisel/noisechisel.h b/bin/noisechisel/noisechisel.h
index c933f4e..b5a289e 100644
--- a/bin/noisechisel/noisechisel.h
+++ b/bin/noisechisel/noisechisel.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/noisechisel/sky.c b/bin/noisechisel/sky.c
index cd66b55..72bf3c5 100644
--- a/bin/noisechisel/sky.c
+++ b/bin/noisechisel/sky.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -59,6 +59,7 @@ sky_mean_std_undetected(void *in_prm)
struct noisechiselparams *p=(struct noisechiselparams *)tprm->params;
int setblank, type=GAL_TYPE_FLOAT32;
+ uint8_t *noskytiles=p->noskytiles->array;
size_t i, tind, numsky, bdsize=2, ndim=p->sky->ndim;
size_t refarea, twidth=gal_type_sizeof(GAL_TYPE_FLOAT32);
gal_data_t *tile, *fusage, *busage, *bintile, *sigmaclip;
@@ -90,71 +91,80 @@ sky_mean_std_undetected(void *in_prm)
tile = &p->cp.tl.tiles[tind];
refarea = p->skyfracnoblank ? 0 : tile->size;
- /* Correct the fake binary tile's properties to be the same as this
- one, then count the number of zero valued elements in it. Note
- that the `CHECK_BLANK' flag of `GAL_TILE_PARSE_OPERATE' is set to
- 1. So blank values in the input array are not counted. */
- bintile->size=tile->size;
- bintile->dsize=tile->dsize;
- bintile->array=gal_tile_block_relative_to_other(tile, p->binary);
- GAL_TILE_PARSE_OPERATE(tile, bintile, 1, 1, {
- if(p->skyfracnoblank) ++refarea;
- if(!*o) ++numsky;
- });
-
- /* Only continue, if the fraction of Sky values is less than the
- requested fraction. */
- setblank=0;
- if( (float)(numsky)/(float)(refarea) > p->minskyfrac)
+ /* If this tile is already known to have signal in it (from the
+ 'qthresh' phase) it will have a value of '1' in the 'noskytiles'
+ array and should be set to blank here too. */
+ setblank=noskytiles[tind];
+ if(setblank==0)
{
- /* Re-initialize the usage array's size information (will be
- corrected to this tile's size by
- `gal_data_copy_to_allocated'). */
- busage->ndim = fusage->ndim = ndim;
- busage->size = fusage->size = p->maxtcontig;
- gal_data_copy_to_allocated(tile, fusage);
- gal_data_copy_to_allocated(bintile, busage);
-
-
- /* Set all the non-zero pixels in `busage' to NaN in `fusage'. */
- busage->flag = fusage->flag = 0;
- gal_blank_flag_apply(fusage, busage);
-
-
- /* Do the sigma-clipping. */
- sigmaclip=gal_statistics_sigma_clip(fusage, p->sigmaclip[0],
- p->sigmaclip[1], 1, 1);
-
- /* When there are zero-valued pixels on the edges of the dataset
- (that have not been set to NaN/blank), given special
- conditions, the whole zero-valued region can get a binary
- value of 1 and so the Sky and its standard deviation can
- become zero. So, we need ignore such tiles. */
- if( ((float *)(sigmaclip->array))[3]==0.0 )
- setblank=1;
- else
+ /* Correct the fake binary tile's properties to be the same as
+ this one, then count the number of zero valued elements in
+ it. Note that the 'CHECK_BLANK' flag of
+ 'GAL_TILE_PARSE_OPERATE' is set to 1. So blank values in the
+ input array are not counted. */
+ bintile->size=tile->size;
+ bintile->dsize=tile->dsize;
+ bintile->array=gal_tile_block_relative_to_other(tile, p->binary);
+ GAL_TILE_PARSE_OPERATE(tile, bintile, 1, 1, {
+ if(p->skyfracnoblank) ++refarea;
+ if(!*o) ++numsky;
+ });
+
+ /* Only continue, if the fraction of Sky values is less than the
+ requested fraction. */
+ if( (float)(numsky)/(float)(refarea) > p->minskyfrac)
{
- /* Copy the sigma-clipped mean and STD to their respective
- places in the tile arrays. But first, make sure
- `sigmaclip' has the same type as the sky and std
- arrays. */
- sigmaclip=gal_data_copy_to_new_type_free(sigmaclip, type);
- memcpy(gal_pointer_increment(p->sky->array, tind, type),
- gal_pointer_increment(sigmaclip->array, 2, type),
- twidth);
- memcpy(gal_pointer_increment(p->std->array, tind, type),
- gal_pointer_increment(sigmaclip->array, 3, type),
- twidth);
+ /* Re-initialize the usage array's size information (will be
+ corrected to this tile's size by
+ 'gal_data_copy_to_allocated'). */
+ busage->ndim = fusage->ndim = ndim;
+ busage->size = fusage->size = p->maxtcontig;
+ gal_data_copy_to_allocated(tile, fusage);
+ gal_data_copy_to_allocated(bintile, busage);
+
+
+ /* Set all the non-zero pixels in 'busage' to NaN in
+ 'fusage'. */
+ busage->flag = fusage->flag = 0;
+ gal_blank_flag_apply(fusage, busage);
+
+
+ /* Do the sigma-clipping. */
+ sigmaclip=gal_statistics_sigma_clip(fusage, p->sigmaclip[0],
+ p->sigmaclip[1], 1, 1);
+
+
+ /* When there are zero-valued pixels on the edges of the
+ dataset (that have not been set to NaN/blank), given
+ special conditions, the whole zero-valued region can get a
+ binary value of 1 and so the Sky and its standard
+ deviation can become zero. So, we need ignore such
+ tiles. */
+ if( ((float *)(sigmaclip->array))[3]==0.0 )
+ setblank=1;
+ else
+ {
+ /* Copy the sigma-clipped mean and STD to their
+ respective places in the tile arrays. But first, make
+ sure 'sigmaclip' has the same type as the sky and std
+ arrays. */
+ sigmaclip=gal_data_copy_to_new_type_free(sigmaclip, type);
+ memcpy(gal_pointer_increment(p->sky->array, tind, type),
+ gal_pointer_increment(sigmaclip->array, 2, type),
+ twidth);
+ memcpy(gal_pointer_increment(p->std->array, tind, type),
+ gal_pointer_increment(sigmaclip->array, 3, type),
+ twidth);
+ }
+
+ /* Clean up. */
+ gal_data_free(sigmaclip);
}
-
- /* Clean up. */
- gal_data_free(sigmaclip);
+ else
+ setblank=1;
}
- else
- setblank=1;
- /* If the tile is marked as being blank, write blank values into
- it. */
+ /* If the tile is marked to be blank, write blank values into it. */
if(setblank==1)
{
gal_blank_write(gal_pointer_increment(p->sky->array, tind, type),
@@ -197,17 +207,18 @@ sky_and_std(struct noisechiselparams *p, char *checkname)
/* Allocate space for the mean and standard deviation. */
- p->sky=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, p->input->ndim, tl->numtiles,
- NULL, 0, cp->minmapsize, p->cp.quietmmap, NULL,
- p->input->unit, NULL);
- p->std=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, p->input->ndim, tl->numtiles,
- NULL, 0, cp->minmapsize, p->cp.quietmmap, NULL,
- p->input->unit, NULL);
+ p->sky=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, p->input->ndim,
+ tl->numtiles, NULL, 0, cp->minmapsize,
+ p->cp.quietmmap, NULL, p->input->unit, NULL);
+ p->std=gal_data_alloc(NULL, GAL_TYPE_FLOAT32, p->input->ndim,
+ tl->numtiles, NULL, 0, cp->minmapsize,
+ p->cp.quietmmap, NULL, p->input->unit, NULL);
/* Find the Sky and its STD on proper tiles. */
gal_threads_spin_off(sky_mean_std_undetected, p, tl->tottiles,
- cp->numthreads);
+ cp->numthreads, p->cp.minmapsize,
+ p->cp.quietmmap);
if(checkname)
{
p->sky->name="SKY";
@@ -291,8 +302,8 @@ sky_subtract(struct noisechiselparams *p)
/* A small sanity check. */
if(p->sky->type!=GAL_TYPE_FLOAT32)
- error(EXIT_FAILURE, 0, "%s: only `float32' type is acceptable "
- "for sky values. but `p->sky' has type `%s'", __func__,
+ error(EXIT_FAILURE, 0, "%s: only 'float32' type is acceptable "
+ "for sky values. but 'p->sky' has type '%s'", __func__,
gal_type_name(p->sky->type, 1));
/* Go over all the tiles. */
diff --git a/bin/noisechisel/sky.h b/bin/noisechisel/sky.h
index a7d308f..3c7be85 100644
--- a/bin/noisechisel/sky.h
+++ b/bin/noisechisel/sky.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/noisechisel/threshold.c b/bin/noisechisel/threshold.c
index 41f3e12..3ca3d03 100644
--- a/bin/noisechisel/threshold.c
+++ b/bin/noisechisel/threshold.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -33,6 +33,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gnuastro/threads.h>
#include <gnuastro/pointer.h>
#include <gnuastro/statistics.h>
+#include <gnuastro/permutation.h>
#include <gnuastro/interpolate.h>
#include <gnuastro-internal/timing.h>
@@ -102,7 +103,7 @@ threshold_apply_on_thread(void *in_prm)
tile->block=p->conv;
}
- /* Apply the threshold: When the `>' comparison fails, it can be
+ /* Apply the threshold: When the '>' comparison fails, it can be
either because the pixel was actually smaller than the
threshold, or that it was a NaN value. In the first case,
return 0, in the second, return a blank value.
@@ -142,7 +143,7 @@ threshold_apply_on_thread(void *in_prm)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s so we "
"can address the problem. A value of %d had for "
- "`taprm->kind' is not valid", __func__, PACKAGE_BUGREPORT,
+ "'taprm->kind' is not valid", __func__, PACKAGE_BUGREPORT,
taprm->kind);
}
}
@@ -162,8 +163,9 @@ threshold_apply(struct noisechiselparams *p, float *value1,
float *value2, int kind)
{
struct threshold_apply_p taprm={value1, value2, kind, p};
- gal_threads_spin_off(threshold_apply_on_thread, &taprm, p->cp.tl.tottiles,
- p->cp.numthreads);
+ gal_threads_spin_off(threshold_apply_on_thread, &taprm,
+ p->cp.tl.tottiles, p->cp.numthreads,
+ p->cp.minmapsize, p->cp.quietmmap);
}
@@ -219,11 +221,12 @@ threshold_write_sn_table(struct noisechiselparams *p,
gal_data_t *insn,
gal_table_comments_add_intro(&comments, PROGRAM_STRING, &p->rawtime);
- /* Write the table. Note that we'll set the `dontdelete' argument to 0
+ /* Write the table. Note that we'll set the 'dontdelete' argument to 0
because when the output is a FITS table, we want all the tables in one
FITS file. We have already deleted any existing file with the same
- name in `ui_set_output_names'.*/
- gal_table_write(cols, comments, p->cp.tableformat, filename, extname, 0);
+ name in 'ui_set_output_names'.*/
+ gal_table_write(cols, NULL, comments, p->cp.tableformat, filename,
+ extname, 0);
/* Clean up (if necessary). */
@@ -264,21 +267,22 @@ threshold_interp_smooth(struct noisechiselparams *p,
gal_data_t **first,
/* A small sanity check. */
if( (*first)->next )
- error(EXIT_FAILURE, 0, "%s: `first' must not have any `next' pointer.",
+ error(EXIT_FAILURE, 0, "%s: 'first' must not have any 'next' pointer.",
__func__);
if( (*second)->next )
- error(EXIT_FAILURE, 0, "%s: `second' must not have any `next' pointer.",
+ error(EXIT_FAILURE, 0, "%s: 'second' must not have any 'next' pointer.",
__func__);
if( third && (*third)->next )
- error(EXIT_FAILURE, 0, "%s: `third' must not have any `next' pointer.",
+ error(EXIT_FAILURE, 0, "%s: 'third' must not have any 'next' pointer.",
__func__);
/* Do the interpolation of both arrays. */
(*first)->next = *second;
if(third) (*second)->next = *third;
- tmp=gal_interpolate_close_neighbors(*first, tl, cp->interpmetric,
- cp->interpnumngb, cp->numthreads,
- cp->interponlyblank, 1);
+ tmp=gal_interpolate_neighbors(*first, tl, cp->interpmetric,
+ cp->interpnumngb, cp->numthreads,
+ cp->interponlyblank, 1,
+ GAL_INTERPOLATE_NEIGHBORS_FUNC_MEDIAN);
gal_data_free(*first);
gal_data_free(*second);
if(third) gal_data_free(*third);
@@ -408,7 +412,7 @@ qthresh_on_tile(void *in_prm)
for(i=0; tprm->indexs[i] != GAL_BLANK_SIZE_T; ++i)
{
/* Re-initialize the usage array's space (will be changed in
- `gal_data_copy_to_allocated' for each tile). */
+ 'gal_data_copy_to_allocated' for each tile). */
usage->ndim=ndim;
usage->size=p->maxtcontig;
memcpy(usage->dsize, p->maxtsize, ndim*sizeof *p->maxtsize);
@@ -421,7 +425,7 @@ qthresh_on_tile(void *in_prm)
/* Temporarily change the tile's pointers so we can do the work on
the convolved image, then copy the desired contents into the
- already allocated `usage' array. */
+ already allocated 'usage' array. */
tarray=tile->array; tblock=tile->block;
tile->array=gal_tile_block_relative_to_other(tile, meanconv);
tile->block=meanconv;
@@ -432,7 +436,7 @@ qthresh_on_tile(void *in_prm)
/* Find the mean's quantile on this tile, note that we have already
copied the tile's dataset to a newly allocated place. So we have
- set the `inplace' flag to `1' to avoid extra allocation. */
+ set the 'inplace' flag to '1' to avoid extra allocation. */
mean=gal_statistics_mean(usage);
num=gal_statistics_number(usage);
mean=gal_data_copy_to_new_type_free(mean, usage->type);
@@ -457,14 +461,14 @@ qthresh_on_tile(void *in_prm)
tarray=tile->array; tblock=tile->block;
tile->array=gal_tile_block_relative_to_other(tile, p->conv);
tile->block=p->conv;
- usage->ndim=ndim; /* Since usage was modified in */
- usage->size=p->maxtcontig; /* place, it needs to be */
- gal_data_copy_to_allocated(tile, usage); /* re-initialized. */
+ usage->ndim=ndim; /* Since usage was modified in */
+ usage->size=p->maxtcontig; /* place, it needs to be */
+ gal_data_copy_to_allocated(tile, usage);/* re-initialized. */
tile->array=tarray; tile->block=tblock;
}
/* Get the erosion quantile for this tile and save it. Note that
- the type of `qvalue' is the same as the input dataset. */
+ the type of 'qvalue' is the same as the input dataset. */
qvalue=gal_statistics_quantile(usage, p->qthresh, 1);
memcpy(gal_pointer_increment(qprm->erode_th->array, tind, type),
qvalue->array, twidth);
@@ -529,9 +533,9 @@ threshold_good_error(size_t number, int before0_after1,
size_t interpnumngb)
"(where the number may decrease even further).");
char *in3 = ( before0_after1
? "\n"
- " - (slightly) Increase `--outliersclip' to reject less "
+ " - (slightly) Increase '--outliersclip' to reject less "
"as outliers.\n"
- " - (slightly) Increase `--outliersigma' to reject less "
+ " - (slightly) Increase '--outliersigma' to reject less "
"as outliers.\n"
: "\n");
@@ -539,7 +543,7 @@ threshold_good_error(size_t number, int before0_after1,
size_t interpnumngb)
error(EXIT_FAILURE, 0, "%zu tiles usable %s!\n\n"
"This is smaller than the requested minimum value of %zu (value to "
- "the `--interpnumngb' option). %s\n\n"
+ "the '--interpnumngb' option). %s\n\n"
"There are several ways to address the problem. The best and most "
"highly recommended is to use a larger input if possible (when the "
@@ -548,23 +552,23 @@ threshold_good_error(size_t number, int before0_after1,
size_t interpnumngb)
"parameters mentioned below in the respective order (and therefore "
"cause scatter/inaccuracy in the final result). Hence its best to "
"not loosen them too much (recall that you can see all the option "
- "values to Gnuastro's programs by appending `-P' to the end of your "
+ "values to Gnuastro's programs by appending '-P' to the end of your "
"command).\n"
- " - (slightly) Decrease `--tilesize' so your tile-grid has more "
+ " - (slightly) Decrease '--tilesize' so your tile-grid has more "
"tiles.\n"
- " - (slightly) Increase `--meanmedqdiff' to accept more tiles.%s"
- " - (slightly) Decrease `--interpnumngb' to be less than %zu.\n\n"
+ " - (slightly) Increase '--meanmedqdiff' to accept more tiles.%s"
+ " - (slightly) Decrease '--interpnumngb' to be less than %zu.\n\n"
"---- Tip ----\n"
- "Append your command with `--checkqthresh' to see the "
+ "Append your command with '--checkqthresh' to see the "
"successful tiles in relation with this dataset's contents "
"before this crash. A visual inspection will greatly help in "
"finding the cause/solution for this particular dataset (note "
- "that the output of `--checkqthresh' is a multi-extension FITS "
+ "that the output of '--checkqthresh' is a multi-extension FITS "
"file).\n\n"
"To better understand this important step, please run the "
- "following command (press `SPACE'/arrow-keys to navigate and "
- "`Q' to return back to the command-line):\n\n"
+ "following command (press 'SPACE'/arrow-keys to navigate and "
+ "'Q' to return back to the command-line):\n\n"
" $ info gnuastro \"Quantifying signal in a tile\"\n", number,
in1, interpnumngb, in2, in3, number);
}
@@ -590,9 +594,9 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
/* Add image to check image if requested. If the user has asked for
- `oneelempertile', then the size of values is not going to be the same
+ 'oneelempertile', then the size of values is not going to be the same
as the input, making it hard to inspect visually. So we'll only put
- the full input when `oneelempertile' isn't requested. */
+ the full input when 'oneelempertile' isn't requested. */
if(p->qthreshname && !tl->oneelempertile)
{
gal_fits_img_write(p->conv ? p->conv : p->input, p->qthreshname, NULL,
@@ -606,10 +610,12 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
/* Allocate space for the quantile threshold values. */
qprm.erode_th=gal_data_alloc(NULL, p->input->type, p->input->ndim,
tl->numtiles, NULL, 0, cp->minmapsize,
- p->cp.quietmmap, NULL, p->input->unit, NULL);
+ p->cp.quietmmap, NULL, p->input->unit,
+ NULL);
qprm.noerode_th=gal_data_alloc(NULL, p->input->type, p->input->ndim,
tl->numtiles, NULL, 0, cp->minmapsize,
- p->cp.quietmmap, NULL, p->input->unit, NULL);
+ p->cp.quietmmap, NULL, p->input->unit,
+ NULL);
qprm.expand_th = ( p->detgrowquant!=1.0f
? gal_data_alloc(NULL, p->input->type, p->input->ndim,
tl->numtiles, NULL, 0, cp->minmapsize,
@@ -626,10 +632,12 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
/* Find the threshold on each tile, free the temporary processing space
and set the blank flag on both. Since they have the same blank
- elements, it is only necessary to check one (with the `updateflag'
+ elements, it is only necessary to check one (with the 'updateflag'
value set to 1), then update the next. */
qprm.p=p;
- gal_threads_spin_off(qthresh_on_tile, &qprm, tl->tottiles, cp->numthreads);
+ gal_threads_spin_off(qthresh_on_tile, &qprm, tl->tottiles,
+ cp->numthreads, cp->minmapsize,
+ cp->quietmmap);
free(qprm.usage);
if( gal_blank_present(qprm.erode_th, 1) )
{
@@ -661,11 +669,21 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
}
- /* Remove outliers if requested. */
- if(p->outliersigma!=0.0)
- gal_tileinternal_no_outlier(qprm.erode_th, qprm.noerode_th,
- qprm.expand_th, &p->cp.tl, p->outliersclip,
- p->outliersigma, p->qthreshname);
+ /* Remove the outliers. */
+ gal_tileinternal_no_outlier_local(qprm.erode_th, qprm.noerode_th,
+ qprm.expand_th, &cp->tl,
+ cp->interpmetric, cp->interpnumngb,
+ cp->numthreads, p->outliersclip,
+ p->outliersigma, p->qthreshname);
+
+
+ /* Use the no-outlier grid as a basis for later estimating the sky. To
+ see this array on the image, use 'gal_tile_full_values_write'. */
+ p->noskytiles=gal_blank_flag(qprm.erode_th);
+ /* For a check:
+ gal_tile_full_values_write(p->noskytiles, &cp->tl, 1,
+ "noskytiles.fits", NULL, NULL);
+ */
/* Check if the number of acceptable tiles is more than the minimum
@@ -676,6 +694,7 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
nval=((size_t *)(num->array))[0];
if( nval < cp->interpnumngb )
threshold_good_error(nval, 1, cp->interpnumngb);
+ gal_data_free(num);
/* Interpolate and smooth the derived values. */
@@ -716,7 +735,7 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
/* If the user wanted to check the threshold and hasn't called
- `continueaftercheck', then stop NoiseChisel. */
+ 'continueaftercheck', then stop NoiseChisel. */
if(p->qthreshname && !p->continueaftercheck)
ui_abort_after_check(p, p->qthreshname, NULL, "quantile threshold check");
}
diff --git a/bin/noisechisel/threshold.h b/bin/noisechisel/threshold.h
index a4bc4bd..0c7abeb 100644
--- a/bin/noisechisel/threshold.h
+++ b/bin/noisechisel/threshold.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index e930a0e..2f3e413 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -144,7 +144,7 @@ ui_initialize_options(struct noisechiselparams *p,
case GAL_OPTIONS_KEY_TABLEFORMAT:
cp->coptions[i].mandatory=GAL_OPTIONS_MANDATORY;
- cp->coptions[i].doc="`txt', `fits-ascii', `fits-binary'.";
+ cp->coptions[i].doc="'txt', 'fits-ascii', 'fits-binary'.";
break;
}
}
@@ -160,18 +160,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
{
struct noisechiselparams *p = state->input;
- /* Pass `gal_options_common_params' into the child parser. */
+ /* Pass 'gal_options_common_params' into the child parser. */
state->child_inputs[0] = &p->cp;
/* In case the user incorrectly uses the equal sign (for example
- with a short format or with space in the long format, then `arg`
+ with a short format or with space in the long format, then 'arg'
start with (if the short version was called) or be (if the long
version was called with a space) the equal sign. So, here we
check if the first character of arg is the equal sign, then the
user is warned and the program is stopped: */
if(arg && arg[0]=='=')
- argp_error(state, "incorrect use of the equal sign (`=`). For short "
- "options, `=` should not be used and for long options, "
+ argp_error(state, "incorrect use of the equal sign ('='). For short "
+ "options, '=' should not be used and for long options, "
"there should be no space between the option, equal sign "
"and value");
@@ -219,34 +219,34 @@ parse_opt(int key, char *arg, struct argp_state *state)
/*************** Sanity Check *******************/
/**************************************************************/
/* Read and check ONLY the options. When arguments are involved, do the
- check in `ui_check_options_and_arguments'. */
+ check in 'ui_check_options_and_arguments'. */
static void
ui_read_check_only_options(struct noisechiselparams *p)
{
/* If the convolved option is given, then the convolved HDU is also
mandatory. */
if(p->convolvedname && p->chdu==NULL)
- error(EXIT_FAILURE, 0, "no value given to `--chdu'. When the "
- "`--convolved' option is called (to specify a convolved image "
+ error(EXIT_FAILURE, 0, "no value given to '--chdu'. When the "
+ "'--convolved' option is called (to specify a convolved image "
"and avoid convolution) it is mandatory to also specify a HDU "
"for it");
/* Make sure that the no-erode-quantile is not smaller or equal to
qthresh. */
if( p->noerodequant <= p->qthresh)
- error(EXIT_FAILURE, 0, "the quantile for no erosion (`--noerodequant') "
- "must be larger than the base quantile threshold (`--qthresh', "
- "or `-t'). You have provided %.4f and %.4f for the former and "
+ error(EXIT_FAILURE, 0, "the quantile for no erosion ('--noerodequant') "
+ "must be larger than the base quantile threshold ('--qthresh', "
+ "or '-t'). You have provided %.4f and %.4f for the former and "
"latter, respectively", p->noerodequant, p->qthresh);
/* For the options that make tables, the table format option is
mandatory. */
if( p->checksn && p->cp.tableformat==0 )
- error(EXIT_FAILURE, 0, "`--tableformat' is necessary with the "
- "`--checksn' option.\n"
- "Please see description for `--tableformat' after running the "
- "following command for more information (use `SPACE' to go down "
- "the page and `q' to return to the command-line):\n\n"
+ error(EXIT_FAILURE, 0, "'--tableformat' is necessary with the "
+ "'--checksn' option.\n"
+ "Please see description for '--tableformat' after running the "
+ "following command for more information (use 'SPACE' to go down "
+ "the page and 'q' to return to the command-line):\n\n"
" $ info gnuastro \"Input Output options\"");
/* Kernel checks. */
@@ -259,7 +259,7 @@ ui_read_check_only_options(struct noisechiselparams *p)
if( gal_fits_name_is_fits(p->kernelname) && p->khdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified for kernel. When the "
"kernel is a FITS file, a HDU must also be specified. You "
- "can use the `--khdu' option and give it the HDU number "
+ "can use the '--khdu' option and give it the HDU number "
"(starting from zero), extension name, or anything "
"acceptable by CFITSIO");
}
@@ -273,8 +273,8 @@ ui_read_check_only_options(struct noisechiselparams *p)
/* If its FITS, see if a HDU has been provided. */
if( gal_fits_name_is_fits(p->widekernelname) && p->whdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified for the given wide kernel "
- "(`%s'). When the wide kernel is a FITS file, a HDU must also "
- "be specified. You can use the `--whdu' option and give it the "
+ "('%s'). When the wide kernel is a FITS file, a HDU must also "
+ "be specified. You can use the '--whdu' option and give it the "
"HDU number (starting from zero), extension name, or any "
"HDU identifier acceptable by CFITSIO", p->widekernelname);
}
@@ -284,11 +284,11 @@ ui_read_check_only_options(struct noisechiselparams *p)
(higher-is-better), not the contamination level
(lower-is-better). This actually happened in a few cases: where we
wanted a false detection rate of 0.0001 (a super-high value!), and
- instead of inputing 0.9999, we mistakenly gave `--snquant' a value of
- `0.0001'. We were thus fully confused with the output (an extremely
+ instead of inputing 0.9999, we mistakenly gave '--snquant' a value of
+ '0.0001'. We were thus fully confused with the output (an extremely
low value) and thought its a bug, while it wasn't! */
if(p->snquant<0.1)
- fprintf(stderr, "\nWARNING: Value of `--snquant' (`-c') is %g. Note "
+ fprintf(stderr, "\nWARNING: Value of '--snquant' ('-c') is %g. Note "
"that this is not a contamination rate (where lower is "
"better), it is a purity rate (where higher is better). If you "
"intentionally asked for such a low purity level, please "
@@ -312,7 +312,7 @@ ui_check_options_and_arguments(struct noisechiselparams *p)
if( gal_fits_name_is_fits(p->inputname) && p->cp.hdu==NULL )
error(EXIT_FAILURE, 0, "no HDU specified for input. When the input "
"is a FITS file, a HDU must also be specified, you can use "
- "the `--hdu' (`-h') option and give it the HDU number "
+ "the '--hdu' ('-h') option and give it the HDU number "
"(starting from zero), extension name, or anything "
"acceptable by CFITSIO");
}
@@ -531,7 +531,7 @@ ui_prepare_tiles(struct noisechiselparams *p)
gal_fits_img_write(check, tl->tilecheckname, NULL, PROGRAM_NAME);
gal_data_free(check);
- /* If `continueaftercheck' hasn't been called, abort NoiseChisel. */
+ /* If 'continueaftercheck' hasn't been called, abort NoiseChisel. */
if(!p->continueaftercheck)
ui_abort_after_check(p, tl->tilecheckname, NULL,
"showing all tiles over the image");
@@ -553,7 +553,7 @@ ui_ngb_check(size_t value, char *optionname, size_t ndim)
case 2:
if(value!=4 && value!=8)
error(EXIT_FAILURE, 0, "%zu is not an acceptable value for "
- "`--%s'. Acceptable values for 2D inputs are 4 or 8",
+ "'--%s'. Acceptable values for 2D inputs are 4 or 8",
value, optionname);
break;
case 3:
@@ -593,7 +593,7 @@ ui_preparations_read_input(struct noisechiselparams *p)
p->input->dsize,
p->input->wcs);
- /* When the input doesn't have a name, use `INPUT'. */
+ /* When the input doesn't have a name, use 'INPUT'. */
if(p->input->name==NULL)
gal_checkset_allocate_copy("INPUT", &p->input->name);
@@ -662,8 +662,8 @@ ui_preparations(struct noisechiselparams *p)
/* Make sure the convolved image is the same size as the input. */
if( gal_dimension_is_different(p->input, p->conv) )
- error(EXIT_FAILURE, 0, "%s (hdu %s), given to `--convolved' and "
- "`--convolvehdu', is not the same size as NoiseChisel's "
+ error(EXIT_FAILURE, 0, "%s (hdu %s), given to '--convolved' and "
+ "'--convolvehdu', is not the same size as NoiseChisel's "
"input: %s (hdu: %s)", p->convolvedname, p->chdu,
p->inputname, p->cp.hdu);
}
@@ -716,9 +716,9 @@ ui_read_check_inputs_setup(int argc, char *argv[],
struct gal_options_common_params *cp=&p->cp;
- /* Include the parameters necessary for argp from this program (`args.h')
- and for the common options to all Gnuastro (`commonopts.h'). We want
- to directly put the pointers to the fields in `p' and `cp', so we are
+ /* Include the parameters necessary for argp from this program ('args.h')
+ and for the common options to all Gnuastro ('commonopts.h'). We want
+ to directly put the pointers to the fields in 'p' and 'cp', so we are
simply including the header here to not have to use long macros in
those headers which make them hard to read and modify. This also helps
in having a clean environment: everything in those headers is only
@@ -831,12 +831,12 @@ ui_abort_after_check(struct noisechiselparams *p, char
*filename,
if(file2name)
{
- if( asprintf(&name, "`%s' and `%s'", filename, file2name)<0 )
+ if( asprintf(&name, "'%s' and '%s'", filename, file2name)<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
}
else
{
- if( asprintf(&name, "`%s'", filename)<0 )
+ if( asprintf(&name, "'%s'", filename)<0 )
error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
}
@@ -848,7 +848,7 @@ ui_abort_after_check(struct noisechiselparams *p, char
*filename,
"%s (%s) has been created.\n\n"
"If you want %s to continue its processing AND save any "
"requested check outputs, please run it again with "
- "`--continueaftercheck'.\n"
+ "'--continueaftercheck'.\n"
"------------------------------------------------\n",
PROGRAM_NAME, name, description, PROGRAM_NAME);
@@ -872,12 +872,15 @@ ui_free_report(struct noisechiselparams *p, struct
timeval *t1)
free(p->maxtsize);
free(p->maxltsize);
free(p->cp.output);
- if(p->skyname) free(p->skyname);
- if(p->detskyname) free(p->detskyname);
- if(p->qthreshname) free(p->qthreshname);
- if(p->detsn_s_name) free(p->detsn_s_name);
- if(p->detsn_d_name) free(p->detsn_d_name);
- if(p->detectionname) free(p->detectionname);
+ if(p->khdu) free(p->khdu);
+ if(p->whdu) free(p->whdu);
+ if(p->chdu) free(p->chdu);
+ if(p->skyname) free(p->skyname);
+ if(p->detskyname) free(p->detskyname);
+ if(p->qthreshname) free(p->qthreshname);
+ if(p->detsn_s_name) free(p->detsn_s_name);
+ if(p->detsn_d_name) free(p->detsn_d_name);
+ if(p->detectionname) free(p->detectionname);
/* Free the allocated datasets. */
gal_data_free(p->sky);
@@ -887,6 +890,7 @@ ui_free_report(struct noisechiselparams *p, struct timeval
*t1)
gal_data_free(p->kernel);
gal_data_free(p->binary);
gal_data_free(p->olabel);
+ gal_data_free(p->noskytiles);
gal_data_free(p->widekernel);
if(p->conv!=p->input) gal_data_free(p->conv);
diff --git a/bin/noisechisel/ui.h b/bin/noisechisel/ui.h
index c42df7d..b08a0ab 100644
--- a/bin/noisechisel/ui.h
+++ b/bin/noisechisel/ui.h
@@ -5,7 +5,7 @@ NoiseChisel is part of GNU Astronomy Utilities (Gnuastro)
package.
Original author:
Mohammad Akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2015-2019, Free Software Foundation, Inc.
+Copyright (C) 2015-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
diff --git a/bin/convertt/Makefile.am b/bin/query/Makefile.am
similarity index 57%
copy from bin/convertt/Makefile.am
copy to bin/query/Makefile.am
index 1935ff1..a3f9a16 100644
--- a/bin/convertt/Makefile.am
+++ b/bin/query/Makefile.am
@@ -1,9 +1,9 @@
## Process this file with automake to produce Makefile.inx
##
## Original author:
-## Mohammad Akhlaghi <mohammad@akhlaghi.org>
+## Mohammad akhlaghi <mohammad@akhlaghi.org>
## Contributing author(s):
-## Copyright (C) 2015-2019, Free Software Foundation, Inc.
+## Copyright (C) 2016-2021, Free Software Foundation, Inc.
##
## Gnuastro is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
@@ -20,27 +20,28 @@
## Necessary pre-processer and linker flags.
-AM_LDFLAGS = -L\$(top_builddir)/lib
-AM_CPPFLAGS = -I\$(top_srcdir)/bootstrapped/lib -I\$(top_srcdir)/lib
+AM_LDFLAGS = -L\$(top_builddir)/lib
+AM_CPPFLAGS = -I\$(top_builddir)/bootstrapped/lib \
+ -I\$(top_srcdir)/bootstrapped/lib \
+ -I\$(top_srcdir)/lib
-if COND_NORPATH
- MAYBE_NORPATH = $(CONFIG_LDADD)
-endif
## Program definition (name, linking, sources and headers)
-bin_PROGRAMS = astconvertt
+bin_PROGRAMS = astquery
-## Reason for linking with `libgnu' described in `bin/TEMPLATE/Makefile.am'.
-astconvertt_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la -lgnuastro \
- $(MAYBE_NORPATH)
+## Reason for linking with 'libgnu' described in 'bin/TEMPLATE/Makefile.am'.
+astquery_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+ -lgnuastro $(CONFIG_LDADD)
-astconvertt_SOURCES = main.c ui.c convertt.c color.c
+astquery_SOURCES = main.c ui.c query.c astron.c gaia.c ned.c tap.c \
+ vizier.c
-EXTRA_DIST = main.h authors-cite.h args.h ui.h convertt.h color.h
+EXTRA_DIST = main.h authors-cite.h args.h ui.h query.h astron.h \
+ gaia.h ned.h tap.h vizier.h
## The configuration file (distribute and install).
## NOTE: the man page is created in doc/Makefile.am
-dist_sysconf_DATA = astconvertt.conf
+dist_sysconf_DATA = astquery.conf
diff --git a/bin/crop/args.h b/bin/query/args.h
similarity index 57%
copy from bin/crop/args.h
copy to bin/query/args.h
index 27ab92d..87db422 100644
--- a/bin/crop/args.h
+++ b/bin/query/args.h
@@ -1,11 +1,11 @@
/*********************************************************************
-Crop - Crop a given size from one or multiple images.
-Crop is part of GNU Astronomy Utilities (Gnuastro) package.
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
- Mohammad Akhlaghi <mohammad@akhlaghi.org>
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -27,139 +27,145 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
+
/* Array of acceptable options. */
struct argp_option program_options[] =
{
- /* Input. */
+ /* Input options */
{
- "mode",
- UI_KEY_MODE,
- "STR",
+ "ccol",
+ UI_KEY_CCOL,
+ "STR,STR",
0,
- "Coordinate mode `img' or `wcs'.",
+ "Coordinate (RA, Dec) column names in dataset.",
GAL_OPTIONS_GROUP_INPUT,
- &p->mode,
- GAL_TYPE_STRING,
+ &p->ccol,
+ GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
- GAL_OPTIONS_MANDATORY,
- GAL_OPTIONS_NOT_SET,
- ui_parse_coordinate_mode
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
},
+
+
+
+
+
+ /* Output related options. */
{
- "hstartwcs",
- UI_KEY_HSTARTWCS,
- "INT",
+ "keeprawdownload",
+ UI_KEY_KEEPRAWDOWNLOAD,
0,
- "Header keyword number to start reading WCS.",
- GAL_OPTIONS_GROUP_INPUT,
- &p->hstartwcs,
- GAL_TYPE_SIZE_T,
- GAL_OPTIONS_RANGE_GE_0,
+ 0,
+ "Don't delete raw downloaded file.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->keeprawdownload,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
{
- "hendwcs",
- UI_KEY_HENDWCS,
- "INT",
+ "information",
+ UI_KEY_INFORMATION,
0,
- "Header keyword number to stop reading WCS.",
- GAL_OPTIONS_GROUP_INPUT,
- &p->hendwcs,
- GAL_TYPE_SIZE_T,
- GAL_OPTIONS_RANGE_GE_0,
+ 0,
+ "Print database or dataset information.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->information,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
{
- "zeroisnotblank",
- UI_KEY_ZEROISNOTBLANK,
- 0,
+ "limitinfo",
+ UI_KEY_LIMITINFO,
+ "STR",
0,
- "0.0 in float or double images are not blank.",
+ "Only retrieve dataset info. with this string.",
GAL_OPTIONS_GROUP_INPUT,
- &p->zeroisnotblank,
- GAL_OPTIONS_NO_ARG_TYPE,
- GAL_OPTIONS_RANGE_0_OR_1,
+ &p->limitinfo,
+ GAL_TYPE_STRING,
+ GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
-
-
-
-
- /* Output. */
{
- "noblank",
- UI_KEY_NOBLANK,
+ "dry-run",
+ UI_KEY_DRYRUN,
0,
0,
- "Remove parts of the crop box out of input image.",
+ "Only print the download command, don't run it.",
GAL_OPTIONS_GROUP_OUTPUT,
- &p->noblank,
+ &p->dryrun,
GAL_OPTIONS_NO_ARG_TYPE,
GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
+
+
+
+
+
+ /* Database and dataset. */
{
- "suffix",
- UI_KEY_SUFFIX,
+ "query",
+ UI_KEY_QUERY,
"STR",
0,
- "Suffix (postfix) of cropped images.",
- GAL_OPTIONS_GROUP_OUTPUT,
- &p->suffix,
+ "The raw query as a simple string.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->query,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
- GAL_OPTIONS_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET,
},
+ /* Generate query automatically */
{
0, 0, 0, 0,
- "Crop by center",
- UI_GROUP_CENTER_GENERAL
+ "Generate query internally (not compatible with '--query'):",
+ UI_GROUP_GENQUERY,
},
{
- "checkcenter",
- UI_KEY_CHECKCENTER,
- "FLT/INT",
+ "dataset",
+ UI_KEY_DATASET,
+ "STR",
0,
- "Width (in pixels) of box at center to check.",
- UI_GROUP_CENTER_GENERAL,
- &p->incheckcenter,
+ "Name of dataset in database.",
+ UI_GROUP_GENQUERY,
+ &p->datasetstr,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET,
- gal_options_parse_csv_float64
},
{
- "width",
- UI_KEY_WIDTH,
- "FLT[,...]",
+ "overlapwith",
+ UI_KEY_OVERLAPWITH,
+ "FITS",
0,
- "Width when crop is defined by its center.",
- UI_GROUP_CENTER_GENERAL,
- &p->width,
+ "Set query region to overlap with this image.",
+ GAL_OPTIONS_GROUP_INPUT,
+ &p->overlapwith,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET,
- gal_options_parse_csv_float64
},
{
"center",
UI_KEY_CENTER,
- "FLT[,...]",
+ "FLT,FLT",
0,
- "Central coordinates of a single crop.",
- UI_GROUP_CENTER_GENERAL,
+ "Center coords. to select by region in sky.",
+ UI_GROUP_GENQUERY,
&p->center,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
@@ -167,116 +173,97 @@ struct argp_option program_options[] =
GAL_OPTIONS_NOT_SET,
gal_options_parse_csv_float64
},
-
-
-
-
-
-
-
- {
- 0, 0, 0, 0,
- "Crop by center (when a catalog is given)",
- UI_GROUP_CENTER_CATALOG
- },
{
- "catalog",
- UI_KEY_CATALOG,
- "STR",
+ "radius",
+ UI_KEY_RADIUS,
+ "FLT",
0,
- "Input catalog filename.",
- UI_GROUP_CENTER_CATALOG,
- &p->catname,
+ "Radius around --center to select targets.",
+ UI_GROUP_GENQUERY,
+ &p->radius,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_SET,
+ gal_options_parse_csv_float64
},
{
- "cathdu",
- UI_KEY_CATHDU,
- "STR/INT",
+ "width",
+ UI_KEY_WIDTH,
+ "FLT[,FLT]",
0,
- "HDU of catalog, if it is a FITS table.",
- UI_GROUP_CENTER_CATALOG,
- &p->cathdu,
+ "Width of box around --center to select targets.",
+ UI_GROUP_GENQUERY,
+ &p->width,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_SET,
+ gal_options_parse_csv_float64
},
{
- "namecol",
- UI_KEY_NAMECOL,
- "STR/INT",
+ "range",
+ UI_KEY_RANGE,
+ "STR,FLT:FLT",
0,
- "Column no./info of crop filename (no suffix).",
- UI_GROUP_CENTER_CATALOG,
- &p->namecol,
+ "Range of selected targets in given column.",
+ UI_GROUP_GENQUERY,
+ &p->range,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_SET,
+ gal_options_parse_name_and_float64s
},
{
- "coordcol",
- UI_KEY_COORDCOL,
- "STR/INT",
+ "noblank",
+ UI_KEY_NOBLANK,
+ "STR[,STR]",
0,
- "Column no./info containing coordinates.",
- UI_GROUP_CENTER_CATALOG,
- &p->coordcol,
+ "No rows with blank value in given column(s).",
+ UI_GROUP_GENQUERY,
+ &p->noblank,
GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
-
-
-
-
-
- {
- 0, 0, 0, 0,
- "Crop by region",
- UI_GROUP_REGION
- },
{
- "section",
- UI_KEY_SECTION,
+ "column",
+ UI_KEY_COLUMN,
"STR",
0,
- "Image section string specifying crop range.",
- UI_GROUP_REGION,
- &p->section,
- GAL_TYPE_STRING,
+ "Column names to download from catalog.",
+ UI_GROUP_GENQUERY,
+ &p->columns,
+ GAL_TYPE_STRLL,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
{
- "polygon",
- UI_KEY_POLYGON,
- "STR",
+ "head",
+ UI_KEY_HEAD,
+ "INT",
0,
- "Polygon vertices of region to crop, keep inside.",
- UI_GROUP_REGION,
- &p->polygon,
- GAL_TYPE_STRING,
+ "Only download given number of top rows.",
+ UI_GROUP_GENQUERY,
+ &p->head,
+ GAL_TYPE_SIZE_T,
GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
- GAL_OPTIONS_NOT_SET
+ GAL_OPTIONS_NOT_SET,
},
{
- "outpolygon",
- UI_KEY_OUTPOLYGON,
- 0,
+ "sort",
+ UI_KEY_SORT,
+ "STR[,STR]",
0,
- "Keep the polygon's outside, mask the inside.",
- UI_GROUP_REGION,
- &p->outpolygon,
- GAL_OPTIONS_NO_ARG_TYPE,
- GAL_OPTIONS_RANGE_0_OR_1,
+ "Sort based on values of given columns.",
+ UI_GROUP_GENQUERY,
+ &p->sort,
+ GAL_TYPE_STRLL,
+ GAL_OPTIONS_RANGE_ANY,
GAL_OPTIONS_NOT_MANDATORY,
GAL_OPTIONS_NOT_SET
},
@@ -284,13 +271,6 @@ struct argp_option program_options[] =
-
-
- /* Operating mode */
-
-
-
-
{0}
};
@@ -298,7 +278,10 @@ struct argp_option program_options[] =
-/* Define the child argp structure. */
+/* Define the child argp structure
+ -------------------------------
+
+ NOTE: these parts can be left untouched.*/
struct argp
gal_options_common_child = {gal_commonopts_options,
gal_options_common_argp_parse,
diff --git a/bin/fits/astfits.conf b/bin/query/astquery.conf
similarity index 58%
copy from bin/fits/astfits.conf
copy to bin/query/astquery.conf
index a69b5d9..d020099 100644
--- a/bin/fits/astfits.conf
+++ b/bin/query/astquery.conf
@@ -1,18 +1,18 @@
-# Default parameters (System) for Fits.
-# Fits is part of GNU Astronomy Utitlies.
+# Default parameters (System) for Query.
+# Query is part of GNU Astronomy Utilities.
#
# Use the long option name of each parameter followed by a value. The name
# and value should be separated by atleast one white-space character (for
-# example ` '[space], or tab). Lines starting with `#' are ignored.
+# example ' '[space], or tab). Lines starting with '#' are ignored.
#
# For more information, please run these commands:
#
-# $ astfits --help # Full list of options, short doc.
-# $ astfits -P # Print all options and used values.
-# $ info astfits # All options and input/output.
+# $ astquery --help # Full list of options, short doc.
+# $ astquery -P # Print all options and used values.
+# $ info astquery # All options and input/output.
# $ info gnuastro "Configuration files" # How to use configuration files.
#
-# Copyright (C) 2015-2019 Free Software Foundation, Inc.
+# Copyright (C) 2020-2021 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
diff --git a/bin/query/astron.c b/bin/query/astron.c
new file mode 100644
index 0000000..c3f41ad
--- /dev/null
+++ b/bin/query/astron.c
@@ -0,0 +1,77 @@
+/*********************************************************************
+Settings for Astron.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+
+#include <gnuastro-internal/checkset.h>
+
+#include "main.h"
+
+#include "ui.h"
+#include "tap.h"
+
+
+
+
+
+static void
+astron_sanity_checks(struct queryparams *p)
+{
+ /* Set the summarized names. */
+ if(p->datasetstr)
+ {
+ if( !strcmp(p->datasetstr, "tgssadr") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("tgssadr.main", &p->datasetstr);
+ }
+ }
+}
+
+
+
+
+
+void
+astron_prepare(struct queryparams *p)
+{
+ /* NED-specific. */
+ astron_sanity_checks(p);
+
+ /* Set the URLs, note that this is a simply-linked list, so we need to
+ reverse it in the end (with 'gal_list_str_reverse') to have the same
+ order here. */
+ gal_list_str_add(&p->urls,
+ "https://vo.astron.nl/__system__/tap/run/tap/sync", 0);
+
+ /* Name of default RA Dec columns. */
+ if(p->ra_name==NULL) p->ra_name="ra";
+ if(p->dec_name==NULL) p->dec_name="dec";
+
+ /* Basic sanity checks. */
+ tap_sanity_checks(p);
+}
diff --git a/bin/TEMPLATE/TEMPLATE.h b/bin/query/astron.h
similarity index 76%
copy from bin/TEMPLATE/TEMPLATE.h
copy to bin/query/astron.h
index e75f578..eabcdc6 100644
--- a/bin/TEMPLATE/TEMPLATE.h
+++ b/bin/query/astron.h
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Settings for Astron.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -20,10 +20,12 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#ifndef TEMPLATE_H
-#define TEMPLATE_H
+#ifndef ASTRON_H
+#define ASTRON_H
+
+#include "main.h"
void
-TEMPLATE(struct TEMPLATEparams *p);
+astron_prepare(struct queryparams *p);
#endif
diff --git a/bin/TEMPLATE/authors-cite.h b/bin/query/authors-cite.h
similarity index 75%
copy from bin/TEMPLATE/authors-cite.h
copy to bin/query/authors-cite.h
index 9090793..144e21e 100644
--- a/bin/TEMPLATE/authors-cite.h
+++ b/bin/query/authors-cite.h
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -26,10 +26,10 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
/* When any specific citation is necessary, please add its BibTeX (from ADS
hopefully) to this variable along with a title decribing what this
paper/book does for the progarm in a short line. In the following line
- put a row of `-' with the same length and then put the BibTeX.
+ put a row of '-' with the same length and then put the BibTeX.
- See the `gnuastro_bibtex' variable in `lib/options' (from the top
- Gnuastro source code directory) as an example.*/
+ This macro will be used in 'gal_options_print_citation' function of
+ 'lib/options.c' (from the top Gnuastro source code directory). */
#define PROGRAM_BIBTEX ""
diff --git a/bin/query/gaia.c b/bin/query/gaia.c
new file mode 100644
index 0000000..135e3ca
--- /dev/null
+++ b/bin/query/gaia.c
@@ -0,0 +1,122 @@
+/*********************************************************************
+Settings for ESA's Gaia.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+
+#include <gnuastro-internal/checkset.h>
+
+#include "main.h"
+
+#include "ui.h"
+#include "tap.h"
+
+
+
+
+
+/* Gaia-specific: use simpler names for the commonly used Gaia
+ datasets. This is relevant anytime that '--dataset' has been called. */
+static void
+gaia_sanity_checks(struct queryparams *p)
+{
+ /* FIRST CHECK (BEFORE SETTING DEFAULT DATASET): Gaia datasets are large
+ and it doesn't allow downloading of the full dataset anonymously! You
+ need to contact them for that. So if no constraints are given for the
+ rows, a warning will be printed. */
+ if(p->information==0
+ && p->datasetstr
+ && p->query==NULL
+ && p->center==NULL
+ && p->range==NULL
+ && p->overlapwith==NULL )
+ error(EXIT_FAILURE, 0, "no constraints specified! "
+ "In other words, you are asking for all the rows within this "
+ "dataset! Gaia datasets have billions of rows, therefore it "
+ "has a limit on the number of rows downloaded anonymously. "
+ "For bulk download access, you should contact "
+ "'gaia-helpdesk@cosmos.esa.int'. Alternatively, you can "
+ "constrain your search to a certain spatial region with "
+ "'--center=RA,DEC' (supplemented by '--radius' or '--width' in "
+ "degrees) or use '--overlapwith' to only download rows that "
+ "overlap with the provided image. See the documentation for "
+ "more with this command: 'info astquery' (press 'q' to return "
+ "to the command-line).");
+
+ /* Fix the summarized names. */
+ if(p->datasetstr)
+ {
+ if( !strcmp(p->datasetstr, "edr3") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("gaiaedr3.gaia_source", &p->datasetstr);
+ }
+ else if( !strcmp(p->datasetstr, "dr2") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("gaiadr2.gaia_source", &p->datasetstr);
+ }
+ else if( !strcmp(p->datasetstr, "dr1") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("gaiadr1.gaia_source", &p->datasetstr);
+ }
+ else if( !strcmp(p->datasetstr, "hipparcos") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("public.hipparcos", &p->datasetstr);
+ }
+ else if( !strcmp(p->datasetstr, "tycho2") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("public.tycho2", &p->datasetstr);
+ }
+ }
+}
+
+
+
+
+
+void
+gaia_prepare(struct queryparams *p)
+{
+ /* Gaia-specific settings. */
+ gaia_sanity_checks(p);
+
+ /* Set the URLs, note that this is a simply-linked list, so we need to
+ reverse it in the end (with 'gal_list_str_reverse') to have the same
+ order here. */
+ gal_list_str_add(&p->urls,
+ "https://gea.esac.esa.int/tap-server/tap/sync", 0);
+
+ /* Name of default RA Dec columns. */
+ if(p->ra_name==NULL) p->ra_name="ra";
+ if(p->dec_name==NULL) p->dec_name="dec";
+
+ /* Basic sanity checks. */
+ tap_sanity_checks(p);
+}
diff --git a/bin/TEMPLATE/TEMPLATE.h b/bin/query/gaia.h
similarity index 76%
copy from bin/TEMPLATE/TEMPLATE.h
copy to bin/query/gaia.h
index e75f578..090c465 100644
--- a/bin/TEMPLATE/TEMPLATE.h
+++ b/bin/query/gaia.h
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Settings for ESA's Gaia.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -20,10 +20,12 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#ifndef TEMPLATE_H
-#define TEMPLATE_H
+#ifndef GAIA_H
+#define GAIA_H
+
+#include "main.h"
void
-TEMPLATE(struct TEMPLATEparams *p);
+gaia_prepare(struct queryparams *p);
#endif
diff --git a/bin/TEMPLATE/main.c b/bin/query/main.c
similarity index 82%
copy from bin/TEMPLATE/main.c
copy to bin/query/main.c
index 22757cb..fcc4bc4 100644
--- a/bin/TEMPLATE/main.c
+++ b/bin/query/main.c
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -30,7 +30,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include "main.h"
#include "ui.h"
-#include "TEMPLATE.h"
+#include "query.h"
/* Main function */
@@ -38,7 +38,7 @@ int
main (int argc, char *argv[])
{
struct timeval t1;
- struct TEMPLATEparams p={{{0},0},0};
+ struct queryparams p={{{0},0},0};
/* Set the starting time. */
time(&p.rawtime);
@@ -47,8 +47,8 @@ main (int argc, char *argv[])
/* Read the input parameters. */
ui_read_check_inputs_setup(argc, argv, &p);
- /* Run TEMPLATE */
- TEMPLATE(&p);
+ /* Run Query */
+ query(&p);
/* Free all non-freed allocations. */
ui_free_report(&p, &t1);
diff --git a/bin/query/main.h b/bin/query/main.h
new file mode 100644
index 0000000..377d41c
--- /dev/null
+++ b/bin/query/main.h
@@ -0,0 +1,78 @@
+/*********************************************************************
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef MAIN_H
+#define MAIN_H
+
+/* Include necessary headers */
+#include <gnuastro/data.h>
+
+#include <gnuastro-internal/options.h>
+
+/* Progarm names. */
+#define PROGRAM_NAME "query" /* Program full name. */
+#define PROGRAM_EXEC "astquery" /* Program executable name. */
+#define PROGRAM_STRING PROGRAM_NAME" (" PACKAGE_NAME ") " PACKAGE_VERSION
+
+
+
+
+
+
+
+/* Main program parameters structure */
+struct queryparams
+{
+ /* From command-line */
+ struct gal_options_common_params cp; /* Common parameters. */
+ uint8_t keeprawdownload; /* Keep raw downloaded file. */
+ uint8_t information; /* Print information on database. */
+ uint8_t dryrun; /* Only print command, don't run it. */
+ char *limitinfo; /* Limit retried dataset information. */
+ int database; /* ID of database to use. */
+ char *datasetstr; /* ID of dataset in database to use. */
+ size_t head; /* The number of top rows. */
+ char *overlapwith; /* Image to use instead of center. */
+ gal_list_str_t *ccol; /* Coordinate column names in dataset.*/
+ gal_data_t *center; /* Center position of query. */
+ gal_data_t *radius; /* Radius around center. */
+ gal_data_t *range; /* Range of magnitudes to query. */
+ gal_list_str_t *noblank; /* Return rows that aren't blank. */
+ gal_list_str_t *sort; /* Sort output by given column(s). */
+ gal_data_t *width; /* Width of box around center. */
+ char *query; /* Raw query string. */
+ gal_list_str_t *columns; /* Columns to extract from database. */
+
+ /* Internal variables. */
+ char *databasestr; /* Name of input database. */
+ char *downloadname; /* Temporary output name. */
+ size_t outtableinfo[2]; /* To print in output. */
+ gal_list_str_t *urls; /* List of URLs to use. */
+ char *ra_name; /* Name of RA column. */
+ char *dec_name; /* Name of Dec columns. */
+ char *finalcommand; /* The final command used. */
+
+ /* Output: */
+ time_t rawtime; /* Starting time of the program. */
+};
+
+#endif
diff --git a/bin/query/ned.c b/bin/query/ned.c
new file mode 100644
index 0000000..f2fd24f
--- /dev/null
+++ b/bin/query/ned.c
@@ -0,0 +1,88 @@
+/*********************************************************************
+Settings for NED.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+
+#include <gnuastro-internal/checkset.h>
+
+#include "main.h"
+
+#include "ui.h"
+#include "tap.h"
+
+
+
+
+
+static void
+ned_sanity_checks(struct queryparams *p)
+{
+ /* Set the summarized names. */
+ if(p->datasetstr)
+ {
+ if( !strcmp(p->datasetstr, "objdir") )
+ {
+ free(p->datasetstr);
+ gal_checkset_allocate_copy("NEDTAP.objdir", &p->datasetstr);
+ }
+ }
+
+ /* Currently NED only has a single table for TAP access, so warn the
+ users about this if they ask for any other table. */
+ if( p->datasetstr==NULL || strcmp(p->datasetstr, "NEDTAP.objdir") )
+ error(EXIT_FAILURE, 0, "NED currently only supports a single "
+ "dataset with the TAP protocol called 'NEDTAP.objdir' "
+ "(which you can also call in Query with '--dataset=objdir'). "
+ "TAP access to more datasets/tables will be provided in "
+ "the future. To see all the column information and select "
+ "the columns you want for your work, please run this command:\n\n"
+ " astquery %s --dataset=objdir --info", p->databasestr);
+}
+
+
+
+
+
+void
+ned_prepare(struct queryparams *p)
+{
+ /* NED-specific. */
+ ned_sanity_checks(p);
+
+ /* Set the URLs, note that this is a simply-linked list, so we need to
+ reverse it in the end (with 'gal_list_str_reverse') to have the same
+ order here. */
+ gal_list_str_add(&p->urls,
+ "https://ned.ipac.caltech.edu/tap/sync", 0);
+
+ /* Name of default RA Dec columns. */
+ if(p->ra_name==NULL) p->ra_name="ra";
+ if(p->dec_name==NULL) p->dec_name="dec";
+
+ /* Basic sanity checks. */
+ tap_sanity_checks(p);
+}
diff --git a/bin/TEMPLATE/TEMPLATE.h b/bin/query/ned.h
similarity index 76%
copy from bin/TEMPLATE/TEMPLATE.h
copy to bin/query/ned.h
index e75f578..01effeb 100644
--- a/bin/TEMPLATE/TEMPLATE.h
+++ b/bin/query/ned.h
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Settings for NED.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -20,10 +20,12 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#ifndef TEMPLATE_H
-#define TEMPLATE_H
+#ifndef NED_H
+#define NED_H
+
+#include "main.h"
void
-TEMPLATE(struct TEMPLATEparams *p);
+ned_prepare(struct queryparams *p);
#endif
diff --git a/bin/query/query.c b/bin/query/query.c
new file mode 100644
index 0000000..b8289b5
--- /dev/null
+++ b/bin/query/query.c
@@ -0,0 +1,392 @@
+/*********************************************************************
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gnuastro/wcs.h>
+#include <gnuastro/pointer.h>
+
+#include <gnuastro-internal/checkset.h>
+
+#include "tap.h"
+#include "ned.h"
+#include "gaia.h"
+#include "query.h"
+#include "astron.h"
+#include "vizier.h"
+
+
+
+
+
+/* Go over the columns and see if a given column exists. */
+static int
+query_output_meta_col(gal_list_str_t **cols, gal_data_t *allcols,
+ size_t numcols, char *string)
+{
+ size_t i;
+ for(i=0; i<numcols; ++i)
+ if( !strcmp(allcols[i].name, string) )
+ {
+ gal_list_str_add(cols, string, 0);
+ return 1;
+ }
+ return 0;
+}
+
+
+
+
+
+/* Read the downloaded metadata for all the tables (datasets) within a
+ database and print them in an easy to read format. */
+static void
+query_output_meta_database(struct queryparams *p)
+{
+ int tableformat;
+ size_t i, *size=NULL;
+ size_t numcols, numrows;
+ gal_list_str_t *cols=NULL;
+ char **name, **type, **desc;
+ gal_data_t *table, *allcols, *scol=NULL;
+
+ /* Get the downloaded metadata column information so we can ask for the
+ proper columns. */
+ allcols=gal_table_info(p->downloadname, "1", NULL, &numcols,
+ &numrows, &tableformat);
+
+ /* Parse the column information to set the necessary columns. */
+ if( query_output_meta_col(&cols, allcols, numcols, "table_name") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'table_name' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ if( query_output_meta_col(&cols, allcols, numcols, "description") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'description' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ if( query_output_meta_col(&cols, allcols, numcols, "table_type") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'table_type' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ query_output_meta_col(&cols, allcols, numcols, "size");
+
+ /* Read the necessary columns in the desired order, we just need to
+ reverse the list first since it is last-in-first-out. */
+ gal_list_str_reverse(&cols);
+ table=gal_table_read(p->downloadname, "1", NULL, cols,
+ GAL_TABLE_SEARCH_NAME, 1, p->cp.minmapsize,
+ p->cp.quietmmap, NULL);
+
+ /* Set the basic columns for easy reading. */
+ name=table->array;
+ desc=table->next->array;
+ type=table->next->next->array;
+ if(table->next->next->next)
+ {
+ scol=gal_data_copy_to_new_type_free(table->next->next->next,
+ GAL_TYPE_SIZE_T);
+ table->next->next->next=scol;
+ size=scol->array;
+ }
+
+ /* Print all the information for those tables that have a type of
+ 'table'. If I understood the TAP standard properly, the 'view' ones
+ aren't relevant for non-webpage users. */
+ printf("\nRETRIEVED DATASET INFORMATION\n"
+ "=============================\n");
+ printf("Database: %s (URL: %s)\n", p->databasestr, p->urls->v);
+ if(p->limitinfo)
+ printf("Only datasets containing string below in description "
+ "(case sensitive): '%s'\n", p->limitinfo);
+ if(table->size)
+ {
+ for(i=0;i<table->size;++i)
+ if( !strcmp(type[i],"table") )
+ {
+ printf("\n%zu of %zu\n"
+ "==================\n"
+ "DATASET NAME: %s\n"
+ "------------------\n", i+1, table->size, name[i]);
+ if(size)
+ printf("DATASET SIZE (number of rows): %zu\n"
+ "------------------\n", size[i]);
+ printf("DATASET DESCRIPTION:\n%s\n"
+ "==================\n", desc[i]);
+ }
+ }
+ else printf("\nNO DATASET FOUND!\n");
+
+ /* Clean up and return. */
+ gal_list_data_free(table);
+ gal_data_array_free(allcols, numcols, 0);
+}
+
+
+
+
+
+static uint8_t
+query_type_from_tap(char *typestr)
+{
+ uint8_t type;
+ if( !strcmp(typestr,"BOOLEAN") ) type=GAL_TYPE_UINT8;
+ else if( !strcmp(typestr,"BIGINT") ) type=GAL_TYPE_INT64;
+ else if( !strcmp(typestr,"REAL") ) type=GAL_TYPE_FLOAT32;
+ else if( !strcmp(typestr,"DOUBLE") ) type=GAL_TYPE_FLOAT64;
+ else if( !strcmp(typestr,"SMALLINT")
+ || !strcmp(typestr,"INTEGER") ) type=GAL_TYPE_INT32;
+ else if( !strcmp(typestr,"VARCHAR")
+ || !strcmp(typestr,"STRING")
+ || !strncmp(typestr, "CHAR", 4) ) type=GAL_TYPE_STRING;
+ else type=GAL_TYPE_INVALID;
+ return type;
+}
+
+
+
+
+/* Read the downloaded metadata for all the columns within a table
+ (dataset) and print them in an easy to read format. */
+static void
+query_output_meta_dataset(struct queryparams *p)
+{
+ size_t i;
+ int tableformat;
+ size_t numcols, numrows;
+ gal_list_str_t *cols=NULL;
+ gal_data_t *table, *allcols;
+ char **name, **type, **unit, **desc;
+
+ /* Get the downloaded metadata column information so we can ask for the
+ proper columns. */
+ allcols=gal_table_info(p->downloadname, "1", NULL, &numcols,
+ &numrows, &tableformat);
+
+ /* Parse the column information to set the necessary columns. */
+ if( query_output_meta_col(&cols, allcols, numcols, "column_name") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'column_name' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ if( query_output_meta_col(&cols, allcols, numcols, "datatype") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'datatype' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ if( query_output_meta_col(&cols, allcols, numcols, "description") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'description' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+ if( query_output_meta_col(&cols, allcols, numcols, "unit") == 0 )
+ { error(EXIT_SUCCESS, 0, "no 'unit' found, but this "
+ "is required by the IVOA TAP standard"); return; }
+
+ /* Read the necessary columns in the desired order, we just need to
+ reverse the list first since it is last-in-first-out. */
+ gal_list_str_reverse(&cols);
+ table=gal_table_read(p->downloadname, "1", NULL, cols,
+ GAL_TABLE_SEARCH_NAME, 1, p->cp.minmapsize,
+ p->cp.quietmmap, NULL);
+
+ /* It may happen that the required dataset name isn't recognized by the
+ database. In this case, 'table' will have 0 rows. */
+ if(table->size)
+ {
+ /* Free the initial 'allcols' and set the array pointers. */
+ name=table->array;
+ type=table->next->array;
+ desc=table->next->next->array;
+ unit=table->next->next->next->array;
+ gal_data_array_free(allcols, numcols, 0);
+
+ /* Allocate the new 'allcols' and fill it with the metadata. */
+ numcols=table->size;
+ allcols=gal_data_array_calloc(numcols);
+ for(i=0;i<numcols;++i)
+ {
+ allcols[i].type=query_type_from_tap(type[i]);
+ gal_checkset_allocate_copy(name[i], &allcols[i].name);
+ gal_checkset_allocate_copy(desc[i], &allcols[i].comment);
+ if( !strcmp(unit[i]," ") ) allcols[i].unit=NULL;
+ else gal_checkset_allocate_copy(unit[i], &allcols[i].unit);
+ }
+
+ /* Print the basic information. */
+ printf("\n--------\ndatabase: %s (URL: %s)\ndataset: %s\n",
+ p->databasestr, p->urls->v, p->datasetstr);
+ gal_table_print_info(allcols, numcols, GAL_BLANK_SIZE_T);
+ }
+ else
+ {
+ /* We are using 'error' to have the progam name at the start, and so
+ it goes to 'stderr'. But we aren't exiting with 'EXIT_FAILURE',
+ because Query still has work to do (for example deleting the
+ temporarily downloaded file). */
+ printf("\n");
+ error(EXIT_SUCCESS, 0, "no '%s' dataset found in the '%s' database. "
+ "For the list of datasets within this database, please run the "
+ "command below (put any search word or phrase in 'SEARCH' to "
+ "find your dataset more easily):\n\n"
+ " astquery %s --information --limitinfo=\"SEARCH\"\n\n",
+ p->datasetstr, p->databasestr, p->databasestr);
+ }
+
+ /* Clean up and return. */
+ gal_list_data_free(table);
+ gal_data_array_free(allcols, numcols, 0);
+}
+
+
+
+
+
+/* Read the raw download data, and write them into the output file with
+ Gnuastro's own library. */
+static void
+query_output_data(struct queryparams *p)
+{
+ gal_data_t *table;
+
+ /* Read the table and write it into a clean output (in case the
+ downloaded table is compressed in any special FITS way). */
+ table=gal_table_read(p->downloadname, "1", NULL, NULL,
+ GAL_TABLE_SEARCH_NAME, 1, p->cp.minmapsize,
+ p->cp.quietmmap, NULL);
+ gal_table_write(table, NULL, NULL, p->cp.tableformat,
+ p->cp.output ? p->cp.output : p->cp.output,
+ "QUERY", 0);
+
+ /* Get basic information about the table and free it. */
+ p->outtableinfo[0]=table->size;
+ p->outtableinfo[1]=gal_list_data_number(table);
+ gal_list_data_free(table);
+}
+
+
+
+
+
+void
+query_check_download(struct queryparams *p)
+{
+ size_t len;
+ int status=0;
+ char *logname;
+ fitsfile *fptr;
+
+ /* Open the FITS file and if the status value is still zero, it means
+ everything worked properly. */
+ fits_open_file(&fptr, p->downloadname, READONLY, &status);
+ if(status==0)
+ {
+ /* Close the FITS file pointer. */
+ fits_close_file(fptr, &status);
+
+ /* Prepare the output dataset. */
+ if(p->information)
+ {
+ if(p->datasetstr) query_output_meta_dataset(p);
+ else query_output_meta_database(p);
+ }
+ else query_output_data(p);
+
+ /* Delete the raw downloaded file if necessary. */
+ if(p->keeprawdownload==0) remove(p->downloadname);
+ }
+ else
+ {
+ /* Add a '.log' suffix to the output filename. */
+ len=strlen(p->downloadname);
+ logname=gal_pointer_allocate(GAL_TYPE_STRING, len+10, 1,
+ __func__, "logname");
+ sprintf(logname, "%s.log", p->downloadname);
+
+ /* Rename the output file to the logname file and let the user
+ know. */
+ rename(p->downloadname, logname);
+ if(p->cp.quiet==0) printf("\n");
+ error(EXIT_FAILURE, 0, "the requested dataset could not be "
+ "retrieved! For more, please see '%s'", logname);
+ }
+
+ /* Add the query keywords to the first extension (if the output was a
+ FITS file). */
+ if( p->information==0 && gal_fits_name_is_fits(p->cp.output) )
+ {
+ gal_fits_key_list_title_add_end(&p->cp.okeys,
+ "Constructed query command", 0);
+ gal_fits_key_list_fullcomment_add_end(&p->cp.okeys,
+ p->finalcommand, 1);
+ gal_fits_key_write_config(&p->cp.okeys, "Query settings",
+ "QUERY-CONFIG", p->cp.output, "0");
+ }
+}
+
+
+
+
+
+void
+query(struct queryparams *p)
+{
+ /* Download the dataset. */
+ switch(p->database)
+ {
+ case QUERY_DATABASE_ASTRON: astron_prepare(p); break;
+ case QUERY_DATABASE_GAIA: gaia_prepare(p); break;
+ case QUERY_DATABASE_NED: ned_prepare(p); break;
+ case QUERY_DATABASE_VIZIER: vizier_prepare(p); break;
+ default:
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to "
+ "address the problem. '%d' is not a recognized database "
+ "code", __func__, PACKAGE_BUGREPORT, p->database);
+ }
+
+ /* Download the requested query. */
+ tap_download(p);
+
+ /* Make sure that the result is a readable FITS file, otherwise, abort
+ with an error. */
+ if(p->dryrun==0)
+ query_check_download(p);
+
+ /* Let the user know that things went well. */
+ if(p->dryrun==0 && p->cp.quiet==0)
+ {
+ if(p->information==0)
+ printf("\nQuery resulted in %zu rows and %zu columns.\n",
+ p->outtableinfo[0], p->outtableinfo[1]);
+ if(p->keeprawdownload)
+ {
+ if(p->information) printf("\n");
+ printf("Query's raw downloaded file: %s\n", p->downloadname);
+ }
+ if(p->information==0)
+ {
+ printf("Query's final output: %s\n", p->cp.output);
+ printf("TIP: use the command below for more on the "
+ "downloaded table:\n"
+ " asttable %s --info\n", p->cp.output);
+ }
+ }
+
+ /* Clean up. */
+ gal_list_str_free(p->urls, 0);
+}
diff --git a/bin/TEMPLATE/TEMPLATE.h b/bin/query/query.h
similarity index 68%
copy from bin/TEMPLATE/TEMPLATE.h
copy to bin/query/query.h
index e75f578..81fed39 100644
--- a/bin/TEMPLATE/TEMPLATE.h
+++ b/bin/query/query.h
@@ -1,11 +1,11 @@
/*********************************************************************
-TEMPLATE - A minimal set of files and functions to define a program.
-TEMPLATE is part of GNU Astronomy Utilities (Gnuastro) package.
+Query - Retreive data from a remote data server.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
Original author:
Mohammad akhlaghi <mohammad@akhlaghi.org>
Contributing author(s):
-Copyright (C) 2016-2019, Free Software Foundation, Inc.
+Copyright (C) 2020-2021, Free Software Foundation, Inc.
Gnuastro is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -20,10 +20,22 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#ifndef TEMPLATE_H
-#define TEMPLATE_H
+#ifndef QUERY_H
+#define QUERY_H
+
+#include "main.h"
+
+enum query_databases
+{
+ QUERY_DATABASE_INVALID,
+ QUERY_DATABASE_ASTRON,
+ QUERY_DATABASE_GAIA,
+ QUERY_DATABASE_NED,
+ QUERY_DATABASE_VIZIER,
+};
+
void
-TEMPLATE(struct TEMPLATEparams *p);
+query(struct queryparams *p);
#endif
diff --git a/bin/query/tap.c b/bin/query/tap.c
new file mode 100644
index 0000000..f934644
--- /dev/null
+++ b/bin/query/tap.c
@@ -0,0 +1,440 @@
+/*********************************************************************
+Table Access Protocol (TAP) based download of given query.
+Query is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad akhlaghi <mohammad@akhlaghi.org>
+Contributing author(s):
+Copyright (C) 2021, Free Software Foundation, Inc.
+
+Gnuastro 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, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro 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 Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+
+#include <gnuastro/wcs.h>
+
+#include <gnuastro-internal/checkset.h>
+
+#include "main.h"
+
+#include "ui.h"
+
+
+
+
+
+/* Basic sanity checks necessary in all TAP-based databases. */
+void
+tap_sanity_checks(struct queryparams *p)
+{
+ /* Checks in case a raw query isn't given. */
+ if(p->query==NULL)
+ {
+ /* If '--center' is given, '--radius' is also necessary. */
+ if(p->center || p->overlapwith)
+ {
+ /* Make sure the radius is given, and that it isn't zero. */
+ if(p->center && p->radius==NULL && p->width==NULL)
+ error(EXIT_FAILURE, 0, "the '--radius' ('-r') or "
+ "'--width' ('-w') options are necessary with "
+ "the '--center' ('-C') option");
+ }
+
+ /* If no dataset is explicitly given, let the user know that a
+ catalog reference is necessary. */
+ if( p->information==0 && p->datasetstr==NULL )
+ error(EXIT_FAILURE, 0, "no '--dataset' specified! To get the "
+ "list of available datasets (tables) in this database, "
+ "please run with '--information' (or '-i'). Note that some "
+ "databases (like VizieR) have (tens of) thousands of "
+ "datasets. Hence, for a fast result, its best to limit the "
+ "downloaded and displayed information list by also adding "
+ "--limitinfo=\"SEARCH\" (where 'SEARCH' can be any string "
+ "in the description of the dataset, usually project or "
+ "author names) for example:\n\n"
+ " astquery %s -i --limitinfo=\"SEARCH_STRING\"\n\n"
+ "For more, see the documentation of 'astquery' and the "
+ "\"Available databases\" section of the book for more:\n\n"
+ " info astquery\n"
+ " info gnuastro \"Available databases\"\n",
+ p->databasestr);
+ }
+}
+
+
+
+
+
+/* The database string needs to be quoted if it contains a slash. */
+static char *
+tap_dataset_quote_if_necessary(struct queryparams *p)
+{
+ int quote=0;
+ char *c, *quoted;
+
+ /* Parse the string for bad characters */
+ for(c=p->datasetstr; *c!='\0'; ++c)
+ if(*c=='/') { quote=1; break; }
+
+ /* Add quotes around the database string. */
+ if(quote)
+ {
+ /* Allocate the new string with quotes. */
+ if( asprintf("ed, "\"%s\"", p->datasetstr)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('quoted')",
+ __func__);
+ }
+ else quoted=p->datasetstr;
+
+ /* Return the possibly quoted string. */
+ return quoted;
+}
+
+
+
+
+
+/* Construct the query for metadata download. */
+static char *
+tap_query_construct_meta(struct queryparams *p)
+{
+ char *querystr;
+
+ /* If a dataset is given, build the query to download the metadata of
+ that dataset. Otherwise, get the metadata of the full database. */
+ if(p->datasetstr)
+ {
+ if( asprintf(&querystr, "\"SELECT * FROM TAP_SCHEMA.columns "
+ "WHERE table_name = '%s'\"", p->datasetstr)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('querystr')",
+ __func__);
+ }
+ else
+ {
+ if(p->limitinfo)
+ {
+ if( asprintf(&querystr, "\"SELECT * FROM TAP_SCHEMA.tables "
+ "WHERE description LIKE '%%%s%%'\"", p->limitinfo)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('querystr')",
+ __func__);
+ }
+ else
+ gal_checkset_allocate_copy("\"SELECT * FROM TAP_SCHEMA.tables\"",
+ &querystr);
+ }
+
+ /* Clean up and return. */
+ return querystr;
+}
+
+
+
+
+
+/* Construct the spatial-constraints criteria if necessary. */
+static char *
+tap_query_construct_spatial(struct queryparams *p)
+{
+ size_t ndim;
+ double width2, *center, *darray;
+ char *regionstr, *spatialstr=NULL;
+ double *ocenter=NULL, *owidth=NULL, *omin=NULL, *omax=NULL;
+
+ /* If the user wanted an overlap with an image, then calculate it. */
+ if(p->overlapwith)
+ {
+ /* Calculate the Sky coverage of the overlap dataset. */
+ gal_wcs_coverage(p->overlapwith, p->cp.hdu, &ndim, &ocenter,
+ &owidth, &omin, &omax);
+
+ /* Make sure a WCS existed in the file. */
+ if(owidth==NULL)
+ error(EXIT_FAILURE, 0, "%s (hdu %s): contains no WCS to "
+ "derive the sky coverage", p->overlapwith, p->cp.hdu);
+ }
+
+ /* For easy reading. */
+ center = p->overlapwith ? ocenter : p->center->array;
+
+ /* Write the region. */
+ if(p->radius)
+ {
+ darray=p->radius->array;
+ if( asprintf(®ionstr, "CIRCLE('ICRS', %.8f, %.8f, %g)",
+ center[0], center[1], darray[0])<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('regionstr')",
+ __func__);
+ }
+ else if(p->width || p->overlapwith)
+ {
+ darray = p->overlapwith ? owidth : p->width->array;
+ width2 = ( (p->overlapwith || p->width->size==2)
+ ? darray[1] : darray[0] );
+ if( asprintf( ®ionstr, "BOX('ICRS', %.8f, %.8f, %.8f, %.8f)",
+ center[0], center[1], darray[0], width2 )<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('regionstr')",
+ __func__);
+ }
+
+ /* Build the final spatial constraint query string. Note on the
+ quotations: the final query is surrounded by single-quotes
+ ('). However, we need the single quotes around 'ICRS' in this command
+ (both in the final string below and the ones above). So just before
+ the first 'ICRS', we end the single-quote and start a double quote and
+ keep it until the end. Finally, we add a single quote again so all
+ other components of the query can assume that the single-quote
+ environment is active.*/
+ if( asprintf(&spatialstr,
+ "1=CONTAINS( POINT('\"'ICRS', %s, %s), %s )\"'",
+ p->ra_name, p->dec_name, regionstr)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation ('querystr')",
+ __func__);
+
+
+ /* Clean up and return. */
+ free(regionstr);
+ if(p->overlapwith)
+ { free(ocenter); free(owidth); free(omin); free(omax); }
+ return spatialstr;
+}
+
+
+
+
+
+static void
+tap_query_construct_noblank(struct queryparams *p, char **outstr)
+{
+ gal_list_str_t *tmp;
+ char *noblankstr=NULL, *prevstr=*outstr;
+
+ for(tmp=p->noblank; tmp!=NULL; tmp=tmp->next)
+ {
+ /* Write 'rangestr'. */
+ if(prevstr)
+ {
+ if( asprintf(&noblankstr, "%s AND %s IS NOT NULL",
+ prevstr, tmp->v) < 0 )
+ error(EXIT_FAILURE, 0,
+ "%s: asprintf allocation ('noblankstr', 1)", __func__);
+ free(prevstr);
+ }
+ else
+ if( asprintf(&noblankstr, "%s IS NOT NULL", tmp->v) < 0 )
+ error(EXIT_FAILURE, 0,
+ "%s: asprintf allocation ('noblankstr', 2)", __func__);
+
+ /* Put the 'rangestr' in previous-range string for the next
+ round.*/
+ prevstr=noblankstr;
+ }
+
+ /* Set the final output pointer. */
+ *outstr=noblankstr;
+}
+
+
+
+
+
+static void
+tap_query_construct_range(struct queryparams *p, char **outstr)
+{
+ double *darray;
+ gal_data_t *tmp;
+ char *rangestr=NULL, *prevstr=*outstr;
+
+ for(tmp=p->range; tmp!=NULL; tmp=tmp->next)
+ {
+ /* Write 'rangestr'. */
+ darray=tmp->array;
+ if(prevstr)
+ {
+ if( asprintf(&rangestr, "%s AND %s>=%g AND %s<=%g", prevstr,
+ tmp->name, darray[0], tmp->name, darray[1]) < 0 )
+ error(EXIT_FAILURE, 0,
+ "%s: asprintf allocation ('rangestr', 1)", __func__);
+ free(prevstr);
+ }
+ else
+ if( asprintf(&rangestr, "%s>=%g AND %s<=%g",
+