Skip to content

Commit

Permalink
fix reading data with wildcard path
Browse files Browse the repository at this point in the history
  • Loading branch information
niyiyu committed Jul 19, 2023
1 parent 346db5b commit fbe2cc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/noisepy/seis/plotting_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def plot_substack_cc(sfile, freqmin, freqmax, disp_lag=None, savefig=True, sdir=
ttr = spair.split("_")
net1, sta1 = ttr[0].split(".")
net2, sta2 = ttr[1].split(".")
for ipath in path_lists:
for ipath in ds.auxiliary_data[spair].list():
chan1, chan2 = ipath.split("_")
try:
dist = ds.auxiliary_data[spair][ipath].parameters["dist"]
Expand Down
2 changes: 1 addition & 1 deletion src/noisepy/seis/pnwstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def read_data(self, timespan: DateTimeRange, chan: Channel) -> ChannelData:

# reconstruct the file name from the channel parameters
chan_str = f"{chan.station.name}.{chan.station.network}.{timespan.start_datetime.strftime('%Y.%j')}"
filename = fs_join(self.paths[timespan.start_datetime], f"{chan_str}")
filename = fs_join(self.paths[timespan.start_datetime].replace("__", chan.station.network), f"{chan_str}")
if not self.fs.exists(filename):
logger.warning(f"Could not find file {filename}")
return ChannelData.empty()
Expand Down
29 changes: 17 additions & 12 deletions tutorials/noisepy_pnwstore_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 1,
"metadata": {
"id": "vceZgD83PnNc"
},
Expand All @@ -94,7 +94,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -107,8 +107,8 @@
],
"source": [
"STATION_XML = \"/1-fnp/pnwstore1/p-wd11/PNWStationXML/\" # storage of stationXML\n",
"DATA = \"/1-fnp/pnwstore1/p-wd00/PNW2020/__/\"\n",
"DB_PATH=\"/data/wsd01/PNWstore_sqlite/2020.sqlite\"\n",
"DATA = \"/1-fnp/pnwstore1/p-wd00/PNW2020/__/\" # __ indicates any two chars (network code)\n",
"DB_PATH=\"/1-fnp/pnwstore1/p-wd00/PNW2020/timeseries.sqlite\"\n",
"# timeframe for analysis\n",
"start = datetime(2020, 1, 2)\n",
"end = datetime(2020, 1, 4)\n",
Expand Down Expand Up @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {
"id": "dIjBD7riIfdJ"
},
Expand All @@ -168,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {
"id": "ByEiHRjmIAPB"
},
Expand Down Expand Up @@ -217,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -226,7 +226,7 @@
"0"
]
},
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -248,13 +248,18 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"stations = \"BBO,BABR,SHUK\".split(\",\") # filter to these stations\n",
"# cross network, cross channel type\n",
"# UW.BBO..HH\n",
"# UW.BABR..HH\n",
"# UW.SHUK..BH\n",
"# CC.PANH..BH\n",
"stations = \"BBO,BABR,SHUK,PANH\".split(\",\") # filter to these stations\n",
"catalog = XMLStationChannelCatalog(STATION_XML, path_format=\"{network}\" + os.path.sep + \"{network}.{name}.xml\")\n",
"raw_store = PNWDataStore(DATA, catalog, DB_PATH, channel_filter(stations, \"HH,BH\"), date_range=range) # Store for reading raw data from S3 bucket\n",
"raw_store = PNWDataStore(DATA, catalog, DB_PATH, channel_filter(stations, \"BH,HH\"), date_range=range) # Store for reading raw data from S3 bucket\n",
"cc_store = ASDFCCStore(cc_data_path) # Store for writing CC data\n",
"# print the configuration parameters. Some are chosen by default but we can modify them\n",
"# print(config)"
Expand Down Expand Up @@ -299,7 +304,7 @@
},
"outputs": [],
"source": [
"file = os.path.join(cc_data_path, '2020_01_03_00_00_00T2020_01_04_00_00_00.h5')\n",
"file = os.path.join(cc_data_path, '2020_01_02_00_00_00T2020_01_03_00_00_00.h5')\n",
"plotting_modules.plot_substack_cc(file,0.1,1,None,False)"
]
},
Expand Down

0 comments on commit fbe2cc1

Please sign in to comment.