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 2 - scientific Python ecosystem: pandas and GeoPandas: Add JN #4

Merged
merged 35 commits into from
Nov 28, 2024

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Sep 22, 2024

This PR adds the Jupyter notebook for Tutorial 2 - scientific Python ecosystem: pandas and GeoPandas:

  • Data stored as pandas DataFrame and GeoPandas GeoDataFrame
  • Different geometries (point, lines, polygons)
  • Choropleth map
  • Handling aspatial data
  • Filtering and using different styles / files for plotting
  • Conversion of objects from other python packages to geopandas related objects

Preview:

@yvonnefroehlich yvonnefroehlich added the enhancement New feature or request label Sep 22, 2024
@yvonnefroehlich yvonnefroehlich self-assigned this Sep 22, 2024
@yvonnefroehlich yvonnefroehlich marked this pull request as draft September 22, 2024 18:12
@yvonnefroehlich yvonnefroehlich changed the title WIP: Add JN for tutorial on pandas and geopandas WIP: Add JN for tutorial 3 on pandas and geopandas Nov 9, 2024
@yvonnefroehlich yvonnefroehlich changed the title WIP: Add JN for tutorial 3 on pandas and geopandas WIP: Add JN for tutorial 3 on pandas and GeoPandas Nov 9, 2024
@yvonnefroehlich yvonnefroehlich changed the title WIP: Add JN for tutorial 3 on pandas and GeoPandas WIP: Add JN for tutorial 2 on pandas and GeoPandas Nov 9, 2024
@yvonnefroehlich yvonnefroehlich changed the title WIP: Add JN for tutorial 2 on pandas and GeoPandas WIP: Tutorial 2 - SPEC: pandas and GeoPandas: Add JN Nov 9, 2024
@yvonnefroehlich yvonnefroehlich changed the title WIP: Tutorial 2 - SPEC: pandas and GeoPandas: Add JN WIP: Tutorial 2 - scientific Python ecosystem: pandas and GeoPandas: Add JN Nov 9, 2024
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Notebook looks very clean and easy to follow so far! Just some minor suggestions for now, not sure if you're planning to add more materials to this notebook?

book/tut2_spec_pd_gpd.ipynb Outdated Show resolved Hide resolved
book/tut2_spec_pd_gpd.ipynb Outdated Show resolved Hide resolved
book/tut2_spec_pd_gpd.ipynb Outdated Show resolved Hide resolved
book/tut2_spec_pd_gpd.ipynb Outdated Show resolved Hide resolved
@yvonnefroehlich
Copy link
Member Author

Notebook looks very clean and easy to follow so far! Just some minor suggestions for now, not sure if you're planning to add more materials to this notebook?

Thanks @weiji14 for already looking at this JN and the positive feedback! I feel the general structure should be finished. What is missing is some documentation and improvements of the formulations, as you already suggested.

@yvonnefroehlich yvonnefroehlich changed the title WIP: Tutorial 2 - scientific Python ecosystem: pandas and GeoPandas: Add JN Tutorial 2 - scientific Python ecosystem: pandas and GeoPandas: Add JN Nov 13, 2024
@yvonnefroehlich
Copy link
Member Author

Just a simple suggestion, using individual cells can help beginners understand how to set a region. For example, they can observe the data range beforehand through print(df_jp_eqs["magnitude"].min(), df_jp_eqs["magnitude"].max()) to demonstrates how to visualize data limits.

This is a good suggestions! Moved these lines to a separate cell.

@yvonnefroehlich yvonnefroehlich marked this pull request as ready for review November 17, 2024 01:05
@yvonnefroehlich yvonnefroehlich added the needs review Review of this PR is welcome label Nov 17, 2024
@Esteban82
Copy link
Member

I think is ready to merge. My only minor suggestion would be to add a frame to the choropleth map.

book/_toc.yml Outdated
@@ -13,3 +13,4 @@ parts:
- file: markdown
- file: notebooks
- file: markdown-notebooks
- file: tut2_spec_pd_gpd
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it's better to add the file names of the JNs or files together within one PR to avoid merge conflicts.

Copy link
Member

Choose a reason for hiding this comment

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

Let's just leave it as is, it'll be a good example to learn how to handle merge conflicts 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Ok, first tutorial is merged, so you'll need to resolve the merge conflict here. If you could also rename the file to tut02_spec_pd_gpd (add an extra 0), that would make it consistent with the first tutorial.

Comment on lines +11 to +13
# Tutorial 2 - pandas and GeoPandas, Tutorial 4 - Geophysics (Seismology)
- pandas=2.2.2
- geopandas=1.0.1
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above, maybe better to update the environment.yml within one PR for all tutorials to avoid merge conflicts.

Copy link
Member

@weiji14 weiji14 Nov 24, 2024

Choose a reason for hiding this comment

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

Since pandas is a required dependency of pygmt, this won't need to be added here, unless you specifically require pandas=2.2.2?

Note that I'll be updating the conda-lock.yml file to pin all dependencies once all the tutorial notebooks are merged, so that people can reproduce the exact dependency versions in the future (including pandas).

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I specifically need this pandas version. Just added the version I am currently having installed in the virtual environment I am using for this pre-workshop.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, we can leave the pin on pandas=2.2.2, sometimes good to be explicit.

Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

This tutorial is next in line to be merged! @yvonnefroehlich, if you can handle the merge conflict on _toc.yml, and maybe add some commentary around fig.legend, I can merge this in the next 24hours.

book/tut2_spec_pd_gpd.ipynb Outdated Show resolved Hide resolved
Comment on lines 312 to 316
"# Add a heading (+H) to the legend and adjust the font size (+f) to 9 points\n",
"fig.plot(data=gpd_rivers_short, pen=\"0.5p,orange\", label=f\"shorter {len_limit} m+Hriver length+f9p\")\n",
"fig.plot(data=gpd_rivers_long, pen=\"0.5p,darkred\", label=f\"longer {len_limit} m\")\n",
"\n",
"fig.legend(position=\"jLT+o0.1c\", box=\"+gwhite@30+p0.1p,gray50\")\n",
Copy link
Member

Choose a reason for hiding this comment

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

Since fig.legend isn't explained in the first tutorial, could you add some text to explain it before the code cell? You can just link to https://www.pygmt.org/v0.13.0/api/generated/pygmt.Figure.legend.html and/or one of the PyGMT gallery examples using legend.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense! I have added some documentation in commit 909f713.

Comment on lines +11 to +13
# Tutorial 2 - pandas and GeoPandas, Tutorial 4 - Geophysics (Seismology)
- pandas=2.2.2
- geopandas=1.0.1
Copy link
Member

Choose a reason for hiding this comment

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

Ok, we can leave the pin on pandas=2.2.2, sometimes good to be explicit.

@yvonnefroehlich
Copy link
Member Author

This tutorial is next in line to be merged! @yvonnefroehlich, if you can handle the merge conflict on _toc.yml, and maybe add some commentary around fig.legend, I can merge this in the next 24hours.

Sounds good! Have resolved the merge conflict and added the leading "0" to the file name (b7f789e).

@weiji14 weiji14 merged commit 99dde5d into main Nov 28, 2024
1 check passed
@weiji14 weiji14 deleted the add-jn-pd-gpd branch November 28, 2024 09:26
@weiji14
Copy link
Member

weiji14 commented Nov 28, 2024

Thanks again @yvonnefroehlich, this PR is merged and tutorial is now up at https://www.generic-mapping-tools.org/agu24workshop/tut02_spe_pd_gpd.html 🎉. Feel free to open a PR for any minor changes (if needed) before the workshop.

@yvonnefroehlich yvonnefroehlich removed the needs review Review of this PR is welcome label Nov 28, 2024
@@ -14,3 +14,4 @@ parts:
- file: notebooks
- file: markdown-notebooks
- file: tut01_firstfigure
- file: tut02_spec_pd_gpd
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we should use "spe" instead of "spec" as the later one seems to refere to scientific Python ecosystem coordination (please see https://scientific-python.org/specs/ [, and Dongdong's very detailed review on my draft for the pygmt talk])?

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

Successfully merging this pull request may close these issues.

4 participants