You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/spherex/spherex_psf.md
+25-47Lines changed: 25 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,42 +228,20 @@ For more information about these changes, see the following webpage: [PSF Erratu
228
228
229
229
Let's first check here if a header update is necessary. We can do that by printing the `VERSION` keyword in the header.
230
230
231
-
For comparisons versions, we can use the Python-internal `Version()` function from the `packaging.version` package. However, since reprocessed images can have version names such as `6.5.4+psffix1` (which are superior to `6.5.4`, for example), we have to write a little wrapper function such that `Version()` can interpret these correctly.
231
+
For comparing versions, we can use the Python-internal `Version()` function from the `packaging.version` package. Images that have already been reprocessed can have version names such as `6.5.4+psffix1` (which are superior to `6.5.4`, for example), and we can use `Version().local` to check for those.
232
232
233
233
```{code-cell} ipython3
234
-
def parse_version(v):
235
-
# detect modifiers
236
-
modifier = None
237
-
base = v
238
-
239
-
if "+" in v:
240
-
base, modifier = v.split("+", 1)
241
-
242
-
base_version = Version(base)
243
-
244
-
if modifier is None:
245
-
return (0, base_version, 0)
246
-
247
-
# extract numeric part if present
248
-
m = re.search(r'\d+', modifier)
249
-
modnum = int(m.group()) if m else 0
250
-
251
-
return (1, base_version, modnum)
252
-
```
253
-
254
-
Now, we can use this function to properly compare versions.
contains_psffix1 = this_version.local is not None and "psffix1" in this_version.local
258
236
print(f"Current version is {this_version}")
259
237
260
-
if this_version <= parse_version("6.5.5"):
238
+
if this_version <= Version("6.5.5") and not contains_psffix1:
261
239
print("PSF header needs to be updated! -> Go to Section 5.1 :(")
262
240
else:
263
241
print("PSF header is already up-to-date! -> Proceed to Section 6 :)")
264
242
```
265
243
266
-
If the version of the SPHEREx spectral image is less or equal than `6.5.5`, we will have to update the header. This is explained in Section 5.1. If the version is later than `6.5.5`, the header is already updated and the PSF issue is fixed. In this case, proceed to Section 6 directly.
244
+
If the version of the SPHEREx spectral image is less or equal than `6.5.5` and hasn't already been reprocessed, we will have to update the header. This is explained in Section 5.1. If the version is later than `6.5.5` or includes `"psffix1"`, the header is already updated and the PSF issue is fixed. In this case, proceed to Section 6 directly.
0 commit comments