kevin218 / Eureka

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

[Bug]: Error during stage 1: AttributeError: 'MetaClass' object has no attribute 'default_ramp_fit_weighting' #688

Closed Paulinappl closed 3 months ago

Paulinappl commented 3 months ago

FAQ check

Instrument

NIRSpec (Stages 1-3)

What happened?

I was running stage 1 for nrs2 data of WASP-39 with nirspec G395H and at the beginning of the run I got this error: AttributeError: 'MetaClass' object has no attribute 'default_ramp_fit_weighting'

I already fixed it adding to the end of the ecf file this:

default_ramp_fit_weighting          default             #Options are "default", "fixed", "interpolated", "flat", or "custom"
## Define the method by which individual frame pixels will be weighted during the default ramp fitting process.
## estos parametros de abajo se usan cuando no es default
default_ramp_fit_fixed_exponent     10                  #Only used for "fixed" weighting
default_ramp_fit_custom_snr_bounds  [5,10,20,50,100]    # Only used for "custom" weighting, array no spaces
default_ramp_fit_custom_exponents   [0.4,1,3,6,10]      # Only used for "custom" weighting, array no spacesDudas con:

But I wanted to raise this issue just in case the fix I made was wrong .

Error traceback output

Error log:

Traceback (most recent call last):
  File "/home/iaunam/Escritorio/Verano_2024/ECF_files_byme/run_eureka_wasp39_2.py", line 26, in <module>
    meta = s1.rampfitJWST(eventlabel, ecf_path=ecf_path)
  File "/home/iaunam/anaconda3/envs/eureka/lib/python3.9/site-packages/eureka/S1_detector_processing/s1_process.py", line 112, in rampfitJWST
    EurekaS1Pipeline().run_eurekaS1(filename, meta, log)
  File "/home/iaunam/anaconda3/envs/eureka/lib/python3.9/site-packages/eureka/S1_detector_processing/s1_process.py", line 220, in run_eurekaS1
    self.ramp_fit.weighting = meta.default_ramp_fit_weighting
AttributeError: 'MetaClass' object has no attribute 'default_ramp_fit_weighting'

Here is my stage 1 ecf file:

# ECF FILE PARA NRS2

suffix              uncal   ## sufijo del Stage 0 JWST dat,uncal.fits
maximum_cores       'half'  #Options are 'none', quarter', 'half', 'all' ## Fraction of processor cores to use when computing the jump step and the ramp fits.

#### lo que puedo probar es default o mean y ver que resultados obtengo:
ramp_fit_algorithm  'default'   #Options are 'default'or'mean' Control ramp fitting method
ramp_fit_max_cores  'half'      #la linea que le añadi en el primer bug al correr

# Pipeline stages 
## AL FINAL ESTA CADA FUNCIÓN: https://jwst-pipeline.readthedocs.io/en/latest/jwst/pipeline/calwebb_detector1.html

