Skip to content

Test of the True/False values in the grid when it is adapted to the data #10

@SimonPetrusPro

Description

@SimonPetrusPro

In adapt_grid.py, I have noted some issues with the line:

if len(np.where(nan_mod_ind is False)[0]) == 0:

I am using a new grid (6 parameters) and I got this error:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-> To compare synthetic spectra with the observation we need to manage them. The following actions are performed:
- extraction -
- resizing on the observation's wavelength range -
- adjustement of the spectral resolution -
- substraction of the continuum (if needed) -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-> Sarting the adaptation of test_data
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniforge3/envs/env_formosa/lib/python3.13/site-packages/spyder_kernels/customize/utils.py:209, in exec_encapsulate_locals(code_ast, globals, locals, exec_fun, filename)
    207     if filename is None:
    208         filename = "<stdin>"
--> 209     exec_fun(compile(code_ast, filename, "exec"), globals, None)
    210 finally:
    211     if use_locals_hack:
    212         # Cleanup code

File ~/Documents/HWO_paper/test_formosa/fit_loops.py:40
     36 adapt_yn = 'no'
     38 global_params = GlobFile(path_config)
---> 40 launch_adapt(global_params, justobs=adapt_yn)
     42 launch_nested_sampling(global_params)
     45 plotForMoSA = PlottingForMoSA(path_config, 'magenta')

File ~/Documents/HWO_paper/formosaic/ForMoSA/ForMoSA/adapt/adapt_obs_mod.py:145, in launch_adapt(global_params, justobs)
    142 print('- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -')
    143 print(f"-> Sarting the adaptation of {obs_name}")
--> 145 adapt_grid(global_params, obs_spectro_merge[0], obs_photo[0], res_mod_obs_merge, obs_name=obs_name, indobs=indobs)

File ~/Documents/HWO_paper/formosaic/ForMoSA/ForMoSA/adapt/adapt_grid.py:113, in adapt_grid(global_params, wav_obs_spectro, wav_obs_photo, res_mod_obs_merge, obs_name, indobs)
    111 model_to_adapt = grid_np[:, p1_i, p2_i, p3_i, p4_i, p5_i, p6_i]
    112 nan_mod_ind = ~np.isnan(model_to_adapt)
--> 113 print(len(np.where(nan_mod_ind is False)[0]))
    114 import sys
    115 sys.exit()

ValueError: Calling nonzero on 0d arrays is not allowed. Use np.atleast_1d(scalar).nonzero() instead. If the context of this error is of the form `arr[nonzero(cond)]`, just use `arr[cond]`.

Apparently, when I replace the "is" by "==" the error is corrected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions