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

Tutorial 4 - Geophysics (Seismology): Add JN #8

Open
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Nov 9, 2024

This PR adds the Jupyter notebook for Tutorial 4 - Geophysics (Seismology).

Content:

Feel free to fill the subsections with suggestions for code and docs🙂.

Preview:

Fixes: #6

@yvonnefroehlich yvonnefroehlich changed the title WIP: Add JN for tutorial 4 Geophysics (Seismology) WIP: Tutorial 4 - Geophysics (Seismology): Add JN Nov 9, 2024
@jhtong33
Copy link
Collaborator

Hi @yvonnefroehlich
do we use grdproject or project ?
Since grdproject is specified for a region rather than individual point-to-point.

see also: https://www.pygmt.org/v0.13.0/gallery/images/cross_section.html#sphx-glr-gallery-images-cross-section-py

@yvonnefroehlich
Copy link
Member Author

Hi @yvonnefroehlich do we use grdproject or project ? Since grdproject is specified for a region rather than individual point-to-point.

see also: https://www.pygmt.org/v0.13.0/gallery/images/cross_section.html#sphx-glr-gallery-images-cross-section-py

Yep, I am sorry, I mean project I mistyped this 🙁.

Copy link
Member Author

@yvonnefroehlich yvonnefroehlich left a comment

Choose a reason for hiding this comment

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

Thanks a lot, @jhtong33 , for getting started here 👍!

I made a few updates:

  • I prefer to use the Scientific colour maps by F. Crameri, i.e., for topography, "oleron".
  • I reduced the resolution of the image showing within the Jupyter notebook to keep the file size smaller.
  • I figured out that list input is supported for the center and endpoint parameters of project.
  • Fix typo grdproject to project.
  • So minor code style improvements.
  • I think we should be consistent and use either single (') or double (") quotation marks; I prefer double quotation marks.

@jhtong33
Copy link
Collaborator

Thanks a lot, @jhtong33 , for getting started here 👍!

I made a few updates:

  • I prefer to use the Scientific colour maps by F. Crameri, i.e., for topography, "oleron".
  • I reduced the resolution of the image showing within the Jupyter notebook to keep the file size smaller.
  • I figured out that list input is supported for the center and endpoint parameters of project.
  • Fix typo grdproject to project.
  • So minor code style improvements.
  • I think we should be consistent and use either single (') or double (") quotation marks; I prefer double quotation marks.

Great! Thanks for your updates.
I used a remote dataset to convert data into a .txt file, which I then provided as input materials for pygmt.xyz2grd.

@jhtong33
Copy link
Collaborator

Hi @yvonnefroehlich
I have one idea that plotting beachballs for magnitude >6 events to make the tutorial more comprehensive.
However, If time make it challenging to cover all details within a 45-minute session, it would be great to focus on one significant event as an example.

see also: https://www.isc.ac.uk/cgi-bin/web-db-run?request=COMPREHENSIVE&out_format=CATCSV&searchshape=RECT&bot_lat=-40&top_lat=0&left_lon=-90&right_lon=-60&ctr_lat=&ctr_lon=&radius=&max_dist_units=deg&srn=&grn=&start_year=2022&start_month=1&start_day=01&start_time=00%3A00%3A00&end_year=2023&end_month=1&end_day=01&end_time=00%3A00%3A00&min_dep=&max_dep=&min_mag=6&max_mag=&req_mag_type=MW&req_mag_agcy=&include_links=on

@yvonnefroehlich yvonnefroehlich changed the title WIP: Tutorial 4 - Geophysics (Seismology): Add JN Tutorial 4 - Geophysics (Seismology): Add JN Nov 23, 2024
@yvonnefroehlich
Copy link
Member Author

yvonnefroehlich commented Nov 23, 2024

In this tutorial, we create a more complex figure across multiple cells. In this case, re-running cells to play around with different arguments for the parameters does not work (it only works for the cell that contains the creation of the new Figure instance).

To improve this, I was wondering if it can work to create for each cell a new "figure variable", i.e. start with fig1 = pygmt.Figure(), next cell fig2 = fig1, next cell fig3 = fig2, etc. (please see commit 075ea2e for this change). In this way, fig1 is not affected by the changes in the cell for fig2 and re-running this cell would again start at the status of fig1. But so far, it looks like it does not work as expected, and both fig1 and fig2 are changed. I am not a Jupyter notebook or lab user (but prefer to write normal [Python] scripts), so ideas from more experienced users are highly welcome 🙂.

@yvonnefroehlich
Copy link
Member Author

yvonnefroehlich commented Nov 24, 2024

So, some more updates

  • Section 3: Added subsection for Section 3 to improve the structure
  • Section 4: Removed the code for plotting seismicity and added some references for orientation
  • Some improvements and additions to the docs
  • Use a colormap of the SC that does not flip between the (GMT) versions
  • Change color of contour line labels for better visibility
  • Introduces a variable to set the resolution for the images within the JN for all images consistently
  • Cartesian plot: Plot the profile with color-coding for the elevation

@jhtong33
Copy link
Collaborator

jhtong33 commented Nov 24, 2024

In this way, fig1 is not affected by the changes in the cell for fig2 and re-running this cell would again start at the status of fig1. But so far, it looks like it does not work as expected, but both fig1 and fig2 are changed. I am not a Jupyter notebook or lab user (but prefer to write normal [Python] scripts), so ideas from more experienced users are highly welcome 🙂.

Understanding your concerns, this approach achieves the same results we expected. By doing it this way, we can avoid altering the original figure.

  • Cartesian plot: Plot the profile with color-coding for the elevation

I prefer using a black line since color-coding does not better visualize the topography variations. The y-axis already effectively indicates this information.

@jhtong33
Copy link
Collaborator

Hi @yvonnefroehlich, I think this tutorial can be reviewed.

@yvonnefroehlich
Copy link
Member Author

  • Cartesian plot: Plot the profile with color-coding for the elevation

I prefer using a black line since color-coding does not better visualize the topography variations. The y-axis already effectively indicates this information.

Totally fine! Maybe using the same color as the profil line has would nice (in our case red).

@yvonnefroehlich
Copy link
Member Author

In this way, fig1 is not affected by the changes in the cell for fig2 and re-running this cell would again start at the status of fig1. But so far, it looks like it does not work as expected, but both fig1 and fig2 are changed. I am not a Jupyter notebook or lab user (but prefer to write normal [Python] scripts), so ideas from more experienced users are highly welcome 🙂.

Understanding your concerns, this approach achieves the same results we expected. By doing it this way, we can avoid altering the original figure.

Hm. But for me, this approach does not work in the expected way. Actually, this reminds me a bit of ObsPy where users actively need to copy the Stream object, before applying any processing steps in case they want to keep their raw data in the initial variable unchanged (https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.copy.html).

@yvonnefroehlich yvonnefroehlich added the needs review Review of this PR is welcome label Nov 24, 2024
@jhtong33
Copy link
Collaborator

Hm. But for me, this approach does not work in the expected way. Actually, this reminds me a bit of ObsPy where users actively need to copy the Stream object, before applying any processing steps in case they want to keep their raw data in the initial variable unchanged (https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.copy.html).

I misunderstood your meaning previously. I also encounter same condition in Jupyter lab.
In obspy, they use copy.deepcopy(self). I tried to use same way to solve this issue, but the result is same.

@yvonnefroehlich
Copy link
Member Author

As this

Hm. But for me, this approach does not work in the expected way. Actually, this reminds me a bit of ObsPy where users actively need to copy the Stream object, before applying any processing steps in case they want to keep their raw data in the initial variable unchanged (https://docs.obspy.org/packages/autogen/obspy.core.stream.Stream.copy.html).

I misunderstood your meaning previously. I also encounter same condition in Jupyter lab. In obspy, they use copy.deepcopy(self). I tried to use same way to solve this issue, but the result is same.

No worries!
As this is not working as expected, I removed introducing different variables for the Figure in 2a2e238.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs review Review of this PR is welcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tutorial 4 - Geophysics (Seismology): Ideas and basic concept
2 participants