lime-stable 2.0.dev6__tar.gz → 2.0.dev8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {lime_stable-2.0.dev6/src/lime_stable.egg-info → lime_stable-2.0.dev8}/PKG-INFO +1 -1
  2. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/pyproject.toml +1 -1
  3. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/archives/read_fits.py +44 -38
  4. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/fitting/lines.py +2 -15
  5. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/io.py +4 -1
  6. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/lime.toml +1 -1
  7. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/observations.py +12 -5
  8. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/bokeh_plots.py +11 -2
  9. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/plots.py +9 -45
  10. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/plots_interactive.py +1 -1
  11. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/utils.py +5 -5
  12. lime_stable-2.0.dev8/src/lime/retrieve/line_bands.py +226 -0
  13. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/transitions.py +67 -60
  14. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/workflow.py +9 -300
  15. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8/src/lime_stable.egg-info}/PKG-INFO +1 -1
  16. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime_stable.egg-info/SOURCES.txt +1 -0
  17. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_model.py +1 -1
  18. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_read_fits.py +33 -0
  19. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_spectrum.py +13 -6
  20. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_tools.py +4 -4
  21. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/LICENSE.rst +0 -0
  22. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/MANIFEST.in +0 -0
  23. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/README.rst +0 -0
  24. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/setup.cfg +0 -0
  25. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/__init__.py +0 -0
  26. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/archives/__init__.py +0 -0
  27. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/archives/tables.py +0 -0
  28. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/changelog.txt +0 -0
  29. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/fitting/__init__.py +0 -0
  30. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/fitting/redshift.py +0 -0
  31. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/inference/detection.py +0 -0
  32. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/inference/intensity_threshold.py +0 -0
  33. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/__init__.py +0 -0
  34. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/format.py +0 -0
  35. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/plotting/theme_lime.toml +0 -0
  36. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/resources/__init__.py +0 -0
  37. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/resources/lines_database_formatting.py +0 -0
  38. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/resources/lines_database_v2.0.0.txt +0 -0
  39. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/resources/logo.py +0 -0
  40. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/resources/types_params.txt +0 -0
  41. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/retrieve/__init__.py +0 -0
  42. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/retrieve/peaks.py +0 -0
  43. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime/tools.py +0 -0
  44. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime_stable.egg-info/dependency_links.txt +0 -0
  45. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime_stable.egg-info/requires.txt +0 -0
  46. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/src/lime_stable.egg-info/top_level.txt +0 -0
  47. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_astro.py +0 -0
  48. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_cube.py +0 -0
  49. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_io.py +0 -0
  50. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_line.py +0 -0
  51. {lime_stable-2.0.dev6 → lime_stable-2.0.dev8}/tests/test_sample.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lime-stable
3
- Version: 2.0.dev6
3
+ Version: 2.0.dev8
4
4
  Summary: Line measuring algorithm for astronomical spectra
5
5
  Author-email: Vital Fernández <vgf@umich.edu>
6
6
  License-Expression: GPL-3.0-or-later
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "lime-stable"
7
- version = "2.0.dev6"
7
+ version = "2.0.dev8"
8
8
  readme = "README.rst"
9
9
  requires-python = ">=3.11"
10
10
  license = "GPL-3.0-or-later"
@@ -257,35 +257,44 @@ def check_fits_instructions(fits_source, online_provider=False):
257
257
  else:
258
258
  fits_reader = None
259
259
 
260
- # # Check for url location for surveys function
261
- # if online_provider:
262
- # if hasattr(UrlFitsSurvey, fits_source):
263
- # url_locator = getattr(UrlFitsSurvey, fits_source)
264
- # else:
265
- # raise LiMe_Error(f'Input {fits_source} does not have a url manager for LiMe could not be created.')
266
- # else:
267
- # url_locator = None
268
-
269
260
  return fits_reader
270
261
 
271
- def load_txt(text_address):
262
+ def load_txt(text_address, **kwargs):
272
263
 
273
264
  # Columns
274
- out_array = np.loadtxt(text_address)
265
+ out_array = np.loadtxt(text_address, **kwargs)
275
266
 
276
- # Transform foot comments as dictionary data
277
- params_dict = {}
278
- with open(text_address, "r") as f:
267
+ # File address
268
+ if not type(text_address).__name__ == "UploadedFile":
269
+ with open(text_address, "r") as f:
270
+ lines = f.readlines()
279
271
 
280
- # Reverse loop while the lines start by a "#"
281
- for line in reversed(f.readlines()):
282
- line = line.strip()
283
- if not line.startswith("#") or (line.startswith("# LiMe")):
284
- break
272
+ # Uploaded file
273
+ else:
274
+ lines = text_address.getvalue().decode("utf-8").splitlines()
285
275
 
286
- # Extract key-value pairs
287
- key, value = line[1:].split(":", 1) # Split at the first ':'
288
- params_dict[key.strip()] = value.strip()
276
+ # Reverse loop over the lines
277
+ params_dict = {}
278
+ for line in reversed(lines):
279
+ line = line.strip()
280
+ if not line.startswith("#") or line.startswith("# LiMe"):
281
+ break
282
+ key, value = line[1:].split(":", 1)
283
+ params_dict[key.strip()] = value.strip()
284
+
285
+ # # Transform foot comments as dictionary data
286
+ # params_dict = {}
287
+ # with open(text_address, "r") as f:
288
+ #
289
+ # # Reverse loop while the lines start by a "#"
290
+ # for line in reversed(f.readlines()):
291
+ # line = line.strip()
292
+ # if not line.startswith("#") or (line.startswith("# LiMe")):
293
+ # break
294
+ #
295
+ # # Extract key-value pairs
296
+ # key, value = line[1:].split(":", 1) # Split at the first ':'
297
+ # params_dict[key.strip()] = value.strip()
289
298
 
290
299
  return out_array, params_dict
291
300
 
@@ -362,10 +371,10 @@ class OpenFits:
362
371
 
363
372
  return
364
373
 
365
- def parse_data_from_file(self, file_address, pixel_mask=None):
374
+ def parse_data_from_file(self, file_address, pixel_mask, **kwargs):
366
375
 
367
376
  # Read the fits data
368
- wave_array, flux_array, err_array, header_list, fits_params = self.fits_reader(file_address)
377
+ wave_array, flux_array, err_array, header_list, fits_params = self.fits_reader(file_address, **kwargs)
369
378
  pixel_mask = pixel_mask if pixel_mask is not None else fits_params['pixel_mask']
370
379
 
371
380
  # Mask requested entries
@@ -441,10 +450,10 @@ class OpenFits:
441
450
  return fits_args
442
451
 
443
452
  @staticmethod
444
- def text(file_address):
453
+ def text(file_address, **kwargs):
445
454
 
446
455
  # Read text file dividing the columns into the spectrum axis and the comments as its parameters
447
- data_arr, params_dict = load_txt(file_address)
456
+ data_arr, params_dict = load_txt(file_address, **kwargs)
448
457
 
449
458
  # Unpack the columns into the spectrum axes
450
459
  wave_array, flux_array = data_arr[:, 0], data_arr[:, 1]
@@ -456,16 +465,13 @@ class OpenFits:
456
465
  # Convert strings to expected format
457
466
  params_dict['redshift'] = float(params_dict['redshift']) if 'redshift' in params_dict else None
458
467
  params_dict['norm_flux'] = float(params_dict['norm_flux']) if 'norm_flux' in params_dict else None
459
- params_dict['id_label'] = params_dict['id_label'] if 'norm_flux' in params_dict else None
468
+ params_dict['id_label'] = params_dict['id_label'] if 'id_label' in params_dict else None
460
469
  params_dict['pixel_mask'] = mask_array
461
470
 
462
- # metadata['units_wave'] = au.Unit(metadata['units_wave']) if 'units_wave' in metadata else au.Unit('AA')
463
- # metadata['units_flux'] = au.Unit(metadata['units_flux']) if 'units_flux' in metadata else au.Unit('FLAM')
464
-
465
471
  return wave_array, flux_array, err_array, None, params_dict
