Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use trace.remove_response() for instrument correction #27

Merged
merged 30 commits into from Mar 16, 2023

Conversation

claudiodsf
Copy link
Member

This PR modernizes the instrument correction routine remove_instr_response() which goes from using trace.simulate() and poles and zeros to trace.remove_response() and full response, as defined in the Inventory() object.

In case users provide a PAZ file, this is converted to an Inventory() object using a custom routine.

Tested and validated on all my examples.

@krisvanneste, I don't know if you use instrument correction from SourceSpec. If that's the case, I'll wait on your feedback before merging. Thanks!

TODO: use config.trace_units when a generic PAZ file id provided
…object

Rename PAZFile() class to PAZ() and move more functions inside the
class.
TODO: _add_paz() will be removed when moving to modern deconvolution
routines
Also, removed the option `sensitivity_only` from
`correct_instrumental_response`
To support the "DEF" option in `trace.remove_response()`
To check if instrument type is consistent with units in inventory
@krisvanneste
Copy link
Collaborator

Claudio,

I will try it.
Kris

@krisvanneste
Copy link
Collaborator

Unfortunately, I have a problem with my obspy version. I'm still on 1.2.2, but now 1.3.0 is required.
Do you use some specific functionality in 1.3.0 that was not there in 1.2.2?
It would of course be good if I update obspy, but I tried it before and the conda updater never found a solution to sort out the dependencies. I will try to clone my environment and try forcing the update...

@claudiodsf
Copy link
Member Author

The reason why I moved to ObsPy 1.3.0 is the option 'DEF' in trace.remove_response() (this line), so that I convert the trace to its nominal units (before doing the integration in ssp_build_spectra()).

A workaround could be to retrieve nominal units from inv.get_response(trace.id, trace.stats.starttime).instrument_sensitivity.input_units and set output to 'VEL', 'DISP' or 'ACC' accordingly.

I can do that! ;-)

@claudiodsf
Copy link
Member Author

Ok, done!

@krisvanneste
Copy link
Collaborator

Thanks for the quick fix!
It runs now.
Now I get the following error message for all stations:
BE.BEBN..HHZ broadb: Unable to remove instrument response: skipping trace
However, this may be due to the way I run sourcespec. I will investigate.

@krisvanneste
Copy link
Collaborator

I finally fixed it. Instead of _add_paz_and_coords, I had to call _add_inventory, _add_coords and _check_instrtype. I also had to turn off clipping detection if I pre-restitute my traces before running sourcespec.
For the example I used, I obtain moment magnitudes that differ less than 0.1 (with 1 exception). The differences can best be evaluated based on the spectra.
Spectra obtained after restitution inside sourcespec:
3069 ssp 00
Spectra obtained after pre-restitution to displacement:
3069 ssp 00

The largest difference can be observed for station BE.UCCS. I think this is due to more narrow pre-filtering on my side.

@krisvanneste
Copy link
Collaborator

The example also reminds me that I should ask you if it is possible to constrain Qo to positive values...

@claudiodsf
Copy link
Member Author

The example also reminds me that I should ask you if it is possible to constrain Qo to positive values...

Yes, you can either provide limits in t_star or in Qo.

From the Configuration File:

# Initial value for t_star (seconds)
t_star_0 = 0.045
# Try to invert for t_star_0.
# If the inverted t_star_0 is non-positive, then fixed t_star_0 will be used
invert_t_star_0 = False
# Allowed variability around inverted t_star_0 in the main inversion
# (expressed as a fraction of t_star_0, between 0 and 1).
# If the inverted t_star_0 is non-positive, then t_star_min_max is used
# (see below).
t_star_0_variability = 0.1

and

# t_star_min_max does not superseed t_star_0_variability
t_star_min_max = None
# optional : Qo bounds (converted into t_star bounds in the code).
# (comment out or use None to indicate no bound)
# Note: if you want to explore negative t_star values, you have to specify
# -Qo_min, Qo_min. This beacause t_star is proportional to 1/Qo.
# Example, for searching only positive t_star values:
#   Qo_min_max = 10, 1000
# If you want to search also negative t_star values:
#   Qo_min_max = -10, 10
Qo_min_max = None

I generally set t_star_min_max

@claudiodsf
Copy link
Member Author

For the example I used, I obtain moment magnitudes that differ less than 0.1 (with 1 exception). The differences can best be evaluated based on the spectra.

What's your metadata format? StationXML, datalessSEED, PAZ, other?

@krisvanneste
Copy link
Collaborator

Thanks for the pointer!

@krisvanneste
Copy link
Collaborator

For the example I used, I obtain moment magnitudes that differ less than 0.1 (with 1 exception). The differences can best be evaluated based on the spectra.

What's your metadata format? StationXML, datalessSEED, PAZ, other?

It's StationXML in this case; in other cases it may also be dataless SEED.

@claudiodsf
Copy link
Member Author

It's StationXML in this case; in other cases it may also be dataless SEED.

Ok, thanks.

Do you think we can validate this, or do you prefer to do more testing?

@krisvanneste
Copy link
Collaborator

I don't think I can test more from my side. I always work with full obspy station inventories, not with PAZ.

@claudiodsf
Copy link
Member Author

Ok, thanks. So, I'm going to merge this and wait for bug reports ::😜

@claudiodsf claudiodsf merged commit 43a0346 into master Mar 16, 2023
@claudiodsf claudiodsf deleted the instrument_correction branch March 16, 2023 10:46
@krisvanneste
Copy link
Collaborator

OK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants