コード例 #1
0
  return p.parse_args(args=argv)


if __name__ == "__main__":   # if is the main

  args = parse(sys.argv[1:])

  for fn in args.ifname:  #file name loop
    if(args.verbose == True):
      print("Process catalogue '{0}'.".format(fn.name))

    #create the output file name and check it
    if(args.replace == None):
      ofile, skip = mf.insert_src(fn.name, args.insert, overwrite=args.overwrite, skip=args.skip)
    else:
      ofile, skip = mf.replace_src(fn.name, args.replace, overwrite=args.overwrite, skip=args.skip)
    if(skip == True):
      print("Skipping")
      continue

    cov = np.loadtxt(fn, usecols=[args.column])   #read the covariance

    dimcov = int(np.sqrt(cov.size))  #size of the output covariance matrix

    cov = cov.reshape([dimcov,dimcov])   #reshape to a square

    np.savetxt(ofile, cov, fmt="%8.7e", delimiter="\t")   #save the matrix
    if(args.verbose == True):
      print( "File '{0}' saved".format(ofile) )

  exit()
コード例 #2
0
if __name__ == "__main__":  #if it's the main

    args = parse(sys.argv[1:])

    #create the output file names
    if (args.replace == None):  #first file
        ofiled1, skip = mf.insert_src(args.catname.name,
                                      args.insert[::2],
                                      overwrite=args.overwrite)
        ofiled2, skip = mf.insert_src(args.catname.name,
                                      args.insert[1:],
                                      overwrite=args.overwrite)
    else:
        ofiled1, skip = mf.replace_src(args.catname.name,
                                       args.replace[:2],
                                       overwrite=args.overwrite)
        ofiled2, skip = mf.replace_src(args.catname.name,
                                       args.replace[::2],
                                       overwrite=args.overwrite)

    cat = np.loadtxt(args.catname)  #read the input catalogue
    if (args.sepname !=
            None):  #if a file with the criteria for the separation is given
        d, hasz = np.loadtxt(args.sepname, usecols=args.columns).T
    else:  #if not keep it from the catalogue and resize the catalogue taking out the last two columns
        d, hasz = cat[:, args.columns].T
        cat = cat[:, :3]  #drop the last two columns
    if (args.verbose == True):
        print("Catalogue read")