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
Implement pixel-based serial CTE correction in CALACS #577
Comments
I'm confirming that our original vision of the algorithm for serial CTE correction in the above comment still holds. I have confirmed that ACSCTE will work as-is on an image with the amps rotated. I took a full-frame image, rotated each amp to point the serial CTE trails towards the chip gap (+Y for WFC2 and -Y for WFC1, as if they were parallel trails) and concatenated the amps back into full 2048x4096 arrays. I created a PCTETAB with extensions 1 through 4 replaced with parameters I determined for serial CTE, and relevant header keywords updated for serial CTE. I'm currently analyzing the resulting CTE-corrected images to determine how to adjust the parameters for a better correction. I can use this technique to test and update the serial CTE model parameters before the serial CTE correction step is implemented in CALACS. It is still true that the new PCTETAB for both parallel and serial correction will have additional extensions. It would have 9 total: 0 for the primary header, 1-4 for parallel CTE parameters, and 5-9 for serial CTE parameters. The format, shape, names, etc of ext 5-9 would be identical to that of ext 1-4, but the values in the data tables and arrays will be different. There will be additional header keywords in the primary header to specify the number of iterations for the forward model (to be determined), number of iterations of correction (PCTENSER), MJD for determining the strength of the correction (SCTEDAT1), and maybe more for serial CTE specifically. I believe the above tests show that the underlying forward model and correction in ACSCTE don't need to be changed for serial CTE. There will need to be a new step to rotate the input arrays correctly first - clockwise 90 deg for amps A and D, counterclockwise 90 deg for amps B and C. Then, the serial CTE correction step will be run using the same code as for parallel CTE, but with the serial header keywords and parameters in the PCTETAB. Then the parallel CTE correction step will be run on the output arrays from the serial correction, rotated back to their normal orientation. One question - does the current CTE correction algorithm use the PCTEFRAC keyword in the PCTETAB header? I'm not sure what it is for at the moment. If you have any questions, let me know! |
@jryon The PCTEFRAC in the PCTETAB header is not even read by the software. The Gen 1 CTE correction does not look for a series of PCTExxxx keywords in the PCTETAB at all. The Gen 2 CTE correction does not look for this particular keyword, though it does look for others (e.g., PCTENSMD). |
@mdlpstsci Great, thanks. Can you provide a list of keywords that the Gen 2 correction cares about, and if you can tell, what they are used for? I want to make sure my understanding of them lines up with what ACSCTE is doing. Thanks! |
@mdlpstsci Remember Issue #166. This issue has been closed as I have added a message to mitigate confusion by any user seeing the so-called error messages which are generated at the lower level. |
@jryon I have a few questions at this time (certainly more later).
|
@mdlpstsci Here are our answers.
Norman's two cents on the last point: "I'm not fussy about the nomenclature, but I don't have a problem with obsoleting both the 'Gen 1' and the current 'Gen 2' versions in favor of the X+Y de-trailing. If the new thing is still called 'Gen 2' because it is essentially two successive Gen2 corrections in orthogonal directions, I'm OK with that." |
|
@mdlpstsci Forgive me, I can't remember which PCTETAB file I sent you - can you remind me? It's been in flux lately so I'd like to make sure you're looking at the current one.
|
@jryon As for 2. above -- No problem. You just need to change the EXTVER when the EXTNAMEs are identical to other extensions. There needs to be a programmatic way to distinguish between the EXTNAMEs. Indeed, the above scheme you note in Item 2 above would work fine. I do suggest there be a keyword in the each extension (for example, 9-12) which indicates the associated amp. |
@jryon |
@jryon |
@jryon I have a working version of the serial and parallel CTE correction coded in CALACS. I have used jdg301bwq for testing which is the image used in ISR ACS 2020-07. I have been trying to verify if I see any improvement. I have tested the flow of the code and I get the same results comparing Items 1, 2, and 3 below which is correct. Item 4 is the full blown new code and reference file, but with an old value for PCTETLEN.
While I have identified the particular object in the image which is discussed in the paper, I cannot say if I see the improvement. I can make the data and software available to you. I have not yet optimized the code, and I may change the way the values are read from the new calibration reference file, depending on the final number of new extensions you want. In any case I wanted you to know I have been working this issue. |
@mdlpstsci Thanks for this great progress! I was out on vacation and then sick for a couple of days, so it'll take me a bit to catch up, but I'm working on it. |
@mdlpstsci Sounds like your testing so far is going well. I'd be happy to take a look at the image you used for testing. It may be that the preliminary PCTETAB I sent you contains an arbitrary serial parameter set, I can't recall. So there may not be much of a correction to see, but I'll take a look. I've put together the current best set of parameters for serial and parallel corrections in a single PCTETAB, located here: /grp/hst/acs3/ryon/ctecorr/pinning/for_michele/combined_par_ser_pctetab.fits I'll note that this is likely not the final version of the PCTETAB. In my testing, I'm seeing some residual serial CTE trails in pre-2022 data that I can't really explain, so it's possible the number of extensions in the PCTETAB may change again. Hopefully this won't cause too much of a headache for you. It would be great if you could test CALACS with this new PCTETAB. I have a number of dark frames we can compare to, so it'd be great if you could run the corrections on any of these files: /grp/hst/acs3/ryon/ctecorr/pinning/serial_data/2022/2022????_long_dark_crrej.fits |
@jryon Thanks for the update. It will take me a few days to get to this as I have to fix a WFC3 issue for software which is part of the latest Release Candidate. I will get to this as soon as I can. |
@jryon I copied your new PCTE TAB calibration file, and I see you have made changes I suggested to the headers. I will now update the code to collect data from this new file which should keep me busy for a bit. Once I am done, then I will attempt to test with data. I will keep you updated. |
@jryon I can properly read your latest PCTETAB file. There is one small issue in that the CTE_VER FITS keyword needs to be a string and not a float. I have to modify the way I am applying the corrections in the code, and this will take me more time. |
@mdlpstsci Thanks, I will make that update to CTE_VER. No problem, I'm still working out the best parameters for past datasets, so take your time. |
@jryon |
@mdlpstsci Great! I'd suggest looking at very hot pixels (>~10k e- in the crrej files) near the amp gaps, so between x ~ 1900 - 2150 in both chips. The highly saturated hot pixels should also have obvious trails. Their approx locations: WFC2 - (1868, 1599), (2703, 1428), (2736, 1592); WFC1 - (2576, 551), (799, 211) Don't know how familiar you are with ds9, but here's what I typically do to see the trails/corrections: open the corrected file in one frame and the uncorrected file in a second frame, then set both to the same scaling (say 0 to 1000e-), lock them according to image coordinates, and then blink the frames to see the changes. |
@jryon |
@mdlpstsci Ah I see. I have newer PCTETAB file(s), one per amp, that I'll combine into a single file for you today. I think the 2022 correction should be about the same with these newer files, but your tests will tell. I've made a few animated gifs blinking uncorrected and corrected darks with the newest parameters: 2022-01-07 dark, WFC2: The files I'm blinking for these two sets of gifs are here: I'd also be happy to take a look at your files if you think that'd be useful. |
@mdlpstsci The most updated PCTETAB is here: /grp/hst/acs3/ryon/ctecorr/pinning/serial_results/combined_par_ser_pctetab_jan2024.fits |
@jryon The calacs.e/acscte.e executables can be accessed here: I have a result in /home/mdelapena/ACS where I did When I blink my input against my output blc, it looks to me as though my version of the code is overcorrecting. It may look this way if there is an "off by 1 pixel" issue somewhere. I would appreciate your comments. |
@mdlpstsci Interestingly, the problem appears to be mostly contained to the first pixel in the trail. I did a few spot checks of hot pixels in my corrected crrej files and yours, and the +2, +3, etc. trail pixels are agreeing well. I'm not sure if that tells us much though, since the trail profile drops off very quickly after +1. I'll continue looking into this tomorrow! |
@mdlpstsci For current testing, since you're only doing the serial correction, I'll update the keywords in the primary header and send you the new file. Sorry for the oversight! |
@jryon |
@jryon |
@mdlpstsci No need to apologize. My fault for assuming they were ready! /grp/hst/acs3/ryon/ctecorr/pinning/michele_testing/ryon_processed/iter2_iter1_unrot_comb_jdg301bwq_blv_tmp_flc.fits |
@jryon
|
|
@jryon /home/mdelapena/cte_repos/hstcal/bin.Linux-3.10.0-1160.108.1.el7.x86_64-x86_64-with-glibc2.17/calacs.e (or acscte.e) which is for test purposes only. This version only has the X CTE correction in play. The two comparison images are located in |
@mdlpstsci |
@jryon I have fixed the rotation issue, but I have been distracted by the Linux and Mac results not agreeing. But I would like to work one issue at a time. When you display the image, do you see what I see? |
If you run the calacs.e executable on the jdg301bwq_raw.fits, does the output match my jdg301bwq_flc.fits? |
@mdlpstsci |
@jryon |
@mdlpstsci |
@jryon Just as an FYI - the source is actually located in /home/mdelapena/fresh_repo/hstcal. I thought I would give you access to these results while I puzzle over the OS-mismatch. As an FYI - this data has been created with a version of the HSTCAL package which has been reorganized by the build manager to clean up cruft, remove circular dependencies, and replace the use of WAF with CMAKE. |
@mdlpstsci |
@jryon Yes, I have done modest testing for the specific update to incorporate the serial correction as I need to make sure that my changes did not modify anything in the parallel processing. The parallel processing is fine. I think I have found a subtle issue associated with OpenMP in the new code, so I believe I have fixed the "serial" problem. I need to do more testing. |
@mdlpstsci |
@jryon I would like to make sure that I have the latest version of the 20220107 file. Is this the latest input and output? INPUT OUTPUT |
@mdlpstsci I should note that I use a custom CCDTAB for processing these long darks since they are stacks of individual dark frames, so their readnoise is reduced by the square root of the number of darks. The custom CCDTAB is in the same directory above, and (confusingly, sorry) has the same name as the reference file: 72m18219j_ccd.fits |
@jryon Having said this, my jdg301bw results agree your results. If you cannot think of something that I left out, can you please processing a few more of the darks with you method and my executable? I did not want to overwrite the executable in /home/mdelapena/hstcal/bin/calacs.e which still exists. My newest executables live here: /home/mdelapena/fresh_repo/hstcal/_build/pkg/acs. You should get the same results regardless of the executable used, but I wanted to be careful. Once you are satisfied the serial CTE looks fine, then I will re-enable the parallel CTE and we can run fuller tests. THANKS |
@mdlpstsci I will also start from scratch and process a few darks all the way to FLC, ensuring the same reference files are used, and let you know what I see. |
@mdlpstsci And these with my code: Both sets use the normal CCDTAB in jref (for simplicity) and the same PCTETAB (combined_par_ser_pctetab_jan2024.fits). I'm seeing exactly the same SCI arrays in both datasets. At this point, I'm happy to sign off on the serial CTE step in your executables. |
Super - I will now enable the serial + parallel CTE correction, and I will let you know when the executable is available. |
@jryon /home/mdelapena/fresh_repo/hstcal/_build/pkg/acs FYI: IMHO I would update the DESCRIP keyword in the new calibration file primary header from Parameters needed for gen2 pixel-based CTE correction to Parameters needed for the serial plus parallel pixel-based CTE correction or something like this so all the documentation in the header of the file is consistent. |
@mdlpstsci |
@jryon |
@mdlpstsci |
@mdlpstsci |
@mdlpstsci Sincere apologies for overlooking this until now! Let me know if there's any more info you need. |
@jryon |
Because this issue is temporarily being put on hold until Jenna has the opportunity/time to examine the regression test data produced (once the software is merged), this is a reminder for me.
|
@jryon Since there are already places in the CALACS code which check for pre- and post-SM4, I just used an "if" statement to check if the expstart (as done in other locations in the source) is "<" or ">= SM4MJD" where SM4MJD=54967. |
We'd like to include a pixel-based correction for serial CTE (X-direction) in CALACS. We have not yet worked out all of the details, so much of this subject to change.
Our initial idea for the algorithm is to take each chip (WFC1, WFC2) from the input science images, split by amp (quadrants), and rotate them such that the serial CTE trails point in the +Y direction. The ACS team would update the PCTETAB to contain the serial CTE trail and trap density parameters in one or more additional extensions. Then, CALACS would run the existing CTE correction algorithm on the rotated quadrants using the serial extensions of the PCTETAB.
The serial CTE correction step would precede the current parallel CTE (Y-direction) correction. The output arrays from serial CTE correction would be input into the parallel CTE correction step, which would proceed as it currently does, using the same extensions/parameters from the PCTETAB.
@yotam-stsci Anything to add?
The text was updated successfully, but these errors were encountered: