@@ -367,8 +367,13 @@ def _parse_datetime_with_day_ratio(
367367 dayratio = day_with_ratio - day
368368 seconds = dayratio * _SECONDS_IN_DAY
369369 dt_ns = (
370- datetime .datetime (year = int (year ), month = int (month ), day = int (1 ))
371- + datetime .timedelta (days = int (day ), seconds = seconds )
370+ datetime .datetime (
371+ year = int (year ),
372+ month = int (month ),
373+ day = int (day ),
374+ tzinfo = datetime .timezone .utc ,
375+ )
376+ + datetime .timedelta (seconds = seconds )
372377 ).timestamp () * 10 ** 9
373378 values .append (int (dt_ns ))
374379 return np .array (values ).astype ("datetime64[ns]" )
@@ -603,7 +608,39 @@ def to_raggedarray(
603608 use_fill_values : bool = True ,
604609 max_chunks : int | None = None ,
605610) -> xr .Dataset :
606- """Get the GDP source dataset."""
611+ """
612+ Convert GDP source data into a ragged array format and return it as an xarray Dataset.
613+
614+ This function processes drifter data from the NOAA GDP (Global Drifter Program) source,
615+ organizes it into a ragged array format, and returns the resulting dataset. It
616+ supports downloading, filtering, and parallel processing of the data.
617+
618+ Args:
619+ tmp_path (str): Path to the temporary directory for storing downloaded files.
620+ Defaults to `_TMP_PATH`.
621+ skip_download (bool): If True, skips downloading the data and assumes it is
622+ already available in `tmp_path`. Defaults to False.
623+ max (int | None): Maximum number of requests to process for testing purposes.
624+ If None, processes all requests. Defaults to None.
625+ chunk_size (int): Number of observations to process in each chunk. Defaults to 100,000.
626+ use_fill_values (bool): Whether to use fill values for missing data. Defaults to True.
627+ max_chunks (int | None): Maximum number of chunks to process. If None, processes all
628+ chunks. Defaults to None.
629+
630+ Returns:
631+ xr.Dataset: An xarray Dataset containing the processed GDP drifter data in a
632+ ragged array format. The dataset includes both observation and
633+ trajectory metadata variables, with appropriate attributes added.
634+
635+ Raises:
636+ Any exceptions raised during file operations, data processing, or async tasks
637+ will propagate to the caller.
638+
639+ Notes:
640+ - The function performs parallel processing of drifter data using asyncio.
641+ - The resulting dataset is sorted by the start date of each drifter.
642+ - Metadata attributes for variables are added based on predefined mappings.
643+ """
607644
608645 os .makedirs (tmp_path , exist_ok = True )
609646
0 commit comments