feature/store_tables #245

Open
hvasbath wants to merge 5 commits from feature/store_tables into master
Collaborator

Add method to gf stores to create interpolation tables of other ray attributes.
For now takeoff-angles and incidence angels.
Another method, get_stored_attribute allows to request those from the stored tables.

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have added unit tests and all tests pass.
  • I have updated the documentation accordingly.
  • I have updated the changelog accordingly.
Add method to gf stores to create interpolation tables of other ray attributes. For now takeoff-angles and incidence angels. Another method, get_stored_attribute allows to request those from the stored tables. ## Description <!--- Describe your changes in detail --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> ## How has this been tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, tests ran to see how --> <!--- your change affects other areas of the code, etc. --> ## Screenshots (if appropriate): ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [x] I have added unit tests and all tests pass. - [ ] I have updated the documentation accordingly. - [ ] I have updated the changelog accordingly.
hvasbath added 2 commits 5 months ago
Owner

Ready for review?

Ready for review?
Poster
Collaborator

Yes!

Yes!
Owner

Yes!

Who? Please assign reviewers :)

> Yes! Who? Please assign reviewers :)
hvasbath requested review from miili 4 months ago
hvasbath requested review from emolch 4 months ago
miili requested changes 3 months ago
src/gf/store.py Outdated
return self.get_stored_phase(phase_def, attribute)(*args)
except NoSuchPhase:
raise StoreError(
'Interpolation table for %s does not exist!' % attribute)
miili commented 3 months ago
Poster
Owner

Please add available attributes to Exception.

Please add available attributes to Exception.
src/gf/store.py Outdated
if attribute not in available_stored_tables:
raise StoreError(
'Cannot create attribute table for %s' % attribute)
miili commented 3 months ago
Poster
Owner

Add available attributes to the exception for better user experience.

Add available attributes to the exception for better user experience.
src/gf/store.py Outdated
from pyrocko import cake
config = self.config
if not config.tabulated_phases:
miili commented 3 months ago
Poster
Owner

imo this should fail hard.

imo this should fail hard.
Poster
Collaborator

Can you please be more specific what you mean?

Can you please be more specific what you mean?
miili commented 3 months ago
Poster
Owner

Do not return but raise an exception.

Do not return but raise an exception.
Poster
Collaborator

Raising an error here causes thousands of tests to fail. Will revert to just return and do nothing.

Raising an error here causes thousands of tests to fail. Will revert to just return and do nothing.
src/gf/store.py Outdated
if config.earthmodel_receiver_1d:
self.check_earthmodels(config)
if not mod:
miili commented 3 months ago
Poster
Owner

Reorder, move 4 lines up.

Reorder, move 4 lines up.
hvasbath marked this conversation as resolved
src/gf/store.py Outdated
def evaluate(args):
if len(args) == 2:
zr, zs, x = (config.receiver_depth,) + args
miili commented 3 months ago
Poster
Owner

what is zr, zs or x? Please use self-describing variable names.

what is `zr`, `zs` or `x`? Please use self-describing variable names.
hvasbath marked this conversation as resolved
src/gf/store.py Outdated
elif len(args) == 3:
zr, zs, x = args
else:
assert False
miili commented 3 months ago
Poster
Owner

Please raise a meaningful exception.

Please raise a meaningful exception.
hvasbath marked this conversation as resolved
src/gf/store.py Outdated
else:
assert False
t = []
miili commented 3 months ago
Poster
Owner

Please use meaningful variable names. Avoid single character variables.

Please use meaningful variable names. Avoid single character variables.
hvasbath marked this conversation as resolved
src/gf/store.py Outdated
if attribute == 'phase':
for v in horvels:
t.append(x/(v*1000.))
miili commented 3 months ago
Poster
Owner

Use km constant.

