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

First run of SV secondaries with real target files. #669

Merged
merged 31 commits into from Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
422448f
match to sweeps files to populate correct TARGETIDs even when a secon…
geordie666 Dec 30, 2020
3952558
smarter handling of whether a secondary target genuinely matched a pr…
geordie666 Dec 30, 2020
447fcf7
update output files to better reflect the data model
geordie666 Dec 30, 2020
09e0ab3
add full bitmask for SV1 secondary targets
geordie666 Jan 1, 2021
0ca8bd5
clean up syntax errors in yaml file
geordie666 Jan 1, 2021
90cf10d
clean up the data model, although secondary files to be .csv as well …
geordie666 Jan 2, 2021
10d0744
general clean up of output/input data model and logging
geordie666 Jan 2, 2021
f5ce532
allow the secondary directory to be passed to the slurm/bundling script
geordie666 Jan 2, 2021
d0a0b7f
make sure the files of matches to primary sources are all written to …
geordie666 Jan 2, 2021
a65a2a5
debug case where there are no in-pixel sweeps sources
geordie666 Jan 3, 2021
e8f960a
quicker reading across the pixelized files of primary information
geordie666 Jan 4, 2021
57829bf
debug resolving various matching cases: A primary can match multiple …
geordie666 Jan 5, 2021
34a3a10
minor code style
geordie666 Jan 5, 2021
125ac82
update the changes file
geordie666 Jan 5, 2021
4227fb7
Merge branch 'master' into ADM-secondary-onsky
geordie666 Jan 5, 2021
8ea3774
commenting out the PV targeting bits, for now, as there may be a bug …
geordie666 Jan 5, 2021
0aceb2a
restore PV targeting bits, bug is fixed; split HPM class into BRIGHT …
geordie666 Jan 6, 2021
ff06f6a
add columns needed by fiberassign
geordie666 Jan 7, 2021
8b925b8
allow secondary targets to be read by the desitarget.io.read_target* …
geordie666 Jan 7, 2021
d170cd2
add a check that the input secondary data have reasonable coordinates
geordie666 Jan 8, 2021
d3dbe9c
add Gaia-only standard star bits to the MWS_MASK
geordie666 Jan 8, 2021
f7a5b0e
add function to create new Gaia-only standards. Also modify preparati…
geordie666 Jan 8, 2021
ad0f228
set the bits for the Gaia-only standards in the MWS target column
geordie666 Jan 9, 2021
3bf60c6
didn't actually need to modify the preparation of data to work with G…
geordie666 Jan 9, 2021
8234125
begin debugging: Need to return the full suite of Gaia parameters
geordie666 Jan 9, 2021
0fbaae2
minor textual changes to check against master
geordie666 Jan 9, 2021
e0643d8
continue debugging; there are now standards in the MWS mask that have…
geordie666 Jan 9, 2021
911a7b3
continue debugging; correct parameter names, import more needed modules
geordie666 Jan 9, 2021
4244302
Duplicate Gaia standard stars code for the Main Survey; update change…
geordie666 Jan 9, 2021
b109cdb
update unit tests and fix sphinx warnings
geordie666 Jan 9, 2021
fae721c
update the Main Survey unit tests for the new GAIA_STD classes, too
geordie666 Jan 9, 2021
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
2 changes: 1 addition & 1 deletion bin/select_secondary
Expand Up @@ -43,7 +43,7 @@ hdr = fitsio.read_header(fns[0], 'SCND_TARG')
surv = hdr["SURVEY"].rstrip()

# ADM find the SCND_DIR environment variable, if it wasn't passed.
scxdir = _get_scxdir(ns.scnddir)
scxdir = _get_scxdir(ns.scnddir, survey=surv)
# ADM and augment the scxdir if this is an SV set of primary files.
if surv != 'main':
scxdir = os.path.join(scxdir, surv)
Expand Down
41 changes: 23 additions & 18 deletions bin/select_sv_targets
Expand Up @@ -67,7 +67,7 @@ ap.add_argument("--nomaskbits", action='store_true',
ap.add_argument("--writeall", action='store_true',
help="Default behavior is to split targets by bright/dark-time surveys. Send this to ALSO write a file of ALL targets")
ap.add_argument("-nos", "--nosecondary", action='store_true',
help="Do NOT create TARGETID look-up files for secondary targets in $SCNDIR/outdata/priminfo-drversion-desitargetversion/$dest.fits (where $dest is the basename of dest)")
help="Do NOT create TARGETID look-up files for secondary targets in $SCNDIR/outdata/desitargetversion/priminfo-drversion-desitargetversion/$dest.fits (where $dest is the basename of dest)")
ap.add_argument("--scnddir",
help="Base directory of secondary target files (e.g. '/project/projectdirs/desi/target/secondary' at NERSC). "+
"Defaults to SCND_DIR environment variable. Not needed if --nosecondary is sent.")
Expand All @@ -80,13 +80,14 @@ ns = ap.parse_args()
# ADM build the list of command line arguments as
# ADM bundlefiles potentially needs to know about them.
extra = " --numproc {}".format(ns.numproc)
if ns.tcnames is not None:
extra += " --tcnames {}".format(ns.tcnames)
nsdict = vars(ns)
for nskey in ["noresolve", "nomaskbits", "writeall",
"nosecondary", "nobackup", "nochecksum"]:
if nsdict[nskey]:
extra += " --{}".format(nskey)
for nskey in ["tcnames", "noresolve", "nomaskbits", "writeall",
"nosecondary", "nobackup", "nochecksum", "scnddir"]:
if isinstance(nsdict[nskey], bool):
if nsdict[nskey]:
extra += " --{}".format(nskey)
elif nsdict[nskey] is not None:
extra += " --{} {}".format(nskey, nsdict[nskey])

infiles = io.list_sweepfiles(ns.sweepdir)
if ns.sweepdir2 is not None:
Expand Down Expand Up @@ -148,25 +149,29 @@ targets, infn = select_targets(
tcnames=tcnames, survey=survey, backup=not(ns.nobackup),
resolvetargs=not(ns.noresolve), mask=not(ns.nomaskbits), return_infiles=True
)
# ADM Set the list of infiles actually processed by select_targets() to
# ADM None if we DON'T want to write their checksums to the output file.
if ns.nochecksum:
shatab = None
else:
shatab = get_checksums(infn, verbose=True)

if ns.bundlefiles is None:
# ADM Set the list of infiles actually processed by select_targets() to
# ADM None if we DON'T want to write their checksums to the output file.
if ns.nochecksum:
shatab = None
else:
shatab = get_checksums(infn, verbose=True)

# ADM only run secondary functions if --nosecondary was not passed.
scndout = None
if not ns.nosecondary and len(targets) > 0:
from desitarget.secondary import _get_scxdir, match_secondary
# ADM read secondary target directory.
scxdir = _get_scxdir(ns.scnddir)
scxdir = _get_scxdir(ns.scnddir, survey=survey)
# ADM construct a label for the secondary file for TARGETID look-ups.
# ADM use RELEASE to determine the release string for the targets.
drint = np.max(targets['RELEASE']//1000)
try:
drint = int(ns.sweepdir.split("dr")[1][0])
except (ValueError, IndexError, AttributeError):
drint = "X"
scndoutdn = "priminfo-dr{}-{}".format(drint, desitarget_version)
scndoutdn = os.path.join(scxdir, survey, "outdata", scndoutdn)
scndoutdn = os.path.join(scxdir, survey,
"outdata", desitarget_version, scndoutdn)
if not os.path.exists(scndoutdn):
log.info("making directory...{}".format(scndoutdn))
os.makedirs(scndoutdn)
Expand All @@ -181,7 +186,7 @@ if ns.bundlefiles is None:
scndout = os.path.join(scndoutdn, scndoutfn)
log.info("writing files of primary matches to...{}".format(scndout))
targets = match_secondary(targets, scxdir, scndout, sep=1.,
pix=pixlist, nside=ns.nside)
pix=pixlist, nside=ns.nside, swfiles=infn)

if ns.mask:
targets = mask_targets(targets, inmaskfile=ns.mask, nside=nside)
Expand Down
39 changes: 22 additions & 17 deletions bin/select_targets
Expand Up @@ -69,7 +69,7 @@ ap.add_argument("--nomaskbits", action='store_true',
ap.add_argument("--writeall", action='store_true',
help="Default behavior is to split targets by bright/dark-time surveys. Send this to ALSO write a file of ALL targets")
ap.add_argument("-nos", "--nosecondary", action='store_true',
help="Do NOT create TARGETID look-up files for secondary targets in $SCNDIR/outdata/priminfo-drversion-desitargetversion/$dest.fits (where $dest is the basename of dest)")
help="Do NOT create TARGETID look-up files for secondary targets in $SCNDIR/outdata/desitargetversion/priminfo-drversion-desitargetversion/$dest.fits (where $dest is the basename of dest)")
ap.add_argument("--scnddir",
help="Base directory of secondary target files (e.g. '/project/projectdirs/desi/target/secondary' at NERSC). "+
"Defaults to SCND_DIR environment variable. Not needed if --nosecondary is sent.")
Expand All @@ -82,13 +82,14 @@ ns = ap.parse_args()
# ADM build the list of command line arguments as
# ADM bundlefiles potentially needs to know about them.
extra = " --numproc {}".format(ns.numproc)
if ns.tcnames is not None:
extra += " --tcnames {}".format(ns.tcnames)
nsdict = vars(ns)
for nskey in ["noresolve", "nomaskbits", "writeall",
"nosecondary", "nobackup", "nochecksum"]:
if nsdict[nskey]:
extra += " --{}".format(nskey)
for nskey in ["tcnames", "noresolve", "nomaskbits", "writeall",
"nosecondary", "nobackup", "nochecksum", "scnddir"]:
if isinstance(nsdict[nskey], bool):
if nsdict[nskey]:
extra += " --{}".format(nskey)
elif nsdict[nskey] is not None:
extra += " --{} {}".format(nskey, nsdict[nskey])

