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

allow several folders for inflating ledgers #408

Merged
merged 2 commits into from Sep 20, 2021
Merged

Conversation

araichoor
Copy link
Contributor

@araichoor araichoor commented Sep 18, 2021

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:

  • first look for folders named $DESI_TARGET/catalogs/{dr}/{dtver}/targets/{survey}*, other than $DESI_TARGET/catalogs/{dr}/{dtver}/targets/{survey};
  • then, for each found extra folder {extradir} look for an extra catalog $DESI_TARGET/catalogs/{dr}/{dtver}/targets/{extradir}/secondary/{program}/{extradir}targets-{program}-secondary.fits;
  • store each of those extra catalogs in a "scnd2", "scnd3", ... key (sorted by extradir names)

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:

export DESI_TARGET=/global/cscratch1/sd/adamyers/desi/target
export DESI_SURVEYOPS=/global/cscratch1/sd/adamyers/test-new-mtl-adds
fba_launch --tileid 999999 --tilera 0 --tiledec 0 --survey main --program DARK --dtver 1.1.1 --outdir ./

This change is backward-compatible, for instance (currently there only is a main/ secondary catalog):

export DESI_TARGET=$DESI_ROOT/target
export DESI_SURVEYOPS=$DESI_ROOT/survey/ops/surveyops/trunk
fba_launch --tileid 999999 --tilera 0 --tiledec 0 --survey main --program DARK --dtver 1.1.1 --outdir ./

Technical python remark:
I came up with: targ = Table(fitsio.read(targdir, columns = columns + ["TARGETID"], rows=rows)), because:

  • I want the fast reading of fitsio with only few columns and some specific rows;
  • I want to stack those with astropy.table.vstack.
    I m happy to implement any more elegant suggestion.

@araichoor
Copy link
Contributor Author

I ve slightly edited the PR first message, to make it more explicit.
@geordie666 : just to confirm: for the main survey, in the future, the expected prefix for added secondary should always be main*, i.e.:
$DESI_TARGET/catalogs/{dr}/{dtver}/targets/main*/secondary/{program}/main*targets-{program}-secondary.fits
right? (like main2, main3, main3a, etc, but it will start with main")

@geordie666
Copy link

Yes, that's correct. The file for added secondary targets will always start with main* (will always be main2, main3, main4...).

@araichoor
Copy link
Contributor Author

ok, great, thanks for the prompt confirmation!

@araichoor araichoor merged commit 5f9781e into master Sep 20, 2021
@araichoor araichoor deleted the scnd_extradirs branch November 3, 2022 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants