e-merlin / eMERLIN_CASA_pipeline

This is CASA eMERLIN pipeline to calibrate data from the e-MERLIN array. Please fork the repository before making any changes and read the Coding Practices page in the wiki. Please add issues with the pipeline in the issues tab.
GNU General Public License v3.0
14 stars 11 forks source link

Plotting error #75

Closed varenius closed 5 years ago

varenius commented 6 years ago

2017-11-04 11:08:34 | INFO | Starting pipeline 2017-11-04 11:08:34 | INFO | Running pipeline from: pipeline/ 2017-11-04 11:08:34 | INFO | Pipeline version: v0.6.2 2017-11-04 11:08:34 | INFO | Using github branch: master 2017-11-04 11:08:34 | INFO | github last commit: a3cc1cb 2017-11-04 11:08:34 | INFO | This log uses UTC times 2017-11-04 11:08:34 | INFO | Inputs from file: inputs.txt 2017-11-04 11:08:34 | INFO | Parameters in inputs file: 2017-11-04 11:08:34 | INFO | fits_path : ./fitsidi/ 2017-11-04 11:08:34 | INFO | inbase : TSARP220_C_20171013 2017-11-04 11:08:34 | INFO | targets : 1534+2330 2017-11-04 11:08:34 | INFO | phscals : 1532+2344,1516+1932 2017-11-04 11:08:34 | INFO | fluxcal : 3C286 2017-11-04 11:08:34 | INFO | bpcal : OQ208 2017-11-04 11:08:34 | INFO | ptcal : 3C84 2017-11-04 11:08:34 | INFO | refant : Mk2 2017-11-04 11:08:34 | INFO | Lo_dropout_scans: 2017-11-04 11:08:34 | INFO | manual_flags_a : ./inputfg_a.flags 2017-11-04 11:08:34 | INFO | manual_flags_b : ./inputfg_b_avg.flags 2017-11-04 11:08:34 | INFO | run_importfits : 0 2017-11-04 11:08:34 | INFO | summary_weblog : 0 2017-11-04 11:08:34 | INFO | hanning : 0 2017-11-04 11:08:34 | INFO | ms2mms : 0 2017-11-04 11:08:34 | INFO | flag_0_aoflagger: 0 2017-11-04 11:08:34 | INFO | flag_1_apriori : 0 2017-11-04 11:08:34 | INFO | flag_2a_manual : 0 2017-11-04 11:08:34 | INFO | average_1 : 1 2017-11-04 11:08:34 | INFO | plot_data : 0 2017-11-04 11:08:34 | INFO | flag_2b_manual : 0 2017-11-04 11:08:34 | INFO | init_models : 0 2017-11-04 11:08:34 | INFO | bandpass_0 : 0 2017-11-04 11:08:34 | INFO | flag_3_tfcropBP : 0 2017-11-04 11:08:34 | INFO | delay : 0 2017-11-04 11:08:34 | INFO | gain_0_p_ap : 0 2017-11-04 11:08:34 | INFO | fluxscale : 0 2017-11-04 11:08:34 | INFO | bandpass_1_sp : 0 2017-11-04 11:08:34 | INFO | gain_1_amp_sp : 0 2017-11-04 11:08:34 | INFO | applycal_all : 0 2017-11-04 11:08:34 | INFO | flag_4_rflag : 0 2017-11-04 11:08:34 | INFO | plot_corrected : 0 2017-11-04 11:08:34 | INFO | weblog : 0 2017-11-04 11:08:34 | INFO | Loaded previous flags list from: ./flags.pkl 2017-11-04 11:08:34 | INFO | Targets: 1534+2330 2017-11-04 11:08:34 | INFO | Phasecals: 1532+2344,1516+1932 2017-11-04 11:08:34 | INFO | Fluxcal: 3C286 2017-11-04 11:08:34 | INFO | Bandpass: OQ208 2017-11-04 11:08:34 | INFO | Pointcal: 3C84 2017-11-04 11:08:34 | INFO | Start split 2017-11-04 11:08:34 | INFO | Sources in MS TSARP220_C_20171013.ms: 1516+1932,1407+284,0319+415,1532+2344,1331+305,1534+2330 2017-11-04 11:08:34 | WARNING | Fields 3C84,3C286,OQ208 not present in MS but listed in inputs file. 2017-11-04 11:08:34 | WARNING | All fields will be included in the averaged MS. 2017-11-04 11:08:34 | INFO | Input MS: TSARP220_C_20171013.ms 2017-11-04 11:08:34 | INFO | Output MS: TSARP220_C_20171013_avg.ms 2017-11-04 11:08:34 | INFO | width=4, timebin= 2017-11-04 11:08:34 | INFO | Fields: 1516+1932,1407+284,0319+415,1532+2344,1331+305,1534+2330 2017-11-04 11:08:34 | INFO | Data column: data 2017-11-04 11:12:12 | INFO | Listobs file in: TSARP220_C_20171013_avg.ms.listobs 2017-11-04 11:12:12 | INFO | End split 2017-11-04 11:12:12 | INFO | Using MS file: ./TSARP220_C_20171013_avg.ms 2017-11-04 11:12:12 | INFO | Reading ms file information for MS: ./TSARP220_C_20171013_avg.ms 2017-11-04 11:12:12 | INFO | Targets: 1534+2330 2017-11-04 11:12:12 | INFO | Phasecals: 1532+2344,1516+1932 2017-11-04 11:12:12 | INFO | Fluxcal: 3C286 2017-11-04 11:12:12 | INFO | Bandpass: OQ208 2017-11-04 11:12:12 | INFO | Pointcal: 3C84 2017-11-04 11:12:12 | INFO | Sources in MS ./TSARP220_C_20171013_avg.ms: 1516+1932,1407+284,0319+415,1532+2344,1331+305,1534+2330 2017-11-04 11:12:12 | INFO | Antennas in MS ./TSARP220_C_20171013_avg.ms: ['Cm' 'Da' 'Kn' 'Mk2' 'Pi'] 2017-11-04 11:12:13 | INFO | Plotting elevation to: ./plots/plots_observation/TSARP220_C_20171013_avg_elevation.png 2017-11-04 11:12:23 | INFO | Plotting uv-coverage for all sources 2017-11-04 11:12:23 | INFO | Plotting uvcov for 1516+1932: ./plots/plots_observation/TSARP220_C_20171013_avg_uvcov_1516+1932.png 2017-11-04 11:12:25 | INFO | Plotting uvcov for 1407+284: ./plots/plots_observation/TSARP220_C_20171013_avg_uvcov_1407+284.png 2017-11-04 11:12:27 | INFO | Plotting uvcov for 0319+415: ./plots/plots_observation/TSARP220_C_20171013_avg_uvcov_0319+415.png 2017-11-04 11:12:28 | INFO | Plotting uvcov for 1532+2344: ./plots/plots_observation/TSARP220_C_20171013_avg_uvcov_1532+2344.png Traceback (most recent call last): File "/opt/packages/casainst/casa-release-5.1.0-74.el7/lib/python2.7/init_welcome.py", line 24, in execfile(candidates[0]) File "pipeline/eMERLIN_CASA_pipeline.py", line 387, in run_pipeline(inputs=inputs) File "pipeline/eMERLIN_CASA_pipeline.py", line 193, in run_pipeline emplt.make_uvcov(msfile, msinfo) File "pipeline/functions/eMERLIN_CASA_plots.py", line 197, in make_uvcov u, v = read_uvw(msfile, f) File "pipeline/functions/eMERLIN_CASA_plots.py", line 177, in read_uvw ms.msselect(staql) File "/opt/packages/casainst/casa-release-5.1.0-74.el7/lib/python2.7/casac__/ms.py", line 1710, in msselect return _ms.ms_msselect(self, *args, **kwargs) RuntimeError: MSSelectionNullSelection : The selected table has zero rows.

