-
Notifications
You must be signed in to change notification settings - Fork 158
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
Test C implementation of ramp_fitting #8414
Comments
Comment by Kenneth MacDonald on JIRA: To run the C code, rather than the python code, there is a variable Set that variable to There are expected differences in outputs when comparing outputs from the python and C code. There are parts of the code that result in different rounding errors, due to underflows, such as dividing small numbers by small numbers. This can result in as many as 5% of differences, but they are typically small. Most differences of this type disappears with tolerances larger than The other difference that shows up is due to computing integration ramp segments in two separate parts of the code and computing them differently. This happens far more rarely than the above and typically happens in the variance arrays. In the files I've tested, when these show up, they only affect a few dozen pixels. There should not be any differences in the DQ arrays. |
Awesome, thanks Kenneth MacDonald ! Just confirming that I can install and run your code; I'm presuming this is the branches np_c_ext in your fork of both jwst and stcal. In one quick test so far I tried processing a MIRI MRS exposure with 188 groups. SCI arrays on initial inspection show only trivial differences consistent with rounding error. Runtime of ramp_fit is 2min 26sec with the regular python code, and 7 seconds with the C code. |
Comment by Kenneth MacDonald on JIRA: David Law There is a np_c_ext branch in JWST as well. There are two changes in the JWST code. First, the changes are for the tests, since the C code enforces typing for the |
Comment by Maria Pena-Guerrero on JIRA: I tested the ramp step on NIRSpec MOS data. The Python code takes about 2 hrs to run, and the C code takes about 10 min. The difference is very small with a mean of about 1.5e-6 and std_dev 3.1e-3 of the SCI arrays. There is indeed no difference in the DQ extensions. |
Comment by Nadia Dencheva on JIRA: Starting a table so it's easier to track results. Please enter all results from now on in the table. groups||total run time Python||total run time C||rampfit run timePython||rampfit run time |
Just updated the table with the results of testing a variety of kinds of data from all 4 instruments. All look good, negligible differences in SCI and ERR arrays and no differences in the DQ arrays. ramp fitting runtime improves dramatically, though in some cases this doesn't have an enormous impact on total detector1 runtime because the jump step is now the tallest pole. Also worth noting that the C code here does not (currently) pull in any of the changes being made for https://jira.stsci.edu/browse/JP-3463, so whatever is done there would need to be added to the C code here. To me this looks like it should be about ready to merge into the main code so that it's easier for INS teams to test further without having to install branches. |
Comment by Ned Molter on JIRA: I am unable to pip install stcal when I'm on your branch. I think Nadia Dencheva mentioned something similar today. I'm using MacOS Ventura 13.6.3 with Apple M2 Max processors. I'm copying the error message below.
building 'stcal.ramp_fitting.slope_fitter' extension
clang -fno-strict-overflow -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /Users/emolter/anaconda3/envs/py312/include -arch arm64 -fPIC -O2 -isystem /Users/emolter/anaconda3/envs/py312/include -arch arm64 -DNUMPY=1 -I/private/var/folders/4c/gd84fq3972vc4jnbtqmnrrnr0005r1/T/pip-build-env-lyksx69r/overlay/lib/python3.12/site-packages/numpy/core/include -I/Users/emolter/anaconda3/envs/py312/include/python3.12 -c src/stcal/ramp_fitting/src/slope_fitter.c -o build/temp.macosx-11.1-arm64-cpython-312/src/stcal/ramp_fitting/src/slope_fitter.o
src/stcal/ramp_fitting/src/slope_fitter.c:2032:9: warning: variable 'nan_cnt' set but not used [-Wunused-but-set-variable]
int nan_cnt;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2637:35: error: expected ')'
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2637:18: note: to match this '('
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2682:39: error: expected ')'
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2682:22: note: to match this '('
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2843:39: error: expected ')'
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
src/stcal/ramp_fitting/src/slope_fitter.c:2843:22: note: to match this '('
seg->var_p = (pr->median_rate pr->dcurrent) / pden;
^
1 warning and 3 errors generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for stcal
Failed to build stcal
ERROR: Could not build wheels for stcal, which is required to install pyproject.toml-based projects ``` |
Comment by Nadia Dencheva on JIRA: I get the same error on Monterey. I'll ask Joe to look at the setup file when he's back. |
Comment by Kenneth MacDonald on JIRA: Ned Molter and Nadia Dencheva when did you pull the branch? I fixed the missing "+" this morning before the stand up and pushed it.
|
Comment by Ned Molter on JIRA: This change fixed the problem for me, thanks. Code runs successfully now. |
Comment by Kenneth MacDonald on JIRA: [^ramp_fit_c_switch.py]
^I updated the STCAL code to be able to switch between the C code and the python code programmatically when using the RampFitStep class. I have attached a test script I used as an example for how to use the JWST RampFitStep class to switch between the C code and the python code. Notice that I have a directory and file name locally defined, so if you use this script change those variables to match your local directory name and file name.^ |
Comment by Kenneth MacDonald on JIRA: I have updated the RampFitStep
|
Issue JP-3594 was created on JIRA by Nadia Dencheva:
The text was updated successfully, but these errors were encountered: