Skip to content
Snippets Groups Projects
Select Git revision
  • 132cea3e09a04ff01561a37b367c9e394fb61609
  • MCCS-163 default
  • main
  • sar-277-update-docs-with-examples-for-lrc
  • st-946-automate
  • sar_302-log-fix
  • sar-287_subarray_commands_to_lrc
  • sar_302-POC_await_sub_device_state
  • sat_302_fix_pipelines
  • sar-286_lrc_one_subarry_command
  • sar-286_lrc_improvements
  • sar-288-async-controller
  • sar-276-combine-tango-queue
  • sar-255_remove_nexus_reference
  • sar-275-add-LRC
  • sar-273-add-lrc-attributes
  • sar-272
  • sp-1106-marvin-1230525148-ska-tango-base
  • sp-1106-marvin-813091765-ska-tango-base
  • sar-255/Publish-package-to-CAR
  • mccs-661-device-under-test-fixture
  • mccs-659-pep257-docstring-linting
  • 0.11.3
  • 0.11.2
  • 0.11.1
  • 0.11.0
  • 0.10.1
  • 0.10.0
  • 0.9.1
  • 0.9.0
  • 0.8.1
  • 0.8.0
  • 0.7.2
  • 0.7.1
  • 0.7.0
  • 0.6.6
  • 0.6.5
  • 0.6.4
  • 0.6.3
  • 0.6.2
  • 0.6.1
  • 0.6.0
42 results

test_reference_base_device.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Ateamclipper.py 2.50 KiB
    #!/usr/bin/env python3
    
    ## changelog
    # W.Williams   2014/11/03  add - to give input/output statistics per channel
    # W.Williams   2014/11/03  fix - statistics per correlation
    # A.Drabent    2019/07/24  write fraction of flagged data into output file (for prefactor3)
    # M.VanderWild 2022/04/21  fix ~ use python3 instead of python
    
    import numpy
    import pyrap.tables as pt
    import os
    import sys
    
    msname = str(sys.argv[1])
    
    cliplevelhba = 5.0
    cliplevellba = 50.0
    
    t = pt.table(msname, readonly=False)
    data = t.getcol('MODEL_DATA')
    flag = t.getcol('FLAG')
    freq_tab= pt.table(msname + '::SPECTRAL_WINDOW')
    freq    = freq_tab.getcol('REF_FREQUENCY')
    
    if freq[0] > 100e6:
     cliplevel = cliplevelhba
    if freq[0] < 100e6:
     cliplevel = cliplevellba
    
    
    print('------------------------------')
    print('SB Frequency [MHz]', freq[0]/1e6)
    for chan in range(0,numpy.size(data[0,:,0])):
      print('chan %i : %.5f%% input XX flagged' %( chan, 100.*numpy.sum(flag[:,chan,0] == True)/numpy.size(flag[:,chan,0]) ))
      print('chan %i : %.5f%% input YY flagged' %( chan, 100.*numpy.sum(flag[:,chan,3] == True)/numpy.size(flag[:,chan,3]) ))
    input_flags_xx = 100. * numpy.sum(flag[:,:,0] == True)/numpy.size(flag[:,:,0])
    input_flags_yy = 100. * numpy.sum(flag[:,:,3] == True)/numpy.size(flag[:,:,3])
    print('Total : %.5f%% input XX flagged' %(   input_flags_xx ))
    print('Total : %.5f%% input YY flagged' %(   input_flags_yy ))
    print('')
    print('Cliplevel used [Jy]', cliplevel)
    print('\n\n')
    
    for pol in range(0,numpy.size(data[0,0,:])):
     for chan in range(0,numpy.size(data[0,:,0])):
      print('Doing polarization,chan', pol, chan)
      idx = numpy.where(abs(data[:,chan,pol]) > cliplevel)
      flag[idx,chan,0] = True
      flag[idx,chan,1] = True
      flag[idx,chan,2] = True
      flag[idx,chan,3] = True 
    
    print('')
    for chan in range(0,numpy.size(data[0,:,0])):
      print('chan %i : %.5f%% output XX flagged' %( chan, 100.*numpy.sum(flag[:,chan,0] == True)/numpy.size(flag[:,chan,0]) ))
      print('chan %i : %.5f%% output YY flagged' %( chan, 100.*numpy.sum(flag[:,chan,3] == True)/numpy.size(flag[:,chan,3]) ))
    output_flags_xx = 100. * numpy.sum(flag[:,:,0] == True)/numpy.size(flag[:,:,0])
    output_flags_yy = 100. * numpy.sum(flag[:,:,3] == True)/numpy.size(flag[:,:,3])
    print('Total : %.5f%% output XX flagged' %(   output_flags_xx ))
    print('Total : %.5f%% output YY flagged' %(   output_flags_yy ))
    print('')
    t.putcol('FLAG', flag)
    t.close()
    freq_tab.close()
    
    os.system('echo ' + str(freq[0]) + ' ' + str(output_flags_xx - input_flags_xx) + ' ' + str(output_flags_yy - input_flags_yy) + ' >> Ateamclipper.txt')