Skip to content

Commit 4ec046e

Browse files
committed
doc: rewording
1 parent 8ed6d14 commit 4ec046e

10 files changed

+93
-86
lines changed

docs/source/api/attribute_api.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
===========
2-
Attribute
2+
Attributes
33
===========
44

5-
In the library, netCDF attributes can be created, accessed, and manipulated
6-
using python dictionary-like syntax. A Pythonic interface for metadata operations
7-
is provided both in the ``File`` class (for global attributes) and the
8-
``Variable`` class (for variable attributes).
5+
NetCDF attributes can be created, accessed, and manipulated using python
6+
dictionary-like syntax. An attribute can be associated to the file, referred to
7+
as ``golbal attribute``, as well as to individual variable, referred to as
8+
``variable's attribute``. Pythonic interfaces for accessing attributes are is
9+
provided both in :class:`pnetcdf.File` (for global attributes) and the
10+
:class:`pnetcdf.Variable` (for variable attributes).
11+

docs/source/api/dimension_api.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
==============
2-
Dimension
2+
Dimensions
33
==============
44

5-
Dimension defines the shape and structure of variables and stores coordinate
6-
data for multidimensional arrays. The ``Dimension`` object, which is also a key
7-
component of ``File`` class, provides an interface to access dimensions.
5+
Class ``Dimension`` is used to define the shape of NetCDF variables. In NetCDF,
6+
a variable, an instance of :class:`pnetcdf.Variable`, is a multi-dimensional
7+
array. Methods in :class:`pnetcdf.Dimension` provide an interface to access
8+
dimensions objects stored in the file.
89

910
.. autoclass:: pnetcdf::Dimension
1011
:members: getfile, isunlimited
@@ -24,7 +25,8 @@ Read-only Python Attributes of Dimension Class
2425

2526
.. attribute:: size
2627

27-
The current size of Dimension (calls ``len`` on Dimension instance).
28+
The current size of Dimension (its value can be obtained by calling
29+
python function ``len()`` on the Dimension instance).
2830

2931
**Type:** `int`
3032

docs/source/api/file_api.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
================
2-
File
2+
Files
33
================
44

5-
``pnetcdf.File`` is a high-level object representing an netCDF file,
6-
which provides a Pythonic interface to create, read and write within
7-
an netCDF file. A File object serves as the root container for dimensions,
8-
variables, and attributes. Together they describe the meaning of data and
9-
relations among data fields stored in a netCDF file.
5+
An instance of class ``pnetcdf.File`` is a high-level object representing a
6+
netCDF file. The class methods provide a set of Pythonic interfaces to create,
7+
read and write a netCDF file. A ``File`` instance serves as the root container
8+
for dimensions, variables, and attributes. Together they describe the meaning
9+
of data and relations among data objects stored in a netCDF file.
1010

1111
.. autoclass:: pnetcdf::File
1212
:members: __init__, close, filepath, redef, enddef, begin_indep, end_indep,
@@ -24,14 +24,14 @@ Read-only Python Attributes of File Class
2424
.. attribute:: dimensions
2525

2626
The dimensions dictionary maps the names of dimensions defined in this
27-
file as an instance of the ``pnetcdf.Dimension`` class.
27+
file as an instance of the :class:`pnetcdf.Dimension`.
2828

2929
**Type:** `dict`
3030

3131
.. attribute:: variables
3232

3333
The variables dictionary maps the names of variables defined in this file
34-
as an instance of the ``pnetcdf.Variable`` class.
34+
as an instance of the :class:`pnetcdf.Variable`.
3535

3636
**Type:** `dict`
3737

docs/source/api/function_api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
================
2-
Utility Functions
2+
Other PnetCDF Utility Functions
33
================
44

55
.. autofunction:: pnetcdf::libver

docs/source/api/variable_api.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
=========
2-
Variable
2+
Variables
33
=========
44

5-
Variable is a core component of a netCDF file representing an array of data
5+
``Variable`` is a core component of a netCDF file representing an array of data
66
values organized along one or more dimensions, with associated metadata in the
7-
form of attributes. The ``Variable`` object in the library provides operations
8-
to read and write the data and metadata of a variable within a netCDF file.
9-
Particularly, data mode operations have a flexible interface, where reads and
10-
writes can be done through either explicit function-call style methods or
11-
indexer-style (numpy-like) syntax.
7+
form of attributes. An instance of class :class:`pnetcdf.Variable` represents a
8+
NetCDF variable stored in the file. The class methods provide I/O operations to
9+
read and write the data and metadata of a NetCDF variable.
10+
11+
Reading and writing a subarray of a variable can be done through either
12+
explicit function-call style methods or Python indexer-style (numpy-like)
13+
syntax.
1214

1315
.. autoclass:: pnetcdf::Variable
1416
:members: ncattrs, put_att, get_att, del_att, rename_att, get_dims,

docs/source/copyright.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
Copyright Statement
33
================
44

5-
::
6-
7-
Copyright (c) 2024 Northwestern University and Argonne National
8-
Laboratory All rights reserved.
5+
Copyright (c) 2024 Northwestern University and Argonne National Laboratory
6+
All rights reserved.
97

108
Portions of this software were developed by the Unidata Program at the
119
University Corporation for Atmospheric Research.

docs/source/index.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
PnetCDF-Python Documentation
6+
PnetCDF-Python User Guide
77
============================
88

99
**Release:** |release|
1010

11-
.. toctree::
12-
:maxdepth: 2
13-
:caption: Introduction
14-
15-
introduction/overview
11+
PnetCDF-python is a Python interface to PnetCDF, a high-performance parallel
12+
I/O library for accessing netCDF files. This integration with Python allows
13+
for easy manipulation, analysis, and visualization of netCDF data using the
14+
rich ecosystem of Python's scientific computing libraries, making it a valuable
15+
tool for python-based applications that require high-performance access to
16+
netCDF files.
1617

1718
.. toctree::
1819
:maxdepth: 2
@@ -32,15 +33,16 @@ PnetCDF-Python Documentation
3233

3334
.. toctree::
3435
:maxdepth: 3
35-
:caption: API Documentation
36+
:caption: API Reference
3637

3738
api/file_api
3839
api/dimension_api
3940
api/variable_api
41+
api/attribute_api
4042
api/function_api
4143

4244
.. toctree::
43-
:maxdepth: 2
45+
:maxdepth: 1
4446
:caption: Copyright Statement
4547

4648
copyright

docs/source/tutorial/basic.rst

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Basics
66
Running Python scripts with MPI
77
-------------------------------
88

9-
Python programs with PnetCDF-Python can be run with the command
10-
:program:`mpiexec`. In practice, running Python programs looks like:
9+
Python programs using PnetCDF-Python can be run with the command
10+
:program:`mpiexec`. In practice, running a Python program looks like:
1111

12-
$ mpiexec -n 4 Python script.py
12+
$ mpiexec -n 4 python script.py
1313

14-
to run the program with 4 processors.
14+
to run the program with 4 MPI processes.
1515

1616
Creating/Opening/Closing a netCDF file
1717
--------------------------------------
@@ -27,24 +27,24 @@ Creating/Opening/Closing a netCDF file
2727
Closing the netCDF file is accomplished via the :meth:`File.close` method of
2828
the ``File`` instance.
2929

30-
Here's an example:
30+
Here is an example of creating a new file:
3131

3232
.. code-block:: Python
3333
34-
from pnetcdf import File
3534
from mpi4py import MPI
36-
comm = MPI.COMM_WORLD
37-
f = File(filename="testfile.nc", mode='w', comm=comm, info=None)
35+
import pnetcdf
36+
37+
f = pnetcdf.File(filename="testfile.nc", mode='w', comm=MPI.COMM_WORLD, info=None)
3838
f.close()
3939
40-
Equivalent example codes in ``netCDF4-python``:
40+
Equivalent example codes when using ``netCDF4-python``:
4141

4242
.. code-block:: Python
4343
4444
from mpi4py import MPI
45-
from netCDF4 import Dataset
46-
comm = MPI.COMM_WORLD
47-
f = Dataset(filename="testfile.nc", mode="w", comm=comm, parallel=True)
45+
import netCDF4
46+
47+
f = netCDF4.Dataset(filename="testfile.nc", mode="w", comm=MPI.COMM_WORLD, parallel=True)
4848
f.close()
4949
5050
For the full example program, see ``examples/craete_open.py``.
@@ -54,11 +54,11 @@ Dimensions
5454

5555
NetCDF variables are multi-dimensional arrays. Before creating any variables,
5656
the dimensions they depend on must be established. To create a dimension, the
57-
:meth:`File.def_dim` method is called on a File instance under define mode.
57+
:meth:`File.def_dim` method is called on a ``File`` instance under define mode.
5858
The dimension's name is set using a Python string, while the size is defined
5959
using an integer value. To create an unlimited dimension (a dimension that can
60-
be expanded), the size can be omitted or assigned as -1. A "Dimension" object
61-
will be returned as a handler for this dimension.
60+
be expanded), the parameter size can be omitted or assigned as -1. A
61+
``Dimension`` instance will be returned as a handler for this dimension.
6262

6363
Here's an example (same if using netcdf4-python):
6464

@@ -70,8 +70,8 @@ Dimensions
7070
lat_dim = f.def_dim(LAT_NAME, LAT_LEN)
7171
time_dim = f.def_dim(TIME_NAME, -1)
7272
73-
All of the Dimension instances are stored in a dictionary as an Python
74-
attribute of File.
73+
All of the ``Dimension`` instances are stored in a Python dictionary as an
74+
attribute of ``File``.
7575

7676
.. code-block:: Python
7777
@@ -94,13 +94,13 @@ Variables
9494
------------
9595

9696
NetCDF variables are similar to multidimensional array objects in Python
97-
provided by the numpy module. To define a netCDF variable, you can utilize the
98-
:meth:`File.def_var` method within a File instance under define mode. The
99-
mandatory arguments for this methods include the variable name (a string in
100-
Python) and dimensions (either a tuple of dimension names or dimension
97+
provided by the ``numpy`` module. To define a netCDF variable, you can utilize
98+
the :meth:`File.def_var` method within a ``File`` instance under define mode.
99+
The mandatory arguments for this methods include the variable name (a string
100+
in Python) and dimensions (either a tuple of dimension names or dimension
101101
instances). In addition, the user need to specify the datatype of the variable
102-
using module-level NC constants (e.g. pnetcdf.NC_INT). The supported
103-
data types given each file format can be found :ref:`here<Datatype>`.
102+
using module-level constants (e.g. ``pnetcdf.NC_INT``). The supported data
103+
types given each file format can be found :ref:`here<Datatype>`.
104104

105105
Here's an example (same if using netcdf4-python):
106106

@@ -132,7 +132,7 @@ Attributes
132132
In a netCDF file, there are two types of attributes: global attributes and
133133
variable attributes. Global attributes are usually related to the netCDF file
134134
as a whole and may be used for purposes such as providing a title or
135-
processing history for a netCDF file. Variable's attributes are used to
135+
processing history for a netCDF file. ``Variable``'s attributes are used to
136136
specify properties related to the variable, such as units, special values,
137137
maximum and minimum valid values, and annotation.
138138

@@ -144,11 +144,11 @@ Attributes
144144
.. code-block:: Python
145145
146146
# set global attributes
147-
f.floatatt = math.pi # Option1: Python attribute assignment
148-
f.put_att("intatt", np.int32(1)) # Option2: method put_att()
147+
f.floatatt = math.pi # Option 1: Python attribute assignment
148+
f.put_att("intatt", np.int32(1)) # Option 2: method put_att()
149149
f.seqatt = np.int32(np.arange(10))
150150
151-
# set variable attributes
151+
# write variable attributes
152152
var = f.variables['var']
153153
var.floatatt = math.pi
154154
var.put_att("int_att", np.int32(1))
@@ -159,8 +159,8 @@ Attributes
159159
.. code-block:: Python
160160
161161
# set root group attributes
162-
f.floatatt = math.pi # Option1: Python attribute assignment
163-
f.setncattr("intatt", np.int32(1)) # Option2: method setncattr()
162+
f.floatatt = math.pi # Option 1: Python attribute assignment
163+
f.setncattr("intatt", np.int32(1)) # Option 2: method setncattr()
164164
f.seqatt = np.int32(np.arange(10))
165165
166166
# set variable attributes
@@ -169,10 +169,10 @@ Attributes
169169
var.setncattr("int_att", np.int32(1))
170170
var.seqatt = np.int32(np.arange(10))
171171
172-
The :meth:`File.ncattrs` method of a File or Variable instance can be used to
173-
retrieve the names of all the netCDF attributes. And the __dict__ attribute of
174-
a File or Variable instance provides all the netCDF attribute name/value pairs
175-
in a python dictionary:
172+
The :meth:`File.ncattrs` method of a ``File`` or ``Variable`` instance can be
173+
used to retrieve the names of all the netCDF attributes. And the __dict__
174+
attribute of a ``File`` or ``Variable`` instance provides all the netCDF
175+
attribute name/value pairs in a python dictionary:
176176

177177
.. code-block:: Python
178178
@@ -184,14 +184,14 @@ Attributes
184184
185185
For the full example program, see ``examples/global_attributes.py``.
186186

187-
Writing to variable
187+
Writing to a variable
188188
--------------------
189189

190190
Once a netCDF variable instance is created, writing the variable must be done
191191
while the file is in data mode. Then for writing, there are two options:
192192

193-
Option1 Indexer (or slicing) syntax
194-
You can just treat the variable like an numpy array and assign data
193+
Option 1 Indexer (or slicing) syntax
194+
You can just treat the variable like an ``numpy`` array and assign data
195195
to a slice. Slices are specified as a `start:stop:step` triplet.
196196

197197
.. code-block:: Python
@@ -202,9 +202,9 @@ Option1 Indexer (or slicing) syntax
202202
The indexer syntax is the same as in ``netcdf4-python`` library for writing to
203203
netCDF variable.
204204

205-
Option2 Method calls of put_var()/get_var()
206-
Alternatively you can also leverage Variable.put/get_var() method of a
207-
Variable instance to perform I/O according to specific access pattern needs.
205+
Option 2 Method calls of put_var()/get_var()
206+
Alternatively you can also leverage ``Variable.put/get_var()`` method of a
207+
``Variable`` instance to perform I/O according to specific access pattern needs.
208208

209209
Here is the example below to write an array to the netCDF variable. The part
210210
of the netCDF variable to write is specified by giving a corner (`start`) and
@@ -218,7 +218,7 @@ Option2 Method calls of put_var()/get_var()
218218
# The above line is equivalent to var[10:20, 0:50] = buff
219219
220220
221-
Reading from variable
221+
Reading from a variable
222222
----------------------
223223

224224
Symmetrically, users can use two options with different syntaxes to retrieve
@@ -228,10 +228,10 @@ Reading from variable
228228
.. code-block:: Python
229229
230230
var = f.variables['var']
231-
# Option1 Indexer: read the topleft 10*10 corner from variable var
231+
# Option 1 Indexer: read the top-left 10*10 corner from variable var
232232
buf = var[:10, :10]
233233
234-
# Option2 Method Call: equivalent to var[10:20, 0:50]
234+
# Option 2 Method Call: equivalent to var[10:20, 0:50]
235235
buf = var.get_var_all(start = [10, 0], count = [10, 50])
236236
237237
Similarly, :meth:`Variable.get_var` takes the same set of optional arguments

docs/source/tutorial/datatypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ NetCDF Variable Data Types
2626
+-------+----------------+-------+----------------------------------------+---------------------+
2727

2828

29-
New data types supported in CDF-5 format:
29+
Additional data types supported in CDF-5 format:
3030

3131
+---------------------+----------------+-------+----------------------------------------+---------------------+
3232
| Type | C #define | Bits | Intent of use | Numpy Equivalent |

docs/source/tutorial/read_write.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Parallel Read and Write
66
NumPy Slicing Syntax
77
--------------------------------------
88

9-
PnetCDF-python datasets re-use the numpy slicing syntax to read and write to
10-
the file. Slice specifications are translated directly to PnetCDF “start,
11-
count, stride” selections, and are a fast and efficient way to access data in
12-
the file. The following slicing arguments are recognized:
9+
PnetCDF-python datasets re-use the ``numpy`` slicing syntax to read and write
10+
to the file. Slice specifications are translated directly to PnetCDF-C style
11+
of subarray selection, i.e. using index arrays of “start, count, stride”.
12+
The following slicing arguments are recognized:
1313

1414
- Indices (var[1,5])
1515
- Slices (i.e. [:] or [0:10])
@@ -29,7 +29,7 @@ NumPy Slicing Syntax
2929
# put values to the entire variable
3030
var[:] = buff
3131
32-
# read the topleft 10*10 corner from variable var
32+
# read the top-left 10*10 corner from variable var
3333
print(var[:10, :10])
3434
3535

0 commit comments

Comments
 (0)