Skip to content

Commit

Permalink
remove old data and notebooks. add some code and revamp license and r…
Browse files Browse the repository at this point in the history
…eadme.
  • Loading branch information
aewallwi committed May 25, 2021
1 parent ead77c3 commit df82040
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 3,579 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pyc
.coverage
build
dist
*.egg-info
438 changes: 0 additions & 438 deletions Interpolate_21cm.ipynb

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Berkeley Radio Astronomy Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# <span style="font-variant:small-caps;">calamity</span>
<span style="font-variant:small-caps;">calamity</span> is a frequency regulated self-cal strategy that simultaneously fits for calibration solutions with foregrounds that are described by a well understood / behaved set of basis vectors. Examples of basis sets that do not incorporate inter-baseline correlations are DPSS vectors and DFT vectors. <span style="font-variant:small-caps;">calamity</span> can also handle fitting modes with inter-baseline correlations to reduce sample variance and potentially recover modes inside of the wedge.
56 changes: 56 additions & 0 deletions calamity/calamity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import numpy as np
from uvtools import dspec
import tensorflow as tf
from pyuvdata import UVData, UVCal

OPTIMIZERS = {'Adadelta': tf.optimizers.Adadelta, 'Adam': tf.optimizers.Adam, 'Adamax':tf.optimizers.Adamax,
'Ftrl': tf.optimizers.Ftrl, 'Nadam':tf.optimizers.Nadam, 'SGD':tf.optimizers.SGD, 'RMSprop': tf.optimizers.RMSprop}


def calibrate_data(uvdata, foreground_basis_vectors, fg0=None, g0=None, weights=None,
foreground_coefficients=None, optimizer='Adamax', tol=1e-14, maxsteps=10000, **opt_kwargs):
"""A foreground loss function
Parameters
----------
uvdata: UVData object
uvdata objet of data to be calibrated.
foreground_coefficients: array-like
Nfg foreground coefficients
foreground_basis_vectros: array-like
(Nbls x Nfrequency) x Nfg 2d tensor of foreground basis vectors.
fg0: array-like
Nfg len complex 1d array of coefficients to serve as initial values for fg
optimization.
g0: array-like
Nant x Nfreqs len complex 1d array of initial gain values.
optimizer: string
Name of optimizer. See OPTIMIZERS dictionary
default is 'Adamax'
tol: float, optional
halting condition for optimizer loop. Stop loop when the change in the cost function falls
below tol.
default is 1e-14
maxsteps: int, optional
maximum number of opt.minimize calls before halting.
default is 10000
Returns
-------
uvdata_model: UVData object
uvdata object containing model of the foregrounds multiplied by the gains
(uncalibrated data). This model is mean to be subtracted from the data
before applying gain solutions.
uvcal_model: UVCal object
uvcal object containing estimates of the gain solutions. These solutions
are not referenced to any sky model and are likely orders of
fitting_info:
dictionary containing fit history with fields:
'loss_history': list of values of the loss function in each minimization iteration.
if record_var_history is True:
each of the following fields is included which points to an Nstep x Nvar array of values
'fg_r': real part of foreground coefficients
'fg_i': imag part of foreground coefficients
'gr': real part of gains.
'gi': imag part of gains
"""
Loading

0 comments on commit df82040

Please sign in to comment.