Skip to content

Fault system solution file

fault_system_solution_file

An FaultSystemSolution archive file helper.

See notes about FaultSystemSolution and OpenSHA InversionSolution archive formats.

Classes

FaultSystemSolutionFile()

Bases: InversionSolutionFile

Class to handle the solution modular archive file form.

Initializes a new FaultSystemSolutionFile instance.

Parameters:

Name Type Description Default
self FaultSystemSolutionFile

The instance to initialize.

required
Source code in solvis/solution/fault_system_solution/fault_system_solution_file.py
66
67
68
69
70
71
72
73
74
def __init__(self) -> None:
    """
    Initializes a new FaultSystemSolutionFile instance.

    Args:
        self (FaultSystemSolutionFile): The instance to initialize.
    """
    self._rates: Optional[pd.DataFrame] = None
    super().__init__()
Attributes
COMPOSITE_RATES_PATH = 'composite_rates.csv' class-attribute instance-attribute
AGGREGATE_RATES_PATH = 'aggregate_rates.csv' class-attribute instance-attribute
FAST_INDICES_PATH = 'ruptures/fast_indices.csv' class-attribute instance-attribute
OPENSHA_SECT_POLYS_PATH = 'ruptures/sect_polygons.geojson' class-attribute instance-attribute
OPENSHA_GRID_REGION_PATH = 'ruptures/grid_region.geojson' class-attribute instance-attribute
OPENSHA_ONLY = [OPENSHA_SECT_POLYS_PATH, OPENSHA_GRID_REGION_PATH] class-attribute instance-attribute
DATAFRAMES = InversionSolutionFile.DATAFRAMES + [COMPOSITE_RATES_PATH, AGGREGATE_RATES_PATH, FAST_INDICES_PATH] class-attribute instance-attribute
composite_rates: pd.DataFrame property

Returns the composite rates dataframe.

Returns:

Type Description
pd.DataFrame

pd.DataFrame: The composite rates dataframe.

aggregate_rates: gpd.GeoDataFrame property

Returns the aggregate rates GeoDataFrame.

Returns:

Type Description
gpd.GeoDataFrame

gpd.GeoDataFrame: The aggregate rates GeoDataFrame.

rupture_rates: DataFrame[RuptureRateSchema] property

Returns a GeoDataFrame containing the rupture rates.

This property returns a pandas DataFrame with a schema of RuptureRateSchema, representing the rupture rates. The data is loaded from the aggregate_rates GeoDataFrame, ensuring that it adheres to the specified schema.

Returns:

Type Description
DataFrame[RuptureRateSchema]

DataFrame[RuptureRateSchema]: A GeoDataFrame containing the rupture rates.

fast_indices: gpd.GeoDataFrame cached property

Retrieves the fast indices as a GeoDataFrame.

The fast_indices property returns a pandas DataFrame containing index data for ruptures, indexed by 'sections'. This data is read from the CSV file specified by FAST_INDICES_PATH, applying specific data types to columns.

Returns:

Type Description
gpd.GeoDataFrame

gpd.GeoDataFrame: A GeoDataFrame containing the fast indices.

Functions
set_props(composite_rates, aggregate_rates, ruptures, indices, fault_sections, fault_regime, average_slips)

Sets the properties of the FaultSystemSolutionFile instance.

Parameters:

Name Type Description Default
self FaultSystemSolutionFile

The instance to set properties for.

required
composite_rates pd.DataFrame

The composite rates dataframe.

required
aggregate_rates pd.DataFrame

The aggregate rates dataframe.

required
ruptures pd.DataFrame

The ruptures dataframe.

required
indices pd.DataFrame

The indices dataframe.

required
fault_sections pd.DataFrame

The fault sections dataframe.

required
fault_regime pd.DataFrame

The fault regime dataframe.

required
average_slips pd.DataFrame

The average slips dataframe.

required

Returns:

Type Description

None

Source code in solvis/solution/fault_system_solution/fault_system_solution_file.py
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def set_props(
    self, composite_rates, aggregate_rates, ruptures, indices, fault_sections, fault_regime, average_slips
):
    """
    Sets the properties of the FaultSystemSolutionFile instance.

    Args:
        self (FaultSystemSolutionFile): The instance to set properties for.
        composite_rates (pd.DataFrame): The composite rates dataframe.
        aggregate_rates (pd.DataFrame): The aggregate rates dataframe.
        ruptures (pd.DataFrame): The ruptures dataframe.
        indices (pd.DataFrame): The indices dataframe.
        fault_sections (pd.DataFrame): The fault sections dataframe.
        fault_regime (pd.DataFrame): The fault regime dataframe.
        average_slips (pd.DataFrame): The average slips dataframe.

    Returns:
        None
    """
    self._composite_rates = composite_rates
    self._aggregate_rates = aggregate_rates

    # Now we need a rates table, structured correctly, with weights from the aggregate_rates
    rates = aggregate_rates.drop(columns=['rate_max', 'rate_min', 'rate_count', 'fault_system']).rename(
        columns={"rate_weighted_mean": "Annual Rate"}
    )
    super().set_props(rates, ruptures, indices, fault_sections, average_slips)
to_archive(archive_path, base_archive_path, compat=False)

Writes the current solution to a new zip archive, cloning data from a base archive.

Source code in solvis/solution/fault_system_solution/fault_system_solution_file.py
123
124
125
126
def to_archive(self, archive_path, base_archive_path, compat=False):
    """Writes the current solution to a new zip archive, cloning data from a base archive."""
    log.debug("%s to_archive %s" % (type(self), archive_path))
    super().to_archive(archive_path, base_archive_path, compat=False)

Functions