Skip to content

Commit 423b123

Browse files
Apply suggestions from copilot code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 7d06952 commit 423b123

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

conda_package/docs/landice/visualization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ The input file is never modified. By default, output is written to
132132

133133
.. code-block:: bash
134134
135-
convert_cell_coordinates_to_sphere.py -i output_state_2015.nc
135+
python landice/mesh_tools_li/convert_cell_coordinates_to_sphere.py -i output_state_2015.nc
136136
137137
You can also choose an explicit output file and optionally warp the surface
138138
to create 3d ice-sheet surface topography on the sphere
@@ -141,7 +141,7 @@ using ``upperSurface`` (or ``thickness`` + ``bedTopography`` if
141141

142142
.. code-block:: bash
143143
144-
convert_cell_coordinates_to_sphere.py \
144+
python landice/mesh_tools_li/convert_cell_coordinates_to_sphere.py \
145145
-i output_state_2015.nc \
146146
-o output_state_2015_sphere.nc \
147147
-w -s 100

landice/mesh_tools_li/convert_cell_coordinates_to_sphere.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from pathlib import Path
1616
from netCDF4 import Dataset
1717
import numpy as np
18+
import sys
1819

1920
parser = argparse.ArgumentParser(
2021
prog='convert_cell_coordinates_to_sphere.py',
@@ -28,7 +29,7 @@
2829
help="sphere radius to use (m)")
2930
parser.add_argument("-w", dest="warp_surface", action='store_true',
3031
help="warp surface by upperSurface variable. " \
31-
"Uses scale factor from -s" \
32+
"Uses scale factor from -s. " \
3233
"If upperSurface is not in file, will attempt " \
3334
"to calculate it from thickness and bedTopography. " \
3435
"Uses geometry from first time level only; it is not " \
@@ -51,7 +52,8 @@
5152

5253
def compute_xyz(latCell_deg, lonCell_deg, radius):
5354
'''
54-
Copied from lonlat2xyz in mesh/creation/util.py
55+
Copied from mpas_tools.mesh.creation.util.lonlat2xyz in
56+
conda_package/mpas_tools/mesh/creation/util.py
5557
'''
5658
lat_rad = np.radians(latCell_deg)
5759
lon_rad = np.radians(lonCell_deg)
@@ -96,3 +98,13 @@ def compute_xyz(latCell_deg, lonCell_deg, radius):
9698
# Update global attributes
9799
ds.setncattr("on_a_sphere", "YES")
98100
ds.setncattr("sphere_radius", args.radius)
101+
102+
# Record this modification in the global history attribute
103+
prev_history = getattr(ds, "history", "")
104+
cmd = Path(__file__).name + " " + " ".join(sys.argv[1:])
105+
cmd = cmd.strip()
106+
if prev_history:
107+
new_history = prev_history + "\n" + cmd
108+
else:
109+
new_history = cmd
110+
ds.setncattr("history", new_history)

0 commit comments

Comments
 (0)