466
472
 
467
473
  @staticmethod
468
- def nirspec(fits_address, data_ext_list=1, hdr_ext_list=(0, 1), pixel_mask=None):
474
+ def nirspec(fits_address, data_ext_list=1, hdr_ext_list=(0, 1), **kwargs):
469
475
 
470
476
  """
471
477
 
@@ -503,7 +509,7 @@ class OpenFits:
503
509
  return wave_array, flux_array, err_array, header_list, params_dict
504
510
 
505
511
  @staticmethod
506
- def isis(fits_address, data_ext_list=0, hdr_ext_list=0, pixel_mask=None):
512
+ def isis(fits_address, data_ext_list=0, hdr_ext_list=0, **kwargs):
507
513
 
508
514
  """
509
515
 
@@ -548,7 +554,7 @@ class OpenFits:
548
554
  return wave_array, flux_array, err_array, header_list, params_dict
549
555
 
550
556
  @staticmethod
551
- def osiris(fits_address, data_ext_list=0, hdr_ext_list=0, pixel_mask=None):
557
+ def osiris(fits_address, data_ext_list=0, hdr_ext_list=0, **kwargs):
552
558
 
553
559
  """
554
560
 
@@ -593,7 +599,7 @@ class OpenFits:
593
599
  return wave_array, flux_array, err_array, header_list, params_dict
594
600
 
595
601
  @staticmethod
596
- def sdss(fits_address, data_ext_list=(1, 2), hdr_ext_list=(0), pixel_mask=None):
602
+ def sdss(fits_address, data_ext_list=(1, 2), hdr_ext_list=(0), **kwargs):
597
603
 
598
604
  """
599
605
 
@@ -645,7 +651,7 @@ class OpenFits:
645
651
  return wave_array, flux_array, err_array, header_list, params_dict
646
652
 
647
653
  @staticmethod
648
- def manga(fits_address, data_ext_list=('WAVE', 'FLUX', 'IVAR'), hdr_ext_list=('FLUX'), pixel_mask=None):
654
+ def manga(fits_address, data_ext_list=('WAVE', 'FLUX', 'IVAR'), hdr_ext_list=('FLUX'), **kwargs):
649
655
 
650
656
  """
651
657
 
@@ -692,7 +698,7 @@ class OpenFits:
692
698
  return wave_array, flux_cube, err_cube, header_list, fits_params
693
699
 
694
700
  @staticmethod
695
- def muse(fits_address, data_ext_list=(1, 2), hdr_ext_list=1, pixel_mask=None):
701
+ def muse(fits_address, data_ext_list=(1, 2), hdr_ext_list=1, **kwargs):
696
702
 
697
703
  """
698
704
 
@@ -737,7 +743,7 @@ class OpenFits:
737
743
  return wave_array, flux_cube, err_cube, header_list, fits_params
738
744
 
739
745
  @staticmethod
740
- def megara(fits_address, data_ext_list=0, hdr_ext_list=(0, 1), pixel_mask=None):
746
+ def megara(fits_address, data_ext_list=0, hdr_ext_list=(0, 1), **kwargs):
741
747
 
742
748
  """
743
749
 
@@ -781,7 +787,7 @@ class OpenFits:
781
787
  return wave_array, flux_cube, err_cube, header_list, fits_params
782
788
 
783
789
  @staticmethod
784
- def miri(fits_address, data_ext_list=(1,2), hdr_ext_list=(1), pixel_mask=None):
790
+ def miri(fits_address, data_ext_list=(1,2), hdr_ext_list=(1), **kwargs):
785
791
 
786
792
  """
787
793
 
@@ -608,7 +608,6 @@ class ProfileModelCompiler:
608
608
  line.eqw = np.full(self.n_comps, np.nan)
609
609
  line.eqw_err = np.full(self.n_comps, np.nan)
610
610
  line.FWHM_p = np.full(self.n_comps, np.nan)
611
- # line.sigma_thermal = np.full(self.n_comps, np.nan)
612
611
 
613
612
  # Check for negative -0.0 # TODO this needs a better place # FIXME -0.0 error
614
613
  if np.signbit(line.sigma_err[i]):
@@ -825,12 +824,6 @@ class LineFitting:
825
824
  line.intg_flux = areasArray.mean()
826
825
  line.intg_flux_err = areasArray.std()
827
826
 
828
- # # Compute the integrated signal to noise # TODO is this an issue for absorptions
829
- # amp_ref = line.peak_flux - line.cont
830
- # if emission_check:
831
- # if amp_ref < 0:
832
- # amp_ref = line.peak_flux
833
-
834
827
  # Compute SN_r
835
828
  line.snr_line = signal_to_noise_rola(line.peak_flux - line.cont, line.cont_err, line.n_pixels)
836
829
  line.snr_cont = line.cont/line.cont_err
@@ -842,20 +835,14 @@ class LineFitting:
842
835
  else:
843
836
  line._narrow_check = False
844
837
 
845
- # # Line width to the pixel below the continuum (or mask size if not happening) # TODO Lime2.0 skip all this if narrow
846
- # idx_0 = compute_FWHM0(peakIdx, emis_flux, -1, cont_arr, emission_check)
847
- # idx_f = compute_FWHM0(peakIdx, emis_flux, 1, cont_arr, emission_check)
848
- #
849
- # # Velocity calculations
850
- # velocArray = c_KMpS * (emis_wave[idx_0:idx_f] - line.peak_wave) / line.peak_wave
851
- # self.velocity_profile_calc(line, velocArray, emis_flux[idx_0:idx_f], cont_arr[idx_0:idx_f], emission_check)
838
+ # Velocity calculations
852
839
  if (line.n_pixels >= min_array_dim) and (line._narrow_check is False):
853
840
  self.velocity_profile_calc(line, peakIdx, emis_wave, emis_flux, cont_arr, emission_check, min_array_dim=min_array_dim)
854
841
 
855
842
  # Pixel velocity # TODO we are not using this one
856
843
  line.pixel_vel = c_KMpS * line.pixelWidth/line.peak_wave
857
844
 
858
- # Equivalent width computation (it must be an 1d array to avoid conflict in blended lines) # TODO Lime2.0 put all this on its function
845
+ # Equivalent width computation (it must be an 1d array to avoid conflict in blended lines)
859
846
  lineContinuumMatrix = cont_arr + normalNoise
860
847
  eqwMatrix = areasArray / lineContinuumMatrix.mean(axis=1)
861
848
 
@@ -569,10 +569,13 @@ def results_to_log(line, log, norm_flux):
569
569
 
570
570
  # Converting None entries to str (9 = group_label)
571
571
  if j == 9:
572
+
572
573
  if param_value is None:
573
574
  param_value = 'none'
574
575
 
575
- # print(comp, param, param_value)
576
+ if line.sub_comps[i] is not None:
577
+ param_value = line.sub_comps[i].group_label
578
+
576
579
  log.at[comp, param] = param_value
577
580
 
578
581
  return
@@ -1,3 +1,3 @@
1
1
  [metadata]
2
2
  name = 'lime-stable'
3
- version = "2.0.dev6"
3
+ version = "2.0.dev8"
@@ -411,7 +411,8 @@ class Spectrum:
411
411
  return spec
412
412
 
413
413
  @classmethod
414
- def from_file(cls, file_address, instrument, mask_flux_entries=None, **kwargs):
414
+ def from_file(cls, file_address, instrument, redshift=None, norm_flux=None, crop_waves=None, res_power=None,
415
+ units_wave=None, units_flux=None, pixel_mask=None, id_label=None, wcs=None, **kwargs):
415
416
 
416
417
  """
417
418
 
@@ -446,13 +447,19 @@ class Spectrum:
446
447
  cls._fitsMgr = OpenFits(file_address, instrument, cls.__name__)
447
448
 
448
449
  # Load the scientific data from the file
449
- fits_args = cls._fitsMgr.parse_data_from_file(cls._fitsMgr.file_address, mask_flux_entries)
450
+ fits_args = cls._fitsMgr.parse_data_from_file(cls._fitsMgr.file_address, pixel_mask, **kwargs)
450
451
 
451
- # Update the parameters file parameters with the user parameters
452
- obs_args = {**fits_args, **kwargs}
452
+ # Update the file parameters with the user parameters
453
+ input_args = dict(redshift=redshift, norm_flux=norm_flux, crop_waves=crop_waves, res_power=res_power,
454
+ units_wave=units_wave, units_flux=units_flux, id_label=id_label, wcs=wcs)
455
+
456
+ if cls._fitsMgr.spectrum_check:
457
+ input_args.pop('wcs')
458
+
459
+ input_args = {**fits_args, **{k: v for k, v in input_args.items() if v is not None}}
453
460
 
454
461
  # Create the LiMe object
455
- return cls(**obs_args)
462
+ return cls(**input_args)
456
463
 
457
464
  @classmethod
458
465
  def from_survey(cls, target_id, survey, mask_flux_entries=None, **kwargs):
@@ -117,16 +117,25 @@ def bands_filling_bokeh(fig, x, y, z_corr, idcs_mask, label, exclude_continua=Fa
117
117
  low_lim = 0 if np.isnan(low_lim) else low_lim
118
118
 
119
119
  # Central bands
120
+ print('1',x[idcs_mask[2]:idcs_mask[3]]/z_corr)
121
+ print('1',y[idcs_mask[2]:idcs_mask[3]]*z_corr)
122
+ print('1',low_lim*z_corr)
120
123
  fig.varea_step(x=x[idcs_mask[2]:idcs_mask[3]]/z_corr, y1=low_lim*z_corr, y2=y[idcs_mask[2]:idcs_mask[3]]*z_corr,
121
124
  step_mode="center", fill_alpha=0.25, color=color_dict['line_band'])
122
125
 
123
126
  # Continua bands exclusion
124
127
  if exclude_continua is False:
128
+ print('2', x[idcs_mask[0]:idcs_mask[1]]/z_corr)
129
+ print('2', low_lim*z_corr)
130
+ print('2', y[idcs_mask[0]:idcs_mask[1]]*z_corr)
125
131
  fig.varea_step(x=x[idcs_mask[0]:idcs_mask[1]]/z_corr,
126
132
  y1=low_lim*z_corr,
127
133
  y2=y[idcs_mask[0]:idcs_mask[1]]*z_corr,
128
134
  step_mode="center", fill_alpha=0.25, color=color_dict['cont_band'])
129
135
 
136
+ print('3', x[idcs_mask[4]:idcs_mask[5]]/z_corr)
137
+ print('3', low_lim*z_corr)
138
+ print('3', y[idcs_mask[4]:idcs_mask[5]]*z_corr)
130
139
  fig.varea_step(x=x[idcs_mask[4]:idcs_mask[5]]/z_corr,
131
140
  y1=low_lim*z_corr,
132
141
  y2=y[idcs_mask[4]:idcs_mask[5]]*z_corr,
@@ -186,7 +195,7 @@ class BokehFigures:
186
195
 
187
196
  return
188
197
 
189
- def bands(self, label, output_address=None, ref_bands=None, include_fits=True, rest_frame=False, log_scale=True,
198
+ def bands(self, label, output_address=None, bands=None, include_fits=True, rest_frame=False, log_scale=True,
190
199
  exclude_continua=True, fig_cfg=None, ax_cfg=None, return_fig=False):
191
200
 
192
201
 
@@ -198,7 +207,7 @@ class BokehFigures:
198
207
  legend_check = True if label is not None else False
199
208
 
200
209
  # Check which line should be plotted
201
- line = parse_bands_arguments(label, log, ref_bands, norm_flux)
210
+ line = parse_bands_arguments(label, log, bands, norm_flux)
202
211
 
203
212
  # Proceed to plot
204
213
  if line is not None:
@@ -657,9 +657,10 @@ def redshift_permu_evaluation(spectrum, z_infered, obs_wave_arr, theo_wave_arr,
657
657
  return
658
658
 
659
659
 
660
- def bands_filling_plot(axis, x, y, z_corr, idcs_mask, label, exclude_continua=False, color_dict=theme.colors, show_central=True):
660
+ def bands_filling_plot(axis, x, y, z_corr, idcs_mask, label, exclude_continua=True, color_dict=theme.colors, show_central=True):
661
661
 
662
662
  # Security check for low selection
663
+ # TODO check this error crashing
663
664
  if y[idcs_mask[2]:idcs_mask[3]].size > 1:
664
665
 
665
666
  # Lower limit for the filled region
@@ -768,8 +769,8 @@ class Plotter:
768
769
  def _line_matching_plot(self, axis, bands, x, y, z_corr, redshift):
769
770
 
770
771
  # Open the bands file the bands
771
- match_log = self._spec.retrieve.line_bands(ref_bands=bands, fit_cfg=None, instrumental_correction=False,
772
- adjust_central_band=False)
772
+ match_log = check_file_dataframe(bands)
773
+
773
774
  # Compute bands limits
774
775
  w3 = match_log.w3.values * (1 + redshift)
775
776
  w4 = match_log.w4.values * (1 + redshift)
@@ -1008,43 +1009,6 @@ class SpectrumFigures(Plotter):
1008
1009
  in_ax.fill_between(wave_plot/z_corr, low_limit*z_corr, high_limit*z_corr, alpha=0.2,
1009
1010
  color=theme.colors['fade_fg'])
1010
1011
 
1011
- # # Include the detection bands
1012
- # if detection_band is not None:
1013
- #
1014
- # detec_obj = getattr(self._spec.infer, detection_band)
1015
- #
1016
- # if detec_obj.confidence is not None:
1017
- #
1018
- # # Boundaries array for confidence intervals
1019
- # bounds = np.array([0.0, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
1020
- #
1021
- # # Adjust color map to match lower detection limit to fg color
1022
- # cmap = plt.get_cmap(theme.colors['mask_map'])
1023
- # cmaplist = [cmap(i) for i in range(cmap.N)]
1024
- # cmaplist[0] = theme.colors['fg']
1025
- # cmap = colors.LinearSegmentedColormap.from_list('mcm', cmaplist, bounds.size-1)
1026
- # norm = colors.BoundaryNorm(bounds * 100, cmap.N)
1027
- #
1028
- # # Iterate through the confidence intervals and plot the step spectrum
1029
- # for i in range(1, len(bounds)):
1030
- # if i > 1:
1031
- # idcs = detec_obj(bounds[i-1]*100, confidence_max=bounds[i]*100)
1032
- # wave_nan, flux_nan = np.full(wave_plot.size, np.nan), np.full(flux_plot.size, np.nan)
1033
- # wave_nan[idcs], flux_nan[idcs] = wave_plot[idcs] / z_corr, flux_plot[idcs] * z_corr
1034
- #
1035
- # in_ax.step(wave_nan, flux_nan, label=label, where='mid', color=cmap(i-1))
1036
- #
1037
- # # Color bar
1038
- # sm = cm.ScalarMappable(cmap=cmap, norm=norm)
1039
- # sm.set_array([])
1040
- # cbar = plt.colorbar(sm, ax=in_ax)
1041
- # cbar.set_label('Detection confidence %', rotation=270, labelpad=35)
1042
- #
1043
- #
1044
- # else:
1045
- # _logger.warning(f'The line detection bands confidence has not been calculated. They are not included'
1046
- # f' on plot.')
1047
-
1048
1012
  # Show components
1049
1013
  if show_categories and self._spec.infer.pred_arr is not None:
1050
1014
 
@@ -1269,8 +1233,8 @@ class SpectrumFigures(Plotter):
1269
1233
 
1270
1234
  return in_fig
1271
1235
 
1272
- def bands(self, label=None, output_address=None, ref_bands=None, include_fits=True, rest_frame=False, y_scale='auto', fig_cfg=None,
1273
- ax_cfg=None, in_fig=None, maximize=False, show_err=False):
1236
+ def bands(self, label=None, bands=None, output_address=None, include_fits=True, rest_frame=False, y_scale='auto', fig_cfg=None,
1237
+ ax_cfg=None, in_fig=None, maximize=False, show_err=False, exclude_continua=False):
1274
1238
 
1275
1239
  """
1276
1240
 
@@ -1327,7 +1291,7 @@ class SpectrumFigures(Plotter):
1327
1291
  display_check = True if in_fig is None else False
1328
1292
 
1329
1293
  # Check which line should be plotted
1330
- line = parse_bands_arguments(label, log, ref_bands, norm_flux)
1294
+ line = parse_bands_arguments(label, bands, log, norm_flux)
1331
1295
 
1332
1296
  # Check the observation has uncertainty to display
1333
1297
  if show_err and (self._spec.err_flux is None):
@@ -1372,13 +1336,13 @@ class SpectrumFigures(Plotter):
1372
1336
  idcs_bands = line.index_bands(self._spec.wave, self._spec.redshift, just_band_edges=True)
1373
1337
 
1374
1338
  # Plot the spectrum
1375
- label_leg = line.latex_label if (line.latex_label is not None and include_fits is False) else None
1339
+ label_leg = line.latex_label[0] if (line.latex_label[0] is not None and include_fits is False) else None
1376
1340
  in_ax[0].step(wave_plot[idcs_bands[0]:idcs_bands[5]] / z_corr, flux_plot[idcs_bands[0]:idcs_bands[5]] * z_corr,
1377
1341
  where='mid', color=theme.colors['fg'], label=label_leg, linewidth=theme.plt['spectrum_width'])
1378
1342
 
1379
1343
  # Continuum bands
1380
1344
  bands_filling_plot(in_ax[0], wave_plot, flux_plot, z_corr, idcs_bands, line, color_dict=theme.colors,
1381
- show_central=not show_err)
1345
+ show_central=not show_err, exclude_continua=exclude_continua)
1382
1346
 
1383
1347
  if show_err:
1384
1348
  err_plot = self._spec.err_flux.data
@@ -1536,7 +1536,7 @@ class CubeInspection:
1536
1536
  self._ax0.set_ylim(self.axlim_dict['image_ylim'])
1537
1537
  self._ax1.set_xlim(self.axlim_dict['spec_xlim'])
1538
1538
 
1539
- if not self.maintain_y_zoom:
1539
+ if self.maintain_y_zoom:
1540
1540
  self._ax1.set_ylim(self.axlim_dict['spec_ylim'])
1541
1541
 
1542
1542
  else:
@@ -7,21 +7,21 @@ from lime.io import _PARENT_BANDS
7
7
  _logger = logging.getLogger('LiMe')
8
8
 
9
9
 
10
- def parse_bands_arguments(label, log, ref_bands, norm_flux):
10
+ def parse_bands_arguments(label, bands, log, norm_flux):
11
11
 
12
12
  line = None
13
13
  if label is None and (log.index.size > 0):
14
14
  label = log.index[-1]
15
15
  line = Line.from_log(label, log, norm_flux)
16
16
 
17
+ # The user provided a reference band to check the region use it
18
+ elif label is not None and bands is not None:
19
+ line = Line(label, bands)
20
+
17
21
  # Line has been measured before
18
22
  elif label is not None and (log.index.size > 0):
19
23
  line = Line.from_log(label, log, norm_flux)
20
24
 
21
- # The user provided a reference band to check the region use it
22
- elif label is not None and ref_bands is not None:
23
- line = Line(label, ref_bands)
24
-
25
25
  elif label is not None and label in _PARENT_BANDS.index:
26
26
  line = Line(label, band=_PARENT_BANDS.loc[label, 'w1':'w6'].to_numpy())
27
27