Use `km` constant.
hvasbath marked this conversation as resolved
src/gf/store.py Outdated
else:
return None
logger.info('making "%s" table for phasegroup "%s"' %
miili commented 3 months ago
Poster
Owner

Use logger.info("%s", string) notation.

Use `logger.info("%s", string)` notation.
hvasbath marked this conversation as resolved
table_time = (t1 - t0) / 100
print('\nTable time', table_time)
print('Table angle', interpolated_attribute)
zr, zs, x = (store.config.receiver_depth,) + args
miili commented 3 months ago
Poster
Owner

Rename variables.

Rename variables.
hvasbath marked this conversation as resolved
print('Table angle', interpolated_attribute)
zr, zs, x = (store.config.receiver_depth,) + args
t2 = time()
for i in range(100):
miili commented 3 months ago
Poster
Owner

use _ for unused iterator.

use `_` for unused iterator.
hvasbath marked this conversation as resolved
self.assertTrue(
numeq(interpolated_attribute, cake_attribute, 0.005))
self.assertRaises(
miili commented 3 months ago
Poster
Owner

Use context

with self.assertRaises(SomeException):
	...

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises

Use context ```python with self.assertRaises(SomeException): ... ``` https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises
hvasbath marked this conversation as resolved
hvasbath added 1 commit 3 months ago
d3bd2a97ba store: add interpolate many stored attributes, cleanup
hvasbath requested review from miili 3 months ago
hvasbath added 1 commit 3 months ago
d15f91c3c1 store: revert change for raising an error if no tabulated phase exists
hvasbath added 108 commits 2 months ago
07ef82a0d1 sta/lta snuffling: various improvements
452bedc1a5 rms snuffling: various improvements
35d1900846 docs gf: fix and improve
b3a3d84998 fomosto qseis backend: allow non-zero (and negative) surface level
e989357c91 tectonics: update reading to handle strings consistent in py2 and py3
7677c51df9 add okada modelling and pseudo-dynamic rupture model (chapter 4)
fa36947d21 okada: started work on new dynamic rupture plotting module WIP
0f8003a958 adding tractions models for PseudoDynamicRupture
b98ca6fcb7 modelling: adding m6s // adding docs
5c920ede65 add okada modelling and pseudo-dynamic rupture model (chapter 20)
7deedce581 snuffler: updates
c066bbd9d8 dynamic rupture plot: updates
057ac53f67 add okada modelling and pseudo-dynamic rupture model (chapter 21)
6c41a5bcb5 add okada modelling and pseudo-dynamic rupture model (chapter 23)
4216ba7e9a snuffler: revert slider valchange rate limit
04431fd65a directivity plot: fixes and improvements
b5aca93e29 polarization snuffling: polishing
Poster
Collaborator

ah yes how I love this rebasing shit-.... I did exactly as written in the contributing guide ... any advice?

ah yes how I love this rebasing shit-.... I did exactly as written in the contributing guide ... any advice?
hvasbath force-pushed feature/store_tables from b5aca93e29 to 0da9c77501 2 months ago
hvasbath added 1 commit 2 months ago
8f1ddcb910 fomosto: add options sat and satview to access interpolation tables
hvasbath force-pushed feature/store_tables from 8f1ddcb910 to 46adc4a326 2 months ago
miili requested changes 2 months ago
miili left a comment

Thanks! This is great :D

'tttview': 'plot travel time table',
'tttextract': 'extract selected travel times',
'tttlsd': 'fix holes in travel time tables',
'sat': 'create stored ray attribute table',
miili commented 2 months ago
Poster
Owner

Can we find something descriptive. idk what sat means.

Can we find something descriptive. idk what `sat` means.
Poster
Collaborator

See docstring behind: (s)tored ray (a)ttribute (t)able

Edit like this with paranthesis?

See docstring behind: (s)tored ray (a)ttribute (t)able Edit like this with paranthesis?
return min(t)
else:
return None
def make_tat(self, force=False):
miili commented 2 months ago
Poster
Owner

write out tat

write out `tat`
Poster
Collaborator

was following convention of make_ttt. Then we would need to change that as well to make_traveltimetable to keep things consistent?!
The docstring then is very clear what it means.

was following convention of make_ttt. Then we would need to change that as well to make_traveltimetable to keep things consistent?! The docstring then is very clear what it means.

Reviewers

emolch was requested for review 4 months ago
miili requested changes 2 months ago
Some checks failed
continuous-integration/drone/push Build is failing
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
Sign in to join this conversation.
Loading…
There is no content yet.