Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed IRISSeismic_1.7.0.tar.gz
Binary file not shown.
Binary file added IRISSeismic_1.9.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ python run_ispaq.py -I #downloads latest packages from CRAN (https://cran.r-p
Or alternatively, install the EarthScope R packages from local files:
```
R CMD INSTALL seismicRoll_1.1.5.tar.gz
R CMD INSTALL IRISSeismic_1.7.0.tar.gz
R CMD INSTALL IRISSeismic_1.9.0.tar.gz
R CMD INSTALL IRISMustangMetrics_2.4.8.tar.gz
```

Expand Down
1 change: 1 addition & 0 deletions ispaq/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

from ispaq.ispaq import __version__
49 changes: 22 additions & 27 deletions ispaq/irisseismic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

# from future.types import newint
import logging
import pandas as pd
from obspy import UTCDateTime
import rpy2.robjects as ro
Expand Down Expand Up @@ -441,8 +442,7 @@ def _userAgent():
"""
Create user agent string for use with new("IrisClient")
"""
# ispaq_version = ispaq.__version__
ispaq_version = "3.4.0"
ispaq_version = ispaq.__version__

r_agent_string = ro.r(
"paste0('IRISSeismic/',installed.packages()['IRISSeismic','Version'],' RCurl/',installed.packages()['RCurl','Version'],' R/',R.version$major,'.',R.version$minor,' ',version$platform,' ISPAQ/')"
Expand Down Expand Up @@ -495,6 +495,12 @@ def getAvailability(
2 629145000
...
"""
logging.getLogger(__name__).warning(
"getAvailability will be deprecated in a future release. "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say it is deprecated now and not in a future release. It will be defunct and removed in a future release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest:
"getAvailability is deprecated and will be removed in a future release. The EarthScope fdsnws/station service no longer supports 'matchtimeseries' and 'includeavailability' parameters which are used by getAvailability. Without those parameters, getAvailability currently returns the same results as the getChannel function."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, there is a difference between the getAvailability in ISPAQ and that of IRISSeismic. This one can be deprecated now or could continue to exist while the underlying IRISSeismic::getAvailability has been changed (but not removed yet). The message does currently indicate that the upstream IRISSeismic::getAvailability has been changed to remove the parameters and will return the same as getChannel, but in reality the ISPAQ getAvailability function hasn't changed at all. matchtimeseries and includeavailability aren't even fields that can be passed along in ISPAQ's getAvailability.

I could at this point move ISPAQ off of ISPAQ's getAvailability and deprecate the function, that was my original plan and it's one of the changes I made before reverting back to using IRISSeismic::getAvailability.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matchtimeseries and includeavailability are hardcoded as parameters inside IRISSeismic getAvailability, but skipped if the source is PH5. So it does have this dependency, but it still works because of how ISPAQ is using it (or not using it). We're not intending ISPAQ to be used as a Python library for the CRAN R-code by users, so you're right that it doesn't really matter if it's explicitly deprecated or not. I think the important thing is to replace our use of the function so that when it gets removed from the R-code, ISPAQ does not break.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought that the updated v1.9.0 IRISSeismic::getAvailability removed those hardcoded matchtimeseries and includeavailability so that IRISSeismic::getAvailability no longer included those parameters at all. And then on the ISPAQ side, our only call out of (ISPAQ's) getAvailability includes the following:

 _R_getAvailability(
        r_client,
        network,
        station,
        location,
        channel,
        starttime,
        endtime,
        includerestricted,
        latitude,
        longitude,
        minradius,
        maxradius,
)

And then, yeah all other calls to the station service are done using obspy, which defaults to none for both matchtimeseries and includeavailability -- and ISPAQ doesn't provide either of those parameters for those calls either.

Regardless of the IRISSeismic::getAvailability behavior, I've switch back to having ISPAQ to use ISPAQ's getChannel, which relies on IRISSeismic::getChannel. So we're off of that dependency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, IRISSeismic did remove the parameters. I need more coffee.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, no problem - I think we're all on the same page now and I'm no longer second guessing my understanding of the changes to mustang-metrics

"The upstream IRISSeismic::getAvailability has been altered to remove the "
"'matchtimeseries' and 'includeavailability' parameters, so its output now "
"matches that of getChannel."
)
user_agent = _userAgent()
cmd = (
'new("IrisClient", site="'
Expand All @@ -505,16 +511,13 @@ def getAvailability(
+ user_agent
+ '")'
)
# cmd = 'new("IrisClient", site="' + client_url + '", service_type="' + client_type + '")'
r_client = ro.r(cmd)

starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)

(includerestricted, latitude, longitude, minradius, maxradius) = (
_R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)
includerestricted, latitude, longitude, minradius, maxradius = _R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)

# Call the function and return a pandas dataframe with the results
Expand Down Expand Up @@ -600,10 +603,8 @@ def getChannel(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(includerestricted, latitude, longitude, minradius, maxradius) = (
_R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)
includerestricted, latitude, longitude, minradius, maxradius = _R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)

# Call the function and return a pandas dataframe with the results
Expand Down Expand Up @@ -681,7 +682,7 @@ def R_getDataselect(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(quality, repository, inclusiveEnd, ignoreEpoch) = _R_args(
quality, repository, inclusiveEnd, ignoreEpoch = _R_args(
quality, repository, inclusiveEnd, ignoreEpoch
)

Expand Down Expand Up @@ -772,7 +773,7 @@ def getEvalresp(

# Convert python arguments to R equivalents
time = R_POSIXct(time)
(minfreq, maxfreq, nfreq, units, output) = _R_args(
minfreq, maxfreq, nfreq, units, output = _R_args(
minfreq, maxfreq, nfreq, units, output
)

Expand Down Expand Up @@ -834,7 +835,7 @@ def getEvent(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(minmag, maxmag, magtype, mindepth, maxdepth) = _R_args(
minmag, maxmag, magtype, mindepth, maxdepth = _R_args(
minmag, maxmag, magtype, mindepth, maxdepth
)

Expand Down Expand Up @@ -899,10 +900,8 @@ def getNetwork(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(includerestricted, latitude, longitude, minradius, maxradius) = (
_R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)
includerestricted, latitude, longitude, minradius, maxradius = _R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)

# Call the function and return a pandas dataframe with the results
Expand Down Expand Up @@ -970,7 +969,7 @@ def R_getSNCL(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(quality, repository, inclusiveEnd, ignoreEpoch) = _R_args(
quality, repository, inclusiveEnd, ignoreEpoch = _R_args(
quality, repository, inclusiveEnd, ignoreEpoch
)

Expand Down Expand Up @@ -1027,10 +1026,8 @@ def getStation(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(includerestricted, latitude, longitude, minradius, maxradius) = (
_R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)
includerestricted, latitude, longitude, minradius, maxradius = _R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)

# Call the function and return a pandas dataframe with the results
Expand Down Expand Up @@ -1128,10 +1125,8 @@ def getUnavailability(
# Convert python arguments to R equivalents
starttime = R_POSIXct(starttime)
endtime = R_POSIXct(endtime)
(includerestricted, latitude, longitude, minradius, maxradius) = (
_R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)
includerestricted, latitude, longitude, minradius, maxradius = _R_stationExtraArgs(
includerestricted, latitude, longitude, minradius, maxradius
)

# Call the function and return a pandas dataframe with the results
Expand Down
13 changes: 8 additions & 5 deletions ispaq/ispaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import numpy as np
import subprocess


__version__ = "3.4.0"
__version__ = "3.5.0"

# dictionary of currently defined ISPAQ metric groups and business logic
# for comparison with R package IRISMustangMetrics/ISPAQUtils.R json
Expand Down Expand Up @@ -224,8 +223,11 @@ def main():
# Full DEBUG level logging goes to ISPAQ_TRANSCRIPT.log
# Console logging level is set by the '--log-level' argument

logger = logging.getLogger(__name__)
# Use the 'ispaq' parent logger so all ispaq.* child loggers (e.g.
# ispaq.irisseismic, ispaq.concierge) propagate here and share these handlers.
logger = logging.getLogger("ispaq")
logger.setLevel(logging.DEBUG)
logger.propagate = False

formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S"
Expand Down Expand Up @@ -412,8 +414,9 @@ def main():
shell=True,
)
elif answer in rejected_answer:
print("Exiting now without updating conda packages.")
raise SystemExit
logger.warning(
f"Continuing with ObsPy {obspy.__version__}. Some features may not work as expected."
)

# Create UserRequest object ------------------------------------------------
#
Expand Down