skip_group_scale    False ## rescales pixel values in raw JWST science data products to correct for instances where on-board frame averaging did not result in the proper downlinked values.
## cuando el numero de frames en un grupo no es una potencia de 2, la pipeline no hace bien el promedio de los frames, entonces se tiene que corregir: NFRAMES =! NDIVISORES (Estan en el header)
skip_dq_init        False ## The Data Quality (DQ) initialization step in the calibration pipeline populates the DQ mask for the input dataset. Flag values from the appropriate static mask (“MASK”) reference file in CRDS are copied into the “PIXELDQ” array of the input dataset, because it is assumed that flags in the mask reference file pertain to problem conditions that affect all groups and integrations for a given pixel.
## identifica y señala los pixeles que tienen "problemas" (ej: cosmic ray or saturated pixels) en un mask y los señala en los datos tambien
skip_saturation     False ##  step flags pixels at or below the A/D floor or above the saturation threshold. Pixels values are flagged as saturated if the pixel value is larger than the defined saturation threshold. Pixel values are flagged as below the A/D floor if they have a value of zero DN.
## idenifica a los pixeles saturados, con nans, y valores negativos o de 0
skip_ipc            True    #Skipped by default for all instruments
skip_superbias      False ## The superbias subtraction step removes the fixed detector bias from a science data set by subtracting a superbias reference image.
## le resta el superbias a los datos (superbias: the average or combined bias over many observations)
skip_refpix         False ## corrects this drift:the readout electronics imposes its own signal on top of this. In its simplest form, the amplifiers add a constant value to each pixel, and this constant value is different from amplifier to amplifier in a given group, and varies from group to group for a given amplifier.
## corrige el ruido ocasionado por los amplificadores y los demás electronicos para leer la señal.
skip_linearity      False ## The linearity step applies the “classic” linearity correction adapted from the HST WFC3/IR linearity correction routine, correcting science data values for detector non-linearity. The correction is applied pixel-by-pixel, group-by-group, integration-by-integration within a science exposure. The correction is represented by an nth-order polynomial for each pixel in the detector, with n+1 arrays of coefficients read from the linearity reference file.
## los pixeles no responden linealmente a la luz, este paso corrige esta respuesta NO uniforme del detector
skip_persistence    True    #Skipped by default for Near-IR TSO
skip_dark_current   False ## The dark current step removes dark current from an exposure by subtracting dark current data stored in a dark reference file in CRDS.
## se restan los darks a los datos, en el CRDS, segun  el handbook of astronomy la dark current es el ruido termico del detector
skip_jump           False ## This step finds and flags outliers (usually caused by cosmic-ray hits) in each pixel of an “up the ramp” IR exposure.
## flaggea los jumps en los ramps, cuando hay más de 3 grupos, para así remover los grupos donde hubo un brinco abrupto
skip_ramp_fitting   False ## This step determines the mean count rate, in units of counts per second, for each pixel by performing a linear fit to the “up the ramp” data in the input file. All fitting is done using the “ordinary least squares” (OLS) method. The fit is performed independently for each pixel. Bad values flagged via DQ flags are rejected from the fits.
##  obtiene las cuentas/tiempo de cada pixel en una imagen
skip_gain_scale     False ##  rescales pixel values in JWST countrate science data products in order to correct for the effect of using a non-standard detector gain setting. The countrate data are rescaled to make them appear as if they had been obtained using the standard gain setting. This currently only applies to NIRSpec exposures that are read out using a subarray pattern, in which case a gain setting of 2 is used instead of the standard setting of 1. Note that this only applies to NIRSpec subarray data obtained after April 2017, which is when the change was made in the instrument flight software to use gain=2. NIRSpec subarray data obtained previous to that time used the standard gain=1 setting.
## corrige para que la respuesta de los pixeles sea pareja

#Pipeline stages parameters

jump_rejection_threshold  7.0 #float, default is 4.0, CR sigma rejection threshold
## numero de desviaciones estadard de la media para que un pixel se considere que hubo jump
## we have found that values around 6.0–8.0 are often reasonable.
# Custom linearity reference file
custom_linearity    True
linearity_file      /home/iaunam/Escritorio/MAST_WASP_39/MAST_2024-07-11T03_29_25.373Z/JWST/jwst_nirspec_linearity_0023.fits

# Custom bias when using NIRSpec G395H --- Method applied to correct the superbias using a scale factor (SF) when no bias pixels are available (i.e., with NIRSpec). Here, SF = (median of group)/(median of superbias), using a background region that is expand_mask pixels from the measured trace. The default option None applies no correction; group_level computes SF for every integration in bias_group; smooth applies a smoothing filter of length bias_smooth_length to the group_level SF values; and mean uses the mean SF over all integrations. For NIRSpec, we currently recommend using smooth with a bias_smooth_length that is ~15 minutes.
custom_bias         True
superbias_file      /home/iaunam/Escritorio/MAST_WASP_39/MAST_2024-07-11T03_29_25.373Z/JWST/jwst_nirspec_superbias_0429.fits

##  For NIRSpec, we currently recommend using smooth with a bias_smooth_length that is ~15 minutes. (info del read the docs)
masktrace           True ## Boolean, creates a mask centered on the trace prior to GLBS for curved traces
bias_correction     smooth    # Bias correction options: [mean, group_level, smooth, None]
bias_group          1       # Group number options: [1, 2, ..., each] For NIRSpec, we currently recommend using the first group (bias_group = 1). 
bias_smooth_length  15     # Window length when using 'smooth' bias correction, ANTES ERA 201
######## deberia dejar en false a custom_bias?, yo creo que si a menos que haga el mio

# Saturation ## lo dejare el primero en false para probar el default
## si quiero probar pondré en true el primero

update_sat_flags    False   # Wheter to update the saturation flags more aggressively
expand_prev_group   False   # Expand saturation flags to previous group
dq_sat_mode         percentile # Options: [percentile, min, defined]
dq_sat_percentile   50      # Percentile of the entire time series to use to define the saturation mask (50=median)
dq_sat_columns      [[0, 0], [0,0], [0,0], [0,0], [0,0]]  #for dq_sat_mode = defined, user defined saturated columns

# Background subtraction

########  deberia estar en true??? y cuales parametros???
#### me parece que la figura es de 0 a 32 en y
grouplevel_bg       True
ncpu                6
bg_y1               6 ## The pixel number for the end of the bottom background region. The background region goes from the bottom of the subarray to this pixel.
bg_y2               27 ## The pixel number for the start of the top background region. The background region goes from this pixel to the top of the subarray.
bg_deg              1 ## Sets the degree of the column-by-column background subtraction. If bg_deg is negative, use the median background of entire frame. Set to None for no background subtraction. Also, best to emphasize that we’re performing column-by-column BG subtraction
p3thresh            7 ## Only important if bg_deg => 0 (see above). # sigma threshold for outlier rejection during background subtraction which corresponds to step 3 of optimal spectral extraction, as defined by Horne (1986).
######################################### añadi estas #################################################
bg_method           median  # Options: std (Standard Deviation), median (Median Absolute Deviation), mean (Mean Absolute Deviation)
bg_row_by_row       False   # Row-by-row BG subtraction (only useful for NIRCam)
bg_x1               None    # Left edge of exclusion region for row-by-row BG subtraction
bg_x2               None    # Right edge of exclusion region for row-by-row BG subtraction
########################################################################################################

##  probare estos parametros primero
verbose             True ## If True, more details will be printed about steps.
isplots_S1          3 ## Sets how many plots should be saved when running Stage 1. A full description of these outputs is available here: Stage 3 Output
nplots              5 ## Sets how many integrations will be used for per-integration figures (Figs 3301, 3302, 3303, 3307, 3501, 3505). Useful for in-depth diagnoses of a few integrations without making thousands of figures. If set to None, a plot will be made for every integration.
hide_plots          True ## If True, plots will automatically be closed rather than popping up on the screen.

# Mask curved traces: hacer una mascara al rededor del espectro
# movi masktrace antes de bias
window_len          11   ## Smoothing length for the trace location
## means that each point in the smoothed trace is the average of 5 points on either side of the central point.
expand_mask         8    ## Aperture (in pixels) around the trace to mask
## pixeles incluidos ademas del trace
ignore_low          5  ## Columns below this index will not be used to create the mask
## se toman las columnas a partir de la 600
ignore_hi           1950 ## Columns above this index will not be used to create the mask
## se toman las columnas hasta none, entonces supongo que hasta donde termina el array

# Manual reference pixel correction for NIRSpec PRISM 
refpix_corr         False ## Boolean, runs a custom ROEBA (Row-by-row, Odd-Even By Amplifier) routine for PRISM observations which do not have reference pixels within the subarray.
npix_top            8
npix_bot            8

topdir              /home/iaunam/1st_trial_eureka/ ## The path to the directory containing the Stage 0 JWST data (uncal.fits). Directories containing spaces should be enclosed in quotation marks.
inputdir            1st_try_MAST_WASP39_nrs2 ## same as tobdir
outputdir           Stage1nrs2

# Diagnostics
testing_S1          False  ## If True, only a single file will be used, outputs won’t be saved, and plots won’t be made. Useful for making sure most of the code can run.

# "Default" ramp fitting settings

default_ramp_fit_weighting          default             #Options are "default", "fixed", "interpolated", "flat", or "custom"
## Define the method by which individual frame pixels will be weighted during the default ramp fitting process.

## estos parametros de abajo se usan cuando no es default
default_ramp_fit_fixed_exponent     10                  #Only used for "fixed" weighting
default_ramp_fit_custom_snr_bounds  [5,10,20,50,100]    # Only used for "custom" weighting, array no spaces
default_ramp_fit_custom_exponents   [0.4,1,3,6,10]      # Only used for "custom" weighting, array no spacesDudas con:

What operating system are you using?

Ubuntu 18.04.6 LTS

What version of Python are you running?

Python 3.9.7

What Python packages do you have installed?

# packages in environment at /home/iaunam/anaconda3/envs/eureka:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
alabaster                 0.7.16                   pypi_0    pypi
asciitree                 0.3.3                    pypi_0    pypi
asdf                      3.2.0                    pypi_0    pypi
asdf-astropy              0.6.1                    pypi_0    pypi
asdf-coordinates-schemas  0.3.0                    pypi_0    pypi
asdf-standard             1.1.1                    pypi_0    pypi
asdf-transform-schemas    0.5.0                    pypi_0    pypi
asdf-wcs-schemas          0.4.0                    pypi_0    pypi
asteval                   1.0.0                    pypi_0    pypi
astraeus                  0.3                      pypi_0    pypi
astropy                   6.0.1                    pypi_0    pypi
astropy-healpix           1.0.3                    pypi_0    pypi
astropy-iers-data         0.2024.7.8.0.31.19          pypi_0    pypi
astroquery                0.4.7                    pypi_0    pypi
astroscrappy              1.2.0                    pypi_0    pypi
asttokens                 2.4.1                    pypi_0    pypi
attrs                     23.2.0                   pypi_0    pypi
babel                     2.15.0                   pypi_0    pypi
backports-tarfile         1.2.0                    pypi_0    pypi
batman-package            2.4.9                    pypi_0    pypi
bayesicfitting            3.2.1                    pypi_0    pypi
beautifulsoup4            4.12.3                   pypi_0    pypi
bokeh                     2.4.3                    pypi_0    pypi
bottleneck                1.4.0                    pypi_0    pypi
ca-certificates           2024.7.2             h06a4308_0  
ccdproc                   2.4.2                    pypi_0    pypi
celerite                  0.4.3                    pypi_0    pypi
certifi                   2024.7.4                 pypi_0    pypi
cffi                      1.16.0                   pypi_0    pypi
cftime                    1.6.4                    pypi_0    pypi
charset-normalizer        3.3.2                    pypi_0    pypi
click                     8.1.7                    pypi_0    pypi
cloudpickle               3.0.0                    pypi_0    pypi
contourpy                 1.2.1                    pypi_0    pypi
corner                    2.2.2                    pypi_0    pypi
crds                      11.17.26                 pypi_0    pypi
cryptography              42.0.8                   pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
dask                      2024.7.0                 pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
dill                      0.3.8                    pypi_0    pypi
docutils                  0.21.2                   pypi_0    pypi
drizzle                   1.15.1                   pypi_0    pypi
dynesty                   2.1.4                    pypi_0    pypi
emcee                     3.1.6                    pypi_0    pypi
eureka                    0.10                     pypi_0    pypi
exceptiongroup            1.2.1                    pypi_0    pypi
executing                 2.0.1                    pypi_0    pypi
exotic-ld                 3.2.0                    pypi_0    pypi
fasteners                 0.19                     pypi_0    pypi
filelock                  3.15.4                   pypi_0    pypi
fonttools                 4.53.1                   pypi_0    pypi
fsspec                    2024.6.1                 pypi_0    pypi
future                    1.0.0                    pypi_0    pypi
george                    0.4.2                    pypi_0    pypi
gwcs                      0.21.0                   pypi_0    pypi
h5netcdf                  1.3.0                    pypi_0    pypi
h5py                      3.11.0                   pypi_0    pypi
html5lib                  1.1                      pypi_0    pypi
idna                      3.7                      pypi_0    pypi
imageio                   2.34.2                   pypi_0    pypi
imagesize                 1.4.1                    pypi_0    pypi
importlib-metadata        8.0.0                    pypi_0    pypi
importlib-resources       6.4.0                    pypi_0    pypi
iniconfig                 2.0.0                    pypi_0    pypi
intel-openmp              2021.4.0          h06a4308_3561  
ipython                   8.18.1                   pypi_0    pypi
jaraco-classes            3.4.0                    pypi_0    pypi
jaraco-context            5.3.0                    pypi_0    pypi
jaraco-functools          4.0.1                    pypi_0    pypi
jedi                      0.19.1                   pypi_0    pypi
jeepney                   0.8.0                    pypi_0    pypi
jinja2                    3.1.4                    pypi_0    pypi
jmespath                  1.0.1                    pypi_0    pypi
jsonschema                4.23.0                   pypi_0    pypi
jsonschema-specifications 2023.12.1                pypi_0    pypi
jwst                      1.11.4                   pypi_0    pypi
keyring                   25.2.1                   pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
lazy-loader               0.4                      pypi_0    pypi
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
lmfit                     1.3.1                    pypi_0    pypi
locket                    1.0.0                    pypi_0    pypi
markupsafe                2.1.5                    pypi_0    pypi
matplotlib                3.9.1                    pypi_0    pypi
matplotlib-inline         0.1.7                    pypi_0    pypi
mkl                       2021.4.0           h06a4308_640  
mkl-service               2.4.0            py39h7f8727e_0  
more-itertools            10.3.0                   pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
netcdf4                   1.7.1.post1              pypi_0    pypi
networkx                  3.2.1                    pypi_0    pypi
numcodecs                 0.12.1                   pypi_0    pypi
numpy                     1.24.4                   pypi_0    pypi
numpydoc                  1.7.0                    pypi_0    pypi
opencv-python-headless    4.10.0.84                pypi_0    pypi
openssl                   1.1.1w               h7f8727e_0  
packaging                 24.1                     pypi_0    pypi
pandas                    2.2.2                    pypi_0    pypi
parsley                   1.3                      pypi_0    pypi
parso                     0.8.4                    pypi_0    pypi
partd                     1.4.2                    pypi_0    pypi
pexpect                   4.9.0                    pypi_0    pypi
photutils                 1.11.0                   pypi_0    pypi
pillow                    10.4.0                   pypi_0    pypi
pip                       24.0             py39h06a4308_0  
pluggy                    1.5.0                    pypi_0    pypi
poppy                     1.1.1                    pypi_0    pypi
prompt-toolkit            3.0.47                   pypi_0    pypi
psutil                    6.0.0                    pypi_0    pypi
ptyprocess                0.7.0                    pypi_0    pypi
pure-eval                 0.2.2                    pypi_0    pypi
pycparser                 2.22                     pypi_0    pypi
pyerfa                    2.0.1.4                  pypi_0    pypi
pygments                  2.18.0                   pypi_0    pypi
pyparsing                 3.1.2                    pypi_0    pypi
pysynphot                 2.0.0                    pypi_0    pypi
pytest                    8.2.2                    pypi_0    pypi
python                    3.9.7                h12debd9_1  
python-dateutil           2.9.0.post0              pypi_0    pypi
pytz                      2024.1                   pypi_0    pypi
pyvo                      1.5.2                    pypi_0    pypi
pyyaml                    6.0.1                    pypi_0    pypi
readline                  8.2                  h5eee18b_0  
referencing               0.35.1                   pypi_0    pypi
reproject                 0.13.0                   pypi_0    pypi
requests                  2.32.3                   pypi_0    pypi
rpds-py                   0.19.0                   pypi_0    pypi
scikit-image              0.24.0                   pypi_0    pypi
scipy                     1.9.3                    pypi_0    pypi
secretstorage             3.3.3                    pypi_0    pypi
semantic-version          2.10.0                   pypi_0    pypi
setuptools                69.5.1           py39h06a4308_0  
setuptools-scm            8.1.0                    pypi_0    pypi
six                       1.16.0             pyhd3eb1b0_1  
snowballstemmer           2.2.0                    pypi_0    pypi
soupsieve                 2.5                      pypi_0    pypi
spherical-geometry        1.3.2                    pypi_0    pypi
sphinx                    7.3.7                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.8                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.6                    pypi_0    pypi
sphinxcontrib-htmlhelp    2.0.5                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.7                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.10                   pypi_0    pypi
sqlite                    3.45.3               h5eee18b_0  
stack-data                0.6.3                    pypi_0    pypi
stcal                     1.4.4                    pypi_0    pypi
stdatamodels              1.7.2                    pypi_0    pypi
stpipe                    0.5.1                    pypi_0    pypi
stsci-image               2.3.9                    pypi_0    pypi
stsci-imagestats          1.8.3                    pypi_0    pypi
stsci-stimage             0.2.9                    pypi_0    pypi
svo-filters               0.4.4                    pypi_0    pypi
tabulate                  0.9.0                    pypi_0    pypi
tifffile                  2024.7.2                 pypi_0    pypi
tk                        8.6.14               h39e8969_0  
tomli                     2.0.1                    pypi_0    pypi
toolz                     0.12.1                   pypi_0    pypi
tornado                   6.4.1                    pypi_0    pypi
tqdm                      4.66.4                   pypi_0    pypi
traitlets                 5.14.3                   pypi_0    pypi
tweakwcs                  0.8.7                    pypi_0    pypi
typing-extensions         4.12.2                   pypi_0    pypi
tzdata                    2024.1                   pypi_0    pypi
uncertainties             3.2.2                    pypi_0    pypi
urllib3                   2.2.2                    pypi_0    pypi
wcwidth                   0.2.13                   pypi_0    pypi
webencodings              0.5.1                    pypi_0    pypi
wheel                     0.43.0           py39h06a4308_0  
wiimatch                  0.3.2                    pypi_0    pypi
xarray                    2024.6.0                 pypi_0    pypi
xz                        5.4.6                h5eee18b_1  
zarr                      2.18.2                   pypi_0    pypi
zipp                      3.19.2                   pypi_0    pypi
zlib                      1.2.13               h5eee18b_1 

