pandoraref 0.1.0__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.
- pandoraref-0.1.0/LICENSE +21 -0
- pandoraref-0.1.0/PKG-INFO +147 -0
- pandoraref-0.1.0/README.md +126 -0
- pandoraref-0.1.0/pyproject.toml +47 -0
- pandoraref-0.1.0/src/pandoraref/__init__.py +51 -0
- pandoraref-0.1.0/src/pandoraref/data/external/fov_distortion.csv +442 -0
- pandoraref-0.1.0/src/pandoraref/data/external/vega.csv +9167 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/badpix.fits +36 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/bias.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/dark.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/flat.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/gain.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/nonlin.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/pixel_position.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/qe.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/readnoise.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/sip.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/throughput.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/nirda/wcs.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/badpix.fits +36 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/bias.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/dark.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/flat.fits +0 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/gain.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/nonlin.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/qe.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/readnoise.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/sip.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/throughput.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/data/visda/wcs.fits +1 -0
- pandoraref-0.1.0/src/pandoraref/dummy.py +612 -0
- pandoraref-0.1.0/src/pandoraref/ref.py +357 -0
- pandoraref-0.1.0/src/pandoraref/wcs.py +222 -0
pandoraref-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pandora Data Processing Center
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pandoraref
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Author: Christina Hedges
|
|
6
|
+
Author-email: christina.l.hedges@nasa.gov
|
|
7
|
+
Requires-Python: >=3.9,<3.13
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Dist: appdirs (>=1.4.4,<2.0.0)
|
|
14
|
+
Requires-Dist: astropy (>=6.0.0)
|
|
15
|
+
Requires-Dist: numpy (>=1.2)
|
|
16
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
17
|
+
Requires-Dist: pandorasat (>=0.11.0)
|
|
18
|
+
Requires-Dist: rich (>=13.9.4,<14.0.0)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Pandora Reference [WIP]
|
|
22
|
+
|
|
23
|
+
This package is a repository to hold reference data for the Pandora SmallSat data processing. This repository is **only used to store the current best reference products** for Pandora data processing. Rolling back to previous versions of this package will roll back to previous versions of reference products. All processed products will contain a version number of this package, which links to specific versions of processing files. At any given version number there is a single version of each file.
|
|
24
|
+
|
|
25
|
+
Follow this README strictly when updating products.
|
|
26
|
+
|
|
27
|
+
## Updating any number of reference products
|
|
28
|
+
|
|
29
|
+
If you are going to update reference products for Pandora processing you must follow these steps.
|
|
30
|
+
|
|
31
|
+
1. Clone this repository, if you do not already have a copy
|
|
32
|
+
2. Ensure the repository is up to date (`git pull`)
|
|
33
|
+
3. Go to the specific product within `src/pandoraref/data/` that you wish to update.
|
|
34
|
+
|
|
35
|
+
- Verify that your new product is compliant with the fits file format of the original product. (Note: If you change the format (e.g. add or remove headers or extensions), you must update the minor version number of this package.)
|
|
36
|
+
- Ensure your new product has an incremented version number in the header, compared to the old product.
|
|
37
|
+
- If you are changing the file name, ensure the new product follows the file naming convention.
|
|
38
|
+
|
|
39
|
+
4. Replace the file in the `src/pandoraref/data/`.
|
|
40
|
+
5. Where appropriate, update the README for each file.
|
|
41
|
+
6. In this modules `__init__.py` file, ensure that the product name is correct in the loading class. If you have added a new file or changed a name, make sure to update the class.
|
|
42
|
+
7. In this modules `pyproject.py` file update the version number. Follow this convention
|
|
43
|
+
|
|
44
|
+
- Updating information within this package (e.g. readmes, docstrings): update patch number
|
|
45
|
+
- Updating data within files, but not changing any file structure: update patch number
|
|
46
|
+
- Updating data and changing the file structure (e.g. adding or removing headers or extensions): update minor version number
|
|
47
|
+
- Adding or removing data products entirely: update major version number
|
|
48
|
+
|
|
49
|
+
8. Update the CHANGELOG for this package.
|
|
50
|
+
|
|
51
|
+
You may update multiple data products at once, but if you make any changes to this repository you must update the version number of this package.
|
|
52
|
+
|
|
53
|
+
### Versioning
|
|
54
|
+
|
|
55
|
+
Version numbers appear in two places:
|
|
56
|
+
|
|
57
|
+
1. Each file should have its own, consistent version number. If you update a flat field, you should increment the version number in that file.
|
|
58
|
+
2. The package itself represents the full assembly of the reference data products. If any files within the system change, this must be incremented.
|
|
59
|
+
|
|
60
|
+
When processing Pandora data, refer to the `pandora-ref` package number that was used when processing, so that your processing is reproducible using the same exact set of reference files.
|
|
61
|
+
|
|
62
|
+
If a file has a version name `dummy` this means this is a file that is for format definition only, and is not meant to be used in practice. `dummy` files should still be in the correct format, and should have data in them so that they can be applied (e.g. a flat field of 1's, a bias value of 0) but they should not contain any real information or expectations.
|
|
63
|
+
|
|
64
|
+
## Contents
|
|
65
|
+
|
|
66
|
+
For any given version number this package will have a single file for at least these files for both Pandora detectors
|
|
67
|
+
|
|
68
|
+
- Flat field
|
|
69
|
+
- Bias image
|
|
70
|
+
- Dark image
|
|
71
|
+
- Gain setting
|
|
72
|
+
- Read noise estimates
|
|
73
|
+
- Bad pixel map
|
|
74
|
+
- Non linearity curve
|
|
75
|
+
- PSF model
|
|
76
|
+
- WCS parameters
|
|
77
|
+
- WCS distortion
|
|
78
|
+
- Quantum Efficiency
|
|
79
|
+
- Throughput
|
|
80
|
+
|
|
81
|
+
For NIRDA only there will be a single file for
|
|
82
|
+
|
|
83
|
+
- Wavelength as a function of pixel position (as measured)
|
|
84
|
+
|
|
85
|
+
### Future contents
|
|
86
|
+
|
|
87
|
+
It's expected that this repository will eventually include some number of SPICE kernels, and potentially will download and store locally the most recent SPICE kernels for the mission.
|
|
88
|
+
|
|
89
|
+
## Usage
|
|
90
|
+
|
|
91
|
+
If you use this package as a dependency to process data, follow these guidelines:
|
|
92
|
+
|
|
93
|
+
**I want to have my processing be reproducible**
|
|
94
|
+
|
|
95
|
+
In this case you should set the dependency to a specific stable version of `pandora-ref`. In any product you make you should specify the exact version number of `pandora-ref` you use.
|
|
96
|
+
|
|
97
|
+
**I want to have my processing have the best possible reference data**
|
|
98
|
+
|
|
99
|
+
In this case you should set the dependency to a specific major and minor versino of `pandora-ref`, but you can enable any patch number and pull the latest patches any time you run. You should keep any eye out for major or minor package version updates. In the case that there is a major or minor version update you should pull these updates, but you may need to update your code base as the file structures may have changed or new files may have been added. In any product you make you should specify the exact version number of `pandora-ref` you use.
|
|
100
|
+
|
|
101
|
+
### Installing and importing this package
|
|
102
|
+
|
|
103
|
+
You can install this package with pip. Once you install it as a dependency you will have the reference files installed locally. You can then find each file using the reference path objects:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from pandoraref import NIRDAReference
|
|
107
|
+
nirdaref = NIRDAReference()
|
|
108
|
+
|
|
109
|
+
nirdaref.flat_file
|
|
110
|
+
nirdaref.badpix_file
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
These will each return strings. You can open the files astropy's FITS module
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from pandoraref import NIRDAReference
|
|
117
|
+
from astropy.io import fits
|
|
118
|
+
nirdaref = NIRDAReference()
|
|
119
|
+
|
|
120
|
+
with fits.open(nirdaref.flat_file) as hdulist:
|
|
121
|
+
print(hdulist[0].header['VERSION'])
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Function naming
|
|
125
|
+
|
|
126
|
+
In this package (and all packages) names matter. We follow this naming convention wherever we can:
|
|
127
|
+
|
|
128
|
+
- Lower case noun is a property, e.g. `flat_file` is a property which is a string
|
|
129
|
+
- Lower case verb and then noun is a function e.g. `get_flat_file` would be a function
|
|
130
|
+
|
|
131
|
+
Certain verbs imply actions:
|
|
132
|
+
|
|
133
|
+
- `get_` implies retrieve and return an object. e.g. `get_wcs` will retrieve a WCS from storage and return that object.
|
|
134
|
+
- `create_` implies it will generatea new object, rather than `get`ting one from file e.g. `create_wcs` will create a new WCS solution from scratch
|
|
135
|
+
|
|
136
|
+
## What should be stored in this package?
|
|
137
|
+
|
|
138
|
+
This package is **not** the place to put codes, processes or data that **generates** reference data products.
|
|
139
|
+
|
|
140
|
+
This package is to
|
|
141
|
+
|
|
142
|
+
1. Store current best estimates of reference products
|
|
143
|
+
2. Hold functions to **convert** between data between other formats and the expected RDP format. (e.g. if LLNL provided a distortion file as a csv it is allowable to store that CSV and have a function to **convert** it to an expected fits file.)
|
|
144
|
+
3. Hold functions to return versions of RDPs under specific conditions. For example, a function to give the WCS RDP given an expected pointing.
|
|
145
|
+
|
|
146
|
+
Do not store calibration data or any generation scripts here.
|
|
147
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Pandora Reference [WIP]
|
|
2
|
+
|
|
3
|
+
This package is a repository to hold reference data for the Pandora SmallSat data processing. This repository is **only used to store the current best reference products** for Pandora data processing. Rolling back to previous versions of this package will roll back to previous versions of reference products. All processed products will contain a version number of this package, which links to specific versions of processing files. At any given version number there is a single version of each file.
|
|
4
|
+
|
|
5
|
+
Follow this README strictly when updating products.
|
|
6
|
+
|
|
7
|
+
## Updating any number of reference products
|
|
8
|
+
|
|
9
|
+
If you are going to update reference products for Pandora processing you must follow these steps.
|
|
10
|
+
|
|
11
|
+
1. Clone this repository, if you do not already have a copy
|
|
12
|
+
2. Ensure the repository is up to date (`git pull`)
|
|
13
|
+
3. Go to the specific product within `src/pandoraref/data/` that you wish to update.
|
|
14
|
+
|
|
15
|
+
- Verify that your new product is compliant with the fits file format of the original product. (Note: If you change the format (e.g. add or remove headers or extensions), you must update the minor version number of this package.)
|
|
16
|
+
- Ensure your new product has an incremented version number in the header, compared to the old product.
|
|
17
|
+
- If you are changing the file name, ensure the new product follows the file naming convention.
|
|
18
|
+
|
|
19
|
+
4. Replace the file in the `src/pandoraref/data/`.
|
|
20
|
+
5. Where appropriate, update the README for each file.
|
|
21
|
+
6. In this modules `__init__.py` file, ensure that the product name is correct in the loading class. If you have added a new file or changed a name, make sure to update the class.
|
|
22
|
+
7. In this modules `pyproject.py` file update the version number. Follow this convention
|
|
23
|
+
|
|
24
|
+
- Updating information within this package (e.g. readmes, docstrings): update patch number
|
|
25
|
+
- Updating data within files, but not changing any file structure: update patch number
|
|
26
|
+
- Updating data and changing the file structure (e.g. adding or removing headers or extensions): update minor version number
|
|
27
|
+
- Adding or removing data products entirely: update major version number
|
|
28
|
+
|
|
29
|
+
8. Update the CHANGELOG for this package.
|
|
30
|
+
|
|
31
|
+
You may update multiple data products at once, but if you make any changes to this repository you must update the version number of this package.
|
|
32
|
+
|
|
33
|
+
### Versioning
|
|
34
|
+
|
|
35
|
+
Version numbers appear in two places:
|
|
36
|
+
|
|
37
|
+
1. Each file should have its own, consistent version number. If you update a flat field, you should increment the version number in that file.
|
|
38
|
+
2. The package itself represents the full assembly of the reference data products. If any files within the system change, this must be incremented.
|
|
39
|
+
|
|
40
|
+
When processing Pandora data, refer to the `pandora-ref` package number that was used when processing, so that your processing is reproducible using the same exact set of reference files.
|
|
41
|
+
|
|
42
|
+
If a file has a version name `dummy` this means this is a file that is for format definition only, and is not meant to be used in practice. `dummy` files should still be in the correct format, and should have data in them so that they can be applied (e.g. a flat field of 1's, a bias value of 0) but they should not contain any real information or expectations.
|
|
43
|
+
|
|
44
|
+
## Contents
|
|
45
|
+
|
|
46
|
+
For any given version number this package will have a single file for at least these files for both Pandora detectors
|
|
47
|
+
|
|
48
|
+
- Flat field
|
|
49
|
+
- Bias image
|
|
50
|
+
- Dark image
|
|
51
|
+
- Gain setting
|
|
52
|
+
- Read noise estimates
|
|
53
|
+
- Bad pixel map
|
|
54
|
+
- Non linearity curve
|
|
55
|
+
- PSF model
|
|
56
|
+
- WCS parameters
|
|
57
|
+
- WCS distortion
|
|
58
|
+
- Quantum Efficiency
|
|
59
|
+
- Throughput
|
|
60
|
+
|
|
61
|
+
For NIRDA only there will be a single file for
|
|
62
|
+
|
|
63
|
+
- Wavelength as a function of pixel position (as measured)
|
|
64
|
+
|
|
65
|
+
### Future contents
|
|
66
|
+
|
|
67
|
+
It's expected that this repository will eventually include some number of SPICE kernels, and potentially will download and store locally the most recent SPICE kernels for the mission.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
If you use this package as a dependency to process data, follow these guidelines:
|
|
72
|
+
|
|
73
|
+
**I want to have my processing be reproducible**
|
|
74
|
+
|
|
75
|
+
In this case you should set the dependency to a specific stable version of `pandora-ref`. In any product you make you should specify the exact version number of `pandora-ref` you use.
|
|
76
|
+
|
|
77
|
+
**I want to have my processing have the best possible reference data**
|
|
78
|
+
|
|
79
|
+
In this case you should set the dependency to a specific major and minor versino of `pandora-ref`, but you can enable any patch number and pull the latest patches any time you run. You should keep any eye out for major or minor package version updates. In the case that there is a major or minor version update you should pull these updates, but you may need to update your code base as the file structures may have changed or new files may have been added. In any product you make you should specify the exact version number of `pandora-ref` you use.
|
|
80
|
+
|
|
81
|
+
### Installing and importing this package
|
|
82
|
+
|
|
83
|
+
You can install this package with pip. Once you install it as a dependency you will have the reference files installed locally. You can then find each file using the reference path objects:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from pandoraref import NIRDAReference
|
|
87
|
+
nirdaref = NIRDAReference()
|
|
88
|
+
|
|
89
|
+
nirdaref.flat_file
|
|
90
|
+
nirdaref.badpix_file
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
These will each return strings. You can open the files astropy's FITS module
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from pandoraref import NIRDAReference
|
|
97
|
+
from astropy.io import fits
|
|
98
|
+
nirdaref = NIRDAReference()
|
|
99
|
+
|
|
100
|
+
with fits.open(nirdaref.flat_file) as hdulist:
|
|
101
|
+
print(hdulist[0].header['VERSION'])
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Function naming
|
|
105
|
+
|
|
106
|
+
In this package (and all packages) names matter. We follow this naming convention wherever we can:
|
|
107
|
+
|
|
108
|
+
- Lower case noun is a property, e.g. `flat_file` is a property which is a string
|
|
109
|
+
- Lower case verb and then noun is a function e.g. `get_flat_file` would be a function
|
|
110
|
+
|
|
111
|
+
Certain verbs imply actions:
|
|
112
|
+
|
|
113
|
+
- `get_` implies retrieve and return an object. e.g. `get_wcs` will retrieve a WCS from storage and return that object.
|
|
114
|
+
- `create_` implies it will generatea new object, rather than `get`ting one from file e.g. `create_wcs` will create a new WCS solution from scratch
|
|
115
|
+
|
|
116
|
+
## What should be stored in this package?
|
|
117
|
+
|
|
118
|
+
This package is **not** the place to put codes, processes or data that **generates** reference data products.
|
|
119
|
+
|
|
120
|
+
This package is to
|
|
121
|
+
|
|
122
|
+
1. Store current best estimates of reference products
|
|
123
|
+
2. Hold functions to **convert** between data between other formats and the expected RDP format. (e.g. if LLNL provided a distortion file as a csv it is allowable to store that CSV and have a function to **convert** it to an expected fits file.)
|
|
124
|
+
3. Hold functions to return versions of RDPs under specific conditions. For example, a function to give the WCS RDP given an expected pointing.
|
|
125
|
+
|
|
126
|
+
Do not store calibration data or any generation scripts here.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pandoraref"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Christina Hedges",email = "christina.l.hedges@nasa.gov"}
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.9,<3.13"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"rich (>=13.9.4,<14.0.0)",
|
|
12
|
+
"numpy (>=1.2)",
|
|
13
|
+
"pandas (>=2.2.3,<3.0.0)",
|
|
14
|
+
"appdirs (>=1.4.4,<2.0.0)",
|
|
15
|
+
"astropy (>=6.0.0)",
|
|
16
|
+
"pandorasat (>=0.11.0)"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.poetry]
|
|
20
|
+
packages = [{include = "pandoraref", from = "src"}]
|
|
21
|
+
|
|
22
|
+
[tool.poetry.group.dev]
|
|
23
|
+
optional = true
|
|
24
|
+
|
|
25
|
+
[tool.poetry.group.dev.dependencies]
|
|
26
|
+
pytest = "^8.3.4"
|
|
27
|
+
black = "^25.1.0"
|
|
28
|
+
isort = "^6.0.0"
|
|
29
|
+
flake8 = "^7.1.2"
|
|
30
|
+
jupyterlab = "^4.4.3"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
34
|
+
build-backend = "poetry.core.masonry.api"
|
|
35
|
+
|
|
36
|
+
[tool.black]
|
|
37
|
+
line-length = 79
|
|
38
|
+
|
|
39
|
+
[tool.isort]
|
|
40
|
+
import_heading_firstparty = 'First-party/Local'
|
|
41
|
+
import_heading_future = 'Future'
|
|
42
|
+
import_heading_stdlib = 'Standard library'
|
|
43
|
+
import_heading_thirdparty = 'Third-party'
|
|
44
|
+
line_length = 79
|
|
45
|
+
multi_line_output = 3
|
|
46
|
+
no_lines_before = 'LOCALFOLDER'
|
|
47
|
+
profile = 'black'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Standard library
|
|
2
|
+
import logging # noqa: E402
|
|
3
|
+
import os # noqa
|
|
4
|
+
|
|
5
|
+
# Third-party
|
|
6
|
+
from rich.console import Console # noqa: E402
|
|
7
|
+
from rich.logging import RichHandler # noqa: E402
|
|
8
|
+
|
|
9
|
+
PACKAGEDIR = os.path.abspath(os.path.dirname(__file__))
|
|
10
|
+
TESTDIR = "/".join(PACKAGEDIR.split("/")[:-2]) + "/tests/"
|
|
11
|
+
|
|
12
|
+
# Standard library
|
|
13
|
+
from importlib.metadata import PackageNotFoundError, version # noqa
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_version():
|
|
17
|
+
try:
|
|
18
|
+
return version("pandoraref")
|
|
19
|
+
except PackageNotFoundError:
|
|
20
|
+
return "unknown"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__version__ = get_version()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Custom Logger with Rich
|
|
27
|
+
class PandoraLogger(logging.Logger):
|
|
28
|
+
def __init__(self, name, level=logging.INFO):
|
|
29
|
+
super().__init__(name, level)
|
|
30
|
+
console = Console()
|
|
31
|
+
self.handler = RichHandler(
|
|
32
|
+
show_time=False, show_level=False, show_path=False, console=console
|
|
33
|
+
)
|
|
34
|
+
self.handler.setFormatter(
|
|
35
|
+
logging.Formatter(
|
|
36
|
+
"%(asctime)s %(levelname)s: %(message)s",
|
|
37
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
self.addHandler(self.handler)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_logger(name="pandoraref"):
|
|
44
|
+
"""Configure and return a logger with RichHandler."""
|
|
45
|
+
return PandoraLogger(name)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
logger = get_logger("pandoraref")
|
|
49
|
+
|
|
50
|
+
from .dummy import create_dummy_reference_products # noqa
|
|
51
|
+
from .ref import * # noqa
|