Exemple #1
0
    np.save(writeOut+'nice',np.array([xs,
                                      avg[0],std[0], #Psi_1
                                      avg[1],std[1], #Psi_2
                                      avg[2],std[2], #A
                                      avg[3],std[3], #B
                                      avg[4],std[4], #par
                                      avg[5],std[5]])) #perp
    np.save(writeOut+'all',allData)
        



                      
    
if __name__ == "__main__":
    start = time.time()
    arrrghs = common.parseCmdArgs([['settings'],['-o','--override']
                               ],
                                  ['Settings json file','array indices in the format a:b to extract from infile list'
                                  ],
                                   [str,str])

    main(arrrghs)
    print("That took {:.1f} s".format(time.time()-start))
    #ADD a setting to settings to control whether we're dealing with npy
    #or dat
        



    velocities = [galaxy.v for galaxy in galaxies]
    #get a list of all the galaxies' velocities. This will let us send it directly to the histogram

    bins_orig = genBins(binsize, chop)

    #Make a histogram using pylab histogram function.
    n, bins, patches = pylab.hist(
        velocities,
        bins_orig,
        histtype="stepfilled",
        label="Galaxy Distribution,\n binsize={:.2f}Mpc".format(binsize))

    #Change visual properties of the histogram
    pylab.setp(patches, 'facecolor', 'g', 'alpha', 0.75)

    #Add axis labels
    pylab.ylabel("Galaxy count")
    pylab.xlabel("Radial Velocity, km/s")
    pylab.title("Distribution of Galaxy radial velocities")
    pylab.axis([0, chop, 0, 1000])

    with pdfback.PdfPages(outputFile + str(binsize)) as pdf:
        pdf.savefig(fig)
    pylab.show()
    pylab.close('all')


if __name__ == "__main__":
    args = common.parseCmdArgs([['settings']], ['Settings json file'], [str])
    statsrun(args)
Exemple #3
0
                phi
            ]  #latitude degrees - -90 - 90
            outCF2String = outCF2String + '{}  {}  {}  {}  {}  {}'.format(
                *cf2row)
            if use_dvs:
                dvs = np.random.normal(peculiarVel,
                                       rho * hubble_constant * 0.2, 20)
                for x in dvs:
                    outCF2String = outCF2String + '  {}'.format(x)
            outCF2String = outCF2String + '\n'

    with open(survey['name'] + '_cf2.txt', 'w') as cf2outfile:
        cf2outfile.write(outCF2String)


def transpose(args):
    print("Loading survey...")
    survey_info = common.getdict(args.survey_file)

    print("Success!")
    with Pool(processes=12) as pool:
        pool.map(proconesurvey, survey_info)


if __name__ == "__main__":
    arrrghs = common.parseCmdArgs(
        [['survey_file']],
        ['Survey .json file with surveys and their centers'], [str])

    transpose(arrrghs)
Exemple #4
0
            #                       (r1[2]-r2[2])**2)
            #                 for r1,r2 in zip(itertools.repeat(galaxyCoord),surveys)]
            if len(surveys) != 0:
                distances = space.distance.cdist([galaxyCoord], surveys)
            else:
                distances = np.array([])

            if np.all(distances > separation):
                #All is officially the 'coolest function ever.' All of an empty list is true!
                surveys.append(galaxyCoord)
                break
            else:
                numCatches += 1
            if numCatches % 500 == 0:
                print("So far we have tried {} times, and have {} surveys".
                      format(numCatches, len(surveys)))
            #if numCatches > 100000:
            #    raise RuntimeError("We're probably in an infinite loop. Try reducing the number of surveys to make.")
    print("Caught {}!".format(numCatches))
    print([list(survey) for survey in surveys])
    return surveys


if __name__ == "__main__":
    arrrghs = common.parseCmdArgs(
        [['settings'], ['-g', '--gpu']],
        ['Settings json file', 'use pyCUDA when GPU is available'],
        [str, 'bool'])

    selectrun(arrrghs)