@@ -101,19 +101,13 @@ class StnData(CDIPnc):
101101 def __init__ (
102102 self , stn : str , data_dir : str = None , org : str = None , deploy_num : int = None
103103 ):
104- """
105- PARAMETERS
106- ----------
107- stn : str
108- Can be in 2, 3 or 5 char format e.g. 28, 028, 028p2
109- data_dir : str [optional]
110- Either a full path to a directory containing a local directory hierarchy
111- of nc files. E.g. '/project/WNC' or a url to a THREDDS server.
112- org: str
113- (Organization) Values are: cdip|ww3|external
114- deploy_num : int [optional]
115- Supply this to access specific station deployment data.
116- Must be >= 1.
104+ """Initializes StnData for a given CDIP station.
105+
106+ Args:
107+ stn (str): Station identifier in 2, 3, or 5 character format (e.g. "28", "028", "028p2").
108+ data_dir (str, optional): Path to directory containing netCDF files or a THREDDS URL.
109+ org (str): Data organization, one of {"cdip", "ww3", "external"}.
110+ deploy_num (int, optional): Deployment number (>=1) to access specific station deployment data.
117111 """
118112 self .nc = None
119113 self .stn = stn
@@ -151,7 +145,11 @@ def __init__(
151145 return None
152146
153147 def get_stn_meta (self ) -> dict :
154- """Returns a dict of station meta data."""
148+ """Returns a dictionary of station metadata.
149+
150+ Returns:
151+ dict: A dictionary containing metadata variables and global attributes.
152+ """
155153 result = {}
156154 if self .meta is None :
157155 return result
@@ -170,15 +168,35 @@ def get_parameters(
170168 apply_mask = True ,
171169 target_records = 0 ,
172170 ) -> dict :
173- """Calls get_series to return wave parameters."""
171+ """Returns wave parameter data using get_series.
172+
173+ Args:
174+ start (datetime, optional): Start time of data request (UTC).
175+ end (datetime, optional): End time of data request (UTC).
176+ pub_set (str, optional): Data quality filter. One of {"public", "nonpub", "all"}. Defaults to "public".
177+ apply_mask (bool, optional): Whether to apply mask filtering. Defaults to True.
178+ target_records (int, optional): Number of records to return if end is not specified.
179+
180+ Returns:
181+ dict: Dictionary of wave parameter data arrays.
182+ """
174183 return self .get_series (
175184 start , end , self .parameter_vars , pub_set , apply_mask , target_records
176185 )
177186
178187 def get_xyz (
179188 self , start : datetime = None , end : datetime = None , pub_set : str = "public"
180189 ) -> dict :
181- """Calls get_series to return displacement data."""
190+ """Returns displacement (XYZ) data using get_series.
191+
192+ Args:
193+ start (datetime, optional): Start time of data request (UTC).
194+ end (datetime, optional): End time of data request (UTC).
195+ pub_set (str, optional): Data quality filter. Defaults to "public".
196+
197+ Returns:
198+ dict: Dictionary of XYZ displacement data.
199+ """
182200 return self .get_series (start , end , self .xyz_vars , pub_set )
183201
184202 def get_spectra (
@@ -190,7 +208,19 @@ def get_spectra(
190208 target_records : int = 0 ,
191209 force_64bands : bool = False ,
192210 ) -> dict :
193- """Calls get_series to return spectral data."""
211+ """Returns spectral data using get_series.
212+
213+ Args:
214+ start (datetime, optional): Start time of data request (UTC).
215+ end (datetime, optional): End time of data request (UTC).
216+ pub_set (str, optional): Data quality filter. Defaults to "public".
217+ apply_mask (bool, optional): Whether to apply mask filtering. Defaults to True.
218+ target_records (int, optional): Number of records to return if end is not specified.
219+ force_64bands (bool, optional): If True, converts all spectra to 64-band format.
220+
221+ Returns:
222+ dict: Dictionary of spectral data arrays.
223+ """
194224 return self .get_series (
195225 start ,
196226 end ,
@@ -211,36 +241,21 @@ def get_series(
211241 target_records : int = 0 ,
212242 force_64bands : bool = False ,
213243 ) -> dict :
244+ """Returns data for a station between specified start and end dates.
245+
246+ Args:
247+ start (datetime or str, optional): Start time of data request (UTC).
248+ end (datetime or str, optional): End time of data request (UTC).
249+ vrs (list, optional): List of variable names to retrieve.
250+ pub_set (str, optional): Data quality filter. One of {"public", "nonpub", "all"}.
251+ apply_mask (bool, optional): Whether to apply mask filtering.
252+ target_records (int, optional): Number of records to return when end is None.
253+ force_64bands (bool, optional): Whether to force conversion of spectra to 64 bands.
254+
255+ Returns:
256+ dict: Dictionary of requested variable arrays.
214257 """
215- Returns a dict of data between start and end dates with specified quality.
216-
217- PARAMETERS
218- ----------
219- start : str or datetime [optional] : default Jan 1, 1975
220- Start time of data request (UTC). If provided as a string must
221- be in the format Y-m-d H:M:S where Y is 4 chars and all others
222- are 2 chars. Ex. '2020-03-30 19:32:56'.
223- end : str or datetime [optional] : default now
224- End time of data request (UTC). If not supplied defaults to now.
225- vrs : list [optional] : default ['waveHs']
226- A list of the names of variables to retrieve. They all must start
227- with the same prefix, e.g. ['waveHs', 'waveTp', 'waveDp']
228- pub_set: str [optional] values = public|nonpub|all
229- Filters data based on data quality flags.
230- apply_mask: bool [optional] default True
231- Removes values from the masked array that have a mask value of True.
232- Ex. If nonpub data is requested and apply_mask is False, the returned
233- array will contain both public and nonpublic data (although public
234- data records will have the mask value set to True). If apply_mask
235- is set to True, only nonpub records will be returned.
236- target_records: int [optional]
237- If start is specified and end is None, this will specify the number
238- of additional records to return closest to start.
239- force_64bands: bool [optional]
240- For the case in which all spectra returned are mk4 100 band format,
241- force the conversion to 64bands. Mixed formats are always returned in mk3
242- 64 band format.
243- """
258+
244259 if vrs is None :
245260 vrs = self .parameter_vars
246261 prefix = self .get_var_prefix (vrs [0 ])
@@ -363,7 +378,14 @@ def __merge_xyz_helper(
363378 return result , start_stamp
364379
365380 def remove_duplicates (self , data_dict : dict ) -> dict :
366- """Duplicate records may exist after merge_ routines. This removes them."""
381+ """Removes duplicate records after merging multiple datasets.
382+
383+ Args:
384+ data_dict (dict): Dictionary of merged data arrays.
385+
386+ Returns:
387+ dict: Dictionary with duplicate records removed.
388+ """
367389 result = {}
368390 keys = list (data_dict .keys ())
369391 if len (keys ) > 0 :
@@ -505,7 +527,14 @@ def __merge_request(self):
505527 return result
506528
507529 def get_nc_files (self , types : list = nc_file_types ) -> dict :
508- """Returns dict of netCDF4 objects of a station's netcdf files"""
530+ """Returns all available netCDF files for a station.
531+
532+ Args:
533+ types (list, optional): List of file types to include. Defaults to all nc_file_types.
534+
535+ Returns:
536+ dict: Dictionary mapping filenames to netCDF objects.
537+ """
509538 result = {}
510539 for ftype in types :
511540 if ftype == "historic" :
@@ -531,24 +560,15 @@ def get_nc_files(self, types: list = nc_file_types) -> dict:
531560 def get_target_timespan (
532561 self , target_timestamp : int , num_target_records : int , time_var : str
533562 ) -> tuple :
534- """Returns a timespan containing the n closest records to the target_timestamp.
535-
536- PARAMETERS
537- ----------
538- target_timestamp : int
539- A unix timestamp which is the target time about which the closest
540- n records will be returned.
541- n : int
542- The number of records to return that are closest to the target
543- timestamp.
544- time_var : str
545- The name of the time dimension variable to use. E.g. waveTime.
546-
547- RETURNS
548- -------
549- A 2-tuple of timestamps corresponding to i and i+n (where n may
550- be negative) which will be the timestamps for the n records
551- closest to the target_timestamp.
563+ """Finds a timespan containing the n records closest to a target timestamp.
564+
565+ Args:
566+ target_timestamp (int): Target UNIX timestamp.
567+ num_target_records (int): Number of records to return.
568+ time_var (str): Name of time variable (e.g. "waveTime").
569+
570+ Returns:
571+ tuple: (start_timestamp, end_timestamp, direction), or (None, None, None) if not found.
552572 """
553573 r_ok = False
554574 if self .realtime .nc is not None :
0 commit comments