Skip to content

Commit

Permalink
Merge pull request #985 from HERA-Team/new-release
Browse files Browse the repository at this point in the history
Prepare for new release with updated hera-sim
  • Loading branch information
steven-murray authored Jan 15, 2025
2 parents 6814a27 + 963f53a commit c3f0e97
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 127 deletions.
14 changes: 0 additions & 14 deletions .flake8

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ jobs:
python-version: ${{ env.PYTHON }}

- name: Install build
run: pip install build
run: pip install build twine

- name: Build a binary wheel and a source tarball
run: |
python -m build
- name: Twine Check
run: twine check dist/*

- name: Publish to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exclude: 'hera_cal/data/'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -22,7 +22,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.0
rev: v0.9.1
hooks:
# Run the linter.
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions hera_cal/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,8 +1762,8 @@ def get_file_times(filepaths, filetype='uvh5'):
assert AIPY, "you need aipy to use the miriad filetype"
uv = aipy.miriad.UV(f)
# get integration time
int_time = uv['inttime'] / (units.si.day.in_units(units.si.s))
int_time_rad = uv['inttime'] * 2 * np.pi / (units.si.sday.in_units(units.si.s))
int_time = uv['inttime'] / (units.si.day.to(units.si.s))
int_time_rad = uv['inttime'] * 2 * np.pi / (units.si.sday.to(units.si.s))
# get start and stop, add half an integration
start_lst = uv['lst'] + int_time_rad / 2.0
start_time = uv['time'] + int_time / 2.0
Expand Down
4 changes: 2 additions & 2 deletions hera_cal/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def predict_noise_variance_from_autos(bl, data, dt=None, df=None, nsamples=None,
Noise variance predicted on baseline bl in units of data squared.
'''
if dt is None:
dt = infer_dt(data.times_by_bl, bl) * units.si.day.in_units(units.si.s)
dt = infer_dt(data.times_by_bl, bl) * units.si.day.to(units.si.s)
if df is None:
assert (len(data.freqs) > 1) # cannot infer channel width if only one channel is present
df = np.median(np.ediff1d(data.freqs))
Expand All @@ -102,7 +102,7 @@ def predict_noise_variance_from_autos(bl, data, dt=None, df=None, nsamples=None,
auto_bl1, auto_bl2 = (bl[0], bl[0], join_pol(ap1, ap1)), (bl[1], bl[1], join_pol(ap2, ap2))
else:
auto_bl1, auto_bl2 = (auto_ant, auto_ant, join_pol(ap1, ap1)), (auto_ant, auto_ant, join_pol(ap2, ap2))

var = np.abs(data[auto_bl1] * data[auto_bl2] / dt / df)
if nsamples is not None:
return var / nsamples[bl]
Expand Down
2 changes: 1 addition & 1 deletion hera_cal/tests/mock_uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def add_noise_to_uvd(uvd, autos: bool = False):
hd = io.to_HERAData(uvd)

data, flags, nsamples = hd.read()
dt = (data.times[1] - data.times[0]) * units.si.day.in_units(units.si.s)
dt = (data.times[1] - data.times[0]) * units.si.day.to(units.si.s)
df = data.freqs[1] - data.freqs[0]

for bl in data.bls():
Expand Down
60 changes: 60 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ write_to = "hera_cal/_version.py"
parentdir_prefix_version = "hera_cal-"
fallback_version = "0.0.0"

[project]
name = "hera-calibration"
description = "A collection of calibration routines to run on the HERA instrument."
readme = "README.md"
authors = [
{name="HERA Team"},
]
license = {text="BSD"}
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Astronomy",
"Topic :: Scientific/Engineering :: Physics",
]
dynamic=["version"]
requires-python = ">=3.9"
dependencies = [
'numpy>=1.10',
"scipy>=1.9.0",
"h5py",
"hdf5plugin",
"astropy",
"astropy-healpix",
"pyuvdata>=3.1.3",
"linsolve",
"hera_qm>=2.2.0",
"scikit-learn",
"hera-filters",
"line_profiler",
"aipy",
"rich",
"jax",
"jaxlib",
"optax",
"attrs",
"frozendict",
"toml",
]

[project.optional-dependencies]
dev = [
"pytest",
"pre-commit",
"pytest-cov",
"hera_sim>=4.3.0",
"pytest-xdist",
"hypothesis",
"ruff",
]

[tool.pytest]
addopts = "--ignore=scripts --cov=hera_cal --cov-config=.coveragerc"

Expand Down Expand Up @@ -58,11 +113,16 @@ select = [
# "UP", # pyupgrade
]

exclude = [
"scripts/notebooks/*.ipynb", # For now, ignore notebooks when linting.
]

ignore = [
"E402",
"E501",
"W291",
"W293",
"A005", # module io shadows python stdlib
# Following Rulesets we really don't want
"AIR", # airflow - unused library
"ASYNC", # async -- unused library
Expand Down
10 changes: 5 additions & 5 deletions scripts/notebooks/omnical_convergence.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@
" k = kde.gaussian_kde(res)\n",
" xi, yi = np.mgrid[x.min():x.max():nbins*1j, y.min():y.max():nbins*1j]\n",
" zi = k(np.vstack([xi.flatten(), yi.flatten()]))\n",
" plt.xlabel('$\\Delta$g, real')\n",
" plt.ylabel('$\\Delta$g, imag')\n",
" plt.xlabel(r'$\\Delta$g, real')\n",
" plt.ylabel(r'$\\Delta$g, imag')\n",
" plt.xlim(-lim,lim); plt.ylim(-lim,lim)\n",
" ax.grid(b=True, which='major', color='k', linestyle='-')\n",
" \n",
" ax2 = plt.subplot(122, sharey=ax)\n",
" plt.grid()\n",
" _ = plt.contour(xi, yi, zi.reshape(xi.shape), alpha=.5)\n",
" plt.xlabel('$\\Delta$g, real')\n",
" plt.xlabel(r'$\\Delta$g, real')\n",
" plt.xlim(-lim,lim)\n",
" plt.setp(ax2.get_yticklabels(), visible=False)\n",
" ax2.grid(b=True, which='major', color='k', linestyle='-')"
Expand Down Expand Up @@ -657,7 +657,7 @@
" err = [np.sqrt(np.average(np.abs(r)**2) / r.size) for r in res]\n",
" color = 'rgbk'[i]\n",
" _ = plt.semilogy(ants, avg, color+'.', label=label+' <$x-x_0$>')\n",
" _ = plt.semilogy(ants, err, color+'x', label=label+' $\\sigma$')\n",
" _ = plt.semilogy(ants, err, color+'x', label=label+r' $\\sigma$')\n",
"plt.ylabel('Residual Deviation')\n",
"plt.xlabel('Antenna Index')\n",
"plt.legend()\n",
Expand Down Expand Up @@ -764,7 +764,7 @@
"for i in range(4):\n",
" sol = sols[i]\n",
" if i == 0:\n",
" label1, label2 = '<$x-x_0$>', '$\\sigma$'\n",
" label1, label2 = '<$x-x_0$>', r'$\\sigma$'\n",
" else:\n",
" label1, label2 = '', ''\n",
" sol_degen = info.remove_degen(antpos, sol, degen_sol=gains)\n",
Expand Down
2 changes: 1 addition & 1 deletion scripts/notebooks/running_smooth_cal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
"plt.subplot(121)\n",
"plt.imshow(np.angle(original_gains[ant]) / (~cs.flag_grids[ant]), cmap='inferno', aspect='auto', extent=extent)\n",
"plt.colorbar(label='Phase (radians)')\n",
"plt.title('Unfiltered: ' + str(ant));\n",
"plt.title('Unfiltered: ' + str(ant))\n",
"plt.xlabel('Frequency (MHz)')\n",
"plt.ylabel('JD -' + str(int(np.floor(cs.time_grid[0]))))\n",
"\n",
Expand Down
11 changes: 0 additions & 11 deletions setup.cfg

This file was deleted.

88 changes: 0 additions & 88 deletions setup.py

This file was deleted.

0 comments on commit c3f0e97

Please sign in to comment.