allow several folders for inflating ledgers #408
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR prepares for the soon-to-come addition of extra secondary targets files, as:
$DESI_TARGET/catalogs/{dr}/{dtver}/targets/{extradir}/secondary/{program}/{extradir}targets-{program}-secondary.fits
(with extradir!={survey})See related PR desihub/desitarget#764.
Catalogs with extradir=main2 are expected to be created soon, but this PR should handle any other name starting with main (e.g. main3).
In fba_launch_io.py, those files are only used to add flux columns to the secondary catalogs read from the ledgers (which will contain all secondary targets, from main/, main2/, etc).
New steps:
The fba_launch_io.get_desitarget_paths() function records the extra existing secondary catalogs, proceeding as follow:
$DESI_TARGET/catalogs/{dr}/{dtver}/targets/{survey}*
, other than$DESI_TARGET/catalogs/{dr}/{dtver}/targets/{survey}
;$DESI_TARGET/catalogs/{dr}/{dtver}/targets/{extradir}/secondary/{program}/{extradir}targets-{program}-secondary.fits
;Then in fba_launch_io.create_mtl() for the secondary targets case, the "regular" secondary catalog, along with any recorded extra catalog, will be used to get the flux column information missing from the ledgers.
Lastly, fba_launch_io.update_fiberassign_header() records in the header any found SCND2, SCND3, ... extra catalog.
Example of use:
With test catalogs with main/ and main2/ secondary catalogs:
This change is backward-compatible, for instance (currently there only is a main/ secondary catalog):
Technical python remark:
I came up with:
targ = Table(fitsio.read(targdir, columns = columns + ["TARGETID"], rows=rows))
, because:I m happy to implement any more elegant suggestion.