Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add URAT catalog information #526

Merged
merged 31 commits into from Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
36708be
add a new module for manupulating URAT files to the API
geordie666 Jul 25, 2019
c9cb590
modify the URAT-provided FORTRAN code for parsing files to work at NERSC
geordie666 Jul 25, 2019
f037583
mild update to fortran binaries
geordie666 Jul 25, 2019
eeb1652
more minor updates to fortran
geordie666 Jul 25, 2019
4adacc9
switch to reading healpix files when calculating pixweight stellar de…
geordie666 Jul 30, 2019
e551271
default to creating an 'all-sky' GFAs file
geordie666 Jul 30, 2019
ff24582
Add a README file explaining the fortran directory
geordie666 Jul 31, 2019
8e21158
a little more logging when generating pixweight files
geordie666 Jul 31, 2019
bf233c5
update RA/Dec matcher to return the match separation, if requested
geordie666 Jul 31, 2019
7bc8dd6
new module to download and format URAT files, and match to URAT locat…
geordie666 Jul 31, 2019
78517bc
update magnitude limit for GFAs to 21
geordie666 Jul 31, 2019
eb8ebc5
add extra keywords to the header of the GFAs file
geordie666 Jul 31, 2019
d87c521
enforce Dec range in hp_in_box, even when returning the full RA range
geordie666 Aug 1, 2019
80c46f9
better limit the Gaia files being considered when making GFAs
geordie666 Aug 1, 2019
97252a4
parallelized function to match URAT to zero-PM GFAs; limit to numproc…
geordie666 Aug 2, 2019
d9aeb79
code style and extra imports
geordie666 Aug 2, 2019
9373011
optimize parallelization of matching; add URAT matching distance to o…
geordie666 Aug 2, 2019
0567210
debugging
geordie666 Aug 2, 2019
c8f17c2
update changes docs
geordie666 Aug 2, 2019
8fe8461
clean up one logging message
geordie666 Aug 2, 2019
345f946
Merge branch 'master' into ADM-URAT-GFAs
geordie666 Aug 2, 2019
03b5592
fix sphinx errors
geordie666 Aug 2, 2019
c10122d
more details about accessing the URAT data in the FORTRAN README file
geordie666 Aug 3, 2019
40894ed
remove fortran binary
geordie666 Aug 3, 2019
7b0b733
mv fortran code to /etc/fortran; slightly weird for a resource_filena…
geordie666 Aug 3, 2019
c061c27
option to not add URAT if you want to circumvent it for some reason
geordie666 Aug 3, 2019
542797a
add the URAT_DIR environment variable to desitarget.module
geordie666 Aug 3, 2019
f0c24f0
add new line at the end of desitarget.module
geordie666 Aug 3, 2019
4203092
slight change to docstring regarding location of v1dump
geordie666 Aug 3, 2019
42d74f9
urat_binary_to_csv() doesn't take numproc as an input; check director…
geordie666 Aug 3, 2019
eaf00cd
place URAT Fortran code in a more sensible place; better error logging
geordie666 Aug 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 24 additions & 11 deletions bin/select_gfas
Expand Up @@ -23,32 +23,40 @@ ap.add_argument("surveydir",
ap.add_argument("dest",
help="Output GFA targets file (e.g. '/project/projectdirs/desi/target/catalogs/gfas-dr6-0.20.0.fits' at NERSC)")
ap.add_argument('-m', '--maglim', type=float,
help="Magnitude limit on GFA targets in Gaia G-band (defaults to [18])",
default=18)
help="Magnitude limit on GFA targets in Gaia G-band (defaults to [21])",
default=21)
ap.add_argument('-n', "--numproc", type=int,
help="number of concurrent processes to use (defaults to [{}])".format(nproc),
help="number of concurrent processes to use (defaults to [{}]). Note that if numproc > 4, I/O limited parts of the code revert to numproc=4".format(nproc),
default=nproc)
ap.add_argument('-s2', "--surveydir2",
help='Additional Legacy Surveys Data Release directory (useful for combining, e.g., DR8 into one file of GFAs)',
default=None)
ap.add_argument('-t', "--tiles",
help="File specifying the tiles to which to restrict the GFAs (defaults to all tiles in the DESI footprint)",
help="File specifying the tiles to which to restrict the GFAs",
default=None)
ap.add_argument('-dec', "--mindec", type=float,
help="Minimum declination to include in output file for NON-LEGACY-SURVEYS sources (degrees; defaults to [-30])",
default=-30)
ap.add_argument('-b', "--mingalb", type=float,
help="Closest latitude to Galactic plane to output for NON-LEGACY-SURVEYS sources (e.g. send the default [10] to limit to areas beyond -10o <= b < 10o)",
default=10)
ap.add_argument("--cmx", action='store_true',
help="If sent, then create a commissioning file. Commissioning files are not restricted by any tiling pattern, even if --tiles is sent")
ap.add_argument("--desifootprint", action='store_true',
help="If sent, then limit to the current DESIMODEL Main Survey footprint (the default is to produce an 'all-sky' file)")

ns = ap.parse_args()

survey = 'main'
if ns.cmx:
log.info('Making a cmx-style file. No restrictions on tiling')
if ns.tiles is not None:
log.info('Restricting to passed tiles')
survey = 'tiles'
cmx = False
elif ns.desifootprint:
log.info('Restricting to the DESI Main Survey footprint')
survey = 'main'
cmx = False
else:
log.info('Producing GFAs across the entire sky (with specified limits)')
survey = 'cmx'
cmx = True

infiles = io.list_sweepfiles(ns.surveydir)
if ns.surveydir2 is not None:
Expand All @@ -66,8 +74,13 @@ if len(infiles) == 0:
log.info('running on {} processors...t = {:.1f} mins'.format(ns.numproc, (time()-t0)/60.))

gfas = select_gfas(infiles, maglim=ns.maglim, numproc=ns.numproc, tilesfile=ns.tiles,
cmx=ns.cmx, mindec=ns.mindec, mingalb=ns.mingalb)
cmx=cmx, mindec=ns.mindec, mingalb=ns.mingalb)

io.write_gfas(ns.dest, gfas, indir=ns.surveydir, indir2=ns.surveydir2, nside=nside, survey=survey)
# ADM extra header keywords for the output fits file.
extra = {k: v for k, v in zip(["maglim", "mindec", "mingalb"],
[ns.maglim, ns.mindec, ns.mingalb])}

log.info('Writing GFAs to file...t = {:.1f} mins'.format((time()-t0)/60.))
io.write_gfas(ns.dest, gfas, indir=ns.surveydir, indir2=ns.surveydir2,
nside=nside, survey=survey, extra=extra)
log.info('{} GFAs written to {}...t = {:.1f} mins'.format(len(gfas), ns.dest, (time()-t0)/60.))
3 changes: 3 additions & 0 deletions doc/api.rst
Expand Up @@ -88,3 +88,6 @@ desitarget API

.. automodule:: desitarget.train.train_mva_decals
:members:

.. automodule:: desitarget.uratmatch
:members:
7 changes: 6 additions & 1 deletion doc/changes.rst
Expand Up @@ -5,6 +5,10 @@ desitarget Change Log
0.31.2 (unreleased)
-------------------

* Add URAT catalog information [`PR #526`_]. Includes:
* New module to retrieve URAT data from Vizier and reformat it.
* Code to match RAs/Decs to URAT, as part of that new URAT module.
* Substitute URAT PMs for GFAs where Gaia has not yet measured PMs.
* Update CMX and Main Survey target classes [`PR #525`_]. Includes:
* New `SV0_WD`, `SV0_STD_FAINT` target classes for commissioning.
* Mild updates to `SV0_BGS` and `SV0_MWS` for commissioning.
Expand All @@ -25,8 +29,9 @@ desitarget Change Log
.. _`PR #518`: https://github.com/desihub/desitarget/pull/518
.. _`PR #519`: https://github.com/desihub/desitarget/pull/519
.. _`PR #521`: https://github.com/desihub/desitarget/pull/521
.. _`PR #525`: https://github.com/desihub/desitarget/pull/525
.. _`PR #523`: https://github.com/desihub/desitarget/pull/523
.. _`PR #525`: https://github.com/desihub/desitarget/pull/525
.. _`PR #526`: https://github.com/desihub/desitarget/pull/526

0.31.1 (2019-07-05)
-------------------
Expand Down
96 changes: 96 additions & 0 deletions py/desitarget/fortran/ADM-v1dump.f
@@ -0,0 +1,96 @@
PROGRAM v1dump
C
C gfortran -o v1dump ADM-v1dump.f v1sub.f
C
C - loop over range of zones
C - read individual URAT zone file (binary data)
C - output all data to ASCII file, no header lines
C - user select column separator character, no empty columns
C - for explanations of the 45 columns see "readme" file
C
C 141120 NZ adopted from UCAC4 code
C 150119 NZ change to "v", bug fix "238"
C 150126 NZ add URAT star ID zzznnnnnn to output
C 150129 NZ change format item #6 I*3 -> I*4 due to neg.flag (no GSC match)
C 100725 ADM Adapted for NERSC and hardcoded to skip interactive steps
IMPLICIT NONE
INTEGER dimc, dims
PARAMETER (dimc = 45 ! number of URAT data columns
. ,dims = 45) ! number of separators

