Exemplo n.º 1
0
 def loadVelocityField(self, input='velocityField.pk'):
     """
     Loads velocity field information from the pickled velocityField.pk
     file. This file is created by processVelocities.py so if that script
     was not run it won't be present and one cannot use this script to
     do the plot.
     """
     self.info['data'] = np.array(read.cPickledData(input)['data'])
Exemplo n.º 2
0
 def loadVelocityField(self, input='velocityField.pk'):
     """
     Loads velocity field information from the pickled velocityField.pk
     file. This file is created by processVelocities.py so if that script
     was not run it won't be present and one cannot use this script to
     do the plot.
     """
     self.info['data'] = np.array(read.cPickledData(input)['data'])
Exemplo n.º 3
0
    def combineVelocityCoordinates(self,
                                   vel='velocity.pk',
                                   coord='coordinates.pk'):
        """
        Combine velocity and coordinate information.
        Takes the data from pickled files.

        :param vel: pickled velocity information
        :type vel: string
        :param coord: pickled coordinate information
        :type coord: string
        """
        #load in data
        coords = read.cPickledData(coord)
        vel = read.cPickledData(vel)

        #output
        out = []
        #loop over all time and space...
        for file in coords.keys():
            for coordline in coords[file]:
                for velline in vel:
                    if velline[0] == file.replace('.fits', '') and int(
                            velline[1]) == coordline[1]:
                        #this is match but need to test if there's any useful veocity info
                        if float(velline[2]) > 0.0 or float(velline[5]) > 0.0:
                            tmp = coordline + [
                                float(velline[2]),
                                float(velline[3]),
                                float(velline[4]),
                                float(velline[5]),
                                float(velline[6]),
                                float(velline[7]), file
                            ]
                            out.append(tmp)

        info = {'coordinates': coords, 'velocities': vel, 'data': out}

        self.velocityField = info
        write.cPickleDumpDictionary(self.velocityField, 'velocityField.pk')
Exemplo n.º 4
0
    def combineVelocityCoordinates(self,
                                   vel='velocity.pk',
                                   coord='coordinates.pk'):
        """
        Combine velocity and coordinate information.
        Takes the data from pickled files.

        :param vel: pickled velocity information
        :type vel: string
        :param coord: pickled coordinate information
        :type coord: string
        """
        #load in data
        coords = read.cPickledData(coord)
        vel = read.cPickledData(vel)

        #output
        out = []
        #loop over all time and space...
        for file in coords.keys():
            for coordline in coords[file]:
                for velline in vel:
                    if velline[0] == file.replace('.fits', '') and int(velline[1]) == coordline[1]:
                        #this is match but need to test if there's any useful veocity info
                        if float(velline[2]) > 0.0 or float(velline[5]) > 0.0:
                            tmp = coordline + [float(velline[2]), float(velline[3]),
                                               float(velline[4]), float(velline[5]),
                                               float(velline[6]), float(velline[7]), file]
                            out.append(tmp)

        info = {'coordinates': coords,
                'velocities': vel,
                'data': out}

        self.velocityField = info
        write.cPickleDumpDictionary(self.velocityField, 'velocityField.pk')
Exemplo n.º 5
0
def plotDistributionRedshiftMasslimits(output,
                                       massmin=12.0,
                                       massmax=12.5,
                                       normalize=True,
                                       average=False):
    """
    Projected separation as a function of redshift bin.

    :param output: name of the output file
    :type output: string
    :param massmin: minimum dark matter halo mass
    :type massmin: float
    :param massmax: maximum dark matter halo mass
    :type massmax: float
    :param normalize: whether to normalize the projected distance with the size of the main halo
    :type normalize: bool
    :param average: whether to take the average of the subhalo distances or not
    :type average: bool

    :return: None
    """
    fig = P.figure()

    title = r'$%.1f \leq \log_{10} \left( M_{dm} [\mathrm{M}_{\odot}]  \right) < %.1f$' % (
        massmin, massmax)

    redshifts = [
        'redshift < 0.5 and', 'redshift >= 0.5 and redshift < 1.0 and',
        'redshift >= 1.0 and redshift < 2.0 and',
        'redshift >= 2.0 and redshift < 3.0 and',
        'redshift >= 3.0 and redshift < 4.0 and',
        'redshift >= 4.0 and redshift < 5.0 and',
        'redshift >= 5.0 and redshift < 6.0 and',
        'redshift >= 6.0 and redshift < 7.0 and'
    ]

    for i, red in enumerate(redshifts):
        #read the pickled data in
        data = read.cPickledData('distances%i.pickle' % (i + 1))

        mass = np.asarray(data['mhalo'])
        msk = (mass >= massmin) & (mass < massmax)

        dm = np.asarray(data['distances'])[msk]
        rm = np.asarray(data['rhalo'])[msk]

        #collect distance information and normalize and average if needed
        distances = []
        for dists, rhalo in zip(dm, rm):
            tmp = []
            for value in dists:
                if normalize:
                    tmp.append(value / (1e3 * rhalo))
                else:
                    tmp.append(value)
            if average:
                distances.append(np.mean(np.asarray(tmp)))
            else:
                distances += tmp

        ax = P.subplot(4, 2, i + 1)

        #write the redshift of the subplot
        tmp = red.split()
        if i > 0:
            txt = r'$' + tmp[2] + ' \leq z < ' + tmp[6] + '$'
        else:
            txt = r'$z < 0.5$'
        ax.text(0.5,
                0.9,
                txt,
                ha='center',
                va='center',
                fontsize=12,
                transform=ax.transAxes)

        #plot histogram if enough data
        if len(distances) > 1:
            ax.hist(distances, bins=np.linspace(0, 1, 20), normed=True)

        if normalize:
            ax.set_xlim(0.0, 0.8)
            ax.set_yticks([])

    #add one x-label
    if normalize:
        P.annotate('Projected Distances / Virial Radius of the Main Halo',
                   (0.5, 0.03),
                   xycoords='figure fraction',
                   ha='center',
                   va='center',
                   fontsize=12)
    else:
        P.annotate('Projected Distance [kpc]', (0.5, 0.03),
                   xycoords='figure fraction',
                   ha='center',
                   va='center',
                   fontsize=12)

    #write title and save figure
    P.annotate(title, (0.5, 0.95),
               xycoords='figure fraction',
               ha='center',
               va='center',
               fontsize=12)
    P.savefig(output)