Skip to content

Commit

Permalink
Merge pull request #13 from dogukankaratas/asceResponse
Browse files Browse the repository at this point in the history
asce method added
  • Loading branch information
dogukankaratas authored Feb 2, 2023
2 parents 7e0e5d7 + 8318837 commit c498efc
Show file tree
Hide file tree
Showing 13 changed files with 391 additions and 82 deletions.
61 changes: 22 additions & 39 deletions Welcome.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
import streamlit as st
import base64

st.set_page_config(page_title="Scalepy GUI", layout="wide")

with st.sidebar:
st.markdown("# ScalePy")
st.markdown("Click [here](https://github.com/dogukankaratas/scalepy) for source code.")
st.markdown("Use [here](https://www.linkedin.com/in/dogukankaratas/) to reach me.")
st.markdown("💻 Click [here](https://github.com/dogukankaratas/scalepy) for source code.")
st.markdown("🧑‍💻 Use [here](https://www.linkedin.com/in/dogukankaratas/) to reach me.")

st.markdown("# Welcome to ScalePy 👋")
st.write("ScalePy is an open-source ground motion selection and scaling framework developed in Python.")
st.write("Package can be use as an API, which is located in GitHub page, and also a GUI has developed for the end-user.")

st.markdown('## Guide')
st.markdown('Follow the steps below to get started.')

st.markdown('### Step 1: Generate Response Spectrum')
st.markdown("First generate a response spectrum with using built-in functions or upload a file.")
col1, col2 = st.columns(2)
with col1:
st.image('assets/responseSpectrum.png')
with col2:
pass

st.markdown('### Step 2: Filter Record Database and Select Record Set')
st.markdown('Filter your records acc. to the properties of your case and select an optimum set using ScalePy algorithm.')
col3, col4 = st.columns(2)
with col3:
st.image('assets/filterRecords.png')
with col4:
st.image('assets/selectRecords.png')

st.markdown('### Step 3: Amplitude Scaling')
st.markdown('Perform amplitude scaling with selected spectral ordinate.')
col5, col6 = st.columns(2)
with col5:
st.image('assets/scaleRecords.png')
with col6:
st.image('assets/rotScale.png')

st.markdown('### Results')
st.markdown('For every step, your data will be visualized in the chart.')
col7, col8 = st.columns(2)
with col7:
st.image('assets/optimumRecords.png')
with col8:
st.image('assets/scaledRecordsChart.png')

st.markdown("Also you can read your scale factors and selected records from the table.")
st.image('assets/resultTable.png')
st.markdown('## Response Spectrum Definition')
st.markdown('Define your target spectrum via using one of the functions of ScalePy below.')

st.image("https://media.giphy.com/media/o0FcopcmojZRYw0lrK/giphy.gif")

st.markdown('## Filter Record Database')
st.markdown('Use the given parameters to filter ground motion database records to find similiar ground motions with your case.')

st.image("https://media.giphy.com/media/eX8k3hxYu5pDv2Ubjg/giphy.gif")

st.markdown('## Find Optimum Set')
st.markdown('Use ScalePy similarity algorithm to find optimum ground motion data set.')

st.image("https://media.giphy.com/media/31KMao2AiZO5TpQAso/giphy.gif")

st.markdown('## Perform Amplitude Scaling')
st.markdown('Use the user inputs to perform amplitude scaling and find optimum scale factors for your set.')

st.image("https://media.giphy.com/media/O8Af6Yivtoi9g2u46W/giphy.gif")
Binary file added __pycache__/accesAsce.cpython-310.pyc
Binary file not shown.
67 changes: 67 additions & 0 deletions accesAsce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import requests
import json
import pandas as pd

def getAsceDataMulti(lat, long, risk, site, title):

asceDataMulti = pd.DataFrame(columns=["multiPeriodDesignSpectrumPeriods", "multiPeriodDesignSpectrumOrdinates"])

