Skip to content

Commit a6f00b1

Browse files
committed
Docs: is_1d() and is_2d() are now under Methods and not Attributes. Improved some more docstrings.
1 parent f960be8 commit a6f00b1

File tree

5 files changed

+36
-50
lines changed

5 files changed

+36
-50
lines changed

docs/source/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ Attributes
9494
Dataset.traj.tlon
9595
Dataset.traj.tlat
9696
Dataset.traj.crs
97-
Dataset.traj.is_1d
98-
Dataset.traj.is_2d
9997

10098
.. _dsmeth:
10199

@@ -121,6 +119,8 @@ Methods
121119
Dataset.traj.get_area_convex_hull
122120
Dataset.traj.gridtime
123121
Dataset.traj.seltime
122+
Dataset.traj.is_1d
123+
Dataset.traj.is_2d
124124

125125
.. currentmodule:: trajan
126126

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"members": True,
8585
"undoc-members": True,
8686
"private-members": True,
87-
"show-inheritance": True,
8887
}
8988
napoleon_use_param = True
9089
napoleon_use_rtype = True

trajan/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ def from_dataframe(df: pd.DataFrame,
3333
Construct a CF-compliant trajectory dataset from a `pd.DataFrame` of positions.
3434
3535
Args:
36-
37-
`lon`: name of column containing longitudes.
38-
39-
`lat`: name of column containing latitudes.
40-
41-
`time`: name of column containing timestamps (parsable by pandas).
42-
43-
`name`: name of column to be used for drifter names.
36+
`lon`: str
37+
Name of column containing longitudes.
38+
`lat`: str
39+
Name of column containing latitudes.
40+
`time`: str
41+
Name of column containing timestamps (parsable by pandas).
42+
`name`: str
43+
Name of column to be used for drifter names.
4444
4545
Returns:
46-
4746
`ds`: a CF-compliant trajectory `xarray.Dataset`.
4847
4948
@@ -155,14 +154,16 @@ def trajectory_dict_to_dataset(trajectory_dict,
155154
global_attributes=None):
156155
"""Create a CF-compatible trajectory file from dictionary of drifter positions
157156
158-
Trajectory_dict shall have the following structure:
157+
Trajectory_dict shall have the following structure::
158+
159159
{'buoy1_name': {
160160
time0: {'lon': lon0, 'lat': lat0, 'variable1': var1_0, ... 'variableM': varM_0},
161161
time1: {'lon': lon1, 'lat': lat1, 'variable1': var1_1, ... 'variableM': varM_1},
162162
...
163163
timeN: {'lon': lonN, 'lat': latN, 'variable1': var1_N, ... 'variableM': varM_N}},
164164
{'buoy2_name': {
165165
...
166+
166167
"""
167168

168169
if variable_attributes is None:

trajan/plot/spectra.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,29 @@ def plot_trajan_spectra(
2727
horizontal time basis.
2828
2929
Args:
30-
31-
`xr_trajan_in`: input xarray following the trajan conventions
32-
30+
`xr_trajan_in`:
31+
input xarray following the trajan conventions
3332
`tuple_date_start_end`: can be either:
34-
- None to plot over the full datetime range available across
35-
trajectories
36-
- a tuple of datetimes (datetime_start, datetime_end) to set
37-
the time axis limits explicitely
38-
33+
- None to plot over the full datetime range available across trajectories
34+
- a tuple of datetimes (datetime_start, datetime_end) to set the time axis limits explicitely
3935
`tuple_vrange_pcolor`: can be either:
4036
- None to use the default log range [-3.0, 1.0]
4137
- a tuple of float to set the log range explicitely
42-
43-
`plt_show`: bool flag, wether to show the figure or not
44-
38+
`plt_show`: bool flag
39+
Whether to show the figure or not
4540
`fignamesave`: can be either:
4641
- None to not save the figure
47-
- a valid filename string or path ending in .png or .pdf to save
48-
the figure to disk
49-
50-
`field`: string, the xr_trajan_in field to use as the 1D spectrum data;
51-
by default, this is the "processed_elevation_energy_spectrum", but
52-
one could also set "elevation_energy_spectrum" to plot also the bins
53-
with low frequency noise.
54-
55-
`nseconds_gap`: float, number of seconds between 2 consecutive
56-
spectra for one instrument above which we consider that there is a
57-
data loss that should be filled with NaN. This is to avoid "stretching"
58-
neighboring spectra over long times if an instrument gets offline.
42+
- a valid filename string or path ending in .png or .pdf to save the figure to disk
43+
`field`: string
44+
the xr_trajan_in field to use as the 1D spectrum data;
45+
by default, this is the "processed_elevation_energy_spectrum", but
46+
one could also set "elevation_energy_spectrum" to plot also the bins
47+
with low frequency noise.
48+
`nseconds_gap`: float
49+
Number of seconds between 2 consecutive
50+
spectra for one instrument above which we consider that there is a
51+
data loss that should be filled with NaN. This is to avoid "stretching"
52+
neighboring spectra over long times if an instrument gets offline.
5953
"""
6054

6155
if tuple_date_start_end is not None:

trajan/traj.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,10 @@ def transform(self, to_crs, x, y):
166166
Transform coordinates in this datasets coordinate system to `to_crs` coordinate system.
167167
168168
Args:
169-
170169
to_crs: `pyproj.CRS`.
171-
172170
x, y: Coordinates in `self` CRS.
173171
174172
Returns:
175-
176173
xn, yn: Coordinates in `to_crs`.
177174
"""
178175
t = pyproj.Transformer.from_crs(self.crs, to_crs, always_xy=True)
@@ -183,13 +180,10 @@ def itransform(self, from_crs, x, y):
183180
Transform coordinates in `from_crs` coordinate system to this datasets coordinate system.
184181
185182
Args:
186-
187183
from_crs: `pyproj.CRS`.
188-
189184
x, y: Coordinates in `from_crs` CRS.
190185
191186
Returns:
192-
193187
xn, yn: Coordinates in this datasets CRS.
194188
"""
195189
t = pyproj.Transformer.from_crs(from_crs, self.crs, always_xy=True)
@@ -269,12 +263,10 @@ def set_crs(self, crs):
269263
@abstractmethod
270264
def is_1d(self):
271265
"""Returns True if dataset is 1D, i.e. time is a 1D coordinate variable."""
272-
pass
273266

274267
@abstractmethod
275268
def is_2d(self):
276269
"""Returns True if dataset is 2D, i.e. time is a 2D variable and not a coordinate variable."""
277-
pass
278270

279271
def assign_cf_attrs(self,
280272
creator_name=None,
@@ -495,15 +487,15 @@ def gridtime(self, times, timedim = None):
495487
"""Interpolate dataset to a regular time interval or a different grid.
496488
497489
Args:
490+
`times`: array or str
491+
Target time interval, can be either:
492+
- an array of times, or
493+
- a string "freq" specifying a Pandas daterange (e.g. 'h', '6h, 'D'...) suitable for `pd.date_range`.
498494
499-
`times`: Target time interval, can be either:
500-
- an array of times, or
501-
- a string "freq" specifying a Pandas daterange (e.g. 'h', '6h, 'D'...) suitable for `pd.date_range`.
502-
503-
`timedime`: Name of new time dimension. The default is to use the same name as previously.
495+
`timedime`: str
496+
Name of new time dimension. The default is to use the same name as previously.
504497
505498
Returns:
506-
507499
A new dataset interpolated to the target times. The dataset will be 1D (i.e. gridded) and the time dimension will be named `time`.
508500
"""
509501

0 commit comments

Comments
 (0)