def test_OS_bug_search(self):
        """
        Used to trackdown ticket #98
        """
        SA = array(
            [
                [
                    [
                        0.14210731,
                        0.29123634,
                        0.23670422,
                        0.13234554,
                        0.08648546,
                        0.06338455,
                        0.04945741,
                        0.04140068,
                        0.03497466,
                        0.02969136,
                        0.02525473,
                        0.02151188,
                        0.018371,
                        0.01571802,
                        0.01344816,
                        0.01148438,
                        0.00980236,
                        0.00836594,
                        0.00714065,
                        0.00609482,
                    ],
                    [
                        0.2093217,
                        0.30976405,
                        0.16232743,
                        0.06989206,
                        0.03216174,
                        0.01945677,
                        0.01347719,
                        0.00987403,
                        0.00799221,
                        0.00660128,
                        0.00547129,
                        0.0045463,
                        0.0042072,
                        0.00418348,
                        0.0041599,
                        0.00413222,
                        0.00410333,
                        0.00407463,
                        0.00404614,
                        0.00401785,
                    ],
                    [
                        0.01450217,
                        0.02750284,
                        0.02231209,
                        0.01127933,
                        0.00793098,
                        0.00621618,
                        0.0051103,
                        0.00430777,
                        0.00364714,
                        0.0031542,
                        0.00279411,
                        0.00247654,
                        0.0022153,
                        0.001994,
                        0.0017948,
                        0.00161223,
                        0.00144737,
                        0.00129929,
                        0.00117312,
                        0.00105988,
                    ],
                ]
            ]
        )
        csm_params = {
            "building_parameters": {
                "residential_drift_threshold": array([[21.9456, 43.8912, 109.728, 164.592]]),
                "design_strength": array([0.033]),
                "height": array([7315.2]),
                "ultimate_to_yield": array([3.0]),
                "structure_class": array(["BUILDING"], dtype="|S8"),
                "non_residential_drift_threshold": array([[5.4864, 43.8912, 82.296, 137.16]]),
                "damping_Be": array([0.1]),
                "fraction_in_first_mode": array([0.8]),
                "nsd_a_ratio": array([0.7254902]),
                "acceleration_threshold": array([[0.2, 0.4, 0.8, 1.6]]),
                "nsd_d_ratio": array([0.11764706]),
                "structure_ratio": array([0.15686275]),
                "structural_damage_threshold": array([[26.33472, 41.69664, 88.87968, 219.456]]),
                "natural_elastic_period": array([0.5]),
                "damping_s": array([0.4]),
                "drift_threshold": array([[5.4864, 43.8912, 82.296, 137.16]]),
                "yield_to_design": array([1.5]),
                "structure_classification": array(["S1L"], dtype="|S13"),
                "height_to_displacement": array([0.75]),
                "ductility": array([5.0]),
                "damping_l": array([0.0]),
                "damping_m": array([0.2]),
            },
            "loss_min_pga": 0.050000000000000003,
            "csm_hysteretic_damping": "Error",
            "csm_use_variability": 1,
            "sdtcap": 0.29999999999999999,
            "csm_variability_method": 3,
            "rtol": 0.01,
            "csm_damping_regimes": CSM_DAMPING_REGIMES_USE_ALL,
            "csm_damping_modify_Tav": CSM_DAMPING_MODIFY_TAV,
            "csm_damping_use_smoothing": CSM_DAMPING_USE_SMOOTHING,
            "magnitudes": array([6.0201519, 6.0201519, 6.0201519]),
            "periods": array(
                [
                    0.0,
                    0.17544,
                    0.35088,
                    0.52632,
                    0.70175,
                    0.87719,
                    1.0526,
                    1.2281,
                    1.4035,
                    1.5789,
                    1.7544,
                    1.9298,
                    2.1053,
                    2.2807,
                    2.4561,
                    2.6316,
                    2.807,
                    2.9825,
                    3.1579,
                    3.3333,
                ]
            ),
            "atten_override_RSA_shape": None,
            "atten_cutoff_max_spectral_displacement": False,
            "csm_damping_max_iterations": 7,
        }

        reset_seed(True)
        capacity_spectrum_model = Capacity_spectrum_model(**csm_params)
        point = capacity_spectrum_model.building_response(SA)
        point_windows = (array([[0.11670333, 0.06428497, 0.0]]), array([[7.35287023, 3.98947559, 0.0]]))
        assert allclose(asarray(point), asarray(point_windows))
    def BROKEN_test_find_intersection(self):
        # An error in the hysteresis area calc means the results
        # from Matlab are wrong.
        SA=array([
   0.21604198097920,
   0.49383398471879,
   0.35207861448168,
   0.28146561293471,
   0.24663798021059,
   0.18607106822206,
   0.12461515892587,
   0.08879073656528,
   0.06464645061910,
   0.04893110975922,
   0.03794974804020,
   0.02998618121319,
   0.02404471425307,
   0.01947448758241,
   0.01577287001015,
   0.01292966840312,
   0.01064323885374,
   0.00876012522030,
   0.00721096310143,
   0.00593573499178])
        SA.shape=1,1,-1
        periods=array([0,0.17544,0.35088,0.52632,0.70175,
                     0.87719,1.0526,1.2281,1.4035,1.5789,
                     1.7544,1.9298,2.1053,2.2807,2.4561,
                     2.6316,2.807,2.9825,3.1579,3.3333])
        magnitudes = array([5.6])


        building_parameters ={
            'height': array([ 4572.]),            
            'ultimate_to_yield': array([ 2.]),
            'design_strength': array([ 0.2]),
            'fraction_in_first_mode': array([ 0.75]),
            'natural_elastic_period': array([ 0.13]), 
            'yield_to_design': array([ 1.5]),            
            'height_to_displacement': array([ 0.75]),
            'ductility': array([ 2.]),           
            'damping_s': array([ 0.001]),
            'damping_m': array([ 0.001]),
            'damping_l': array([ 0.001]),
            'damping_Be': array([ 0.05])} 
       
        csm_hysteretic_damping='curve'
        rtol=1/100.0
        csm_damping_max_iterations=7
        sdtcap=0.3
        csm_use_variability=False
        csm_variability_method=3
        csm_variability_method=3
        atten_override_RSA_shape=0
        capacity_spectrum_model=Capacity_spectrum_model(
                 periods,
                 magnitudes,
                 building_parameters,
                 csm_damping_regimes=CSM_DAMPING_REGIMES_USE_ALL,
                 csm_damping_modify_Tav=CSM_DAMPING_MODIFY_TAV,
                 csm_damping_use_smoothing=CSM_DAMPING_USE_SMOOTHING,
                 csm_hysteretic_damping=csm_hysteretic_damping,
                 rtol=rtol,
                 csm_damping_max_iterations=csm_damping_max_iterations,
                 sdtcap=sdtcap,
                 csm_use_variability=csm_use_variability,
                 atten_override_RSA_shape=atten_override_RSA_shape,
                 csm_variability_method=csm_variability_method)
        SAcr,SDcr=capacity_spectrum_model.building_response(SA)
        #print SDcr
        #print SAcr

        assert allclose(1.99087165775938,SDcr[0,0])
        assert allclose(0.46802255489563,SAcr)