INTEGER dv(dimc), mi(dimc), ma(dimc), is(dims)
CHARACTER*1 csc

INTEGER i,j,k, jo, uni,uno,zn1,zn2,zn, nst,nsz, idn
CHARACTER*45 line*223, a1*1, bfc*1
CHARACTER*100 uratdir, pathi, patho, fnin, fnout
LOGICAL eozf, bf

DATA is /11, 21, 25, 29, 32, 36, 42, 48, 52, 55, 57, 61, 65, 69
. , 73, 79, 85, 89, 92, 95,106,112,118,124,129,134,139,141
. ,143,145,147,149,151,157,163,169,175,181,186,191,196,201
. ,206,210,214/

* defaults
C ADM the input/output directories.
CALL get_environment_variable("URAT_DIR", uratdir)
pathi = TRIM(TRIM(uratdir) // "/binary/")
patho = TRIM(TRIM(uratdir) // "/csv/")
C ADM the file RANGE to convert.
zn1 = 326
zn2 = 900
C ADM byte-flip or not (big or little endian).
bfc = 'N'
C ADM the delimiter for the output files.
csc = ','

IF (bfc.EQ.'Y'.OR.bfc.EQ.'y') THEN
bf = .TRUE.
ELSE
bf = .FALSE.
ENDIF

* prepare
jo = INDEX (patho,' ') - 2
uni= 11
uno= 20
nst= 0

* loop zone files
DO zn = zn1,zn2
WRITE (fnout,'(a,a,i3.3,a)') patho(1:jo),'/z',zn,'.csv'
CALL open_zfile (pathi,uni,zn,fnin)
OPEN (uno,FILE=fnout)
eozf = .FALSE.

WRITE (*,'(/a,a)') 'begin read file = ',fnin
WRITE (*,'( a,a)') '... output to = ',fnout

DO nsz = 1,999000
CALL getistar (uni,nsz,bf,eozf,dv,dimc)
IF (eozf) GOTO 91

idn = zn * 1000000 + nsz ! official star ID number

WRITE (line,'(2i10,2i4,i3,i4,i6,i6,i4,i3,i2,4i4,2i6,i4
. ,2i3,i11,3i6,3i5,6i2,5i6,5i5,2i4,i10.9)')
. (dv(j),j=1,dimc), idn

IF (csc.NE.' ') THEN
DO j=1,dims
k = is(j)
line(k:k) = csc
ENDDO
ENDIF

WRITE (uno,'(a)') line
ENDDO ! loop stars on individ. zone files

91 CLOSE (uni)
CLOSE (uno)
nsz = nsz - 1
nst = nst + nsz
WRITE (*,'(a,i7,i10)') 'numb.stars/zone, total = ',nsz,nst
ENDDO ! loop all zones

END ! main <v1dump>
26 changes: 26 additions & 0 deletions py/desitarget/fortran/README
@@ -0,0 +1,26 @@
The files in this directory are:

ADM-v1dump.f: FORTRAN code to parse UCAC/URAT files, adapted from
http://cdsarc.u-strasbg.fr/ftp/I/329/URAT1/access/v1dump.f
by Adam D. Myers (University of Wyoming).

v1sub.f: Routines to help parse UCAC/URAT files, taken directly from
http://cdsarc.u-strasbg.fr/ftp/I/329/URAT1/access/v1sub.f

v1dump: An executable compiled at NERSC via:
geordie666 marked this conversation as resolved.
Show resolved Hide resolved

gfortran -o v1dump ADM-v1dump.f v1sub.f
geordie666 marked this conversation as resolved.
Show resolved Hide resolved


More about the URAT survey is available at:

http://cdsarc.u-strasbg.fr/viz-bin/Cat?I/329


This code is used as part of desitarget.uratmatch.make_urat_files(),
specifically, desitarget.uratmatch.urat_binary_to_csv() to download
and format URAT data from http://cdsarc.u-strasbg.fr/ftp/I/329/


At NERSC, desitarget.uratmatch.make_urat_files() has already been run
and the output is in /project/projectdirs/desi/target/urat_dr1
Binary file added py/desitarget/fortran/v1dump
Binary file not shown.