Skip to content

Commit

Permalink
update packages and fix CI (#518)
Browse files Browse the repository at this point in the history
* sep_pjw

* update precommit

* gitignore

* update various packages

* run poetry update

* ruff notebooks

* add 3.12 to test
  • Loading branch information
ismael-mendoza authored Jan 15, 2025
1 parent 021e4ec commit 7675940
Show file tree
Hide file tree
Showing 10 changed files with 1,901 additions and 1,768 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout github repo
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
/dist/
/docs/build
/data/cache
Dockerfile
.devcontainer
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ^.*fits
Expand All @@ -15,7 +15,7 @@ repos:
exclude: ^.*fits

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.1
hooks:
- id: nbstripout
args:
Expand Down
2 changes: 1 addition & 1 deletion btk/deblend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Dict, List, Optional, Tuple, Union

import numpy as np
import sep
import sep_pjw as sep
from astropy import units
from astropy.coordinates import SkyCoord
from astropy.table import Table
Expand Down
2 changes: 1 addition & 1 deletion btk/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import galsim
import numpy as np
import sep
import sep_pjw as sep
from galsim import GSObject


Expand Down
2 changes: 1 addition & 1 deletion notebooks/01-advanced-deblending.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"plt.imshow(blend_batch.blend_images[3, 2, :, :], cmap=\"gray\")\n",
"\n",
"# plot centers of truth\n",
"plt.scatter(blend_batch.catalog_list[3][\"x_peak\"], blend_batch.catalog_list[3][\"y_peak\"], \n",
"plt.scatter(blend_batch.catalog_list[3][\"x_peak\"], blend_batch.catalog_list[3][\"y_peak\"],\n",
" c=\"r\", marker=\"x\", label=\"targets\")\n",
"\n",
"# plot centers of prediction\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/01-advanced-generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
"from btk.catalog import CosmosCatalog\n",
"\n",
"cosmos_files = [\n",
"\"../data/cosmos/real_galaxy_catalog_23.5_example.fits\", \n",
"\"../data/cosmos/real_galaxy_catalog_23.5_example.fits\",\n",
"\"../data/cosmos/real_galaxy_catalog_23.5_example_fits.fits\"\n",
"]\n",
"\n",
Expand Down
18 changes: 9 additions & 9 deletions notebooks/02-advanced-plots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"plt.imshow(blend_batch.blend_images[ii, 2, :, :], cmap=\"gray\")\n",
"\n",
"# plot centers\n",
"plt.scatter(blend_batch.catalog_list[ii][\"x_peak\"], \n",
"plt.scatter(blend_batch.catalog_list[ii][\"x_peak\"],\n",
" blend_batch.catalog_list[ii][\"y_peak\"], c=\"r\", marker=\"x\")"
]
},
Expand Down Expand Up @@ -423,7 +423,7 @@
"r, c = mat1.shape\n",
"_mat1[:r, :c] = mat1[:, :]\n",
"\n",
"# plot \n",
"# plot\n",
"im1 = ax1.imshow(_mat1, vmin=0, vmax=1, cmap='binary')\n",
"im2 = ax2.imshow(_mat2, vmin=0, vmax=1, cmap='binary')\n",
"\n",
Expand All @@ -435,7 +435,7 @@
"\n",
"ax1.set_yticks([0, 1, 2, 3, 4, 5, 6])\n",
"ax2.set_yticks([0, 1, 2, 3, 4, 5, 6])\n",
"ax2.set_xticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); "
"ax2.set_xticks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);"
]
},
{
Expand Down Expand Up @@ -574,7 +574,7 @@
"# join data from all batches into single array\n",
"\n",
"# sep\n",
"all_sep = {'mse': np.array([]), 'psnr': np.array([]), 'ssim': np.array([])} \n",
"all_sep = {'mse': np.array([]), 'psnr': np.array([]), 'ssim': np.array([])}\n",
"for metric_name, metric in metrics_sep.items():\n",
" for mvalues in metric.all_data:\n",
" all_sep[metric_name] = np.concatenate([all_sep[metric_name], mvalues[metric_name]])\n",
Expand Down Expand Up @@ -610,15 +610,15 @@
}
],
"source": [
"# plot histograms of each metric for both deblenders \n",
"# plot histograms of each metric for both deblenders\n",
"fig, axes = plt.subplots(1, 3, figsize=(15, 5))\n",
"ranges = [(0, 200), (20, 70), (0.9, 1.0)]\n",
"latex_metric_names = [r'\\rm MSE', r'\\rm PSNR', r'\\rm SSIM']\n",
"for ii, metric_name in enumerate(['mse', 'psnr', 'ssim']):\n",
" ax = axes[ii]\n",
" _, bins, _ = ax.hist(all_sep[metric_name], bins=25, alpha=0.5, label=r'\\rm SEP',\n",
" color='C0', histtype='stepfilled', range=ranges[ii])\n",
" ax.hist(all_scarlet[metric_name], bins=bins, alpha=0.5, label=r'\\rm Scarlet', \n",
" ax.hist(all_scarlet[metric_name], bins=bins, alpha=0.5, label=r'\\rm Scarlet',\n",
" color='C1', histtype='stepfilled', range=ranges[ii])\n",
" ax.set_xlabel(latex_metric_names[ii], fontsize=20)\n",
" if ii == 0:\n",
Expand Down Expand Up @@ -670,10 +670,10 @@
"min_distance = int(get_psf_size(survey)) # needs to be an integer\n",
"\n",
"# setup both deblenders\n",
"peak_finder = PeakLocalMax(max_n_sources=max_n_sources+10, \n",
"peak_finder = PeakLocalMax(max_n_sources=max_n_sources+10,\n",
" sky_level=sky_level,\n",
" threshold_scale=5, \n",
" min_distance=min_distance*2, \n",
" threshold_scale=5,\n",
" min_distance=min_distance*2,\n",
" use_band=2 # r-band\n",
" )\n",
"\n",
Expand Down
Loading

0 comments on commit 7675940

Please sign in to comment.