Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper tracking of flagged times #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fhd_core/setup_metadata/fhd_struct_init_obs.pro
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct={code_version:String(code_version),instrument:String(instrument),obsname:
kpix:Float(kbinsize),degpix:Float(degpix),obsaz:meta.obsaz,obsalt:meta.obsalt,obsra:meta.obsra,obsdec:meta.obsdec,$
zenra:meta.zenra,zendec:meta.zendec,obsx:meta.obsx,obsy:meta.obsy,zenx:meta.zenx,zeny:meta.zeny,$
phasera:meta.phasera,phasedec:meta.phasedec,orig_phasera:meta.orig_phasera,orig_phasedec:meta.orig_phasedec,$
n_pol:Fix(n_pol,type=2),n_tile:Long(n_tile),n_tile_flag:Long(n_flag),n_freq:Long(n_freq),n_freq_flag:0L,n_time:Long(n_time),n_time_flag:n_time_cut,$
n_pol:Fix(n_pol,type=2),n_tile:Long(n_tile),n_tile_flag:Long(n_flag),n_freq:Long(n_freq),n_freq_flag:0L,n_time:Long(n_time),n_time_flag:Long(n_time_cut),$
n_vis:Long(n_vis),n_vis_in:Long(n_vis_in),n_vis_raw:Long(n_vis_raw),nf_vis:Long(n_vis_arr),primary_beam_area:Ptrarr(4),primary_beam_sq_area:Ptrarr(4),pol_names:pol_names,$
jd0:meta.jd0,max_baseline:Double(max_baseline),min_baseline:Double(min_baseline),delays:meta.delays,lon:meta.lon,lat:meta.lat,alt:meta.alt,$
freq_center:Float(freq_center),freq_res:Float(freq_res),time_res:Float(meta.time_res),astr:meta.astr,alpha:Float(spectral_index),$
Expand Down
31 changes: 18 additions & 13 deletions fhd_core/visibility_manipulation/vis_flag_basic.pro
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,27 @@ IF Keyword_Set(no_frequency_flagging) THEN BEGIN
ENDIF ELSE freq_use=0>freq_use<1
tile_use=0>tile_use<1

;Time-based flagging
;;; Time-based flagging
time_use=(*obs.baseline_info).time_use
n_time = obs.n_time
IF Min(time_use) LE 0 THEN BEGIN
n_baselines=N_Elements((*obs.baseline_info).tile_A)
bin_offset=(*obs.baseline_info).bin_offset
bin_offset=[bin_offset,n_baselines]
time_bin=Lonarr(n_baselines)
FOR ti=0L,n_time-1 DO BEGIN
IF time_use[ti] LE 0 THEN BEGIN
FOR pol_i=0, n_pol-1 DO BEGIN
(*vis_weight_ptr[pol_i])[*, bin_offset[ti]:bin_offset[ti+1]-1] = 0
ENDFOR
ENDIF
n_baselines=N_Elements((*obs.baseline_info).tile_A)
bin_offset=(*obs.baseline_info).bin_offset
bin_offset=[bin_offset,n_baselines]
FOR ti=0L,n_time-1 DO BEGIN
; Make sure the flagging of the visibilities matches the time_use array
IF time_use[ti] LE 0 THEN BEGIN
FOR pol_i=0, n_pol-1 DO BEGIN
(*vis_weight_ptr[pol_i])[*, bin_offset[ti]:bin_offset[ti+1]-1] = 0
ENDFOR
ENDIF
; Make sure the time_use array matches the flagging of the visiblities
FOR pol_i=0, n_pol-1 DO BEGIN
; If any polarization is fully flagged, then count that time as flagged
time_use[ti] *= total((*vis_weight_ptr[pol_i])[*, bin_offset[ti]:bin_offset[ti+1]-1] > 0) GT 0
Comment on lines +130 to +131
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be revisited in the case that Dara developed for HERA where antenna flagging can be per pol. I don't think we want to support different per-time flagging per pol if both pols are included, but we do want to support entirely flagging one pol of an antenna and not flagging the other pol. We can push that to another PR if we want just wanted to note the potential conflict.

ENDFOR
ENDIF
ENDFOR
(*obs.baseline_info).time_use = time_use
;;; End time-based flagging

IF Keyword_Set(unflag_all) THEN BEGIN
tile_use[*]=1
Expand Down