Skip to content

Commit

Permalink
graduate deinterleave
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdillon committed Jan 7, 2025
1 parent a73abd2 commit 830272b
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions notebooks/single_baseline_postprocessing_and_pspec.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Single Baseline Filtering and Power Spectrum Estimation\n",
"\n",
"**by Josh Dillon, Bobby Pascua, and Mike Wilensky**, last updated November 5, 2024\n",
"**by Josh Dillon, Bobby Pascua, and Mike Wilensky**, last updated January 6, 2025\n",
"\n",
"This notebook is designed to take a single redundantly-averaged unique baseline (typically after LST-binning) and push it through all the way to the power spectrum. It operates on single files that contain a single baseline for all LSTs and both `'ee'` and `'nn'` polarizations. It then can:\n",
"* Throw out highly flagged times and/or channels\n",
Expand Down Expand Up @@ -787,30 +787,6 @@
" nsamples[ap + (pstokes,)] = combined_nsamples"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79e04ba6",
"metadata": {},
"outputs": [],
"source": [
"# TODO: graduate this function into hera_cal\n",
"\n",
"def deinterleave_datacontainer(dc, ninterleave=NINTERLEAVE, tslice=slice(None)):\n",
" '''Breaks datacontainers into ninterleave separate containers and returns a list of deinterleaved datacontainers.\n",
" Also updates .times and .lsts attributes. Integrations at the end that do not evenly divide are dropped.'''\n",
" deint_dcs = []\n",
" for i in range(ninterleave):\n",
" islice = slice(i, (len(dc.times[tslice]) // ninterleave) * ninterleave, ninterleave) # ensures all slices have same shape\n",
" new_dc = copy.deepcopy(dc)\n",
" new_dc.times = dc.times[tslice][islice]\n",
" new_dc.lsts = dc.lsts[tslice][islice]\n",
" for bl in new_dc:\n",
" new_dc[bl] = dc[bl][tslice, :][islice, :]\n",
" deint_dcs.append(new_dc)\n",
" return deint_dcs"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1067,10 +1043,10 @@
"outputs": [],
"source": [
"# perform deinterleaving\n",
"deint_filt_data = deinterleave_datacontainer(filt_data, ninterleave=NINTERLEAVE, tslice=tslice)\n",
"deint_flags = deinterleave_datacontainer(filt_flags, ninterleave=NINTERLEAVE, tslice=tslice)\n",
"deint_nsamples = deinterleave_datacontainer(filt_nsamples, ninterleave=NINTERLEAVE, tslice=tslice)\n",
"deint_wgts = deinterleave_datacontainer(time_filt_wgts, ninterleave=NINTERLEAVE, tslice=tslice)"
"deint_filt_data = filt_data.deinterleave(NINTERLEAVE, tslice=tslice)\n",
"deint_flags = filt_flags.deinterleave(NINTERLEAVE, tslice=tslice)\n",
"deint_nsamples = filt_nsamples.deinterleave(NINTERLEAVE, tslice=tslice)\n",
"deint_wgts = time_filt_wgts.deinterleave(NINTERLEAVE, tslice=tslice)"
]
},
{
Expand Down

0 comments on commit 830272b

Please sign in to comment.