nodes: 0, module; 1, function_definition; 2, function_name:concat; 3, parameters; 4, block; 5, identifier:invises; 6, identifier:outvis; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, for_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, for_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, if_statement; 22, expression_statement; 23, identifier:timesort; 24, False; 25, comment:"""Concatenate visibility measurement sets.
  
      invises (list of str)
        Paths to the input measurement sets
      outvis (str)
        Path to the output measurement set.
      timesort (boolean)
        If true, sort the output in time after concatenation.
  
      Example::
  
        from pwkit.environments.casa import tasks
        tasks.concat(['epoch1.ms', 'epoch2.ms'], 'combined.ms')
  
      """; 26, assignment; 27, assignment; 28, call; 29, block; 30, identifier:invis; 31, identifier:invises; 32, block; 33, call; 34, call; 35, call; 36, call; 37, identifier:invis; 38, subscript; 39, block; 40, call; 41, call; 42, call; 43, identifier:timesort; 44, block; 45, call; 46, identifier:tb; 47, call; 48, identifier:ms; 49, call; 50, attribute; 51, argument_list; 52, raise_statement; 53, if_statement; 54, attribute; 55, argument_list; 56, attribute; 57, argument_list; 58, attribute; 59, argument_list; 60, attribute; 61, argument_list; 62, identifier:invises; 63, slice; 64, expression_statement; 65, attribute; 66, argument_list; 67, attribute; 68, argument_list; 69, attribute; 70, argument_list; 71, expression_statement; 72, attribute; 73, argument_list; 74, attribute; 75, argument_list; 76, attribute; 77, argument_list; 78, attribute; 79, identifier:exists; 80, identifier:outvis; 81, call; 82, not_operator; 83, block; 84, identifier:tb; 85, identifier:open; 86, call; 87, identifier:tb; 88, identifier:copy; 89, call; 90, keyword_argument; 91, keyword_argument; 92, identifier:tb; 93, identifier:close; 94, identifier:ms; 95, identifier:open; 96, call; 97, keyword_argument; 98, integer:1; 99, call; 100, identifier:ms; 101, identifier:writehistory; 102, keyword_argument; 103, keyword_argument; 104, identifier:ms; 105, identifier:writehistory; 106, keyword_argument; 107, keyword_argument; 108, identifier:ms; 109, identifier:writehistory; 110, keyword_argument; 111, keyword_argument; 112, call; 113, identifier:ms; 114, identifier:close; 115, attribute; 116, identifier:table; 117, attribute; 118, identifier:ms; 119, identifier:os; 120, identifier:path; 121, identifier:RuntimeError; 122, argument_list; 123, call; 124, raise_statement; 125, identifier:b; 126, argument_list; 127, identifier:b; 128, argument_list; 129, identifier:deep; 130, True; 131, identifier:valuecopy; 132, True; 133, identifier:b; 134, argument_list; 135, identifier:nomodify; 136, False; 137, attribute; 138, argument_list; 139, identifier:message; 140, string; 141, identifier:origin; 142, string; 143, identifier:message; 144, call; 145, identifier:origin; 146, string; 147, identifier:message; 148, call; 149, identifier:origin; 150, string; 151, attribute; 152, argument_list; 153, identifier:util; 154, identifier:tools; 155, identifier:util; 156, identifier:tools; 157, binary_operator:'output "%s" already exists' % outvis; 158, attribute; 159, argument_list; 160, call; 161, subscript; 162, identifier:outvis; 163, identifier:outvis; 164, identifier:ms; 165, identifier:concatenate; 166, keyword_argument; 167, keyword_argument; 168, keyword_argument; 169, string_content:taskname=tasklib.concat; 170, string_content:tasklib.concat; 171, identifier:b; 172, argument_list; 173, string_content:tasklib.concat; 174, identifier:b; 175, argument_list; 176, string_content:tasklib.concat; 177, identifier:ms; 178, identifier:timesort; 179, string:'output "%s" already exists'; 180, identifier:outvis; 181, attribute; 182, identifier:isdir; 183, identifier:invis; 184, identifier:RuntimeError; 185, argument_list; 186, identifier:invises; 187, integer:0; 188, identifier:msfile; 189, call; 190, identifier:freqtol; 191, call; 192, identifier:dirtol; 193, call; 194, binary_operator:'vis = ' + ', '.join(invises); 195, binary_operator:'timesort = ' + 'FT'[int(timesort)]; 196, identifier:os; 197, identifier:path; 198, binary_operator:'input "%s" does not exist' % invis; 199, identifier:b; 200, argument_list; 201, identifier:b; 202, argument_list; 203, identifier:b; 204, argument_list; 205, string; 206, call; 207, string; 208, subscript; 209, string:'input "%s" does not exist'; 210, identifier:invis; 211, identifier:invis; 212, identifier:concat_freqtol; 213, identifier:concat_dirtol; 214, string_content:vis =; 215, attribute; 216, argument_list; 217, string_content:timesort =; 218, string; 219, call; 220, string; 221, identifier:join; 222, identifier:invises; 223, string_content:FT; 224, identifier:int; 225, argument_list; 226, string_content:,; 227, identifier:timesort
code: def concat(invises, outvis, timesort=False):
      """Concatenate visibility measurement sets.
  
      invises (list of str)
        Paths to the input measurement sets
      outvis (str)
        Path to the output measurement set.
      timesort (boolean)
        If true, sort the output in time after concatenation.
  
      Example::
  
        from pwkit.environments.casa import tasks
        tasks.concat(['epoch1.ms', 'epoch2.ms'], 'combined.ms')
  
      """
      tb = util.tools.table()
      ms = util.tools.ms()
  
      if os.path.exists(outvis):
          raise RuntimeError('output "%s" already exists' % outvis)
  
      for invis in invises:
          if not os.path.isdir(invis):
              raise RuntimeError('input "%s" does not exist' % invis)
  
      tb.open(b(invises[0]))
      tb.copy(b(outvis), deep=True, valuecopy=True)
      tb.close()
  
      ms.open(b(outvis), nomodify=False)
  
      for invis in invises[1:]:
          ms.concatenate(msfile=b(invis), freqtol=b(concat_freqtol),
                          dirtol=b(concat_dirtol))
  
      ms.writehistory(message=b'taskname=tasklib.concat', origin=b'tasklib.concat')
      ms.writehistory(message=b('vis = ' + ', '.join(invises)), origin=b'tasklib.concat')
      ms.writehistory(message=b('timesort = ' + 'FT'[int(timesort)]), origin=b'tasklib.concat')
  
      if timesort:
          ms.timesort()
  
      ms.close()