Perhaps this may have to do with the fact that I flagged one antenna, De, completely using a manual flag file with contents "antenna='De'", since Defford receivers were warm here? If the plotting always assumes all antennas to be there, it may fail because of this?

varenius commented 6 years ago

Two notes: 1) The plotting step seem to have run even thought it was not selected in the "input.txt", see the input log parameters above. This should not happen. 2) It seems that the "antennas in MS" are correctly identified, so it should know that De is not there. So perhaps the error is something else.

varenius commented 6 years ago

Actually, it seems this plotting calls are always run, no matter what input parameter are chosen. The code is the following in the main pipeline script, after the "average_1" step:

    logger.info('Using MS file: {0}'.format(msfile))

    ### Load or create dictionary with ms information.
    if os.path.isfile(msfile+'.msinfo.pkl'):
        logger.info('Loading msinfo from: {}'.format(msfile+'.msinfo.pkl'))
        #msinfo = load_obj(msfile+'.msinfo')  I decide to read it again,
        #because it is very fast, and it is needed if user changes some inputs.
        msinfo = em.get_msinfo(msfile, inputs)
        save_obj(msinfo, msfile+'.msinfo')
        logger.info('Elevation and uvcov plots will not be created again as long as the {}.pkl file exists.'.format(msfile+'.msinfo'))
    elif os.path.isdir(msfile):
        msinfo = em.get_msinfo(msfile, inputs)
        ### Produce basic observation plots
        emplt.make_elevation(msfile, msinfo)
        emplt.make_uvcov(msfile, msinfo)
        save_obj(msinfo, msfile+'.msinfo')
        logger.info('Saving information of MS {0} in: {1}'.format(msfile, msfile+'.pkl'))
    else:
        logger.info('No data or msinfo found. Calibration will not work.')
        pass

This code is always run, which I think is the wrong behaviour? If nothing is specified in inputs.txt, the pipeline should do nothing,

jmoldon commented 6 years ago
    ms.open(msfile)
    staql={'field':field, 'spw':'0'}
    ms.msselect(staql)

it looks more like casa bug? And I have not find the same problem, I will try to replicate it. In any case, I don't know the solution.

The original reason for all that code you copied is that in previous versions getdata2 was slow, so it took long to produce the msinfo dictionary (sources, antennas, spw, num_channels, etc.), but it was fundamental information for many steps. So I decided to run it only once and keep the information in a msinfo.pkl file that could be read later. If now we move the elev and uvcov plots, I don't think there is any reason to keep it there, as it is better to read all the msinfo every time.

varenius commented 6 years ago

Right, thanks for the info.

I did a "reset" by removing all pipeline products and starting from scratch. This time it ran without problems. The only change I made was the source names in the inputs-file, e.g. OQ208->1407+284. Perhaps some failure due to the wrong names in an earlier step gave rise to this. Anyway, this particular error seems gone so I'm closing this issue.

varenius commented 6 years ago

I re-ran the pipeline another time (to reset flags) and it failed again! 2017-11-06 13:39:30 | INFO | Pipeline version: v0.6.2 2017-11-06 13:39:30 | INFO | Using github branch: master 2017-11-06 13:39:30 | INFO | github last commit: a3cc1cb ... 2017-11-06 15:29:38 | INFO | Plotting uvcov for 0319+415: ./plots/plots_observation/TSARP220_C_20171013_avg_uvcov_0319+415.png Traceback (most recent call last): File "/opt/packages/casainst/casa-release-5.1.0-74.el7/lib/python2.7/init_welcome.py", line 24, in execfile(candidates[0]) File "pipeline/eMERLIN_CASA_pipeline.py", line 387, in run_pipeline(inputs=inputs) File "pipeline/eMERLIN_CASA_pipeline.py", line 193, in run_pipeline emplt.make_uvcov(msfile, msinfo) File "pipeline/functions/eMERLIN_CASA_plots.py", line 197, in make_uvcov u, v = read_uvw(msfile, f) File "pipeline/functions/eMERLIN_CASA_plots.py", line 177, in read_uvw ms.msselect(staql) File "/opt/packages/casainst/casa-release-5.1.0-74.el7/lib/python2.7/casac__/ms.py", line 1710, in msselect return _ms.ms_msselect(self, *args, **kwargs) RuntimeError: MSSelectionNullSelection : The selected table has zero rows.

I ran this on "embe1". I saw that you, javi, also ran things there today. Is there perhaps some CASA-issue with running multiple CASA instances? I have no idea, they should be fully independent. But since this part of the code is causing the problem, it would be nice to be able to turn it off.

jmoldon commented 5 years ago

Resolved by #100