Skip to content

Conversation

lpilz
Copy link
Collaborator

@lpilz lpilz commented Apr 13, 2022

Change Summary

Tutorial showing xWRF usage.

Related issue number

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable

@lpilz
Copy link
Collaborator Author

lpilz commented Apr 13, 2022

@andersy005 Can you advise me on how to properly integrate the jupyter notebooks into the docs?

@andersy005
Copy link
Member

andersy005 commented Apr 13, 2022

@andersy005 Can you advise me on how to properly integrate the jupyter notebooks into the docs?

@lpilz, since we are already using markdown for docs, i would recommend using myst + jupytext combo to author the notebooks as well. here's an example of a notebook in a myst markdown format: https://raw.githubusercontent.com/intake/intake-esm/main/docs/source/tutorials/index.md. with myst + jupytext, the git diff integration is way smoother than the native notebook's (which is a huge plus in my opinion)

here's a pointer to the docs as well: https://myst-nb.readthedocs.io/en/latest/use/markdown.html

feel free to ping me whenever you need any feedback and/or clarification

@dcherian
Copy link
Contributor

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/xwrf/conda/72/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 294, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named xwrf-dev

I've had trouble with writing a notebook using nb_conda_kernels making the RTD build fail. If you resave the notebook with just "Python3 (ipykernel)" (i.e.choose the base kernel because the RTD build will need to use that after activating the environment), the build should move forward.

@lpilz
Copy link
Collaborator Author

lpilz commented Apr 14, 2022

Alright, thanks @andersy005 and @dcherian for your help! After a bit of trial and error, everything seems to work now and this is ready for review from my end. Looking forward to your suggestions :)

@lpilz lpilz marked this pull request as ready for review April 14, 2022 12:04
@kmpaul
Copy link
Contributor

kmpaul commented Apr 14, 2022

@lpilz: This is looking great! Thanks for doing this!

Some comments:

  1. I'm wondering if we should reference the non-code name of the project as simply xWRF, instead of xWRF (i.e., without the back-ticks). My thinking here is that back-ticks should be used for the name of actual code. For example, the package that you import would be xwrf, but the "English name" of the package is xWRF. (Does that make sense? I'm open to other suggestions.)

  2. It appears that the xarray HTML reprs do not play well with dark mode iin the furo Sphinx theme. Some of the text is rendering with too little contrast to visually see in dark mode, but it displays beautifully with light mode. I don't think this a problem for xWRF to solve, but it is something that needs further investigation and a new issue in the right place needs to be made (or a PR, if we can figure out how to fix it). (Note that there are lots of dark-mode display problems that have come up: small contrast of html view in VScode darkmode pydata/xarray#4024, support darkmode pydata/xarray#4036, Dark theme-friendly HTML Dataset and DataArray reprs for jupyter notebooks? pydata/xarray#4161, and others, I'm sure.)


def interp_and_keep_attrs(grid, da, axis):
_attrs = da.attrs
da = grid.interp(da, axis=axis)
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it seem like the "stagger" attribute should not be present at all.

The information about staggering is already present in the dimension names, indeed that is the xarray+xgcm data model: we know where the variables are on the grid by looking at names of dimensions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a point, which @jthielen also raised in #70. Maybe we should discuss this in a new issue? My argument would be that there might be code in use depending on these attributes, which would break if we stripped them.

Copy link
Collaborator Author

@lpilz lpilz Apr 20, 2022

Choose a reason for hiding this comment

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

I just read this one again and maybe we should refrain from manually adding the stagger attribute here, since this is really not needed. My thinking was just that somebody might want to simply copy and paste this code...

@kmpaul
Copy link
Contributor

kmpaul commented Apr 18, 2022

@lpilz: I believe I have developed a "hack" to fix the xarray HTML repr display issues. It turns out the that Xarray HTML repr includes/ships CSS that assumes that any theme changes will be contained in the html element's theme attribute. But the Sphinx Furo theme assumes that the body element will have a data-theme attribute containing the theme (dark or light or auto). So, I added some custom javascript to force the html[theme] attribute to match the body[data-theme] attribute.

@kmpaul
Copy link
Contributor

kmpaul commented Apr 18, 2022

I'm not sure what the proper fix for this is...whether it should go in the Furo theme or in Xarray to specifically deal with the Furo theme.

@kmpaul
Copy link
Contributor

kmpaul commented Apr 18, 2022

BTW, this fix works on Chrome, and I haven't verified with other browsers.

@andersy005
Copy link
Member

BTW, this fix works on Chrome, and I haven't verified with other browsers.

unfortunately, this is still not functional on non-chromium based browsers

  1. Safari

Screen Shot 2022-04-18 at 10 12 46 PM

  1. Firefox

Screen Shot 2022-04-18 at 10 11 48 PM

@lpilz
Copy link
Collaborator Author

lpilz commented Apr 19, 2022

@kmpaul

I'm wondering if we should reference the non-code name of the project as simply xWRF, instead of xWRF

I also put some thought into that and decided to preliminarily go with the backticked version simply because of capitalization issues at the start of sentences. However, I agree that it adds a level of highlight that is maybe too much. I'll change it and we can just see if we like it like that.

@lpilz
Copy link
Collaborator Author

lpilz commented Apr 19, 2022

@kmpaul Thanks for your work on the styling issue. Unfortuately, I don't have a lot of experience with front end engineering, so I won't be able to help a lot on this. But if there is something I can do nonetheless - don't hesitate to delegate.

@andersy005
Copy link
Member

In my opinion, we should document the styling issue in a separate issue and address it at a later time

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

@andersy005: I think that's fine. Yes. I realized that my fix might be browser limited...but I wasn't expecting it to be that limited. Since it displays fine with the light theme of Furo, which is always an option, let's not let the styling issue hold up this PR.

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

See #73

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

Incidentally, I implemented the "proper fix" for this in Xarray yesterday (see pydata/xarray#6500 and pydata/xarray#6501). So, after the next release of Xarray, we won't need this hacky fix anyway.

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

Well... So, I know we said we'd fix this in another PR, but it turns out the fix was really easy. It shouldn't have worked on Chrome, either, but it turns out Chrome is a little more forgiving about assigning values to const variables. So, I just fixed it.

@andersy005
Copy link
Member

thank you 🙏, @kmpaul! the fix looks great

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

Thanks, @andersy005! I'm appreciate that.

@lpilz
Copy link
Collaborator Author

lpilz commented Apr 19, 2022

I concur, nice work. Thanks a lot @kmpaul :)

@kmpaul
Copy link
Contributor

kmpaul commented Apr 19, 2022

@lpilz, you are welcome! Glad I could help!

@lpilz lpilz merged commit 62a9613 into xarray-contrib:main Apr 21, 2022
@lpilz lpilz deleted the tutorial branch April 21, 2022 12:35
@jthielen jthielen mentioned this pull request Jul 13, 2022
3 tasks
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.

4 participants