Code of Conduct

taylorbell57 commented 3 months ago

As I'd mentioned in an earlier issue, you need to make sure you're looking at the templates for the Eureka! version you're running. We're in the process of making lots of backwards compatibility breaking changes in preparation for version 1.0 (which should make things better/easier for everyone), but in and around the time that we're making these transitions it is super important that everyone uses the templates based on their installed Eureka! version. Since you're using v0.10, you'll want to look at the templates at https://github.com/kevin218/Eureka/tree/v0.10/demos/JWST

Paulinappl commented 3 months ago

Thank you Taylor!

I couldn't find previously on the link (https://github.com/kevin218/Eureka/tree/v0.10/demos/JWST) a stage 1 NIRSpec ecf demo file, the only ones available are: S1_miri_template.ecf and S1_nirx_template.ecf for stage 1.

Should I base my ecf file of stage 1 NIRSpec ecf file in one of those two files in the demo folder?

taylorbell57 commented 3 months ago

The nirx template is meant to be used for NIRCam and NIRSpec (and eventually NIRISS, although we don't yet support NIRISS)

Paulinappl commented 2 months ago

Got it!, thank you so much :)

kevin218 commented 2 months ago

Sure thing. This is one of life's little mysteries, like why is abbreviation such a long word? 🤷‍♂️