kevin218 / Eureka

Eureka! is a data reduction and analysis pipeline intended for time-series observations with JWST.
https://eurekadocs.readthedocs.io/
MIT License
56 stars 44 forks source link

[Bug]: Stripes visible in Stage3 with NIRSpec G395 data #607

Closed educrot22 closed 5 months ago

educrot22 commented 5 months ago

FAQ check

Instrument

NIRSpec (Stages 1-3)

What happened?

I tried to reduce NIRSPec G935 data for the first time (K2-18 b (GO 2722) nrs1 and nrs2).

For nrs1 I started from the calints.fits images directly. On the images I can see that the trace is curved and that the images are cropped (see image1 attached). In the Stage 3 .ecf file (pasted at the end of the issue) I set curvature to "correct" and try to select xwindow and ywindow such that the cropped pixel lines are not included (image 2 attached). As a result of stage 3 I can see wide stripes in the 2-dimensional, non-drift-corrected light curve (image 3 attached). I have tried changing all the sigma thresholds values but this does not seem to help.

With nrs2 I have exactly the same problem but even more pronounced as the trace is even more curved and it very hard to find a set of xwindow and ywindow that includes all of it (see image 4).

I am sure there is something I'm missing here as this is my first time dealing with NIRSpec data, but I was wondering if anyone else ever encountered this issue ?

Thank you very much,

ps: strangely I cannot unzip the folder when I try downloading theuncal.fits images from MAST so I can't start from Stage1.

Stage 3 .ecf file:

# Eureka! Control File for Stage 3: Data Reduction

# Stage 3 Documentation: https://eurekadocs.readthedocs.io/en/latest/ecf.html#stage-3

ncpu            6           # Number of CPUs
nfiles          2           # The number of data files to analyze simultaneously
max_memory      0.5         # The maximum fraction of memory you want utilized by read-in frames (this will reduce nfiles if need be)
indep_batches   False       # Independently treat each batch of files? Strongly recommended to leave this as False unless you have a clear reason to set it to True.
suffix          calints     # Data file suffix

calibrated_spectra  False   # Set True to generate flux-calibrated spectra/photometry in mJy
                            # Set False to convert to electrons

# Subarray region of interest
ywindow         [5,25]      # Vertical axis as seen in DS9
xwindow         [60,1000]   #nrs1 60,1200 # Horizontal axis as seen in DS9
src_pos_type    gaussian    # Determine source position when not given in header (Options: header, gaussian, weighted, max, or hst)
record_ypos     True        # Option to record the y position and width for each integration (only records if src_pos_type is gaussian)
dqmask          True        # Mask pixels with an odd entry in the DQ array
expand          1           # Super-sampling factor along cross-dispersion direction

# Outlier rejection along time axis
ff_outlier      False       # Set False to use only background region (recommended for deep transits)
                            # Set True to use full frame (works well for shallow transits/eclipses)
bg_thresh       [5,5]       # Double-iteration X-sigma threshold for outlier rejection along time axis

# Background parameters
bg_hw           6          # Half-width of exclusion region for BG subtraction (relative to source position)
bg_deg          0          # Polynomial order for column-by-column background subtraction, -1 for median of entire frame
p3thresh        7          # X-sigma threshold for outlier rejection during background subtraction

# Spectral extraction parameters
spec_hw         4           # Half-width of aperture region for spectral extraction (relative to source position)
fittype         meddata      # Method for constructing spatial profile (Options: smooth, meddata, poly, gauss, wavelet, or wavelet2D)
median_thresh   5           # Sigma threshold when flagging outliers in median frame, when fittype=meddata and window_len > 1
window_len      13          # Smoothing window length, for median frame or when fittype = smooth or meddata (when computing median frame). Can set to 1 for no smoothing when computing median frame for fittype=meddata.
prof_deg        3           # Polynomial degree, when fittype = poly
p5thresh        10          # X-sigma threshold for outlier rejection while constructing spatial profile
p7thresh        60          # X-sigma threshold for outlier rejection during optimal spectral extraction

# G395H curvature treatment
curvature       correct        # How to manage the curved trace on the detector (Options: None, correct). Use correct for NIRSpec/G395.

# Diagnostics
isplots_S3      3           # Generate few (1), some (3), or many (5) figures (Options: 1 - 5)
nplots          5           # How many of each type of figure do you want to make per file?
vmin            0.97        # Sets the vmin of the color bar for Figure 3101.
vmax            1.03        # Sets the vmax of the color bar for Figure 3101.
time_axis       'y'         # Determines whether the time axis in Figure 3101 is along the y-axis ('y') or the x-axis ('x')
testing_S3      False       # Boolean, set True to only use last file and generate select figures
hide_plots      False       # If True, plots will automatically be closed rather than popping up
save_output     True        # Save outputs for use in S4
verbose         True        # If True, more details will be printed about steps

# Project directory
topdir          /home/localuser/Documents/Internship/User/DataAnalysis/JWST/K2-18b/data_nrs1/

# Directories relative to topdir
inputdir        Stage2  # The folder containing the outputs from Eureka!'s S2 or JWST's S2 pipeline (will be overwritten if calling S2 and S3 sequentially)
outputdir       Stage3

image1 image2 image3 image4

Error traceback output

No response

What operating system are you using?

Mac OS Big Sus

What version of Python are you running?

python3.9.7

What Python packages do you have installed?

No response

Code of Conduct

taylorbell57 commented 5 months ago

@educrot22, I'm not much of a NIRSpec G395H expert at this time, but it seems to me that the changes under consideration in PR #599 might resolve your issue. If you want to make quick progress before we can get that PR merged, you could experiment with that tweak and see if it resolves your issue

educrot22 commented 5 months ago

Hi Taylor,

Thank you very much for your answer. My issue was actually simply solved when I started from the uncal.fits files and re-ran Stage 1 and 2 through Eureka! with the setups for NIRSpec (usinf the nirx.ecf control files).

However, I then encountered the waterfall effect issue that you mentioned and the solution from issue #599 worked for me!

In the end the 2-D spectrum looks way better: fig3102-2D_LC

Thanks again!

taylorbell57 commented 5 months ago

Hi Elsa, really glad to hear you got this sorted out! Yeah, starting from scratch with the _uncal files is almost always the best choice. And good to know that the pending PR resolved an issue for you as well - hopefully we can get that merged sooner than later!