scriptfilename := 'make_scan_index.g'; #============================================================================= # # Set values in the scan_number column in MS. # # This script only recognizes a new scan when a field_id or a # subarray_id changes. I haven't quite figured out how to use the # data_desc_id yet... # #----------------------------------------------------------------------------- # Set some input control parameters here : # inname := 'ab973short'; # #============================================================================= # include 'logger.g'; include 'table.g'; # # Build the input and output file names. # msfilename := spaste(inname, ".ms"); # tbl := table(msfilename, readonly=F); # scan_num:=tbl.getcol('SCAN_NUMBER'); field_id:=tbl.getcol('FIELD_ID'); data_id :=tbl.getcol('DATA_DESC_ID'); subarray:=tbl.getcol('ARRAY_ID'); # nrows := len(scan_num); # last_scan_num := 0; last_field_id := -1; last_data_id := -1; last_subarray := -1; # print "nrows = ", nrows; for (irow in 1:nrows) { if (last_field_id != field_id[irow] || last_subarray != subarray[irow]) { last_scan_num := last_scan_num + 1; last_field_id := field_id[irow]; last_data_id := data_id[irow]; last_subarray := subarray[irow]; print irow, 'new : ', last_scan_num, last_field_id, last_data_id, last_subarray; } scan_num[irow] := last_scan_num; } # ok := tbl.putcol ('SCAN_NUMBER', scan_num); # ok := tbl.done(); #