From 317cd8a6416ca8ff9518a25dab12bbe2233fe991 Mon Sep 17 00:00:00 2001 From: CatalinaYepes Date: Wed, 3 Jan 2024 13:25:48 +0100 Subject: [PATCH 1/4] fix bug in Pandas. iteritems was removed in 2.0.0. https://github.com/gem/earthquake-scenarios/issues/27 --- src/usgs_stations_json_csv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usgs_stations_json_csv.py b/src/usgs_stations_json_csv.py index 55581b2a..fc831c6c 100644 --- a/src/usgs_stations_json_csv.py +++ b/src/usgs_stations_json_csv.py @@ -47,7 +47,7 @@ def read_usgs_json(json_path): # Iterate over different columns. Each colum can be a component data = [] pgas = [] - for index, chan in rec_sation.iteritems(): + for index, chan in rec_sation.items(): try: if chan["name"].endswith("Z") or chan["name"].endswith("U"): continue From 3b9bfb5ae7b574d7fef6a9a119204a8cc187f1c2 Mon Sep 17 00:00:00 2001 From: CatalinaYepes Date: Wed, 3 Jan 2024 15:37:43 +0100 Subject: [PATCH 2/4] Fix text by adding rupture_dict to read rupture file --- src/get_rupture_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get_rupture_info.py b/src/get_rupture_info.py index a83d1e53..323ca37c 100644 --- a/src/get_rupture_info.py +++ b/src/get_rupture_info.py @@ -10,7 +10,7 @@ class OqP: inputs = {'rupture_model': ""} rupture_mesh_spacing = 2.0 ses_seed = 69 - + rupture_dict = None def repture_xml_to_df(filepath, add_geometry=False): ''' From d0d63fe5b80e0a61e3b47d10e80ef39ddb1d6390 Mon Sep 17 00:00:00 2001 From: CatalinaYepes Date: Wed, 3 Jan 2024 15:39:59 +0100 Subject: [PATCH 3/4] polish code --- src/usgs_stations_json_csv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/usgs_stations_json_csv.py b/src/usgs_stations_json_csv.py index fc831c6c..3dad73de 100644 --- a/src/usgs_stations_json_csv.py +++ b/src/usgs_stations_json_csv.py @@ -41,13 +41,13 @@ def read_usgs_json(json_path): channels = pd.DataFrame(stations.channels.to_list()) vals = pd.Series([], dtype = 'object') - for row, rec_sation in channels.iterrows(): - rec_sation.dropna(inplace=True) + for row, rec_station in channels.iterrows(): + rec_station.dropna(inplace=True) # Iterate over different columns. Each colum can be a component data = [] pgas = [] - for index, chan in rec_sation.items(): + for _, chan in rec_station.items(): try: if chan["name"].endswith("Z") or chan["name"].endswith("U"): continue From 79486d66a8247448fc35b93bb696e8e7fd72ee31 Mon Sep 17 00:00:00 2001 From: CatalinaYepes Date: Wed, 3 Jan 2024 15:43:00 +0100 Subject: [PATCH 4/4] removed unused libraries --- src/usgs_stations_json_csv.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/usgs_stations_json_csv.py b/src/usgs_stations_json_csv.py index 3dad73de..890b45ef 100644 --- a/src/usgs_stations_json_csv.py +++ b/src/usgs_stations_json_csv.py @@ -1,16 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import os -import glob import json -import numpy as np import pandas as pd -import geopandas as gpd -import contextily as ctx -import matplotlib.pyplot as plt - def read_usgs_json(json_path): '''