Example #1
0
    def pdf(self, sample):
        """Checks to insure that the sample's subfaults are not out of bounds,
        then evaluates the depth distribution's probability density function 
        at the sample's depth. 
        
        Parameters
        ----------
        sample : pandas Series of floats
            The series containing the arrays of information for a sample.
            Contains keys 'latitude', 'longitude', 'magnitude', 'delta_logl',
            'delta_logw', and 'depth_offset' with their associated float values.

        Returns
        -------
        pdf : float
            The value of the probability density function for the depth distribution
            evaluated at the depth of the sample. 
        """
        # compute subfaults (for out-of-bounds calculation)
        length = calc_length(sample['magnitude'], sample['delta_logl'])
        width = calc_width(sample['magnitude'], sample['delta_logw'])
        subfault_params = self.fault.subfault_split(sample['latitude'],
                                                    sample['longitude'],
                                                    length, width, 1,
                                                    sample['depth_offset'])

        if out_of_bounds(
                subfault_params,
                self.fault.bounds):  #FAULT: Which bounds will this call?
            return 0
        else:
            depth = self.fault.depth_map(
                sample['latitude'],
                sample['longitude']) + 1000 * sample['depth_offset']
            return self.depth_dist.pdf(depth)
Example #2
0
    def logpdf(self, sample):
        """Checks to insure that the sample's subfaults are not out of bounds,
        then computes the log of the depth distribution's probability density
        function evaluated at the sample's depth.

        Parameters
        ----------
        sample : pandas Series of floats
            The series containing the arrays of information for a sample.
            Contains keys 'latitude', 'longitude', 'magnitude', 'delta_logl',
            'delta_logw', and 'depth_offset' with their associated float
            values.

        Returns
        -------
        NINF -or- logpdf : float
            Returns negative inifity if out-of-bounds,
            otherwise returns the log of the probability density function
            for the depth distribution evaluated at the sample's depth.
        """
        # compute subfaults (for out-of-bounds calculation)
        length = calc_length(sample['magnitude'], sample['delta_logl'])
        width = calc_width(sample['magnitude'], sample['delta_logw'])

        subfault_params = self.fault.subfault_split_RefCurve(
            lat=sample['latitude'],
            lon=sample['longitude'],
            length=length,
            width=width,
            slip=1,
            depth_offset=sample['depth_offset'],
            dip_offset=sample['dip_offset'],
            rake_offset=sample['rake_offset'])

        if subfault_params.isnull().values.any():
            return np.NINF
        if out_of_bounds(subfault_params, self.fault.model_bounds):
            return np.NINF
        else:
            depth = (
                self.fault.depth_map(sample['latitude'], sample['longitude']) +
                1000 * sample['depth_offset'])
            return self.depth_dist.logpdf(depth)
Example #3
0
    def map_to_model_params(self, sample):
        """Evaluate the map from sample parameters to forward model parameters.

        Parameters
        ----------
        sample : pandas Series of floats
            The series containing the arrays of information for a sample.
            Contains keys 'latitude', 'longitude', 'magnitude', 'delta_logl',
            'delta_logw', and 'depth_offset' with their associated float values.
        
        Returns
        -------
        model_params : dict
            A dictionary that builds off of the sample dictionary whose keys are the 
            okada parameters: 'latitude', 'longitude', 'depth_offset', 'strike','length',
            'width','slip','depth','dip','rake', 
            and whose associated values are the newly calculated values from the sample. 
        """
        #FAULT: Here, we're simply calling strike_map, dip_map, depth_map. A good place to test the multifault???
        length = calc_length(sample['magnitude'], sample['delta_logl'])
        width = calc_width(sample['magnitude'], sample['delta_logw'])
        slip = calc_slip(sample['magnitude'], length, width)
        strike = self.fault.strike_map(sample['latitude'], sample['longitude'])
        dip = self.fault.dip_map(sample['latitude'], sample['longitude'])
        depth = self.fault.depth_map(sample['latitude'], sample['longitude'])
        rake = 90

        model_params = dict()
        model_params['latitude'] = sample['latitude']
        model_params['longitude'] = sample['longitude']
        model_params['depth_offset'] = sample['depth_offset']
        model_params['length'] = length
        model_params['width'] = width
        model_params['slip'] = slip
        model_params['strike'] = strike
        model_params['dip'] = dip
        model_params['depth'] = depth
        model_params['rake'] = rake
        return model_params
Example #4
0
    def map_to_model_params(self, flores_sample, walanae_sample):
        """Evaluate the map from sample parameters to forward model parameters.

        Parameters
        ----------
        sample : pandas Series of floats
            The series containing the arrays of information for a sample.
            Contains keys 'latitude', 'longitude', 'magnitude', 'delta_logl',
            'delta_logw', and 'depth_offset' with their associated float
            values.

        Returns
        -------
        model_params : dict
            A dictionary that builds off of the sample dictionary whose keys
            are the okada parameters: 'latitude', 'longitude', 'depth_offset',
            'strike','length', 'width','slip','depth','dip','rake', and whose
            associated values are the newly calculated values from the sample.
        """
        flores_length = calc_length(flores_sample['magnitude'],
                                    flores_sample['delta_logl'])
        flores_width = calc_width(flores_sample['magnitude'],
                                  flores_sample['delta_logw'])
        flores_slip = calc_slip(flores_sample['magnitude'], flores_length,
                                flores_width)

        walanae_length = calc_length(walanae_sample['magnitude'],
                                     walanae_sample['delta_logl'])
        walanae_width = calc_width(walanae_sample['magnitude'],
                                   walanae_sample['delta_logw'])
        walanae_slip = calc_slip(walanae_sample['magnitude'], walanae_length,
                                 walanae_width)

        flores_strike, flores_strike_std = self.flores_fault.strike_map(
            flores_sample['latitude'],
            flores_sample['longitude'],
            return_std=True)
        flores_dip, flores_dip_std = self.flores_fault.dip_map(
            flores_sample['latitude'],
            flores_sample['longitude'],
            return_std=True)
        flores_depth, flores_depth_std = self.flores_fault.depth_map(
            flores_sample['latitude'],
            flores_sample['longitude'],
            return_std=True)
        flores_rake, flores_rake_std = self.flores_fault.rake_map(
            flores_sample['latitude'],
            flores_sample['longitude'],
            return_std=True)

        # WHY IS THIS BLOCK NOT REPEATED FOR WALANAE?!?!
        ########################################################################
        # Multiply strike, dip, depth offsets by standard deviation of
        # Gaussian processes
        flores_sample['depth_offset'] *= flores_depth_std
        flores_sample['dip_offset'] *= flores_dip_std
        flores_sample['strike_offset'] *= flores_strike_std
        flores_sample['rake_offset'] *= flores_rake_std
        ########################################################################

        walanae_strike = self.walanae_fault.strike_map(
            walanae_sample['latitude'], walanae_sample['longitude'])
        walanae_dip = self.walanae_fault.dip_map(walanae_sample['latitude'],
                                                 walanae_sample['longitude'])
        walanae_depth = self.walanae_fault.depth_map(
            walanae_sample['latitude'], walanae_sample['longitude'])
        walanae_rake = 80  # On Walanae, the rake is assumed to be 80.

        model_params = dict()
        model_params['latitude'] = [
            flores_sample['latitude'], walanae_sample['latitude']
        ]
        model_params['longitude'] = [
            flores_sample['longitude'], walanae_sample['longitude']
        ]
        model_params['length'] = [flores_length, walanae_length]
        model_params['width'] = [flores_width, walanae_width]
        model_params['slip'] = [flores_slip, walanae_slip]
        model_params['strike'] = [flores_strike, walanae_strike]
        model_params['strike_offset'] = [
            flores_sample['strike_offset'], walanae_sample['strike_offset']
        ]
        model_params['dip'] = [flores_dip, walanae_dip]
        model_params['dip_offset'] = [
            flores_sample['dip_offset'], walanae_sample['dip_offset']
        ]
        model_params['depth'] = [flores_depth, walanae_depth]
        model_params['depth_offset'] = [
            flores_sample['depth_offset'], walanae_sample['depth_offset']
        ]
        model_params['rake'] = [flores_rake, walanae_rake]
        model_params['rake_offset'] = [
            flores_sample['rake_offset'], walanae_sample['rake_offset']
        ]

        return model_params
Example #5
0
    def map_to_model_params(self, sample):
        """Evaluate the map from sample parameters to forward model parameters.

        Parameters
        ----------
        sample : pandas Series of floats
            The series containing the arrays of information for a sample.
            Contains keys 'latitude', 'longitude', 'magnitude', 'delta_logl',
            'delta_logw', and 'depth_offset' with their associated float
            values.

        Returns
        -------
        model_params : dict
            A dictionary that builds off of the sample dictionary whose keys
            are the okada parameters: 'latitude', 'longitude', 'depth_offset',
            'strike','length', 'width','slip','depth','dip','rake', and whose
            associated values are the newly calculated values from the sample.
        """
        length = calc_length(sample['magnitude'], sample['delta_logl'])
        width = calc_width(sample['magnitude'], sample['delta_logw'])
        slip = calc_slip(sample['magnitude'], length, width)
        if sample['fault_idx'] == 0:  # If we are on the Flores fault:
            strike, strike_std = self.fault.strike_map(sample['latitude'],
                                                       sample['longitude'],
                                                       return_std=True)
            dip, dip_std = self.fault.dip_map(sample['latitude'],
                                              sample['longitude'],
                                              return_std=True)
            depth, depth_std = self.fault.depth_map(sample['latitude'],
                                                    sample['longitude'],
                                                    return_std=True)
            rake, rake_std = self.fault.rake_map(sample['latitude'],
                                                 sample['longitude'],
                                                 return_std=True)

            # Multiply strike, dip, depth offsets by standard deviation of
            # Gaussian processes
            sample['depth_offset'] *= depth_std
            sample['dip_offset'] *= dip_std
            sample['strike_offset'] *= strike_std
            sample['rake_offset'] *= rake_std

        else:
            strike = self.fault.strike_map(sample['latitude'],
                                           sample['longitude'])
            dip = self.fault.dip_map(sample['latitude'], sample['longitude'])
            depth = self.fault.depth_map(sample['latitude'],
                                         sample['longitude'])
            rake = 80  # On Walanae, the rake is assumed to be 80.

        model_params = dict()
        model_params['latitude'] = sample['latitude']
        model_params['longitude'] = sample['longitude']
        model_params['length'] = length
        model_params['width'] = width
        model_params['slip'] = slip
        model_params['strike'] = strike
        model_params['strike_offset'] = sample['strike_offset']
        model_params['dip'] = dip
        model_params['dip_offset'] = sample['dip_offset']
        model_params['depth'] = depth
        model_params['depth_offset'] = sample['depth_offset']
        model_params['rake'] = rake
        model_params['rake_offset'] = sample['rake_offset']

        return model_params