From da16b0a0cc3565d25288ed1242cc6bb31bc590a8 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 18 Mar 2024 07:56:14 -0700 Subject: [PATCH 1/6] bump support to 3.10 or higher --- .github/workflows/ci_cron.yml | 2 +- .github/workflows/ci_tests.yml | 4 +- doc/help/run_pypeit.rst | 2 +- doc/include/dependencies_table.rst | 2 +- doc/include/keck_deimos.sorted.rst | 6 +-- doc/pypeit_par.rst | 62 +++++++++++++++--------------- doc/releases/1.15.1dev.rst | 2 + setup.cfg | 5 ++- tox.ini | 10 ++--- 9 files changed, 49 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci_cron.yml b/.github/workflows/ci_cron.yml index ae23b4affe..530acb47ad 100644 --- a/.github/workflows/ci_cron.yml +++ b/.github/workflows/ci_cron.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python: ['3.9', '3.10', '3.11'] + python: ['3.10', '3.11', '3.12'] toxenv: [test-alldeps, test-numpydev, test-linetoolsdev, test-gingadev, test-astropydev] steps: - name: Check out repository diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 6e735c802f..9c2f37ec7d 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python: ['3.9', '3.10', '3.11'] + python: ['3.10', '3.11', '3.12'] toxenv: [test, test-alldeps-cov, test-linetoolsdev, test-gingadev, test-astropydev] steps: - name: Check out repository @@ -48,7 +48,7 @@ jobs: fail-fast: false matrix: os: [windows-latest, macos-latest] - python: ['3.9', '3.10', '3.11'] + python: ['3.10', '3.11', '3.12'] toxenv: [test-alldeps] steps: - name: Check out repository diff --git a/doc/help/run_pypeit.rst b/doc/help/run_pypeit.rst index be6166e46d..d64a06202a 100644 --- a/doc/help/run_pypeit.rst +++ b/doc/help/run_pypeit.rst @@ -4,7 +4,7 @@ usage: run_pypeit [-h] [-v VERBOSITY] [-r REDUX_PATH] [-m] [-s] [-o] [-c] pypeit_file - ## PypeIt : The Python Spectroscopic Data Reduction Pipeline v1.15.1.dev38+g075fdecaa.d20240212 + ## PypeIt : The Python Spectroscopic Data Reduction Pipeline v1.15.1.dev126+ga20cda141.d20240305 ## ## Available spectrographs include: ## bok_bc, gemini_flamingos1, gemini_flamingos2, gemini_gmos_north_e2v, diff --git a/doc/include/dependencies_table.rst b/doc/include/dependencies_table.rst index 5d8b49f10a..b6e6ba3778 100644 --- a/doc/include/dependencies_table.rst +++ b/doc/include/dependencies_table.rst @@ -1,5 +1,5 @@ ======================= ========================================================================================================================================================================================================================================================================================================================================================= -Python Version ``>=3.9,<3.12`` +Python Version ``>=3.10,<3.13`` Required for users ``IPython>=7.10.0``, ``PyERFA>=2.0.0``, ``PyYAML>=5.1``, ``astropy>=4.3``, ``bottleneck``, ``configobj>=5.0.6``, ``extension-helpers>=0.1``, ``fast-histogram>=0.11``, ``ginga>=4.1.1``, ``linetools>=0.3.1``, ``matplotlib>=3.7``, ``numpy>=1.22``, ``packaging>=0.19``, ``pygithub``, ``pyqt6``, ``qtpy>=2.0.1``, ``scikit-learn>=1.0``, ``scipy>=1.7`` Required for developers ``coverage``, ``docutils<0.19``, ``psutil # Strictly only needed for the dev-suite``, ``pytest-astropy``, ``pytest-cov``, ``pytest-qt # Strictly only needed for the dev-suite``, ``pytest>=6.0.0``, ``scikit-image``, ``specutils>=1.12``, ``sphinx-automodapi``, ``sphinx<7,>=1.6``, ``sphinx_rtd_theme==1.2.2``, ``tox`` ======================= ========================================================================================================================================================================================================================================================================================================================================================= diff --git a/doc/include/keck_deimos.sorted.rst b/doc/include/keck_deimos.sorted.rst index 655eedb3a6..828519122f 100644 --- a/doc/include/keck_deimos.sorted.rst +++ b/doc/include/keck_deimos.sorted.rst @@ -14,13 +14,13 @@ d0527_0030.fits.gz | arc,tilt | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.077631 | 1.41291034 | 1.0 | 8099.98291016 | SINGLE:B | OG550 | Kr Xe Ar Ne | 2017-05-27 | 01:51:53.87 | 30 | 0 d0527_0031.fits.gz | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.07851 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:53:10.93 | 31 | 0 DE.20170527.06790.fits | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.07851 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:53:10.93 | 31 | 0 - d0527_0032.fits.gz | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.079356 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:54:24.03 | 32 | 0 DE.20170527.06864.fits | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.079356 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:54:24.03 | 32 | 0 - DE.20170527.06936.fits | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.080211 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:55:36.93 | 33 | 0 + d0527_0032.fits.gz | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.079356 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:54:24.03 | 32 | 0 d0527_0033.fits.gz | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.080211 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:55:36.93 | 33 | 0 + DE.20170527.06936.fits | pixelflat,illumflat,trace | 57.99999999999999 | 45.0 | DOME PHLAT | 830G | LongMirr | 1,1 | 57900.080211 | 1.41291034 | 4.0 | 8099.98291016 | SINGLE:B | OG550 | Qz | 2017-05-27 | 01:55:36.93 | 33 | 0 DE.20170527.37601.fits | science | 261.0363749999999 | 19.028166666666667 | P261_OFF | 830G | LongMirr | 1,1 | 57900.435131 | 1.03078874 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 10:26:41.61 | 80 | 0 - DE.20170527.38872.fits | science | 261.0363749999999 | 19.028166666666667 | P261_OFF | 830G | LongMirr | 1,1 | 57900.449842 | 1.01267696 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 10:47:52.92 | 81 | 0 d0527_0081.fits.gz | science | 261.0363749999999 | 19.028166666666667 | P261_OFF | 830G | LongMirr | 1,1 | 57900.449842 | 1.01267696 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 10:47:52.92 | 81 | 0 + DE.20170527.38872.fits | science | 261.0363749999999 | 19.028166666666667 | P261_OFF | 830G | LongMirr | 1,1 | 57900.449842 | 1.01267696 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 10:47:52.92 | 81 | 0 DE.20170527.41775.fits | science | 261.0362916666666 | 19.028888888888886 | P261_OFF | 830G | LongMirr | 1,1 | 57900.483427 | 1.00093023 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 11:36:15.35 | 83 | 0 d0527_0083.fits.gz | science | 261.0362916666666 | 19.028888888888886 | P261_OFF | 830G | LongMirr | 1,1 | 57900.483427 | 1.00093023 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 11:36:15.35 | 83 | 0 DE.20170527.43045.fits | science | 261.0362916666666 | 19.028888888888886 | P261_OFF | 830G | LongMirr | 1,1 | 57900.498135 | 1.00838805 | 1200.0 | 8099.98291016 | SINGLE:B | OG550 | Off | 2017-05-27 | 11:57:25.35 | 84 | 0 diff --git a/doc/pypeit_par.rst b/doc/pypeit_par.rst index 1d091bb265..80cd630ecc 100644 --- a/doc/pypeit_par.rst +++ b/doc/pypeit_par.rst @@ -576,21 +576,21 @@ Collate1DPar Keywords Class Instantiation: :class:`~pypeit.par.pypeitpar.Collate1DPar` -========================= ========== ======= ===================================== ================================================================================================================================================================================================================================================================================================================================================================================================================== -Key Type Options Default Description -========================= ========== ======= ===================================== ================================================================================================================================================================================================================================================================================================================================================================================================================== -``dry_run`` bool .. False If set, the script will display the matching File and Object Ids but will not flux, coadd or archive. -``exclude_serendip`` bool .. False Whether to exclude SERENDIP objects from collating. -``exclude_slit_trace_bm`` list, str .. [] A list of slit trace bitmask bits that should be excluded. -``flux`` bool .. False If set, the script will flux calibrate using archived sensfuncs before coadding. -``ignore_flux`` bool .. False If set, the script will only coadd non-fluxed spectra even if flux data is present. Otherwise fluxed spectra are coadded if all spec1ds have been fluxed calibrated. -``match_using`` str .. ``ra/dec`` Determines how 1D spectra are matched as being the same object. Must be either 'pixel' or 'ra/dec'. -``outdir`` str .. ``/Users/rcooke/Software/PypeIt/doc`` The path where all coadded output files and report files will be placed. -``refframe`` str .. .. Perform reference frame correction prior to coadding. Options are: observed, heliocentric, barycentric -``spec1d_outdir`` str .. .. The path where all modified spec1d files are placed. These are only created if flux calibration or refframe correction are asked for. -``tolerance`` str, float .. ``1.0`` The tolerance used when comparing the coordinates of objects. If two objects are within this distance from each other, they are considered the same object. If match_using is 'ra/dec' (the default) this is an angular distance. The defaults units are arcseconds but other units supported by astropy.coordinates.Angle can be used (`e.g.`, '0.003d' or '0h1m30s'). If match_using is 'pixel' this is a float. -``wv_rms_thresh`` float .. .. If set, any objects with a wavelength RMS > this value are skipped, else all wavelength RMS values are accepted. -========================= ========== ======= ===================================== ================================================================================================================================================================================================================================================================================================================================================================================================================== +========================= ========== ======= ============================================ ================================================================================================================================================================================================================================================================================================================================================================================================================== +Key Type Options Default Description +========================= ========== ======= ============================================ ================================================================================================================================================================================================================================================================================================================================================================================================================== +``dry_run`` bool .. False If set, the script will display the matching File and Object Ids but will not flux, coadd or archive. +``exclude_serendip`` bool .. False Whether to exclude SERENDIP objects from collating. +``exclude_slit_trace_bm`` list, str .. [] A list of slit trace bitmask bits that should be excluded. +``flux`` bool .. False If set, the script will flux calibrate using archived sensfuncs before coadding. +``ignore_flux`` bool .. False If set, the script will only coadd non-fluxed spectra even if flux data is present. Otherwise fluxed spectra are coadded if all spec1ds have been fluxed calibrated. +``match_using`` str .. ``ra/dec`` Determines how 1D spectra are matched as being the same object. Must be either 'pixel' or 'ra/dec'. +``outdir`` str .. ``/Users/westfall/Work/packages/pypeit/doc`` The path where all coadded output files and report files will be placed. +``refframe`` str .. .. Perform reference frame correction prior to coadding. Options are: observed, heliocentric, barycentric +``spec1d_outdir`` str .. .. The path where all modified spec1d files are placed. These are only created if flux calibration or refframe correction are asked for. +``tolerance`` str, float .. ``1.0`` The tolerance used when comparing the coordinates of objects. If two objects are within this distance from each other, they are considered the same object. If match_using is 'ra/dec' (the default) this is an angular distance. The defaults units are arcseconds but other units supported by astropy.coordinates.Angle can be used (`e.g.`, '0.003d' or '0h1m30s'). If match_using is 'pixel' this is a float. +``wv_rms_thresh`` float .. .. If set, any objects with a wavelength RMS > this value are skipped, else all wavelength RMS values are accepted. +========================= ========== ======= ============================================ ================================================================================================================================================================================================================================================================================================================================================================================================================== ---- @@ -643,22 +643,22 @@ ReduxPar Keywords Class Instantiation: :class:`~pypeit.par.pypeitpar.ReduxPar` -====================== ============== ======= ===================================== ========================================================================================================================================================================================================================================================================================================================================================================================================== -Key Type Options Default Description -====================== ============== ======= ===================================== ========================================================================================================================================================================================================================================================================================================================================================================================================== -``calwin`` int, float .. 0 The window of time in hours to search for calibration frames for a science frame -``chk_version`` bool .. True If True enforce strict PypeIt version checking to ensure that all files were created with the current version of PypeIt. If set to False, the code will attempt to read out-of-date files and keep going. Beware (!!) that this can lead to unforeseen bugs that either cause the code to crash or lead to erroneous results. I.e., you really need to know what you are doing if you set this to False! -``detnum`` int, list .. .. Restrict reduction to a list of detector indices. In case of mosaic reduction (currently only available for Gemini/GMOS and Keck/DEIMOS) ``detnum`` should be a list of tuples of the detector indices that are mosaiced together. E.g., for Gemini/GMOS ``detnum`` would be ``[(1,2,3)]`` and for Keck/DEIMOS it would be ``[(1, 5), (2, 6), (3, 7), (4, 8)]`` -``ignore_bad_headers`` bool .. False Ignore bad headers (NOT recommended unless you know it is safe). -``maskIDs`` str, int, list .. .. Restrict reduction to a set of slitmask IDs Example syntax -- ``maskIDs = 818006,818015`` This must be used with detnum (for now). -``qadir`` str .. ``QA`` Directory relative to calling directory to write quality assessment files. -``quicklook`` bool .. False Run a quick look reduction? This is usually good if you want to quickly reduce the data (usually at the telescope in real time) to get an initial estimate of the data quality. -``redux_path`` str .. ``/Users/rcooke/Software/PypeIt/doc`` Path to folder for performing reductions. Default is the current working directory. -``scidir`` str .. ``Science`` Directory relative to calling directory to write science files. -``slitspatnum`` str, list .. .. Restrict reduction to a set of slit DET:SPAT values (closest slit is used). Example syntax -- slitspatnum = DET01:175,DET01:205 or MSC02:2234 If you are re-running the code, (i.e. modifying one slit) you *must* have the precise SPAT_ID index. -``sortroot`` str .. .. A filename given to output the details of the sorted files. If None, the default is the root name of the pypeit file. If off, no output is produced. -``spectrograph`` str .. .. Spectrograph that provided the data to be reduced. See :ref:`instruments` for valid options. -====================== ============== ======= ===================================== ========================================================================================================================================================================================================================================================================================================================================================================================================== +====================== ============== ======= ============================================ ========================================================================================================================================================================================================================================================================================================================================================================================================== +Key Type Options Default Description +====================== ============== ======= ============================================ ========================================================================================================================================================================================================================================================================================================================================================================================================== +``calwin`` int, float .. 0 The window of time in hours to search for calibration frames for a science frame +``chk_version`` bool .. True If True enforce strict PypeIt version checking to ensure that all files were created with the current version of PypeIt. If set to False, the code will attempt to read out-of-date files and keep going. Beware (!!) that this can lead to unforeseen bugs that either cause the code to crash or lead to erroneous results. I.e., you really need to know what you are doing if you set this to False! +``detnum`` int, list .. .. Restrict reduction to a list of detector indices. In case of mosaic reduction (currently only available for Gemini/GMOS and Keck/DEIMOS) ``detnum`` should be a list of tuples of the detector indices that are mosaiced together. E.g., for Gemini/GMOS ``detnum`` would be ``[(1,2,3)]`` and for Keck/DEIMOS it would be ``[(1, 5), (2, 6), (3, 7), (4, 8)]`` +``ignore_bad_headers`` bool .. False Ignore bad headers (NOT recommended unless you know it is safe). +``maskIDs`` str, int, list .. .. Restrict reduction to a set of slitmask IDs Example syntax -- ``maskIDs = 818006,818015`` This must be used with detnum (for now). +``qadir`` str .. ``QA`` Directory relative to calling directory to write quality assessment files. +``quicklook`` bool .. False Run a quick look reduction? This is usually good if you want to quickly reduce the data (usually at the telescope in real time) to get an initial estimate of the data quality. +``redux_path`` str .. ``/Users/westfall/Work/packages/pypeit/doc`` Path to folder for performing reductions. Default is the current working directory. +``scidir`` str .. ``Science`` Directory relative to calling directory to write science files. +``slitspatnum`` str, list .. .. Restrict reduction to a set of slit DET:SPAT values (closest slit is used). Example syntax -- slitspatnum = DET01:175,DET01:205 or MSC02:2234 If you are re-running the code, (i.e. modifying one slit) you *must* have the precise SPAT_ID index. +``sortroot`` str .. .. A filename given to output the details of the sorted files. If None, the default is the root name of the pypeit file. If off, no output is produced. +``spectrograph`` str .. .. Spectrograph that provided the data to be reduced. See :ref:`instruments` for valid options. +====================== ============== ======= ============================================ ========================================================================================================================================================================================================================================================================================================================================================================================================== ---- diff --git a/doc/releases/1.15.1dev.rst b/doc/releases/1.15.1dev.rst index 6adada653b..4d1f780320 100644 --- a/doc/releases/1.15.1dev.rst +++ b/doc/releases/1.15.1dev.rst @@ -8,6 +8,8 @@ Installation Changes Dependency Changes ------------------ +- PypeIt now only supports python versions 3.10 or later + Functionality/Performance Improvements and Additions ---------------------------------------------------- diff --git a/setup.cfg b/setup.cfg index 5e57b0d31d..cdf123c4a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,8 +17,9 @@ classifiers = Natural Language :: English Operating System :: OS Independent Programming Language :: Python - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Topic :: Documentation :: Sphinx Topic :: Scientific/Engineering :: Astronomy Topic :: Software Development :: Libraries :: Python Modules @@ -28,7 +29,7 @@ classifiers = zip_safe = False use_2to3=False packages = find: -python_requires = >=3.9,<3.12 +python_requires = >=3.10,<3.13 setup_requires = setuptools_scm include_package_data = True install_requires = diff --git a/tox.ini b/tox.ini index f568605e74..55bbe46e07 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist = - {3.9,3.10,3.11}-test{,-alldeps,-shapely,-specutils}{,-cov} - {3.9,3.10,3.11}-test-numpy{122,123,124,125} - {3.9,3.10,3.11}-test-{numpy,astropy,linetools,ginga}dev + {3.10,3.11,3.12}-test{,-alldeps,-shapely,-specutils}{,-cov} + {3.10,3.11,3.12}-test-numpy{123,124,125,126} + {3.10,3.11,3.12}-test-{numpy,astropy,linetools,ginga}dev codestyle requires = setuptools >= 30.3.0 @@ -36,19 +36,19 @@ description = devdeps: with the latest developer version of key dependencies oldestdeps: with the oldest supported version of key dependencies cov: and test coverage - numpy122: with numpy 1.22.* numpy123: with numpy 1.23.* numpy124: with numpy 1.24.* numpy125: with numpy 1.25.* + numpy126: with numpy 1.26.* # The following provides some specific pinnings for key packages deps = cov: coverage - numpy122: numpy==1.22.* numpy123: numpy==1.23.* numpy124: numpy==1.24.* numpy125: numpy==1.25.* + numpy126: numpy==1.26.* numpydev: numpy>=0.0.dev0 astropydev: git+https://github.com/astropy/astropy.git#egg=astropy From 067bb417c3b5a9d44b2713ce768e7929a4a40668 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 18 Mar 2024 07:58:59 -0700 Subject: [PATCH 2/6] bump numpy --- doc/releases/1.15.1dev.rst | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/releases/1.15.1dev.rst b/doc/releases/1.15.1dev.rst index 4d1f780320..6477b47fd4 100644 --- a/doc/releases/1.15.1dev.rst +++ b/doc/releases/1.15.1dev.rst @@ -8,7 +8,7 @@ Installation Changes Dependency Changes ------------------ -- PypeIt now only supports python versions 3.10 or later +- PypeIt now only supports python versions 3.10 or later, and numpy version 1.23 and later Functionality/Performance Improvements and Additions ---------------------------------------------------- diff --git a/setup.cfg b/setup.cfg index cdf123c4a4..9311f2da03 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ python_requires = >=3.10,<3.13 setup_requires = setuptools_scm include_package_data = True install_requires = - numpy>=1.22 + numpy>=1.23 astropy>=4.3 extension-helpers>=0.1 packaging>=0.19 From ee4cc7aa421daef5f7cd4a22dee769d1963e7430 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 18 Mar 2024 11:11:52 -0700 Subject: [PATCH 3/6] fix importlib issue --- pypeit/display/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pypeit/display/__init__.py b/pypeit/display/__init__.py index 3ddda10da3..1e65b4f696 100644 --- a/pypeit/display/__init__.py +++ b/pypeit/display/__init__.py @@ -11,11 +11,13 @@ def plugins_available(return_report=False): available_plugins = [] - # TODO: metadata.entry_points(group='ginga.rv.plugins') doesn't work in python3.9!! - for entry_point in metadata.entry_points()['ginga.rv.plugins']: + # WARNING: + # - metadata.entry_points(group='ginga.rv.plugins') doesn't work in python3.9 + # - and metadata.entry_points()['ginga.rv.plugins'] doesn't work in python3.12 + for entry_point in metadata.entry_points(group='ginga.rv.plugins'): spec = entry_point.load()() available_plugins += [spec.get('name', spec.get('menu', - spec.get('klass', spec.get('module'))))] + spec.get('klass', spec.get('module'))))] indx = numpy.isin(required_plugins, available_plugins) result = (numpy.all(indx),) if return_report: From 5bb9d0c04d28be27454a59033e2733508d31a2a6 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 18 Mar 2024 11:21:47 -0700 Subject: [PATCH 4/6] handle other deprecations --- pypeit/bspline/setup_package.py | 2 +- pypeit/calibrations.py | 2 +- pypeit/inputfiles.py | 2 +- pypeit/pypeit.py | 2 +- pypeit/pypmsgs.py | 2 +- pypeit/setup_gui/controller.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pypeit/bspline/setup_package.py b/pypeit/bspline/setup_package.py index 80b7111dd6..415759c0c1 100644 --- a/pypeit/bspline/setup_package.py +++ b/pypeit/bspline/setup_package.py @@ -2,7 +2,7 @@ import sys import tempfile, subprocess, shutil -from distutils.extension import Extension +from setuptools import Extension # the most reliable way to check for openmp support in the C compiler is to try to build # some test code with the -fopenmp flag. openmp provides a big performance boost, but some diff --git a/pypeit/calibrations.py b/pypeit/calibrations.py index 07f15a32cf..b0539623cc 100644 --- a/pypeit/calibrations.py +++ b/pypeit/calibrations.py @@ -1334,7 +1334,7 @@ def association_summary(ofile, fitstbl, spectrograph, caldir, subset=None, det=N with open(_ofile, 'w') as ff: ff.write('# Auto-generated calibration association file using PypeIt version: ' f' {__version__}\n') - ff.write(f'# UTC {datetime.utcnow().isoformat(timespec="milliseconds")}\n') + ff.write(f'# UTC {datetime.now(datetime.UTC).isoformat(timespec="milliseconds")}\n') if det is None: ff.write(f'# NOTE: {detname} is a placeholder for the reduced detectors/mosaics\n') ff.write(yaml.dump(utils.yamlify(asn))) diff --git a/pypeit/inputfiles.py b/pypeit/inputfiles.py index 332822081f..8d12443a4b 100644 --- a/pypeit/inputfiles.py +++ b/pypeit/inputfiles.py @@ -520,7 +520,7 @@ def write(self, input_file, version_override=None, date_override=None): documentation purposes only!** """ _version = __version__ if version_override is None else version_override - _date = datetime.utcnow().isoformat(timespec='milliseconds') \ + _date = datetime.now(datetime.UTC).isoformat(timespec='milliseconds') \ if date_override is None else date_override # Here we go diff --git a/pypeit/pypeit.py b/pypeit/pypeit.py index cb199c91f5..10ee070d1d 100644 --- a/pypeit/pypeit.py +++ b/pypeit/pypeit.py @@ -111,7 +111,7 @@ def __init__(self, pypeit_file, verbosity=2, overwrite=True, reuse_calibs=False, # Write the full parameter set here # -------------------------------------------------------------- par_file = pypeit_file.replace( - '.pypeit', f"_UTC_{datetime.datetime.utcnow().date()}.par") + '.pypeit', f"_UTC_{datetime.datetime.now(datetime.UTC).date()}.par") self.par.to_config(par_file, include_descr=False) # -------------------------------------------------------------- diff --git a/pypeit/pypmsgs.py b/pypeit/pypmsgs.py index 36caf265b4..5f61d14ecc 100644 --- a/pypeit/pypmsgs.py +++ b/pypeit/pypmsgs.py @@ -407,7 +407,7 @@ def set_logfile_and_verbosity(self, scriptname, verbosity): Verbosity level between 0 [none] and 2 [all] """ # Create a UT timestamp (to the minute) for the log filename - timestamp = datetime.datetime.utcnow().strftime("%Y%m%d-%H%M") + timestamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d-%H%M") # Create a logfile only if verbosity == 2 logname = f"{scriptname}_{timestamp}.log" if verbosity == 2 else None # Set the verbosity in msgs diff --git a/pypeit/setup_gui/controller.py b/pypeit/setup_gui/controller.py index a127c18137..89fc5c8728 100644 --- a/pypeit/setup_gui/controller.py +++ b/pypeit/setup_gui/controller.py @@ -593,7 +593,7 @@ def __init__(self, args): if args.logfile is not None: logpath = Path(args.logfile) if logpath.exists(): - timestamp = datetime.datetime.utcnow().strftime("%Y%m%d-%H%M%S") + timestamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d-%H%M%S") old_log=logpath.parent / (logpath.stem + f".{timestamp}" + logpath.suffix) logpath.rename(old_log) From 15a0cc7981b9f2d37e8459ba72a471ca5a88e528 Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Mon, 18 Mar 2024 11:36:18 -0700 Subject: [PATCH 5/6] fix for 3.10 --- pypeit/calibrations.py | 10 +++++++++- pypeit/inputfiles.py | 10 +++++++++- pypeit/pypeit.py | 12 ++++++++++-- pypeit/pypmsgs.py | 14 ++++++++++---- pypeit/setup_gui/controller.py | 13 +++++++++++-- 5 files changed, 49 insertions(+), 10 deletions(-) diff --git a/pypeit/calibrations.py b/pypeit/calibrations.py index b0539623cc..4b3f24f719 100644 --- a/pypeit/calibrations.py +++ b/pypeit/calibrations.py @@ -11,6 +11,14 @@ from collections import Counter import yaml +# TODO: datetime.UTC is not defined in python 3.10. Remove this when we decide +# to no longer support it. +try: + __UTC__ = datetime.UTC +except AttributeError as e: + from datetime import timezone + __UTC__ = timezone.utc + from IPython import embed import numpy as np @@ -1334,7 +1342,7 @@ def association_summary(ofile, fitstbl, spectrograph, caldir, subset=None, det=N with open(_ofile, 'w') as ff: ff.write('# Auto-generated calibration association file using PypeIt version: ' f' {__version__}\n') - ff.write(f'# UTC {datetime.now(datetime.UTC).isoformat(timespec="milliseconds")}\n') + ff.write(f'# UTC {datetime.now(__UTC__).isoformat(timespec="milliseconds")}\n') if det is None: ff.write(f'# NOTE: {detname} is a placeholder for the reduced detectors/mosaics\n') ff.write(yaml.dump(utils.yamlify(asn))) diff --git a/pypeit/inputfiles.py b/pypeit/inputfiles.py index 8d12443a4b..ee6f4a730d 100644 --- a/pypeit/inputfiles.py +++ b/pypeit/inputfiles.py @@ -13,6 +13,14 @@ from collections.abc import Sequence import configobj +# TODO: datetime.UTC is not defined in python 3.10. Remove this when we decide +# to no longer support it. +try: + __UTC__ = datetime.UTC +except AttributeError as e: + from datetime import timezone + __UTC__ = timezone.utc + from astropy.table import Table, column from astropy.io import ascii @@ -520,7 +528,7 @@ def write(self, input_file, version_override=None, date_override=None): documentation purposes only!** """ _version = __version__ if version_override is None else version_override - _date = datetime.now(datetime.UTC).isoformat(timespec='milliseconds') \ + _date = datetime.now(__UTC__).isoformat(timespec='milliseconds') \ if date_override is None else date_override # Here we go diff --git a/pypeit/pypeit.py b/pypeit/pypeit.py index 10ee070d1d..78a33e812a 100644 --- a/pypeit/pypeit.py +++ b/pypeit/pypeit.py @@ -9,7 +9,15 @@ import time import os import copy -import datetime +from datetime import datetime + +# TODO: datetime.UTC is not defined in python 3.10. Remove this when we decide +# to no longer support it. +try: + __UTC__ = datetime.UTC +except AttributeError as e: + from datetime import timezone + __UTC__ = timezone.utc from IPython import embed @@ -111,7 +119,7 @@ def __init__(self, pypeit_file, verbosity=2, overwrite=True, reuse_calibs=False, # Write the full parameter set here # -------------------------------------------------------------- par_file = pypeit_file.replace( - '.pypeit', f"_UTC_{datetime.datetime.now(datetime.UTC).date()}.par") + '.pypeit', f"_UTC_{datetime.now(__UTC__).date()}.par") self.par.to_config(par_file, include_descr=False) # -------------------------------------------------------------- diff --git a/pypeit/pypmsgs.py b/pypeit/pypmsgs.py index 5f61d14ecc..6383dbe950 100644 --- a/pypeit/pypmsgs.py +++ b/pypeit/pypmsgs.py @@ -5,15 +5,21 @@ Why not use pythons native logging package? """ -import datetime +from datetime import datetime import sys import os import getpass -import glob -import textwrap import inspect import io +# TODO: datetime.UTC is not defined in python 3.10. Remove this when we decide +# to no longer support it. +try: + __UTC__ = datetime.UTC +except AttributeError as e: + from datetime import timezone + __UTC__ = timezone.utc + # Imported for versioning import scipy import numpy @@ -407,7 +413,7 @@ def set_logfile_and_verbosity(self, scriptname, verbosity): Verbosity level between 0 [none] and 2 [all] """ # Create a UT timestamp (to the minute) for the log filename - timestamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d-%H%M") + timestamp = datetime.now(__UTC__).strftime("%Y%m%d-%H%M") # Create a logfile only if verbosity == 2 logname = f"{scriptname}_{timestamp}.log" if verbosity == 2 else None # Set the verbosity in msgs diff --git a/pypeit/setup_gui/controller.py b/pypeit/setup_gui/controller.py index 89fc5c8728..8e2d8643e6 100644 --- a/pypeit/setup_gui/controller.py +++ b/pypeit/setup_gui/controller.py @@ -7,12 +7,21 @@ import traceback import signal import sys -import datetime +from datetime import datetime import re import io from pathlib import Path from functools import partial from contextlib import contextmanager + +# TODO: datetime.UTC is not defined in python 3.10. Remove this when we decide +# to no longer support it. +try: + __UTC__ = datetime.UTC +except AttributeError as e: + from datetime import timezone + __UTC__ = timezone.utc + from qtpy.QtCore import QCoreApplication, Signal, QMutex from qtpy.QtCore import QObject, Qt, QThread from qtpy.QtGui import QKeySequence @@ -593,7 +602,7 @@ def __init__(self, args): if args.logfile is not None: logpath = Path(args.logfile) if logpath.exists(): - timestamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%d-%H%M%S") + timestamp = datetime.now(__UTC__).strftime("%Y%m%d-%H%M%S") old_log=logpath.parent / (logpath.stem + f".{timestamp}" + logpath.suffix) logpath.rename(old_log) From de9010f9dcdf11738631e97b665ac810328b2b3f Mon Sep 17 00:00:00 2001 From: Kyle Westfall Date: Thu, 21 Mar 2024 14:19:45 -0700 Subject: [PATCH 6/6] ginga version --- pypeit/core/wavecal/autoid.py | 1 + setup.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pypeit/core/wavecal/autoid.py b/pypeit/core/wavecal/autoid.py index fcd00cd5d2..1206caab27 100644 --- a/pypeit/core/wavecal/autoid.py +++ b/pypeit/core/wavecal/autoid.py @@ -582,6 +582,7 @@ def reidentify(spec, spec_arxiv_in, wave_soln_arxiv_in, line_list, success, shift_vec[iarxiv], stretch_vec[iarxiv], ccorr_vec[iarxiv], _, _ = \ wvutils.xcorr_shift_stretch(use_spec, use_spec_arxiv[:, iarxiv], sigdetect=sigdetect, lag_range=cc_shift_range, cc_thresh=cc_thresh, fwhm=fwhm, seed=random_state, +# stretch_mnmx=(0.99,1.01), debug=debug_xcorr) msgs.info(f'shift = {shift_vec[iarxiv]:5.3f}, stretch = {stretch_vec[iarxiv]:5.3f}, cc = {ccorr_vec[iarxiv]:5.3f}') # If cc < cc_thresh or if this optimization failed, don't reidentify from this arxiv spectrum diff --git a/setup.cfg b/setup.cfg index 9311f2da03..ffcb732fa2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,7 +45,7 @@ install_requires = configobj>=5.0.6 scikit-learn>=1.0 IPython>=7.10.0 - ginga>=4.1.1 + ginga==4.1.1 linetools>=0.3.1 qtpy>=2.0.1 pygithub