Skip to content

Commit

Permalink
update with cross-pol calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-a-cox committed Jul 27, 2024
1 parent 28ee265 commit d164a91
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions notebooks/file_calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1248,40 +1248,32 @@
" model_blvecs = {bl: model.antpos[bl[0]] - model.antpos[bl[1]] for bl in model.keys()}\n",
" utils.lst_rephase(model, model_blvecs, model.freqs, data.lsts - model.lsts, lat=hdm.telescope_location_lat_lon_alt_degrees[0], inplace=True)\n",
"\n",
" # Solve for polarization phase offset\n",
" weighted_sum = np.zeros(data.shape, dtype=complex)\n",
"\n",
" wgts_here = {}\n",
" data_here = {}\n",
"\n",
" \n",
" for red in cross_reds:\n",
" data_bl = red[0]\n",
" if data_bl in data_to_model_bl_map:\n",
" # load data and model visibilities\n",
" model_bl = data_to_model_bl_map[data_bl]\n",
" wgts_here = np.sum([\n",
"\n",
" wgts_here[data_bl] = np.sum([\n",
" np.logical_not(omni_flags[utils.split_bl(bl)[0]] | omni_flags[utils.split_bl(bl)[1]])\n",
" for bl in red\n",
" ], axis=0)\n",
" data_here = np.nanmean([\n",
" data_here[data_bl] = np.nanmean([\n",
" np.where(\n",
" omni_flags[utils.split_bl(bl)[0]] | omni_flags[utils.split_bl(bl)[1]],\n",
" np.nan, sol.calibrate_bl(bl, data[bl])\n",
" ) \n",
" for bl in red\n",
" ], axis=0)\n",
" \n",
" # Compute data-model product \n",
" model_data_prod = model[model_bl].conj() * data_here\n",
" \n",
" if data_bl[-1] == 'ne':\n",
" model_data_prod = np.conj(model_data_prod)\n",
"\n",
" weighted_sum += wgts_here * model_data_prod\n",
"\n",
" delta = np.where(np.isfinite(weighted_sum), np.angle(weighted_sum), 0.0)\n",
" delta_gains = {\n",
" antpol: np.exp(1j * delta) if antpol[-1] == 'Jee'\n",
" else np.ones_like(delta)\n",
" for antpol in sol.gains\n",
" }\n",
" \n",
" # Run cross-polarized phase calibration\n",
" delta_gains = abscal.cross_pol_phase_cal(\n",
" model=model, data=data_here, wgts=wgts_here, data_bls=data_bls, model_bls=model_bls, return_gains=True,\n",
" gain_ants=sol.gains.keys()\n",
" )\n",
" \n",
" # apply gains\n",
" # \\Delta = \\phi_e - \\phi_n, where V_{en}^{cal} = V_{en}^{uncal} * e^{i \\Delta} \n",
Expand Down Expand Up @@ -1807,7 +1799,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.6"
},
"toc": {
"base_numbering": 1,
Expand Down

0 comments on commit d164a91

Please sign in to comment.