PyNOT-redux 2.4.1__tar.gz → 2.4.2__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 (117) hide show
  1. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PKG-INFO +1 -1
  2. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/PKG-INFO +1 -1
  3. pynot_redux-2.4.2/pynot/VERSION +1 -0
  4. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/fitsio.py +2 -2
  5. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/notes.py +68 -2
  6. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/viewer.py +25 -1
  7. pynot_redux-2.4.1/pynot/VERSION +0 -1
  8. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/.gitattributes +0 -0
  9. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/.github/dependabot.yml +0 -0
  10. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/.gitignore +0 -0
  11. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/LICENSE +0 -0
  12. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/MANIFEST.in +0 -0
  13. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/SOURCES.txt +0 -0
  14. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/dependency_links.txt +0 -0
  15. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/entry_points.txt +0 -0
  16. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/requires.txt +0 -0
  17. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/PyNOT_redux.egg-info/top_level.txt +0 -0
  18. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/README.md +0 -0
  19. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/.extract_msg +0 -0
  20. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/.identify_msg +0 -0
  21. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/.instrument.cfg +0 -0
  22. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/.response_msg +0 -0
  23. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/__init__.py +0 -0
  24. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/alfosc.py +0 -0
  25. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/HeAr_linelist.dat +0 -0
  26. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/HeNe_linelist.dat +0 -0
  27. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/ThAr_linelist.dat +0 -0
  28. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/al-gr18_pixeltable.dat +0 -0
  29. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/al-gr19_pixeltable.dat +0 -0
  30. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/al-gr4_pixeltable.dat +0 -0
  31. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/al-gr7_pixeltable.dat +0 -0
  32. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/alfosc_filters.dat +0 -0
  33. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/default_options.yml +0 -0
  34. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/default_options_img.yml +0 -0
  35. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/ef-gr13_pixeltable.dat +0 -0
  36. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/ef-gr14_pixeltable.dat +0 -0
  37. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/ef-gr1_pixeltable.dat +0 -0
  38. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/ef-gr3_pixeltable.dat +0 -0
  39. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/efosc_filters.dat +0 -0
  40. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/lapalma.ext +0 -0
  41. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/lasilla.ext +0 -0
  42. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/paranal.ext +0 -0
  43. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/bd174708.dat +0 -0
  44. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/bd262606.dat +0 -0
  45. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/bd332642.dat +0 -0
  46. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/bd75325.dat +0 -0
  47. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/eg21.dat +0 -0
  48. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/feige110.dat +0 -0
  49. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/feige34.dat +0 -0
  50. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/gd153.dat +0 -0
  51. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/gd50.dat +0 -0
  52. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/gd71.dat +0 -0
  53. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/hd19445.dat +0 -0
  54. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/hd84937.dat +0 -0
  55. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/hd93521.dat +0 -0
  56. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/he3.dat +0 -0
  57. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/hiltner600.dat +0 -0
  58. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/ltt3864.dat +0 -0
  59. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/tcs_namelist.txt +0 -0
  60. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calib/std/wolf1346.dat +0 -0
  61. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/calibs.py +0 -0
  62. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/__init__.py +0 -0
  63. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/alfosc.rules +0 -0
  64. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/efosc.rules +0 -0
  65. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/help/welcome_msg_extract.html +0 -0
  66. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/help/welcome_msg_identify.html +0 -0
  67. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/help/welcome_msg_response.html +0 -0
  68. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/io.py +0 -0
  69. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/obs.py +0 -0
  70. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/data/organizer.py +0 -0
  71. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/efosc.py +0 -0
  72. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/extract_gui.py +0 -0
  73. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/extraction.py +0 -0
  74. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/functions.py +0 -0
  75. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/identify_gui.py +0 -0
  76. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/images.py +0 -0
  77. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/insconfig.py +0 -0
  78. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/logging.py +0 -0
  79. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/main.py +0 -0
  80. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/operations.py +0 -0
  81. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/phot.py +0 -0
  82. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/phot_redux.py +0 -0
  83. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/redux.py +0 -0
  84. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/reports.py +0 -0
  85. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/response.py +0 -0
  86. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/response_gui.py +0 -0
  87. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/scired.py +0 -0
  88. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/scombine.py +0 -0
  89. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/skysub.py +0 -0
  90. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/tasks.py +0 -0
  91. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/transients.py +0 -0
  92. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/txtio.py +0 -0
  93. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/__init__.py +0 -0
  94. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/containers.py +0 -0
  95. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/default_linelists.json +0 -0
  96. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/dust.py +0 -0
  97. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/linelists.py +0 -0
  98. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/messages.py +0 -0
  99. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/models.py +0 -0
  100. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/spectrum.py +0 -0
  101. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/tablemodels.py +0 -0
  102. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/targets.py +0 -0
  103. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/Assef_2010.dat +0 -0
  104. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/FeII.Vestergaard.dat +0 -0
  105. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/FeIII.Vestergaard.dat +0 -0
  106. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/Hernan_Caballero_quasar_NIR_template.txt +0 -0
  107. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/QSO_selsing.dat +0 -0
  108. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/QSO_template.Krawczyk_all.dat +0 -0
  109. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/QSO_template.Krawczyk_high.dat +0 -0
  110. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/viewer/templates/QSO_template.Krawczyk_low.dat +0 -0
  111. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/wavecal.py +0 -0
  112. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/wcs.py +0 -0
  113. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pynot/welcome.py +0 -0
  114. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/pyproject.toml +0 -0
  115. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/requirements.txt +0 -0
  116. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/setup.cfg +0 -0
  117. {pynot_redux-2.4.1 → pynot_redux-2.4.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyNOT-redux
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: Data Reduction Pipeline for NOT/ALFOSC
5
5
  Home-page: https://github.com/jkrogager/PyNOT
6
6
  Author: Jens-Kristian Krogager
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyNOT-redux
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: Data Reduction Pipeline for NOT/ALFOSC
5
5
  Home-page: https://github.com/jkrogager/PyNOT
6
6
  Author: Jens-Kristian Krogager
@@ -0,0 +1 @@
1
+ 2.4.2
@@ -4,7 +4,7 @@ __author__ = "Jens-Kristian Krogager"
4
4
  import warnings
5
5
  from astropy.io import fits
6
6
  from astropy import units as u
7
- from astropy.table import QTable
7
+ from astropy.table import Table
8
8
  import numpy as np
9
9
  import os
10
10
 
@@ -165,7 +165,7 @@ def get_spectrum_fits_table(table_hdu):
165
165
  Numpy boolean array of pixel mask. `True` if the pixel is 'good',
166
166
  `False` if the pixel is bad and should not be used.
167
167
  """
168
- tbdata = QTable.read(table_hdu)
168
+ tbdata = Table.read(table_hdu)
169
169
  # table_names = [name.lower() for name in tbdata.names]
170
170
  for colname in tbdata.colnames:
171
171
  tbdata.rename_column(colname, colname.lower())
@@ -3,8 +3,9 @@ import logging
3
3
  import json
4
4
  import numpy as np
5
5
  from enum import IntFlag
6
- from dataclasses import dataclass
6
+ from dataclasses import dataclass, fields
7
7
  import datetime
8
+ import os
8
9
 
9
10
  from PyQt5.QtWidgets import QFileDialog
10
11
 
@@ -64,6 +65,10 @@ class TargetNote:
64
65
  return row
65
66
 
66
67
 
68
+ target_note_fields = [f.name for f in fields(TargetNote)]
69
+ target_note_defaults = {f.name: f.type for f in fields(TargetNote)}
70
+
71
+
67
72
  REDSHIFT_NAMES = ['REDSHIFT', 'Z_SPEC', 'ZBEST', 'Z_PIPE', 'ZSPEC', 'Z', 'ZFIT', 'Z_VI']
68
73
  ID_NAMES = ['PROV', 'FILENAME', 'PROV', 'OBJ_NME', 'OBJ_UID', 'NAME', 'OBJECT', 'TARGET', 'TARGETID', 'ID', 'UID']
69
74
  CLASS_NAMES = ['TYPE', 'ZBESTTYPE', 'SPECTYPE', 'CLASS', 'CLASSIFICATION', 'OBJ_CLS']
@@ -170,7 +175,7 @@ def redshift_table_lookup(redshift_table, spectrum):
170
175
  name_column = redshift_table.meta['NAME_COLUMN']
171
176
 
172
177
  if name_column.upper() == 'FILENAME' or name_column.upper() == 'PROV':
173
- name = spectrum.filename
178
+ name = os.path.basename(spectrum.filename)
174
179
 
175
180
  else:
176
181
  if not spectrum.meta:
@@ -272,3 +277,64 @@ def write_notes_to_file(notes: dict[str, TargetNote], flags: dict[str, DataFlag]
272
277
 
273
278
  file_saved = writer(rows, filename)
274
279
  return file_saved
280
+
281
+
282
+ def load_json(filename):
283
+ with open(filename) as f:
284
+ rows = json.load(f)
285
+ return Table(rows)
286
+
287
+
288
+ def load_table(filename):
289
+ return Table.read(filename)
290
+
291
+
292
+ def parse_masked_values(key, val):
293
+ if hasattr(val, 'mask') and val.mask:
294
+ return target_note_defaults[key]()
295
+ else:
296
+ return val
297
+
298
+
299
+ def target_note_from_row(**kwargs):
300
+ pars = {}
301
+ for key, val in kwargs.items():
302
+ if key in target_note_fields and key == 'filenames':
303
+ pars[key] = val.split(';')
304
+ elif key in target_note_fields and key != 'filenames':
305
+ pars[key] = parse_masked_values(key, val)
306
+ else:
307
+ continue
308
+ return TargetNote(**pars)
309
+
310
+
311
+ def data_flag_from_row(row):
312
+ try:
313
+ flag = DataFlag(row['flag'])
314
+ except ValueError:
315
+ flag = DataFlag(0)
316
+ logging.error(f"Could not parse flag value: {row['flag']}. The flags must have changed")
317
+ return flag
318
+
319
+
320
+ def validate_table(tab: Table):
321
+ mandatory_columns = [f.name for f in fields(TargetNote)]
322
+ mandatory_columns.append('flag')
323
+ valid = all([key in tab.colnames for key in mandatory_columns])
324
+ return valid
325
+
326
+
327
+ def load_notes_from_file(filename):
328
+ if '.json' in filename:
329
+ loader = load_json
330
+ else:
331
+ loader = load_table
332
+
333
+ tab = loader(filename)
334
+ valid = validate_table(tab)
335
+ if not valid:
336
+ logging.error(f"Error loading notes from file: {filename}. Unexpected format!")
337
+
338
+ target_notes = {row['name']: target_note_from_row(**row) for row in tab}
339
+ target_flags = {row['name']: data_flag_from_row(row) for row in tab}
340
+ return target_notes, target_flags
@@ -17,7 +17,11 @@ import os
17
17
  import warnings
18
18
 
19
19
  from pynot.fitsio import load_fits_spectrum, save_fits_spectrum
20
- from pynot.viewer.notes import load_redshift_table, redshift_table_lookup, TargetNote, DataFlag, write_notes_to_file
20
+ from pynot.viewer.notes import (load_redshift_table,
21
+ redshift_table_lookup,
22
+ TargetNote, DataFlag,
23
+ write_notes_to_file,
24
+ load_notes_from_file)
21
25
  from pynot.viewer.tablemodels import TableModel, ActiveTableModel, AbstractIndex
22
26
  from pynot.viewer.spectrum import Spectrum, join_spectra, Template, ModelSpectrum
23
27
  from pynot.viewer.messages import QtLogHandler, LogViewerDialog
@@ -967,6 +971,21 @@ class MainWindow(QtWidgets.QMainWindow):
967
971
  self.notes_filename = str(notes_filename)
968
972
  logging.info(f"Saved target notes to file: {notes_filename}")
969
973
 
974
+ def load_notes(self, filename=None):
975
+ current_dir = "./"
976
+ filters = "CSV Files (*.csv);; JSON Files (*.json);; FITS Files (*.fits)"
977
+ fname, selected_filter = QtWidgets.QFileDialog.getOpenFileName(
978
+ self,
979
+ 'Load Target Notes',
980
+ current_dir,
981
+ filters)
982
+ if not fname:
983
+ return
984
+ loaded_notes, loaded_flags = load_notes_from_file(fname)
985
+ self.target_notes = loaded_notes
986
+ self.target_flags = loaded_flags
987
+ logging.info(f"Loaded target notes from file: {fname}")
988
+
970
989
  def create_menubar(self):
971
990
  self.main_menu = self.menuBar()
972
991
 
@@ -979,11 +998,16 @@ class MainWindow(QtWidgets.QMainWindow):
979
998
  save_action.triggered.connect(lambda x: self.write_notes())
980
999
  save_action.setShortcut("Ctrl+S")
981
1000
 
1001
+ load_action = QtWidgets.QAction("Load Notes", self)
1002
+ load_action.triggered.connect(lambda x: self.load_notes())
1003
+ load_action.setShortcut("Ctrl+L")
1004
+
982
1005
  # Exit QAction
983
1006
  exit_action = QtWidgets.QAction("Exit", self)
984
1007
  exit_action.triggered.connect(self.close)
985
1008
 
986
1009
  self.file_menu.addAction(save_action)
1010
+ self.file_menu.addAction(load_action)
987
1011
  self.file_menu.addAction(exit_action)
988
1012
 
989
1013
  # -- Models Menu
@@ -1 +0,0 @@
1
- 2.4.1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes