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

Patch 202210 #436

Merged
merged 11 commits into from
Oct 19, 2022
Merged

Patch 202210 #436

merged 11 commits into from
Oct 19, 2022

Conversation

araichoor
Copy link
Contributor

This PR prepares the Fall 2022 patching (dubbed "patch_202210") of the fiberassign files.
Patched files (in $DESI_ROOT/users/raichoor/fiberassign-patch/20220928-patch) still need to be vetted, but I am opening the PR as Work In Progress.

The first patching was done on Oct. 5, 2021.

This PR should addresses multiple raised issues (e.g., #375. #403, #423, #432, #433).

Patching approach:

The patching philosophy is:

  • start from the svn fiberassign.fits.gz files (discarding some commissioning tiles, but not restricting to observed tiles);
  • use as "truth" the desitarget catalogs (not the fiberassign intermediate files);
  • patch (remaining) discrepancies between the fiberassign files and the desitarget catalogs;
  • write only the modified fiberassign files.

In addition, we agreed to do in the FIBERASSIGN-extension:

  • fill the EBV values if those are equal to zero;
  • add the FLUX_IVAR_{W1,W2} columns if missing.

The discrepancies can arise from:

  • left-over from the row-mixing not patched in the first round of patching;
  • patched values from the first round of patching that come from extra-desitarget catalogs (those values could be correct, but we just replace with "zeros" in those cases);
  • values not propagated from the desitarget catalogs;
  • other things (e.g. SV3_{DESI,SCND}_TARGET values not propagated for early ToOs).

We agreed to let some remaining discrepancies, and just document them.
For instance, few REF_EPOCH values (for PMRA=PMDEC=0 objects), some MWS_TARGET for "specialbackup" test tiles designed with preliminary desitarget catalogs, some early tiles with extra columns, etc.

Method:

There are three scripts:

  • py/fiberassign/fba_patch_io.py: utility script with all relevant functions;
  • bin/fba_patch_diagnosis: execute the diagnosis;
  • bin/fba_patch: execute the patching, with writing patched files in a separate folder (and save all changes in a fiberassign-TILEID-patching_202210.ecsv file).

And one file:

  • py/fiberassign/data/patching_202210.yaml: lists the desired patched columns, added columns, and populate_ebv behavior.

Test files:

My current test files are in: $DESI_ROOT/users/raichoor/fiberassign-patch:

  • 20220928-diagnosis: the diagnosis on the svn fiberassign files;
  • 20220928-patch: the patched files;
  • 20220928-patch-diagnosis: sanity check, diagnosis run on the patched files;
  • 20220928-patch-patch: sanity check, patching run on the patched files.

The sanity check have "expected" results with:

  • 20220928-patch-diagnosis:
  • remaining REF_EPOCH discrepancy for SUBDIR=000;
  • "created" EBV inconsistency for non-sky/scnd/too filled values for the FIBERASSIGN-extension for SUBDIR=080,082 (EBV inconsistency for sky/scnd/too are ignored, as we actually do modify those since Populate EBV=0 rows in FIBERASSIGN with correct values #414);
  • 20220928-patch-patch: no remaining patching to do on the patched files.

Of course, those tests are kind of circular, so extra-checks are required!

@araichoor araichoor added the WIP Work In Progress label Sep 29, 2022
@araichoor
Copy link
Contributor Author

I forgot to mention that the core patching code has originally been written by @dstndstn (here https://github.com/desihub/fiberassign/blob/f163e9908da4f43505059f31e7b19e325c20c83a/bin/patch-fa-2.py), which I thank a lot for that!
I simply copied/adapted in fba_patch_io.patch().

One technical python question for people more familiar with fitsio than I am:
For the case where we add some columns (here FLUX_IVAR_W{1,2}):

  • we first read the array with
F = fitsio.FITS(in_fafn)
ff = F[ext]
tab = ff.read()
  • we patch the values in tab, which is then stored in patched_tables[extname]
  • but, as I do not know how to add columns to this tab, I create an other array addtab = Table(), where I add the columns; this is then stored in added_tables[extname]
  • we then create a Fout = fitsio.FITS() object which we fill with those tables;
  • and I came up with this not-looking-nice line of code to concatenate those two arrays:
    data = np.array(hstack([Table(patched_tables[extname]), added_tables[extname]]))

    as Fout.write() wants a numpy array.

In addition to being not elegant at all, I am a little worried that this line may change things in the format or that Table() may do some funny things with e.g. introducing some masked values in there.

@araichoor
Copy link
Contributor Author

for info, I ve run few sanity checks (patched. vs. svn) on the headers of the patched files in $DESI_ROOT/users/raichoor/fiberassign-patch/20220928-patch.

I notice one required modification (I ll take care of it), and a few probably harmless differences.

Required modification:

in the current code, when copying the header, we remove the COMMENT keywords:

# fitsio will add its own headers about the FITS format, so trim out all COMMENT cards.
newhdr = fitsio.FITSHDR()
for r in hdr.records():
if r["name"] == "COMMENT":
continue
newhdr.add_record(r)

that has to be changed, as in some early tiles, some information was stored in those COMMENT cards.
for instance:
/global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/080/fiberassign-080611.fits.gz

COMMENT = 'PRIORITY_INIT=2000 and NUMOBS_INIT=1 for BGS_ANY'                    
COMMENT = 'PRIORITY_INIT=10000 and NUMOBS_INIT=1 for STD_WD'                    
COMMENT = 'rescaling SUBPRIORITY in [0.622,1] for BGS_BRIGHT'                   
COMMENT = 'rescaling SUBPRIORITY in [0.404,1] for BGS_FAINT'                    
COMMENT = 'rescaling SUBPRIORITY in [0.0,1] for BGS_FAINT_EXT'                  
COMMENT = 'rescaling SUBPRIORITY in [0.73,1] for BGS_FIBMAG'                    
COMMENT = 'rescaling SUBPRIORITY in [0.692,1] for BGS_LOWQ'                     

which are no more in /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20220928-patch/080/fiberassign-080611.fits.gz.
I ll work on that.

(Harmless) difference nº1:
patched files can have lots of trailing blank keys in the header for ext=1,2,3,4,5.
for instance:

>>> hdr = fits.getheader("/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20220928-patch/001/fiberassign-001006.fits.gz", 5)
>>> [cards[0] for cards in hdr.cards]
['XTENSION', 'BITPIX', 'NAXIS', 'NAXIS1', 'NAXIS2', 'PCOUNT', 'GCOUNT', 'TFIELDS', 'TTYPE1', 'TFORM1', 'TTYPE2', 'TFORM2', 'TTYPE3', 'TFORM3', 'EXTNAME', 'TILEID', 'TILERA', 'TILEDEC', 'FIELDROT', 'FA_PLAN', 'FA_HA', 'FA_RUN', 'FA_M_GFA', 'FA_M_PET', 'FA_M_POS', 'REQRA', 'REQDEC', 'FIELDNUM', 'FA_VER', 'FA_SURV', 'DEPNAM00', 'DEPVER00', 'DEPNAM01', 'DEPVER01', 'DEPNAM02', 'DEPVER02', 'DEPNAM03', 'DEPVER03', 'DEPNAM04', 'DEPVER04', 'DEPNAM05', 'DEPVER05', 'DEPNAM06', 'DEPVER06', 'DEPNAM07', 'DEPVER07', 'DEPNAM08', 'DEPVER08', 'DEPNAM09', 'DEPVER09', 'DEPNAM10', 'DEPVER10', 'DEPNAM11', 'DEPVER11', 'DEPNAM12', 'DEPVER12', 'DEPNAM13', 'DEPVER13', 'DEPNAM14', 'DEPVER14', '', '', '', '', '', '', '', '', '', '', '', '']

whereas those do not exist in the svn file:

>>> hdr = fits.getheader("/global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/001/fiberassign-001006.fits.gz", 5)
>>> [cards[0] for cards in hdr.cards]
['XTENSION', 'BITPIX', 'NAXIS', 'NAXIS1', 'NAXIS2', 'PCOUNT', 'GCOUNT', 'TFIELDS', 'TTYPE1', 'TFORM1', 'TTYPE2', 'TFORM2', 'TTYPE3', 'TFORM3', 'EXTNAME', 'TILEID', 'TILERA', 'TILEDEC', 'FIELDROT', 'FA_PLAN', 'FA_HA', 'FA_RUN', 'FA_M_GFA', 'FA_M_PET', 'FA_M_POS', 'REQRA', 'REQDEC', 'FIELDNUM', 'FA_VER', 'FA_SURV', 'DEPNAM00', 'DEPVER00', 'DEPNAM01', 'DEPVER01', 'DEPNAM02', 'DEPVER02', 'DEPNAM03', 'DEPVER03', 'DEPNAM04', 'DEPVER04', 'DEPNAM05', 'DEPVER05', 'DEPNAM06', 'DEPVER06', 'DEPNAM07', 'DEPVER07', 'DEPNAM08', 'DEPVER08', 'DEPNAM09', 'DEPVER09', 'DEPNAM10', 'DEPVER10', 'DEPNAM11', 'DEPVER11', 'DEPNAM12', 'DEPVER12', 'DEPNAM13', 'DEPVER13', 'DEPNAM14', 'DEPVER14']

I am not sure what is the reason for that.
shall we ignore?

(Harmless) difference nº2:
in some svn-files, some of the COMMENT fits infos are duplicated; e.g.:

>>> hdr = fits.getheader("/global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/082/fiberassign-082140.fits.gz", 0)
>>> hdr["COMMENT"]
  FITS (Flexible Image Transport System) format is defined in 'Astronomy
  and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
  and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
  FITS (Flexible Image Transport System) format is defined in 'Astronomy

whereas they are no more duplicated in the patched files; e.g.:

>>> hdr = fits.getheader("/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20220928-patch/082/fiberassign-082140.fits.gz", 0)
>>> hdr["COMMENT"]
  FITS (Flexible Image Transport System) format is defined in 'Astronomy
  and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H

This sounds also harmless; but could probably be fixed by the above required code change, which is about the COMMENT keywords.

(Harmless) difference nº3:
When adding columns (FLUX_IVAR_W1, FLUX_IVAR_W2), some keywords are naturally changed (NAXIS1, TFIELDS), and few are naturally added (TFORM, TTYPE).
Of course, this is fine.

@araichoor
Copy link
Contributor Author

@sbailey : for info, I m re-generating a set of patching tiles with this fix for the COMMENT header (see commit just ~now).
those will be in $DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch.
it should be done after lunch.

I ll try to perform few extra checks on my side but, as said, it s kind of limited as, by definition, I m using the same tools than for patching.
I didn t have any feedback from @dstndstn or @moustakas.

I suggest that we go ahead and commit the changes this afternoon or tomorrow?

For info, the breakdown of the 3891 patched files:

  • SV3 (SUBDIR=000): all 528 tiles
  • Main/Dark (SUBDIR=001-011): 963 tiles
  • Main/Bright (SUBDIR=020-026): 869 tiles
  • SUBDIR=080: 880 tiles
  • SUBDIR=081: 66 tiles
  • SUBDIR=082: 585 tiles.

@moustakas
Copy link
Member

@araichoor I'm only seeing directories 000-011 and 020-024 in $DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch. Should I be looking elsewhere for the 08[0-2] subdirectories or maybe the patching process isn't completed yet?

@araichoor
Copy link
Contributor Author

yes, please look at $DESI_ROOT/users/raichoor/fiberassign-patch/20220928-patch.
cori is just super-slow today, and it just takes hours to complete.

the only difference is for this COMMENT header thing for some tiles, so looking at 20220928-patch shouldn t prevent you to run tests on the photometric columns!

thanks!

@araichoor
Copy link
Contributor Author

for info, I ve run an independent check for the 20221010-patch version:

  • the inconsistent BRICKID, BRICK_OBJID values in the svn fiberassign files now are consistent in the patched files;
  • the patched files have no inconsistent BRICKID, BRICK_OBJID values.

for most of the targets, the check is to simply consider that those columns are consistent with what decode_targetid() returns.

though, there are some "special" cases to deal with (and took 90% of the time to code...):

(1) secondary-only or ToO targets should have BRICKID=BRICK_OBJID=0 (see discussion here #423).
I add in that target category the "M33_H2PN", "M33_GC", "M33_QSO", "M33_M33cen", "M33_M33out" targets from tileid=80615.

(2) some gaia-only targets should have a meaningful BRICKID, but OBJID=-1.
I identify those with gaiadrs!=0 (output from decode_targetid()) and BACKUP_* or GAIA_* in the cmx or mws bits.
for those I check that the BRICKID is ok with an approximate method: I verify that the brickid derived from the TARGET_RA,TARGET_DEC is in one "adjacent" brick of the reported BRICKID; with "adjacent" meaning that the brick center is within within BRICKROW +/- 1, and 0.4 deg from the BRICKID center.
the reason for that is that some targets have proper-motion correction applied, and this can -- rarely I think -- make the target "move" to another brick.
and I don t want to chase down which targets have proper-motion applied...
[note that some "regular" targets on early tiles also have proper-motion correction applied; but it happens that they all are consistent with brickid derived from the TARGET_RA,TARGET_DEC; probably the GAIA/BACKUP ones are much more numerous, so few cases of "moving-to-another-brick" happen].

ps: if useful, this file lists the found inconsistencies in the svn fiberassign files: /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221010-patch/check-brickidobjid.ecsv.
one can see that all the eight reported cases from #423 with BRICKID, BRICK_OBJID!=0 in the svn tileid=10 fiberassign file are correctly patched with BRICKID=BRICK_OBJID=0.

@araichoor
Copy link
Contributor Author

and for sanity, this file contains the astropy.io.fits.HeaderDiff reports for all patched files, when compared to the svn ones:
/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221010-patch/check-header.ecsv.

the remaining differences are:
(1) extra blank cards;
(2) some FITS (Flexible Image Transport System) format is defined in 'Astronomy and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H duplicate COMMENT removed;
(3) expected differences when the FLUX_IVAR_W{1,2} columns are added.

if the (1) and (2) cases are problematic, please let me know (and then I d appreciate hints of how to fix those).

@araichoor
Copy link
Contributor Author

for info:

  • I forgot to say that files in $DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch (eventually!) finished running yesterday (the tests I reported in my last two messages where done on those);
  • I plan to make another test this morning, checking the consistency of the gaia information w.r.t. the desitarget catalogs, using desitarget.gaiamatch.match_gaia_to_primary().

@dstndstn
Copy link
Contributor

dstndstn commented Oct 11, 2022

Sorry that I have been no help here... is there anything specific you would like me to check?

PS - Anand is a hero!

@dstndstn
Copy link
Contributor

Okay, one quick comment. Files such as
/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221010-patch/000/fiberassign-000002.fits.gz
are not actually in gzip format -- they're uncompressed FITS.

@araichoor
Copy link
Contributor Author

oh, very nice catch!
I guess code change should be here:

os.rename(tempout, out_fafn)

I ll update the code (or you can go ahead if you re willing to :))

(if useful, note that there is this function

def secure_gzip(
fiberassignfn, log=Logger.get(), step="", start=time(),
):
"""
Secure gzipping of the fiberassign-TILEID.fits file.
Args:
fiberassignfn: path to fiberassign-TILEID.fits file (string)
log (optional, defaults to Logger.get()): Logger object
step (optional, defaults to ""): corresponding step, for fba_launch log recording
(e.g. dotiles, dosky, dogfa, domtl, doscnd, dotoo)
start(optional, defaults to time()): start time for log (in seconds; output of time.time()
"""
log.info("")
log.info("")
log.info("{:.1f}s\t{}\tTIMESTAMP={}".format(time() - start, step, Time.now().isot))
if os.path.isfile("{}.gz".format(fiberassignfn)):
os.remove("{}.gz".format(fiberassignfn))
log.info(
"{:.1f}s\t{}\tdeleting existing {}.gz".format(
time() - start, step, fiberassignfn
)
)
os.system("gzip {}".format(fiberassignfn))
log.info("{:.1f}s\t{}\tgzipping {}".format(time() - start, step, fiberassignfn))
)

yes, any check on formatting would be great!

@dstndstn
Copy link
Contributor

I thought it was enough to use a filename of .fits.gz and fitsio would automatically handle the gzipping.

@araichoor
Copy link
Contributor Author

@dstndstn I m back here.
I m quite ignorant about those..
actually, with looking at the code, could it be the culprit is this line:

f, tempout = tempfile.mkstemp(dir=outdir, suffix=".fits")
?
ie could using suffix=".fits.gz" solve that?

I ll make some test-n-tries on one tile, and ping you for confirming things look good.

@moustakas
Copy link
Member

This is what I have to do in fastspecfit to get gzipped output, but I think I just stole this from desispec somewhere--
https://github.com/desihub/fastspecfit/blob/main/py/fastspecfit/io.py#L1059-L1068

@dstndstn
Copy link
Contributor

@araichoor Yeah, that's what I was thinking, changing that suffix from .fits to .fits.gz . A quick test here shows that to work, hopefully it also works on the complicated multi-table fiberassign files!

@araichoor
Copy link
Contributor Author

thanks @moustakas.

I ve given a shot at the simple suggestion I made, i.e. use:

        f, tempout = tempfile.mkstemp(dir=outdir, suffix=".fits.gz")                                                                                                                                

as @dstndstn says, it looks like it should be working.
see this test file in 20221011-patch, compared to the svn-file, and the 20221010-patch version:

raichoor@cori11:~> ls -l {$DESI_TARGET/fiberassign/tiles/trunk,$DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch,$DESI_ROOT/users/raichoor/fiberassign-patch/20221011-patch}/000/fiberassign-000001.fits.gz
-rw-r----- 1 desi     desi  5714316 Oct  5  2021 /global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/000/fiberassign-000001.fits.gz
-rw-rw---- 1 raichoor desi 20784960 Oct 10 10:19 /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221010-patch/000/fiberassign-000001.fits.gz
-rw-rw---- 1 raichoor desi  5716063 Oct 11 13:07 /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221011-patch/000/fiberassign-000001.fits.gz
raichoor@cori11:~> file {$DESI_TARGET/fiberassign/tiles/trunk,$DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch,$DESI_ROOT/users/raichoor/fiberassign-patch/20221011-patch}/000/fiberassign-000001.fits.gz
/global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/000/fiberassign-000001.fits.gz:                  gzip compressed data, max speed, from Unix
/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221010-patch/000/fiberassign-000001.fits.gz: FITS image data, 16-bit, two's complement binary integer
/global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221011-patch/000/fiberassign-000001.fits.gz: gzip compressed data, max speed, from Unix

I ll make that change.

I ll wait for ~tonight to re-generate a new set of files, in case we discover other things today.
so please continue to use $DESI_ROOT/users/raichoor/fiberassign-patch/20221010-patch for checks.

@moustakas
Copy link
Member

I've done a wide range of checks on these files---including looking at the diagnostic files which @araichoor has generated---and I haven't found any totally obvious problems.

As a further check, I went ahead and generated the targetphot and tractorphot catalogs (documented here), focusing on Fuji and the observed (not potential) targets and after removing all the special-casing that I had previously coded up to deal with many (all?) of the issues that have been ostensibly fixed by these patched files.

I found differences with 44,164 objects, all from either sv1-other or sv1-dark, which I'm pasting below. I'm still analyzing these results to convince myself that the "new" values are the correct ones, but I wanted to report these results here as soon as I had them.

new = Table(fitsio.read('/global/cscratch1/sd/ioannis/photocatalog/fuji/observed-targets/targetphot-fuji.fits'))
old = Table(fitsio.read('/global/cfs/cdirs/desi/public/edr/vac/lsdr9-photometry/fuji/v1.0/observed-targets/targetphot-fuji.fits'))
I = []
for col in new.colnames:
    diff = np.where(new[col] != old[col])[0]
    if len(diff) > 0:
        print('Found {} differences in column {}'.format(len(diff), col))
        I.append(diff)
    I = np.unique(np.hstack(I))
Found 12839 differences in column RELEASE
Found 12839 differences in column BRICKID
Found 12839 differences in column BRICKNAME
Found 18856 differences in column RA
Found 12839 differences in column RA_IVAR
Found 19037 differences in column DEC
Found 12839 differences in column DEC_IVAR
Found 52163 differences in column DCHISQ
Found 12839 differences in column EBV
Found 11163 differences in column FLUX_G
Found 9583 differences in column FLUX_R
Found 7684 differences in column FLUX_Z
Found 12770 differences in column FLUX_IVAR_G
Found 12831 differences in column FLUX_IVAR_R
Found 12829 differences in column FLUX_IVAR_Z
Found 12839 differences in column MW_TRANSMISSION_G
Found 12839 differences in column MW_TRANSMISSION_R
Found 12839 differences in column MW_TRANSMISSION_Z
Found 8411 differences in column FRACFLUX_G
Found 8446 differences in column FRACFLUX_R
Found 8469 differences in column FRACFLUX_Z
Found 12673 differences in column FRACMASKED_G
Found 12741 differences in column FRACMASKED_R
Found 12760 differences in column FRACMASKED_Z
Found 12772 differences in column FRACIN_G
Found 12835 differences in column FRACIN_R
Found 12832 differences in column FRACIN_Z
Found 12756 differences in column NOBS_G
Found 12812 differences in column NOBS_R
Found 12829 differences in column NOBS_Z
Found 12741 differences in column PSFDEPTH_G
Found 12785 differences in column PSFDEPTH_R
Found 12817 differences in column PSFDEPTH_Z
Found 12741 differences in column GALDEPTH_G
Found 12785 differences in column GALDEPTH_R
Found 12817 differences in column GALDEPTH_Z
Found 12765 differences in column FLUX_W1
Found 12765 differences in column FLUX_W2
Found 12765 differences in column FLUX_W3
Found 12765 differences in column FLUX_W4
Found 12765 differences in column FLUX_IVAR_W1
Found 12765 differences in column FLUX_IVAR_W2
Found 12765 differences in column FLUX_IVAR_W3
Found 12765 differences in column FLUX_IVAR_W4
Found 12839 differences in column MW_TRANSMISSION_W1
Found 12839 differences in column MW_TRANSMISSION_W2
Found 12839 differences in column MW_TRANSMISSION_W3
Found 12839 differences in column MW_TRANSMISSION_W4
Found 10 differences in column ALLMASK_G
Found 17 differences in column ALLMASK_R
Found 10 differences in column ALLMASK_Z
Found 12471 differences in column FIBERFLUX_G
Found 12798 differences in column FIBERFLUX_R
Found 12797 differences in column FIBERFLUX_Z
Found 12617 differences in column FIBERTOTFLUX_G
Found 12822 differences in column FIBERTOTFLUX_R
Found 12823 differences in column FIBERTOTFLUX_Z
Found 22339 differences in column REF_EPOCH
Found 511 differences in column WISEMASK_W1
Found 275 differences in column WISEMASK_W2
Found 1159 differences in column MASKBITS
Found 6794 differences in column SHAPE_R
Found 2932 differences in column SHAPE_E1
Found 2932 differences in column SHAPE_E2
Found 6794 differences in column SHAPE_R_IVAR
Found 2932 differences in column SHAPE_E1_IVAR
Found 2932 differences in column SHAPE_E2_IVAR
Found 6794 differences in column SERSIC
Found 177 differences in column SERSIC_IVAR
Found 3733 differences in column REF_ID
Found 3733 differences in column REF_CAT
Found 1338 differences in column GAIA_PHOT_G_MEAN_MAG
Found 3184 differences in column GAIA_PHOT_G_MEAN_FLUX_OVER_ERROR
Found 20105 differences in column GAIA_PHOT_BP_MEAN_MAG
Found 21359 differences in column GAIA_PHOT_BP_MEAN_FLUX_OVER_ERROR
Found 20090 differences in column GAIA_PHOT_RP_MEAN_MAG
Found 21354 differences in column GAIA_PHOT_RP_MEAN_FLUX_OVER_ERROR
Found 21366 differences in column GAIA_PHOT_BP_RP_EXCESS_FACTOR
Found 923 differences in column GAIA_ASTROMETRIC_EXCESS_NOISE
Found 233 differences in column GAIA_DUPLICATED_SOURCE
Found 3184 differences in column GAIA_ASTROMETRIC_SIGMA5D_MAX
Found 3184 differences in column GAIA_ASTROMETRIC_PARAMS_SOLVED
Found 2021 differences in column PARALLAX
Found 2145 differences in column PARALLAX_IVAR
Found 3327 differences in column PMRA
Found 2528 differences in column PMRA_IVAR
Found 3252 differences in column PMDEC
Found 2528 differences in column PMDEC_IVAR
Found 12839 differences in column PHOTSYS
Found 25521 differences in column SUBPRIORITY
Found 25521 differences in column OBSCONDITIONS
Found 25521 differences in column PRIORITY_INIT
Found 25521 differences in column NUMOBS_INIT
Found 549 differences in column HPXPIXEL
Found 549 differences in column CMX_TARGET
Found 24972 differences in column SV1_DESI_TARGET
Found 24972 differences in column SV1_SCND_TARGET

with

new[I]
<Table length=44164>
RELEASE BRICKID BRICKNAME BRICK_OBJID MORPHTYPE         RA              RA_IVAR      ... SCND_TARGET SV1_SCND_TARGET SV2_SCND_TARGET SV3_SCND_TARGET SURVEY PROGRAM TILEID
 int16   int32     str8      int32       str4        float64            float32      ...    int64         int64           int64           int64       str7    str6  int32
------- ------- --------- ----------- --------- ------------------ ----------------- ... ----------- --------------- --------------- --------------- ------ ------- ------
   9010  504441  0233p317        3202       PSF   23.3193735438858    975858760000.0 ...           0               0               0               0    cmx   other  80615
   9010  504441  0233p317        5032       PSF  23.39482861890465     41131780000.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0                          0.0               0.0 ...           0               0               0               0    cmx   other  80615
    ...     ...       ...         ...       ...                ...               ... ...         ...             ...             ...             ...    ...     ...    ...
   9011  560879  2372p440        3294       REX   237.398061944953    665753800000.0 ...           0               0               0               0    sv3  bright    595
   9011  564993  2358p450        2612       SER 235.93224830780977   1488772700000.0 ...           0               0               0  79164837199872    sv3  bright    595
   9011  562943  2360p445        2036       REX  236.1029436656815   1145250900000.0 ...           0               0               0               0    sv3  bright    595
   9011  558794  2378p435        1820       SER  237.8642088052636   1094833200000.0 ...           0               0               0               0    sv3  bright    595
   9011  559830  2346p437         608       REX 234.54180905416288   1947112400000.0 ...           0               0               0               0    sv3  bright    595
   9011  559830  2346p437         255       DEV 234.50452614560277     87855915000.0 ...           0               0               0               0    sv3  bright    595
   9011  558785  2347p435        2860       PSF 234.88297811355991 436443570000000.0 ...           0               0               0               0    sv3  bright    595
   9011  560872  2348p440         620       PSF 234.75078421764516 375852900000000.0 ...           0               0               0               0    sv3  bright    595
   9011  559834  2360p437         104       SER  235.8688031416093    297534800000.0 ...           0               0               0               0    sv3  bright    595
   9011  552429  2358p420        1291       PSF  235.7503758255727 705559850000000.0 ...           0               0               0               0    sv3  bright    595
   9011  552433  2371p420        2714       PSF 237.18596747925608  68861550000000.0 ...           0               0               0               0    sv3  bright    595
   9011  552430  2361p420         607       SER 236.02099423694838   2964397800000.0 ...           0               0               0               0    sv3  bright    595

and

old[I]
<Table length=44164>
RELEASE BRICKID BRICKNAME BRICK_OBJID MORPHTYPE         RA              RA_IVAR      ... SCND_TARGET SV1_SCND_TARGET SV2_SCND_TARGET SV3_SCND_TARGET SURVEY PROGRAM TILEID
 int16   int32     str8      int32       str4        float64            float32      ...    int64         int64           int64           int64       str7    str6  int32
------- ------- --------- ----------- --------- ------------------ ----------------- ... ----------- --------------- --------------- --------------- ------ ------- ------
   9010  504441  0233p317        3202       PSF   23.3193735438858    975858760000.0 ...           0               0               0               0    cmx   other  80615
   9010  504441  0233p317        5032       PSF  23.39482861890465     41131780000.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0            23.61778505511247               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0            24.85371131302741               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           23.290294500593273               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           23.903718088910544               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0            24.46656243600391               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           24.734400081956533               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           24.244636253784797               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           23.690612716667154               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0           23.704303265886644               0.0 ...           0               0               0               0    cmx   other  80615
      0       0                     0            23.60869244480378               0.0 ...           0               0               0               0    cmx   other  80615
    ...     ...       ...         ...       ...                ...               ... ...         ...             ...             ...             ...    ...     ...    ...
   9011  560879  2372p440        3294       REX   237.398061944953    665753800000.0 ...           0               0               0               0    sv3  bright    595
   9011  564993  2358p450        2612       SER 235.93224830780977   1488772700000.0 ...           0               0               0  79164837199872    sv3  bright    595
   9011  562943  2360p445        2036       REX  236.1029436656815   1145250900000.0 ...           0               0               0               0    sv3  bright    595
   9011  558794  2378p435        1820       SER  237.8642088052636   1094833200000.0 ...           0               0               0               0    sv3  bright    595
   9011  559830  2346p437         608       REX 234.54180905416288   1947112400000.0 ...           0               0               0               0    sv3  bright    595
   9011  559830  2346p437         255       DEV 234.50452614560277     87855915000.0 ...           0               0               0               0    sv3  bright    595
   9011  558785  2347p435        2860       PSF 234.88297811355991 436443570000000.0 ...           0               0               0               0    sv3  bright    595
   9011  560872  2348p440         620       PSF 234.75078421764516 375852900000000.0 ...           0               0               0               0    sv3  bright    595
   9011  559834  2360p437         104       SER  235.8688031416093    297534800000.0 ...           0               0               0               0    sv3  bright    595
   9011  552429  2358p420        1291       PSF  235.7503758255727 705559850000000.0 ...           0               0               0               0    sv3  bright    595
   9011  552433  2371p420        2714       PSF 237.18596747925608  68861550000000.0 ...           0               0               0               0    sv3  bright    595
   9011  552430  2361p420         607       SER 236.02099423694838   2964397800000.0 ...           0               0               0               0    sv3  bright    595

@moustakas
Copy link
Member

Focusing on the subset of SV1 secondary targets, which have historically been problematic, it looks like my original ("old") catalogs had a bug or some other issue possibly related to the current, non-patched fiberassign files for ~25k of these objects. (Another 1.5k objects are only different in some of the Gaia photometric quantities, which were patched, so that all looks good.)

Here's a snapshot of those objects:

W = np.where((old[I]['SV1_SCND_TARGET'] == 0) * (new[I]['SV1_SCND_TARGET'] > 0))[0]
old[I][W]
<Table length=24972>
RELEASE BRICKID BRICKNAME BRICK_OBJID MORPHTYPE         RA             RA_IVAR             DEC         ... SV3_MWS_TARGET SCND_TARGET SV1_SCND_TARGET SV2_SCND_TARGET SV3_SCND_TARGET SURVEY PROGRAM TILEID
 int16   int32     str8      int32       str4        float64           float32           float64       ...     int64         int64         int64           int64           int64       str7    str6  int32
------- ------- --------- ----------- --------- ------------------ ---------------- ------------------ ... -------------- ----------- --------------- --------------- --------------- ------ ------- ------
   9010  441180  1308p195           0           130.81102637972919 44123856000000.0  19.50410435290587 ...              0           0               0               0               0    sv1    dark  80687
   9010  442539  1308p197           0           130.80441405782605 13994567000000.0   19.6502979192866 ...              0           0               0               0               0    sv1    dark  80687
   9010  432979  1300p180           0           129.92384490586852 27278606000000.0 17.933903296131277 ...              0           0               0               0               0    sv1    dark  80687
   9011  513318  1305p335           0            130.4727120331827   110471004000.0   33.4537705345472 ...              0           0               0               0               0    sv1    dark  80689
      0       0                     0                          0.0              0.0                0.0 ...              0           0               0               0               0    sv1    dark  80689
   9011  510918  1346p330           0           134.59172477429598   131669310000.0  33.01002652785511 ...              0           0               0               0               0    sv1    dark  80691
   9011  510918  1346p330           0           134.71933493102756    98712175000.0  32.92441489815461 ...              0           0               0               0               0    sv1    dark  80691
   9011  514552  1399p337           0           139.80468978636415   156691020000.0  33.80510943320067 ...              0           0               0               0               0    sv1    dark  80692
   9011  510931  1384p330           0           138.44650343646603      318456900.0  32.88174511782534 ...              0           0               0               0               0    sv1    dark  80692
   9010  507281  1379p322           0            138.0775142014151 16940125000000.0  32.18109661751957 ...              0           0               0               0               0    sv1    dark  80692
   9011  642396  1384p702           0           138.21513575141392   102587605000.0  70.37479458559505 ...              0           0               0               0               0    sv1    dark  80695
   9011  641403  1387p697           0           138.97198441897763   194152190000.0   69.6416660349806 ...              0           0               0               0               0    sv1    dark  80695
   9011  643845  1414p710           0           141.71145970744516   117328620000.0  70.89352800534101 ...              0           0               0               0               0    sv1    dark  80695
    ...     ...       ...         ...       ...                ...              ...                ... ...            ...         ...             ...             ...             ...    ...     ...    ...
   9010  507659  2494p322           0           249.39506742555182    24622250000.0 32.297638223679954 ...              0           0               0               0               0    sv1    dark  80901
   9010  507659  2494p322           0           249.40464857210952   226629650000.0 32.216078493194864 ...              0           0               0               0               0    sv1    dark  80901
   9010  507657  2489p322           0           248.85807983911235    20494547000.0  32.26158105714855 ...              0           0               0               0               0    sv1    dark  80901
   9011  510086  2474p327           0           247.39311200764317    64985375000.0 32.666799273291566 ...              0           0               0               0               0    sv1    dark  80902
   9011  511295  2467p330           0           246.93167833631648 27609405000000.0  32.94417702900941 ...              0           0               0               0               0    sv1    dark  80902
   9011  511294  2464p330           0           246.54902459987835 11820995000000.0     33.02921009563 ...              0           0               0               0               0    sv1    dark  80902
   9011  513713  2486p335           0           248.65582063912484   226158070000.0  33.46087322890791 ...              0           0               0               0               0    sv1    dark  80902
   9011  514913  2482p337           0           248.16575912771063    88802610000.0  33.74278277452765 ...              0           0               0               0               0    sv1    dark  80902
   9011  514913  2482p337           0           248.20335270412528   270515780000.0 33.787665978986695 ...              0           0               0               0               0    sv1    dark  80902
      0       0                     0                          0.0              0.0                0.0 ...              0           0               0               0               0    sv1    dark  80902
   9011  514910  2473p337           0           247.38588244374014    51612107000.0  33.83292072951017 ...              0           0               0               0               0    sv1    dark  80902
   9011  514909  2470p337           0            246.9110423593867    25976529000.0  33.72570017717439 ...              0           0               0               0               0    sv1    dark  80902
   9011  511304  2494p330           0           249.50327429772383  1726764700000.0  32.92713894284664 ...              0           0               0               0               0    sv1    dark  80902
   9010  503975  2468p315           0           246.97698778298283 69219794000000.0 31.554800844999864 ...              0           0               0               0               0    sv1    dark  80902

and

new[I][W]
<Table length=24972>
RELEASE BRICKID BRICKNAME BRICK_OBJID MORPHTYPE         RA         RA_IVAR        DEC         DEC_IVAR ... SV3_MWS_TARGET SCND_TARGET SV1_SCND_TARGET SV2_SCND_TARGET SV3_SCND_TARGET SURVEY PROGRAM TILEID
 int16   int32     str8      int32       str4        float64       float32      float64       float32  ...     int64         int64         int64           int64           int64       str7    str6  int32
------- ------- --------- ----------- --------- ------------------ ------- ------------------ -------- ... -------------- ----------- --------------- --------------- --------------- ------ ------- ------
      0       0                     0                      130.811     0.0          19.504128      0.0 ...              0           0    755914637312               0               0    sv1    dark  80687
      0       0                     0                    130.80439     0.0          19.650296      0.0 ...              0           0    755914637312               0               0    sv1    dark  80687
      0       0                     0             129.923844905869     0.0   17.9339032961313      0.0 ...              0           0          262144               0               0    sv1    dark  80687
      0       0                     0             130.472711671896     0.0   33.4537703302205      0.0 ...              0           0            2048               0               0    sv1    dark  80689
      0       0                     0                    132.66211     0.0           33.16773      0.0 ...              0           0               2               0               0    sv1    dark  80689
      0       0                     0             134.591721894933     0.0   33.0100264469923      0.0 ...              0           0            2048               0               0    sv1    dark  80691
      0       0                     0             134.719340254623     0.0   32.9244172262287      0.0 ...              0           0            2048               0               0    sv1    dark  80691
      0       0                     0             139.804690999734     0.0    33.805109766338      0.0 ...              0           0            2048               0               0    sv1    dark  80692
      0       0                     0             138.446637446027     0.0   32.8816434623671      0.0 ...              0           0            2048               0               0    sv1    dark  80692
      0       0                     0             138.077514201415     0.0   32.1810966175196      0.0 ...              0           0          393216               0               0    sv1    dark  80692
      0       0                     0             138.215125421985     0.0   70.3747968823005      0.0 ...              0           0            2048               0               0    sv1    dark  80695
      0       0                     0              138.97198025892     0.0   69.6416667799498      0.0 ...              0           0            2048               0               0    sv1    dark  80695
      0       0                     0             141.711462663836     0.0   70.8935266656755      0.0 ...              0           0            2048               0               0    sv1    dark  80695
    ...     ...       ...         ...       ...                ...     ...                ...      ... ...            ...         ...             ...             ...             ...    ...     ...    ...
      0       0                     0           249.39506742555182     0.0 32.297638223679954      0.0 ...              0           0     34359738368               0               0    sv1    dark  80901
      0       0                     0           249.40464857210952     0.0 32.216078493194864      0.0 ...              0           0     34359738368               0               0    sv1    dark  80901
      0       0                     0           248.85807983911235     0.0  32.26158105714855      0.0 ...              0           0     34359738368               0               0    sv1    dark  80901
      0       0                     0             247.393116770815     0.0   32.6668011500165      0.0 ...              0           0          133120               0               0    sv1    dark  80902
      0       0                     0           246.93167828898066     0.0 32.944176508294014      0.0 ...              0           0          524288               0               0    sv1    dark  80902
      0       0                     0             246.549024599878     0.0     33.02921009563      0.0 ...              0           0    549756207104               0               0    sv1    dark  80902
      0       0                     0             248.655820855275     0.0    33.460874330149      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0             248.165761305252     0.0   33.7427827201487      0.0 ...              0           0          133120               0               0    sv1    dark  80902
      0       0                     0             248.203351381178     0.0   33.7876655042255      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0             247.696828897356     0.0   33.9714736770654      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0              247.38588466805     0.0   33.8329202404397      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0              246.91104386667     0.0   33.7257011890908      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0             249.503275096129     0.0   32.9271393614752      0.0 ...              0           0            2048               0               0    sv1    dark  80902
      0       0                     0             246.976987782983     0.0   31.5548008449999      0.0 ...              0           0    549756207104               0               0    sv1    dark  80902

@araichoor
Copy link
Contributor Author

for info, I ve run another "independent" check on the patched files: if I exclude the EBV and FLUX_IVAR_W{1,2} modifications, the modified rows mostly are for SCND_ANY targets, as one would expect from the row-mixing bug.

details:
I browse my fiberassign-TILEID-patching_202210.ecsv files which lists all the modifications.
I exclude modifications due to EBV (as we fill it) and FLUX_IVAR_W{1,2} (as we add those).
I then remove all targets which have as their primary mask equal to SCND_ANY (secondary-only or ToOs, affected by the row-mixing bug).

Then remain only modifications for tiles:

  • 80605-80610 + 80615
  • dither tiles 80000-80604

For those early tiles from Dec. 2020, the rows are modified for ~all the TARGETIDs, because we patch the fact that some columns were not propagated then, and just filled with zeros (BRICKNAME,HPXPIXEL and BRICKID,BRICKNAME,BRICK_OBJID,HPXPIXEL,RELEASE).

So it overall makes sense (to me at least!).

@araichoor
Copy link
Contributor Author

and a last check report, on the gaia column values consistency with desitarget.gaiamatch.match_gaia_to_primary(): the patching process looks good to me, as far as I can tell (the interpretation of the listed inconsistencies is not trivial).

here, what I do is:

  • I discard the dithprec,dithlost,dithfocus tiles and tiles with PMCORR applied from this test
  • for each tile, I select in the svn (ie not patched) fiberassign files objects with REF_CAT=G2 or G3, and I compare for those the gaia column content in the fiberassign files w.r.t. what is return when matching with desitarget.gaiamatch.match_gaia_to_primary().
  • I list all discrepant values, along with the values in the patched files.

all discrepant values happen for TARGETID where the patching nulled the REF_ID (and the mask is SCND_ANY), i.e. the target is not officially drawn from gaia, it comes from a secondary-only program or a ToO, and have no REF_ID.
note that those secondary program or ToO actually likely have picked those targets from gaia, and there actually can be some (apparent?) discrepancy; but that is not our issue here.

while doing that check, I also uncover an apparent issue in Tractor, ie in the ls-dr9 files.
it appears that a couple hundreds of primary targets have wrong gaia column values.
but again, here, that is not our issue.

@sbailey
Copy link
Contributor

sbailey commented Oct 18, 2022

I agree that the minimalist comment is sufficient, though let's merge + run "python setup.py version" to update the dev version that gets recorded before the final final rerun on the files so that the fiberassign version matches what was actually used.

@araichoor
Copy link
Contributor Author

ok perfect, let s go for the minimalist comment.
so we are happy with the code changes? if so, I ll merge.

about: run "python setup.py version" to update the dev version
@sbailey could you give me clear instructions?

shall I do the following?

  • first merge
  • then (e.g. from my user nersc account):
git checkout main
git pull origin main
python setup.py version
git commit -am "update dev version after merging patch_202210 [skip ci]"
git push origin main

@sbailey
Copy link
Contributor

sbailey commented Oct 19, 2022

Bummer about the ls-dr9 gaia targets, but this PR and cross checks look good, so merging now. Thanks.

And yes about steps for updating the dev version number. If you hit any problems with that, ping me on slack and we'll sort it out.

@sbailey sbailey merged commit b2f7282 into main Oct 19, 2022
@sbailey sbailey deleted the patch_202210 branch October 19, 2022 02:49
@araichoor
Copy link
Contributor Author

@sbailey : there were two commits I haven t pushed yet ! (sorry I realize my previous message was ambiguous).
I see some "revert" and "restore branch" buttons: could you do that?

then I ll push my two commits + merge.

@sbailey sbailey restored the patch_202210 branch October 19, 2022 03:05
@sbailey
Copy link
Contributor

sbailey commented Oct 19, 2022

I restored the branch, but I'll ping you on slack to coordinate next steps

@araichoor
Copy link
Contributor Author

for the record: I ve uploaded on DocDB the preparatory document used to make the diagnosis of the inconsistencies: https://desi.lbl.gov/DocDB/cgi-bin/private/ShowDocument?docid=7086.

@weaverba137
Copy link
Member

Is it still possible to add:

LONGSTRN= 'OGIP 1.0' / Long string convention may be used.

To HDU 0 of the patched files?

@araichoor
Copy link
Contributor Author

I finished the svn commit (nersc) + checkout (kpno) on Sunday.
the progress was reported in this thread: https://desisurvey.slack.com/archives/C01HNN87Y7J/p1666295718270009.

in theory, I think I could re-generate the files with adding that LONGSTRN keyword, and re-svn commit/checkout, but I feel it s not critical enough to do that, no?

if I understand correctly: that would be to handle in a cleaner way the added COMMENT which is spreading on two lines?
if so, note that every designed main tile (and all special tiles designed since quite some time) already has a super-long FAARGS argument...

raichoor@cori05:~> fitsheader -e 0 -k FAARGS $DESI_TARGET/fiberassign/tiles/trunk/001/fiberassign-001000.fits.gz 
# HDU 0 in /global/cfs/cdirs/desi/target/fiberassign/tiles/trunk/001/fiberassign-001000.fits.gz:
FAARGS  = '--doclean n --dr dr9 --dtver 1.0.0 --gaiadr gaiadr2 --goaltime 1000&'CONTINUE  '.0 --ha 15.91 --hdr_faprgrm dark --hdr_survey main --log_stdout Fal&'CONTINUE  'se --margin_gfa 0.4 --margin_petal 0.4 --margin_pos 0.05 --mintfrac&'CONTINUE  ' 0.85 --mtltime 2021-05-14T23:48:14+00:00 --pmcorr n --pmtime_utc_s&'CONTINUE  'tr 2021-05-14T23:48:14+00:00 --program DARK --rundate 2021-05-14T23&'CONTINUE  ':48:14+00:00 --sbprof ELG --sky_per_petal 40 --sky_per_slitblock 1 &'CONTINUE  '--standards_per_petal 10 --survey main --tiledec 0.0 --tileid 1000 &'CONTINUE  '--tilera 238.282'

@weaverba137
Copy link
Member

Adding LONGSTRN avoids a warning when verifying the files with fitsverify. Has fitsverify actually been run on all the files? Even if we don't modify LONGSTRN, that's still a really important, independent QA check.

If we're already at the svn commit stage though, it's probably too late to add it. We can still run fitsverify though.

@weaverba137
Copy link
Member

Also LONGSTRN is concerned with real string header cards, like FAARGS, which have a CONTINUE card. It's not so much concerned with COMMENT cards.

@araichoor
Copy link
Contributor Author

I didn t run fitsverify; I did run some checks against the original files.
I can rerun those + fitsverify, and report (later today).
thanks for pointing that out!

@araichoor
Copy link
Contributor Author

I ve run fitsverify -q FILENAME on the 3891 patched files, results are in this file: tmp-fitsverify.txt.

52 are OK, 3839 are FAILED with 1, 2, 6, or 7 warnings:

raichoor@cori05:~> fitsverify -q $DESI_ROOT/users/raichoor/fiberassign-patch/20221019-patch/???/fiberassign-??????.fits.gz > tmp-fitsverify.txt
raichoor@cori05:~> grep OK tmp-fitsverify.txt | wc -l
52
raichoor@cori05:~> grep FAILED tmp-fitsverify.txt | wc -l
3839
raichoor@cori05:~> grep FAILED tmp-fitsverify.txt | awk '{$1=""; $2=""; $3=""; print $0;}' | sort | uniq
   1 warnings and 0 errors
   2 warnings and 0 errors
   6 warnings and 0 errors
   7 warnings and 0 errors

I think the warnings are just these ones:

*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)

e.g. running this command:

raichoor@cori05:~/Scripts> fitsverify $DESI_ROOT/users/raichoor/fiberassign-patch/20221019-patch/???/fiberassign-??????.fits.gz | grep Warning | sort | uniq                                 
fits HDU#  Name (version)       Type             Warnings  Errors
*** Warning: The OGIP long string keyword convention is used without the

@weaverba137
Copy link
Member

I believe you that most of the warnings are due to missing LONGSTRN. However, I am not convinced that all of the warnings are due to that.

In particular, let's assume that for some reason every HDU in a particular file needed to have the LONGSTRN keyword. That would emit 6 warnings, because there are 6 HDUs. However:

   6 warnings and 0 errors
   7 warnings and 0 errors

Where does the extra warning come from? So if nothing else, there is still something suspicious going on. I would like to actually see the examples that have 6-7 warnings.

@araichoor
Copy link
Contributor Author

isn t this command from my last message demonstrating it s only due to missing LONGSTRN?:

raichoor@cori05:~/Scripts> fitsverify $DESI_ROOT/users/raichoor/fiberassign-patch/20221019-patch/???/fiberassign-??????.fits.gz | grep Warning | sort | uniq                                 
fits HDU#  Name (version)       Type             Warnings  Errors
*** Warning: The OGIP long string keyword convention is used without the

about the 7 warnings cases: from grepping the tmp-fitsverify.txt file, those are dithered tiles: https://desi.lbl.gov/trac/wiki/SurveyOps/TileDesigns#a82692-82795-Dithers.
more precisely: dithered are generated by series, e.g. Tiles 82692 - 82704:

  • the first tile of each serie is undithered
  • the other ones are dithered; and have an EXTRA extra extension, recording the undithered positions.
    there are here eight series of 13 dithers (for each serie, one undithered, the first, with 6 extensions, and 12 dithered with 7 extensions).

there are 1x8=8 6 warnings cases, and 12x8=96 7 warnings cases.

then one legitimate question is: why for those dithers tiles, all extensions get a warning, while it s not the case for the other tiles?
from spot-checking one file, I believe it s because the way DESIMODEL is stored:

raichoor@cori08:~/Scripts> fitsheader -e 1 -k DEPNAM21 -k DEPVER21 /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/082/fiberassign-082692.fits.gz
# HDU 1 in /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/082/fiberassign-082692.fits.gz:
DEPNAM21= 'DESIMODEL'                                                           
DEPVER21= '/global/common/software/desi/cori/desiconda/20211217-2.0.0/code/des&'CONTINUE  'imodel/master'                                                       

for non-dithered tiles, the dependencies are stored differently:

raichoor@cori08:~/Scripts> fitsheader -e 0 -k DEPNAM06 -k DEPVER06 /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/080/fiberassign-080605.fits.gz 
# HDU 0 in /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/080/fiberassign-080605.fits.gz:
FA_VER  = '2.0.0.dev2618'                                                       
DEPNAM06= 'desimodel'                                                           
DEPVER06= '0.13.1.dev619'                                                       

that s likely explainable with digging into fba_cmx which generates those dithered tiles.

@araichoor
Copy link
Contributor Author

for completeness, here is one example of a 7 warnings case:

raichoor@cori08:~/Scripts> fitsverify /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/082/fiberassign-082693.fits.gz
 
              fitsverify 4.20 (CFITSIO V4.000)              
              --------------------------------              
 
 
File: /global/cfs/cdirs/desi/users/raichoor/fiberassign-patch/20221019-patch/082/fiberassign-082693.fits.gz

7 Header-Data Units in this file.
 
=================== HDU 1: Primary Array ===================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 84 header keywords
 
 Null data array; NAXIS = 0 
 
=================== HDU 2: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 196 header keywords
 
 FIBERASSIGN  (62 columns x 5000 rows)
 
 Col# Name (Units)       Format
   1 TARGETID             K         
   2 PETAL_LOC            I         
   3 DEVICE_LOC           J         
   4 LOCATION             J         
   5 FIBER                J         
   6 FIBERSTATUS          J         
   7 TARGET_RA            D         
   8 TARGET_DEC           D         
   9 PMRA                 E         
  10 PMDEC                E         
  11 REF_EPOCH            E         
  12 LAMBDA_REF           E         
  13 FA_TARGET            K         
  14 FA_TYPE              B         
  15 OBJTYPE              3A        
  16 FIBERASSIGN_X        E         
  17 FIBERASSIGN_Y        E         
  18 PRIORITY             J         
  19 SUBPRIORITY          D         
  20 OBSCONDITIONS        J         
  21 RELEASE              I         
  22 BRICKNAME            8A        
  23 BRICKID              J         
  24 BRICK_OBJID          J         
  25 MORPHTYPE            4A        
  26 EBV                  E         
  27 FLUX_G               E         
  28 FLUX_R               E         
  29 FLUX_Z               E         
  30 FLUX_W1              E         
  31 FLUX_W2              E         
  32 FLUX_IVAR_G          E         
  33 FLUX_IVAR_R          E         
  34 FLUX_IVAR_Z          E         
  35 FLUX_IVAR_W1         E         
  36 FLUX_IVAR_W2         E         
  37 FIBERFLUX_G          E         
  38 FIBERFLUX_R          E         
  39 FIBERFLUX_Z          E         
  40 FIBERTOTFLUX_G       E         
  41 FIBERTOTFLUX_R       E         
  42 FIBERTOTFLUX_Z       E         
  43 MASKBITS             I         
  44 SERSIC               E         
  45 SHAPE_R              E         
  46 SHAPE_E1             E         
  47 SHAPE_E2             E         
  48 REF_ID               K         
  49 REF_CAT              2A        
  50 GAIA_PHOT_G_MEAN_MAG E         
  51 GAIA_PHOT_BP_MEAN_MA E         
  52 GAIA_PHOT_RP_MEAN_MA E         
  53 PARALLAX             E         
  54 PHOTSYS              1A        
  55 PRIORITY_INIT        K         
  56 NUMOBS_INIT          K         
  57 CMX_TARGET           K         
  58 DESI_TARGET          K         
  59 BGS_TARGET           K         
  60 MWS_TARGET           K         
  61 PLATE_RA             D         
  62 PLATE_DEC            D         
 
=================== HDU 3: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 112 header keywords
 
 SKY_MONITOR  (20 columns x 20 rows)
 
 Col# Name (Units)       Format
   1 FIBER                J         
   2 LOCATION             J         
   3 TARGETID             K         
   4 BRICKID              J         
   5 BRICK_OBJID          J         
   6 FA_TARGET            K         
   7 FA_TYPE              B         
   8 TARGET_RA            D         
   9 TARGET_DEC           D         
  10 FIBERASSIGN_X        E         
  11 FIBERASSIGN_Y        E         
  12 BRICKNAME            8A        
  13 FIBERSTATUS          J         
  14 PETAL_LOC            I         
  15 DEVICE_LOC           J         
  16 PRIORITY             J         
  17 SUBPRIORITY          D         
  18 FIBERFLUX_G          E         
  19 FIBERFLUX_R          E         
  20 FIBERFLUX_Z          E         
 
=================== HDU 4: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 150 header keywords
 
 GFA_TARGETS  (39 columns x 586 rows)
 
 Col# Name (Units)       Format
   1 RELEASE              J         
   2 TARGETID             K         
   3 BRICKID              J         
   4 BRICK_OBJID          J         
   5 TARGET_RA            D         
   6 TARGET_DEC           D         
   7 TARGET_RA_IVAR       E         
   8 TARGET_DEC_IVAR      E         
   9 MORPHTYPE            4A        
  10 MASKBITS             I         
  11 FLUX_G               E         
  12 FLUX_R               E         
  13 FLUX_Z               E         
  14 FLUX_IVAR_G          E         
  15 FLUX_IVAR_R          E         
  16 FLUX_IVAR_Z          E         
  17 REF_ID               K         
  18 REF_CAT              2A        
  19 REF_EPOCH            E         
  20 PARALLAX             E         
  21 PARALLAX_IVAR        E         
  22 PMRA                 E         
  23 PMDEC                E         
  24 PMRA_IVAR            E         
  25 PMDEC_IVAR           E         
  26 GAIA_PHOT_G_MEAN_MAG E         
  27 GAIA_PHOT_G_MEAN_FLU E         
  28 GAIA_PHOT_BP_MEAN_MA E         
  29 GAIA_PHOT_BP_MEAN_FL E         
  30 GAIA_PHOT_RP_MEAN_MA E         
  31 GAIA_PHOT_RP_MEAN_FL E         
  32 GAIA_ASTROMETRIC_EXC E         
  33 URAT_ID              K         
  34 URAT_SEP             E         
  35 HPXPIXEL             K         
  36 GFA_LOC              I         
  37 GUIDE_FLAG           I         
  38 FOCUS_FLAG           I         
  39 ETC_FLAG             I         
 
=================== HDU 5: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 96 header keywords
 
 TARGETS  (12 columns x 129781 rows)
 
 Col# Name (Units)       Format
   1 TARGETID             K         
   2 RA                   D         
   3 DEC                  D         
   4 FA_TARGET            K         
   5 FA_TYPE              B         
   6 PRIORITY             J         
   7 SUBPRIORITY          D         
   8 OBSCONDITIONS        J         
   9 CMX_TARGET           K         
  10 DESI_TARGET          K         
  11 BGS_TARGET           K         
  12 MWS_TARGET           K         
 
=================== HDU 6: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 78 header keywords
 
 POTENTIAL_ASSIGNMENTS  (3 columns x 144346 rows)
 
 Col# Name (Units)       Format
   1 TARGETID             K         
   2 FIBER                J         
   3 LOCATION             J         
 
=================== HDU 7: BINARY Table ====================
 
*** Warning: The OGIP long string keyword convention is used without the
             recommended LONGSTRN keyword.  (HEASARC Convention)
 
 91 header keywords
 
 EXTRA  (3 columns x 5000 rows)
 
 Col# Name (Units)       Format
   1 UNDITHER_RA          D         
   2 UNDITHER_DEC         D         
   3 TARGETID             K         
 
++++++++++++++++++++++ Error Summary  ++++++++++++++++++++++
 
 HDU#  Name (version)       Type             Warnings  Errors
 1                          Primary Array    1         0     
 2     FIBERASSIGN          Binary Table     1         0     
 3     SKY_MONITOR          Binary Table     1         0     
 4     GFA_TARGETS          Binary Table     1         0     
 5     TARGETS              Binary Table     1         0     
 6     POTENTIAL_ASSIGNMENTS Binary Table     1         0     
 7     EXTRA                Binary Table     1         0     
 
**** Verification found 7 warning(s) and 0 error(s). ****

@weaverba137
Copy link
Member

I'll take a look myself, but fitsverify -l is actually what you want to really reveal the details of header keywords.

@araichoor
Copy link
Contributor Author

ok thanks!
please let me know if you need more details / explanations from my side.

besides, I ve on my to-do-list to update the fiberassign datamodel with a comment that some dithered tiles can have a 7th extension: https://desidatamodel.readthedocs.io/en/latest/DESI_TARGET/fiberassign/tiles/TILES_VERSION/TILEXX/fiberassign-TILEID.html.

@weaverba137
Copy link
Member

OK, I have confirmed your findings. It is indeed possible for every HDU to contain a CONTINUE card!

Since this PR is already merged, I think we can just stop commenting to call this done. Thanx for the extra QA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants