Skip to content

Commit

Permalink
Fix 144: move client_url_key to ConfigParameters (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgjs authored Jul 5, 2023
1 parent c3b9674 commit e0c94a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
12 changes: 3 additions & 9 deletions src/noisepy/seis/S0A_download_ASDF_MPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@
# we expect no parameters need to be changed below


def download(
direc: str,
prepro_para: ConfigParameters,
client_url_key: str = "SCEDC",
):
def download(direc: str, prepro_para: ConfigParameters):
# client/data center. see https://docs.obspy.org/packages/obspy.clients.fdsn.html for a list
client = Client(client_url_key)
client = Client(prepro_para.client_url_key)
chan_list = prepro_para.channels
sta_list = prepro_para.stations
executor = ThreadPoolExecutor()
Expand Down Expand Up @@ -242,7 +238,6 @@ def download(
task = executor.submit(
download_stream,
prepro_para,
client_url_key,
inv,
net[ista],
sta[ista],
Expand Down Expand Up @@ -273,7 +268,6 @@ def download(

def download_stream(
prepro_para: ConfigParameters,
url_key: str,
inv: obspy.Inventory,
net: str,
sta: str,
Expand All @@ -284,7 +278,7 @@ def download_stream(
index: int,
) -> Tuple[int, obspy.Stream]:
logger.debug(f"Start download for {sta}.{chan}")
client = Client(url_key, timeout=15)
client = Client(prepro_para.client_url_key, timeout=15)
retries = 5
while retries > 0:
try:
Expand Down
1 change: 1 addition & 0 deletions src/noisepy/seis/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class StackMethod(Enum):


class ConfigParameters(YamlModel):
client_url_key: str = "SCEDC"
start_date: datetime = Field(default=datetime(2019, 1, 1))
end_date: datetime = Field(default=datetime(2019, 1, 2))
samp_freq: float = Field(default=20) # TODO: change this samp_freq for the obspy "sampling_rate"
Expand Down
5 changes: 2 additions & 3 deletions tutorials/get_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
"os.makedirs(path,exist_ok=True)\n",
"raw_data_path = os.path.join(path, \"RAW_DATA\")\n",
"cc_data_path = os.path.join(path, \"CCF\")\n",
"stack_data_path = os.path.join(path, \"STACK\")\n",
"\n"
"stack_data_path = os.path.join(path, \"STACK\")"
]
},
{
Expand Down Expand Up @@ -180,7 +179,7 @@
"config.end_date = isoparse(\"2019-02-02\")\n",
"\n",
"# Download data locally. Enters raw data path, channel types, stations, config, and fdsn server.\n",
"download(raw_data_path, config, \"SCEDC\")"
"download(raw_data_path, config)"
]
},
{
Expand Down

0 comments on commit e0c94a0

Please sign in to comment.