def get_stressors(lat, lon):
    """
    Example for looking up stressors at a particular location.

    """

    # Note df is a flattened list of lat/lon values that only includes those over land
    df = pvcz.get_pvcz_data()

    # Point of interest specified by lat/lon coordinates.
    lat_poi = float(lat)
    lon_poi = float(lon)

    # Find the closest location on land to a point of interest
    closest_index = pvcz.arg_closest_point(lat_poi, lon_poi, df['lat'],
                                           df['lon'])

    first_table_keys = [
        'lat', 'lon', 'T_equiv_rack_1p1eV', 'T_equiv_roof_1p1eV',
        'specific_humidity_mean', 'T_velocity_rack', 'GHI_mean',
        'T_ambient_min', 'T_ambient_max', 'T_ambient_mean', 'KG_zone',
        'T_equiv_rack_1p1eV_zone', 'T_equiv_roof_1p1eV_zone',
        'specific_humidity_mean_zone', 'pvcz', 'pvcz_labeled',
        'ASCE 7-16 MRI 25-Year', 'wind_speed_max'
    ]

    detail_table_keys = [
        'T_equiv_rack_0p1eV', 'T_equiv_rack_0p3eV', 'T_equiv_rack_0p5eV',
        'T_equiv_rack_0p7eV', 'T_equiv_rack_0p9eV', 'T_equiv_rack_1p1eV',
        'T_equiv_rack_1p3eV', 'T_equiv_rack_1p5eV', 'T_equiv_rack_1p7eV',
        'T_equiv_rack_1p9eV', 'T_equiv_rack_2p1eV', 'T_equiv_roof_0p1eV',
        'T_equiv_roof_0p3eV', 'T_equiv_roof_0p5eV', 'T_equiv_roof_0p7eV',
        'T_equiv_roof_0p9eV', 'T_equiv_roof_1p1eV', 'T_equiv_roof_1p3eV',
        'T_equiv_roof_1p5eV', 'T_equiv_roof_1p7eV', 'T_equiv_roof_1p9eV',
        'T_equiv_roof_2p1eV', 'T_velocity_rack', 'T_velocity_roof',
        'wind_speed_rms', 'specific_humidity_rms'
    ]

    # Get the stressor data from this location
    # location_df = pd.DataFrame(data={'Parameter': [pvtoolslib.pvcz_legend_str[p] for p in df.keys()],
    #                                  'Value': df.iloc[closest_index]})
    location_df = pd.DataFrame(
        data={
            'Parameter':
            [pvtoolslib.pvcz_legend_str[p] for p in first_table_keys],
            'Value': df[first_table_keys].iloc[closest_index]
        })
    for p in [
            'T_equiv_rack_1p1eV', 'T_equiv_roof_1p1eV',
            'specific_humidity_mean', 'T_velocity_rack', 'GHI_mean',
            'T_ambient_min', 'T_ambient_max', 'T_ambient_mean',
            'wind_speed_max', 'ASCE 7-16 MRI 25-Year'
    ]:
        location_df.loc[p, 'Value'] = '{:.2f}'.format(location_df['Value'][p])

    detail_df = pd.DataFrame(
        data={
            'Parameter':
            [pvtoolslib.pvcz_legend_str[p] for p in detail_table_keys],
            'Value': df[detail_table_keys].iloc[closest_index]
        })

    for p in detail_df.index:
        detail_df.loc[p, 'Value'] = '{:.2f}'.format(detail_df['Value'][p])

    return html.Div([
        dbc.Table.from_dataframe(
            location_df,
            striped=False,
            bordered=True,
            hover=True,
            index=False,
            size='sm',
            # style={'font-size':'0.8rem'}
        ),
        html.Details([
            html.Summary("More stressors"),
            html.Div(
                [
                    dbc.Table.from_dataframe(
                        detail_df,
                        striped=False,
                        bordered=True,
                        hover=True,
                        index=False,
                        size='sm',
                        # style={'font-size':'0.8rem'}
                    ),
                ],
                style={'marginLeft': 50}),
        ]),
    ])


#
# if __name__ == '__main__':
#     app.run_server(debug=True)
Beispiel #2
0
"""
Example for looking up stressors at a particular location.

"""

import pvcz

# Note df is a flattened list of lat/lon values that only includes those over land
df = pvcz.get_pvcz_data()

# Point of interest specified by lat/lon coordinates.
lat_poi = 32
lon_poi = -95.23

# Find the closest location on land to a point of interest
closest_index = pvcz.arg_closest_point(lat_poi, lon_poi, df['lat'], df['lon'])

# Get the stressor data from this location
location_data = df.iloc[closest_index]