Skip to content

Commit 0b01221

Browse files
authored
Merge pull request #101 from xylar/expand-docs
A major expansion of the docs
2 parents 6ba5df7 + aa40f2d commit 0b01221

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1006
-137
lines changed

Diff for: LICENSE

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
This software is open source software available under the BSD-3 license.
22

3-
Copyright (c) 2019 Triad National Security, LLC. All rights reserved.
4-
Copyright (c) 2019 Lawrence Livermore National Security, LLC. All rights reserved.
5-
Copyright (c) 2019 UT-Battelle, LLC. All rights reserved.
3+
Copyright (c) 2025 Triad National Security, LLC. All rights reserved.
4+
Copyright (c) 2025 Lawrence Livermore National Security, LLC. All rights reserved.
5+
Copyright (c) 2025 UT-Battelle, LLC. All rights reserved.
66

77

8-
Copyright (c) 2019 Triad National Security, LLC. This program was produced
8+
Copyright (c) 2025 Triad National Security, LLC. This program was produced
99
under U.S. Government contract 89233218CNA000001 for Los Alamos National
1010
Laboratory (LANL), which is operated by Triad National Security, LLC for the
1111
U.S. Department of Energy/National Nuclear Security Administration. All rights
@@ -16,7 +16,7 @@ irrevocable worldwide license in this material to reproduce, prepare derivative
1616
works, distribute copies to the public, perform publicly and display publicly,
1717
and to permit others to do so.
1818

19-
Copyright (c) 2019 Lawrence Livermore National Security, LLC. This work was
19+
Copyright (c) 2025 Lawrence Livermore National Security, LLC. This work was
2020
produced under the auspices of the U.S. Department of Energy by Lawrence
2121
Livermore National Laboratory under Contract DE-AC52-07NA27344. This work was
2222
prepared as an account of work sponsored by an agency of the United States

Diff for: README.md

+7-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pyremap
22

3+
![pyremap logo](docs/_static/logo.png)
4+
35
Python remapping tools for climate and earth system models.
46

57
## Documentation
@@ -24,44 +26,10 @@ python -m pip install --no-deps --no-build-isolation -e .
2426

2527
## Examples
2628

27-
```
28-
cd examples
29-
```
30-
First, make mapping files for a lat-lon grid, and test it out by remapping
31-
temperature from the example file:
32-
```
33-
wget https://web.lcrc.anl.gov/public/e3sm/inputdata/ocn/mpas-o/oQU240/ocean.QU.240km.151209.nc
34-
./make_mpas_to_lat_lon_mapping.py
35-
```
36-
You should now see the mapping file:
37-
```
38-
map_oQU240_to_0.5x0.5degree.nc
39-
```
40-
as well as the input file (an initial condition for the MPAS-Ocean model) and
41-
an example of temperature from the initial condition remapped to the new grid.
42-
```
43-
ocean.QU.240km.151209.nc
44-
temp_0.5x0.5degree.nc
45-
```
29+
Detailed examples of how to use `pyremap` can be found in the [documentation](http://mpas-dev.github.io/pyremap/main/). These include:
4630

47-
Second, let's try the same but to an Antarctic stereographic grid:
48-
```
49-
./make_mpas_to_antarctic_stereo_mapping.py
50-
```
51-
Now, there's a new mapping file and example output file:
52-
```
53-
map_oQU240_to_6000.0x6000.0km_10.0km_Antarctic_stereo.nc
54-
temp_6000.0x6000.0km_10.0km_Antarctic_stereo.nc
55-
```
31+
1. Creating mapping files for remapping to a lat-lon grid.
32+
2. Creating mapping files for remapping to an Antarctic stereographic grid.
33+
3. Remapping data between different stereographic grids.
5634

57-
Finally, let's remap the temperature on the Antarctic grid to a lower
58-
resolution Antarctic grid:
59-
```
60-
./remap_stereographic.py -i temp_6000.0x6000.0km_10.0km_Antarctic_stereo.nc \
61-
-o temp_6000.0x6000.0km_20.0km_Antarctic_stereo.nc -r 20
62-
```
63-
This created another mapping file and an output file:
64-
```
65-
map_6000x6000km_10km_Antarctic_stereo_to_6000x6000km_20.0km_Antarctic_stereo.nc
66-
temp_6000.0x6000.0km_20.0km_Antarctic_stereo.nc
67-
```
35+
For step-by-step walkthroughs, see the [examples section](http://mpas-dev.github.io/pyremap/main/examples/index.html).

Diff for: docs/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/generated
22
/_build
3-
/quick_start.md

Diff for: docs/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ clean:
3333
rm -rf generated
3434
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3535

36+
clean-versioned-html:
37+
rm -rf $(BUILDDIR)/html/*
38+
@echo "Cleaned versioned HTML builds."
39+
3640
.PHONY: help Makefile
3741

3842
# Catch-all target: route all unknown targets to Sphinx using the new

Diff for: docs/_static/logo.png

54.5 KB
Loading

Diff for: docs/_templates/layout.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
</script>
2424

2525
<!-- Load version switcher JS -->
26-
<script src="../shared/version-switcher.js"></script>
26+
<script src="{{ pathto("shared/version-switcher.js", True) }}"></script>
2727

2828
{% endblock %}

Diff for: docs/conf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from datetime import date
1414

1515
from pyremap.version import __version__
16-
from pyremap.docs.parse_quick_start import build_quick_start
1716

1817
# -- General configuration ------------------------------------------------
1918

@@ -118,6 +117,9 @@
118117
#
119118
# html_theme_options = {}
120119

120+
# Ensure the index is enabled
121+
html_use_index = True
122+
121123
# -- Options for HTMLHelp output ------------------------------------------
122124

123125
# Output file base name for HTML help builder.
@@ -180,8 +182,6 @@
180182
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
181183
'xarray': ('http://xarray.pydata.org/en/stable/', None)}
182184

183-
build_quick_start()
184-
185185
github_doc_root = 'https://github.com/rtfd/recommonmark/tree/master/doc/'
186186

187187
# Add any paths that contain custom static files (such as style sheets) here,
@@ -196,6 +196,6 @@
196196
}
197197

198198
html_context = {
199-
'current_version': version,
199+
'current_version': version if 'DOCS_VERSION' in os.environ else 'main',
200200
# Other context variables
201201
}

Diff for: docs/api.md renamed to docs/developer_guide/api.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# API reference
22

3+
:index:
4+
35
This page provides an auto-generated summary of the pyremap API.
46

57
## Mesh Descriptors

Diff for: docs/developer_guide/contribution_workflow.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Contribution Workflow
2+
3+
This document outlines the workflow for contributing to `pyremap`.
4+
5+
## Step 1: Fork the Repository
6+
7+
1. Navigate to the [pyremap repository](https://github.com/MPAS-Dev/pyremap).
8+
2. Click the "Fork" button in the top-right corner to create your own copy of the repository.
9+
10+
## Step 2: Clone Your Fork
11+
12+
1. Clone your forked repository to your local machine:
13+
```bash
14+
git clone https://github.com/your-username/pyremap.git
15+
```
16+
2. Navigate to the project directory:
17+
```bash
18+
cd pyremap
19+
```
20+
21+
## Step 3: Create a Feature Branch
22+
23+
1. Create a new branch for your changes:
24+
```bash
25+
git checkout -b your-feature-name
26+
```
27+
28+
## Step 4: Use a Worktree (Alternative to Step 3)
29+
30+
1. Add a new worktree for your feature branch:
31+
```bash
32+
git worktree add ../your-feature-name
33+
```
34+
2. Navigate to the new worktree directory:
35+
```bash
36+
cd ../your-feature-name
37+
```
38+
39+
> **Note:** This allows you to work on multiple branches simultaneously in separate directories.
40+
41+
## Step 5: Make Changes
42+
43+
1. Implement your changes in the codebase.
44+
2. Write or update tests to cover your changes.
45+
3. Update documentation if necessary.
46+
47+
## Step 6: Commit Your Changes
48+
49+
1. Stage your changes:
50+
```bash
51+
git add .
52+
```
53+
2. Commit your changes with a descriptive message:
54+
```bash
55+
git commit -m "Add feature: your-feature-name"
56+
```
57+
58+
> **Note:** Please commit often and in small pieces. You can
59+
always `git rebase` later to consolidate pieces of your work into fewer
60+
commits, but breaking commits into smaller pieces is very difficult.
61+
62+
## Step 7: Push Your Changes
63+
64+
1. Push your feature branch to your fork:
65+
```bash
66+
git push origin your-feature-name
67+
```
68+
69+
## Step 8: Submit a Pull Request
70+
71+
1. Navigate to your fork on GitHub.
72+
2. Click the "Compare & pull request" button.
73+
3. Provide a detailed description of your changes.
74+
4. Submit the pull request.
75+
76+
## Step 9: Address Feedback
77+
78+
1. Review comments from maintainers on your pull request.
79+
2. Make necessary changes and push updates to your feature branch:
80+
```bash
81+
git push origin your-feature-name
82+
```
83+
84+
## Additional Resources
85+
86+
- Refer to the [Contribution Guidelines](index.md#contribution-guidelines) for more details.
87+
- For help with Git, see the [Git documentation](https://git-scm.com/doc).

Diff for: docs/developer_guide/index.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Developer Guide
2+
3+
:index:
4+
5+
Welcome to the Developer Guide for `pyremap`. This section provides resources and guidelines for contributors.
6+
7+
## Coding Standards
8+
9+
- Follow [PEP 8](https://peps.python.org/pep-0008/) for Python code style.
10+
- Use descriptive variable and function names.
11+
- Write clear and concise docstrings for all public functions and classes.
12+
- Ensure code is compatible with Python 3.8+.
13+
14+
## Testing
15+
16+
- Write unit tests for all new features and bug fixes.
17+
- Use the `pytest` framework for testing.
18+
- Place tests in the `pyremap/tests/` directory.
19+
- Run tests locally before submitting changes:
20+
```bash
21+
pytest --pyargs pyremap
22+
```
23+
24+
## Contribution Guidelines
25+
26+
- Fork the repository and create a feature branch for your changes.
27+
- Write clear and concise commit messages.
28+
- Ensure all tests pass before submitting a pull request.
29+
- Include documentation updates for any new features or changes.
30+
- Submit a pull request with a detailed description of your changes.
31+
32+
## Additional Resources
33+
34+
- [API Reference](api.md)
35+
- [Testing Instructions](testing_instructions.md)
36+
- [Contribution Workflow](contribution_workflow.md)

Diff for: docs/developer_guide/testing_instructions.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Testing Instructions
2+
3+
This document provides detailed instructions for testing `pyremap`.
4+
5+
## Running Tests
6+
7+
1. Ensure all dependencies are installed. You can use `conda` to install any missing dependencies:
8+
```bash
9+
conda install --file dev-spec.txt
10+
```
11+
12+
2. Install pyremap in edit mode:
13+
```bash
14+
python -m pip install --no-deps --no-build-isolation -e .
15+
```
16+
17+
3. Run the test suite using `pytest`:
18+
```bash
19+
pytest --pyargs pyremap
20+
```
21+
22+
4. To run a specific test file, provide the file path:
23+
```bash
24+
pytest path/to/test_file.py
25+
```
26+
27+
5. For more verbose output, use the `-v` flag:
28+
```bash
29+
pytest -v --pyargs pyremap
30+
```
31+
32+
## Writing Tests
33+
34+
- Place all test files in the `pyremap/tests/` directory.
35+
- Use descriptive names for test functions and files.
36+
- Follow the `pytest` conventions for writing tests.
37+
38+
## Debugging Failures
39+
40+
- Use the `--pdb` flag to drop into the Python debugger on test failure:
41+
```bash
42+
pytest --pdb --pyargs pyremap
43+
```
44+
45+
- Review the stack trace provided by `pytest` to identify the source of the failure.
46+
47+
## Additional Resources
48+
49+
- Refer to the [pytest documentation](https://docs.pytest.org/en/latest/) for advanced usage and features.

Diff for: docs/examples/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Examples
2+
3+
Detailed walkthroughs of example scripts.
4+
5+
```{toctree}
6+
:maxdepth: 2
7+
8+
make_mpas_to_lat_lon_mapping
9+
make_mpas_to_antarctic_stereo_mapping
10+
make_mpas_vertex_to_antarctic_stereo_mapping
11+
```
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Make MPAS to Antarctic Stereo Mapping
2+
3+
:index:
4+
5+
This example demonstrates how to create a mapping file from an MPAS mesh to an Antarctic stereographic grid.
6+
7+
## Script Overview
8+
9+
The script uses `pyremap` to:
10+
- Read an MPAS mesh file.
11+
- Define a target Antarctic stereographic grid.
12+
- Generate a mapping file for regridding.
13+
14+
## Example Code
15+
16+
```python
17+
#!/usr/bin/env python
18+
19+
"""
20+
Creates a mapping file to remap MPAS files to an Antarctic stereographic grid.
21+
"""
22+
23+
from pyremap import Remapper, get_polar_descriptor
24+
25+
# Input MPAS mesh file and name
26+
src_mesh_name = 'oQU240'
27+
src_mesh_filename = 'ocean.QU.240km.151209.nc'
28+
29+
# Configure the remapper
30+
remapper = Remapper(ntasks=4, method='bilinear')
31+
remapper.src_from_mpas(filename=src_mesh_filename, mesh_name=src_mesh_name)
32+
33+
# Define the target Antarctic stereographic grid descriptor
34+
remapper.dst_descriptor = get_polar_descriptor(
35+
lx=6000., # Grid width in km
36+
ly=5000., # Grid height in km
37+
dx=10., # Grid cell size in x-direction (km)
38+
dy=10., # Grid cell size in y-direction (km)
39+
projection='antarctic' # Antarctic stereographic projection
40+
)
41+
42+
# Build the mapping file
43+
remapper.build_map()
44+
```
45+
46+
## Expected Output
47+
48+
The script generates a mapping file named:
49+
```
50+
map_oQU240_to_6000.0x5000.0km_10.0km_Antarctic_stereo_esmfbilin.nc
51+
```
52+
that can be used for regridding MPAS data to an Antarctic stereographic grid.

0 commit comments

Comments
 (0)