url = f"https://earthquake.usgs.gov/ws/designmaps/asce7-22.json?latitude={lat}&longitude={long}&riskCategory={risk}&siteClass={site}&title={title}"

r = requests.get(url)

schema = json.loads(r.text)

# Multi Period Design Spectrum
asceDataMulti['multiPeriodDesignSpectrumPeriods'] = schema['response']['data']['multiPeriodDesignSpectrum']['periods']
asceDataMulti['multiPeriodDesignSpectrumOrdinates'] = schema['response']['data']['multiPeriodDesignSpectrum']['ordinates']

return asceDataMulti

def getAsceDataMultiMCEr(lat, long, risk, site, title):

asceDataMultiMCEr = pd.DataFrame(columns=["multiPeriodMCErSpectrumPeriods", "multiPeriodMCErSpectrumOrdinates"])

url = f"https://earthquake.usgs.gov/ws/designmaps/asce7-22.json?latitude={lat}&longitude={long}&riskCategory={risk}&siteClass={site}&title={title}"

r = requests.get(url)

schema = json.loads(r.text)

## Multi Period MCEr Spectrum
asceDataMultiMCEr['multiPeriodMCErSpectrumPeriods'] = schema['response']['data']['multiPeriodMCErSpectrum']['periods']
asceDataMultiMCEr['multiPeriodMCErSpectrumOrdinates'] = schema['response']['data']['multiPeriodMCErSpectrum']['ordinates']

return asceDataMultiMCEr

def getAsceDataTwo(lat, long, risk, site, title):

asceDataTwo = pd.DataFrame(columns=["twoPeriodDesignSpectrumPeriods", "twoPeriodDesignSpectrumOrdinates"])

url = f"https://earthquake.usgs.gov/ws/designmaps/asce7-22.json?latitude={lat}&longitude={long}&riskCategory={risk}&siteClass={site}&title={title}"

r = requests.get(url)

schema = json.loads(r.text)

## Two period Design Spectrum
asceDataTwo['twoPeriodDesignSpectrumPeriods'] = schema['response']['data']['twoPeriodDesignSpectrum']['periods']
asceDataTwo['twoPeriodDesignSpectrumOrdinates'] = schema['response']['data']['twoPeriodDesignSpectrum']['ordinates']

return asceDataTwo.drop(10)

def getAsceDataTwoMCEr(lat, long, risk, site, title):

asceDataTwoMCEr = pd.DataFrame(columns=["twoPeriodMCErSpectrumPeriods", "twoPeriodMCErSpectrumOrdinates"])

url = f"https://earthquake.usgs.gov/ws/designmaps/asce7-22.json?latitude={lat}&longitude={long}&riskCategory={risk}&siteClass={site}&title={title}"

r = requests.get(url)

schema = json.loads(r.text)

## Two period MCEr Spectrum
asceDataTwoMCEr['twoPeriodMCErSpectrumPeriods'] = schema['response']['data']['twoPeriodMCErSpectrum']['periods']
asceDataTwoMCEr['twoPeriodMCErSpectrumOrdinates'] = schema['response']['data']['twoPeriodMCErSpectrum']['ordinates']

return asceDataTwoMCEr.drop(10)
Binary file removed assets/filterRecords.png
Binary file not shown.
Binary file removed assets/flowchart.png
Binary file not shown.
Binary file removed assets/optimumRecords.png
Binary file not shown.
Binary file removed assets/responseSpectrum.png
Binary file not shown.
Binary file removed assets/resultTable.png
Binary file not shown.
Binary file removed assets/rotScale.png
Binary file not shown.
Binary file removed assets/scaleRecords.png
Binary file not shown.
Binary file removed assets/scaledRecordsChart.png
Binary file not shown.
Binary file removed assets/selectRecords.png
Binary file not shown.
Loading

0 comments on commit c498efc

Please sign in to comment.