infiles = io.list_sweepfiles(ns.sweepdir)
if ns.sweepdir2 is not None:
Expand Down Expand Up @@ -149,25 +150,29 @@ targets, infn = select_targets(
tcnames=tcnames, survey='main', backup=not(ns.nobackup),
resolvetargs=not(ns.noresolve), mask=not(ns.nomaskbits), return_infiles=True
)
# ADM Set the list of infiles actually processed by select_targets() to
# ADM None if we DON'T want to write their checksums to the output file.
if ns.nochecksum:
shatab = None
else:
shatab = get_checksums(infn, verbose=True)

if ns.bundlefiles is None:
# ADM Set the list of infiles actually processed by select_targets() to
# ADM None if we DON'T want to write their checksums to the output file.
if ns.nochecksum:
shatab = None
else:
shatab = get_checksums(infn, verbose=True)

# ADM only run secondary functions if --nosecondary was not passed.
scndout = None
if not ns.nosecondary and len(targets) > 0:
from desitarget.secondary import _get_scxdir, match_secondary
# ADM read secondary target directory.
scxdir = _get_scxdir(ns.scnddir)
# ADM construct a label for the secondary file for TARGETID look-ups.
# ADM use RELEASE to determine the release string for the targets.
drint = np.max(targets['RELEASE']//1000)
try:
drint = int(ns.sweepdir.split("dr")[1][0])
except (ValueError, IndexError, AttributeError):
drint = "X"
scndoutdn = "priminfo-dr{}-{}".format(drint, desitarget_version)
scndoutdn = os.path.join(scxdir, "outdata", scndoutdn)
scndoutdn = os.path.join(scxdir,
"outdata", desitarget_version, scndoutdn)
if not os.path.exists(scndoutdn):
log.info("making directory...{}".format(scndoutdn))
os.makedirs(scndoutdn)
Expand All @@ -182,7 +187,7 @@ if ns.bundlefiles is None:
scndout = os.path.join(scndoutdn, scndoutfn)
log.info("writing files of primary matches to...{}".format(scndout))
targets = match_secondary(targets, scxdir, scndout, sep=1.,
pix=pixlist, nside=ns.nside)
pix=pixlist, nside=ns.nside, swfiles=infn)

if ns.mask:
targets = mask_targets(targets, inmaskfile=ns.mask, nside=nside)
Expand Down
10 changes: 9 additions & 1 deletion doc/changes.rst
Expand Up @@ -5,6 +5,14 @@ desitarget Change Log
0.47.1 (unreleased)
-------------------

* First run of secondaries with real target files [`PR #669`_]. Includes:
* Add Gaia-only standard stars to the MWS masks for SV, Main Survey:
* `GAIA_STD_FAINT`, `GAIA_STD_BRIGHT`, `GAIA_STD_WD`.
* General optimization, updating and debugging of the secondary code.
* Get `TARGETIDs` from the input sweeps, not just the actual targets.
* Add the first full bitmask for the SV1 secondary target files.
* Updates to the data model to better reflect the primary targets.
* Clean-up minor style and doc issues from `PR #636`_ [`PR #668`_].
* Updates and bug fixes for DR9 now SV is on-sky [`PR #665`_]. Includes:
* Pass `MASKBITS` column forward for GFAs.
* Bug fixes necessitated by target files having a second extension.
Expand All @@ -15,12 +23,12 @@ desitarget Change Log
* Simplify stellar SV bits [`PR #636`_]:
* Secondary bit requirement for main stellar SV program to 4 bits.
* Primary bright science WDs use the old algorithmic selection.
* Clean-up minor style and doc issues from `PR #636`_ [`PR #668`_].

.. _`PR #636`: https://github.com/desihub/desitarget/pull/636
.. _`PR #664`: https://github.com/desihub/desitarget/pull/664
.. _`PR #665`: https://github.com/desihub/desitarget/pull/665
.. _`PR #668`: https://github.com/desihub/desitarget/pull/668
.. _`PR #669`: https://github.com/desihub/desitarget/pull/669

0.47.0 (2020-12-10)
-------------------
Expand Down